Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

SCA_LogicManager.h

Go to the documentation of this file.
00001 #ifndef __KX_LOGICMANAGER
00002 #define __KX_LOGICMANAGER
00003 
00004 
00005 
00006 
00007 
00008 #ifdef _WIN32
00009 #pragma warning (disable:4786)
00010 #endif 
00011 
00012 #include <vector>
00013 //#include "GEN_Map.h"
00014 #include <set>
00015 #include <map>
00016 #include <list>
00017 
00018 #include "GEN_Map.h"
00019 #include "KX_HashedString.h"
00020 #include "Value.h"
00021 
00022 using namespace std;
00023 typedef list<class SCA_IController*> controllerlist;
00024 
00037 
00038 #include "SCA_ILogicBrick.h"
00039 
00040 class SCA_LogicManager
00041 {
00042         vector<class SCA_EventManager*>                         m_eventmanagers;
00043         
00044         vector<class SCA_ISensor*>                                m_activatedsensors;
00045         set<class SCA_IActuator*,SCACompare >           m_activeActuators;
00046 
00047         map<SCA_ISensor*,controllerlist >       m_sensorcontrollermapje;
00048 
00049         // need to find better way for this
00050         // also known as FactoryManager...
00051         GEN_Map<KX_HashedString,CValue*>                        m_mapStringToGameObjects;
00052         GEN_Map<KX_HashedString,void*>                  m_mapStringToMeshes;
00053 
00054 
00055 public:
00056 
00057         SCA_LogicManager()  {};
00058         virtual ~SCA_LogicManager();
00059         //void  SetKeyboardManager(SCA_KeyboardManager* keyboardmgr) { m_keyboardmgr=keyboardmgr;}
00060         void    RegisterEventManager(SCA_EventManager* eventmgr) { m_eventmanagers.push_back(eventmgr);}
00061         void    RegisterToSensor(SCA_IController* controller,class SCA_ISensor* sensor);
00062         void    RegisterToActuator(SCA_IController* controller,class SCA_IActuator* actuator);
00063         
00064         void    BeginFrame(double curtime,double deltatime);
00065         void    UpdateFrame(double curtime,double deltatime);
00066         void    EndFrame();
00067         void    AddActivatedSensor(SCA_ISensor* sensor);
00068         void    AddActiveActuator(SCA_IActuator* sensor,class CValue* event);
00069         SCA_EventManager*       FindEventManager(int eventmgrtype);
00070         
00074         void    RemoveSensor(SCA_ISensor* sensor);
00075         void    RemoveController(SCA_ISensor* sensor);
00076         void    RemoveActuator(SCA_ISensor* sensor);
00077 
00078         // for the scripting... needs a FactoryManager later (if we would have time... ;)
00079         void    RegisterMeshName(const CCString& meshname,void* mesh)

00080         {
00081                 KX_HashedString mn = meshname;
00082                 m_mapStringToMeshes.insert(mn,mesh);
00083         }
00084         void*   GetMeshByName(const CCString& meshname)

00085         {
00086                 KX_HashedString mn = "ME"+meshname;
00087                 void** meshptr = m_mapStringToMeshes[mn];
00088                 if (meshptr)
00089                         return *meshptr;
00090                 return NULL;
00091         }
00092 
00093         void    RegisterGameObjectName(const CCString& gameobjname,CValue* gameobj)

00094         {
00095                 KX_HashedString mn = gameobjname;
00096                 m_mapStringToGameObjects.insert(mn,gameobj);
00097         }
00098         class CValue*   GetGameObjectByName(const CCString& gameobjname)
00099         {
00100                 KX_HashedString mn = "OB"+gameobjname;
00101                 class CValue** gameptr = m_mapStringToGameObjects[mn];
00102                 if (gameptr)
00103                         return *gameptr;
00104                 return NULL;
00105         }
00106 
00107 };
00108 
00109 #endif //__KX_LOGICMANAGER

Generated at Thu Feb 1 13:03:10 2001 for Ketsji Game Engine by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000