00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef NL_ACTOR_SCRIPT_H_
00028 #define NL_ACTOR_SCRIPT_H_
00029
00030 #include "nel/ai/agent/agent.h"
00031 #include "nel/ai/agent/agent_script.h"
00032 #include "nel/ai/agent/agent_manager.h"
00033 #include "nel/ai/logic/bool_cond.h"
00034 #include "nel/ai/script/type_def.h"
00035 #include "nel/ai/script/interpret_actor.h"
00036 #include "nel/ai/agent/comp_handle.h"
00037
00038 namespace NLAIAGENT
00039 {
00049 class CActorScript : public CAgentScript
00050 {
00051 protected:
00052
00053 enum c_funcs_id
00054 {
00055 fid_activate,
00056 fid_onActivate,
00057 fid_unActivate,
00058 fid_onUnActivate,
00059 fid_switch,
00060 fid_launch,
00061 fid_launch_goal,
00062 fid_launched,
00063 fid_pause,
00064 fid_restart,
00065 fid_success,
00066 fid_msg_success,
00067 fid_failure,
00068 fid_msg_failure,
00069 fid_nb_answers,
00070 fid_toplevel,
00071 fid_owner,
00072 fid_isactive,
00073 fid_last
00074 };
00075
00076 bool _IsActivated;
00077 bool _OnActivate;
00078 bool _IsPaused;
00079
00080
00081 sint32 _OnActivateIndex;
00082 sint32 _OnUnActivateIndex;
00083 sint32 _OnPauseIndex;
00084 sint32 _OnRestartIndex;
00085 sint32 _OnSuccessIndex;
00086 sint32 _OnFailureIndex;
00087
00088 sint32 _NbAnswers;
00089
00091
00092 std::vector<CComponentHandle *> _Actors;
00093
00094 std::list<IBasicAgent *> _Launched;
00095
00096 CAgentScript *_TopLevel;
00097
00101 virtual void switchActor(CActorScript *, bool stay_active = false);
00105 virtual void switchActor(std::vector<CActorScript *> &, bool stay_active = false);
00109 virtual void switchActor(std::vector<CComponentHandle *> &, bool stay_active = false);
00110
00111 public:
00112 static NLAISCRIPT::COperandSimpleListOr *ParamIdSuccessMsg;
00113 static NLAISCRIPT::CParam *ParamSuccessMsg;
00114 static NLAISCRIPT::COperandSimpleListOr *ParamIdFailureMsg;
00115 static NLAISCRIPT::CParam *ParamFailureMsg;
00116
00117 public:
00118
00119 CActorScript(IAgentManager *, bool activated = false);
00120
00121 CActorScript(const CActorScript &);
00122 CActorScript(IAgentManager *, IBasicAgent *, std::list<IObjectIA *> &, NLAISCRIPT::CAgentClass *);
00123 virtual ~CActorScript();
00124
00126 bool isActivated();
00128
00130 void activate();
00132 virtual void onActivate();
00133
00135 void unActivate();
00137 virtual void onUnActivate();
00138
00140 virtual const NLAIC::IBasicType *clone() const;
00141 virtual const NLAIC::IBasicType *newInstance() const;
00142 virtual void getDebugString(std::string &t) const;
00143 virtual bool isEqual(const IBasicObjectIA &a) const;
00144 virtual void processMessages();
00145 virtual const CProcessResult &run();
00146
00147 virtual CProcessResult sendMessage(IObjectIA *);
00148 virtual const NLAIC::CIdentType &getType() const;
00149
00150 static const NLAIC::CIdentType IdActorScript;
00151
00152 virtual void save(NLMISC::IStream &os);
00153 virtual void load(NLMISC::IStream &is);
00154
00155
00156 virtual int getBaseMethodCount() const;
00157 virtual sint32 getMethodIndexSize() const;
00158 virtual tQueue getPrivateMember(const IVarName *,const IVarName *,const IObjectIA &) const;
00159 virtual IObjectIA::CProcessResult runMethodBase(int heritance, int index,IObjectIA *);
00160 virtual IObjectIA::CProcessResult runMethodBase(int index,IObjectIA *);
00161
00162 virtual void cancel();
00163
00167 virtual void processSuccess(NLAIAGENT::IObjectIA *);
00168 virtual void processFailure(NLAIAGENT::IObjectIA *);
00169 virtual void success();
00170
00171 virtual void failure();
00172
00174 void pause();
00175 void restart();
00176
00178 virtual void onPause();
00179 virtual void onRestart();
00180
00183 virtual void onSuccess( IObjectIA *) {}
00184 virtual void onFailure( IObjectIA *) {}
00185
00187 virtual float priority() const;
00188
00189 virtual void setTopLevel(CAgentScript *);
00190 const CAgentScript *getTopLevel() const;
00191
00192 virtual IMessageBase *runTell(const IMessageBase &m);
00193
00194 public:
00195 static void initClass();
00196 static void releaseClass();
00197
00198 virtual void Launch(const std::string &name, NLAIAGENT::IBasicAgent *);
00199 };
00200 }
00201 #endif