NodeComponent.cs 823 B

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