Decompiled source of NoSlowMo v1.2.0

wow.stolenrealm.NoSlowMo.dll

Decompiled 41 minutes ago
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace Wow.StolenRealm.NoSlowMo;

[BepInPlugin("wow.stolenrealm.NoSlowMo", "No Slow-Mo", "1.2.0")]
public class Plugin : BaseUnityPlugin
{
	internal static ConfigEntry<bool> DisableRagdollSlowMo;

	internal static ConfigEntry<bool> BlockGlobalSlowdown;

	internal static ConfigEntry<float> LaunchStrength;

	private void Awake()
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		DisableRagdollSlowMo = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableRagdollSlowMo", true, "Stops enemy bodies from going into slow motion when they die.");
		BlockGlobalSlowdown = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "BlockGlobalSlowdown", true, "If anything sets the game speed between 0 and 1 (slow motion), reset it to normal. Pausing (0) is left alone.");
		LaunchStrength = ((BaseUnityPlugin)this).Config.Bind<float>("General", "LaunchStrength", 0.7f, "How hard dead enemies get knocked back (1 = full game force, which sends them flying; 0 = just collapse).");
		new Harmony("wow.stolenrealm.NoSlowMo").PatchAll(typeof(Plugin).Assembly);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"No Slow-Mo loaded");
	}

	private void LateUpdate()
	{
		if (BlockGlobalSlowdown.Value)
		{
			float timeScale = Time.timeScale;
			if (timeScale > 0f && timeScale < 0.999f)
			{
				Time.timeScale = 1f;
			}
		}
	}
}
[HarmonyPatch(typeof(RagdollTimeScaler), "StartSlowing")]
internal static class RagdollPatch
{
	private static void Postfix(RagdollTimeScaler __instance)
	{
		if (Plugin.DisableRagdollSlowMo.Value)
		{
			Traverse val = Traverse.Create((object)__instance);
			__instance.timeScale = 1f;
			val.Field("slowing").SetValue((object)false);
			Rigidbody value = val.Field("rigidbody").GetValue<Rigidbody>();
			if (!((Object)(object)value == (Object)null))
			{
				value.useGravity = true;
				value.isKinematic = false;
			}
		}
	}
}
[HarmonyPatch(typeof(Ragdoll), "ExecuteSlowMoRagdoll")]
internal static class RagdollLaunchPatch
{
	private static void Prefix(Ragdoll __instance, ref float waitSec, ref float multiplier)
	{
		if (!Plugin.DisableRagdollSlowMo.Value)
		{
			return;
		}
		waitSec = 0f;
		multiplier *= Plugin.LaunchStrength.Value;
		Rigidbody[] value = Traverse.Create((object)__instance).Field("rbs").GetValue<Rigidbody[]>();
		if (value == null)
		{
			return;
		}
		Rigidbody[] array = value;
		foreach (Rigidbody val in array)
		{
			if ((Object)(object)val != (Object)null)
			{
				val.useGravity = true;
			}
		}
	}
}