Decompiled source of Aicho Enhanced Movement v1.0.0

plugins/AichoEnhancedMovement.dll

Decompiled 13 hours ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AichoEnhancedMovement")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AichoEnhancedMovement")]
[assembly: AssemblyTitle("AichoEnhancedMovement")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AichoEnhancedMovement
{
	[BepInPlugin("aicho.sprintequip", "Aicho Enhanced Movement", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Aicho Enhanced Movement 1.0.0 cargado");
			new Harmony("aicho.sprintequip").PatchAll();
		}
	}
	[HarmonyPatch(typeof(Player), "ClearActionQueue")]
	public static class ClearActionQueuePatch
	{
		private static bool Prefix(Player __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			IEnumerable value = Traverse.Create((object)__instance).Field("m_actionQueue").GetValue<IEnumerable>();
			if (value == null)
			{
				return true;
			}
			foreach (object item in value)
			{
				if (item != null)
				{
					string value2 = Traverse.Create(item).Field("m_animation").GetValue<string>();
					if (value2 == "equipping")
					{
						return false;
					}
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Player), "SetControls")]
	public static class SetControlsPatch
	{
		private static void Prefix(Player __instance, Vector3 movedir, out bool __state)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			__state = false;
			if (!((Object)(object)__instance == (Object)null))
			{
				bool value = Traverse.Create((object)__instance).Field("m_autoRun").GetValue<bool>();
				__state = value && movedir.z >= -0.1f;
			}
		}

		private static void Postfix(Player __instance, Vector3 movedir, bool crouch, bool __state)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_009c: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)__instance == (Object)null) && __state)
			{
				Traverse.Create((object)__instance).Field("m_autoRun").SetValue((object)true);
				if (crouch)
				{
					Traverse.Create((object)__instance).Method("SetCrouch", new object[1] { !((Character)__instance).IsCrouching() }).GetValue();
				}
				Vector3 value = Traverse.Create((object)__instance).Field("m_lookDir").GetValue<Vector3>();
				value.y = 0f;
				((Vector3)(ref value)).Normalize();
				Vector3 val = Vector3.Cross(Vector3.up, value);
				Vector3 val2 = value + movedir.x * val;
				val2.y = 0f;
				if (((Vector3)(ref val2)).magnitude > 0.1f)
				{
					((Vector3)(ref val2)).Normalize();
					Traverse.Create((object)__instance).Field("m_moveDir").SetValue((object)val2);
				}
			}
		}
	}
}