RobotManagerComponentSystem.cs 959 B

1234567891011121314151617181920212223242526272829303132
  1. namespace ET.Server
  2. {
  3. [EntitySystemOf(typeof(RobotManagerComponent))]
  4. [FriendOf(typeof(RobotManagerComponent))]
  5. public static partial class RobotManagerComponentSystem
  6. {
  7. [EntitySystem]
  8. private static void Awake(this RobotManagerComponent self)
  9. {
  10. }
  11. [EntitySystem]
  12. private static void Destroy(this RobotManagerComponent self)
  13. {
  14. async ETTask Remove(int f)
  15. {
  16. await FiberManager.Instance.Remove(f);
  17. }
  18. foreach (int fiberId in self.robots)
  19. {
  20. Remove(fiberId).NoContext();
  21. }
  22. }
  23. public static async ETTask NewRobot(this RobotManagerComponent self, string account)
  24. {
  25. int robot = await FiberManager.Instance.Create(SchedulerType.ThreadPool, self.Zone(), SceneType.Robot, account);
  26. self.robots.Add(robot);
  27. }
  28. }
  29. }