123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using System.Linq;
- namespace ET.Server
- {
- [FriendOf(typeof (GameMapComponent))]
- public static class GameMapComponentSystem
- {
- public class GameMapComponentAwakeSystem: AwakeSystem<GameMapComponent>
- {
-
-
-
-
- protected override void Awake(GameMapComponent self)
- {
- GameMapComponent.Instance = self;
-
- }
- }
- public class GameMapComponentDestroySystem: DestroySystem<GameMapComponent>
- {
-
-
-
-
- protected override void Destroy(GameMapComponent self)
- {
- }
- }
- public static void Add(this GameMapComponent self, long roomId, Map map)
- {
- self.allMaps.TryAdd(map.Id, map);
-
- self.rooms.TryAdd(roomId, map.Id);
- }
- public static Map Get(this GameMapComponent self, long instanceId)
- {
- self.allMaps.TryGetValue(instanceId, out Map map);
- return map;
- }
- public static void Remove(this GameMapComponent self, long instanceId, long roomId)
- {
- self.allMaps.Remove(instanceId);
-
- self.rooms.Remove(roomId);
- }
- public static Map[] GetAll(this GameMapComponent self)
- {
- return self.allMaps.Values.ToArray();
- }
- public static Map GetMapByRoomId(this GameMapComponent self, long roomId)
- {
- if (!self.rooms.TryGetValue(roomId, out long instanceId))
- {
- return null;
- }
- if (instanceId > 0)
- {
- return self.Get(instanceId);
- }
- return null;
- }
- }
- }
|