initial plugin before git init
This commit is contained in:
56
Patches/LeverPatch.cs
Normal file
56
Patches/LeverPatch.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
|
||||
namespace LaunchConfirm;
|
||||
|
||||
[HarmonyPatch(typeof(StartMatchLever))]
|
||||
public class LeverPatch
|
||||
{
|
||||
private static LungProp? _cachedApparatus;
|
||||
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch("Update")]
|
||||
private static void UpdatePostfix(StartMatchLever __instance)
|
||||
{
|
||||
// prevent weird null references
|
||||
if (__instance == null || __instance.triggerScript == null) return;
|
||||
if (StartOfRound.Instance == null || RoundManager.Instance == null) return;
|
||||
|
||||
|
||||
if (StartOfRound.Instance.inShipPhase)
|
||||
{
|
||||
__instance.triggerScript.hoverTip = "Pull lever : [Land Ship]";
|
||||
_cachedApparatus = null; // clear api for next round
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// caching the apparatus to prevent polling it EVERY FUCKING FRAME
|
||||
if (_cachedApparatus == null)
|
||||
{
|
||||
_cachedApparatus = Object.FindObjectOfType<LungProp>();
|
||||
}
|
||||
|
||||
// Checking if its actually been pulled.
|
||||
bool isApparatusPulled;
|
||||
|
||||
if (_cachedApparatus != null)
|
||||
{
|
||||
isApparatusPulled = _cachedApparatus.isInShipRoom;
|
||||
} else {
|
||||
isApparatusPulled = true; // cant find the apparatus
|
||||
}
|
||||
|
||||
if (!isApparatusPulled)
|
||||
{
|
||||
__instance.triggerScript.hoverTip = "Pull lever : [Start Ship]\n<color=#FF0000>WARNING: Launching without Apparatus in the Ship!</color>";
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.triggerScript.hoverTip = "Pull lever : [Start Ship]";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user