Decompiled source of CrazyRagdolls v1.0.0

CrazyRagdolls.dll

Decompiled a week 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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("CrazyRagdolls")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CrazyRagdolls")]
[assembly: AssemblyTitle("CrazyRagdolls")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace CrazyRagdolls;

[BepInPlugin("com.crazyragdolls.roadsideresearch", "CrazyRagdolls", "1.0.0")]
public class Plugin : BasePlugin
{
	public const string GUID = "com.crazyragdolls.roadsideresearch";

	public const string Name = "CrazyRagdolls";

	public const string Version = "1.0.0";

	internal static ManualLogSource Log;

	internal static ConfigEntry<bool> Enabled;

	internal static ConfigEntry<float> LaunchMultiplier;

	internal static ConfigEntry<float> SlipMultiplier;

	public override void Load()
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Expected O, but got Unknown
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Expected O, but got Unknown
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BasePlugin)this).Log;
		Enabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master toggle for both car-hit and goop-slip ragdoll amplification. Set to false to restore vanilla reactions without uninstalling.");
		LaunchMultiplier = ((BasePlugin)this).Config.Bind<float>("CarHits", "LaunchMultiplier", 2.5f, new ConfigDescription("Multiplier applied to the launch impulse when an NPC is hit by a car (1.0 = vanilla, 2.5 = default crazy, 5.0+ = absurd).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
		SlipMultiplier = ((BasePlugin)this).Config.Bind<float>("GoopSlips", "SlipMultiplier", 2.5f, new ConfigDescription("Multiplier applied to the ragdoll force when an NPC slips on goop (1.0 = vanilla).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
		ManualLogSource log = Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(42, 5, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CrazyRagdolls");
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded. Enabled=");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(Enabled.Value);
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", CarHits=");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(LaunchMultiplier.Value);
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x, GoopSlips=");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(SlipMultiplier.Value);
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x");
		}
		log.LogInfo(val);
		Harmony val2 = new Harmony("com.crazyragdolls.roadsideresearch");
		val2.PatchAll(typeof(CarHitPatch));
		val2.PatchAll(typeof(GoopSlipPatch));
	}
}
[HarmonyPatch(typeof(RagdollOnCarCollision), "CalculateRagdollImpulse")]
public static class CarHitPatch
{
	[HarmonyPostfix]
	public static void ScaleCarImpulse(ref Vector3 __result)
	{
		//IL_000f: 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)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		if (Plugin.Enabled.Value)
		{
			__result *= Plugin.LaunchMultiplier.Value;
		}
	}
}
[HarmonyPatch(typeof(RagdollOnGoop), "OnTriggerEnter")]
public static class GoopSlipPatch
{
	[HarmonyPrefix]
	public static void Pre(RagdollOnGoop __instance, out float __state)
	{
		Traverse val = Traverse.Create((object)__instance).Field("_impulseForce");
		__state = val.GetValue<float>();
		if (Plugin.Enabled.Value)
		{
			val.SetValue((object)(__state * Plugin.SlipMultiplier.Value));
		}
	}

	[HarmonyPostfix]
	public static void Post(RagdollOnGoop __instance, float __state)
	{
		Traverse.Create((object)__instance).Field("_impulseForce").SetValue((object)__state);
	}
}