UnitEnvironment.Values.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. using CommonAI.RTS; using CommonLang.Vector;
  2. using CommonAI.Zone.Attributes;
  3. using CommonAI.Zone.Instance;
  4. using CommonAI.Zone.ZoneEditor;
  5. using CommonAI.Zone.ZoneEditor.EventTrigger;
  6. using CommonLang.Property;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using CommonAI.Zone.EventTrigger;
  12. namespace CommonAI.Zone.ZoneEditor.EventTrigger
  13. {
  14. //-------------------------------------------------------------------------------------------
  15. #region _获取_单位变量_
  16. [DescAttribute("单位变量", "单位 - 变量")]
  17. public class GetUnitAsString : StringValue
  18. {
  19. [DescAttribute("变量名")]
  20. public string Key = "VarName";
  21. [DescAttribute("单位")]
  22. public UnitValue Unit = new UnitValue.Trigging();
  23. public override string ToString()
  24. {
  25. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  26. }
  27. public override string GetValue(IEditorValueAdapter api, EventArguments args)
  28. {
  29. InstanceUnit unit = Unit.GetValue(api, args);
  30. if (unit != null)
  31. {
  32. return unit.GetEnvironmentVarAs<string>(Key);
  33. }
  34. return null;
  35. }
  36. }
  37. [DescAttribute("单位变量", "单位 - 变量")]
  38. public class GetUnitAsInteger : IntegerValue
  39. {
  40. [DescAttribute("变量名")]
  41. public string Key = "VarName";
  42. [DescAttribute("单位")]
  43. public UnitValue Unit = new UnitValue.Trigging();
  44. public override string ToString()
  45. {
  46. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  47. }
  48. public override Int32 GetValue(IEditorValueAdapter api, EventArguments args)
  49. {
  50. InstanceUnit unit = Unit.GetValue(api, args);
  51. if (unit != null)
  52. {
  53. return unit.GetEnvironmentVarAs<Int32>(Key);
  54. }
  55. return 0;
  56. }
  57. }
  58. [DescAttribute("单位变量", "单位 - 变量")]
  59. public class GetUnitAsReal : RealValue
  60. {
  61. [DescAttribute("变量名")]
  62. public string Key = "VarName";
  63. [DescAttribute("单位")]
  64. public UnitValue Unit = new UnitValue.Trigging();
  65. public override string ToString()
  66. {
  67. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  68. }
  69. public override Single GetValue(IEditorValueAdapter api, EventArguments args)
  70. {
  71. InstanceUnit unit = Unit.GetValue(api, args);
  72. if (unit != null)
  73. {
  74. return unit.GetEnvironmentVarAs<Single>(Key);
  75. }
  76. return 0;
  77. }
  78. }
  79. [DescAttribute("单位变量", "单位 - 变量")]
  80. public class GetUnitAsBoolean : BooleanValue
  81. {
  82. [DescAttribute("变量名")]
  83. public string Key = "VarName";
  84. [DescAttribute("单位")]
  85. public UnitValue Unit = new UnitValue.Trigging();
  86. public override string ToString()
  87. {
  88. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  89. }
  90. public override Boolean GetValue(IEditorValueAdapter api, EventArguments args)
  91. {
  92. InstanceUnit unit = Unit.GetValue(api, args);
  93. if (unit != null)
  94. {
  95. return unit.GetEnvironmentVarAs<Boolean>(Key);
  96. }
  97. return false;
  98. }
  99. }
  100. [DescAttribute("单位变量", "单位 - 变量")]
  101. public class GetUnitAsUnit : UnitValue
  102. {
  103. [DescAttribute("变量名")]
  104. public string Key = "VarName";
  105. [DescAttribute("单位")]
  106. public UnitValue Unit = new UnitValue.Trigging();
  107. public override string ToString()
  108. {
  109. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  110. }
  111. public override InstanceUnit GetValue(IEditorValueAdapter api, EventArguments args)
  112. {
  113. InstanceUnit unit = Unit.GetValue(api, args);
  114. if (unit != null)
  115. {
  116. return unit.GetEnvironmentVarAs<InstanceUnit>(Key);
  117. }
  118. return null;
  119. }
  120. }
  121. [DescAttribute("单位变量", "单位 - 变量")]
  122. public class GetUnitAsItem : ItemValue
  123. {
  124. [DescAttribute("变量名")]
  125. public string Key = "VarName";
  126. [DescAttribute("单位")]
  127. public UnitValue Unit = new UnitValue.Trigging();
  128. public override string ToString()
  129. {
  130. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  131. }
  132. public override InstanceItem GetValue(IEditorValueAdapter api, EventArguments args)
  133. {
  134. InstanceUnit unit = Unit.GetValue(api, args);
  135. if (unit != null)
  136. {
  137. return unit.GetEnvironmentVarAs<InstanceItem>(Key);
  138. }
  139. return null;
  140. }
  141. }
  142. [DescAttribute("单位变量", "单位 - 变量")]
  143. public class GetUnitAsFlag : FlagValue
  144. {
  145. [DescAttribute("变量名")]
  146. public string Key = "VarName";
  147. [DescAttribute("单位")]
  148. public UnitValue Unit = new UnitValue.Trigging();
  149. public override string ToString()
  150. {
  151. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  152. }
  153. public override InstanceFlag GetValue(IEditorValueAdapter api, EventArguments args)
  154. {
  155. InstanceUnit unit = Unit.GetValue(api, args);
  156. if (unit != null)
  157. {
  158. return unit.GetEnvironmentVarAs<InstanceFlag>(Key);
  159. }
  160. return null;
  161. }
  162. }
  163. [DescAttribute("单位变量", "单位 - 变量")]
  164. public class GetUnitAsPosition : PositionValue
  165. {
  166. [DescAttribute("变量名")]
  167. public string Key = "VarName";
  168. [DescAttribute("单位")]
  169. public UnitValue Unit = new UnitValue.Trigging();
  170. public override string ToString()
  171. {
  172. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  173. }
  174. public override Vector2 GetValue(IEditorValueAdapter api, EventArguments args)
  175. {
  176. InstanceUnit unit = Unit.GetValue(api, args);
  177. if (unit != null)
  178. {
  179. return unit.GetEnvironmentVarAs<Vector2>(Key);
  180. }
  181. return null;
  182. }
  183. }
  184. #endregion
  185. //-------------------------------------------------------------------------------------------
  186. #region _获取_单位变量_StringValueKey_
  187. [DescAttribute("单位变量", "单位 - 变量(变量索引)")]
  188. public class GetUnitAsStringStringValueKey : StringValue
  189. {
  190. [DescAttribute("变量名")]
  191. public StringValue Key = new StringValue.VALUE("VarName");
  192. [DescAttribute("单位")]
  193. public UnitValue Unit = new UnitValue.Trigging();
  194. public override string ToString()
  195. {
  196. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  197. }
  198. public override string GetValue(IEditorValueAdapter api, EventArguments args)
  199. {
  200. InstanceUnit unit = Unit.GetValue(api, args);
  201. string key = Key.GetValue(api, args);
  202. if (unit != null && key != null)
  203. {
  204. return unit.GetEnvironmentVarAs<string>(key);
  205. }
  206. return null;
  207. }
  208. }
  209. [DescAttribute("单位变量", "单位 - 变量(变量索引)")]
  210. public class GetUnitAsIntegerStringValueKey : IntegerValue
  211. {
  212. [DescAttribute("变量名")]
  213. public StringValue Key = new StringValue.VALUE("VarName");
  214. [DescAttribute("单位")]
  215. public UnitValue Unit = new UnitValue.Trigging();
  216. public override string ToString()
  217. {
  218. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  219. }
  220. public override Int32 GetValue(IEditorValueAdapter api, EventArguments args)
  221. {
  222. InstanceUnit unit = Unit.GetValue(api, args);
  223. string key = Key.GetValue(api, args);
  224. if (unit != null && key != null)
  225. {
  226. return unit.GetEnvironmentVarAs<Int32>(key);
  227. }
  228. return 0;
  229. }
  230. }
  231. [DescAttribute("单位变量", "单位 - 变量(变量索引)")]
  232. public class GetUnitAsRealStringValueKey : RealValue
  233. {
  234. [DescAttribute("变量名")]
  235. public StringValue Key = new StringValue.VALUE("VarName");
  236. [DescAttribute("单位")]
  237. public UnitValue Unit = new UnitValue.Trigging();
  238. public override string ToString()
  239. {
  240. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  241. }
  242. public override Single GetValue(IEditorValueAdapter api, EventArguments args)
  243. {
  244. InstanceUnit unit = Unit.GetValue(api, args);
  245. string key = Key.GetValue(api, args);
  246. if (unit != null && key != null)
  247. {
  248. return unit.GetEnvironmentVarAs<Single>(key);
  249. }
  250. return 0;
  251. }
  252. }
  253. [DescAttribute("单位变量", "单位 - 变量(变量索引)")]
  254. public class GetUnitAsBooleanStringValueKey : BooleanValue
  255. {
  256. [DescAttribute("变量名")]
  257. public StringValue Key = new StringValue.VALUE("VarName");
  258. [DescAttribute("单位")]
  259. public UnitValue Unit = new UnitValue.Trigging();
  260. public override string ToString()
  261. {
  262. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  263. }
  264. public override Boolean GetValue(IEditorValueAdapter api, EventArguments args)
  265. {
  266. InstanceUnit unit = Unit.GetValue(api, args);
  267. string key = Key.GetValue(api, args);
  268. if (unit != null && key != null)
  269. {
  270. return unit.GetEnvironmentVarAs<Boolean>(key);
  271. }
  272. return false;
  273. }
  274. }
  275. [DescAttribute("单位变量", "单位 - 变量(变量索引)")]
  276. public class GetUnitAsUnitStringValueKey : UnitValue
  277. {
  278. [DescAttribute("变量名")]
  279. public StringValue Key = new StringValue.VALUE("VarName");
  280. [DescAttribute("单位")]
  281. public UnitValue Unit = new UnitValue.Trigging();
  282. public override string ToString()
  283. {
  284. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  285. }
  286. public override InstanceUnit GetValue(IEditorValueAdapter api, EventArguments args)
  287. {
  288. InstanceUnit unit = Unit.GetValue(api, args);
  289. string key = Key.GetValue(api, args);
  290. if (unit != null && key != null)
  291. {
  292. return unit.GetEnvironmentVarAs<InstanceUnit>(key);
  293. }
  294. return null;
  295. }
  296. }
  297. [DescAttribute("单位变量", "单位 - 变量(变量索引)")]
  298. public class GetUnitAsItemStringValueKey : ItemValue
  299. {
  300. [DescAttribute("变量名")]
  301. public StringValue Key = new StringValue.VALUE("VarName");
  302. [DescAttribute("单位")]
  303. public UnitValue Unit = new UnitValue.Trigging();
  304. public override string ToString()
  305. {
  306. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  307. }
  308. public override InstanceItem GetValue(IEditorValueAdapter api, EventArguments args)
  309. {
  310. InstanceUnit unit = Unit.GetValue(api, args);
  311. string key = Key.GetValue(api, args);
  312. if (unit != null && key != null)
  313. {
  314. return unit.GetEnvironmentVarAs<InstanceItem>(key);
  315. }
  316. return null;
  317. }
  318. }
  319. [DescAttribute("单位变量", "单位 - 变量(变量索引)")]
  320. public class GetUnitAsFlagStringValueKey : FlagValue
  321. {
  322. [DescAttribute("变量名")]
  323. public StringValue Key = new StringValue.VALUE("VarName");
  324. [DescAttribute("单位")]
  325. public UnitValue Unit = new UnitValue.Trigging();
  326. public override string ToString()
  327. {
  328. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  329. }
  330. public override InstanceFlag GetValue(IEditorValueAdapter api, EventArguments args)
  331. {
  332. InstanceUnit unit = Unit.GetValue(api, args);
  333. string key = Key.GetValue(api, args);
  334. if (unit != null && key != null)
  335. {
  336. return unit.GetEnvironmentVarAs<InstanceFlag>(key);
  337. }
  338. return null;
  339. }
  340. }
  341. [DescAttribute("单位变量", "单位 - 变量(变量索引)")]
  342. public class GetUnitAsPositionStringValueKey : PositionValue
  343. {
  344. [DescAttribute("变量名")]
  345. public StringValue Key = new StringValue.VALUE("VarName");
  346. [DescAttribute("单位")]
  347. public UnitValue Unit = new UnitValue.Trigging();
  348. public override string ToString()
  349. {
  350. return string.Format("获取单位({1})变量\"{0}\"", Key, Unit);
  351. }
  352. public override Vector2 GetValue(IEditorValueAdapter api, EventArguments args)
  353. {
  354. InstanceUnit unit = Unit.GetValue(api, args);
  355. string key = Key.GetValue(api, args);
  356. if (unit != null && key != null)
  357. {
  358. return unit.GetEnvironmentVarAs<Vector2>(key);
  359. }
  360. return null;
  361. }
  362. }
  363. #endregion
  364. }