"L. Spiro Engine"

F:/My Projects/LSEngine/Modules/LSEngine/Src/States/LSEStateMachine.h

00001 
00027 #ifndef __LSE_STATEMACHINE_H__
00028 #define __LSE_STATEMACHINE_H__
00029 
00030 #include "../LSEEngine.h"
00031 //#include "../Mesh/LSECore3dModel.h"
00032 //#include "../Sound/LSECoreSoundManager.h"
00033 #include "LSEState.h"
00034 #include "Vector/LSTLVectorPoD.h"
00035 
00036 namespace lse {
00037         // We need to know about the game class because states need to know about the game class.
00038         // But it is just for passing down, so the circular dependency is rather minor.
00039         class CGame;
00040 
00046         class CStateMachine {
00047         public :
00048                 // == Various constructors.
00049                 LSE_INLINE LSE_CALL                                     CStateMachine();
00050 
00051 
00052                 // == Functions.
00064                 LSBOOL LSE_CALL                                         SetState( CState * _psState, CGame * _pgGame, LSINT32 _ui32State, LSINT32 _ui32PrevState, LSUINTPTR _uptrUser,
00065                         LSUINT32 _ui32AllocCutOff );
00066 
00072                 LSE_INLINE CState * LSE_CALL            GetCurState();
00073                 
00079                 LSE_INLINE const CState * LSE_CALL      GetCurState() const;
00080 
00086                 LSE_INLINE CState * LSE_CALL            GetCurTopState();
00087 
00093                 LSE_INLINE LSUINT32 LSE_CALL            GetCurStateId() const;
00094 
00100                 LSE_INLINE LSUINT32 LSE_CALL            GetTopStateId() const;
00101 
00107                 LSE_INLINE LSUINT32 LSE_CALL            GetTotalStates() const;
00108 
00116                 LSBOOL LSE_CALL                                         Tick( CGame * _pgGame );
00117 
00126                 LSBOOL LSE_CALL                                         Draw( CGame * _pgGame );
00127 
00136                 LSVOID LSE_CALL                                         IssueSoundEvent( CGame * _pgGame,
00137                         CSoundSource * _pssSource,
00138                         LSUINT32 _ui32EventType, CSoundManagerEx * _psmManager );
00139 
00140 
00141         protected :
00142                 // == Members.
00147                 LSUINT32                                                        m_ui32AllocNumber;
00148 
00152                 CVectorPoD<CState *, LSUINT16, 2UL>     m_vCurStates;
00153 
00154 
00162                 LSBOOL LSE_CALL                                         PopAllStates( CGame * _pgGame, LSINT32 _ui32NextState );
00163         };
00164 
00165 
00166         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00167         // DEFINITIONS
00168         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00169         // == Various constructors.
00170         LSE_INLINE LSE_CALL CStateMachine::CStateMachine() :
00171                 m_ui32AllocNumber( 0UL ) {
00172         }
00173 
00174         // == Functions.
00180         LSE_INLINE CState * CStateMachine::GetCurState() {
00181                 if ( !m_vCurStates.Length() ) { return NULL; }
00182                 return m_vCurStates[0];
00183         }
00184         
00190         LSE_INLINE const CState * LSE_CALL CStateMachine::GetCurState() const {
00191                 if ( !m_vCurStates.Length() ) { return NULL; }
00192                 return m_vCurStates[0];
00193         }
00194 
00200         LSE_INLINE CState * CStateMachine::GetCurTopState() {
00201                 if ( !m_vCurStates.Length() ) { return NULL; }
00202                 return m_vCurStates[m_vCurStates.Length()-1];
00203         }
00204 
00210         LSE_INLINE LSUINT32 LSE_CALL CStateMachine::GetCurStateId() const {
00211                 if ( !m_vCurStates.Length() ) { return static_cast<LSUINT32>(LSE_GS_INVALID); }
00212                 return m_vCurStates[0]->m_ui32StateId;
00213         }
00214 
00220         LSE_INLINE LSUINT32 LSE_CALL CStateMachine::GetTopStateId() const {
00221                 if ( !m_vCurStates.Length() ) { return static_cast<LSUINT32>(LSE_GS_INVALID); }
00222                 return m_vCurStates[m_vCurStates.Length()-1]->m_ui32StateId;
00223         }
00224 
00230         LSE_INLINE LSUINT32 LSE_CALL CStateMachine::GetTotalStates() const {
00231                 return m_vCurStates.Length();
00232         }
00233 
00234 }       // namespace lse
00235 
00236 #endif  // __LSE_STATEMACHINE_H__
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator