ReloadConfigConsoleHandler.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. namespace ET
  3. {
  4. [ConsoleHandler(ConsoleMode.ReloadConfig)]
  5. public class ReloadConfigConsoleHandler: IConsoleHandler
  6. {
  7. public async ETTask Run(ModeContex contex, string content)
  8. {
  9. switch (content)
  10. {
  11. case ConsoleMode.ReloadConfig:
  12. contex.Parent.RemoveComponent<ModeContex>();
  13. Log.Console("C must have config name, like: C UnitConfig");
  14. break;
  15. default:
  16. string[] ss = content.Split(" ");
  17. string configName = ss[1];
  18. string category = $"{configName}Category";
  19. Type type = EventSystem.Instance.GetType($"ET.{category}");
  20. if (type == null)
  21. {
  22. Log.Console($"reload config but not find {category}");
  23. return;
  24. }
  25. ConfigComponent.Instance.LoadOneConfig(type);
  26. Log.Console($"reload config {configName} finish!");
  27. break;
  28. }
  29. await ETTask.CompletedTask;
  30. }
  31. }
  32. }