GamePlayerComponentSystem.cs 758 B

1234567891011121314151617181920212223242526272829
  1. using System.Linq;
  2. namespace ET.Server
  3. {
  4. [FriendOf(typeof(GamePlayerComponent))]
  5. public static class GamePlayerComponentSystem
  6. {
  7. public static void Add(this GamePlayerComponent self, Player player)
  8. {
  9. self.idPlayers.Add(player.Id, player);
  10. }
  11. public static Player Get(this GamePlayerComponent self, long id)
  12. {
  13. self.idPlayers.TryGetValue(id, out Player gamer);
  14. return gamer;
  15. }
  16. public static void Remove(this GamePlayerComponent self, long id)
  17. {
  18. self.idPlayers.Remove(id);
  19. }
  20. public static Player[] GetAll(this GamePlayerComponent self)
  21. {
  22. return self.idPlayers.Values.ToArray();
  23. }
  24. }
  25. }