diff --git a/1.6/1.6/Assemblies/AlienRace.dll b/1.6/1.6/Assemblies/AlienRace.dll deleted file mode 100644 index dbf4c0dc..00000000 Binary files a/1.6/1.6/Assemblies/AlienRace.dll and /dev/null differ diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll index d2b3f983..6987661f 100644 Binary files a/1.6/1.6/Assemblies/WulaFallenEmpire.dll and b/1.6/1.6/Assemblies/WulaFallenEmpire.dll differ diff --git a/Source/WulaFallenEmpire/HarmonyPatches/Patch_CaravanUIUtility_AddPawnsSections_Postfix.cs b/Source/WulaFallenEmpire/HarmonyPatches/Patch_CaravanUIUtility_AddPawnsSections_Postfix.cs new file mode 100644 index 00000000..e12a04e5 --- /dev/null +++ b/Source/WulaFallenEmpire/HarmonyPatches/Patch_CaravanUIUtility_AddPawnsSections_Postfix.cs @@ -0,0 +1,33 @@ +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 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() != null; + }) + .ToList(); + + // 如果找到了任何自主机械体,就为它们添加一个新的分组 + if (autonomousMechs.Any()) + { + widget.AddSection("WULA_AutonomousMechsSection".Translate(), autonomousMechs); + Log.Message($"[WULA] Postfix: Added 'Autonomous Mechs' section with {autonomousMechs.Count} mechs."); + } + } + } +} \ No newline at end of file diff --git a/Source/WulaFallenEmpire/HarmonyPatches/WULA_AutonomousMech/Patch_CaravanFormingUtility_AllSendablePawns.cs b/Source/WulaFallenEmpire/HarmonyPatches/WULA_AutonomousMech/Patch_CaravanFormingUtility_AllSendablePawns.cs new file mode 100644 index 00000000..58d3cee1 --- /dev/null +++ b/Source/WulaFallenEmpire/HarmonyPatches/WULA_AutonomousMech/Patch_CaravanFormingUtility_AllSendablePawns.cs @@ -0,0 +1,45 @@ +using HarmonyLib; +using RimWorld; +using RimWorld.Planet; // 关键修复 +using System.Collections.Generic; +using Verse; + +namespace WulaFallenEmpire +{ + [HarmonyPatch(typeof(RimWorld.Planet.CaravanFormingUtility), "AllSendablePawns")] // 关键修复 + public static class Patch_CaravanFormingUtility_AllSendablePawns + { + [HarmonyPostfix] + public static void Postfix(Map map, ref List __result) + { + if (map == null) + { + return; + } + + Log.Message("[WULA] Patch_CaravanFormingUtility_AllSendablePawns Postfix - Start checking for autonomous mechs..."); + + // 遍历地图上所有的Pawn + foreach (Pawn pawn in map.mapPawns.AllPawns) + { + // 检查是否是殖民地派系的机械体 + if (pawn.IsColonyMech) + { + bool alreadyInList = __result.Contains(pawn); + var comp = pawn.GetComp(); + bool canBeAutonomous = comp != null && comp.CanBeAutonomous; + + Log.Message($"[WULA] Checking Mech: {pawn.LabelCap}, Already in list: {alreadyInList}, Has CompAutonomousMech: {comp != null}, CanBeAutonomous: {canBeAutonomous}"); + + // 如果它是一个可以自主行动的机械体,但没有被原版方法包含,我们就添加它 + if (!alreadyInList && canBeAutonomous) + { + __result.Add(pawn); + Log.Message($"[WULA] -> Added {pawn.LabelCap} to the list."); + } + } + } + Log.Message("[WULA] Patch_CaravanFormingUtility_AllSendablePawns Postfix - Finished."); + } + } +} \ No newline at end of file diff --git a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj index 21bdd02a..612709db 100644 --- a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj +++ b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj @@ -40,6 +40,7 @@ ..\..\..\..\..\..\workshop\content\294100\839005762\1.6\Assemblies\AlienRace.dll + False ..\..\..\..\..\..\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll @@ -142,6 +143,8 @@ + +