From 7acaab866df15e6333b70ffb0c9061a70987a7f9 Mon Sep 17 00:00:00 2001 From: KirisameSoup Date: Sun, 7 Apr 2024 00:59:30 +0800 Subject: [PATCH] made escape spawn possible --- reversed/Plugin.cs | 46 ++++++++++++++++++++++++++++++++-------- reversed/reversed.csproj | 4 ++-- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/reversed/Plugin.cs b/reversed/Plugin.cs index cfc93a7..866c52f 100644 --- a/reversed/Plugin.cs +++ b/reversed/Plugin.cs @@ -20,6 +20,8 @@ void Start() { harmony = Harmony.CreateAndPatchAll(typeof(Rev), "com.kirisoup.hff.reversed"); + harmony.PatchAll(typeof(Rev.MakeClimb)); + Cmds.RegCmds(); } @@ -77,21 +79,13 @@ void FixedUpdate() print($"d {h} vy {vy} desiredVy {desiredVy} vy < desiredVy {vy < desiredVy} acc {acc}"); - if (vy < desiredVy) + if (vy + acc < desiredVy) foreach (Rigidbody rigidbody in player.human.rigidbodies) rigidbody.velocity += new Vector3(0, acc, 0); } - - - - - } - - - } static void ThrowPlayer(string input = null) @@ -196,6 +190,7 @@ static void SetPosition(ref Vector3 spawnPos) if (!enabledRev) return; if (!executingSpawnAt) return; if (Game.instance.currentCheckpointNumber != 0) return; + if (Game.instance.currentLevelNumber == -1) return; redrock = lvltype == WorkshopItemSource.EditorPick && lvlnum == 7; @@ -221,6 +216,39 @@ static void SetPosition(ref Vector3 spawnPos) print($"Human.instance.velocity {Human.instance.velocity}"); } + + [HarmonyPatch(typeof(Human), "FixedUpdate")] + public static class MakeClimb + { + static bool justSpawed; + static bool keepGrabbing; + + static void Prefix() + { + if (Game.instance.currentCheckpointNumber != 0) return; + + print($"justSpawed {justSpawed} keepGrabbing {keepGrabbing}"); + + if (Human.instance.state == HumanState.Spawning) justSpawed = true; + } + + static void Postfix() + { + if (Game.instance.currentCheckpointNumber != 0) return; + + if (!justSpawed && !keepGrabbing) return; + + if (Human.instance.hasGrabbed) keepGrabbing = false; + + if (Human.instance.state == HumanState.Spawning || Human.instance.state == HumanState.Unconscious) return; + + justSpawed = false; + if (!Human.instance.hasGrabbed) keepGrabbing = true; + + if (keepGrabbing) Human.instance.state = HumanState.Climb; + } + + } } static LevelPassTrigger FindClosestFinish(LevelPassTrigger[] origFinishes) diff --git a/reversed/reversed.csproj b/reversed/reversed.csproj index 32360b3..0364c9b 100644 --- a/reversed/reversed.csproj +++ b/reversed/reversed.csproj @@ -3,8 +3,8 @@ net46 reversed - reversed - 0.0.1 + revphysics queriesersed + 0.0.0.2 true latest