From e61f119f32a2f71757303be4421651d2c016e289 Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Wed, 26 Jul 2023 10:38:14 -0500 Subject: [PATCH] [FuckToes] Update for 2023r171 Fixed a few setting issues too. --- FuckToes/HarmonyPatches.cs | 25 ---------------- FuckToes/Main.cs | 46 +++++++++++++++++++++-------- FuckToes/Properties/AssemblyInfo.cs | 9 +++--- FuckToes/format.json | 12 ++++---- 4 files changed, 45 insertions(+), 47 deletions(-) delete mode 100644 FuckToes/HarmonyPatches.cs diff --git a/FuckToes/HarmonyPatches.cs b/FuckToes/HarmonyPatches.cs deleted file mode 100644 index d975ef4..0000000 --- a/FuckToes/HarmonyPatches.cs +++ /dev/null @@ -1,25 +0,0 @@ -using ABI_RC.Core.Savior; -using HarmonyLib; -using RootMotion.FinalIK; - - -namespace NAK.FuckToes.HarmonyPatches; - -//yes im patching VRIK directly, cvr does not force calibration or mess with references, and leaves it to vrik to handle -class VRIKPatches -{ - [HarmonyPostfix] - [HarmonyPatch(typeof(VRIK), "AutoDetectReferences")] - private static void Postfix_VRIK_AutoDetectReferences(ref VRIK __instance) - { - //only run for PlayerLocal VRIK - if (__instance.gameObject.layer != 8) return; - - if (FuckToes.EntryEnabledVR.Value && MetaPort.Instance.isUsingVr) - { - if (!FuckToes.EntryEnabledFBT.Value && MetaPort.Instance.isUsingFullbody) return; - __instance.references.leftToes = null; - __instance.references.rightToes = null; - } - } -} \ No newline at end of file diff --git a/FuckToes/Main.cs b/FuckToes/Main.cs index b12f45e..c98b8e0 100644 --- a/FuckToes/Main.cs +++ b/FuckToes/Main.cs @@ -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 EntryEnabledVR = - Category.CreateEntry("Enabled", true, description: "Nuke VRIK toes when in Halfbody."); + public static readonly MelonPreferences_Entry EntryEnabledVR = + Category.CreateEntry("Enabled in HalfBody", true, description: "Nuke VRIK toes when in Halfbody."); - public static readonly MelonPreferences_Entry EntryEnabledFBT = - Category.CreateEntry("Enabled in FBT", false, description: "Nuke VRIK toes when in FBT."); + public static readonly MelonPreferences_Entry 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); } } } \ No newline at end of file diff --git a/FuckToes/Properties/AssemblyInfo.cs b/FuckToes/Properties/AssemblyInfo.cs index 1472056..06b71da 100644 --- a/FuckToes/Properties/AssemblyInfo.cs +++ b/FuckToes/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using FuckToes.Properties; +using NAK.FuckToes.Properties; using MelonLoader; using System.Reflection; @@ -20,12 +20,13 @@ using System.Reflection; [assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")] [assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] [assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)] -[assembly: MelonOptionalDependencies("BTKUILib")] +[assembly: MelonColor(255, 255, 200, 0)] +[assembly: MelonAuthorColor(255, 158, 21, 32)] [assembly: HarmonyDontPatchAll] -namespace FuckToes.Properties; +namespace NAK.FuckToes.Properties; internal static class AssemblyInfoParams { - public const string Version = "1.0.1"; + public const string Version = "1.0.2"; public const string Author = "NotAKidoS"; } \ No newline at end of file diff --git a/FuckToes/format.json b/FuckToes/format.json index 51299fe..e814d47 100644 --- a/FuckToes/format.json +++ b/FuckToes/format.json @@ -1,12 +1,12 @@ { "_id": 129, "name": "FuckToes", - "modversion": "1.0.1", - "gameversion": "2022r170p1", + "modversion": "1.0.2", + "gameversion": "2023r171", "loaderversion": "0.6.1", "modtype": "Mod", "author": "NotAKidoS", - "description": "Prevents VRIK from using toe bones in VR & optionaly FBT.\n\nVRIK calculates weird center of mass when toes are mapped, so it is sometimes desired to unmap toes to prevent an avatars feet from resting far back.\n\nPlease see the README for relevant imagery detailing the problem.", + "description": "Prevents VRIK from using toe bones in HalfBody or FBT.\n\nVRIK calculates weird center of mass when toes are mapped, so it is sometimes desired to unmap toes to prevent an avatars feet from resting far back.\n\nPlease see the README for relevant imagery detailing the problem.", "searchtags": [ "toes", "vrik", @@ -16,8 +16,8 @@ "requirements": [ "None" ], - "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/FuckToes.dll", + "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r14/FuckToes.dll", "sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/FuckToes/", - "changelog": "- Initial Release\n- No double patching. Bad. Stinky. Dont do it.", - "embedcolor": "#ffc700" + "changelog": "- Fixes for 2023r171.", + "embedcolor": "#ffc800" } \ No newline at end of file