# ai_instance.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_instance.hpp 16835 2009-07-15 20:29:45Z rubidium $ */
    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
    00031 class AIInstance {
    00032 public:
    00033   friend class AIObject;
    00034   AIInstance(class AIInfo *info);
    00035   ~AIInstance();
    00036
    00041   void Continue();
    00042
    00046   void GameLoop();
    00047
    00051   void CollectGarbage();
    00052
    00056   static class AIStorage *GetStorage();
    00057
    00061   static void DoCommandReturn(AIInstance *instance);
    00062
    00066   static void DoCommandReturnVehicleID(AIInstance *instance);
    00067
    00071   static void DoCommandReturnSignID(AIInstance *instance);
    00072
    00076   static void DoCommandReturnGroupID(AIInstance *instance);
    00077
    00081   class AIController *GetController() { return controller; }
    00082
    00086   void Save();
    00087
    00091   static void SaveEmpty();
    00092
    00098   void Load(int version);
    00099
    00104   bool CallLoad();
    00105
    00109   static void LoadEmpty();
    00110
    00111 private:
    00112   static class AIInstance *current_instance;
    00113
    00114   class AIController *controller;
    00115   class AIStorage *storage;
    00116   class Squirrel *engine;
    00117   SQObject *instance;
    00118
    00119   bool is_started;
    00120   bool is_dead;
    00121   bool is_save_data_on_stack;
    00122   int suspend;
    00123   AISuspendCallbackProc *callback;
    00124
    00128   void RegisterAPI();
    00129
    00133   void Died();
    00134
    00144   static bool SaveObject(HSQUIRRELVM vm, SQInteger index, int max_depth, bool test);
    00145
    00150   static bool LoadObjects(HSQUIRRELVM vm);
    00151 };
    00152
    00153 #endif /* AI_INSTANCE_HPP */