/*=========================================================================
* Brain.h : Brain's functions
*
*
*         Brain MUST BE REPLACE BY THE HEADER FILENAME
*
*
* Version              1.0
* Creation date        01/10/96
* Revision date
*
* That file needs to be compatible for all platforms.
*
* (c) Ubi Studios 1996
*=======================================================================*/
 
#if !defined(__Brain_H__)
#define __Brain_H__
 
/******************************************/
#if _MSC_VER >= 1000
#pragma once
#endif /* _MSC_VER >= 1000 */
/******************************************/
 
#include "GAM/Header.h"
 
#undef EXTERN
#undef extern
#if !defined(D_Brain_VariableDefine)
#define EXTERN extern
#else
#define EXTERN
#endif /* D_Brain_VariableDefine */
 
#if defined(__cplusplus)
extern "C"
{
#endif /* __cplusplus */
 
/********************************************************************************/
/**** If we are int StdGame.c file, then, create the structures and variables ****/
/********************************************************************************/
/*#if defined(D_Brain_StructureDefine)*/
struct tdstBrain_
{
	struct AI_tdstMind_				*p_stMind;
	GMT_tdxHandleToGameMaterial		hLastCollidedGoThroughMaterial;
	ACP_tdxBool						bWarnMechanicsFlag;
};
/*#endif /* D_Brain_StructureDefine   */
 
/***********************/
/**** Handle define ****/
/***********************/
typedef struct tdstBrain_ * MS_tdxHandleToBrain;
 
 
#define M_pstGetMindOfBrain(h_Brain) fn_p_stBrainGetMind(h_Brain)
#define M_SetMindOfBrain(h_Brain, p_stM) fn_vBrainSetMind((h_Brain),(p_stM))
/*ANNECY BBB 24/11/97 {*/
#define M_hGetLastCollidedGoThroughMaterialOfBrain(h_Brain) fn_hBrainGetLastCollidedGoThroughMaterial(h_Brain)
#define M_vSetLastCollidedGoThroughMaterialOfBrain(h_Brain, hGameMaterial) fn_vBrainSetLastCollidedGoThroughMaterial((h_Brain),(hGameMaterial))
/*#define M_bGetWarnMechanicsFlagOfBrain(h_Brain) fn_bBrainGetWarnMechanicsFlag(h_Brain)*/
#define M_vSetWarnMechanicsFlagOfBrain(h_Brain, bFlag) fn_vBrainSetWarnMechanicsFlag((h_Brain),(bFlag))
/*ENDANNECY BBB 24/11/97 }*/
 
#define AI_M_stGetMindOfSuperObj(hSupObj) ((AI_tdstMind *)fn_p_stBrainGetMind(M_GetMSHandle((hSupObj), Brain)))
 
/**** Brain scripts ****/
#define C_SectionBrainDescription                "Brain"
 
/*******************************/
/**** Base functions define ****/
/*******************************/
#if !defined(U64)
extern CPA_EXPORT SCR_tde_Anl_ReturnValue fn_eBrainScriptCallBack(SCR_tdst_File_Description *_p_stFile,char *_p_szName,char *_ap_szParams[],SCR_tde_Anl_Action	_eAction);
#endif /* U64 */
/*extern CPA_EXPORT void fn_vBrainSaveMiniStructure(SCR_tdst_File_Description *p_stFile,struct tdstEngineObject_ *p_stObject);*/
extern CPA_EXPORT unsigned long fn_ulBrainSizeOf();
extern CPA_EXPORT void fn_vBrainAlloc(struct tdstEngineObject_ *p_stObject);
extern CPA_EXPORT MS_tdxHandleToBrain fn_h_BrainRealAlloc();
extern CPA_EXPORT void fn_vBrainFree(struct tdstEngineObject_ *p_stObject);
extern CPA_EXPORT void fn_vBrainInit(struct tdstEngineObject_ *p_stObject,enum tdeObjectTreeInit_ eObjectInit);
extern CPA_EXPORT void fn_vBrainDesinit(struct tdstEngineObject_ *p_stObject,enum tdeObjectTreeInit_ eObjectInit);
extern CPA_EXPORT void fn_vBrainCopyClone(struct tdstEngineObject_ * _p_stObjectDest,struct tdstEngineObject_ * _p_stObjectSrc);
 
/********************************/
/**** Acces functions define ****/
/********************************/
/*extern CPA_EXPORT struct AI_tdstMind_ *fn_p_stBrainGetMind(MS_tdxHandleToBrain h_Brain);*/
/*extern CPA_EXPORT void fn_vBrainSetMind(MS_tdxHandleToBrain h_Brain,struct AI_tdstMind_ *p_stMind);*/
/*ANNECY BBB 24/11/97 {*/
/*extern CPA_EXPORT GMT_tdxHandleToGameMaterial fn_hBrainGetLastCollidedGoThroughMaterial(MS_tdxHandleToBrain h_Brain);*/
/*extern CPA_EXPORT void fn_vBrainSetLastCollidedGoThroughMaterial(MS_tdxHandleToBrain h_Brain, GMT_tdxHandleToGameMaterial _hGameMaterial);*/
/*extern CPA_EXPORT ACP_tdxBool fn_bBrainGetWarnMechanicsFlag(MS_tdxHandleToBrain h_Brain);*/
/*extern CPA_EXPORT void fn_vBrainSetWarnMechanicsFlag(MS_tdxHandleToBrain h_Brain, ACP_tdxBool _bFlag);*/
/*ENDANNECY BBB 24/11/97 }*/
 
/**********************************/
/**** Special functions define ****/
/**********************************/
extern CPA_EXPORT void fn_vFirstInitBrain(MS_tdxHandleToBrain h_Brain);
 
 
 
 
#ifdef BIN_SaveBin
extern CPA_EXPORT unsigned long Brain_fn_ulWriteBinaryBloc(unsigned long _ulStructAddress, char* _p_cDestBuffer,struct tdstEngineObject_* _hEngObj);
#endif
 
/*NZO 25/09/97*/
#ifdef BIN_LoadBin
extern CPA_EXPORT void Brain_fn_vReadBinaryBloc(unsigned long _ulStructAddress, char* _p_cDestBuffer,struct tdstEngineObject_* _hEngObj);
#endif
 
 
/*ANNECY jt {*/
#define fn_bBrainWaterCollideSO(hSupObj)	fn_bBrainGetWarnMechanicsFlag(M_GetMSHandle(hSupObj,Brain));
/*extern CPA_EXPORT ACP_tdxBool fn_bBrainWaterCollideSO (HIE_tdxHandleToSuperObject hSupObj);*/
/*ENDANNECY jt }*/
 
 
 
/* inline functions that have moved from the BRAIN.C file.*/
INLINE
struct AI_tdstMind_ *fn_p_stBrainGetMind(MS_tdxHandleToBrain h_Brain)
{
	return(h_Brain->p_stMind);
}
INLINE
void fn_vBrainSetMind(MS_tdxHandleToBrain h_Brain,struct AI_tdstMind_ *p_stMind)
{
	h_Brain->p_stMind=p_stMind;
}
 
INLINE
GMT_tdxHandleToGameMaterial fn_hBrainGetLastCollidedGoThroughMaterial(MS_tdxHandleToBrain h_Brain)
{
	return h_Brain->hLastCollidedGoThroughMaterial;
}
INLINE
void fn_vBrainSetLastCollidedGoThroughMaterial(MS_tdxHandleToBrain h_Brain, GMT_tdxHandleToGameMaterial _hGameMaterial)
{
	h_Brain->hLastCollidedGoThroughMaterial = _hGameMaterial;
}
INLINE
ACP_tdxBool fn_bBrainGetWarnMechanicsFlag(MS_tdxHandleToBrain h_Brain)
{
	return h_Brain->bWarnMechanicsFlag;
}
INLINE
void fn_vBrainSetWarnMechanicsFlag(MS_tdxHandleToBrain h_Brain, ACP_tdxBool _bFlag)
{
	h_Brain->bWarnMechanicsFlag = _bFlag;
}
 
 
/* this function has been replaced (with a define) by the fn_bBrainGetWarnMechanicsFlag*/
/*INLINE
CPA_EXPORT ACP_tdxBool fn_bBrainWaterCollideSO (HIE_tdxHandleToSuperObject hSupObj)
{
	return M_bGetWarnMechanicsFlagOfBrain (M_GetMSHandle(hSupObj,Brain));
}
*/
 
 
 
 
 
 
#if defined(__cplusplus)
}
#endif /* __cplusplus */
 
#endif /* __Brain_H__ */
