Decompiled source of Configurable Ragdoll v1.0.1

ConfigurableRagdoll.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Character;
using FishNet.Object;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ModGentleman")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ModGentleman")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("96c2e944-9691-4ff8-8853-58f1664a244e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ConfigurableRagdollMod;

[BepInPlugin("com.unii.agd.configurableragdoll", "Configurable Ragdoll Time", "1.0.0")]
public class ConfigurableRagdollPlugin : BaseUnityPlugin
{
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	public struct PluginInfo
	{
		public const string PLUGIN_GUID = "com.unii.agd.configurableragdoll";

		public const string PLUGIN_NAME = "Configurable Ragdoll Time";

		public const string PLUGIN_VERSION = "1.0.0";
	}

	public static ConfigEntry<float> MaxRagdollTimeConfig;

	public static ConfigEntry<float> minSpeedForGetupConfig;

	public static ConfigEntry<float> ForgivingSpeedConfig;

	private void Awake()
	{
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		MaxRagdollTimeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Gameplay", "MaxRagdollTime", 30f, "The maximum amount of time (in seconds) a character can spend in the ragdoll state.");
		minSpeedForGetupConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Gameplay", "minSpeedForGetup", 20f, "The minimum speed a characcter needs to reach before getting up.");
		ForgivingSpeedConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Gameplay", "ForgivingSpeedThreshold", 1.5f, "The maximum sliding/tumbling speed allowed to successfully stand up.");
		new Harmony("com.unii.agd.configurableragdoll").PatchAll(typeof(RagdollPatch));
		((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("Plugin {0} loaded! MaxRagdollTime: {1}s. minSpeedForGetup: {2}. ForgivingSpeed: {3}", "Configurable Ragdoll Time", MaxRagdollTimeConfig.Value, minSpeedForGetupConfig, ForgivingSpeedConfig));
	}
}
[HarmonyPatch(typeof(RagdollController))]
public class RagdollPatch
{
	[HarmonyPatch("Awake")]
	[HarmonyPostfix]
	private static void AwakePostfix(RagdollController __instance)
	{
		__instance.maxRagdollTime = ConfigurableRagdollPlugin.MaxRagdollTimeConfig.Value;
		__instance.minSpeedForGetup = ConfigurableRagdollPlugin.minSpeedForGetupConfig.Value;
	}

	[HarmonyPatch("HandleStandUp")]
	[HarmonyPostfix]
	private static void HandleStandUpPostfix(RagdollController __instance)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: 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)
		if ((!((NetworkBehaviour)__instance).IsServerInitialized && (!__instance.IsClientRagdoll || !((NetworkBehaviour)__instance).IsOwner)) || !__instance.IsRagdoll || !__instance.IsOnGround || __instance.IsStandingUpNetworked.Value)
		{
			return;
		}
		Vector3 rootVelocity = __instance.RootVelocity;
		float magnitude = ((Vector3)(ref rootVelocity)).magnitude;
		if (__instance.TimeInRagdollState.Elapsed > 1f && magnitude < ConfigurableRagdollPlugin.ForgivingSpeedConfig.Value)
		{
			MethodInfo methodInfo = AccessTools.Method(typeof(RagdollController), "StartStandUp", (Type[])null, (Type[])null);
			if (methodInfo != null)
			{
				methodInfo.Invoke(__instance, new object[2]
				{
					__instance.RootRigidbody.position,
					false
				});
			}
		}
	}
}