/*=========================================================================
* 
* SECTobj.hpp :  Sector_Object  
* 
*
* Version			1.0
* Creation date		
* Revision date
*
* Shaitan
*=======================================================================*/

#ifndef __SECT_OBJ_HPP__
#define __SECT_OBJ_HPP__

//Shaitan Clean Env
//#include "SECTenv.hpp"
#include "SECTlist.hpp"
//Shaitan Clean Env
//#include "SECTsurf.hpp"

//**************************************
#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
//**************************************

//#################################################################################
// Defines
//#################################################################################

typedef enum
{
	E_NoActiveList	= -1,
	E_Graphic		= 0,
	E_Collision		= 1,
	E_Activity		= 2,
	E_Sound			= 3,
	E_SoundEvent	= 4
}
tdeTypeList;

#define C_NumberOfLists 5

#define C_szSectorBorderSubSection "Border"

/*===========================================================================
*		Description:	class Sector_Object
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                      Author:         
*=========================================================================*/

class Sector_Object :	public CPA_SaveObject,
						public CPA_EdMot<SECT_tdxHandleOfSectorObject>
					
{
protected:
	
	// links
	SECT_CollisionList	m_oCollisionList;
	SECT_ActivityList	m_oActivityList;
	SECT_GraphicList	m_oGraphicList;
	SECT_SoundList		m_oSoundList;
	SECT_SoundEventList m_oSoundEventList;

//Shaitan Clean Env
/*
	// env & srf
	SECT_SurfaceList	 m_oSurfaceList;
	SECT_EnvironmentList m_oEnvironmentList;
	long				 m_lNbEnvironments;
	long				 m_lNbSurfaces;
*/
	// sub-sections
	BOOL				 m_bHasSectorsLinkSection;
//Shaitan Clean Env
//	BOOL				 m_bHasEnvAndSurfSection;
	
	// super-object
	CPA_SuperObject		*m_pSuperObject;
	BOOL				 m_bWasRenamed;

	CPA_SuperObject		*m_pBorder;
	CPA_SectionObject	*m_pBorderSection;

	SECT_ElementBase	*m_pVirtualSection;
	SECT_ElementBase	*m_pCameraSection;
	SECT_ElementBase	*m_pPrioritySection;

	void fn_vInitEngineAnchors (void);

public:
	Sector_Object  (CPA_ObjectDLLBase *p_oDLL,
					SECT_tdxHandleOfSectorObject hObj,
					CString csName = "", CString csFileName = "");
	~Sector_Object (void);

// inits
	static void StaticInit();

// return Data
    virtual long   GetDataType	(void)  { return HIE_C_ulSector; }
    virtual void * GetData		(void)  { return GetStruct(); }

// engine struct
	void *GetEngineStruct() { return GetStruct(); }
	void SetEngineStruct (SECT_tdxHandleOfSectorObject hObj);

// super-object
	CPA_SuperObject * GetSuperObject (void)						{ return m_pSuperObject; }
	void			  SetSuperObject (CPA_SuperObject *pSupObj) { m_pSuperObject = pSupObj; }

	// border
	CPA_SuperObject	  * GetBorder		  (void) { return m_pBorder; }
	CPA_SectionObject * GetBorderSection  (void) { return m_pBorderSection; }

	MTH_tdxReal		  GetZmaxOfSector (void);
	MTH_tdxReal		  GetZmaxOfBorder (void);
	void			  SetZmaxOfBorder (MTH_tdxReal xNewZmax);

	void			  GetMinPointInBorder (MTH3D_tdstVector *p_stMinPoint);
	void			  GetMaxPointInBorder (MTH3D_tdstVector *p_stMaxPoint);
	void			  GetCenterInBorder   (MTH3D_tdstVector *p_stCenter);
	MTH_tdxReal		  GetMaxDimension	  (void);

	// Zfar
	MTH_tdxReal		  GetZfarInSector (void);
	void			  SetZfarInSector (MTH_tdxReal xNewZfar);
	// virtual
	SECT_ElementBase * GetVirtualSection  (void) { return m_pVirtualSection; }
	SECT_ElementBase * GetCameraSection  (void) { return m_pCameraSection; }
	SECT_ElementBase * GetPrioritySection  (void) { return m_pPrioritySection; }

// interface
	Sector_Interface * GetSectorInterface (void) { return (Sector_Interface *)GetEditor(); }

// lists
	SECT_SoundEventList  * GetSoundEventList	(void)	{ return &m_oSoundEventList; }
	SECT_CollisionList	 * GetCollisionList		(void)	{ return &m_oCollisionList; }
	SECT_ActivityList	 * GetActivityList		(void)	{ return &m_oActivityList; }
	SECT_GraphicList	 * GetGraphicList		(void)	{ return &m_oGraphicList; }
	SECT_SoundList		 * GetSoundList			(void)	{ return &m_oSoundList; }

//Shaitan Clean Env
/*
	SECT_EnvironmentList * GetEnvironmentList	(void)	{ return &m_oEnvironmentList; }
	SECT_SurfaceList	 * GetSurfaceList		(void)	{ return &m_oSurfaceList; }

	long				   GetNbEnvironments	(void)	{ return m_lNbEnvironments; }
	long				   GetNbSurfaces		(void)	{ return m_lNbSurfaces; }
*/

// inits
	void fn_vInitSortedLists	(void);
//Shaitan Clean Env
//	void fn_vInitEnvironments	(void);
//	void fn_vInitSurfaces		(void);
	void fn_vInitBorder			(void);
	
// virtual or gothrough
	BOOL fn_bIsVirtual	(void);
	void fn_vSetVirtual	(BOOL bVirtual, CPA_SuperObject *pBorder = NULL);
	
// sector links
	BOOL fn_bAddSectorInList	(SECT_ElementBase *pNewElem, tdeTypeList eType);
	BOOL fn_bRemoveSectorInList (SECT_ElementBase *pOldElem, tdeTypeList eType);

	SECT_ListBase	 * GetCurrentList (tdeTypeList eType);
	SECT_ElementBase * GetNewElement  (tdeTypeList eType, CPA_SuperObject *pSector);

	BOOL fn_bHasFullLink (tdeTypeList eType);

//Shaitan Clean Env
/*
// environment element
	BOOL fn_bAddEnvironmentElement (SECT_EnvElem *pEnvElem, SECT_SurfElem *pSurfElem);
	BOOL fn_bDelEnvironmentElement (SECT_EnvElem *pEnvElem, SECT_SurfElem *pSurfElem);

	SECT_EnvElem	 * GetEnvironment (long lNumEnv);
	SECT_SurfElem	 * GetSurface	  (long lNumSurf);

	long fn_lUpdateEnvironmentElement (long lNumEnvElem);
	void fn_vApplySameEnvironment	  (CPA_List<SECT_Environment> *pListEnv, CPA_List<SECT_Surface> *pListSrf);
*/

// save
    BOOL fn_bHasSectorsLinkSection	(void) { return m_bHasSectorsLinkSection; }
//Shaitan Clean Env
//	BOOL fn_bHasEnvAndSurfSection	(void) { return m_bHasEnvAndSurfSection; }

	void SetExistingSectorsLinkSection	(BOOL bExist) { m_bHasSectorsLinkSection = bExist; }
//Shaitan Clean Env
//    void SetExistingEnvAndSurfSection	(BOOL bExist) { m_bHasEnvAndSurfSection = bExist; }

	CString GetSectorsLinkSection	(void);
//Shaitan Clean Env
//	CString GetEnvAndSurfSection	(void);

	static void CallBackSaveName (SCR_tdst_File_Description *p_stFile, char *szSectionName, void *p_vData, SCR_tde_Ntfy_Action eAction);

// border
	CString GetSectorBorderSection		(void);
	void	fn_vNotifyBorderSection		(BOOL bWrite);

	static void CallBackSaveSectorBorder (SCR_tdst_File_Description *p_stFile, char *szSectionName, void *p_vData, SCR_tde_Ntfy_Action eAction);

	char GetCameraType (void);
	void SetCameraType (char cType);

	char GetPriority (void);
	void SetPriority (char cPriority);
};



#endif //__SECT_OBJ_HPP__
