diff --git a/PulsarModLoader/Content/Components/ComponentModBase.cs b/PulsarModLoader/Content/Components/ComponentModBase.cs index 207e3a0..56d30bb 100644 --- a/PulsarModLoader/Content/Components/ComponentModBase.cs +++ b/PulsarModLoader/Content/Components/ComponentModBase.cs @@ -70,25 +70,7 @@ public virtual void AddStats(PLShipComponent InComp) } public virtual void OnWarp(PLShipComponent InComp) { - if (InComp.Unstable) - { - int num = InComp.Unstable_JumpCounter; - InComp.Unstable_JumpCounter = num + 1; - } - if (InComp.Level == 0) - { - InComp.Unstable_JumpCounter = 0; - } - if (InComp.Unstable_JumpCounter > 6) - { - InComp.Unstable_JumpCounter = 0; - if (InComp.Level > 0) - { - int num = InComp.Level; - InComp.Level = num - 1; - PulsarModLoader.Utilities.Messaging.Notification(InComp.GetItemName(true) + " has degraded to Level " + (InComp.Level + 1)); - } - } + } public virtual void Tick(PLShipComponent InComp) { diff --git a/PulsarModLoader/Content/Components/OnWarpUnstableNotificationPatch.cs b/PulsarModLoader/Content/Components/OnWarpUnstableNotificationPatch.cs new file mode 100644 index 0000000..bba72bc --- /dev/null +++ b/PulsarModLoader/Content/Components/OnWarpUnstableNotificationPatch.cs @@ -0,0 +1,34 @@ +using HarmonyLib; +using System.Collections.Generic; +using System.Reflection.Emit; +using static PulsarModLoader.Patches.HarmonyHelpers; + +namespace PulsarModLoader.Content.Components +{ + [HarmonyPatch()] + class OnWarpUnstableNotificationPatch + { + static IEnumerable Transpiler(IEnumerable instructions) + { + List targetSequence = new List() + { + new CodeInstruction(OpCodes.Ldloc_0), + new CodeInstruction(OpCodes.Ldc_I4_1), + new CodeInstruction(OpCodes.Sub), + new CodeInstruction(OpCodes.Call), + }; + + List injectedSequence = new List() + { + new CodeInstruction(OpCodes.Ldarg_0), + new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(OnWarpUnstableNotificationPatch), "PatchMethod")) + }; + + return PatchBySequence(instructions, targetSequence, injectedSequence, checkMode: CheckMode.NEVER); + } + static void PatchMethod(PLShipComponent InComp) + { + PulsarModLoader.Utilities.Messaging.Notification(InComp.GetItemName(true) + " has degraded to Level " + (InComp.Level + 1)); + } + } +} diff --git a/PulsarModLoader/Content/Components/WarpDriveProgram/WarpDriveProgramModManager.cs b/PulsarModLoader/Content/Components/WarpDriveProgram/WarpDriveProgramModManager.cs index ffc1192..cd73694 100644 --- a/PulsarModLoader/Content/Components/WarpDriveProgram/WarpDriveProgramModManager.cs +++ b/PulsarModLoader/Content/Components/WarpDriveProgram/WarpDriveProgramModManager.cs @@ -189,12 +189,12 @@ private static IEnumerator LateAddToSendQueueReplacement(int shipID, int sendQue [HarmonyPatch(typeof(PLWarpDriveProgram), "GetActiveTimerAlpha")] class WarpDriveProgramGetActiveTimerAlphaPatch { - static void Postfix(PLWarpDriveProgram __instance, ref float __result) + static void Postfix(PLWarpDriveProgram __instance, ref float __result, float __ShieldBooster_LastActivationTime) { int subtypeformodded = __instance.SubType - WarpDriveProgramModManager.Instance.VanillaWarpDriveProgramMaxType; if (subtypeformodded > -1 && subtypeformodded < WarpDriveProgramModManager.Instance.WarpDriveProgramTypes.Count) { - __result = Mathf.Clamp01((Time.time - (float)__instance.GetType().GetField("ShieldBooster_LastActivationTime", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance)) / WarpDriveProgramModManager.Instance.WarpDriveProgramTypes[subtypeformodded].ActiveTime); + __result = Mathf.Clamp01((Time.time - __ShieldBooster_LastActivationTime) / WarpDriveProgramModManager.Instance.WarpDriveProgramTypes[subtypeformodded].ActiveTime); } } } diff --git a/PulsarModLoader/PulsarModLoader.csproj b/PulsarModLoader/PulsarModLoader.csproj index cc0af9d..a3b6fde 100644 --- a/PulsarModLoader/PulsarModLoader.csproj +++ b/PulsarModLoader/PulsarModLoader.csproj @@ -159,6 +159,7 @@ +