Scaled jump

Minor changes
This commit is contained in:
SDraw 2023-05-07 20:42:52 +03:00
parent 08b1909d52
commit e73dd54e7b
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
11 changed files with 435 additions and 216 deletions

View file

@ -0,0 +1,57 @@
using ABI.CCK.Components;
using ABI_RC.Core.Player;
using ABI_RC.Systems.IK.SubSystems;
using System.Reflection;
namespace ml_amt.Fixes
{
static class FBTDetectionFix
{
static readonly MethodInfo[] ms_fbtDetouredMethods =
{
typeof(PlayerSetup).GetMethod("Update", BindingFlags.NonPublic | BindingFlags.Instance),
typeof(PlayerSetup).GetMethod("FixedUpdate", BindingFlags.NonPublic | BindingFlags.Instance),
typeof(PlayerSetup).GetMethod("UpdatePlayerAvatarMovementData", BindingFlags.NonPublic | BindingFlags.Instance),
typeof(CVRParameterStreamEntry).GetMethod(nameof(CVRParameterStreamEntry.CheckUpdate))
};
static bool ms_fbtDetour = false;
internal static void Init(HarmonyLib.Harmony p_instance)
{
// FBT detour
p_instance.Patch(
typeof(BodySystem).GetMethod(nameof(BodySystem.FBTAvailable)),
new HarmonyLib.HarmonyMethod(typeof(FBTDetectionFix).GetMethod(nameof(OnFBTAvailable_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
null
);
foreach(MethodInfo l_detoured in ms_fbtDetouredMethods)
{
p_instance.Patch(
l_detoured,
new HarmonyLib.HarmonyMethod(typeof(FBTDetectionFix).GetMethod(nameof(FBTDetour_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
new HarmonyLib.HarmonyMethod(typeof(FBTDetectionFix).GetMethod(nameof(FBTDetour_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
);
}
}
// FBT detection override
static void FBTDetour_Prefix()
{
ms_fbtDetour = true;
}
static void FBTDetour_Postfix()
{
ms_fbtDetour = false;
}
static bool OnFBTAvailable_Prefix(ref bool __result)
{
if(ms_fbtDetour && !BodySystem.isCalibratedAsFullBody)
{
__result = false;
return false;
}
return true;
}
}
}