00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020
00021 #ifndef AIWRAPPER_H
00022 #define AIWRAPPER_H
00023
00024 #include "AIManager.h"
00025 #include <assert.h>
00026
00037 class AIWrapper {
00038 struct AIFSMWrapper {
00039 AIFSM* _FSM;
00040 AIState* _state;
00041 float _timeStampStateChange;
00042 AI_FSM_IDS _index;
00043 bool _isEnabled;
00044
00045 AIFSMWrapper();
00046 };
00047
00048 AIFSMWrapper _FSMs[AI_FSM_MAX];
00049 std::stack<AIFSMWrapper*> _stackFSMs;
00050 AI_FSM_IDS _currFSMIndex;
00051 AIKB* _kb;
00052 bool _wasKBCreatedHere;
00053 AILogic* _logic;
00054 public:
00058 AIWrapper();
00059
00061
00067 virtual void init(AI_LOGIC_IDS LOGICID_, AI_FSM_IDS FSMID_, AIState* state_);
00071 virtual void init(AI_LOGIC_IDS LOGICID_, AI_FSM_IDS FSMID_, AIState* state_, AIKB* kb_);
00073
00078 virtual bool performLogic(bool includeglobalkb_=false);
00079
00083 AIState* getCurrentState() const { return _FSMs[_currFSMIndex]._state; }
00084
00089 void enableFSM(AI_FSM_IDS FSMID_, AIState* state_=0);
00090
00094 void disableFSM(AI_FSM_IDS FSMID_) { _FSMs[FSMID_]._isEnabled = false; }
00095
00105 bool setFSM(AI_FSM_IDS FSMID_, AIState* state_=0, bool autoEnable_=true);
00106
00110 AI_FSM_IDS getFSM() { return _currFSMIndex; }
00111
00121 bool pushFSM(AI_FSM_IDS FSMID_, AIState* state_=0, bool autoEnable_=true);
00122
00127 bool popFSM();
00128
00132 bool setLogic(AI_LOGIC_IDS LOGICID_);
00133
00137 AI_LOGIC_IDS getCurrentLOGICID() { return _logic->getLOGICID(); }
00138
00142 AIKB* getKB() const { return _kb; }
00143
00144 virtual void doAction();
00145
00149 virtual ~AIWrapper();
00150 };
00151
00152 extern bool usedHeap;
00153
00158 void initAIEngine(std::ifstream* fin_=0);
00159
00160 void destroyAIEngine();
00161
00167 void popAllAIExceptions(bool only_add_new=false, bool remove_all=false);
00168
00169 #endif //AIWRAPPER_H