Refactor LeverPatch to improve apparatus handling and add debug teleportation features
This commit is contained in:
@@ -8,9 +8,6 @@ namespace LaunchConfirm;
|
|||||||
[HarmonyPatch(typeof(StartMatchLever))]
|
[HarmonyPatch(typeof(StartMatchLever))]
|
||||||
public class LeverPatch
|
public class LeverPatch
|
||||||
{
|
{
|
||||||
private static LungProp? _cachedApparatus;
|
|
||||||
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch("Update")]
|
[HarmonyPatch("Update")]
|
||||||
private static void UpdatePostfix(StartMatchLever __instance)
|
private static void UpdatePostfix(StartMatchLever __instance)
|
||||||
@@ -23,25 +20,70 @@ public class LeverPatch
|
|||||||
if (StartOfRound.Instance.inShipPhase)
|
if (StartOfRound.Instance.inShipPhase)
|
||||||
{
|
{
|
||||||
__instance.triggerScript.hoverTip = "Pull lever : [Land Ship]";
|
__instance.triggerScript.hoverTip = "Pull lever : [Land Ship]";
|
||||||
_cachedApparatus = null; // clear api for next round
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LungProp[] allApparatuses = Object.FindObjectsOfType<LungProp>();
|
||||||
|
|
||||||
// caching the apparatus to prevent polling it EVERY FUCKING FRAME
|
// ==========================================
|
||||||
if (_cachedApparatus == null)
|
// QUICK DEBUG MACROS
|
||||||
|
// ==========================================
|
||||||
|
if (Keyboard.current != null)
|
||||||
{
|
{
|
||||||
_cachedApparatus = Object.FindObjectOfType<LungProp>();
|
// 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.
|
// Checking if its actually been pulled.
|
||||||
bool isApparatusPulled;
|
bool isApparatusPulled = true;
|
||||||
|
|
||||||
if (_cachedApparatus != null)
|
foreach (LungProp apparatus in allApparatuses)
|
||||||
{
|
{
|
||||||
isApparatusPulled = _cachedApparatus.isInShipRoom;
|
// if any of the Lungs are NOT in the ship, that means theres still 1 (or more) in the facility.
|
||||||
} else {
|
if (!apparatus.isInShipRoom)
|
||||||
isApparatusPulled = true; // cant find the apparatus
|
{
|
||||||
|
isApparatusPulled = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isApparatusPulled)
|
if (!isApparatusPulled)
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("HerpieDerpiee.LaunchConfirm")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("HerpieDerpiee.LaunchConfirm")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+663a466e99a8eed66bed8bd74fdadfee12e10f1b")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d589d779346e91bc72296452801e7583b2a9d20b")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("LaunchConfirm")]
|
[assembly: System.Reflection.AssemblyProductAttribute("LaunchConfirm")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("HerpieDerpiee.LaunchConfirm")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("HerpieDerpiee.LaunchConfirm")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
4ffe5e172e780b6533ec3c053d32c9127bd42dfd49711592538bbe25eb9f7d17
|
0be369dc4d72d118d028f782172cbfac31039d12298acc29e777bd7b00ae4b4c
|
||||||
|
|||||||
Reference in New Issue
Block a user