Decompiled source of SpeedyMod v0.0.1

SpeedyMod.dll

Decompiled a month 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.Logging;
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("SpeedyMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("SpeedyMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 SpeedyMod
{
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class DodgePatch
	{
		private static readonly FieldInfo slidingField = AccessTools.Field(typeof(NewMovement), "sliding");

		private static readonly FieldInfo hurtInvincibilityField = AccessTools.Field(typeof(NewMovement), "hurtInvincibility");

		private static readonly FieldInfo levelOverField = AccessTools.Field(typeof(NewMovement), "levelOver");

		private static readonly FieldInfo boostLeftField = AccessTools.Field(typeof(NewMovement), "boostLeft");

		private static readonly FieldInfo explodedField = AccessTools.Field(typeof(NewMovement), "exploded");

		private static readonly FieldInfo preSlideSpeedField = AccessTools.Field(typeof(NewMovement), "preSlideSpeed");

		private static readonly FieldInfo frictionField = AccessTools.Field(typeof(NewMovement), "friction");

		private static readonly FieldInfo preSlideDelayField = AccessTools.Field(typeof(NewMovement), "preSlideDelay");

		private static readonly FieldInfo modNoDashSlideField = AccessTools.Field(typeof(NewMovement), "modNoDashSlide");

		private static readonly FieldInfo groundPropertiesField = AccessTools.Field(typeof(NewMovement), "groundProperties");

		private static readonly FieldInfo dodgeDirectionField = AccessTools.Field(typeof(NewMovement), "dodgeDirection");

		private static readonly FieldInfo walkSpeedField = AccessTools.Field(typeof(NewMovement), "walkSpeed");

		private static readonly FieldInfo rbField = AccessTools.Field(typeof(NewMovement), "rb");

		private static readonly FieldInfo gcField = AccessTools.Field(typeof(NewMovement), "gc");

		private static readonly FieldInfo pushForceField = AccessTools.Field(typeof(NewMovement), "pushForce");

		private static readonly FieldInfo dashStorageField = AccessTools.Field(typeof(NewMovement), "dashStorage");

		private static readonly FieldInfo movementDirectionField = AccessTools.Field(typeof(NewMovement), "movementDirection");

		private static readonly FieldInfo slideEndingField = AccessTools.Field(typeof(NewMovement), "slideEnding");

		private static readonly FieldInfo movementDirection2Field = AccessTools.Field(typeof(NewMovement), "movementDirection2");

		private static readonly FieldInfo boostField = AccessTools.Field(typeof(NewMovement), "boost");

		private static readonly MethodInfo stopSlideMethod = AccessTools.Method(typeof(NewMovement), "StopSlide", (Type[])null, (Type[])null);

		private static readonly MethodInfo createSlideScrapeMethod = AccessTools.Method(typeof(NewMovement), "CreateSlideScrape", (Type[])null, (Type[])null);

		private static MethodInfo TargetMethod()
		{
			return AccessTools.Method(typeof(NewMovement), "Dodge", (Type[])null, (Type[])null);
		}

		private static bool Prefix(NewMovement __instance)
		{
			//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0603: Unknown result type (might be due to invalid IL or missing references)
			//IL_0629: Unknown result type (might be due to invalid IL or missing references)
			//IL_0630: Expected O, but got Unknown
			//IL_0591: Unknown result type (might be due to invalid IL or missing references)
			//IL_0596: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d2: Expected O, but got Unknown
			//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_0738: Unknown result type (might be due to invalid IL or missing references)
			//IL_073f: Expected O, but got Unknown
			//IL_0741: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0515: Unknown result type (might be due to invalid IL or missing references)
			//IL_051c: Expected O, but got Unknown
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0530: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_0534: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Expected O, but got Unknown
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			if ((bool)slidingField.GetValue(__instance))
			{
				float num = (float)hurtInvincibilityField.GetValue(__instance);
				bool flag = (bool)levelOverField.GetValue(__instance);
				float num2 = (float)boostLeftField.GetValue(__instance);
				if (num <= 0f && !flag && num2 <= 0f)
				{
					((Component)__instance).gameObject.layer = 2;
					explodedField.SetValue(__instance, false);
				}
				float num3 = 1f;
				float num4 = (float)preSlideSpeedField.GetValue(__instance);
				float num5 = (float)frictionField.GetValue(__instance);
				GroundCheck val = (GroundCheck)gcField.GetValue(__instance);
				if (num4 > 1f)
				{
					if (num4 > 3f)
					{
						preSlideSpeedField.SetValue(__instance, 3f);
						num4 = 3f;
					}
					num3 = num4;
					if ((Object)(object)val != (Object)null && val.onGround && num5 != 0f)
					{
						preSlideSpeedField.SetValue(__instance, num4 - Time.fixedDeltaTime * num4 * num5);
					}
					preSlideDelayField.SetValue(__instance, 0f);
				}
				if ((bool)modNoDashSlideField.GetValue(__instance))
				{
					stopSlideMethod.Invoke(__instance, null);
					return false;
				}
				object value = groundPropertiesField.GetValue(__instance);
				if (value != null)
				{
					PropertyInfo propertyInfo = AccessTools.Property(value.GetType(), "canSlide");
					PropertyInfo propertyInfo2 = AccessTools.Property(value.GetType(), "speedMultiplier");
					if (propertyInfo != null && !(bool)propertyInfo.GetValue(value, null))
					{
						stopSlideMethod.Invoke(__instance, null);
						return false;
					}
					if (propertyInfo2 != null)
					{
						num3 *= (float)propertyInfo2.GetValue(value, null);
					}
				}
				Vector3 val2 = (Vector3)dodgeDirectionField.GetValue(__instance);
				float num6 = (float)walkSpeedField.GetValue(__instance);
				Vector3 val3 = default(Vector3);
				((Vector3)(ref val3))..ctor(val2.x * num6 * Time.deltaTime * 40f * num3, ((Rigidbody)rbField.GetValue(__instance)).velocity.y, val2.z * num6 * Time.deltaTime * 40f * num3);
				if (value != null)
				{
					PropertyInfo propertyInfo3 = AccessTools.Property(value.GetType(), "push");
					if (propertyInfo3 != null && (bool)propertyInfo3.GetValue(value, null))
					{
						PropertyInfo propertyInfo4 = AccessTools.Property(value.GetType(), "pushForce");
						PropertyInfo propertyInfo5 = AccessTools.Property(value.GetType(), "pushDirectionRelative");
						if (propertyInfo4 != null)
						{
							Vector3 val4 = (Vector3)propertyInfo4.GetValue(value, null);
							if (propertyInfo5 != null && (bool)propertyInfo5.GetValue(value, null))
							{
								PropertyInfo propertyInfo6 = AccessTools.Property(value.GetType(), "transform");
								if (propertyInfo6 != null)
								{
									Transform val5 = (Transform)propertyInfo6.GetValue(value, null);
									if ((Object)(object)val5 != (Object)null)
									{
										val4 = val5.rotation * val4;
									}
								}
							}
							val3 += val4;
						}
					}
				}
				if ((Object)(object)val != (Object)null && val.onGround)
				{
					createSlideScrapeMethod.Invoke(__instance, new object[2] { false, false });
				}
				if (num2 > 0f)
				{
					float num7 = (float)dashStorageField.GetValue(__instance);
					dashStorageField.SetValue(__instance, Mathf.MoveTowards(num7, 0f, Time.fixedDeltaTime));
					if ((float)dashStorageField.GetValue(__instance) <= 0f)
					{
						boostLeftField.SetValue(__instance, 0f);
					}
				}
				Vector2 val6 = MonoSingleton<InputManager>.Instance.InputSource.Move.ReadValue<Vector2>();
				Vector3 val7 = Vector3.ClampMagnitude(val6.x * ((Component)__instance).transform.right, 1f) * 5f;
				movementDirectionField.SetValue(__instance, val7);
				HookArm instance = MonoSingleton<HookArm>.Instance;
				if ((Object)(object)instance == (Object)null || !instance.beingPulled)
				{
					Rigidbody val8 = (Rigidbody)rbField.GetValue(__instance);
					Vector3 val9 = (Vector3)pushForceField.GetValue(__instance);
					val8.velocity = val3 + val9 + val7;
					return false;
				}
				stopSlideMethod.Invoke(__instance, null);
				return false;
			}
			bool flag2 = (bool)slideEndingField.GetValue(__instance);
			float num8 = 0f;
			if (flag2)
			{
				num8 = ((Rigidbody)rbField.GetValue(__instance)).velocity.y;
			}
			float num9 = 27.5f;
			Vector3 val10 = (Vector3)dodgeDirectionField.GetValue(__instance);
			float num10 = (float)walkSpeedField.GetValue(__instance);
			Vector3 val11 = default(Vector3);
			((Vector3)(ref val11))..ctor(val10.x * num10 * Time.deltaTime * num9, num8, val10.z * num10 * Time.deltaTime * num9);
			movementDirection2Field.SetValue(__instance, val11);
			((Component)__instance).gameObject.layer = 15;
			GroundCheck val12 = (GroundCheck)gcField.GetValue(__instance);
			float num11 = (float)frictionField.GetValue(__instance);
			if (flag2)
			{
				slideEndingField.SetValue(__instance, false);
				if ((Object)(object)val12 == (Object)null || !val12.onGround || num11 == 0f)
				{
					boostField.SetValue(__instance, false);
					return false;
				}
			}
			float num12 = (float)boostLeftField.GetValue(__instance);
			if (num12 > 0f)
			{
				Rigidbody val13 = (Rigidbody)rbField.GetValue(__instance);
				val13.velocity = val11 * 30f;
				boostLeftField.SetValue(__instance, num12 - 40f);
				return false;
			}
			if ((Object)(object)val12 == (Object)null || !val12.onGround || num11 != 0f)
			{
				Rigidbody val14 = (Rigidbody)rbField.GetValue(__instance);
				val14.velocity = val11;
			}
			boostField.SetValue(__instance, false);
			return false;
		}
	}
	[BepInPlugin("gay.loudsynth.speedymod", "SpeedyMod", "0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"The gay.loudsynth.speedymod, loaded, has been.");
			Harmony val = new Harmony("gay.loudsynth.speedymod");
			val.PatchAll();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SpeedyMod";

		public const string PLUGIN_NAME = "My first plugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}