PlayerSystem.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. namespace ET.Server
  2. {
  3. [FriendOf(typeof(Player))]
  4. public static class PlayerSystem
  5. {
  6. [ObjectSystem]
  7. public class PlayerAwakeSystem : AwakeSystem<Player, string>
  8. {
  9. protected override void Awake(Player self, string a)
  10. {
  11. Log.Info($"创建玩家实体...");
  12. self.Account = a;
  13. self.IsOnline = true;
  14. self.LoginTime = TimeHelper.ServerNow();
  15. self.RoomID = 0;
  16. // 添加本地玩家数据
  17. self.DomainScene().GetComponent<GamePlayerComponent>().Add(self);
  18. }
  19. }
  20. [ObjectSystem]
  21. public class PlayerDestroySystem : DestroySystem<Player>
  22. {
  23. protected override void Destroy(Player self)
  24. {
  25. Log.Info($"销毁玩家实体...");
  26. self.IsOnline = false;
  27. self.LogoutTime = TimeHelper.ServerNow();
  28. // 移除本地玩家数据
  29. self.DomainScene().GetComponent<GamePlayerComponent>()?.Remove(self.Id);
  30. }
  31. }
  32. }
  33. }