From f052ec7c8d38b4ec3f2c8f25d5c19fbadd0b204f Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Thu, 27 Jun 2024 21:00:48 -0500 Subject: [PATCH] [KeepVelocityOnExitFlight] Initial release --- .../KeepVelocityOnExitFlight.csproj | 6 ++++ KeepVelocityOnExitFlight/Main.cs | 36 +++++++++++++++++++ .../Properties/AssemblyInfo.cs | 32 +++++++++++++++++ KeepVelocityOnExitFlight/README.md | 14 ++++++++ KeepVelocityOnExitFlight/format.json | 24 +++++++++++++ 5 files changed, 112 insertions(+) create mode 100644 KeepVelocityOnExitFlight/KeepVelocityOnExitFlight.csproj create mode 100644 KeepVelocityOnExitFlight/Main.cs create mode 100644 KeepVelocityOnExitFlight/Properties/AssemblyInfo.cs create mode 100644 KeepVelocityOnExitFlight/README.md create mode 100644 KeepVelocityOnExitFlight/format.json diff --git a/KeepVelocityOnExitFlight/KeepVelocityOnExitFlight.csproj b/KeepVelocityOnExitFlight/KeepVelocityOnExitFlight.csproj new file mode 100644 index 0000000..bec5b03 --- /dev/null +++ b/KeepVelocityOnExitFlight/KeepVelocityOnExitFlight.csproj @@ -0,0 +1,6 @@ + + + + LoadedObjectHack + + diff --git a/KeepVelocityOnExitFlight/Main.cs b/KeepVelocityOnExitFlight/Main.cs new file mode 100644 index 0000000..a9dc414 --- /dev/null +++ b/KeepVelocityOnExitFlight/Main.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using ABI_RC.Core.Util.AnimatorManager; +using ABI_RC.Systems.Movement; +using ABI.CCK.Scripts; +using HarmonyLib; +using MelonLoader; +using UnityEngine; + +namespace NAK.KeepVelocityOnExitFlight; + +public class KeepVelocityOnExitFlightMod : MelonMod +{ + public override void OnInitializeMelon() + { + HarmonyInstance.Patch( + typeof(BetterBetterCharacterController).GetMethod(nameof(BetterBetterCharacterController.ChangeFlight), + BindingFlags.Public | BindingFlags.Instance), + prefix: new HarmonyMethod(typeof(KeepVelocityOnExitFlightMod).GetMethod(nameof(Prefix_OnChangeFlight), + BindingFlags.NonPublic | BindingFlags.Static)), + postfix: new HarmonyMethod(typeof(KeepVelocityOnExitFlightMod).GetMethod(nameof(Postfix_OnChangeFlight), + BindingFlags.NonPublic | BindingFlags.Static)) + ); + } + + // ReSharper disable once RedundantAssignment + private static void Prefix_OnChangeFlight(ref BetterBetterCharacterController __instance, ref Vector3 __state) + { + __state = __instance.GetVelocity(); + } + + private static void Postfix_OnChangeFlight(ref BetterBetterCharacterController __instance, ref Vector3 __state) + { + if (__instance.FlightAllowedInWorld && !__instance.IsFlying()) + __instance.SetVelocity(__state); + } +} \ No newline at end of file diff --git a/KeepVelocityOnExitFlight/Properties/AssemblyInfo.cs b/KeepVelocityOnExitFlight/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3cfd192 --- /dev/null +++ b/KeepVelocityOnExitFlight/Properties/AssemblyInfo.cs @@ -0,0 +1,32 @@ +using MelonLoader; +using NAK.KeepVelocityOnExitFlight.Properties; +using System.Reflection; + +[assembly: AssemblyVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyTitle(nameof(NAK.KeepVelocityOnExitFlight))] +[assembly: AssemblyCompany(AssemblyInfoParams.Author)] +[assembly: AssemblyProduct(nameof(NAK.KeepVelocityOnExitFlight))] + +[assembly: MelonInfo( + typeof(NAK.KeepVelocityOnExitFlight.KeepVelocityOnExitFlightMod), + nameof(NAK.KeepVelocityOnExitFlight), + AssemblyInfoParams.Version, + AssemblyInfoParams.Author, + downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/KeepVelocityOnExitFlight" +)] + +[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")] +[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] +[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)] +[assembly: MelonColor(255, 125, 126, 129)] +[assembly: MelonAuthorColor(255, 158, 21, 32)] +[assembly: HarmonyDontPatchAll] + +namespace NAK.KeepVelocityOnExitFlight.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/KeepVelocityOnExitFlight/README.md b/KeepVelocityOnExitFlight/README.md new file mode 100644 index 0000000..d5471d4 --- /dev/null +++ b/KeepVelocityOnExitFlight/README.md @@ -0,0 +1,14 @@ +# KeepVelocityOnExitFlight + +Keeps the player's velocity when exiting flight mode. Makes it possible to fling yourself like in Garry's Mod. + +--- + +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/KeepVelocityOnExitFlight/format.json b/KeepVelocityOnExitFlight/format.json new file mode 100644 index 0000000..63499d0 --- /dev/null +++ b/KeepVelocityOnExitFlight/format.json @@ -0,0 +1,24 @@ +{ + "_id": -1, + "name": "KeepVelocityOnExitFlight", + "modversion": "1.0.0", + "gameversion": "2024r175", + "loaderversion": "0.6.1", + "modtype": "Mod", + "author": "NotAKidoS", + "description": "Keeps the player's velocity when exiting flight mode. Makes it possible to fling yourself like in Garry's Mod.", + "searchtags": [ + "flight", + "mode", + "velocity", + "flying", + "fly" + ], + "requirements": [ + "None" + ], + "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r33/KeepVelocityOnExitFlight.dll", + "sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/KeepVelocityOnExitFlight/", + "changelog": "- Initial release", + "embedcolor": "#f61963" +} \ No newline at end of file