Decompiled source of RagdollView v1.2.1

Mods/RagdollView.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSLZ.Marrow;
using MelonLoader;
using MelonLoader.Preferences;
using RagdollView;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(RagdollViewMod), "Ragdoll View", "1.2.1", "Lakatrazz", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: AssemblyDescription("A BONELAB mod that lets you see from the perspective of your ragdoll.")]
[assembly: AssemblyTitle("Ragdoll View")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.0")]
[module: UnverifiableCode]
namespace RagdollView;

public class RagdollViewMod : MelonMod
{
	public const string Version = "1.2.1";

	private static bool _preferencesSetup;

	public static MelonPreferences_Category MelonPrefCategory { get; private set; }

	public static MelonPreferences_Entry<bool> MelonPrefEnabled { get; private set; }

	public static bool IsEnabled { get; private set; }

	public static Page MainPage { get; private set; }

	public static BoolElement EnabledElement { get; private set; }

	public override void OnInitializeMelon()
	{
		SetupMelonPrefs();
		SetupBoneMenu();
	}

	public static void SetupMelonPrefs()
	{
		MelonPrefCategory = MelonPreferences.CreateCategory("Ragdoll View");
		MelonPrefEnabled = MelonPrefCategory.CreateEntry<bool>("IsEnabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		IsEnabled = MelonPrefEnabled.Value;
		_preferencesSetup = true;
	}

	public static void SetupBoneMenu()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		MainPage = Page.Root.CreatePage("Ragdoll View", Color.cyan, 0, true);
		EnabledElement = MainPage.CreateBool("Mod Toggle", Color.yellow, IsEnabled, (Action<bool>)OnSetEnabled);
	}

	public static void OnSetEnabled(bool value)
	{
		IsEnabled = value;
		MelonPrefEnabled.Value = value;
		MelonPrefCategory.SaveToFile(false);
	}

	public override void OnPreferencesLoaded()
	{
		if (_preferencesSetup)
		{
			IsEnabled = MelonPrefEnabled.Value;
			EnabledElement.Value = IsEnabled;
		}
	}

	public override void OnLateUpdate()
	{
		OnParentView();
	}

	private static void OnParentView()
	{
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		RigManager rigManager = Player.RigManager;
		if (!((Object)(object)rigManager == (Object)null) && !(Time.timeScale <= 0f))
		{
			OpenControllerRig obj = ((Il2CppObjectBase)rigManager.controllerRig).TryCast<OpenControllerRig>();
			Transform transform = ((Component)((Rig)obj).m_head).transform;
			Transform transform2 = ((Component)obj).transform;
			Transform head = ((Rig)rigManager.physicsRig).m_head;
			bool flag = rigManager.physicsRig.torso.shutdown || !rigManager.physicsRig.ballLocoEnabled;
			if (IsEnabled && flag && !Object.op_Implicit((Object)(object)rigManager.activeSeat))
			{
				transform2.localPosition = Vector3.zero;
				transform2.localRotation = Quaternion.identity;
				transform2.rotation = Quaternion.identity;
				transform2.rotation = head.rotation * Quaternion.Inverse(transform.rotation);
				transform2.position += head.position - transform.position;
			}
		}
	}
}