00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "asGameManager.h"
00018
00019 #ifdef __COMPILE_WITH_ANGELSCRIPT__
00020
00021 #include "asGameState.h"
00022 #include "../../core/GameManager.h"
00023
00024
00026 GameManager* createGameManager()
00027 {
00028 return GameManager::Instance();
00029 }
00030
00033 void changeState(asIScriptObject *object, GameManager *pGameMgr)
00034 {
00035 ScriptedGameState *state = new ScriptedGameState(object);
00036 pGameMgr->changeState(state);
00037 state->drop();
00038 }
00039
00042 void pushState(asIScriptObject *object, GameManager *pGameMgr)
00043 {
00044 ScriptedGameState *state = new ScriptedGameState(object);
00045 pGameMgr->pushState(state);
00046 state->drop();
00047 }
00048
00050 void bindGameManager(asIScriptEngine *engine)
00051 {
00052
00053 int r;
00054
00055
00056 r = engine->RegisterObjectType("GameManager", sizeof(GameManager), asOBJ_REF); assert(r >= 0);
00057
00058
00059 r = engine->RegisterObjectBehaviour("GameManager", asBEHAVE_FACTORY, "GameManager@ f()",
00060 asFUNCTION(createGameManager), asCALL_CDECL); assert(r >= 0);
00061 r = engine->RegisterObjectBehaviour("GameManager", asBEHAVE_ADDREF, "void f()",
00062 asMETHOD(GameManager, grab), asCALL_THISCALL); assert(r >= 0);
00063 r = engine->RegisterObjectBehaviour("GameManager", asBEHAVE_RELEASE, "void f()",
00064 asMETHOD(GameManager, drop), asCALL_THISCALL); assert(r >= 0);
00065
00066
00067 r = engine->RegisterGlobalFunction("GameManager& getGameManager()", asFUNCTION(GameManager::Instance),
00068 asCALL_CDECL); assert( r >= 0 );
00069
00070 r = engine->RegisterObjectMethod("GameManager", "void changeState(GameState @+)",
00071 asMETHODPR(GameManager, changeState, (GameState*), void),
00072 asCALL_THISCALL); assert(r >= 0);
00073 r = engine->RegisterObjectMethod("GameManager", "void changeState(IGameState @+)",
00074 asFUNCTION(changeState), asCALL_CDECL_OBJLAST); assert(r >= 0);
00075 r = engine->RegisterObjectMethod("GameManager", "void pushState(GameState @+)",
00076 asMETHODPR(GameManager, pushState, (GameState*), void),
00077 asCALL_THISCALL); assert(r >= 0);
00078 r = engine->RegisterObjectMethod("GameManager", "void pushState(IGameState @+)",
00079 asFUNCTION(pushState), asCALL_CDECL_OBJLAST); assert(r >= 0);
00080 r = engine->RegisterObjectMethod("GameManager", "void popState()",
00081 asMETHOD(GameManager, popState), asCALL_THISCALL); assert(r >= 0);
00082
00083 r = engine->RegisterObjectMethod("GameManager", "AssetManager@ getAssetManager()",
00084 asMETHOD(GameManager, getAssetManager), asCALL_THISCALL); assert(r >= 0);
00085 r = engine->RegisterObjectMethod("GameManager", "DataStore@ getDataStore()",
00086 asMETHOD(GameManager, getDataStore), asCALL_THISCALL); assert(r >= 0);
00087 r = engine->RegisterObjectMethod("GameManager", "EntityManager@ getEntityManager()",
00088 asMETHOD(GameManager, getEntityManager), asCALL_THISCALL); assert(r >= 0);
00089 r = engine->RegisterObjectMethod("GameManager", "EventManager@ getEventManager()",
00090 asMETHOD(GameManager, getEventManager), asCALL_THISCALL); assert(r >= 0);
00091 r = engine->RegisterObjectMethod("GameManager", "ScriptManager@ getScriptManager()",
00092 asMETHOD(GameManager, getScriptManager), asCALL_THISCALL); assert(r >= 0);
00093 #ifdef __COMPILE_WITH_SFML_AUDIO__
00094 r = engine->RegisterObjectMethod("GameManager", "SoundManager@ getSoundManager()",
00095 asMETHOD(GameManager, getSoundManager), asCALL_THISCALL); assert(r >= 0);
00096 #endif // __COMPILE_WITH_SFML_AUDIO__
00097
00098 r = engine->RegisterObjectMethod("GameManager", "bool getIsRunning()",
00099 asMETHOD(GameManager, getIsRunning), asCALL_THISCALL); assert(r >= 0);
00100
00101 r = engine->RegisterObjectMethod("GameManager", "void setIsRunning(bool)",
00102 asMETHOD(GameManager, setIsRunning), asCALL_THISCALL); assert(r >= 0);
00103 }
00104
00105 #endif // __COMPILE_WITH_ANGELSCRIPT__
00106
00107