ZoneSceneManagerComponentSystem.cs 1.4 KB

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