提交示例代码
This commit is contained in:
60
物品和背包的完整代码/Config/Excel/Custom/ItemUseEffectToEnum.cs
Normal file
60
物品和背包的完整代码/Config/Excel/Custom/ItemUseEffectToEnum.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Tools.ConfigTable;
|
||||
|
||||
namespace Exporter;
|
||||
|
||||
public sealed class ItemUseEffectToEnum : ACustomExport
|
||||
{
|
||||
private class ItemUseEffectInfo
|
||||
{
|
||||
public int Index;
|
||||
public string Name;
|
||||
public string Descride;
|
||||
}
|
||||
public override void Run()
|
||||
{
|
||||
if (!ExcelExporter.IgnoreTable.TryGetValue("#ItemUseEffect", out var itemTypePath))
|
||||
{
|
||||
Log.Error("ItemUseEffect is null");
|
||||
return;
|
||||
}
|
||||
|
||||
var dic = new List<ItemUseEffectInfo>();
|
||||
var excelWorksheet = ExcelExporter.LoadExcel(itemTypePath, false);
|
||||
for (int row = 2; row <= excelWorksheet.Dimension.Rows; row++)
|
||||
{
|
||||
var exportIndex = excelWorksheet.GetCellValue(row, 1);
|
||||
if (string.IsNullOrEmpty(exportIndex))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
dic.Add(new ItemUseEffectInfo()
|
||||
{
|
||||
Index = int.Parse(exportIndex),
|
||||
Name = excelWorksheet.GetCellValue(row, 2),
|
||||
Descride = excelWorksheet.GetCellValue(row, 3),
|
||||
});
|
||||
}
|
||||
|
||||
Write(dic, CustomExportType.Server);
|
||||
Write(dic, CustomExportType.Client);
|
||||
}
|
||||
|
||||
private void Write(List<ItemUseEffectInfo> dic, CustomExportType customExportType)
|
||||
{
|
||||
var strBuilder = new StringBuilder();
|
||||
strBuilder.AppendLine("namespace Fantasy\n{");
|
||||
strBuilder.AppendLine("\t// 生成器自动生成,请不要手动编辑,修改请在#ItemUseEffect.xsl里。");
|
||||
strBuilder.AppendLine("\tpublic enum ItemUseEffect\n\t{");
|
||||
strBuilder.AppendLine("\t\tNone = 0,");
|
||||
foreach (var constValueInfo in dic)
|
||||
{
|
||||
strBuilder.AppendLine($"\t\t{constValueInfo.Name} = {constValueInfo.Index},// {constValueInfo.Descride}");
|
||||
}
|
||||
strBuilder.AppendLine("\t}\n}");
|
||||
Write("ItemUseEffect.cs", strBuilder.ToString(), customExportType);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user