/* (c) Ubi Studios 1996*/
/*/////////////////////////////////*/
 
#ifndef __ACTOR_OBJECT_HPP__
#define __ACTOR_OBJECT_HPP__
 
#if _MSC_VER >= 1000
#pragma once
#endif /* _MSC_VER >= 1000*/
 
#ifdef _ACTORS_DLL_
	#ifdef CPA_WANTS_IMPORT
	#pragma message("========================================================")
	#pragma message("== WARNING ! You are importing the ACTOR object class ==")
	#pragma message("========================================================")
	#endif	/*CPA_WANTS_IMPORT*/
#endif /*_ACTORS_DLL_*/
 
/****************************************/
#ifndef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
#endif
/****************************************/
 
/*BEGIN ROMTEAM Cristi Petrescu 98-05-*/
/* For "IncAI.h" !!*/
#include "ACP_Base.h"
#include "IncAI.h"
/* End For "IncAI.h" !!*/
/*END ROMTEAM Cristi Petrescu 98-05-*/
 
typedef tdstEngineObject * EdActors_tdhHandleToActor;	
 
class CTL_Editor_EnumDescriptor;
class EditorObjectTable;
class EdActors_EditorActor;
class EdActors_EditorActorModel;
class EdActors_EditorActorInstance;
class CPA_Family;
class CPA_SuperObject;
class CPA_State;
class CPA_Action;
class CPA_tdoNameList;
/*BEGIN ROMTEAM Cristi Petrescu 98-05-*/
class CPA_EdIR_DebugInfo;
/*END ROMTEAM Cristi Petrescu 98-05-*/
 
class CPA_EXPORT CPA_Actor :	public CPA_SaveObject,
															public CPA_EdMot<EdActors_tdhHandleToActor>
{
 
public:
	/*Normal constructor*/
	CPA_Actor(EdActors_tdhHandleToActor hObj,
						EdActors_EditorActor *pclEditorActor,
						CString csType,
						CPA_Actor *pclBaseModel = NULL,
						CPA_Family *pclBaseFamily = NULL,
						CPA_SuperObject *_p_oSuperObject = NULL,
						CString csName = "",
						BOOL _bActorIsAvailable = TRUE);
 
	/*Copy constructor*/
	CPA_Actor(CPA_Actor *_pclSourceActor,
						CPA_SuperObject *_p_oSuperObject,
						CString _csName);
 
	~CPA_Actor();
 
	void SetEngineStruct(EdActors_tdhHandleToActor);
 
	static void StaticInit();
 
/*Attributes*/
public:
 
protected:
 
private:
	EdActors_EditorActor *m_pclEditorActor;
 
	BOOL m_bDisplayZone;
 
	CString m_csFamilyName;
 
	BOOL m_bIsAnAlways;
 
	BOOL m_bIsAGenDoor;
 
	BOOL m_pri_bIsAlwaysActive;
 
/* ANNECY MT - 19/11/98 {*/
	BOOL m_pri_bIsInAllSubMaps;
/* END ANNECY MT }*/
 
	/*A (keeped) pointer on the SO isolated before engine mode*/
	/*Only useful for GenDoors type Actors*/
	/*This So is child of the Actor*/
	CPA_SuperObject *m_pclIsolatedSuperObject;
	
	/*This SO represents the Actro in the Hierarchy*/
	CPA_SuperObject *m_pclSuperObject;
 
	/*The Current Object Table*/
	EditorObjectTable *m_pri_pclCurrentObjectTable;
	
	/*The Initial Object Table*/
	EditorObjectTable *m_pri_pclInitialObjectTable;
 
	/*The Current Action*/
	CPA_Action *m_pri_pclCurrentAction;
	
	/*The Initial Action*/
	CPA_Action *m_pri_pclInitialAction;
 
	/*The Current State*/
	CPA_State *m_pri_pclCurrentState;
	
	/*The Initial State*/
	CPA_State *m_pri_pclInitialState;
 
	/*The Family of the Actor*/
	CPA_Family *m_pri_pclFamily;
 
	/*Indicates whether the Actor is an Instance (TRUE) or a Model (FALSE)*/
	BOOL m_bIsAnInstance;
 
	/*Internal Object, used to notify the file (and not the section)*/
	CPA_SectionObject *m_pclSectionSubObject;
 
	/*Indicates whether the Actor must be saved in "_Common" directory, or in Level*/
	BOOL m_pri_bIsCommon;
 
	/*Indicates whether the Actor must be saved in "Game.fix" file*/
	BOOL m_pri_bIsInFix;
 
	/*Indicates whether this Actor must be saved or not*/
	BOOL m_pri_bHasBeenModified;
 
	/*CPA2 Stegaru Cristian 98-06*/
	/*hide variable option*/
	BOOL m_bHideVariable;
	static CString m_csINIFileName;
	static CString m_csHideVariableSection;
	BOOL m_bCheckZonesAgainstBV;
	/*End CPA2 Stegaru Cristian 98-06*/
 
/*Functions*/
public:
/*//////////////////////////////////////////////////////////////*/
/*										PUBLIC FUNCTIONS												//*/
/*//////////////////////////////////////////////////////////////*/
	/*Returns the Model of the Actor(or NULL if the Actor is a Model)*/
	CPA_Actor *m_fn_pclGetModel();
 
	/*Returns TRUE if the Actor is an Instance, else returns FALSE*/
	BOOL m_fn_bIsAnInstance();
	/*Returns TRUE if the Actor is a Model, else returns FALSE*/
	BOOL m_fn_bIsAModel();
 
	/*Returns the Editor's Actor (a priori, not needed out of Actors DLL)*/
	void m_fn_vSetEditorActor(EdActors_EditorActor *);
	EdActors_EditorActor *m_fn_pclGetEditorActor();
	EdActors_EditorActorModel *m_fn_pclGetEditorModel();
	EdActors_EditorActorInstance *m_fn_pclGetEditorInstance();
 
	/*To set a new name for an Actor*/
	BOOL m_fn_bRename(CString csNewName);
 
	/*To finish loading a Model*/
	void m_fn_vFinishLoading();
 
	/**/
	CString m_fn_csGetFamilyName();
	void m_fn_vSetFamilyName(CString csNewFamilyName);
 
	/**/
	void m_fn_vMakeAlways(BOOL bIsAnAlways = TRUE);
	BOOL m_fn_bIsAnAlways();
	BOOL m_fn_bCanBeAnAlways();
 
	/*Get/Set for pointer on the SO isolated before engine mode*/
	/*Only useful for GenDoors type Actors*/
	CPA_SuperObject *m_fn_pclGetIsolatedSuperObject();
	void m_fn_vSetIsolatedSuperObject(CPA_SuperObject *);
 
	/*Gen Doors*/
	void m_fn_vMakeGenDoor(BOOL bIsAGenDoor = TRUE);
	BOOL m_fn_bIsAGenDoor();
 
	/*Always active*/
	BOOL m_pub_fn_bIsAlwaysActive();
	void m_pub_fn_vSetAlwaysActive(BOOL _bAlwaysActive, BOOL _bIsLoading = FALSE);
 
	/*In All SubMaps*/
	BOOL m_pub_fn_bIsInAllSubMaps();
	void m_pub_fn_vSetInAllSubMaps(BOOL _bInAllSubMaps, BOOL _bIsLoading = FALSE);
 
	/*To get the Motor status of Actors*/
	BOOL m_fn_bIsTheCurrentMotorCamera();
	BOOL m_fn_bIsAPrincipalActor();
	/*BOOL m_fn_bIsTheWorldActor();*/
 
	/*To add childs to an Actor, according to its status*/
	void m_pub_fn_vAddChildsFromEngineChilds();
	void m_pub_fn_vAddChildsForGenDoors();
	/*To remove editor childs*/
	void m_pub_fn_vRemoveAllEditorChilds();
	/*To compare the two hierarchies (motor and editor) when back from motor mode*/
	/* returns TRUE only if hierarchies are the same*/
	BOOL m_pub_fn_bCompareEditorAndMotorChilds();
 
	/*To handle the Object Tables of an Actor*/
	CTL_Editor_EnumDescriptor *m_pub_fn_pclGetEnumDescriptorForObjectsTables();
	void m_pub_fn_vConstructEnumDescriptorForObjectsTables();
 
	/*Object Tables*/
	EditorObjectTable *m_pub_fn_pclGetCurrentObjectTable();
	void m_pub_fn_vSetCurrentObjectTable(EditorObjectTable *);
	EditorObjectTable *m_pub_fn_pclGetInitialObjectTable();
	void m_pub_fn_vSetInitialObjectTable(EditorObjectTable *);
	
	void m_pub_fn_vUpdateObjectTablesList(EditorObjectTable *pclOT = NULL);
 
	/*Action*/
	CPA_Action *m_pub_fn_pclGetCurrentAction();
	void m_pub_fn_vSetCurrentAction(CPA_Action *);
	CPA_Action *m_pub_fn_pclGetInitialAction();
	void m_pub_fn_vSetInitialAction(CPA_Action *);
 
	/*State*/
	CPA_State *m_pub_fn_pclGetCurrentState();
	void m_pub_fn_vSetCurrentState(CPA_State *);
	CPA_State *m_pub_fn_pclGetInitialState();
	void m_pub_fn_vSetInitialState(	CPA_State *,
																	BOOL _bMustNotifyLevel = FALSE);
 
	/*To get Motor and Editor SuperObjects*/
	HIE_tdxHandleToSuperObject m_pub_fn_hGetMotorSuperObject();
	CPA_SuperObject *m_pub_fn_pclGetSuperObject();
	void m_pub_fn_vSetSuperObject(CPA_SuperObject *);
 
	/*To get/set the Family*/
	/*Returns the Family of the Actor (Model or Instance)*/
	CPA_Family *m_pub_fn_pclGetFamily();
	void m_pub_fn_vSetFamily(CPA_Family *pclNewFamily);
 
	/*For a Model, indicates wether it can be instantiated or not*/
	BOOL m_pub_fn_bCanBeInstantiated();
 
	/**/
	BOOL m_pub_fn_bIsCommon();
	void m_pub_fn_vSetCommon(	BOOL _bCommon = TRUE,
														BOOL _bIsLoading = FALSE);
 
	/**/
	BOOL m_pub_fn_bIsInFix();
	void m_pub_fn_vSetInFix(	BOOL _bIsInFix = TRUE,
														BOOL _bIsLoading = FALSE);
 
	/*Indicates whether this Actor must be saved or not*/
	BOOL m_pub_fn_bHasBeenModified();
 
	/*To re-init the Actor as if it was in its intial state*/
	void m_pub_fn_vReInitActor();
 
	/*Returns the number of Instances of a Model, and -1 for an Instance*/
	long m_pub_fn_lGetNumberOfInstances();
 
	/*Checks Model before Instanciation*/
	BOOL m_pub_fn_bCheckModelForInstanciation();
 
/*	//Returns the name of a Designer Variable, knowing its ID
	// ... For IAD ...
	CString m_pub_fn_csGetDsgVarNameFromID(long _lID);
 
	//Displays the IA editor with the good behaviour
	// ... For IAD ...
	void		m_pub_fn_vShowBehaviour(struct tdstNodeInterpret_ *_pstNode);*/
 
	/*BEGIN ROMTEAM Cristi Petrescu 98-05-*/
	/*CPA_EdIR_DebugInfo *m_fn_pGetDebugInfo (tdstNodeInterpret *_pstNode);*/
	/* initialize the debugger*/
	void	m_fn_vMustBuildDebugInfo (BOOL);
	/* for building behaviour nodes*/
	CString m_fn_csGetBehaviourName (tdstNodeInterpret *);
	/* for diplaying in the IA window the executed code*/
	/*void	m_fn_vStartExecutedCodeDisplay (CString);*/
	/*void	m_fn_vStopExecutedCodeDisplay (CString);*/
	void	m_fn_vClearExecutedNodes (CString);
	void	m_fn_vSetOneExecutedNode (tdstNodeInterpret *);
	void	m_fn_vShowBehaviour (struct tdstNodeInterpret_ *);
	void	m_fn_vShowBehaviour (CString);
	/*END ROMTEAM Cristi Petrescu 98-05-*/
 
	/*Get ???*/
	/*For TIA*/
	CPA_tdoNameList *m_pub_fn_pclGetNameList(CString _csName);
 
	/*CPA2 Stegaru Cristian 98-06*/
	BOOL mfn_bIsHideVarChecked ();
	void mfn_vCheckHideVar (BOOL bHideVar); 
	static CString mfn_csGetINIFileName () { return m_csINIFileName;}
	BOOL mfn_bSet_CheckZonesAgainstBV (BOOL bCheck) { return m_bCheckZonesAgainstBV = bCheck;}
	BOOL mfn_bGet_CheckZonesAgainstBV () { return m_bCheckZonesAgainstBV;}
	/*End CPA2 Stegaru Cristian 98-06*/
 
  /*SHAITAN*/
  void mfn_vUpdateAIModel (AI_tdstAIModel *p_stAIModel);
  void mfn_vUpdateAllInstancesForFastC (void);
  /*SHAITAN*/
/*//////////////////////////////////////////////////////////////*/
/*								end of PUBLIC FUNCTIONS											//*/
/*//////////////////////////////////////////////////////////////*/
 
public:
	/*Virtual Functions*/
	virtual long GetDataType(void);
	virtual void *GetData(void);
 
	virtual void fn_vNotifySave(void);
	virtual void fn_vNotifyUnSave(void);
	virtual void fn_vNotifyRestore(void);
	virtual void fn_vNotifyRename(void);
 
	/*CPA2 Stegaru Cristian 98-06*/
	virtual tdeMissingCriteria fn_eCheckValidity (const CString csNewName);
	/*End CPA2 Stegaru Cristian 98-06*/
 
	virtual CString fn_csComputeReferencedSectionName(const CString csNewName);
 
	/*Specific Functions*/
	static void s_m_fn_vCallBackSaveActor(SCR_tdst_File_Description *_p_stFile,
																				char *_p_szSectionName,
																				void *_p_vData,
																				SCR_tde_Ntfy_Action _eAction);
 
	BOOL GetDisplayZone() {return m_bDisplayZone;};
	void SetDisplayZone(BOOL _bDisplayZone) {m_bDisplayZone = _bDisplayZone;};
 
	BOOL m_pub_fn_bCanBeRenamed();
 
/* Shaitan Correction {*/
	void fn_vSetExistingSectionSubObject (BOOL bExist);
/*End Shaitan Correction }*/
 
	void m_fn_vSetModelDefaultValues (void);
 
protected:
 
private:
	CString m_pri_fn_csComputeReferencedSectionName(CString csName = "",
																									CPA_Family *pclFamily = NULL);
	CString m_pri_fn_csComputeCompleteSectionName(CString csName = "",
																								CPA_Family *pclFamily = NULL);
 
 	CString m_pri_fn_csComputeCompleteFileName(void);
 	CString m_pri_fn_csComputeReferencedFileName(void);
 
 
 
	/*To build (recursively) the hierarchy of Modules childs for the Actor*/
	void m_pri_fn_vBuildChildOfOneLevel(CPA_SuperObject *_pclEditorSoFather);
	/*To remove (recursively) editor childs of one SuperObject*/
	void m_pri_fn_vRemoveAllChildsForOneSO(CPA_SuperObject *_pclEditorSoFather);
	/*To compare (recursively) editor and motor childs of ONE SuperObject*/
	BOOL m_pri_fn_bCompareOneLevelOfEditorAndMotorChilds(CPA_SuperObject *_pclFatherSO);
 
	/*CPA2 Stegaru Cristian 98-06*/
	void mfn_vSaveToINI ();
	void mfn_vLoadFromINI ();
	/*End CPA2 Stegaru Cristian 98-06*/
 
};
 
class EdActors_MyDocument;
 
class CPA_MakeAlways : public CPA_Modif
{
private:	
	EdActors_MyDocument *m_pDocument;
	CPA_List<CPA_Actor>	 m_lstActors;
	BOOL				 m_bMakeAlways;
/* CPA2 ASilvescu 98-04-24*/
	BOOL m_bIsCommon;
/* End CPA2 ASilvescu 98-04-24*/
 
public:
	CPA_MakeAlways (EdActors_MyDocument *pDocument, CPA_List<CPA_SuperObject> *pSOActors, BOOL bMakeAlways);
	CPA_MakeAlways (EdActors_MyDocument *pDocument, CPA_Actor *pActor, BOOL bMakeAlways);
	~CPA_MakeAlways (void);
 
	BOOL Do (void);
	BOOL Undo (void);
};
 
 
#endif /*__ACTOR_OBJECT*/
