WatcherComponentSystem.cs 1.2 KB

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