GameRoomComponentSystem.cs 651 B

12345678910111213141516171819202122232425262728
  1. using System.Linq;
  2. namespace ET.Server;
  3. [FriendOf(typeof(GameRoomComponent))]
  4. public static class GameRoomComponentSystem
  5. {
  6. public static void Add(this GameRoomComponent self, Room room)
  7. {
  8. self.idRooms.Add(room.RoomId, room);
  9. }
  10. public static Room Get(this GameRoomComponent self, int roomId)
  11. {
  12. self.idRooms.TryGetValue(roomId, out Room room);
  13. return room;
  14. }
  15. public static void Remove(this GameRoomComponent self, int roomId)
  16. {
  17. self.idRooms.Remove(roomId);
  18. }
  19. public static Room[] GetAll(this GameRoomComponent self)
  20. {
  21. return self.idRooms.Values.ToArray();
  22. }
  23. }