Decompiled source of NoSlopeSlide v0.1.0

plugins\NoSlopeSlide.dll

Decompiled a month ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NoSlopeSlide")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoSlopeSlide")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
namespace NoSlopeSlide;

[BepInPlugin("orax.NoSlopeSlide", "NoSlopeSlide", "0.1.0")]
public class NoSlopeSlide : BaseUnityPlugin
{
	public const string PluginGUID = "orax.NoSlopeSlide";

	public const string PluginName = "NoSlopeSlide";

	public const string PluginVersion = "0.1.0";

	public static ConfigEntry<bool> Enabled;

	private Harmony _harmony;

	private void Awake()
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable this mod.");
		_harmony = new Harmony("orax.NoSlopeSlide");
		_harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"NoSlopeSlide v0.1.0 loaded.");
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}
}
internal class Patch
{
	[HarmonyPatch(typeof(Character), "ApplySlide")]
	private class Character_ApplySlide_Patch
	{
		private static bool Prefix(Character __instance)
		{
			if (!NoSlopeSlide.Enabled.Value)
			{
				return true;
			}
			if (!((Object)(object)__instance == (Object)null))
			{
				return !__instance.IsPlayer();
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Character), "UpdateMotion")]
	private class Character_UpdateMotion_Patch
	{
		private static void Prefix(Character __instance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if (NoSlopeSlide.Enabled.Value && !((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && !(__instance.GetMoveDir() != Vector3.zero) && __instance.IsOnGround() && !__instance.IsSwimming() && !__instance.IsAttached() && !__instance.IsRiding() && !__instance.IsDead() && !((Object)(object)__instance.GetStandingOnShip() != (Object)null))
			{
				Rigidbody component = ((Component)__instance).GetComponent<Rigidbody>();
				Vector3 lastGroundNormal = __instance.m_lastGroundNormal;
				if (!((Object)(object)component == (Object)null) && !(((Vector3)(ref lastGroundNormal)).sqrMagnitude < 0.5f))
				{
					((Vector3)(ref lastGroundNormal)).Normalize();
					Vector3 val = Vector3.ProjectOnPlane(Physics.gravity, lastGroundNormal);
					component.AddForce(-val, (ForceMode)5);
				}
			}
		}
	}
}