PlayerSystem.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. namespace ET.Server
  4. {
  5. [FriendOf(typeof(Player))]
  6. public static class PlayerSystem
  7. {
  8. [ObjectSystem]
  9. public class PlayerAwakeSystem : AwakeSystem<Player, Session>
  10. {
  11. protected override void Awake(Player self, Session session)
  12. {
  13. Log.Info($"创建玩家实体...");
  14. self.GameSessionActorId = session.InstanceId;
  15. self.Session = session;
  16. // self.Account = a;
  17. self.LoginTime = TimeHelper.ServerNow();
  18. self.IsOnline = true;
  19. self.IsAuto = false;
  20. self.RemainCards = Array.Empty<int>();
  21. self.DisCards = Array.Empty<int>();
  22. self.KeZi = new List<Struct.Kezi>();
  23. self.Act = new int[5];
  24. self.ActInfo = new List<Struct.Kezi>();
  25. self.HuCards = new List<int>();
  26. // 添加本地玩家数据
  27. self.DomainScene().GetComponent<GamePlayerComponent>().Add(self);
  28. }
  29. }
  30. [ObjectSystem]
  31. public class PlayerDestroySystem : DestroySystem<Player>
  32. {
  33. protected override void Destroy(Player self)
  34. {
  35. Log.Info($"销毁玩家实体...");
  36. self.IsOnline = false;
  37. self.LogoutTime = TimeHelper.ServerNow();
  38. // 移除本地玩家数据
  39. self.DomainScene().GetComponent<GamePlayerComponent>()?.Remove(self.Id);
  40. }
  41. }
  42. }
  43. }