# ai_instance.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_instance.hpp 16508 2009-06-03 13:33:58Z 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   int suspend;
    00122   AISuspendCallbackProc *callback;
    00123
    00127   void RegisterAPI();
    00128
    00132   void Died();
    00133
    00143   static bool SaveObject(HSQUIRRELVM vm, SQInteger index, int max_depth, bool test);
    00144
    00149   static bool LoadObjects(HSQUIRRELVM vm);
    00150 };
    00151
    00152 #endif /* AI_INSTANCE_HPP */