牢砖的强制攻击
This commit is contained in:
Binary file not shown.
@@ -679,6 +679,7 @@
|
||||
<li Class="CompProperties_AmbientSound">
|
||||
<sound>MechTurretBig_Call</sound>
|
||||
</li>
|
||||
<li Class="WulaFallenEmpire.CompProperties_ForceTargetable" />
|
||||
</comps>
|
||||
<passability>PassThroughOnly</passability>
|
||||
<pathCost>50</pathCost>
|
||||
|
||||
@@ -281,6 +281,7 @@
|
||||
<chargeIntervalTicks>-1</chargeIntervalTicks>
|
||||
<chargeDurationTicks>0</chargeDurationTicks>
|
||||
</li>
|
||||
<li Class="WulaFallenEmpire.CompProperties_ForceTargetable" />
|
||||
</comps>
|
||||
<modExtensions>
|
||||
<li Class="WulaFallenEmpire.PocketMapProperties">
|
||||
|
||||
25
Source/WulaFallenEmpire/CompForceTargetable.cs
Normal file
25
Source/WulaFallenEmpire/CompForceTargetable.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Verse;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
/// <summary>
|
||||
/// This CompProperties class is used in the XML defs to add the CompForceTargetable to a Thing.
|
||||
/// </summary>
|
||||
public class CompProperties_ForceTargetable : CompProperties
|
||||
{
|
||||
public CompProperties_ForceTargetable()
|
||||
{
|
||||
this.compClass = typeof(CompForceTargetable);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A simple marker component. Any Building_TurretGun that has this component
|
||||
/// will be forcefully made targetable by players via a Harmony patch.
|
||||
/// </summary>
|
||||
public class CompForceTargetable : ThingComp
|
||||
{
|
||||
// This component doesn't need any specific logic.
|
||||
// Its mere presence on a turret is checked by the Harmony patch.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using HarmonyLib;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
[HarmonyPatch(typeof(Building_ArmedShuttle), "get_CanSetForcedTarget")]
|
||||
public static class Patch_Building_ArmedShuttle_CanSetForcedTarget
|
||||
{
|
||||
/// <summary>
|
||||
/// Postfix patch to allow armed shuttles with CompForceTargetable to be manually targeted.
|
||||
/// </summary>
|
||||
public static void Postfix(Building_ArmedShuttle __instance, ref bool __result)
|
||||
{
|
||||
// If the result is already true, no need to do anything.
|
||||
if (__result)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the shuttle has our marker component and belongs to the player.
|
||||
if (__instance.GetComp<CompForceTargetable>() != null && __instance.Faction == Faction.OfPlayer)
|
||||
{
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Source/WulaFallenEmpire/Patch_ForceTargetable.cs
Normal file
28
Source/WulaFallenEmpire/Patch_ForceTargetable.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using HarmonyLib;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
[HarmonyPatch(typeof(Building_TurretGun), "get_CanSetForcedTarget")]
|
||||
public static class Patch_Building_TurretGun_CanSetForcedTarget
|
||||
{
|
||||
/// <summary>
|
||||
/// Postfix patch to allow turrets with CompForceTargetable to be manually targeted.
|
||||
/// </summary>
|
||||
public static void Postfix(Building_TurretGun __instance, ref bool __result)
|
||||
{
|
||||
// If the result is already true, no need to do anything.
|
||||
if (__result)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the turret has our marker component and belongs to the player.
|
||||
if (__instance.GetComp<CompForceTargetable>() != null && __instance.Faction == Faction.OfPlayer)
|
||||
{
|
||||
__result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,6 +187,9 @@
|
||||
<Compile Include="CompUseEffect_AddDamageShieldCharges.cs" />
|
||||
<Compile Include="HediffCompProperties_GiveHediffsInRangeToRace.cs" />
|
||||
<Compile Include="HediffComp_GiveHediffsInRangeToRace.cs" />
|
||||
<Compile Include="CompForceTargetable.cs" />
|
||||
<Compile Include="Patch_ForceTargetable.cs" />
|
||||
<Compile Include="Patch_ArmedShuttle_ForceTargetable.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
Reference in New Issue
Block a user