-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cef1b65
commit 374df0e
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using HarmonyLib; | ||
using System.Reflection; | ||
using UnityEngine; | ||
using System.Linq; | ||
|
||
namespace RealismOverhaul.Harmony | ||
{ | ||
[HarmonyPatch] | ||
internal class PatchKSPWheel_KSPWheelDamage_wearUpdateSimple | ||
{ | ||
internal static bool Prepare() | ||
{ | ||
bool foundKSPWheel = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.name.Equals("KSPWheel", System.StringComparison.OrdinalIgnoreCase)) != null; | ||
return foundKSPWheel; | ||
} | ||
|
||
internal static MethodBase TargetMethod() => AccessTools.TypeByName("KSPWheel.KSPWheelDamage")?.GetMethod("wearUpdateSimple", AccessTools.all); | ||
|
||
[HarmonyPrefix] | ||
internal static bool Prefix_wearUpdateSimple(PartModule __instance, ref float ___load, ref float ___loadStress, ref float ___speed, ref float ___stressTime) | ||
{ | ||
if (!HighLogic.LoadedSceneIsFlight) | ||
return true; | ||
|
||
if (__instance.vessel == null) | ||
return true; | ||
|
||
// We clobber prelaunch just in case there's kraken twitching. | ||
// And we obviously clobber all the other situations | ||
// so we only bail when Landed. | ||
if (__instance.vessel.situation == Vessel.Situations.LANDED) | ||
return true; | ||
|
||
// Reset everything | ||
___load = ___loadStress = ___speed = 0f; | ||
// the method does this if load and speed are under limit | ||
___stressTime = Mathf.Max(0f, ___stressTime - Time.fixedDeltaTime); | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters