RedBehaviacTree.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. // -------------------------------------------------------------------------------
  2. // THIS FILE IS ORIGINALLY GENERATED BY THE DESIGNER.
  3. // YOU ARE ONLY ALLOWED TO MODIFY CODE BETWEEN '///<<< BEGIN' AND '///<<< END'.
  4. // PLEASE MODIFY AND REGENERETE IT IN THE DESIGNER FOR CLASS/MEMBERS/METHODS, ETC.
  5. // -------------------------------------------------------------------------------
  6. #ifndef _BEHAVIAC_RED_REDBEHAVIACTREE_H_
  7. #define _BEHAVIAC_RED_REDBEHAVIACTREE_H_
  8. #include "reboltBt_behaviac_headers.h"
  9. ///<<< BEGIN WRITING YOUR CODE FILE_INIT
  10. class ReboltRunDelegate;
  11. struct ReboltErrorInfo;
  12. namespace redream {
  13. class ReboltRedManager;
  14. class WaitableStateBase;
  15. class LoopWaiter;
  16. }
  17. ///<<< END WRITING YOUR CODE
  18. namespace red
  19. {
  20. ///<<< BEGIN WRITING YOUR CODE NAMESPACE_INIT
  21. typedef enum NumOperatorType{
  22. NOT_abs = 0, //绝对值
  23. NOT_floor, //向下取整
  24. NOT_ceil, //向上取整
  25. NOT_sqrt, //平方根
  26. NOT_sin,
  27. NOT_cos,
  28. NOT_tan,
  29. NOT_asin,
  30. NOT_acos,
  31. NOT_atan,
  32. NOT_ln, //自然对数
  33. NOT_log10,
  34. NOT_exp,
  35. NOT_pow10,
  36. } NumOperatorType;
  37. class RedBehaviacTree;
  38. class RedBehaviacTreeDelegate{
  39. public:
  40. virtual void onTreeRunningEnd(RedBehaviacTree* tree, int endType, std::string treeName) = 0;
  41. };
  42. ///<<< END WRITING YOUR CODE
  43. class RedBehaviacTree : public behaviac::Agent
  44. ///<<< BEGIN WRITING YOUR CODE RedBehaviacTree
  45. ///<<< END WRITING YOUR CODE
  46. {
  47. public:
  48. RedBehaviacTree();
  49. virtual ~RedBehaviacTree();
  50. BEHAVIAC_DECLARE_AGENTTYPE(red::RedBehaviacTree, behaviac::Agent)
  51. public: bool temporaryVariablesBool;
  52. public: float temporaryVariablesFloat;
  53. public: int temporaryVariablesInt;
  54. public: behaviac::string temporaryVariablesString;
  55. public: bool videoIsSuccess;
  56. public: void addCustomDataVar(behaviac::string blockId, behaviac::string dataName, float content);
  57. public: void addFunLocalBoolToMap(behaviac::string stringKey, bool content);
  58. public: void addFunLocalStringToMap(behaviac::string stringKey, behaviac::string content);
  59. public: void clearFunLocalMap();
  60. public: void customFunc(behaviac::string blockId, behaviac::string funName);
  61. public: bool findSubString(behaviac::string stringKey1, behaviac::string stringKey2);
  62. public: behaviac::string floatFormat(float number, int format);
  63. public: behaviac::string floatToString(float num);
  64. public: float getCoderFloat(behaviac::string key);
  65. public: behaviac::string getCoderString(behaviac::string key);
  66. public: float getCustomFloat(behaviac::string key);
  67. public: behaviac::string getCustomString(behaviac::string key);
  68. public: bool getFunBoolVar(behaviac::string funcVarKey);
  69. public: behaviac::string getFunStringVar(behaviac::string funcVarKey);
  70. public: float getGlobalFloat(behaviac::string key);
  71. public: behaviac::string getGlobalString(behaviac::string key);
  72. public: behaviac::EBTStatus getInterstitialAdsState(behaviac::string adName);
  73. public: float getLocalTreeFloat(behaviac::string key);
  74. public: behaviac::string getLocalTreeString(behaviac::string dataKey);
  75. public: behaviac::EBTStatus getLoopState(behaviac::string blockId);
  76. public: float getLoopTimes();
  77. public: behaviac::EBTStatus getNodeAnimState(behaviac::string nodeId, behaviac::string animPath);
  78. public: behaviac::EBTStatus getNotifyDevelopmentState(behaviac::string key);
  79. public: behaviac::EBTStatus getRewardVideoAdsState(behaviac::string adName);
  80. public: behaviac::EBTStatus getSubredTimeLineState(behaviac::string redPath, behaviac::string timeLineId);
  81. public: behaviac::EBTStatus getSubRedTreeState(behaviac::string redPath);
  82. public: behaviac::EBTStatus getTimeLineState(behaviac::string timeLineId);
  83. public: behaviac::EBTStatus getTreeState();
  84. public: void globalListVarAdd(behaviac::string blockId, behaviac::string dataName, behaviac::string content);
  85. public: float globalListVarCount(behaviac::string dataName);
  86. public: void globalListVarDeleteAll(behaviac::string blockId, behaviac::string dataName);
  87. public: void globalListVarDeleteOne(behaviac::string blockId, behaviac::string dataName, int index);
  88. public: float globalListVarFindValueID(behaviac::string dataName, behaviac::string content);
  89. public: bool globalListVarHasValue(behaviac::string dataName, behaviac::string content);
  90. public: behaviac::string globalListVarIndexValue(behaviac::string dataName, int index);
  91. public: void globalListVarInsertBefore(behaviac::string blockId, behaviac::string dataName, int index, behaviac::string content);
  92. public: void globalListVarReplace(behaviac::string blockId, behaviac::string dataName, int index, behaviac::string content);
  93. public: void hiddenNode(behaviac::string blockId, behaviac::string nodeId);
  94. public: void hiddenRedNode(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId);
  95. public: void hiddenSelf(behaviac::string blockId);
  96. public: bool isHiddenNode(behaviac::string nodeId);
  97. public: bool isHiddenRedNode(behaviac::string redPath, behaviac::string nodeId);
  98. public: void messageSend(behaviac::string blockId, behaviac::string messageName, behaviac::string messageValue);
  99. public: float nodeGetGlobalPosX(behaviac::string nodeId);
  100. public: float nodeGetGlobalPosY(behaviac::string nodeId);
  101. public: float nodeGetPosX(behaviac::string nodeId);
  102. public: float nodeGetPosY(behaviac::string nodeId);
  103. public: void nodeSetAnimAction(behaviac::string blockId, behaviac::string nodeId, behaviac::string animPath, behaviac::string posXKey, behaviac::string posYKey, behaviac::string posXKey2, behaviac::string posYKey2);
  104. public: void nodeSetAnimActionWithCallBack(behaviac::string blockId, behaviac::string nodeId, behaviac::string animPath, behaviac::string callbacktreeId, behaviac::string posXKey, behaviac::string posYKey, behaviac::string posXKey2, behaviac::string posYKey2);
  105. public: void nodeSetAnimWaitAction(behaviac::string blockId, behaviac::string nodeId, behaviac::string animPath, behaviac::string posXKey, behaviac::string posYKey, behaviac::string posXKey2, behaviac::string posYKey2);
  106. public: void nodeSetPos(behaviac::string blockId, behaviac::string nodeId, behaviac::string posXKey, behaviac::string posYKey);
  107. public: void notifyDevelopment(behaviac::string blockId, behaviac::string key);
  108. public: void notifyDevelopmentWait(behaviac::string blockId, behaviac::string key);
  109. public: void notifyDevelopmentWithParam(behaviac::string blockId, behaviac::string key, behaviac::string paramKey);
  110. public: void notifyDevelopmentWithParamAndNode(behaviac::string blockId, behaviac::string key, behaviac::string paramKey, behaviac::string nodeId);
  111. public: void notifyDevelopmentWithParamAndNodeWait(behaviac::string blockId, behaviac::string key, behaviac::string paramKey, behaviac::string nodeId);
  112. public: void notifyDevelopmentWithParamAndSubredNode(behaviac::string blockId, behaviac::string key, behaviac::string paramKey, behaviac::string redPath, behaviac::string nodeId);
  113. public: void notifyDevelopmentWithParamAndSubredNodeWait(behaviac::string blockId, behaviac::string key, behaviac::string paramKey, behaviac::string redPath, behaviac::string nodeId);
  114. public: void notifyDevelopmentWithParamWait(behaviac::string blockId, behaviac::string key, behaviac::string paramKey);
  115. public: float numberOperator(behaviac::string floatKey1, int type);
  116. public: float numModOperator(behaviac::string floatKey1, behaviac::string floatKey2);
  117. public: behaviac::string numRandOperator(behaviac::string floatKey1);
  118. public: void onLoopEnd();
  119. public: void playSubredTimeLine(behaviac::string blockId, behaviac::string redPath, behaviac::string actionName);
  120. public: void playSubredTimeLineWait(behaviac::string blockId, behaviac::string redPath, behaviac::string actionName);
  121. public: void playSubredTimeLineWithCallBack(behaviac::string blockId, behaviac::string redPath, behaviac::string actionName, behaviac::string callbacktreeId);
  122. public: void playTimeLine(behaviac::string blockId, behaviac::string actionName);
  123. public: void playTimeLineWait(behaviac::string blockId, behaviac::string actionName);
  124. public: void playTimeLineWithCallBack(behaviac::string blockId, behaviac::string actionName, behaviac::string callbacktreeId);
  125. public: void playWiseSound(behaviac::string blockId, behaviac::string bnkPathKey, behaviac::string eventNameKey);
  126. public: float randOperator(behaviac::string floatKey1, behaviac::string floatKey2);
  127. public: void redCustomFunc(behaviac::string blockId, behaviac::string redPath, behaviac::string funName);
  128. public: void redProgressBar(behaviac::string blockId, behaviac::string barName, float number);
  129. public: bool rewardVideoIsLoad(behaviac::string adName);
  130. public: float sceneNodeGetGlobalPosX(behaviac::string redPath, behaviac::string nodeId);
  131. public: float sceneNodeGetGlobalPosY(behaviac::string redPath, behaviac::string nodeId);
  132. public: float sceneNodeGetPosX(behaviac::string redPath, behaviac::string nodeId);
  133. public: float sceneNodeGetPosY(behaviac::string redPath, behaviac::string nodeId);
  134. public: void sceneNodeSetPos(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId, behaviac::string posXKey, behaviac::string posYKey);
  135. public: void sceneProgressBar(behaviac::string blockId, behaviac::string redPath, behaviac::string barName, float number);
  136. private: void setButtonEnable(behaviac::string blockId, behaviac::string nodeId, bool isEnable);
  137. public: void setCoderDataVar(behaviac::string blockId, behaviac::string dataName, behaviac::string content);
  138. public: void setCustomDataVar(behaviac::string blockId, behaviac::string dataName, behaviac::string content);
  139. public: void setGlobalDataVar(behaviac::string blockId, behaviac::string dataName, behaviac::string content);
  140. public: void setLabelTitle(behaviac::string blockId, behaviac::string labelName, behaviac::string content);
  141. public: void setNodeRotation(behaviac::string blockId, behaviac::string nodeId, float rotation);
  142. public: void setNodeScale(behaviac::string blockId, behaviac::string nodeId, behaviac::string scaleXKey, behaviac::string scaleYKey);
  143. public: void setSceneLabelTitle(behaviac::string blockId, behaviac::string redPath, behaviac::string labelName, behaviac::string content);
  144. public: void setSpriteImage(behaviac::string blockId, behaviac::string nodeId, behaviac::string imagePath);
  145. public: void setSpritePlist(behaviac::string blockId, behaviac::string nodeId, behaviac::string plistPath, behaviac::string frameName);
  146. private: void setSubredButtonEnable(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId, bool isEnable);
  147. public: void setSubredNodeRotation(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId, float rotation);
  148. public: void setSubredNodeScale(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId, behaviac::string scaleXKey, behaviac::string scaleYKey);
  149. public: void setSubredSpriteImage(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId, behaviac::string imagePath);
  150. public: void setSubredSpritePlist(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId, behaviac::string plistPath, behaviac::string frameName);
  151. public: void showInterstitialAds(behaviac::string blockId, behaviac::string adName);
  152. public: void showNode(behaviac::string blockId, behaviac::string nodeId);
  153. public: void showRedNode(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId);
  154. public: void showRewardVideoAds(behaviac::string blockId, behaviac::string adName);
  155. public: void showSelf(behaviac::string blockId);
  156. public: void startLoop(behaviac::string blockId);
  157. public: void stopSubredTimeLine(behaviac::string blockId, behaviac::string redPath);
  158. public: void stopTimeLine(behaviac::string blockId);
  159. public: void storageTemporaryVariables(behaviac::string keyVariables, float number);
  160. public: void storageTemporaryVariablesString(behaviac::string dataKey, behaviac::string v);
  161. public: bool stringEqual(behaviac::string stringKey1, behaviac::string stringKey2);
  162. public: float stringLen(behaviac::string stringKey1);
  163. public: behaviac::string stringLink(behaviac::string stringKey1, behaviac::string stringKey2);
  164. public: behaviac::string stringLinkMoreOperator(behaviac::string stringKeyA, behaviac::string stringKeyB, behaviac::string stringKeyC, behaviac::string stringKeyD, behaviac::string stringKeyE);
  165. public: float stringToFloat(behaviac::string str);
  166. ///<<< BEGIN WRITING YOUR CODE CLASS_PART
  167. public:
  168. void setReboltRedManager(redream::ReboltRedManager* pReboltRedManager){_reboltRedManager = pReboltRedManager;}
  169. void update();
  170. void updateBySubTree();
  171. void runBehaviacTree();
  172. void setTreeName(std::string treeName){_treeName = treeName;}
  173. std::string getTreeName(){return _treeName;}
  174. void setReboltRunDelegate(ReboltRunDelegate* reboltRunDelegate){_reboltRunDelegate = reboltRunDelegate;}
  175. void setArgumentsBoolMap(const std::map<std::string, bool> &boolMap){_argumentsBoolMap = boolMap;}
  176. void setArgumentsStringMap(const std::map<std::string, std::string> &stringMap){_argumentsStringMap = stringMap;}
  177. void setWaitableStateBase(redream::WaitableStateBase* wsb);
  178. void setReboltLoopManager(redream::LoopWaiter* rlm){_reboltLoopManager = rlm;}
  179. void addRedBehaviacTreeDelegate(RedBehaviacTreeDelegate* delegate);
  180. void removeRedBehaviacTreeDelegate(RedBehaviacTreeDelegate* delegate);
  181. void removeAllRedBehaviacTreeDelegate();
  182. inline void prohibitUpdateByTree() {_canUpdateBySubTree = false;};
  183. private:
  184. bool _isRunning;
  185. bool _canUpdateBySubTree;
  186. redream::ReboltRedManager* _reboltRedManager;
  187. std::string _treeName;
  188. std::string _runningSubtreeName;
  189. std::string _getTreeStateSubtreeName;
  190. std::string _getTreeStateRedPath;
  191. std::map<std::string, float> _localTreeFloatMap;
  192. std::map<std::string, std::string> _localTreeStringMap;
  193. std::map<std::string, bool> _argumentsBoolMap;
  194. std::map<std::string, std::string> _argumentsStringMap;
  195. std::map<std::string, bool> _funLocalBoolMap;
  196. std::map<std::string, std::string> _funLocalStringMap;
  197. ReboltRunDelegate* _reboltRunDelegate;
  198. int _runingAnimTag; //在一颗树上,同时只能存在一个等待结束的时间线,所以这个地方只要一个变量就足够了。
  199. redream::WaitableStateBase* _waitableStateBase; // 等待执行类型块的逻辑管理对象
  200. std::vector<RedBehaviacTreeDelegate*> _delegateVer;
  201. redream::LoopWaiter* _reboltLoopManager;
  202. private:
  203. void onTreeStepStart(std::string blockId, std::string blockName);
  204. void processError(std::string blockId, ReboltErrorInfo& errorInfo);
  205. behaviac::EBTStatus getWaitableState();
  206. ///<<< END WRITING YOUR CODE
  207. };
  208. ///<<< BEGIN WRITING YOUR CODE NAMESPACE_UNINIT
  209. ///<<< END WRITING YOUR CODE
  210. }
  211. ///<<< BEGIN WRITING YOUR CODE FILE_UNINIT
  212. ///<<< END WRITING YOUR CODE
  213. #endif