HGHHMainCheckerComponentSystem.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. namespace ET.Server
  3. {
  4. [Invoke(TimerInvokeType.HGHHMainChecker)]
  5. public class HGHHMainChecker: ATimer<HGHHMainCheckerComponent>
  6. {
  7. protected override void Run(HGHHMainCheckerComponent self)
  8. {
  9. try
  10. {
  11. self.Check();
  12. }
  13. catch (Exception e)
  14. {
  15. Log.Error($"move timer error: {self.Id}\n{e}");
  16. }
  17. }
  18. }
  19. [ObjectSystem]
  20. public class HGHHMainCheckerComponentAwakeSystem: AwakeSystem<HGHHMainCheckerComponent>
  21. {
  22. protected override void Awake(HGHHMainCheckerComponent self)
  23. {
  24. Log.Info($"创建黄冈晃晃主逻辑组件...");
  25. self.RepeatedTimer = TimerComponent.Instance.NewRepeatedTimer(1000, TimerInvokeType.HGHHMainChecker, self);
  26. }
  27. }
  28. [ObjectSystem]
  29. public class HGHHMainCheckerComponentDestroySystem: DestroySystem<HGHHMainCheckerComponent>
  30. {
  31. protected override void Destroy(HGHHMainCheckerComponent self)
  32. {
  33. Log.Info($"销毁黄冈晃晃主逻辑组件...");
  34. TimerComponent.Instance?.Remove(ref self.RepeatedTimer);
  35. }
  36. }
  37. public static class HGHHMainCheckerComponentSystem
  38. {
  39. // 黄冈晃晃牌库
  40. public static void Check(this HGHHMainCheckerComponent self)
  41. {
  42. Room room = self.GetParent<Room>();
  43. if (room == null)
  44. {
  45. Log.Error($"黄冈晃晃主逻辑组件获取不到主实体...");
  46. return;
  47. }
  48. Log.Debug($"检测: 黄冈晃晃-房间号:{room.RoomId}, 状态:{room.State}...");
  49. }
  50. }
  51. }