/*=========================================================================
* State.h :       Define the engine state structure.
* This is a part of the Game project.
*
* Version                      1.0
* Creation date        09/08/96
* Revision date
*
* That file needs to be compatible for all platforms.
*
* (c) Ubi Studios 1996
*=======================================================================*/
#if !defined(__STATE_H__)
#define __STATE_H__
 
/******************************************/
#if _MSC_VER >= 1000
#pragma once
#endif /* _MSC_VER >= 1000 */
/******************************************/
 
#ifdef  __cplusplus
extern "C" {
#endif
 
 
#include "GAM/Header.h"
 
#include "../PlayAnim/PLA_dbg.h"
 
#define C_ucAllowedState			0
#define C_ucProhibitedState		1
 
/*ANNECY CT 11/02/98{*/
#define C_ucStandardLink      0
#define C_ucProportionalLink  1
/*ENDANNECY CT}*/
 
/***********************/
/**** Handle define ****/
/***********************/
#if defined(D_State_Define)
 
/* structure to determined which transitional state to use*/
typedef struct tdstTransition_   /* maj 15/11 DVD (Gizmo)*/
{
  LST2_M_StaticElementDeclaration(tdxHandleToTransition)
  tdxHandleToState h_TargetState;
  tdxHandleToState h_StateToGo;
/*ANNECY CT 11/02/98{*/
  unsigned char ucLinkingType;   /* C_ucStandardLink or C_ucProportionalLink*/
/*ENDANNECY CT}*/
} tdstTransition;
 
/* structure to determined which states are prohibited*/
typedef struct tdstProhibit_   
{
  LST2_M_StaticElementDeclaration(tdxHandleToProhibit)
  tdxHandleToState h_ProhibitedState;
} tdstProhibit;
 
 
 
typedef struct tdstState_
{
#ifdef _DEBUG_STRING_FOR_PLA_
    char szStateName[LEN_DEBUG_STRING];
#endif
	
	/* Macro to create chain list for State Array */
	LST2_M_StaticElementDeclaration(tdxHandleToState)
		
	/* pointer of the animation for this state in the model's animation array */
	struct tdstAnim3d_ *p_stAnim;
 
	/*
 	 * array of States can be doing in this state
	 * NULL pointer : None
	 */
	LST2_M_StaticAnchorDeclaration(tdxHandleToTransition) hForTransitionArray;
	
	/*
	 * array of States can't be doing in this state
	 * NULL pointer : None
	 */
	LST2_M_StaticAnchorDeclaration(tdxHandleToProhibit) hForProhibitArray;
	
	/*
	 * next state in the automaton when the animation ends
	 */
	tdxHandleToState h_NextState;
	
	/* maj 23/01/97 Sébastien DAVID (Gizmo)*/
	/* dynamic array of unsigned char (length=NumberOfModule) for the moment,*/
	/* in final there will be a bit-field array.*/
	/* unsigned char * d_ucModuleCollsetActivationFlags;*/
	
	DNM_tdxHandleToMecIdentityCard h_LinkedMechanicsIdCard;
		
	/*
	 * How many time the animation must be repeated.
	 * if ucRepeatAnimation = 0, the animation is played 1 time.
	 * if ucRepeatAnimation = 1, the animation is played 2 times.
	 * and so on...
	 */
	unsigned char ucRepeatAnimation; 
	
	/*
	 * animation playback speed in VBLs per frame
	 */
	signed char scSpeedAnim;
	
	
	unsigned char ucTransitionStatusFlag;   /* C_ucAllowedState or C_ucProhibitedState*/
	
/* ANNECY MT - 24/11/98 {*/
	unsigned char ucCustomBits;				/* new	*/
/* END ANNECY MT }*/
} tdstState;
 
#endif /* D_State_Define */
 
/*******************************/
/**** Base functions define ****/
/*******************************/
 
/* ************* STATE *************/
extern CPA_EXPORT unsigned long fn_ulStateSizeOf();
extern CPA_EXPORT tdxHandleToState fn_h_StateAlloc();
extern CPA_EXPORT void fn_h_StateFree(tdxHandleToState h_State);
 
/* ************ Transition ************** */
extern CPA_EXPORT unsigned long fn_ulTransitionSizeOf();
extern CPA_EXPORT tdxHandleToTransition fn_h_TransitionAlloc();
extern CPA_EXPORT void fn_h_TransitionFree(tdxHandleToTransition h_Transition);
/* ************ Prohibited State ************** */
extern CPA_EXPORT unsigned long fn_ulProhibitSizeOf();
extern CPA_EXPORT tdxHandleToProhibit fn_h_ProhibitAlloc();
extern CPA_EXPORT void fn_h_ProhibitFree(tdxHandleToProhibit h_Prohibit);
 
 
/*********************************/
/**** Access functions define ****/
/*********************************/
 
/*################################## STATE #############*/
/* ************ Name *************/
extern CPA_EXPORT char* fn_p_szGetStateName(tdxHandleToState h_State);
/* ************ Anim *************/
extern CPA_EXPORT struct tdstAnim3d_* fn_p_stGetAnimInState(tdxHandleToState h_State);
extern CPA_EXPORT void fn_vSetAnimInState(tdxHandleToState h_State,struct tdstAnim3d_ *p_stAnim);
/********** NextState ************/
extern CPA_EXPORT tdxHandleToState fn_hGetNextStateInState(tdxHandleToState h_State);
extern CPA_EXPORT void fn_vSetNextStateInState(tdxHandleToState h_State,tdxHandleToState h_NextState);
/* ******* RepeatAnimation *******/
extern CPA_EXPORT unsigned char fn_ucGetRepeatAnimationInState(tdxHandleToState h_State);
extern CPA_EXPORT void fn_vSetRepeatAnimationInState(tdxHandleToState h_State,unsigned char ucRepeatAnimation);
/* ******* TransitionStatusFlag *******/
extern CPA_EXPORT unsigned char fn_ucGetTransitionStatusFlagInState(tdxHandleToState h_State);
extern CPA_EXPORT void fn_vSetTransitionStatusFlagInState(tdxHandleToState h_State,unsigned char ucTransitionStatusFlag);
/* ********* SpeedAnim ***********/
extern CPA_EXPORT signed char fn_scGetSpeedInState(tdxHandleToState h_State);
extern CPA_EXPORT void fn_vSetSpeedInState(tdxHandleToState h_State,signed char scSpeedAnim);
/* ******* MechanicsIdCard *******/
extern CPA_EXPORT DNM_tdxHandleToMecIdentityCard fn_hGetStateMechanicsIdCard(tdxHandleToState h_State);
extern CPA_EXPORT void fn_vSetStateMechanicsIdCard(tdxHandleToState h_State,DNM_tdxHandleToMecIdentityCard h_LinkedMechanicsIdCard);
/* ANNECY MT - 24/11/98 {*/
/* ******* CustomBits *******/
extern CPA_EXPORT unsigned char fn_ucGetStateCustomBits(tdxHandleToState h_State);
extern CPA_EXPORT void fn_vSetStateCustomBits(tdxHandleToState h_State,unsigned char ucCustomBits);
/* END ANNECY MT }*/
 
 
/*################################## TRANSITION #############*/
/*********** TargetState *******************/
extern CPA_EXPORT tdxHandleToState fn_hGetTargetStateInTransition(tdxHandleToTransition h_Transition);
extern CPA_EXPORT void fn_vSetTargetStateInTransition(tdxHandleToTransition h_Transition,tdxHandleToState h_TargetState);
/*************** StateToGo *******************/
extern CPA_EXPORT tdxHandleToState fn_hGetStateToGoInTransition(tdxHandleToTransition h_Transition);
extern CPA_EXPORT void fn_vSetStateToGoInTransition(tdxHandleToTransition h_Transition,tdxHandleToState h_StateToGo);
 
/*ANNECY CT 11/02/98{*/
/*************** LinkingType *******************/
extern CPA_EXPORT unsigned char fn_ucGetLinkingTypeInTransition(tdxHandleToTransition h_Transition);
extern CPA_EXPORT void fn_vSetLinkingTypeInTransition(tdxHandleToTransition h_Transition,unsigned char ucLinkingType);
/*ENDANNECY CT}*/
 
extern CPA_EXPORT tdxHandleToState fn_hGetProhibitedStateInProhibit( tdxHandleToProhibit _hProhibit );
extern CPA_EXPORT void fn_vSetProhibitedStateInProhibit( tdxHandleToProhibit _hProhibit, tdxHandleToState _hState );
extern CPA_EXPORT tdxHandleToTransition fn_hGetTransitionalWithTargetState( tdxHandleToState _hState, tdxHandleToState _hTargetState );
 
/*ANNECY CT 11/02/98{*/
/*extern CPA_EXPORT tdxHandleToState fn_hIfExistTransitionalWithTargetState(tdxHandleToState  h_State, tdxHandleToState h_TargetState);*/
extern CPA_EXPORT tdxHandleToTransition fn_hIfExistTransitionalWithTargetState(tdxHandleToState  h_State, tdxHandleToState h_TargetState);
/*ENDANNECY CT}*/
 
extern CPA_EXPORT long fn_hIfExistProhibitedState(tdxHandleToState  h_State, tdxHandleToState h_TargetState);
 
#ifdef  __cplusplus
}/* extern "C" */
#endif
 
 
#endif /* !__STATE_H__ */
