00001 // ///////////////////////////////////////////////////////////////////////////// 00002 // 00003 // Name: GameState.h 00004 // Author: Michael Bartsch (ZCCdark203) 00005 // 00006 // Desc : Declaration of the GameState class. 00007 // 00008 // License: Copyright (C) 2009 Michael Bartsch and Contributors 00009 // 00010 // This program is free software: you can redistribute it 00011 // and/or modify it under the terms of the zlib/libpng License. 00012 // See main.cpp for conditions of distribution and use. 00013 // 00014 // ///////////////////////////////////////////////////////////////////////////// 00015 00016 #ifndef __GAMESTATE_H__ 00017 #define __GAMESTATE_H__ 00018 00019 // Include files 00020 #include "GameManager.h" 00021 00022 // Forward declarations 00023 class GameManager; 00024 00025 00026 // GameState class 00028 class GameState 00029 { 00030 friend class ScriptedGameState; 00031 00032 public: 00033 00034 // Initialisation, deinitialisation and control... 00036 GameState(); 00038 virtual ~GameState(); 00039 00041 virtual void init(); 00043 virtual void clear(); 00044 00047 virtual void update(f32 deltaTime); 00049 virtual void render(); 00050 00051 // AngelScript binding 00054 static GameState* refFactory(); 00057 void refAdd(); 00060 void refRelease(); 00061 00062 // Public functions 00064 const Entity* getBaseEntity() const; 00065 00066 // Event functions 00069 void onUpdate(f32 deltaTime); 00072 void onRender(); 00075 void onPause(); 00078 void onUnPause(); 00079 00080 protected: 00081 00082 // Protected members 00083 Entity *mBaseEntity; 00084 00085 private: 00086 00087 // Static members 00088 static u32 mIDCount; 00089 00090 // Angelscript members 00091 s32 mRefCount; 00092 00093 // Private members 00094 u32 mID; 00095 std::string mEventGroup; 00096 }; 00097 00098 00099 // ScriptedGameState class 00103 class ScriptedGameState : public GameState 00104 { 00105 public: 00106 00107 // Initialisation, deinitialisation and control... 00108 ScriptedGameState(asIScriptObject *object); 00109 virtual ~ScriptedGameState(); 00110 00111 void init(); 00112 void clear(); 00113 00114 void update(f32 deltaTime); 00115 void render(); 00116 00117 private: 00118 00119 // Private members 00120 asIScriptObject *mObject; 00121 asIScriptContext *mContext; 00122 00123 }; 00124 00125 00126 // GameState Angelscript binding. 00128 extern void bindGameState(asIScriptEngine *engine); 00129 00130 #endif