FuckToes: fixes for r176

This commit is contained in:
NotAKidoS 2024-09-06 01:08:37 -05:00
parent 16a1a35a91
commit 51f29106c3
3 changed files with 38 additions and 24 deletions

View file

@ -6,46 +6,58 @@ using System.Reflection;
namespace NAK.FuckToes;
public class FuckToes : MelonMod
public class FuckToesMod : MelonMod
{
internal static MelonLogger.Instance Logger;
private static MelonLogger.Instance Logger;
public static readonly MelonPreferences_Category Category =
MelonPreferences.CreateCategory(nameof(FuckToes));
#region Melon Preferences
public static readonly MelonPreferences_Entry<bool> EntryEnabledVR =
private static readonly MelonPreferences_Category Category =
MelonPreferences.CreateCategory(nameof(FuckToesMod));
private 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 =
private static readonly MelonPreferences_Entry<bool> EntryEnabledFBT =
Category.CreateEntry("Enabled in FBT", true, description: "Nuke VRIK toes when in FBT.");
#endregion Melon Preferences
#region Melon Events
public override void OnInitializeMelon()
{
Logger = LoggerInstance;
HarmonyInstance.Patch(
typeof(VRIK).GetMethod(nameof(VRIK.AutoDetectReferences)),
prefix: new HarmonyLib.HarmonyMethod(typeof(FuckToes).GetMethod(nameof(OnVRIKAutoDetectReferences_Prefix), BindingFlags.NonPublic | BindingFlags.Static))
prefix: new HarmonyLib.HarmonyMethod(typeof(FuckToesMod).GetMethod(nameof(OnVRIKAutoDetectReferences_Prefix), BindingFlags.NonPublic | BindingFlags.Static))
);
}
#endregion Melon Events
#region Harmony Patches
private static void OnVRIKAutoDetectReferences_Prefix(ref VRIK __instance)
{
try
{
// Must be PlayerLocal layer and in VR
if (__instance.gameObject.layer != 8 || !MetaPort.Instance.isUsingVr)
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;
switch (IKSystem.Instance.BodySystem.FullBodyActive)
{
case false when !EntryEnabledVR.Value: // Not in FBT, and not enabled, perish
case true when !EntryEnabledFBT.Value: // In FBT, and not enabled in fbt, perish
return;
default:
__instance.references.leftToes = null;
__instance.references.rightToes = null;
break;
}
}
catch (Exception e)
{
@ -53,4 +65,6 @@ public class FuckToes : MelonMod
Logger.Error(e);
}
}
#endregion Harmony Patches
}