using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using Il2CppSLZ.Marrow;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using WigglesHandSigns;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: MelonInfo(typeof(HandSignsMod), "Wiggles Hand Signs", "1.1.0", "adama", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: SecurityPermission((SecurityAction)8, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : System.Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(/*Could not decode attribute arguments.*/)]
internal sealed class RefSafetyRulesAttribute : System.Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace WigglesHandSigns
{
public enum Sign
{
None,
Rock,
Peace,
MiddleFinger,
CallMe
}
public enum SignButton
{
StickClick,
UpperButton,
LowerButton
}
public enum ShowWhen
{
Fist,
GripOnly,
Always
}
public class HandSignsMod : MelonMod
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static Action<bool> <>9__13_0;
public static Action<System.Enum> <>9__13_1;
public static Action<System.Enum> <>9__13_2;
public static Action<System.Enum> <>9__13_3;
public static Action<System.Enum> <>9__13_4;
public static Action <>9__13_5;
internal void <BuildMenu>b__13_0(bool v)
{
_on.Value = v;
if (!v)
{
_sign[0] = Sign.None;
_sign[1] = Sign.None;
}
}
internal void <BuildMenu>b__13_1(System.Enum v)
{
_button.Value = ((object)v).ToString();
}
internal void <BuildMenu>b__13_2(System.Enum v)
{
_show.Value = ((object)v).ToString();
}
internal void <BuildMenu>b__13_3(System.Enum v)
{
_sign[0] = (Sign)(object)v;
}
internal void <BuildMenu>b__13_4(System.Enum v)
{
_sign[1] = (Sign)(object)v;
}
internal void <BuildMenu>b__13_5()
{
_sign[0] = Sign.None;
_sign[1] = Sign.None;
}
}
private static MelonPreferences_Entry<bool> _on;
private static MelonPreferences_Entry<string> _button;
private static readonly Sign[] _sign = new Sign[2];
private static readonly bool[] _was = new bool[2];
private static readonly float[] _downAt = new float[2];
private static readonly bool[] _heldOff = new bool[2];
private const float HoldToClear = 0.6f;
private static readonly float[][] Curls;
private static MelonPreferences_Entry<string> _show;
private static ShowWhen CurrentShow
{
get
{
ShowWhen result = default(ShowWhen);
if (!System.Enum.TryParse<ShowWhen>(_show.Value, ref result))
{
return ShowWhen.Fist;
}
return result;
}
}
private static SignButton CurrentButton
{
get
{
SignButton result = default(SignButton);
if (!System.Enum.TryParse<SignButton>(_button.Value, ref result))
{
return SignButton.StickClick;
}
return result;
}
}
public override void OnInitializeMelon()
{
MelonPreferences_Category obj = MelonPreferences.CreateCategory("WigglesHandSigns");
_on = obj.CreateEntry<bool>("Enabled", true, "Hand signs on", (string)null, false, false, (ValueValidator)null, (string)null);
_button = obj.CreateEntry<string>("Button", ((object)SignButton.StickClick/*cast due to .constrained prefix*/).ToString(), "StickClick, UpperButton (B/Y) or LowerButton (A/X)", (string)null, false, false, (ValueValidator)null, (string)null);
_show = obj.CreateEntry<string>("ShowWhen", ((object)ShowWhen.Fist/*cast due to .constrained prefix*/).ToString(), "Fist (grip + trigger), GripOnly or Always", (string)null, false, false, (ValueValidator)null, (string)null);
BuildMenu();
}
private static bool Showing(BaseController c)
{
switch (CurrentShow)
{
case ShowWhen.Always:
return true;
case ShowWhen.GripOnly:
return c.GetGripForce() > 0.6f;
default:
if (c.GetGripForce() > 0.6f)
{
return c.GetPrimaryInteractionButtonAxis() > 0.5f;
}
return false;
}
}
private void BuildMenu()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: 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_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Expected O, but got Unknown
Page obj = Page.Root.CreatePage("Hand Signs", new Color(1f, 0.75f, 0.3f), 0, true);
obj.CreateBool("Enabled", Color.white, _on.Value, (Action<bool>)delegate(bool v)
{
_on.Value = v;
if (!v)
{
_sign[0] = Sign.None;
_sign[1] = Sign.None;
}
});
obj.CreateEnum("Button", Color.white, (System.Enum)CurrentButton, (Action<System.Enum>)delegate(System.Enum v)
{
_button.Value = ((object)v).ToString();
});
obj.CreateEnum("Show When", Color.white, (System.Enum)CurrentShow, (Action<System.Enum>)delegate(System.Enum v)
{
_show.Value = ((object)v).ToString();
});
obj.CreateEnum("Left Hand", Color.cyan, (System.Enum)Sign.None, (Action<System.Enum>)delegate(System.Enum v)
{
_sign[0] = (Sign)(object)v;
});
obj.CreateEnum("Right Hand", Color.cyan, (System.Enum)Sign.None, (Action<System.Enum>)delegate(System.Enum v)
{
_sign[1] = (Sign)(object)v;
});
Color red = Color.red;
object obj2 = <>c.<>9__13_5;
if (obj2 == null)
{
Action val = delegate
{
_sign[0] = Sign.None;
_sign[1] = Sign.None;
};
<>c.<>9__13_5 = val;
obj2 = (object)val;
}
obj.CreateFunction("Clear Both", red, (Action)obj2);
}
private static bool Pressed(BaseController c)
{
return CurrentButton switch
{
SignButton.UpperButton => c.GetBButton(),
SignButton.LowerButton => c.GetAButton(),
_ => c.GetThumbStick(),
};
}
private static Hand HandOf(int side)
{
if (side != 0)
{
return Player.RightHand;
}
return Player.LeftHand;
}
public override void OnUpdate()
{
if (_on == null || !_on.Value)
{
return;
}
try
{
for (int i = 0; i < 2; i++)
{
Hand val = HandOf(i);
BaseController val2 = (((Object)(object)val != (Object)null) ? val.Controller : null);
if (!((Object)(object)val2 == (Object)null))
{
bool flag = Pressed(val2);
if (flag && !_was[i])
{
_downAt[i] = Time.unscaledTime;
_heldOff[i] = false;
}
if (flag && !_heldOff[i] && Time.unscaledTime - _downAt[i] >= 0.6f)
{
_sign[i] = Sign.None;
_heldOff[i] = true;
}
if (!flag && _was[i] && !_heldOff[i] && !val.HasAttachedObject())
{
_sign[i] = (Sign)((int)(_sign[i] + 1) % 5);
}
_was[i] = flag;
}
}
}
catch
{
}
Apply();
}
public override void OnLateUpdate()
{
Apply();
}
public override void OnFixedUpdate()
{
Apply();
}
private static void Apply()
{
if (_on == null || !_on.Value)
{
return;
}
try
{
for (int i = 0; i < 2; i++)
{
if (_sign[i] == Sign.None)
{
continue;
}
Hand val = HandOf(i);
if (!((Object)(object)val == (Object)null) && !val.HasAttachedObject())
{
BaseController controller = val.Controller;
if (!((Object)(object)controller == (Object)null) && Showing(controller))
{
float[] array = Curls[(int)_sign[i]];
controller._processedThumb = array[0];
controller._processedIndex = array[1];
controller._processedMiddle = array[2];
controller._processedRing = array[3];
controller._processedPinky = array[4];
}
}
}
}
catch
{
}
}
static HandSignsMod()
{
float[][] array = new float[5][];
float[] array2 = new float[5];
RuntimeHelpers.InitializeArray((System.Array)array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
array[1] = array2;
float[] array3 = new float[5];
RuntimeHelpers.InitializeArray((System.Array)array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
array[2] = array3;
float[] array4 = new float[5];
RuntimeHelpers.InitializeArray((System.Array)array4, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
array[3] = array4;
float[] array5 = new float[5];
RuntimeHelpers.InitializeArray((System.Array)array5, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
array[4] = array5;
Curls = array;
}
}
}