提交示例代码

This commit is contained in:
Bob.Song
2026-03-05 11:39:06 +08:00
commit 25958f58c3
2534 changed files with 209593 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
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<ContainerConfigInfo>();
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<ContainerConfigInfo> 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);
}
}