Files
WulaFallenEmpireRW/Source/WulaFallenEmpire/HarmonyPatches/Patch_CaravanUIUtility_AddPawnsSections_Postfix.cs
ProjectKoi-Kalo\Kalo 98a0400c78 WulaFallenEmpireSettings.cs - 添加了 public bool enableDebugLogs = false; 字段和保存配置
 WulaLog.cs - 修改了DebugEnabled属性,仅检查enableDebugLogs设置(不检查DevMode)
 WulaFallenEmpireMod.cs - 在DoSettingsWindowContents中添加了UI复选框,显示"Enable Debug Logs"选项
 替换了所有848个Log.Message/Error/Warning调用为WulaLog.Debug()
2025-12-15 13:05:50 +08:00

33 lines
1.2 KiB
C#

using HarmonyLib;
using RimWorld;
using RimWorld.Planet;
using System.Collections.Generic;
using System.Linq;
using Verse;
namespace WulaFallenEmpire
{
[HarmonyPatch(typeof(CaravanUIUtility), "AddPawnsSections")]
public static class Patch_CaravanUIUtility_AddPawnsSections_Postfix
{
[HarmonyPostfix]
public static void Postfix(TransferableOneWayWidget widget, List<TransferableOneWay> transferables)
{
// 筛选出所有拥有自主组件的机械体
var autonomousMechs = transferables
.Where(x => {
if (x.ThingDef.category != ThingCategory.Pawn) return false;
var pawn = x.AnyThing as Pawn;
return pawn != null && pawn.GetComp<CompAutonomousMech>() != null;
})
.ToList();
// 如果找到了任何自主机械体,就为它们添加一个新的分组
if (autonomousMechs.Any())
{
widget.AddSection("WULA_AutonomousMechsSection".Translate(), autonomousMechs);
WulaLog.Debug($"[WULA] Postfix: Added 'Autonomous Mechs' section with {autonomousMechs.Count} mechs.");
}
}
}
}