98 lines
3.4 KiB
C#
98 lines
3.4 KiB
C#
using HarmonyLib;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
|
|
namespace LaunchConfirm;
|
|
|
|
[HarmonyPatch(typeof(StartMatchLever))]
|
|
public class LeverPatch
|
|
{
|
|
[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]";
|
|
return;
|
|
}
|
|
|
|
LungProp[] allApparatuses = Object.FindObjectsOfType<LungProp>();
|
|
|
|
// ==========================================
|
|
// QUICK DEBUG MACROS
|
|
// ==========================================
|
|
if (Keyboard.current != null)
|
|
{
|
|
// Press Numpad Minus (-) to Teleport to the UNSECURED Apparatus
|
|
if (Keyboard.current[Key.NumpadMinus].wasPressedThisFrame)
|
|
{
|
|
LungProp targetApparatus = null;
|
|
|
|
// Find the core that is actually out in the wild, not the one on the ship
|
|
foreach (LungProp apparatus in allApparatuses)
|
|
{
|
|
if (!apparatus.isInShipRoom)
|
|
{
|
|
targetApparatus = apparatus;
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Fallback: If they are all secured, just grab any of them
|
|
if (targetApparatus == null && allApparatuses.Length > 0)
|
|
{
|
|
targetApparatus = allApparatuses[0];
|
|
}
|
|
|
|
if (targetApparatus != null && GameNetworkManager.Instance?.localPlayerController != null)
|
|
{
|
|
GameNetworkManager.Instance.localPlayerController.TeleportPlayer(targetApparatus.transform.position + Vector3.up);
|
|
HUDManager.Instance.DisplayTip("Debug", "Teleported to Apparatus!");
|
|
}
|
|
}
|
|
|
|
// Press Numpad Plus (+) to Teleport back to the Ship Lever
|
|
if (Keyboard.current[Key.NumpadPlus].wasPressedThisFrame)
|
|
{
|
|
if (GameNetworkManager.Instance?.localPlayerController != null)
|
|
{
|
|
GameNetworkManager.Instance.localPlayerController.TeleportPlayer(__instance.transform.position);
|
|
HUDManager.Instance.DisplayTip("Debug", "Teleported back to Ship!");
|
|
}
|
|
}
|
|
}
|
|
// ==========================================
|
|
// END QUICK DEBUG MACROS
|
|
// ==========================================
|
|
|
|
|
|
// Checking if its actually been pulled.
|
|
bool isApparatusPulled = true;
|
|
|
|
foreach (LungProp apparatus in allApparatuses)
|
|
{
|
|
// if any of the Lungs are NOT in the ship, that means theres still 1 (or more) in the facility.
|
|
if (!apparatus.isInShipRoom)
|
|
{
|
|
isApparatusPulled = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
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]";
|
|
}
|
|
}
|
|
} |