RWStruct.hpp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. //
  2. // RWStruct.hpp
  3. // redwise_sdk
  4. //
  5. // Created by 余纪柱 on 2023/9/6.
  6. //
  7. #ifndef RWStruct_hpp
  8. #define RWStruct_hpp
  9. // wwise native include
  10. #include <AK/SoundEngine/Common/AkTypes.h>
  11. #pragma mark 本地数据键值
  12. enum RWDataKeys
  13. {
  14. None,
  15. EffectStatus = 1,
  16. MusicStatus = 2,
  17. StashedEffectStatus = 3,
  18. StashedMusicStatus = 4
  19. };
  20. enum class RWItemIndexA
  21. {
  22. ID = 0,
  23. Name = 1,
  24. WwiseObjectPath = 2,
  25. Notes = 3
  26. };
  27. enum class RWItemIndexB
  28. {
  29. ID = 0,
  30. Name = 1,
  31. Notes = 2
  32. };
  33. #pragma mark 声明枚举_RedWise API 返回类型
  34. enum class RWResultType
  35. {
  36. None,
  37. EventForcePost, // 强制使事件活动
  38. EventRuning, // 事件活动中
  39. EventRest, // 事件空闲中
  40. EventNotFind, // 事件不存在
  41. EventFind, // 找到事件
  42. ResetSuccess, // 重置成功
  43. ResetFail, // 重置失败
  44. SetAppNameSucess, // 设置成功
  45. SetAppNameFail, // 设置失败
  46. SetAppNameFailWhenRelease, // 正式版App拒绝设置AppName,因其使用场景为debug
  47. RetainBankSuccess,
  48. RetainBankFail,
  49. NameStringEmpty // 检测到作为名字使用的串为空
  50. };
  51. #pragma mark 声明结构体_描述配置文件(XX.txt)中各属性基本信息
  52. struct RWBankDescription
  53. {
  54. string bankName;
  55. string bankFileName;
  56. };
  57. struct RWEventDescription
  58. {
  59. string eventName;
  60. uint32_t eventID;
  61. string ownerBankName;
  62. };
  63. struct RWSwitchDescription
  64. {
  65. uint32_t switchID;
  66. string switchName;
  67. string ownerSwitchGroup;
  68. };
  69. struct RWSwitchGroupDescription
  70. {
  71. uint32_t groupID;
  72. string groupName;
  73. vector<string> ownerEvents;
  74. };
  75. struct RWStateDescription
  76. {
  77. uint32_t stateID;
  78. string stateName;
  79. string ownerStateGroup;
  80. };
  81. struct RWStateGroupDescription
  82. {
  83. uint32_t groupID;
  84. string groupName;
  85. vector<string> ownerEvents;
  86. };
  87. struct RWParamDescription
  88. {
  89. uint32_t paramID;
  90. string paramName;
  91. vector<string> ownerEvents;
  92. };
  93. #pragma mark 声明结构体_描述各属性 “基础信息+关联关系” 的详细信息(Event、Switch、State、StateGroup、SwitchGroup、Parameter)
  94. struct RWSwitchInfo
  95. {
  96. RWSwitchDescription switchDescription;
  97. };
  98. struct RWStateInfo
  99. {
  100. RWStateDescription stateDescription;
  101. };
  102. struct RWSwitchGroupInfo
  103. {
  104. string switchsFormat;
  105. set<string> switchs;
  106. RWSwitchGroupDescription switchGroupDescription;
  107. };
  108. struct RWStateGroupInfo
  109. {
  110. string statesFormat;
  111. set<string> states;
  112. RWStateGroupDescription stateGroupDescription;
  113. };
  114. struct RWEventInfo
  115. {
  116. set<string> switchGroupNames;
  117. set<string> stateGroupNames;
  118. set<string> paramNames;
  119. RWEventDescription eventDescription;
  120. };
  121. struct RWParamInfo
  122. {
  123. RWParamDescription paramDescription;
  124. };
  125. struct RWBankInfo
  126. {
  127. RWBankDescription bnkDescription;
  128. unordered_map<string, RWEventInfo> EventPool;
  129. unordered_map<string, RWStateGroupInfo> StateGroupPool;
  130. unordered_map<string, RWSwitchGroupInfo> SwitchGroupPool;
  131. unordered_map<string, RWSwitchInfo> switchPool;
  132. unordered_map<string, RWStateInfo> statePool;
  133. unordered_map<string, RWParamInfo> ParameterPool;
  134. };
  135. #pragma mark 声明结构体_描述播放详情
  136. struct RWPlayInfo
  137. {
  138. function<void(void)> onEventEnd;
  139. RWPlayInfo(function<void(void)> p_eventEndCallback)
  140. : onEventEnd(p_eventEndCallback){};
  141. };
  142. struct RWEmitterInfo
  143. {
  144. cocos2d::Node* emitter;
  145. function<void(void)> onEventEnd;
  146. RWEmitterInfo(function<void(void)> p_eventEndCallback, cocos2d::Node* p_emitter)
  147. : onEventEnd(p_eventEndCallback), emitter(p_emitter){};
  148. };
  149. struct RWEventCacheItem
  150. {
  151. unordered_map<AkPlayingID, RWPlayInfo> m_playInfo;
  152. };
  153. struct RWReturn
  154. {
  155. bool findEvent = false;
  156. RWResultType type = RWResultType::None;
  157. uint32_t eventID = 0;
  158. AkPlayingID playID = 0;
  159. string error;
  160. string warn;
  161. };
  162. struct RWLog
  163. {
  164. string error;
  165. string warn;
  166. void addError(const string& str){error.append(str);error.append("\n");};
  167. void addWarn(const string& str){warn.append(str);warn.append("\n");}
  168. void popTo(RWReturn* rr = NULL)
  169. {
  170. if(rr)
  171. {
  172. rr->error = error;
  173. rr->warn = warn;
  174. }
  175. error = "";
  176. warn = "";
  177. }
  178. };
  179. class RedWise;
  180. struct RWSonStruct
  181. {
  182. RedWise* m_owner ;
  183. inline void setOwner(RedWise* owner)
  184. {m_owner = owner ;};
  185. };
  186. struct RWBankCacheItem
  187. {
  188. AkUInt32 bankID;
  189. int referenceCount;
  190. function<void(void)> asyncLoadCallback;
  191. function<void(void)> asyncUnloadCallback;
  192. RWBankCacheItem(int in_referenceCount, AkUInt32 in_bankID, function<void(void)> in_asyncLoadCallback = NULL, function<void(void)> in_asyncUnloadCallback = NULL)
  193. {
  194. referenceCount = in_referenceCount;
  195. bankID = in_bankID;
  196. asyncLoadCallback = in_asyncLoadCallback;
  197. asyncUnloadCallback = in_asyncUnloadCallback;
  198. };
  199. };
  200. struct RWRedreamParam
  201. {
  202. string name;
  203. float value = 0;
  204. float min = 0.f;
  205. float max = 100.f;
  206. RWRedreamParam() {};
  207. RWRedreamParam(const string& name, float value, float min, float max)
  208. : name(name), value(value), min(min), max(max) {}
  209. };
  210. struct RWRedreamEvent
  211. {
  212. string name;
  213. vector<RWRedreamParam> params;
  214. };
  215. struct RWRedreamInfo
  216. {
  217. vector<RWRedreamEvent> events;
  218. RWReturn log;
  219. };
  220. #endif /* RWStruct_hpp */