UnitComponentSystem.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. namespace ET
  2. {
  3. [ObjectSystem]
  4. public class UnitComponentAwakeSystem : AwakeSystem<UnitComponent>
  5. {
  6. protected override void Awake(UnitComponent self)
  7. {
  8. }
  9. }
  10. [ObjectSystem]
  11. public class UnitComponentDestroySystem : DestroySystem<UnitComponent>
  12. {
  13. protected override void Destroy(UnitComponent self)
  14. {
  15. }
  16. }
  17. [FriendOfAttribute(typeof(ET.UnitComponent))]
  18. public static class UnitComponentSystem
  19. {
  20. public static void Add(this UnitComponent self, Unit unit)
  21. {
  22. if (unit.IsActor)
  23. {
  24. self.IDActor = unit.Id;
  25. }
  26. }
  27. public static Unit GetActor(this UnitComponent self)
  28. {
  29. return self.GetChild<Unit>(self.IDActor);
  30. }
  31. public static Unit Get(this UnitComponent self, long id)
  32. {
  33. Unit unit = self.GetChild<Unit>(id);
  34. return unit;
  35. }
  36. public static void Remove(this UnitComponent self, long id)
  37. {
  38. Unit unit = self.GetChild<Unit>(id);
  39. unit?.Dispose();
  40. }
  41. }
  42. }