Decompiled source of RagdollFix v2.0.0

Mods/RagdollFix.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using MelonLoader;
using MelonLoader.Preferences;
using RagdollFix;
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(null)]
[assembly: AssemblyDescription(null)]
[assembly: AssemblyCompany(null)]
[assembly: AssemblyProduct("Ragdoll Fix")]
[assembly: AssemblyCopyright("Developed by Bread Soup")]
[assembly: AssemblyTrademark(null)]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: MelonInfo(typeof(Main), "Ragdoll Fix", "2.0.0", "Bread Soup", null)]
[assembly: MelonColor(0, 0, 0, 0)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("2.0.0.0")]
namespace RagdollFix;

internal class Main : MelonMod
{
	internal const string Name = "Ragdoll Fix";

	internal const string Description = null;

	internal const string Author = "Bread Soup";

	internal const string Company = null;

	internal const string Version = "2.0.0";

	internal const string DownloadLink = null;

	private bool _sceneLoaded;

	private bool _previousRagdollState;

	private bool _currentRagdollState;

	public override void OnInitializeMelon()
	{
		Hooking.OnLevelLoaded += delegate
		{
			OnSceneAwake();
		};
		Preferences.MelonPreferencesCreator();
		Preferences.BoneMenuCreator();
	}

	private void OnSceneAwake()
	{
		_sceneLoaded = true;
		_previousRagdollState = Player.PhysicsRig._legsKinematic;
	}

	public override void OnUpdate()
	{
		//IL_004b: 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_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		if (_sceneLoaded && Preferences.IsEnabled)
		{
			_currentRagdollState = Player.PhysicsRig._legsKinematic;
			if (!_previousRagdollState && _currentRagdollState)
			{
				Vector3 val = Player.PhysicsRig.feet.transform.position + new Vector3(0f, 0.25f, 0f);
				Player.RigManager.Teleport(val, true);
			}
		}
		_previousRagdollState = _currentRagdollState;
	}
}
internal static class Preferences
{
	private static MelonPreferences_Category MelonPrefCategory { get; set; }

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

	public static bool IsEnabled { get; private set; }

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

	public static void BoneMenuCreator()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		Page val = Page.Root.CreatePage("Ragdoll Fix", Color.yellow, 0, true);
		val.CreateBool("Mod Toggle", Color.yellow, IsEnabled, (Action<bool>)OnSetEnabled);
	}

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