Files
WulaFallenEmpireRW/Source/WulaFallenEmpire/HarmonyPatches/WULA_AutonomousMech/Patch_Pawn_ThreatDisabled.cs
Tourswen 66c4ce1177
2025-12-14 17:17:58 +08:00

40 lines
1.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using HarmonyLib;
using RimWorld;
using Verse;
using Verse.AI;
using System.Collections.Generic;
namespace WulaFallenEmpire
{
// 核心补丁:修复威胁禁用检查
[HarmonyPatch(typeof(Pawn), "ThreatDisabled")]
public static class Patch_Pawn_ThreatDisabled
{
public static void Postfix(Pawn __instance, ref bool __result)
{
// 如果已经判定为无威胁检查是否有CompAutonomousMech组件
if (__result && __instance.GetComp<CompAutonomousMech>() != null)
{
__result = false; // 强制设置为有威胁
}
}
}
// 核心补丁:修复机械师需求检查 - 正确的方法在 MechanitorUtility 中
[HarmonyPatch(typeof(MechanitorUtility), "IsColonyMechRequiringMechanitor")]
public static class Patch_MechanitorUtility_IsColonyMechRequiringMechanitor
{
public static void Postfix(Pawn mech, ref bool __result)
{
if (__result && mech.IsColonyMech)
{
var comp = mech.GetComp<CompAutonomousMech>();
if (comp != null && comp.CanFightAutonomously)
{
__result = false;
}
}
}
}
}