RuntimePackage.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using IwbZero.IwbId;
  4. using WeEngine.Enum;
  5. namespace WeEngine
  6. {
  7. /// <summary>
  8. /// 方案包运行态
  9. /// </summary>
  10. public class RuntimePackage:IIwbId
  11. {
  12. public Package PackageInfo { get; set; }
  13. public string Id { get; set; }
  14. #region CurrentInfo
  15. public int CurRoundIndex => CurRoundInfo.RoundIndex;
  16. public SceneRound CurRoundInfo => GetCurrentRoundInfo();
  17. public List<SceneFlowBlock> CurSceneFlowBlocks => GetCurrentFlowBlocks();
  18. public List<SceneFlow> CurSceneFlows => GetCurrentFlows();
  19. public List<SceneFloor> CurSceneFloors => GetCurrentFloors();
  20. public List<SceneInfo> CurSceneInfos => GetCurrentSceneInfos();
  21. public List<BehaviorInfo> CurBehaviorInfos => GetCurrentBehaviors();
  22. public List<KeyWord> CurKeyWords => GetCurrentKeyWords();
  23. private SceneRound GetCurrentRoundInfo()
  24. {
  25. return (SceneRound)PackageInfo.Children.FirstOrDefault(a => a.NodeState == NodeState.Running);
  26. }
  27. private List<SceneFlowBlock> GetCurrentFlowBlocks()
  28. {
  29. var list = new List<SceneFlowBlock>();
  30. var children = CurRoundInfo.HasChild ? CurRoundInfo.Children.Where(a => a.NodeState == NodeState.Running).Select(a => (SceneFlowBlock)a).ToList() : new List<SceneFlowBlock>();
  31. list.AddRange(children);
  32. return list;
  33. }
  34. private List<SceneFlow> GetCurrentFlows()
  35. {
  36. var list = new List<SceneFlow>();
  37. foreach (var cur in CurSceneFlowBlocks)
  38. {
  39. var children = cur.HasChild ? cur.Children.Where(a => a.NodeState == NodeState.Running).Select(a => (SceneFlow)a).ToList() : new List<SceneFlow>();
  40. list.AddRange(children);
  41. }
  42. return list;
  43. }
  44. private List<SceneFloor> GetCurrentFloors()
  45. {
  46. var list = new List<SceneFloor>();
  47. foreach (var cur in CurSceneFlows)
  48. {
  49. var children = cur.HasChild ? cur.Children.Where(a => a.NodeState == NodeState.Running).Select(a => (SceneFloor)a).ToList() : new List<SceneFloor>();
  50. list.AddRange(children);
  51. }
  52. return list;
  53. }
  54. private List<SceneInfo> GetCurrentSceneInfos()
  55. {
  56. var list = new List<SceneInfo>();
  57. foreach (var cur in CurSceneFloors)
  58. {
  59. var sceneNode = cur.Children.FirstOrDefault(a => a.NodeState == NodeState.Running);
  60. var children = sceneNode?.HasChild == true
  61. ? sceneNode.Children.Where(a => a.NodeState == NodeState.Running).Select(a => (SceneInfo)a)
  62. .ToList()
  63. : new List<SceneInfo>();
  64. list.AddRange(children);
  65. }
  66. return list;
  67. }
  68. private List<BehaviorInfo> GetCurrentBehaviors()
  69. {
  70. var list = new List<BehaviorInfo>();
  71. foreach (var cur in CurSceneInfos)
  72. {
  73. var children = cur.HasChild ? cur.Children.Where(a => a.NodeState == NodeState.Running).Select(a => (BehaviorInfo)a).ToList() : new List<BehaviorInfo>();
  74. list.AddRange(children);
  75. }
  76. return list;
  77. }
  78. private List<KeyWord> GetCurrentKeyWords()
  79. {
  80. var list = new List<KeyWord>();
  81. foreach (var cur in CurBehaviorInfos)
  82. {
  83. var children = cur.HasChild
  84. ? cur.Children.Where(a => a.NodeState == NodeState.Running).Select(a => (KeyWord)a).ToList()
  85. : new List<KeyWord>();
  86. list.AddRange(children);
  87. }
  88. return list;
  89. }
  90. #endregion
  91. }
  92. }