From a8e0553e53532fe83913f12c7a1a80edbd083dff Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidoS@users.noreply.github.com> Date: Sat, 12 Apr 2025 02:41:43 -0500 Subject: [PATCH] [DoubleTapJumpToExitSeat] Initial push --- .../DoubleTapJumpToExitSeat.csproj | 6 + DoubleTapJumpToExitSeat/Main.cs | 103 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 32 ++++++ DoubleTapJumpToExitSeat/README.md | 14 +++ DoubleTapJumpToExitSeat/format.json | 23 ++++ 5 files changed, 178 insertions(+) create mode 100644 DoubleTapJumpToExitSeat/DoubleTapJumpToExitSeat.csproj create mode 100644 DoubleTapJumpToExitSeat/Main.cs create mode 100644 DoubleTapJumpToExitSeat/Properties/AssemblyInfo.cs create mode 100644 DoubleTapJumpToExitSeat/README.md create mode 100644 DoubleTapJumpToExitSeat/format.json diff --git a/DoubleTapJumpToExitSeat/DoubleTapJumpToExitSeat.csproj b/DoubleTapJumpToExitSeat/DoubleTapJumpToExitSeat.csproj new file mode 100644 index 0000000..5a8badc --- /dev/null +++ b/DoubleTapJumpToExitSeat/DoubleTapJumpToExitSeat.csproj @@ -0,0 +1,6 @@ + + + + YouAreMineNow + + diff --git a/DoubleTapJumpToExitSeat/Main.cs b/DoubleTapJumpToExitSeat/Main.cs new file mode 100644 index 0000000..91c268e --- /dev/null +++ b/DoubleTapJumpToExitSeat/Main.cs @@ -0,0 +1,103 @@ +using System.Reflection; +using ABI_RC.Core.InteractionSystem; +using ABI_RC.Core.Savior; +using ABI_RC.Systems.InputManagement; +using ABI_RC.Systems.Movement; +using HarmonyLib; +using MelonLoader; +using UnityEngine; + +namespace NAK.DoubleTapJumpToExitSeat; + +public class DoubleTapJumpToExitSeatMod : MelonMod +{ + #region Melon Preferences + + public static readonly MelonPreferences_Category Category = + MelonPreferences.CreateCategory(nameof(DoubleTapJumpToExitSeatMod)); + + public static readonly MelonPreferences_Entry EntryOnlyInVR = + Category.CreateEntry("only_in_vr", false, display_name: "Only In VR", description: "Should this behaviour only be active in VR?"); + + #endregion Melon Preferences + + #region Melon Events + + public override void OnInitializeMelon() + { + #region CVRSeat Patches + + HarmonyInstance.Patch( + typeof(CVRSeat).GetMethod(nameof(CVRSeat.Update), + BindingFlags.NonPublic | BindingFlags.Instance), + prefix: new HarmonyMethod(typeof(DoubleTapJumpToExitSeatMod).GetMethod(nameof(OnPreCVRSeatUpdate), + BindingFlags.NonPublic | BindingFlags.Static)) + ); + + #endregion CVRSeat Patches + + #region ViewManager Patches + + HarmonyInstance.Patch( + typeof(ViewManager).GetMethod(nameof(ViewManager.Update), + BindingFlags.NonPublic | BindingFlags.Instance), + prefix: new HarmonyMethod(typeof(DoubleTapJumpToExitSeatMod).GetMethod(nameof(OnPreViewManagerUpdate), + BindingFlags.NonPublic | BindingFlags.Static)), + postfix: new HarmonyMethod(typeof(DoubleTapJumpToExitSeatMod).GetMethod(nameof(OnPostViewManagerUpdate), + BindingFlags.NonPublic | BindingFlags.Static)) + ); + + #endregion ViewManager Patches + } + + #endregion Melon Events + + #region Harmony Patches + + private static float lastJumpTime = -1f; + private static bool wasJumping; + + private static bool OnPreCVRSeatUpdate(CVRSeat __instance) + { + if (!__instance.occupied) return false; + + // Crazy? + bool jumped = CVRInputManager.Instance.jump; + bool justJumped = jumped && !wasJumping; + wasJumping = jumped; + if (justJumped && (!EntryOnlyInVR.Value || MetaPort.Instance.isUsingVr)) + { + float t = Time.time; + if (t - lastJumpTime <= BetterBetterCharacterController.DoubleJumpFlightTimeOut) + { + lastJumpTime = -1f; + __instance.ExitSeat(); + return false; + } + lastJumpTime = t; + } + + // Double update this frame (this ensures Extrapolate / Every Frame Updated objects are seated correctly) + if (__instance.vrSitPosition.position != __instance._lastPosition || __instance.vrSitPosition.rotation != __instance._lastRotation) + __instance.MovePlayerToSeat(__instance.vrSitPositionReady ? __instance.vrSitPosition : __instance.transform); + + // Steal sync + if (__instance.lockControls) + { + if (__instance._spawnable != null) __instance._spawnable.ForceUpdate(4); + if (__instance._objectSync != null) __instance._objectSync.ForceUpdate(4); + } + + return false; // don't call original method + } + + // ReSharper disable once RedundantAssignment + private static void OnPreViewManagerUpdate(ref bool __state) + => (__state, BetterBetterCharacterController.Instance._isSitting) + = (BetterBetterCharacterController.Instance._isSitting, false); + + private static void OnPostViewManagerUpdate(ref bool __state) + => BetterBetterCharacterController.Instance._isSitting = __state; + + #endregion Harmony Patches +} \ No newline at end of file diff --git a/DoubleTapJumpToExitSeat/Properties/AssemblyInfo.cs b/DoubleTapJumpToExitSeat/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fd30036 --- /dev/null +++ b/DoubleTapJumpToExitSeat/Properties/AssemblyInfo.cs @@ -0,0 +1,32 @@ +using MelonLoader; +using NAK.DoubleTapJumpToExitSeat.Properties; +using System.Reflection; + +[assembly: AssemblyVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyTitle(nameof(NAK.DoubleTapJumpToExitSeat))] +[assembly: AssemblyCompany(AssemblyInfoParams.Author)] +[assembly: AssemblyProduct(nameof(NAK.DoubleTapJumpToExitSeat))] + +[assembly: MelonInfo( + typeof(NAK.DoubleTapJumpToExitSeat.DoubleTapJumpToExitSeatMod), + nameof(NAK.DoubleTapJumpToExitSeat), + AssemblyInfoParams.Version, + AssemblyInfoParams.Author, + downloadLink: "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/DoubleTapJumpToExitSeat" +)] + +[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")] +[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] +[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)] +[assembly: MelonColor(255, 246, 25, 99)] // red-pink +[assembly: MelonAuthorColor(255, 158, 21, 32)] // red +[assembly: HarmonyDontPatchAll] + +namespace NAK.DoubleTapJumpToExitSeat.Properties; +internal static class AssemblyInfoParams +{ + public const string Version = "1.0.0"; + public const string Author = "NotAKidoS"; +} \ No newline at end of file diff --git a/DoubleTapJumpToExitSeat/README.md b/DoubleTapJumpToExitSeat/README.md new file mode 100644 index 0000000..df6f722 --- /dev/null +++ b/DoubleTapJumpToExitSeat/README.md @@ -0,0 +1,14 @@ +# DoubleTapJumpToExitSeat + +Literally the mod name. + +--- + +Here is the block of text where I tell you this mod is not affiliated with or endorsed by ABI. +https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games + +> This mod is an independent creation not affiliated with, supported by, or approved by Alpha Blend Interactive. + +> Use of this mod is done so at the user's own risk and the creator cannot be held responsible for any issues arising from its use. + +> To the best of my knowledge, I have adhered to the Modding Guidelines established by Alpha Blend Interactive. diff --git a/DoubleTapJumpToExitSeat/format.json b/DoubleTapJumpToExitSeat/format.json new file mode 100644 index 0000000..b7fa28e --- /dev/null +++ b/DoubleTapJumpToExitSeat/format.json @@ -0,0 +1,23 @@ +{ + "_id": -1, + "name": "DoubleTapJumpToExitSeat", + "modversion": "1.0.0", + "gameversion": "2025r179", + "loaderversion": "0.6.1", + "modtype": "Mod", + "author": "NotAKidoS", + "description": "Literally the mod name.", + "searchtags": [ + "double", + "jump", + "chair", + "seat" + ], + "requirements": [ + "None" + ], + "downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r46/DoubleTapJumpToExitSeat.dll", + "sourcelink": "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/DoubleTapJumpToExitSeat/", + "changelog": "- Initial Release", + "embedcolor": "#00FFFF" +} \ No newline at end of file