Node.cs 755 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.Collections.Generic;
  2. namespace Model
  3. {
  4. public abstract class Node
  5. {
  6. private readonly NodeConfig config;
  7. protected readonly List<Node> children = new List<Node>();
  8. protected Node(NodeConfig config)
  9. {
  10. this.config = config;
  11. }
  12. /// <summary>
  13. /// 策划配置的id
  14. /// </summary>
  15. public int Id
  16. {
  17. get
  18. {
  19. return this.config.Id;
  20. }
  21. }
  22. /// <summary>
  23. /// 节点的类型例如: NodeType.Not
  24. /// </summary>
  25. public NodeType Type
  26. {
  27. get
  28. {
  29. return this.config.Type;
  30. }
  31. }
  32. public List<string> Args
  33. {
  34. get
  35. {
  36. return this.config.Args;
  37. }
  38. }
  39. public void AddChild(Node child)
  40. {
  41. this.children.Add(child);
  42. }
  43. public virtual bool Run(Env env)
  44. {
  45. return true;
  46. }
  47. }
  48. }