NodeComponent.cs 787 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. namespace XGame.Framework.Nodes
  3. {
  4. /// <summary>
  5. /// node的逻辑组件基类
  6. /// </summary>
  7. public abstract class NodeComponent : INodeComponent, IDisposable
  8. {
  9. private NodeContext _context;
  10. public NodeContext Context => _context;
  11. /// <summary>
  12. /// node节点的忽略order
  13. /// </summary>
  14. public int Order => 0;
  15. public void Bind(object context)
  16. {
  17. _context = context as NodeContext;
  18. }
  19. void IDisposable.Dispose()
  20. {
  21. OnDispose();
  22. _context = default;
  23. }
  24. public abstract void OnEnable(object intent);
  25. public abstract void OnDisable();
  26. protected virtual void OnDispose()
  27. {
  28. }
  29. }
  30. }