ConfigLoader.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. namespace ET.Server
  5. {
  6. [Invoke]
  7. public class GetAllConfigBytes: AInvokeHandler<ConfigComponent.GetAllConfigBytes, Dictionary<Type, byte[]>>
  8. {
  9. public override Dictionary<Type, byte[]> Handle(ConfigComponent.GetAllConfigBytes args)
  10. {
  11. Dictionary<Type, byte[]> output = new Dictionary<Type, byte[]>();
  12. List<string> startConfigs = new List<string>()
  13. {
  14. "StartMachineConfigCategory",
  15. "StartProcessConfigCategory",
  16. "StartSceneConfigCategory",
  17. "StartZoneConfigCategory",
  18. };
  19. HashSet<Type> configTypes = EventSystem.Instance.GetTypes(typeof (ConfigAttribute));
  20. foreach (Type configType in configTypes)
  21. {
  22. string configFilePath = startConfigs.Contains(configType.Name)? $"../Config/GenFromExcel/s/{Options.Instance.StartConfig}/{configType.Name}.bytes" : $"../Config/GenFromExcel/s/{configType.Name}.bytes";
  23. output[configType] = File.ReadAllBytes(configFilePath);
  24. }
  25. return output;
  26. }
  27. }
  28. [Invoke]
  29. public class GetOneConfigBytes: AInvokeHandler<ConfigComponent.GetOneConfigBytes, byte[]>
  30. {
  31. public override byte[] Handle(ConfigComponent.GetOneConfigBytes args)
  32. {
  33. return File.ReadAllBytes($"../Config/GenFromExcel/{args.ConfigName}.bytes");
  34. }
  35. }
  36. }