00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CEL_BEHAVIOUR_TREE__
00021 #define __CEL_BEHAVIOUR_TREE__
00022
00023 #include "behaviourlayer/behave.h"
00024 #include "tools/decorators.h"
00025 #include "tools/parameters.h"
00026 #include "tools/rewards.h"
00027 #include "tools/triggers.h"
00028
00029
00030
00031
00032
00060 struct iBTNode : public virtual iBase
00061 {
00062 SCF_INTERFACE (iBTNode, 0, 0, 1);
00063
00068 virtual bool Execute (const celParams& params) = 0;
00069
00073 virtual bool AddChild (iBTNode* child) = 0;
00074
00075 };
00076
00077
00078
00079
00080
00085 struct iBTAction: public virtual iBase
00086 {
00087 SCF_INTERFACE (iBTAction, 0, 0, 1);
00088
00092 virtual void AddReward (iReward* reward) = 0;
00093 };
00094
00099 struct iParameterCheckCondition: public virtual iBase
00100 {
00101 SCF_INTERFACE (iParameterCheckCondition, 0, 0, 1);
00102
00106 virtual void SetParameter (const char* parameter) = 0;
00107
00111 virtual void SetValue (const char* value) = 0;
00112 };
00113
00114
00120 struct iTriggerFiredCondition: public virtual iBase
00121 {
00122 SCF_INTERFACE (iTriggerFiredCondition, 0, 0, 1);
00123
00127 virtual void SetTrigger (iTrigger* trigger) = 0;
00128
00136 virtual void SetFireOnce (bool once) = 0;
00137 };
00138
00139
00140
00144 #define CEL_DECLARE_BTNODE(name) \
00145 class cel##name : public scfImplementation2< \
00146 cel##name ,iBTNode, iComponent> \
00147 { \
00148 private: \
00149 iObjectRegistry* object_reg; \
00150 csRefArray<iBTNode> children; \
00151 public: \
00152 cel##name (iBase* parent); \
00153 virtual ~cel##name () { } \
00154 virtual bool Initialize (iObjectRegistry*); \
00155 virtual bool Execute (const celParams& params); \
00156 virtual bool AddChild (iBTNode* child); \
00157 };
00158
00162 #define CEL_IMPLEMENT_BTNODE(name) \
00163 cel##name::cel##name (iBase* parent) \
00164 : scfImplementationType (this, parent), object_reg(0) \
00165 { \
00166 } \
00167 bool cel##name::Initialize ( \
00168 iObjectRegistry* object_reg) \
00169 { \
00170 cel##name::object_reg = object_reg; \
00171 return true; \
00172 }
00173
00174 #endif // __CEL_BEHAVIOUR_TREE__