ai_instance.hpp
Go to the documentation of this file.00001
00002
00005 #ifndef AI_INSTANCE_HPP
00006 #define AI_INSTANCE_HPP
00007
00011 typedef void (AISuspendCallbackProc)(class AIInstance *instance);
00012
00016 class AI_VMSuspend {
00017 public:
00018 AI_VMSuspend(int time, AISuspendCallbackProc *callback) :
00019 time(time),
00020 callback(callback)
00021 {}
00022
00023 int GetSuspendTime() { return time; }
00024 AISuspendCallbackProc *GetSuspendCallback() { return callback; }
00025
00026 private:
00027 int time;
00028 AISuspendCallbackProc *callback;
00029 };
00030
00034 class AI_FatalError {
00035 public:
00036 AI_FatalError(const char *msg) :
00037 msg(msg)
00038 {}
00039
00040 const char *GetErrorMessage() { return msg; }
00041
00042 private:
00043 const char *msg;
00044 };
00045
00046 class AIInstance {
00047 public:
00048 friend class AIObject;
00049 AIInstance(class AIInfo *info);
00050 ~AIInstance();
00051
00056 void Continue();
00057
00061 void GameLoop();
00062
00066 void CollectGarbage();
00067
00071 static class AIStorage *GetStorage();
00072
00076 static void DoCommandReturn(AIInstance *instance);
00077
00081 static void DoCommandReturnVehicleID(AIInstance *instance);
00082
00086 static void DoCommandReturnSignID(AIInstance *instance);
00087
00091 static void DoCommandReturnGroupID(AIInstance *instance);
00092
00096 class AIController *GetController() { return controller; }
00097
00101 inline bool IsDead() { return this->is_dead; }
00102
00106 void Save();
00107
00111 static void SaveEmpty();
00112
00118 void Load(int version);
00119
00124 bool CallLoad();
00125
00129 static void LoadEmpty();
00130
00131 private:
00132 static class AIInstance *current_instance;
00133
00134 class AIController *controller;
00135 class AIStorage *storage;
00136 class Squirrel *engine;
00137 SQObject *instance;
00138
00139 bool is_started;
00140 bool is_dead;
00141 bool is_save_data_on_stack;
00142 int suspend;
00143 AISuspendCallbackProc *callback;
00144
00148 void RegisterAPI();
00149
00153 void Died();
00154
00164 static bool SaveObject(HSQUIRRELVM vm, SQInteger index, int max_depth, bool test);
00165
00170 static bool LoadObjects(HSQUIRRELVM vm);
00171 };
00172
00173 #endif