mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
[FuckToes] Update for 2023r171
Fixed a few setting issues too.
This commit is contained in:
parent
ba4bb02a6d
commit
e61f119f32
4 changed files with 45 additions and 47 deletions
|
@ -1,34 +1,56 @@
|
|||
using MelonLoader;
|
||||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Systems.IK;
|
||||
using MelonLoader;
|
||||
using RootMotion.FinalIK;
|
||||
using System.Reflection;
|
||||
|
||||
namespace NAK.FuckToes;
|
||||
|
||||
public class FuckToes : MelonMod
|
||||
{
|
||||
public static readonly MelonPreferences_Category Category =
|
||||
internal static MelonLogger.Instance Logger;
|
||||
|
||||
public static readonly MelonPreferences_Category Category =
|
||||
MelonPreferences.CreateCategory(nameof(FuckToes));
|
||||
|
||||
public static readonly MelonPreferences_Entry<bool> EntryEnabledVR =
|
||||
Category.CreateEntry("Enabled", true, description: "Nuke VRIK toes when in Halfbody.");
|
||||
public static readonly MelonPreferences_Entry<bool> EntryEnabledVR =
|
||||
Category.CreateEntry("Enabled in HalfBody", true, description: "Nuke VRIK toes when in Halfbody.");
|
||||
|
||||
public static readonly MelonPreferences_Entry<bool> EntryEnabledFBT =
|
||||
Category.CreateEntry("Enabled in FBT", false, description: "Nuke VRIK toes when in FBT.");
|
||||
public static readonly MelonPreferences_Entry<bool> EntryEnabledFBT =
|
||||
Category.CreateEntry("Enabled in FBT", true, description: "Nuke VRIK toes when in FBT.");
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
//Apply patches (i stole)
|
||||
ApplyPatches(typeof(HarmonyPatches.VRIKPatches));
|
||||
Logger = LoggerInstance;
|
||||
HarmonyInstance.Patch(
|
||||
typeof(VRIK).GetMethod(nameof(VRIK.AutoDetectReferences)),
|
||||
prefix: new HarmonyLib.HarmonyMethod(typeof(FuckToes).GetMethod(nameof(OnVRIKAutoDetectReferences_Prefix), BindingFlags.NonPublic | BindingFlags.Static))
|
||||
);
|
||||
}
|
||||
|
||||
private void ApplyPatches(Type type)
|
||||
private static void OnVRIKAutoDetectReferences_Prefix(ref VRIK __instance)
|
||||
{
|
||||
try
|
||||
{
|
||||
HarmonyInstance.PatchAll(type);
|
||||
// Must be PlayerLocal layer and in VR
|
||||
if (__instance.gameObject.layer != 8 || !MetaPort.Instance.isUsingVr)
|
||||
return;
|
||||
|
||||
// Not in FBT, and not enabled, perish
|
||||
if (!IKSystem.Instance.BodySystem.FBTActive() && !EntryEnabledVR.Value)
|
||||
return;
|
||||
|
||||
// In FBT, and not enabled in fbt, perish
|
||||
if (IKSystem.Instance.BodySystem.FBTActive() && !EntryEnabledFBT.Value)
|
||||
return;
|
||||
|
||||
__instance.references.leftToes = null;
|
||||
__instance.references.rightToes = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LoggerInstance.Msg($"Failed while patching {type.Name}!");
|
||||
LoggerInstance.Error(e);
|
||||
Logger.Error($"Error during the patched method {nameof(OnVRIKAutoDetectReferences_Prefix)}");
|
||||
Logger.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue