忘记补patch
This commit is contained in:
Binary file not shown.
@@ -327,6 +327,7 @@
|
||||
<Compile Include="Buildings\Building_CatastropheMissileSilo\Building_CatastropheMissileSilo.cs" />
|
||||
<Compile Include="Buildings\Building_CatastropheMissileSilo\WorldObject_CatastropheMissile.cs" />
|
||||
<Compile Include="HarmonyPatches\Patch_ForceTargetable.cs" />
|
||||
<Compile Include="HarmonyPatches\Projectile_Launch_Patch.cs" />
|
||||
<Compile Include="Building_Comps\CompForceTargetable.cs" />
|
||||
<Compile Include="PowerArmor\ARA_PowerArmor.cs" />
|
||||
<Compile Include="PowerArmor\CompPowerArmorStation.cs" />
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
|
||||
namespace ArachnaeSwarm.HarmonyPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(Projectile), "CheckForFreeInterceptBetween")]
|
||||
public static class Projectile_CheckForFreeInterceptBetween_Patch
|
||||
{
|
||||
private static readonly MethodInfo ImpactMethod = AccessTools.Method(typeof(Projectile), "Impact");
|
||||
|
||||
public static bool Prefix(Projectile __instance, Vector3 lastExactPos, Vector3 newExactPos)
|
||||
{
|
||||
if (__instance.Map == null || __instance.Destroyed) return true;
|
||||
|
||||
foreach (Pawn pawn in __instance.Map.mapPawns.AllPawnsSpawned)
|
||||
{
|
||||
if (pawn.apparel != null)
|
||||
{
|
||||
foreach (Apparel apparel in pawn.apparel.WornApparel)
|
||||
{
|
||||
if (apparel.TryGetComp<CompApparelInterceptor>(out var interceptor))
|
||||
{
|
||||
if (interceptor.TryIntercept(__instance, lastExactPos, newExactPos))
|
||||
{
|
||||
// Directly destroy the projectile instead of calling Impact via reflection.
|
||||
// This is cleaner and avoids the NRE that happens when the game engine
|
||||
// continues to process a projectile that was destroyed mid-tick.
|
||||
__instance.Destroy(DestroyMode.Vanish);
|
||||
|
||||
return false; // Prevent original method from running.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user