using System; using System.Collections.Generic; using System.IO; using UnityEngine; namespace ET { [Invoke] public class GetAllConfigBytes: AInvokeHandler>> { public override async ETTask> Handle(ConfigLoader.GetAllConfigBytes args) { Dictionary output = new Dictionary(); HashSet configTypes = CodeTypes.Instance.GetTypes(typeof (ConfigAttribute)); if (Define.IsEditor) { string ct = "cs"; GlobalConfig globalConfig = Resources.Load("GlobalConfig"); CodeMode codeMode = globalConfig.CodeMode; switch (codeMode) { case CodeMode.Client: ct = "c"; break; case CodeMode.Server: ct = "s"; break; case CodeMode.ClientServer: ct = "cs"; break; default: throw new ArgumentOutOfRangeException(); } List startConfigs = new List() { "StartMachineConfigCategory", "StartProcessConfigCategory", "StartSceneConfigCategory", "StartZoneConfigCategory", }; foreach (Type configType in configTypes) { string configFilePath; if (startConfigs.Contains(configType.Name)) { configFilePath = $"../Config/Excel/{ct}/{Options.Instance.StartConfig}/{configType.Name}.bytes"; } else { configFilePath = $"../Config/Excel/{ct}/{configType.Name}.bytes"; } output[configType] = File.ReadAllBytes(configFilePath); } } else { foreach (Type type in configTypes) { TextAsset v = await ResourcesComponent.Instance.LoadAssetAsync($"Assets/Bundles/Config/{type.Name}.bytes"); output[type] = v.bytes; } } return output; } } [Invoke] public class GetOneConfigBytes: AInvokeHandler> { public override async ETTask Handle(ConfigLoader.GetOneConfigBytes args) { string ct = "cs"; GlobalConfig globalConfig = Resources.Load("GlobalConfig"); CodeMode codeMode = globalConfig.CodeMode; switch (codeMode) { case CodeMode.Client: ct = "c"; break; case CodeMode.Server: ct = "s"; break; case CodeMode.ClientServer: ct = "cs"; break; default: throw new ArgumentOutOfRangeException(); } List startConfigs = new List() { "StartMachineConfigCategory", "StartProcessConfigCategory", "StartSceneConfigCategory", "StartZoneConfigCategory", }; string configName = args.ConfigName; string configFilePath; if (startConfigs.Contains(configName)) { configFilePath = $"../Config/Excel/{ct}/{Options.Instance.StartConfig}/{configName}.bytes"; } else { configFilePath = $"../Config/Excel/{ct}/{configName}.bytes"; } await ETTask.CompletedTask; return File.ReadAllBytes(configFilePath); } } }