# ai_instance.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_instance.hpp 15467 2009-02-13 17:17:34Z yexo $ */
    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   AIInstance(class AIInfo *info);
    00034   ~AIInstance();
    00035
    00040   void Continue();
    00041
    00045   void GameLoop();
    00046
    00050   void CollectGarbage();
    00051
    00055   static class AIStorage *GetStorage();
    00056
    00060   static void DoCommandReturn(AIInstance *instance);
    00061
    00065   static void DoCommandReturnVehicleID(AIInstance *instance);
    00066
    00070   static void DoCommandReturnSignID(AIInstance *instance);
    00071
    00075   static void DoCommandReturnGroupID(AIInstance *instance);
    00076
    00080   class AIController *GetController() { return controller; }
    00081
    00085   void Save();
    00086
    00090   static void SaveEmpty();
    00091
    00097   void Load(int version);
    00098
    00103   bool CallLoad();
    00104
    00108   static void LoadEmpty();
    00109
    00110 private:
    00111   static class AIInstance *current_instance;
    00112
    00113   class AIController *controller;
    00114   class AIStorage *storage;
    00115   class Squirrel *engine;
    00116   SQObject *instance;
    00117
    00118   bool is_started;
    00119   bool is_dead;
    00120   int suspend;
    00121   AISuspendCallbackProc *callback;
    00122
    00126   void RegisterAPI();
    00127
    00131   void Died();
    00132
    00142   static bool SaveObject(HSQUIRRELVM vm, SQInteger index, int max_depth, bool test);
    00143
    00148   static bool LoadObjects(HSQUIRRELVM vm);
    00149 };
    00150
    00151 #endif /* AI_INSTANCE_HPP */