GamePlayerComponentSystem.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Linq;
  2. namespace ET.Server
  3. {
  4. [FriendOf(typeof (GamePlayerComponent))]
  5. public static class GamePlayerComponentSystem
  6. {
  7. public class PlayerComponentAwakeSystem: AwakeSystem<GamePlayerComponent>
  8. {
  9. /// <summary>
  10. /// 游戏服在线玩家组件创建
  11. /// </summary>
  12. /// <param name="self"></param>
  13. protected override void Awake(GamePlayerComponent self)
  14. {
  15. }
  16. }
  17. public class PlayerComponentDestroySystem: DestroySystem<GamePlayerComponent>
  18. {
  19. /// <summary>
  20. /// 游戏服在线玩家组件销毁
  21. /// </summary>
  22. /// <param name="self"></param>
  23. protected override void Destroy(GamePlayerComponent self)
  24. {
  25. }
  26. }
  27. public static void Add(this GamePlayerComponent self, long playerId, WNPlayer player)
  28. {
  29. self.idPlayers[playerId] = player;
  30. }
  31. public static WNPlayer Get(this GamePlayerComponent self, long id)
  32. {
  33. self.idPlayers.TryGetValue(id, out WNPlayer gamer);
  34. return gamer;
  35. }
  36. public static void Remove(this GamePlayerComponent self, long id)
  37. {
  38. self.idPlayers.Remove(id);
  39. }
  40. public static WNPlayer[] GetAll(this GamePlayerComponent self)
  41. {
  42. return self.idPlayers.Values.ToArray();
  43. }
  44. }
  45. }