可控机械族(未完成)
This commit is contained in:
Binary file not shown.
@@ -1,6 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
<ThingDef Abstract="True" Name="Wula_Human_Protect_Superclass" ParentName="BasePawn">
|
||||
<!-- human的克隆,防止其他mod修改human导致的不兼容 -->
|
||||
<ThingDef Name="Wula_Human_Protect_Superclass" ParentName="BasePawn">
|
||||
<defName>Human</defName>
|
||||
<label>human</label>
|
||||
<description>A baseline human, mostly unmodified by gene engineering and mostly unchanged by evolutionary pressures on non-Earth planets.</description>
|
||||
<statBases>
|
||||
<MarketValue>1750</MarketValue>
|
||||
<MoveSpeed>4.6</MoveSpeed>
|
||||
@@ -221,10 +225,16 @@
|
||||
</li>
|
||||
</comps>
|
||||
</ThingDef>
|
||||
<AlienRace.ThingDef_AlienRace Name="Race_Wula_Machine" ParentName="Wula_Human_Protect_Superclass">
|
||||
<!-- 基础类,希望对human的更改在此处应用 -->
|
||||
<ThingDef Abstract="True" Name="Wula_Human_Base" ParentName="Wula_Human_Protect_Superclass">
|
||||
<statBases>
|
||||
<MarketValue>0</MarketValue>
|
||||
</statBases>
|
||||
</ThingDef>
|
||||
<AlienRace.ThingDef_AlienRace Name="Race_Wula_Machine" ParentName="Wula_Human_Base">
|
||||
<defName>WulaSpecies</defName>
|
||||
<label>机械乌拉</label>
|
||||
<description>乌拉星人是一个曾统治银河系的堕落帝国的主要种族,机械乌拉则是仿照她们样貌制作的合成人——随着帝国的衰颓,大量乌拉合成人流散各地。她们拥有近乎无限的寿命,并且拥有一部分机械体的特性。</description>
|
||||
<description>诞生于乌拉帝国的机械生命体</description>
|
||||
<uiIconPath>Wula/Things/WulaSpecies/WULA_Species_Icon</uiIconPath>
|
||||
|
||||
<alienRace>
|
||||
@@ -1355,6 +1365,7 @@
|
||||
<WastepacksPerRecharge MayRequire="Ludeon.RimWorld.Biotech">0</WastepacksPerRecharge>
|
||||
</statBases>
|
||||
<race>
|
||||
<thinkTreeMain>WULA_AutonomousMech</thinkTreeMain>
|
||||
<mechEnabledWorkTypes>
|
||||
<li>Hauling</li>
|
||||
<!-- <li>Mining</li> -->
|
||||
@@ -1385,6 +1396,11 @@
|
||||
</deathAction>
|
||||
</race>
|
||||
<comps>
|
||||
<li Class="WulaFallenEmpire.CompProperties_AutonomousMech">
|
||||
<enableAutonomousDrafting>true</enableAutonomousDrafting>
|
||||
<enableAutonomousWork>true</enableAutonomousWork>
|
||||
<requirePowerForAutonomy>true</requirePowerForAutonomy>
|
||||
</li>
|
||||
<!--
|
||||
全局指挥组件 (Global Mech Command Component)
|
||||
此组件通过Harmony补丁 MechanitorUtility_InMechanitorCommandRange_Patch.cs 来实现功能。
|
||||
|
||||
169
1.6/1.6/Defs/ThinkTreeDefs/WULA_AutonomousMech.xml
Normal file
169
1.6/1.6/Defs/ThinkTreeDefs/WULA_AutonomousMech.xml
Normal file
@@ -0,0 +1,169 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
<ThinkTreeDef>
|
||||
<defName>WULA_AutonomousMech</defName>
|
||||
<thinkRoot Class="ThinkNode_Priority">
|
||||
<subNodes>
|
||||
<!-- Despawned -->
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>Despawned</treeDef>
|
||||
</li>
|
||||
|
||||
<!-- Deactivated -->
|
||||
<li Class="ThinkNode_ConditionalDeactivated" MayRequire="Ludeon.RimWorld.Odyssey">
|
||||
<subNodes>
|
||||
<li Class="JobGiver_Deactivated" />
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Downed -->
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>Downed</treeDef>
|
||||
</li>
|
||||
|
||||
<!-- Self-Shutdown -->
|
||||
<li Class="ThinkNode_ConditionalLowEnergy" MayRequire="Ludeon.RimWorld.Biotech">
|
||||
<subNodes>
|
||||
<li Class="JobGiver_SelfShutdown" />
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Mental state -->
|
||||
<li Class="ThinkNode_ConditionalMentalState">
|
||||
<state>BerserkMechanoid</state>
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Priority">
|
||||
<subNodes>
|
||||
<li Class="JobGiver_Berserk" />
|
||||
<li Class="JobGiver_WanderAnywhere">
|
||||
<maxDanger>Deadly</maxDanger>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Do a queued job (支持右键强制高优先级工作) -->
|
||||
<li Class="ThinkNode_QueuedJob" />
|
||||
|
||||
<!-- 征召行为:使用人类的条件节点 -->
|
||||
<li Class="ThinkNode_ConditionalDrafted">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>DraftedOrder</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_MoveToStandable" />
|
||||
<li Class="JobGiver_Orders" />
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Lord -->
|
||||
<li Class="ThinkNode_Subtree">
|
||||
<treeDef>LordDuty</treeDef>
|
||||
</li>
|
||||
|
||||
<!-- 自主机械族工作模式 -->
|
||||
<li Class="WulaFallenEmpire.ThinkNode_ConditionalAutonomousMech">
|
||||
<subNodes>
|
||||
<li Class="ThinkNode_ConditionalNotFormingCaravan">
|
||||
<subNodes>
|
||||
|
||||
<!-- Keep charging if we're already charging -->
|
||||
<li Class="ThinkNode_ConditionalRecharging">
|
||||
<subNodes>
|
||||
<li Class="JobGiver_GetEnergy_Charger" />
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Work modes -->
|
||||
<li Class="ThinkNode_ConditionalWorkMode" MayRequire="Ludeon.RimWorld.Biotech">
|
||||
<workMode>Work</workMode>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_SeekAllowedArea" />
|
||||
<li Class="JobGiver_GetEnergy_Charger" />
|
||||
|
||||
<!-- 紧急工作 -->
|
||||
<li Class="JobGiver_Work">
|
||||
<emergency>true</emergency>
|
||||
</li>
|
||||
|
||||
<!-- 常规工作 -->
|
||||
<li Class="JobGiver_Work" />
|
||||
|
||||
<!-- 非战斗机械族的巡逻行为 -->
|
||||
<li Class="ThinkNode_ConditionalWorkMech">
|
||||
<invert>true</invert>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_AIFightEnemies">
|
||||
<targetAcquireRadius>65</targetAcquireRadius>
|
||||
<targetKeepRadius>72</targetKeepRadius>
|
||||
</li>
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>MiscWork</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_WanderColony">
|
||||
<maxDanger>Deadly</maxDanger>
|
||||
<reportStringOverride>Patrolling.</reportStringOverride>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- 充电模式 -->
|
||||
<li Class="ThinkNode_ConditionalWorkMode" MayRequire="Ludeon.RimWorld.Biotech">
|
||||
<workMode>Recharge</workMode>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_SeekAllowedArea" />
|
||||
<li Class="JobGiver_GetEnergy_Charger" />
|
||||
<li Class="JobGiver_GetEnergy_SelfShutdown">
|
||||
<forced>true</forced>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- 休眠模式 -->
|
||||
<li Class="ThinkNode_ConditionalWorkMode" MayRequire="Ludeon.RimWorld.Biotech">
|
||||
<workMode>SelfShutdown</workMode>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_SeekAllowedArea" />
|
||||
<li Class="JobGiver_SelfShutdown" />
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
</subNodes>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- 非玩家控制机械族的战斗行为 -->
|
||||
<li Class="ThinkNode_ConditionalPlayerControlledMech">
|
||||
<invert>true</invert>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_AIFightEnemies">
|
||||
<targetAcquireRadius>30</targetAcquireRadius>
|
||||
<targetKeepRadius>35</targetKeepRadius>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- 空闲时的行为 -->
|
||||
<li Class="ThinkNode_Tagger">
|
||||
<tagToGive>Idle</tagToGive>
|
||||
<subNodes>
|
||||
<li Class="JobGiver_WanderColony">
|
||||
<maxDanger>None</maxDanger>
|
||||
</li>
|
||||
</subNodes>
|
||||
</li>
|
||||
|
||||
<!-- Idle error -->
|
||||
<li Class="JobGiver_IdleError"/>
|
||||
</subNodes>
|
||||
</thinkRoot>
|
||||
</ThinkTreeDef>
|
||||
</Defs>
|
||||
@@ -0,0 +1,271 @@
|
||||
using System.Collections.Generic;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using Verse.AI;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
// 自定义条件节点:检查是否处于自主工作模式
|
||||
public class ThinkNode_ConditionalAutonomousMech : ThinkNode_Conditional
|
||||
{
|
||||
protected override bool Satisfied(Pawn pawn)
|
||||
{
|
||||
if (pawn == null || pawn.Dead || pawn.Downed)
|
||||
return false;
|
||||
|
||||
// 检查是否被征召
|
||||
if (pawn.Drafted)
|
||||
return false;
|
||||
|
||||
// 检查是否有机械师控制
|
||||
if (pawn.GetOverseer() != null)
|
||||
return false;
|
||||
|
||||
// 检查是否有自主能力
|
||||
var comp = pawn.GetComp<CompAutonomousMech>();
|
||||
if (comp == null || !comp.CanWorkAutonomously)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class CompProperties_AutonomousMech : CompProperties
|
||||
{
|
||||
public bool enableAutonomousDrafting = true;
|
||||
public bool enableAutonomousWork = true;
|
||||
public bool requirePowerForAutonomy = true;
|
||||
public bool suppressUncontrolledWarning = true;
|
||||
|
||||
public CompProperties_AutonomousMech()
|
||||
{
|
||||
compClass = typeof(CompAutonomousMech);
|
||||
}
|
||||
}
|
||||
|
||||
public class CompAutonomousMech : ThingComp
|
||||
{
|
||||
public CompProperties_AutonomousMech Props => (CompProperties_AutonomousMech)props;
|
||||
|
||||
public Pawn MechPawn => parent as Pawn;
|
||||
|
||||
public bool CanBeAutonomous
|
||||
{
|
||||
get
|
||||
{
|
||||
if (MechPawn == null || MechPawn.Dead || MechPawn.Downed)
|
||||
return false;
|
||||
|
||||
if (!Props.enableAutonomousDrafting)
|
||||
return false;
|
||||
|
||||
if (MechPawn.GetOverseer() != null)
|
||||
return false;
|
||||
|
||||
if (Props.requirePowerForAutonomy)
|
||||
{
|
||||
var energyNeed = MechPawn.needs?.TryGetNeed<Need_MechEnergy>();
|
||||
if (energyNeed != null && energyNeed.CurLevelPercentage < 0.1f)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanWorkAutonomously
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Props.enableAutonomousWork)
|
||||
return false;
|
||||
|
||||
if (!CanBeAutonomous)
|
||||
return false;
|
||||
|
||||
if (MechPawn.Drafted)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShouldSuppressUncontrolledWarning
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Props.suppressUncontrolledWarning)
|
||||
return false;
|
||||
|
||||
return CanBeAutonomous;
|
||||
}
|
||||
}
|
||||
|
||||
public override void PostSpawnSetup(bool respawningAfterLoad)
|
||||
{
|
||||
base.PostSpawnSetup(respawningAfterLoad);
|
||||
|
||||
if (MechPawn != null && MechPawn.IsColonyMech)
|
||||
{
|
||||
EnsureWorkSettings();
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<Gizmo> CompGetGizmosExtra()
|
||||
{
|
||||
if (MechPawn == null || !CanBeAutonomous)
|
||||
yield break;
|
||||
|
||||
// 自主征召按钮
|
||||
yield return new Command_Toggle
|
||||
{
|
||||
defaultLabel = "Autonomous Mode",
|
||||
defaultDesc = "Enable autonomous operation without mechanitor control",
|
||||
icon = TexCommand.Draft,
|
||||
isActive = () => MechPawn.Drafted,
|
||||
toggleAction = () => ToggleAutonomousDraft(),
|
||||
hotKey = KeyBindingDefOf.Misc1
|
||||
};
|
||||
|
||||
// 工作模式切换按钮
|
||||
if (CanWorkAutonomously)
|
||||
{
|
||||
yield return new Command_Action
|
||||
{
|
||||
defaultLabel = "Work Mode: " + GetCurrentWorkMode(),
|
||||
defaultDesc = "Switch autonomous work mode",
|
||||
icon = TexCommand.Attack,
|
||||
action = () => ShowWorkModeMenu()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleAutonomousDraft()
|
||||
{
|
||||
if (MechPawn.drafter == null)
|
||||
return;
|
||||
|
||||
if (MechPawn.Drafted)
|
||||
{
|
||||
MechPawn.drafter.Drafted = false;
|
||||
Messages.Message($"{MechPawn.LabelCap} autonomous mode deactivated",
|
||||
MechPawn, MessageTypeDefOf.NeutralEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CanBeAutonomous)
|
||||
{
|
||||
MechPawn.drafter.Drafted = true;
|
||||
Messages.Message($"{MechPawn.LabelCap} is now operating autonomously",
|
||||
MechPawn, MessageTypeDefOf.PositiveEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Messages.Message($"Cannot activate autonomous mode: {GetBlockReason()}",
|
||||
MechPawn, MessageTypeDefOf.NegativeEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GetCurrentWorkMode()
|
||||
{
|
||||
if (MechPawn.workSettings == null)
|
||||
return "None";
|
||||
|
||||
// 检查当前激活的工作模式
|
||||
foreach (var workType in MechPawn.RaceProps.mechEnabledWorkTypes)
|
||||
{
|
||||
if (MechPawn.workSettings.GetPriority(workType) > 0)
|
||||
{
|
||||
return workType.defName;
|
||||
}
|
||||
}
|
||||
|
||||
return "None";
|
||||
}
|
||||
|
||||
private void ShowWorkModeMenu()
|
||||
{
|
||||
List<FloatMenuOption> list = new List<FloatMenuOption>();
|
||||
|
||||
// 工作模式
|
||||
list.Add(new FloatMenuOption("Work Mode", () => SetWorkMode("Work")));
|
||||
|
||||
// 充电模式
|
||||
list.Add(new FloatMenuOption("Recharge Mode", () => SetWorkMode("Recharge")));
|
||||
|
||||
// 休眠模式
|
||||
list.Add(new FloatMenuOption("Shutdown Mode", () => SetWorkMode("SelfShutdown")));
|
||||
|
||||
Find.WindowStack.Add(new FloatMenu(list));
|
||||
}
|
||||
|
||||
private void SetWorkMode(string mode)
|
||||
{
|
||||
if (MechPawn.workSettings == null)
|
||||
return;
|
||||
|
||||
// 重置所有工作模式优先级
|
||||
foreach (var workType in MechPawn.RaceProps.mechEnabledWorkTypes)
|
||||
{
|
||||
MechPawn.workSettings.SetPriority(workType, 0);
|
||||
}
|
||||
|
||||
// 设置选择的工作模式
|
||||
var targetMode = DefDatabase<WorkTypeDef>.GetNamedSilentFail(mode);
|
||||
if (targetMode != null)
|
||||
{
|
||||
MechPawn.workSettings.SetPriority(targetMode, 3);
|
||||
Messages.Message($"{MechPawn.LabelCap} switched to {mode} mode",
|
||||
MechPawn, MessageTypeDefOf.NeutralEvent);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetBlockReason()
|
||||
{
|
||||
if (MechPawn.Dead || MechPawn.Downed)
|
||||
return "Mech is incapacitated";
|
||||
|
||||
if (MechPawn.GetOverseer() != null)
|
||||
return "Mech is under mechanitor control";
|
||||
|
||||
if (Props.requirePowerForAutonomy)
|
||||
{
|
||||
var energyNeed = MechPawn.needs?.TryGetNeed<Need_MechEnergy>();
|
||||
if (energyNeed != null && energyNeed.CurLevelPercentage < 0.1f)
|
||||
return "Insufficient energy";
|
||||
}
|
||||
|
||||
return "Autonomous mode disabled";
|
||||
}
|
||||
|
||||
private void EnsureWorkSettings()
|
||||
{
|
||||
if (MechPawn.workSettings == null)
|
||||
{
|
||||
MechPawn.workSettings = new Pawn_WorkSettings(MechPawn);
|
||||
}
|
||||
|
||||
if (MechPawn.RaceProps.mechEnabledWorkTypes != null)
|
||||
{
|
||||
// 默认设置为工作模式
|
||||
var workMode = DefDatabase<WorkTypeDef>.GetNamedSilentFail("Work");
|
||||
if (workMode != null)
|
||||
{
|
||||
MechPawn.workSettings.SetPriority(workMode, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GetAutonomousStatusString()
|
||||
{
|
||||
if (!CanBeAutonomous)
|
||||
return null;
|
||||
|
||||
if (MechPawn.Drafted)
|
||||
return "Operating autonomously";
|
||||
else
|
||||
return "Autonomous mode available";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
[HarmonyPatch(typeof(Pawn_DraftController), "get_ShowDraftGizmo")]
|
||||
public static class Patch_Pawn_DraftController_ShowDraftGizmo
|
||||
{
|
||||
public static void Postfix(Pawn_DraftController __instance, ref bool __result)
|
||||
{
|
||||
Pawn pawn = __instance.pawn;
|
||||
|
||||
if (!__result && pawn != null && pawn.IsColonyMech)
|
||||
{
|
||||
var comp = pawn.GetComp<CompAutonomousMech>();
|
||||
if (comp != null && comp.CanBeAutonomous)
|
||||
{
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(MechanitorUtility), "CanDraftMech")]
|
||||
public static class Patch_MechanitorUtility_CanDraftMech
|
||||
{
|
||||
public static void Postfix(Pawn mech, ref AcceptanceReport __result)
|
||||
{
|
||||
if (!__result && mech != null && mech.IsColonyMech)
|
||||
{
|
||||
var comp = mech.GetComp<CompAutonomousMech>();
|
||||
if (comp != null && comp.CanBeAutonomous)
|
||||
{
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(CompOverseerSubject), "CompInspectStringExtra")]
|
||||
public static class Patch_CompOverseerSubject_CompInspectStringExtra
|
||||
{
|
||||
public static void Postfix(CompOverseerSubject __instance, ref string __result)
|
||||
{
|
||||
Pawn mech = __instance.parent as Pawn;
|
||||
if (mech != null && mech.IsColonyMech)
|
||||
{
|
||||
var comp = mech.GetComp<CompAutonomousMech>();
|
||||
if (comp != null && comp.ShouldSuppressUncontrolledWarning)
|
||||
{
|
||||
string autonomousStatus = comp.GetAutonomousStatusString();
|
||||
if (!string.IsNullOrEmpty(autonomousStatus))
|
||||
{
|
||||
__result = autonomousStatus;
|
||||
}
|
||||
else
|
||||
{
|
||||
__result = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
// 修复红色名字问题 - 直接修补 PawnNameColorUtility.PawnNameColorOf 方法
|
||||
[HarmonyPatch(typeof(PawnNameColorUtility), "PawnNameColorOf")]
|
||||
public static class Patch_PawnNameColorUtility_PawnNameColorOf
|
||||
{
|
||||
public static void Postfix(Pawn pawn, ref Color __result)
|
||||
{
|
||||
if (pawn != null && pawn.IsColonyMech)
|
||||
{
|
||||
var comp = pawn.GetComp<CompAutonomousMech>();
|
||||
if (comp != null && comp.ShouldSuppressUncontrolledWarning)
|
||||
{
|
||||
// 使用正常的白色名字
|
||||
__result = Color.white;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 修复红光闪烁问题 - 使用 Traverse 访问私有字段
|
||||
[HarmonyPatch(typeof(Pawn_PlayerSettings), "get_UncontrolledMechDrawPulse")]
|
||||
public static class Patch_Pawn_PlayerSettings_UncontrolledMechDrawPulse
|
||||
{
|
||||
public static bool Prefix(Pawn_PlayerSettings __instance, ref float __result)
|
||||
{
|
||||
var traverse = Traverse.Create(__instance);
|
||||
Pawn pawn = traverse.Field("pawn").GetValue<Pawn>();
|
||||
|
||||
if (pawn != null && pawn.IsColonyMech)
|
||||
{
|
||||
var comp = pawn.GetComp<CompAutonomousMech>();
|
||||
if (comp != null && comp.ShouldSuppressUncontrolledWarning)
|
||||
{
|
||||
// 返回 0 来禁用红光脉冲
|
||||
__result = 0f;
|
||||
return false; // 跳过原始方法
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 修复机械族控制状态检查
|
||||
[HarmonyPatch(typeof(MechanitorUtility), "IsMechanitorControlled")]
|
||||
public static class Patch_MechanitorUtility_IsMechanitorControlled
|
||||
{
|
||||
public static void Postfix(Pawn mech, ref bool __result)
|
||||
{
|
||||
if (!__result && mech != null && mech.IsColonyMech)
|
||||
{
|
||||
var comp = mech.GetComp<CompAutonomousMech>();
|
||||
if (comp != null && comp.ShouldSuppressUncontrolledWarning)
|
||||
{
|
||||
// 让游戏认为机械族是受控的
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 修复机械族控制状态检查的另一个方法
|
||||
[HarmonyPatch(typeof(CompOverseerSubject), "get_IsControlled")]
|
||||
public static class Patch_CompOverseerSubject_IsControlled
|
||||
{
|
||||
public static void Postfix(CompOverseerSubject __instance, ref bool __result)
|
||||
{
|
||||
Pawn mech = __instance.parent as Pawn;
|
||||
if (!__result && mech != null && mech.IsColonyMech)
|
||||
{
|
||||
var comp = mech.GetComp<CompAutonomousMech>();
|
||||
if (comp != null && comp.ShouldSuppressUncontrolledWarning)
|
||||
{
|
||||
// 让游戏认为机械族是受控的
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 修复机械族控制状态显示的另一个检查
|
||||
[HarmonyPatch(typeof(Pawn), "GetOverseer")]
|
||||
public static class Patch_Pawn_GetOverseer
|
||||
{
|
||||
public static void Postfix(Pawn __instance, ref Pawn __result)
|
||||
{
|
||||
if (__result == null && __instance.IsColonyMech)
|
||||
{
|
||||
var comp = __instance.GetComp<CompAutonomousMech>();
|
||||
if (comp != null && comp.ShouldSuppressUncontrolledWarning)
|
||||
{
|
||||
// 返回一个虚拟的监管者来避免红色显示
|
||||
__result = __instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 修复机械族控制组提示
|
||||
[HarmonyPatch(typeof(CompOverseerSubject), "GetUndraftedControlGroupTip")]
|
||||
public static class Patch_CompOverseerSubject_GetUndraftedControlGroupTip
|
||||
{
|
||||
public static bool Prefix(CompOverseerSubject __instance, ref string __result)
|
||||
{
|
||||
Pawn mech = __instance.parent as Pawn;
|
||||
if (mech != null && mech.IsColonyMech)
|
||||
{
|
||||
var comp = mech.GetComp<CompAutonomousMech>();
|
||||
if (comp != null && comp.ShouldSuppressUncontrolledWarning)
|
||||
{
|
||||
// 提供自主状态的提示而不是未受控提示
|
||||
__result = comp.GetAutonomousStatusString() ?? "Autonomous operation";
|
||||
return false; // 跳过原始方法
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 修复机械族控制状态的其他检查
|
||||
[HarmonyPatch(typeof(Pawn), "GetInspectString")]
|
||||
public static class Patch_Pawn_GetInspectString
|
||||
{
|
||||
public static void Postfix(Pawn __instance, ref string __result)
|
||||
{
|
||||
if (__instance.IsColonyMech)
|
||||
{
|
||||
var comp = __instance.GetComp<CompAutonomousMech>();
|
||||
if (comp != null && comp.ShouldSuppressUncontrolledWarning)
|
||||
{
|
||||
// 清理任何未受控相关的文本
|
||||
if (__result.Contains("MechUncontrolled") || __result.Contains("uncontrolled"))
|
||||
{
|
||||
string autonomousStatus = comp.GetAutonomousStatusString();
|
||||
if (!string.IsNullOrEmpty(autonomousStatus))
|
||||
{
|
||||
__result = autonomousStatus;
|
||||
}
|
||||
else
|
||||
{
|
||||
__result = __result.Replace("MechUncontrolled", "")
|
||||
.Replace("uncontrolled", "autonomous");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 修复机械族控制状态的UI显示
|
||||
[HarmonyPatch(typeof(MechanitorUtility), "GetMechControlGroupDesc")]
|
||||
public static class Patch_MechanitorUtility_GetMechControlGroupDesc
|
||||
{
|
||||
public static bool Prefix(Pawn mech, ref string __result)
|
||||
{
|
||||
if (mech != null && mech.IsColonyMech)
|
||||
{
|
||||
var comp = mech.GetComp<CompAutonomousMech>();
|
||||
if (comp != null && comp.ShouldSuppressUncontrolledWarning)
|
||||
{
|
||||
// 提供自主状态描述
|
||||
__result = comp.GetAutonomousStatusString() ?? "Autonomous operation";
|
||||
return false; // 跳过原始方法
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,6 +104,9 @@
|
||||
<Compile Include="Pawn\WULA_AutoMechCarrier\CompAutoMechCarrier.cs" />
|
||||
<Compile Include="Pawn\WULA_AutoMechCarrier\CompProperties_AutoMechCarrier.cs" />
|
||||
<Compile Include="Pawn\WULA_AutoMechCarrier\PawnProductionEntry.cs" />
|
||||
<Compile Include="Pawn\WULA_AutonomousMech\CompAutonomousMech.cs" />
|
||||
<Compile Include="Pawn\WULA_AutonomousMech\Patch_MechanitorUtility_CanDraftMech.cs" />
|
||||
<Compile Include="Pawn\WULA_AutonomousMech\Patch_UncontrolledMechDrawPulse.cs" />
|
||||
<Compile Include="Pawn\WULA_BrokenPersonality\MentalBreakWorker_BrokenPersonality.cs" />
|
||||
<Compile Include="Pawn\WULA_BrokenPersonality\MentalStateDefExtension_BrokenPersonality.cs" />
|
||||
<Compile Include="Pawn\WULA_BrokenPersonality\MentalState_BrokenPersonality.cs" />
|
||||
|
||||
Reference in New Issue
Block a user