WatcherComponentSystem.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections;
  2. using System.Diagnostics;
  3. namespace ET.Server
  4. {
  5. [FriendOf(typeof(WatcherComponent))]
  6. public static class WatcherComponentSystem
  7. {
  8. public class WatcherComponentAwakeSystem: AwakeSystem<WatcherComponent>
  9. {
  10. protected override void Awake(WatcherComponent self)
  11. {
  12. WatcherComponent.Instance = self;
  13. }
  14. }
  15. public class WatcherComponentDestroySystem: DestroySystem<WatcherComponent>
  16. {
  17. protected override void Destroy(WatcherComponent self)
  18. {
  19. WatcherComponent.Instance = null;
  20. }
  21. }
  22. public static void Start(this WatcherComponent self, int createScenes = 0)
  23. {
  24. string[] localIP = NetworkHelper.GetAddressIPs();
  25. var processConfigs = StartProcessConfigCategory.Instance.GetAll();
  26. foreach (StartProcessConfig startProcessConfig in processConfigs.Values)
  27. {
  28. if (!WatcherHelper.IsThisMachine(startProcessConfig.InnerIP, localIP))
  29. {
  30. continue;
  31. }
  32. Process process = WatcherHelper.StartProcess(startProcessConfig.Id, createScenes);
  33. self.Processes.Add(startProcessConfig.Id, process);
  34. }
  35. }
  36. }
  37. }