Skip to content

Commit

Permalink
- Fix patching error for SelectionStateSensorLock in HarmonyX
Browse files Browse the repository at this point in the history
  • Loading branch information
IceRaptor committed Apr 14, 2023
1 parent 068ec66 commit 9154b01
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions IRTweaks/IRTweaks/Modules/Combat/FlexibleSensorLock.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using BattleTech.Save.SaveGameStructure;
using System.Linq;
using UnityEngine;

namespace IRTweaks.Modules.Combat
Expand Down Expand Up @@ -31,30 +32,38 @@ public static bool ActorHasFreeSensorLock(AbstractActor actor)
}

// --- SelectionStateSensorLock classes ---
[HarmonyPatch(typeof(SelectionStateSensorLock), "ConsumesFiring", MethodType.Getter)]
static class SelectionStateSensorLock_ConsumesFiring
// HarmonyX does not allow targeting inherited properties, so target the override on SelectionStateTarget instead of SelectionStateSensorLock
[HarmonyPatch(typeof(SelectionStateTarget), "ConsumesFiring", MethodType.Getter)]
static class SelectionStateTarget_ConsumesFiring
{
[HarmonyPrepare]
static bool Prepare() => Mod.Config.Fixes.FlexibleSensorLock;

[HarmonyPostfix]
static void Postfix(ref bool __result)
static void Postfix(SelectionStateTarget __instance, ref bool __result)
{
__result = false;
if (__instance != null && __instance.GetType() == typeof(SelectionStateSensorLock))
{
__result = false;
}

}

}

[HarmonyPatch(typeof(SelectionStateSensorLock), "ConsumesMovement", MethodType.Getter)]
static class SelectionStateSensorLock_ConsumesMovement
[HarmonyPatch(typeof(SelectionStateTarget), "ConsumesMovement", MethodType.Getter)]
static class SelectionStateTarget_ConsumesMovement
{
[HarmonyPrepare]
static bool Prepare() => Mod.Config.Fixes.FlexibleSensorLock;

[HarmonyPostfix]
static void Postfix(ref bool __result)
static void Postfix(SelectionStateTarget __instance, ref bool __result)
{
__result = false;
if (__instance != null && __instance.GetType() == typeof(SelectionStateSensorLock))
{
__result = false;
}
}

}
Expand Down

0 comments on commit 9154b01

Please sign in to comment.