暂存
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -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<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);
|
||||
Log.Message($"[WULA] Postfix: Added 'Autonomous Mechs' section with {autonomousMechs.Count} mechs.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<Pawn> __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<CompAutonomousMech>();
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@
|
||||
</Reference>
|
||||
<Reference Include="AlienRace">
|
||||
<HintPath>..\..\..\..\..\..\workshop\content\294100\839005762\1.6\Assemblies\AlienRace.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\..\..\..\..\..\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||
@@ -142,6 +143,8 @@
|
||||
<Compile Include="HarmonyPatches\WULA_AutonomousMech\Patch_FloatMenuOptionProvider_SelectedPawnValid.cs" />
|
||||
<Compile Include="HarmonyPatches\WULA_AutonomousMech\Patch_IsColonyMechPlayerControlled.cs" />
|
||||
<Compile Include="HarmonyPatches\WULA_AutonomousMech\Patch_MechanitorUtility_CanDraftMech.cs" />
|
||||
<Compile Include="HarmonyPatches\Patch_CaravanUIUtility_AddPawnsSections_Postfix.cs" />
|
||||
<Compile Include="HarmonyPatches\WULA_AutonomousMech\Patch_CaravanFormingUtility_AllSendablePawns.cs" />
|
||||
<Compile Include="HarmonyPatches\WULA_AutonomousMech\Patch_Pawn_ThreatDisabled.cs" />
|
||||
<Compile Include="HarmonyPatches\WULA_AutonomousMech\Patch_UncontrolledMechDrawPulse.cs" />
|
||||
<Compile Include="HediffComp\HediffCompProperties_NanoRepair.cs" />
|
||||
|
||||
Reference in New Issue
Block a user