mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2026-02-11 18:56:11 +00:00
mass commit of laziness
This commit is contained in:
parent
ce992c70ee
commit
6d4fc549d9
167 changed files with 5471 additions and 675 deletions
34
.Deprecated/KeepVelocityOnExitFlight/Main.cs
Normal file
34
.Deprecated/KeepVelocityOnExitFlight/Main.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System.Reflection;
|
||||
using ABI_RC.Systems.Movement;
|
||||
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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue