GameMapComponentSystem.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.Linq;
  2. namespace ET.Server
  3. {
  4. public class GameMapComponentAwakeSystem: AwakeSystem<GameMapComponent>
  5. {
  6. /// <summary>
  7. /// 游戏服场景组件创建
  8. /// </summary>
  9. /// <param name="self"></param>
  10. protected override void Awake(GameMapComponent self)
  11. {
  12. // todo 添加场景销毁检测定时器
  13. }
  14. }
  15. public class GameMapComponentDestroySystem: DestroySystem<GameMapComponent>
  16. {
  17. /// <summary>
  18. /// 游戏服场景组件销毁
  19. /// </summary>
  20. /// <param name="self"></param>
  21. /// <exception cref="NotImplementedException"></exception>
  22. protected override void Destroy(GameMapComponent self)
  23. {
  24. }
  25. }
  26. [FriendOf(typeof (GameMapComponent))]
  27. public static class GameMapComponentSystem
  28. {
  29. public static void Add(this GameMapComponent self, Map map)
  30. {
  31. if (!self.allMaps.ContainsKey(map.Id))
  32. {
  33. self.allMaps.Add(map.Id, map);
  34. }
  35. }
  36. public static Map Get(this GameMapComponent self, long instanceId)
  37. {
  38. self.allMaps.TryGetValue(instanceId, out Map map);
  39. return map;
  40. }
  41. public static void Remove(this GameMapComponent self, long instanceId)
  42. {
  43. self.allMaps.Remove(instanceId);
  44. }
  45. public static Map[] GerAll(this GameMapComponent self)
  46. {
  47. return self.allMaps.Values.ToArray();
  48. }
  49. }
  50. }