00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef NL_OPERATOR_SCRIPT_H_
00028 #define NL_OPERATOR_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/logic/interpret_object_operator.h"
00036 #include "nel/ai/agent/actor_script.h"
00037
00038
00039
00040
00041
00042
00043
00044 namespace NLAIAGENT
00045 {
00046 class COperatorScript : public CActorScript
00047 {
00048 protected:
00049 enum c_funcs_id
00050 {
00051 fid_modeachieve,
00052 fid_modemaintain,
00053 fid_isPaused,
00054 fid_getPriority,
00055 fid_setPriority,
00056 fid_isActivable,
00057 fid_background,
00058 fid_exclusive,
00059 fid_achieve,
00060 fid_order,
00061 fid_last
00062 };
00063
00064 private:
00065 std::vector<NLAIAGENT::IObjectIA *> _VarValues;
00066 NLAILOGIC::CFactBase *_FactBase;
00067 NLAILOGIC::CGoal *_CurrentGoal;
00068 sint32 _CyclesBeforeUpdate;
00069 std::list<NLAILOGIC::CGoal *> _ActivatedGoals;
00070 bool _IsActivable;
00071 bool _Exclusive;
00072 bool _Maintain;
00073 float _Priority;
00074 float _BasePriority;
00075 public:
00076
00077 COperatorScript(IAgentManager *, bool activated = false);
00078
00079 COperatorScript(const COperatorScript &);
00080 COperatorScript(IAgentManager *, IBasicAgent *, std::list<IObjectIA *> &, NLAISCRIPT::COperatorClass *);
00081 virtual ~COperatorScript();
00082
00084 float priority() const;
00085 void calcPriority();
00086
00087
00088
00090 virtual const NLAIC::IBasicType *clone() const;
00091 virtual const NLAIC::IBasicType *newInstance() const;
00092 virtual void getDebugString(std::string &) const;
00093 virtual bool isEqual(const IBasicObjectIA &a) const;
00094
00095 virtual bool checkActivation();
00096 virtual const CProcessResult &run();
00097 virtual void processMessages(NLAIAGENT::IMessageBase *msg,NLAIAGENT::IObjectIA *o);
00098
00099
00100
00101 virtual const NLAIC::CIdentType &getType() const;
00102
00103 static const NLAIC::CIdentType IdOperatorScript;
00104
00105 virtual void save(NLMISC::IStream &os);
00106 virtual void load(NLMISC::IStream &is);
00107
00108 virtual IObjectIA::CProcessResult runMethodBase(int heritance, int index,IObjectIA *);
00109 virtual IObjectIA::CProcessResult runMethodBase(int index,IObjectIA *);
00110
00111
00112
00113 tQueue getPrivateMember(const IVarName *,const IVarName *,const IObjectIA &) const;
00114 virtual sint32 getMethodIndexSize() const;
00115 virtual int getBaseMethodCount() const;
00116
00117 virtual void onKill(IConnectIA *a);
00118
00119 void getFatherComponent(IVarName &);
00120
00122 void linkGoalArgs(NLAILOGIC::CGoal *);
00123
00125 virtual NLAILOGIC::CGoal *selectGoal();
00126
00127 virtual void cancel();
00128
00129
00130 virtual void onSuccess( IObjectIA *);
00131 virtual void onFailure( IObjectIA *);
00132
00133
00134 NLAILOGIC::CFact *buildFromVars(NLAILOGIC::IBaseAssert *, std::vector<sint32> &, NLAILOGIC::CValueSet *);
00135 std::list<NLAILOGIC::CValueSet *> *propagate(std::list<NLAILOGIC::CValueSet *> &, NLAILOGIC::CValueSet *, std::vector<sint32> &);
00136 std::list<NLAILOGIC::CFact *> *propagate(std::list<NLAILOGIC::CFact *> &);
00137 NLAILOGIC::CValueSet *unifyLiaison( const NLAILOGIC::CValueSet *, NLAILOGIC::CValueSet *, std::vector<sint32> &);
00138
00139 void lookForGoals();
00140 bool checkPreconditions();
00141 void execOnActivate();
00142 void checkPause();
00143 bool isExclusive();
00144 void setPriority(float prio);
00145
00146 virtual bool checkTrigMsg();
00147
00148 virtual void order( NLAIAGENT::IBaseGroupType *, NLAILOGIC::IGoal *);
00149 };
00150 }
00151 #endif