Component.cs 716 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. namespace AtomicEngine
  3. {
  4. public partial class Component : Animatable
  5. {
  6. /// <summary>
  7. /// Whether the component has been explicitly destroyed
  8. /// </summary>
  9. public bool Destroyed { get; private set; }
  10. /// <summary>
  11. /// Explicitly removes component and disposes of it
  12. /// </summary>
  13. public virtual void Destroy()
  14. {
  15. if (Destroyed)
  16. return;
  17. Destroyed = true;
  18. Remove();
  19. Dispose();
  20. }
  21. public T GetComponent<T>(bool recursive = false) where T : Component
  22. {
  23. return Node.GetComponent<T>(recursive);
  24. }
  25. }
  26. }