using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using HarmonyLib;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Interaction;
using IndexFingers;
using MelonLoader;
using MelonLoader.Preferences;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("IndexFingers")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany(null)]
[assembly: AssemblyProduct("IndexFingers")]
[assembly: AssemblyCopyright("Created by EvroDev")]
[assembly: AssemblyTrademark(null)]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("2.2.0")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: MelonInfo(typeof(global::IndexFingers.IndexFingers), "IndexFingers", "2.2.0", "EvroDev", null)]
[assembly: MelonGame(null, null)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("2.2.0.0")]
namespace IndexFingers;
public static class BuildInfo
{
public const string Name = "IndexFingers";
public const string Author = "EvroDev";
public const string Company = null;
public const string Version = "2.2.0";
public const string DownloadLink = null;
}
public class IndexFingers : MelonMod
{
[HarmonyPatch(typeof(OpenController), "OnUpdate")]
public static class ControllerPatch
{
public static Vector2 previousValues;
public static Vector2 ringsMax = Vector2.one;
public static Vector2 pinkysMax = Vector2.one;
public static Vector2 middleFingerUsage;
public static Vector2 buttonPressLengths;
public static void Postfix(OpenController __instance)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
Handedness handedness = ((BaseController)__instance).handedness;
if (((BaseController)__instance)._bButtonDown && !IsHoldingObject(handedness))
{
ToggleMiddle(handedness);
}
else if (IsHoldingObject(handedness) && IsMiddleToggled(handedness))
{
DisableMiddle(handedness);
}
if (((BaseController)__instance)._bButton)
{
buttonPressLengths.SetFromHandedness(handedness, buttonPressLengths.FromHandedness(handedness) + Time.deltaTime);
if (buttonPressLengths.FromHandedness(handedness) >= 1f)
{
DisableMiddle(handedness);
}
}
else if (buttonPressLengths.FromHandedness(handedness) != 0f)
{
buttonPressLengths.SetFromHandedness(handedness, 0f);
}
if (HandsWereOpen(handedness) && ((BaseController)__instance)._processedMiddle == 1f)
{
RandomizeFingerLimits(handedness);
}
previousValues.SetFromHandedness(handedness, ((BaseController)__instance)._processedMiddle);
float num = ringsMax.FromHandedness(handedness);
float num2 = pinkysMax.FromHandedness(handedness);
float num3 = ((middleFingerUsage.FromHandedness(handedness) != 1f) ? 1f : (middleEnabled ? defaultMinimum : 1f));
((BaseController)__instance)._processedMiddle = (movingFingersEnabled ? Mathf.Clamp(Mathf.Sqrt(((BaseController)__instance)._processedMiddle), defaultMinimum, num3) : Mathf.Clamp(((BaseController)__instance)._processedMiddle, defaultMinimum, num3));
((BaseController)__instance)._processedIndex = Mathf.Clamp(((BaseController)__instance)._processedIndex, defaultMinimum, 1f);
((BaseController)__instance)._processedRing = Mathf.Clamp(((BaseController)__instance)._processedRing, defaultMinimum, num);
((BaseController)__instance)._processedPinky = (movingFingersEnabled ? Mathf.Clamp(Mathf.Pow(((BaseController)__instance)._processedPinky, 2f), defaultMinimum, num2) : Mathf.Clamp(((BaseController)__instance)._processedPinky, defaultMinimum, num2));
}
public static void EnableMiddle(Handedness handedness)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
middleFingerUsage.SetFromHandedness(handedness, 1f);
}
public static void DisableMiddle(Handedness handedness)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
middleFingerUsage.SetFromHandedness(handedness, 0f);
}
public static void ToggleMiddle(Handedness handedness)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
if (IsMiddleToggled(handedness))
{
DisableMiddle(handedness);
}
else
{
EnableMiddle(handedness);
}
}
public static void RandomizeFingerLimits(Handedness handedness)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
if (!closedHandFingerEnabled)
{
ResetFingerLimits(handedness);
return;
}
ringsMax.SetFromHandedness(handedness, Random.Range(0.9f, 1f));
pinkysMax.SetFromHandedness(handedness, Random.Range(0.8f, 1f));
}
public static void ResetFingerLimits(Handedness handedness)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
ringsMax.SetFromHandedness(handedness, 1f);
pinkysMax.SetFromHandedness(handedness, 1f);
}
public static bool HandsWereOpen(Handedness handedness)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return previousValues.FromHandedness(handedness) != 1f;
}
public static bool IsMiddleToggled(Handedness handedness)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return middleFingerUsage.FromHandedness(handedness) == 1f;
}
public static bool IsHoldingObject(Handedness handedness)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
if ((int)handedness == 1)
{
return (Object)(object)Player.GetObjectInHand(Player.LeftHand) != (Object)null;
}
return (Object)(object)Player.GetObjectInHand(Player.RightHand) != (Object)null;
}
}
public static bool middleEnabled = true;
public static bool closedHandFingerEnabled = true;
public static bool movingFingersEnabled = true;
public static float defaultMinimum = 0.1f;
public override void OnInitializeMelon()
{
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
MelonPreferences.CreateCategory("IndexFingers");
middleEnabled = MelonPreferences.CreateEntry<bool>("IndexFingers", "MidToggle", true, (string)null, (string)null, false, false, (ValueValidator)null).Value;
movingFingersEnabled = MelonPreferences.CreateEntry<bool>("IndexFingers", "MovingOffset", true, (string)null, (string)null, false, false, (ValueValidator)null).Value;
closedHandFingerEnabled = MelonPreferences.CreateEntry<bool>("IndexFingers", "GrabbedOffset", true, (string)null, (string)null, false, false, (ValueValidator)null).Value;
defaultMinimum = MelonPreferences.CreateEntry<float>("IndexFingers", "DefaultCurl", 0.1f, (string)null, (string)null, false, false, (ValueValidator)null).Value;
Page val = Page.Root.CreatePage("IndexFingers", Color.white, 0, true);
val.CreateBool("Middle Finger Toggling", Color.white, MelonPreferences.GetEntryValue<bool>("IndexFingers", "MidToggle"), (Action<bool>)delegate(bool b)
{
middleEnabled = b;
});
val.CreateBool("Moving Finger Offset", Color.white, MelonPreferences.GetEntryValue<bool>("IndexFingers", "MovingOffset"), (Action<bool>)delegate(bool b)
{
movingFingersEnabled = b;
});
val.CreateBool("Grabbed Finger Offset", Color.white, MelonPreferences.GetEntryValue<bool>("IndexFingers", "GrabbedOffset"), (Action<bool>)delegate(bool b)
{
closedHandFingerEnabled = b;
});
val.CreateFloat("Default Curl Amount", Color.white, MelonPreferences.GetEntryValue<float>("IndexFingers", "DefaultCurl"), 0.01f, 0f, 1f, (Action<float>)delegate(float f)
{
defaultMinimum = f;
});
}
public override void OnApplicationQuit()
{
MelonPreferences.SetEntryValue<bool>("IndexFingers", "MidToggle", middleEnabled);
MelonPreferences.SetEntryValue<bool>("IndexFingers", "MovingOffset", movingFingersEnabled);
MelonPreferences.SetEntryValue<bool>("IndexFingers", "GrabbedOffset", closedHandFingerEnabled);
MelonPreferences.SetEntryValue<float>("IndexFingers", "DefaultCurl", defaultMinimum);
}
}
public static class StupidExtensionsForVeryBreifSimplificationKinda
{
public static float FromHandedness(this Vector2 vector, Handedness handedness)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
if ((int)handedness == 1)
{
return vector.x;
}
return vector.y;
}
public static void SetFromHandedness(this ref Vector2 vector, Handedness handedness, float value)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
if ((int)handedness == 1)
{
vector.x = value;
}
else
{
vector.y = value;
}
}
}