Files
WulaFallenEmpireRW/Source/WulaFallenEmpire/Pawn/WULA_AutonomousMech/Patch_IsColonyMechPlayerControlled.cs
Tourswen 242866bada 好玩
2025-11-03 02:39:00 +08:00

42 lines
1.1 KiB
C#
Raw 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;
namespace WulaFallenEmpire
{
[HarmonyPatch(typeof(Pawn), "get_IsColonyMechPlayerControlled")]
public static class Patch_IsColonyMechPlayerControlled
{
[HarmonyPostfix]
public static void Postfix(Pawn __instance, ref bool __result)
{
// 如果原版已经返回true不需要修改
if (__result)
return;
// 检查是否是殖民地机械
if (!__instance.IsColonyMech)
return;
// 检查是否有自主机械组件
var comp = __instance.GetComp<CompAutonomousMech>();
if (comp == null)
return;
// 如果机械族处于自主战斗模式,则视为玩家控制
if (comp.CanFightAutonomously)
{
__result = true;
return;
}
// 如果机械族处于自主工作模式,也视为玩家控制(用于工作相关判定)
if (comp.CanWorkAutonomously)
{
__result = true;
return;
}
}
}
}