Decompiled source of AdjustHandRotations v1.0.0

WristOffsetMod.dll

Decompiled 4 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
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 WristOffsetMod;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(WristOffsetMain), "Wrist Offset Mod", "1.0.0", "YourName", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("WristOffsetMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WristOffsetMod")]
[assembly: AssemblyTitle("WristOffsetMod")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WristOffsetMod
{
	public class WristOffsetMain : MelonMod
	{
		private const string PrefCategory = "WristOffsetMod";

		private static MelonPreferences_Category _category;

		private static MelonPreferences_Entry<float> _entryX;

		private static MelonPreferences_Entry<float> _entryY;

		private static MelonPreferences_Entry<float> _entryZ;

		private static MelonPreferences_Entry<bool> _entryMirror;

		public static float ValX;

		public static float ValY;

		public static float ValZ;

		public static bool MirrorLeftHand = true;

		private Transform _leftHandPhysics;

		private Transform _rightHandPhysics;

		private GameObject _lastKnownRigManager;

		public override void OnInitializeMelon()
		{
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			_category = MelonPreferences.CreateCategory("WristOffsetMod");
			_entryX = _category.CreateEntry<float>("OffsetX", 0f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_entryY = _category.CreateEntry<float>("OffsetY", 0f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_entryZ = _category.CreateEntry<float>("OffsetZ", 0f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_entryMirror = _category.CreateEntry<bool>("MirrorLeft", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			ValX = _entryX.Value;
			ValY = _entryY.Value;
			ValZ = _entryZ.Value;
			MirrorLeftHand = _entryMirror.Value;
			Page val2 = Page.Root.CreatePage("Wrist Offset", Color.cyan, 0, true);
			val2.CreateFloat("X Pitch", Color.white, ValX, 0.5f, -180f, 180f, (Action<float>)delegate(float val)
			{
				ValX = val;
				_entryX.Value = val;
				MelonPreferences.Save();
			});
			val2.CreateFloat("Y Yaw", Color.white, ValY, 0.5f, -180f, 180f, (Action<float>)delegate(float val)
			{
				ValY = val;
				_entryY.Value = val;
				MelonPreferences.Save();
			});
			val2.CreateFloat("Z Roll", Color.white, ValZ, 0.5f, -180f, 180f, (Action<float>)delegate(float val)
			{
				ValZ = val;
				_entryZ.Value = val;
				MelonPreferences.Save();
			});
			val2.CreateBool("Mirror Left Hand", Color.yellow, MirrorLeftHand, (Action<bool>)delegate(bool val)
			{
				MirrorLeftHand = val;
				_entryMirror.Value = val;
				MelonPreferences.Save();
			});
			val2.CreateFunction("Reset to 0", Color.red, (Action)delegate
			{
				ValX = 0f;
				ValY = 0f;
				ValZ = 0f;
				_entryX.Value = 0f;
				_entryY.Value = 0f;
				_entryZ.Value = 0f;
				MelonPreferences.Save();
				MelonLogger.Msg("Reset complete. Reopen menu to see changes.");
			});
			MelonLogger.Msg("WristOffsetMod Initialized.");
		}

		public override void OnFixedUpdate()
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			RigManager rigManager = Player.RigManager;
			if ((Object)(object)rigManager == (Object)null)
			{
				return;
			}
			if ((Object)(object)((Component)rigManager).gameObject != (Object)(object)_lastKnownRigManager)
			{
				RefreshHands(rigManager);
			}
			if (ValX != 0f || ValY != 0f || ValZ != 0f)
			{
				if ((Object)(object)_leftHandPhysics != (Object)null)
				{
					Quaternion val = ((!MirrorLeftHand) ? Quaternion.Euler(ValX, ValY, ValZ) : Quaternion.Euler(ValX, 0f - ValY, 0f - ValZ));
					Transform leftHandPhysics = _leftHandPhysics;
					leftHandPhysics.localRotation *= val;
				}
				if ((Object)(object)_rightHandPhysics != (Object)null)
				{
					Quaternion val2 = Quaternion.Euler(ValX, ValY, ValZ);
					Transform rightHandPhysics = _rightHandPhysics;
					rightHandPhysics.localRotation *= val2;
				}
			}
		}

		private void RefreshHands(RigManager rigManager)
		{
			_lastKnownRigManager = ((Component)rigManager).gameObject;
			MelonLogger.Msg("New RigManager detected. Finding Physics Hands...");
			Transform val = ((Component)rigManager).transform.Find("PhysicsRig");
			if ((Object)(object)val != (Object)null)
			{
				Transform leftHandPhysics = val.Find("Hand (left)");
				Transform rightHandPhysics = val.Find("Hand (right)");
				_leftHandPhysics = leftHandPhysics;
				_rightHandPhysics = rightHandPhysics;
				if ((Object)(object)_leftHandPhysics != (Object)null)
				{
					MelonLogger.Msg(" -> Linked Left Physics Hand");
				}
				else
				{
					MelonLogger.Error(" -> Could not find 'Hand (left)' in PhysicsRig!");
				}
				if ((Object)(object)_rightHandPhysics != (Object)null)
				{
					MelonLogger.Msg(" -> Linked Right Physics Hand");
				}
				else
				{
					MelonLogger.Error(" -> Could not find 'Hand (right)' in PhysicsRig!");
				}
			}
			else
			{
				MelonLogger.Error("Could not find 'PhysicsRig' child on RigManager.");
			}
		}
	}
}