全局指挥组件

This commit is contained in:
2025-08-01 11:13:40 +08:00
parent e34397e63b
commit 16b2a83afd
6 changed files with 64 additions and 12 deletions

Binary file not shown.

View File

@@ -968,6 +968,10 @@
<!-- <baseHealthScale>4</baseHealthScale> -->
<canFlyInVacuum>true</canFlyInVacuum>
</race>
<comps>
<!--加上这个组件的机械体会直接跳过原版指挥范围判定-->
<li Class="WulaFallenEmpire.CompProperties_GlobalMechCommand" />
</comps>
<!-- <comps Inherit="False">
<li Class="CompProperties_CanBeDormant" />
<li Class="CompProperties_WakeUpDormant">
@@ -1016,6 +1020,15 @@
<!-- <baseHealthScale>4</baseHealthScale> -->
<canFlyInVacuum>true</canFlyInVacuum>
</race>
<comps>
<!--
全局指挥组件 (Global Mech Command Component)
此组件通过Harmony补丁 MechanitorUtility_InMechanitorCommandRange_Patch.cs 来实现功能。
当一个Pawn的ThingDef拥有此组件时补丁会拦截原版的指挥范围检查并始终返回“在范围内”。
这使得拥有此组件的机械体可以被机械师在地图的任何位置进行指挥,无视距离限制。
-->
<li Class="WulaFallenEmpire.CompProperties_GlobalMechCommand" />
</comps>
<!-- <comps Inherit="False">
<li Class="CompProperties_CanBeDormant" />
<li Class="CompProperties_WakeUpDormant">

View File

@@ -7,7 +7,7 @@
"RelativeMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|solutionrelative:verb\\trackingbullet.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|c:\\steam\\steamapps\\common\\rimworld\\mods\\3516260226\\source\\wulafallenempire\\verb\\propershotgun.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"AbsoluteMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\verb\\propershotgun.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{F5AE8C3B-0221-4C16-A128-9A62D521A8FF}|WulaFallenEmpire.csproj|solutionrelative:verb\\propershotgun.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
@@ -50,8 +50,12 @@
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 0,
"SelectedChildIndex": 1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
},
{
"$type": "Document",
"DocumentIndex": 0,
@@ -75,12 +79,7 @@
"RelativeToolTip": "Verb\\ProperShotgun.cs",
"ViewState": "AQIAABUAAAAAAAAAAAAIwAgAAAAaAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-07-31T17:19:04.819Z",
"EditorCaption": ""
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
"WhenOpened": "2025-07-31T17:19:04.819Z"
},
{
"$type": "Document",
@@ -92,8 +91,7 @@
"RelativeToolTip": "Verb\\VerbPropertiesExplosiveBeam.cs",
"ViewState": "AQIAAAAAAAAAAAAAAADwvwAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-07-31T17:16:20.591Z",
"EditorCaption": ""
"WhenOpened": "2025-07-31T17:16:20.591Z"
},
{
"$type": "Document",
@@ -105,8 +103,7 @@
"RelativeToolTip": "Verb\\Verb_ShootBeamExplosive.cs",
"ViewState": "AQIAAAAAAAAAAAAAAADwvwYAAAAaAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-07-31T17:12:13.033Z",
"EditorCaption": ""
"WhenOpened": "2025-07-31T17:12:13.033Z"
},
{
"$type": "Document",

View File

@@ -0,0 +1,41 @@
using HarmonyLib;
using Verse;
namespace WulaFallenEmpire
{
/// <summary>
/// A CompProperties class that, when added to a Pawn's ThingDef, grants them global command range.
/// </summary>
public class CompProperties_GlobalMechCommand : CompProperties
{
public CompProperties_GlobalMechCommand()
{
this.compClass = typeof(CompGlobalMechCommand);
}
}
/// <summary>
/// The actual Comp that does nothing but act as a marker.
/// </summary>
public class CompGlobalMechCommand : ThingComp
{
// This component doesn't need to do anything. Its presence is what matters.
}
[HarmonyPatch(typeof(MechanitorUtility), "InMechanitorCommandRange")]
public static class MechanitorUtility_InMechanitorCommandRange_Patch
{
[HarmonyPrefix]
public static bool Prefix(Pawn mech, ref bool __result)
{
// Check if the pawn's def has the CompProperties_GlobalMechCommand
if (mech.def.HasComp(typeof(CompGlobalMechCommand)))
{
__result = true; // Grant global command range
return false; // Skip original method
}
return true; // Execute original method
}
}
}

View File

@@ -99,6 +99,7 @@
<Compile Include="HarmonyPatches\Caravan_NeedsTracker_TrySatisfyPawnNeeds_Patch.cs" />
<Compile Include="HarmonyPatches\FloatMenuOptionProvider_Ingest_Patch.cs" />
<Compile Include="HarmonyPatches\Projectile_Launch_Patch.cs" />
<Compile Include="HarmonyPatches\MechanitorUtility_InMechanitorCommandRange_Patch.cs" />
<Compile Include="MentalState_BrokenPersonality.cs" />
<Compile Include="MentalStateDefExtension_BrokenPersonality.cs" />
<Compile Include="MentalBreakWorker_BrokenPersonality.cs" />