ZoneSceneManagerComponentSystem.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. namespace ET
  3. {
  4. [ObjectSystem]
  5. public class ZoneSceneManagerComponentAwakeSystem: AwakeSystem<ZoneSceneManagerComponent>
  6. {
  7. public override void Awake(ZoneSceneManagerComponent self)
  8. {
  9. ZoneSceneManagerComponent.Instance = self;
  10. }
  11. }
  12. [ObjectSystem]
  13. public class ZoneSceneManagerComponentDestroySystem: DestroySystem<ZoneSceneManagerComponent>
  14. {
  15. public override void Destroy(ZoneSceneManagerComponent self)
  16. {
  17. self.ZoneScenes.Clear();
  18. }
  19. }
  20. public static class ZoneSceneManagerComponentSystem
  21. {
  22. public static Scene ZoneScene(this Entity entity)
  23. {
  24. return ZoneSceneManagerComponent.Instance.Get(entity.DomainZone());
  25. }
  26. public static void Add(this ZoneSceneManagerComponent self, Scene zoneScene)
  27. {
  28. self.ZoneScenes.Add(zoneScene.Zone, zoneScene);
  29. }
  30. public static Scene Get(this ZoneSceneManagerComponent self, int zone)
  31. {
  32. self.ZoneScenes.TryGetValue(zone, out Scene scene);
  33. return scene;
  34. }
  35. public static void Remove(this ZoneSceneManagerComponent self, int zone)
  36. {
  37. self.ZoneScenes.Remove(zone);
  38. }
  39. }
  40. }