using System.Text; using Fantasy.Exporter; using Fantasy.Tools.ConfigTable; using System.Collections.Generic; namespace Exporter; public class ContainerConfigToEnum : ACustomExport { private class ContainerConfigInfo { public int Type; public string Name; public string Descride; } public override void Run() { if (!Worksheets.TryGetValue("ContainerConfig", out var containerConfig)) { Log.Info("ContainerConfig is null"); return; } var dic = new List(); for (int row = 7; row <= containerConfig.Dimension.Rows; row++) { var containerName = containerConfig.GetCellValue(row, 4); var containerType = containerConfig.GetCellValue(row, 6); var containerDes = containerConfig.GetCellValue(row, 5); dic.Add(new ContainerConfigInfo() { Type = int.Parse(containerType), Name = containerName, Descride = containerDes, }); } Write(dic, CustomExportType.Server); Write(dic, CustomExportType.Client); } private void Write(List dic, CustomExportType customExportType) { var strBuilder = new StringBuilder(); strBuilder.AppendLine("using System;\n"); strBuilder.AppendLine("namespace Fantasy\n{"); strBuilder.AppendLine("\t// 生成器自动生成,请不要手动编辑,修改请在ContainerConfig.xsl里。"); strBuilder.AppendLine("\t[Flags]"); strBuilder.AppendLine("\tpublic enum ContainerType : byte\n\t{"); strBuilder.AppendLine("\t\tNone = 0,"); foreach (var constValueInfo in dic) { strBuilder.AppendLine($"\t\t{constValueInfo.Name} = {constValueInfo.Type},// {constValueInfo.Descride}"); } strBuilder.AppendLine("\t\tCell = Equip | Trade,// 按格子存储的容器"); strBuilder.AppendLine("\t\tNormal = Bag,// 正常的容器"); strBuilder.AppendLine("\t}\n}"); Write("ContainerType.cs", strBuilder.ToString(), customExportType); } }