Decompiled source of MovementPlus v1.0.5

plugins/Movement+/Movement.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UltraTweaker;
using UltraTweaker.SettingUI;
using UltraTweaker.SettingUI.UIElements;
using UltraTweaker.SettingUI.UIElements.Impl;
using UltraTweaker.Subsettings;
using UltraTweaker.Subsettings.Impl;
using UltraTweaker.Tweaks;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.SceneManagement;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("Movement")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("funny silly machine go fast! :3")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ef328d0880f8857eb6f79820d3f4e1be2ce0fb37")]
[assembly: AssemblyProduct("Movement")]
[assembly: AssemblyTitle("Movement")]
[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 Movement
{
	[BepInPlugin("waffle.ultrakill.movement", "MovementPlus", "1.0.5")]
	public class Movement : BaseUnityPlugin
	{
		public const string GUID = "waffle.ultrakill.movement";

		public const string Name = "MovementPlus";

		public const string Version = "1.0.5";

		public static readonly string AssetsPath = Path.Combine(ModPath(), "Assets");

		public static readonly string BundlePath = Path.Combine(AssetsPath, "movementplus.bundle");

		public static AssetBundle Bundle;

		public void Start()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Bundle = AssetBundle.LoadFromFile(BundlePath);
			SettingUIHandler.Pages.Add("waffle.ultrakill.movement.movement_mod", new Page("GENERAL", "MOVEMENT+"));
			UltraTweaker.AddAssembly(Assembly.GetExecutingAssembly());
		}

		public static string ModPath(Assembly asm = null)
		{
			if (asm == null)
			{
				asm = Assembly.GetExecutingAssembly();
			}
			return asm.Location.Substring(0, asm.Location.LastIndexOf(Path.DirectorySeparatorChar));
		}
	}
}
namespace Movement.Tweaks
{
	[TweakMetadata("Double Jump", "waffle.ultrakill.movement.double_jump", "Jump, but double.", "waffle.ultrakill.movement.movement_mod", 2, null, false, false)]
	public class DoubleJump : Tweak
	{
		public class JumpPatches
		{
			[HarmonyPatch(typeof(NewMovement), "Update")]
			[HarmonyPrefix]
			public static void DoubleJump(NewMovement __instance)
			{
				if (__instance.gc.onGround)
				{
					JumpsLeft = Jumps;
				}
				if (MonoSingleton<InputManager>.Instance.InputSource.Jump.WasPerformedThisFrame && !__instance.gc.onGround && !__instance.wc.onWall && JumpsLeft > 0f)
				{
					__instance.Jump();
					JumpsLeft -= 1f;
				}
			}
		}

		private Harmony harmony = new Harmony("waffle.ultrakill.movement.double_jump");

		public static float Jumps;

		public static float JumpsLeft;

		public DoubleJump()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_004b: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			base.Subsettings = new Dictionary<string, Subsetting> { 
			{
				"jumps",
				(Subsetting)new IntSubsetting((Tweak)(object)this, new Metadata("Jumps", "jumps", "How many jumps you get."), (SubsettingUIElement)new SliderIntSubsettingElement("{0}"), 2, 5, 1)
			} };
		}

		public override void OnTweakEnabled()
		{
			((Tweak)this).OnTweakEnabled();
			SetValues();
			harmony.PatchAll(typeof(JumpPatches));
		}

		public override void OnTweakDisabled()
		{
			((Tweak)this).OnTweakDisabled();
			harmony.UnpatchSelf();
		}

		public override void OnSubsettingUpdate()
		{
			SetValues();
		}

		public void SetValues()
		{
			Jumps = base.Subsettings["jumps"].GetValue<int>();
		}
	}
	[TweakMetadata("Momentum Dash", "waffle.ultrakill.movement.momentum_dash", "Dashes don't decrease speed at the end.", "waffle.ultrakill.movement.movement_mod", 3, null, false, false)]
	public class MomentumDash : Tweak
	{
		public class DashPatches
		{
			[HarmonyPatch(typeof(NewMovement), "Update")]
			[HarmonyPrefix]
			public static bool CancelCancelling(NewMovement __instance)
			{
				if (__instance.boostLeft - 4f >= 0f && !__instance.gc.touchingGround)
				{
					__instance.boostLeft = 0f;
					__instance.boost = false;
					return false;
				}
				return true;
			}
		}

		private Harmony harmony = new Harmony("waffle.ultrakill.movement.momentum_dash");

		public override void OnTweakEnabled()
		{
			((Tweak)this).OnTweakEnabled();
			harmony.PatchAll(typeof(DashPatches));
		}

		public override void OnTweakDisabled()
		{
			((Tweak)this).OnTweakDisabled();
			harmony.UnpatchSelf();
		}
	}
	[TweakMetadata("Hook Swing", "waffle.ultrakill.movement.real_hook", "Swing with the whiplash.", "waffle.ultrakill.movement.movement_mod", 0, null, false, false)]
	public class RealHook : Tweak
	{
		public class RealHookPatches
		{
			private static ConfigurableJoint gj;

			[HarmonyPatch(typeof(HookArm), "Start")]
			[HarmonyPostfix]
			public static void ReplaceModel(HookArm __instance)
			{
				if (((Tweak)Tweak.GetInstance<RealHook>()).Subsettings["custom_model"].GetValue<bool>())
				{
					CreateArmModel();
				}
			}

			[HarmonyPatch(typeof(HookArm), "Update")]
			[HarmonyPostfix]
			public static void FixHandPos(HookArm __instance)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				((Component)__instance.hand).transform.localPosition = Vector3.zero;
			}

			[HarmonyPatch(typeof(HookArm), "Update")]
			[HarmonyPostfix]
			public static void MakeSwing(HookArm __instance)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Invalid comparison between Unknown and I4
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_012d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0132: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0105: Unknown result type (might be due to invalid IL or missing references)
				//IL_010f: Unknown result type (might be due to invalid IL or missing references)
				if (!__instance.lightTarget && (int)__instance.state == 3)
				{
					if ((Object)(object)__instance.caughtTransform != (Object)null)
					{
						__instance.hookPoint = __instance.caughtTransform.position + __instance.caughtPoint;
						if (!Object.op_Implicit((Object)(object)((Component)MonoSingleton<NewMovement>.Instance).GetComponent<ConfigurableJoint>()))
						{
							gj = ((Component)MonoSingleton<NewMovement>.Instance).gameObject.AddComponent<ConfigurableJoint>();
							gj.xMotion = (ConfigurableJointMotion)1;
							gj.yMotion = (ConfigurableJointMotion)1;
							gj.zMotion = (ConfigurableJointMotion)1;
							ConfigurableJoint obj = gj;
							SoftJointLimit linearLimit = default(SoftJointLimit);
							((SoftJointLimit)(ref linearLimit)).limit = Vector3.Distance(((Component)gj).transform.position, __instance.caughtTransform.position + __instance.caughtPoint);
							obj.linearLimit = linearLimit;
							((Joint)gj).autoConfigureConnectedAnchor = false;
							MonoSingleton<NewMovement>.Instance.rb.AddForce(Vector3.up * 15f * -1f, (ForceMode)2);
						}
						((Joint)gj).connectedAnchor = __instance.caughtTransform.position + __instance.caughtPoint;
					}
					if ((Object)(object)__instance.caughtEid != (Object)null && __instance.caughtEid.dead)
					{
						Object.Destroy((Object)(object)gj);
						__instance.StopThrow(0f, false);
					}
				}
				else
				{
					Object.Destroy((Object)(object)gj);
				}
			}

			[HarmonyPatch(typeof(HookArm), "Update")]
			[HarmonyPrefix]
			public static void CollideWithWalls(HookArm __instance)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Invalid comparison between Unknown and I4
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)invisHook != (Object)null && (int)__instance.state == 0)
				{
					RaycastHit val = default(RaycastHit);
					Physics.Raycast(((Component)MonoSingleton<CameraController>.Instance).transform.position, ((Component)MonoSingleton<CameraController>.Instance).transform.forward, ref val, 1000000f, LayerMask.op_Implicit(__instance.enviroMask), (QueryTriggerInteraction)1);
					invisHook.transform.position = ((RaycastHit)(ref val)).point - ((Component)MonoSingleton<CameraController>.Instance).transform.forward;
				}
			}

			[HarmonyPatch(typeof(HookArm), "FixedUpdate")]
			[HarmonyPrefix]
			public static bool StopPull(HookArm __instance, ref Vector3 __state)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Invalid comparison between Unknown and I4
				__state = MonoSingleton<NewMovement>.Instance.rb.velocity;
				if (!__instance.lightTarget && (int)__instance.state == 3)
				{
					return false;
				}
				return true;
			}

			[HarmonyPatch(typeof(HookArm), "FixedUpdate")]
			[HarmonyPostfix]
			public static void SetVelo(HookArm __instance, Vector3 __state)
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				if (!__instance.lightTarget)
				{
					MonoSingleton<NewMovement>.Instance.rb.velocity = __state;
				}
			}

			[HarmonyPatch(typeof(HookArm), "StopThrow")]
			[HarmonyPrefix]
			public static bool StopJumpDisablingTheHook(HookArm __instance, float animationTime)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Invalid comparison between Unknown and I4
				if ((int)__instance.state == 3 && !__instance.lightTarget && MonoSingleton<InputManager>.Instance.InputSource.Jump.WasPerformedThisFrame && animationTime == 1f)
				{
					return false;
				}
				return true;
			}

			[HarmonyPatch(typeof(HookArm), "Update")]
			[HarmonyPostfix]
			public static void Pull(HookArm __instance)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Invalid comparison between Unknown and I4
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				if ((int)__instance.state == 3 && !__instance.lightTarget && MonoSingleton<InputManager>.Instance.InputSource.Jump.IsPressed)
				{
					ConfigurableJoint obj = gj;
					SoftJointLimit linearLimit = default(SoftJointLimit);
					SoftJointLimit linearLimit2 = gj.linearLimit;
					((SoftJointLimit)(ref linearLimit)).limit = ((SoftJointLimit)(ref linearLimit2)).limit - Time.deltaTime * shortenSpeed;
					obj.linearLimit = linearLimit;
					Rigidbody rb = MonoSingleton<NewMovement>.Instance.rb;
					float pullSpeed = RealHook.pullSpeed;
					Vector3 val = ((Component)MonoSingleton<HookArm>.Instance.caughtTransform).transform.position + MonoSingleton<HookArm>.Instance.caughtPoint - ((Component)__instance).transform.position;
					rb.velocity = pullSpeed * ((Vector3)(ref val)).normalized;
				}
			}
		}

		private Harmony harmony = new Harmony("waffle.ultrakill.movement.real_hook");

		private static GameObject model;

		private static GameObject invisHook;

		private static float pullSpeed;

		private static float shortenSpeed;

		private static HookArmDataStorage hads;

		public RealHook()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0044: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0070: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00b0: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_00f0: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			base.Subsettings = new Dictionary<string, Subsetting>
			{
				{
					"custom_model",
					(Subsetting)new BoolSubsetting((Tweak)(object)this, new Metadata("Custom Model", "custom_model", "A custom model by Rem_Safe_Space."), (SubsettingUIElement)new BoolSubsettingElement(), true)
				},
				{
					"any_surf",
					(Subsetting)new BoolSubsetting((Tweak)(object)this, new Metadata("Any Surface", "any_surf", "If you should hook on every surface."), (SubsettingUIElement)new BoolSubsettingElement(), true)
				},
				{
					"space_pull",
					(Subsetting)new FloatSubsetting((Tweak)(object)this, new Metadata("Space To Pull", "space_pull", "Amount to pull yourself to the center with Space."), (SubsettingUIElement)new SliderFloatSubsettingElement("{0}", 1), 50f, 100f, 0f)
				},
				{
					"space_short",
					(Subsetting)new FloatSubsetting((Tweak)(object)this, new Metadata("Space To Shorten", "space_short", "Amount to shorten the hook with Space."), (SubsettingUIElement)new SliderFloatSubsettingElement("{0}", 1), 0f, 100f, 0f)
				}
			};
		}

		public override void OnTweakEnabled()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			((Tweak)this).OnTweakEnabled();
			harmony.PatchAll(typeof(RealHookPatches));
			SetValues();
			if ((Object)(object)model == (Object)null)
			{
				model = Movement.Bundle.LoadAsset<GameObject>("Swing Arm.prefab");
				model.GetComponentInChildren<Renderer>().material.shader = Addressables.LoadAssetAsync<Shader>((object)"Assets/Shaders/Main/ULTRAKILL-vertexlit.shader").WaitForCompletion();
			}
		}

		public override void OnTweakDisabled()
		{
			((Tweak)this).OnTweakDisabled();
			harmony.UnpatchSelf();
		}

		public override void OnSubsettingUpdate()
		{
			SetValues();
		}

		public override void OnSceneLoad(Scene scene, LoadSceneMode mode)
		{
			SetValues();
		}

		public void SetValues()
		{
			Object.Destroy((Object)(object)invisHook);
			pullSpeed = base.Subsettings["space_pull"].GetValue<float>();
			shortenSpeed = base.Subsettings["space_short"].GetValue<float>();
			TryMakeHookPoint();
			if (((Tweak)Tweak.GetInstance<RealHook>()).Subsettings["custom_model"].GetValue<bool>() && (Object)(object)hads == (Object)null)
			{
				CreateArmModel();
			}
			else
			{
				hads?.Begone();
			}
		}

		public void TryMakeHookPoint()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_00b2: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			if (Tweak.IsGameplayScene() && base.Subsettings["any_surf"].GetValue<bool>())
			{
				invisHook = Object.Instantiate<GameObject>(Addressables.LoadAssetAsync<GameObject>((object)"Assets/Prefabs/Levels/Interactive/GrapplePoint.prefab").WaitForCompletion());
				((Component)invisHook.transform.GetChild(0)).gameObject.SetActive(false);
				((Component)invisHook.transform.GetChild(1)).gameObject.SetActive(false);
				((Behaviour)invisHook.GetComponent<Light>()).enabled = false;
				((Behaviour)invisHook.GetComponent<AudioSource>()).enabled = false;
				invisHook.GetComponent<HookPoint>().grabParticle = new GameObject();
				invisHook.GetComponent<HookPoint>().grabParticle.AddComponent<DestroyOnCheckpointRestart>();
				invisHook.transform.localScale = Vector3.one * 2f;
			}
		}

		public static void CreateArmModel()
		{
			HookArm instance = MonoSingleton<HookArm>.Instance;
			if ((Object)(object)instance != (Object)null && Tweak.IsGameplayScene())
			{
				hads = Object.Instantiate<GameObject>(model, ((Component)instance).transform).GetComponent<HookArmDataStorage>();
				hads.Apply();
			}
		}
	}
	public class HookArmDataStorage : MonoBehaviour
	{
		public Animator anim;

		public Transform hand;

		public Transform hook;

		public GameObject hookModel;

		public LineRenderer inspectLr;

		private GameObject oldModel;

		private Animator oldAnim;

		private Transform oldHand;

		private Transform oldHook;

		private GameObject oldHookModel;

		private LineRenderer oldInspectLr;

		private Color oldColour;

		public void Apply()
		{
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			HookArm instance = MonoSingleton<HookArm>.Instance;
			oldModel = instance.model;
			oldAnim = instance.anim;
			oldHand = instance.hand;
			oldHook = instance.hook;
			oldHookModel = instance.hookModel;
			oldInspectLr = instance.inspectLr;
			instance.model = ((Component)this).gameObject;
			instance.anim = anim;
			instance.hand = hand;
			instance.hook = hook;
			instance.hookModel = hookModel;
			instance.inspectLr = inspectLr;
			instance.model.SetActive(oldModel.activeSelf);
			oldModel.SetActive(false);
			oldColour = instance.lr.startColor;
			instance.lr.startColor = Color.white;
			instance.lr.endColor = Color.white;
		}

		public void Begone()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			HookArm instance = MonoSingleton<HookArm>.Instance;
			instance.model = oldModel;
			instance.anim = oldAnim;
			instance.hand = oldHand;
			instance.hook = oldHook;
			instance.hookModel = oldHookModel;
			instance.inspectLr = oldInspectLr;
			instance.lr.startColor = oldColour;
			instance.lr.endColor = oldColour;
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
	[TweakMetadata("Recoil", "waffle.ultrakill.movement.recoil", "Every weapon gives recoil.", "waffle.ultrakill.movement.movement_mod", 1, null, false, false)]
	public class Recoil : Tweak
	{
		public class RecoilPatches
		{
			[HarmonyPatch(typeof(Revolver), "Shoot")]
			[HarmonyPrefix]
			private static void AddRevolverRecoil(Revolver __instance, int shotType)
			{
				if (shotType == 2)
				{
					float num = __instance.pierceShotCharge / 100f;
					AddRecoil(20f * RevolverRecoil * num);
				}
				else
				{
					AddRecoil(10f * RevolverRecoil);
				}
			}

			[HarmonyPatch(typeof(Shotgun), "Shoot")]
			[HarmonyPrefix]
			private static void AddShotgunRecoil(Shotgun __instance)
			{
				float num = 1 + ((__instance.variation == 1) ? ((__instance.primaryCharge + 1) / 3) : 0);
				AddRecoil(15f * num * ShotgunRecoil);
			}

			[HarmonyPatch(typeof(Shotgun), "ShootSinks")]
			[HarmonyPrefix]
			private static void AddShotgunCoreRecoil(Shotgun __instance)
			{
				AddRecoil(10f * (__instance.grenadeForce / 30f * 2f) * ShotgunRecoil);
			}

			[HarmonyPatch(typeof(Nailgun), "Shoot")]
			[HarmonyPrefix]
			private static void AddNailRecoil()
			{
				AddRecoil(0.75f * NailgunRecoil);
			}

			[HarmonyPatch(typeof(Nailgun), "ShootMagnet")]
			[HarmonyPrefix]
			private static void AddNailMagnetRecoil()
			{
				AddRecoil(10f * NailgunRecoil);
			}

			[HarmonyPatch(typeof(Railcannon), "Shoot")]
			[HarmonyPrefix]
			private static void AddRailRecoil()
			{
				AddRecoil(50f * RailcannonRecoil);
			}

			[HarmonyPatch(typeof(RocketLauncher), "Shoot")]
			[HarmonyPrefix]
			private static void AddRocketRecoil()
			{
				AddRecoil(15f * RocketRecoil);
			}

			[HarmonyPatch(typeof(RocketLauncher), "ShootCannonball")]
			[HarmonyPrefix]
			private static void AddRocketCannonballRecoil(RocketLauncher __instance)
			{
				AddRecoil(30f * __instance.cbCharge * RocketRecoil);
			}
		}

		private Harmony harmony = new Harmony("waffle.ultrakill.movement.recoil");

		public static float RevolverRecoil;

		public static float ShotgunRecoil;

		public static float NailgunRecoil;

		public static float RailcannonRecoil;

		public static float RocketRecoil;

		public static float FloorMult;

		public static float FlooredMultiplier => MonoSingleton<NewMovement>.Instance.gc.touchingGround ? FloorMult : 1f;

		public Recoil()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0058: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_0098: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00d8: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_0118: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Expected O, but got Unknown
			//IL_0158: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Expected O, but got Unknown
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			//IL_0198: Expected O, but got Unknown
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Expected O, but got Unknown
			base.Subsettings = new Dictionary<string, Subsetting>
			{
				{
					"rev_recoil",
					(Subsetting)new FloatSubsetting((Tweak)(object)this, new Metadata("Revolver", "rev_recoil", "Revolver recoil amount."), (SubsettingUIElement)new SliderFloatSubsettingElement("{0}x", 1), 1f, 2f, 0f)
				},
				{
					"sho_recoil",
					(Subsetting)new FloatSubsetting((Tweak)(object)this, new Metadata("Shotgun", "sho_recoil", "Shotgun recoil amount."), (SubsettingUIElement)new SliderFloatSubsettingElement("{0}x", 1), 1f, 2f, 0f)
				},
				{
					"nai_recoil",
					(Subsetting)new FloatSubsetting((Tweak)(object)this, new Metadata("Nail", "nai_recoil", "Nailgun recoil amount."), (SubsettingUIElement)new SliderFloatSubsettingElement("{0}x", 1), 1f, 2f, 0f)
				},
				{
					"rai_recoil",
					(Subsetting)new FloatSubsetting((Tweak)(object)this, new Metadata("Railcannon", "rai_recoil", "Railcannon recoil amount."), (SubsettingUIElement)new SliderFloatSubsettingElement("{0}x", 1), 1f, 2f, 0f)
				},
				{
					"rock_recoil",
					(Subsetting)new FloatSubsetting((Tweak)(object)this, new Metadata("Rocket", "rock_recoil", "Rocket Launcher recoil amount."), (SubsettingUIElement)new SliderFloatSubsettingElement("{0}x", 1), 1f, 2f, 0f)
				},
				{
					"floor_mult",
					(Subsetting)new FloatSubsetting((Tweak)(object)this, new Metadata("On Floor", "floor_mult", "On floor recoil multiplier."), (SubsettingUIElement)new SliderFloatSubsettingElement("{0}x", 1), 1f, 2f, 0f)
				}
			};
		}

		public static void AddRecoil(float strength)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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)
			MonoSingleton<NewMovement>.Instance.rb.AddForce(strength * -((Component)MonoSingleton<CameraController>.Instance).transform.forward * FlooredMultiplier, (ForceMode)2);
		}

		public override void OnTweakEnabled()
		{
			((Tweak)this).OnTweakEnabled();
			SetValues();
			harmony.PatchAll(typeof(RecoilPatches));
		}

		public override void OnTweakDisabled()
		{
			((Tweak)this).OnTweakDisabled();
			harmony.UnpatchSelf();
		}

		public override void OnSubsettingUpdate()
		{
			SetValues();
		}

		public void SetValues()
		{
			RevolverRecoil = base.Subsettings["rev_recoil"].GetValue<float>();
			ShotgunRecoil = base.Subsettings["sho_recoil"].GetValue<float>();
			NailgunRecoil = base.Subsettings["nai_recoil"].GetValue<float>();
			RailcannonRecoil = base.Subsettings["rai_recoil"].GetValue<float>();
			RocketRecoil = base.Subsettings["rock_recoil"].GetValue<float>();
			FloorMult = base.Subsettings["floor_mult"].GetValue<float>();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal static class IsExternalInit
	{
	}
}