Decompiled source of ScrapIsFuel v1.1.3

ScrapIsFuel.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CSync.Lib;
using CSync.Util;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using Microsoft.CodeAnalysis;
using ScrapIsFuel.Config;
using ScrapIsFuel.Input;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("com.sigurd.csync")]
[assembly: IgnoresAccessChecksTo("LethalCompanyInputUtils")]
[assembly: IgnoresAccessChecksTo("LethalConfig")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.PhysicsModule")]
[assembly: AssemblyCompany("ScrapIsFuel")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("MANKIND IS DEAD. SCRAP IS FUEL. MOONS ARE FULL.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ScrapIsFuel")]
[assembly: AssemblyTitle("ScrapIsFuel")]
[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 ScrapIsFuel
{
	[BepInPlugin("ScrapIsFuel", "ScrapIsFuel", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ScrapIsFuel : BaseUnityPlugin
	{
		internal static readonly ManualLogSource mls = Logger.CreateLogSource("ScrapIsFuel");

		internal static UltraInputs UltraInputsInstance;

		internal static UltraConfigs Config { get; private set; }

		private void Awake()
		{
			UltraInputsInstance = new UltraInputs();
			Config = new UltraConfigs(((BaseUnityPlugin)this).Config);
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "ScrapIsFuel");
			mls.LogInfo((object)"Plugin ScrapIsFuel is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ScrapIsFuel";

		public const string PLUGIN_NAME = "ScrapIsFuel";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ScrapIsFuel.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		private static bool sliding = false;

		private static bool slideJumped = false;

		private static float slideTimer = ScrapIsFuel.Config.MOMENTUM_PERIOD.Value;

		private static bool slamming = false;

		private static float slamHeight = 0f;

		private static float slamTimer = ScrapIsFuel.Config.SLAM_JUMP_PERIOD.Value;

		private static bool slamStorage = false;

		private static bool dashing = false;

		private static float dashTimer = 0f;

		private static Vector3 dashVector;

		private static int wallJumps = 0;

		private static float wallClingTimer = 0f;

		private static float floatTimer = 0f;

		private static float previousY;

		private static Vector3 momentumVector;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePostfix()
		{
			IngamePlayerSettings.Instance.playerInput.actions.FindAction("Crouch", false).Disable();
		}

		[HarmonyPatch("Jump_performed")]
		[HarmonyTranspiler]
		[HarmonyPriority(800)]
		private static IEnumerable<CodeInstruction> Jump_performedTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = instructions.ToList();
			for (int i = 0; i < list.Count; i++)
			{
				if (((object)list[i]).ToString().Contains("0.08"))
				{
					list.RemoveRange(i - 3, 9);
				}
			}
			return list.AsEnumerable();
		}

		private static float directionsToRotation(bool forward, bool left, bool down, bool right)
		{
			float num = 0f;
			if (left)
			{
				num -= 90f;
				if (forward)
				{
					num += 45f;
				}
				if (down)
				{
					num -= 45f;
				}
			}
			if (right)
			{
				num += 90f;
				if (forward)
				{
					num -= 45f;
				}
				if (down)
				{
					num += 45f;
				}
			}
			if (down && !left && !right)
			{
				num += 180f;
			}
			return num;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePostfix(PlayerControllerB __instance)
		{
			//IL_0063: 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)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: 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_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_065b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_0639: Unknown result type (might be due to invalid IL or missing references)
			//IL_0643: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0741: Unknown result type (might be due to invalid IL or missing references)
			//IL_0746: Unknown result type (might be due to invalid IL or missing references)
			//IL_084f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0863: Unknown result type (might be due to invalid IL or missing references)
			//IL_0868: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d46: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0939: Unknown result type (might be due to invalid IL or missing references)
			//IL_093e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0942: Unknown result type (might be due to invalid IL or missing references)
			//IL_0957: Unknown result type (might be due to invalid IL or missing references)
			//IL_095c: Unknown result type (might be due to invalid IL or missing references)
			//IL_097d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0982: Unknown result type (might be due to invalid IL or missing references)
			//IL_0987: Unknown result type (might be due to invalid IL or missing references)
			//IL_098c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0991: Unknown result type (might be due to invalid IL or missing references)
			//IL_099c: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0807: Unknown result type (might be due to invalid IL or missing references)
			//IL_080c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a56: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a5b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a76: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a78: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a82: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a87: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a91: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a96: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c35: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c3a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0adb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b09: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b02: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b88: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd8: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled)
			{
				return;
			}
			if (!ScrapIsFuel.Config.FALL_DAMAGE_ENABLED.Value)
			{
				__instance.takingFallDamage = false;
			}
			momentumVector.y = 0f;
			if (!ScrapIsFuel.Config.MOMENTUM_ENABLED.Value)
			{
				momentumVector = Vector3.zero;
			}
			dashTimer += Time.deltaTime;
			if (dashing)
			{
				if (__instance.thisController.isGrounded && __instance.playerActions.FindAction("Jump", false).WasPressedThisFrame())
				{
					dashTimer = ScrapIsFuel.Config.DASH_DURATION.Value;
					dashing = false;
					IngamePlayerSettings.Instance.playerInput.actions.FindAction("Move", false).Enable();
				}
				else if (dashTimer < ScrapIsFuel.Config.DASH_DURATION.Value && (!__instance.thisController.isGrounded || !__instance.playerActions.FindAction("Move", false).IsPressed()))
				{
					__instance.thisController.Move(dashVector * Time.deltaTime);
				}
				else
				{
					if (!__instance.thisController.isGrounded || __instance.playerActions.FindAction("Move", false).IsPressed())
					{
						momentumVector = Vector3.zero;
					}
					dashing = false;
					IngamePlayerSettings.Instance.playerInput.actions.FindAction("Move", false).Enable();
				}
			}
			if (!__instance.isClimbingLadder && !__instance.inTerminalMenu && !__instance.thisController.isGrounded && (momentumVector.x != 0f || momentumVector.z != 0f))
			{
				__instance.thisController.Move(momentumVector * Time.deltaTime);
			}
			bool flag = Physics.Raycast(new Ray(((Component)__instance).transform.position + Vector3.up * 2.3f, -((Component)__instance).transform.right), ref __instance.hit, 0.53f, __instance.walkableSurfacesNoPlayersMask, (QueryTriggerInteraction)1);
			bool flag2 = Physics.Raycast(new Ray(((Component)__instance).transform.position + Vector3.up * 2.3f, ((Component)__instance).transform.right), ref __instance.hit, 0.53f, __instance.walkableSurfacesNoPlayersMask, (QueryTriggerInteraction)1);
			bool flag3 = Physics.Raycast(new Ray(((Component)__instance).transform.position + Vector3.up * 2.3f, -((Component)__instance).transform.forward), ref __instance.hit, 0.53f, __instance.walkableSurfacesNoPlayersMask, (QueryTriggerInteraction)1);
			bool flag4 = Physics.Raycast(new Ray(((Component)__instance).transform.position + Vector3.up * 2.3f, ((Component)__instance).transform.forward), ref __instance.hit, 0.53f, __instance.walkableSurfacesNoPlayersMask, (QueryTriggerInteraction)1);
			Vector2 val = __instance.playerActions.FindAction("Move", false).ReadValue<Vector2>();
			bool flag5 = val.y > 0f;
			bool flag6 = val.x < 0f;
			bool flag7 = val.y < 0f;
			bool flag8 = val.x > 0f;
			if (flag4 || flag || flag3 || flag2)
			{
				if (ScrapIsFuel.Config.WALL_CLINGING_ENABLED.Value && ((flag4 && flag5) || (flag && flag6) || (flag3 && flag7) || (flag2 && flag8)))
				{
					momentumVector = Vector3.Lerp(momentumVector, Vector3.zero, Time.deltaTime * 5f);
					if (((Component)__instance).transform.position.y < previousY)
					{
						wallClingTimer += Time.deltaTime;
						__instance.fallValue /= Mathf.Lerp(ScrapIsFuel.Config.WALL_CLINGING_SLOWDOWN.Value, 1f, wallClingTimer);
					}
				}
				if (ScrapIsFuel.Config.WALL_JUMPING_ENABLED.Value && __instance.playerActions.FindAction("Jump", false).WasPressedThisFrame() && !__instance.thisController.isGrounded && wallJumps < ScrapIsFuel.Config.MAX_WALL_JUMPS.Value)
				{
					if (ScrapIsFuel.Config.SLAM_STORAGE_ENABLED.Value && ScrapIsFuel.UltraInputsInstance.SlamNSlide.WasPressedThisFrame())
					{
						slamStorage = true;
						slamTimer = 0f;
						slamHeight = ScrapIsFuel.Config.SLAM_STORAGE_HEIGHT.Value;
					}
					wallJumps++;
					((MonoBehaviour)__instance).StartCoroutine(WallJump(__instance, flag4, flag, flag3, flag2));
				}
			}
			else
			{
				wallClingTimer = 0f;
			}
			if (__instance.fallValue >= 0f)
			{
				floatTimer = 0f;
			}
			if (slamming)
			{
				if (__instance.thisController.isGrounded)
				{
					slamming = false;
					slamTimer = 0f;
					slamHeight = Mathf.Min(slamHeight - ((Component)__instance).transform.position.y, (float)(ScrapIsFuel.Config.SLAM_STORAGE_HEIGHT.Value - 50));
					__instance.takingFallDamage = false;
					IngamePlayerSettings.Instance.playerInput.actions.FindAction("Jump", false).Enable();
					IngamePlayerSettings.Instance.playerInput.actions.FindAction("Move", false).Enable();
				}
				else
				{
					__instance.takingFallDamage = false;
					__instance.thisController.Move(Vector3.down * (float)ScrapIsFuel.Config.SLAM_AMPLITUDE.Value * Time.deltaTime);
				}
			}
			else if (((Component)__instance).transform.position.y < previousY)
			{
				floatTimer += Time.deltaTime * 5f;
				__instance.fallValue = Mathf.Clamp(__instance.fallValue / Mathf.Lerp(1.01f, 1f, Math.Min(Mathf.Log(floatTimer, 2f) + 0.5f, 1f)), (float)ScrapIsFuel.Config.MAX_FALL_VALUE.Value, float.PositiveInfinity);
			}
			if (__instance.thisController.isGrounded)
			{
				slamTimer += Time.deltaTime;
				if (!sliding)
				{
					slideTimer += Time.deltaTime;
				}
				if (__instance.playerActions.FindAction("Move", false).IsPressed())
				{
					momentumVector = Vector3.zero;
				}
				wallJumps = 0;
				if (slamTimer >= ScrapIsFuel.Config.SLAM_JUMP_PERIOD.Value)
				{
					slamStorage = false;
				}
				if (dashTimer >= ScrapIsFuel.Config.MOMENTUM_PERIOD.Value && slideTimer >= ScrapIsFuel.Config.MOMENTUM_PERIOD.Value)
				{
					momentumVector = Vector3.Lerp(momentumVector, Vector3.zero, Time.deltaTime * 5f);
					if (Mathf.Abs(momentumVector.x) < 0.1f && Mathf.Abs(momentumVector.z) < 0.1f)
					{
						momentumVector = Vector3.zero;
					}
				}
			}
			if (!slideJumped && slideTimer < ScrapIsFuel.Config.MOMENTUM_PERIOD.Value && !__instance.thisController.isGrounded)
			{
				slideJumped = true;
				momentumVector *= ScrapIsFuel.Config.SLIDE_JUMP_MULTIPLIER.Value;
			}
			if (!__instance.isClimbingLadder && !__instance.inTerminalMenu)
			{
				if (ScrapIsFuel.Config.DASH_ENABLED.Value && !dashing && __instance.sprintMeter >= ScrapIsFuel.Config.DASH_STAMINA.Value && ScrapIsFuel.UltraInputsInstance.Dash.WasPressedThisFrame())
				{
					dashing = true;
					slamming = false;
					IngamePlayerSettings.Instance.playerInput.actions.FindAction("Move", false).Disable();
					__instance.sprintMeter = Mathf.Clamp(__instance.sprintMeter - ScrapIsFuel.Config.DASH_STAMINA.Value, 0f, 1f);
					Vector3 forward = ((Component)__instance.gameplayCamera).transform.forward;
					dashVector = ((Vector3)(ref forward)).normalized * (float)ScrapIsFuel.Config.DASH_AMPLITUDE.Value;
					dashVector.y = 0f;
					dashVector = Quaternion.AngleAxis(directionsToRotation(flag5, flag6, flag7, flag8), Vector3.up) * dashVector;
					__instance.thisController.Move(dashVector * Time.deltaTime);
					momentumVector.x = dashVector.x * ScrapIsFuel.Config.DASH_MOMENTUM.Value;
					momentumVector.z = dashVector.z * ScrapIsFuel.Config.DASH_MOMENTUM.Value;
					dashTimer = 0f;
				}
				else if (ScrapIsFuel.UltraInputsInstance.SlamNSlide.WasPressedThisFrame())
				{
					if (ScrapIsFuel.Config.SLIDE_ENABLED.Value && __instance.thisController.isGrounded)
					{
						Vector3 forward2 = ((Component)__instance.gameplayCamera).transform.forward;
						forward2.y = 0f;
						((Vector3)(ref forward2)).Normalize();
						momentumVector = Quaternion.AngleAxis(Vector3.SignedAngle(momentumVector, forward2, Vector3.up), Vector3.up) * momentumVector;
						if (slamTimer < ScrapIsFuel.Config.SLAM_JUMP_PERIOD.Value)
						{
							momentumVector = forward2;
							((MonoBehaviour)__instance).StartCoroutine(Slide(__instance, momentumVector * Mathf.Max(slamHeight - 20f, 2f) / 2f));
						}
						else
						{
							((MonoBehaviour)__instance).StartCoroutine(Slide(__instance, slideJumped ? momentumVector : Vector3.zero));
							slideJumped = false;
						}
					}
					else if (!slamming && !slamStorage)
					{
						IngamePlayerSettings.Instance.playerInput.actions.FindAction("Move", false).Disable();
						IngamePlayerSettings.Instance.playerInput.actions.FindAction("Jump", false).Disable();
						slamming = true;
						momentumVector = Vector3.zero;
						slamHeight = ((Component)__instance).transform.position.y;
						__instance.takingFallDamage = false;
						__instance.thisController.Move(Vector3.down * (float)ScrapIsFuel.Config.SLAM_AMPLITUDE.Value * Time.deltaTime);
					}
				}
				else if (__instance.thisController.isGrounded && __instance.playerActions.FindAction("Jump", false).WasPressedThisFrame())
				{
					if (slamTimer < ScrapIsFuel.Config.SLAM_JUMP_PERIOD.Value)
					{
						momentumVector = Vector3.zero;
						((MonoBehaviour)__instance).StartCoroutine(ExtendJump(__instance, Mathf.Lerp(0f, ScrapIsFuel.Config.SLAM_JUMP_MAX_DURATION.Value, Mathf.Min(slamHeight / (float)ScrapIsFuel.Config.SLAM_JUMP_DURATION_DIVISOR.Value + ScrapIsFuel.Config.SLAM_JUMP_DURATION_OFFSET.Value, 1f)), slamStorage ? ((float)ScrapIsFuel.Config.SLAM_STORAGE_FORCE.Value) : Mathf.Lerp((float)ScrapIsFuel.Config.SLAM_JUMP_FORCE_MIN.Value, (float)ScrapIsFuel.Config.SLAM_JUMP_FORCE_MAX.Value, Mathf.Min(new float[1] { slamHeight / (float)ScrapIsFuel.Config.SLAM_JUMP_FORCE_DIVISOR.Value + ScrapIsFuel.Config.SLAM_JUMP_FORCE_OFFSET.Value }))));
						slamStorage = false;
					}
					else
					{
						((MonoBehaviour)__instance).StartCoroutine(ExtendJump(__instance, ScrapIsFuel.Config.JUMP_DURATION.Value, ScrapIsFuel.Config.JUMP_FORCE.Value));
					}
				}
			}
			previousY = ((Component)__instance).transform.position.y;
		}

		private static IEnumerator ExtendJump(PlayerControllerB instance, float duration, float startForce)
		{
			slamTimer = ScrapIsFuel.Config.SLAM_JUMP_PERIOD.Value;
			float timeElapsed = 0f;
			while (!slamming && timeElapsed < duration && (!(timeElapsed > 0.01f) || !instance.thisController.isGrounded))
			{
				instance.fallValue = 0f;
				timeElapsed += Time.deltaTime;
				instance.thisController.Move(Vector3.Lerp(new Vector3(0f, startForce, 0f), Vector3.up, timeElapsed / duration) * Time.deltaTime);
				yield return null;
			}
		}

		private static IEnumerator WallJump(PlayerControllerB instance, bool forwardHit, bool leftHit, bool backHit, bool rightHit)
		{
			instance.ResetFallGravity();
			float timeElapsed = 0f;
			Vector3 direction = Quaternion.AngleAxis(directionsToRotation(forwardHit, leftHit, backHit, rightHit) + 180f, Vector3.up) * ((Component)instance).transform.forward;
			direction.y = 1.5f;
			while (!slamming && timeElapsed < 0.33f)
			{
				instance.ResetFallGravity();
				timeElapsed += Time.deltaTime;
				instance.thisController.Move(Vector3.Lerp(direction * 15f, direction, timeElapsed / 0.33f) * Time.deltaTime);
				yield return null;
			}
		}

		private static IEnumerator Slide(PlayerControllerB instance, Vector3 initialBuildup)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			IngamePlayerSettings.Instance.playerInput.actions.FindAction("Move", false).Disable();
			instance.Crouch(true);
			sliding = true;
			slamTimer = ScrapIsFuel.Config.SLAM_JUMP_PERIOD.Value;
			float timeElapsed = 0f;
			Vector3 oldPos = new Vector3(0f, 0f, 0f);
			Vector3 newPos = ((Component)instance).transform.position;
			Vector3 forward = ((Component)instance.gameplayCamera).transform.forward;
			Vector3 direction = ((Vector3)(ref forward)).normalized * 10f;
			direction.y = 0f;
			while (!instance.isSinking && !ScrapIsFuel.UltraInputsInstance.Dash.WasPressedThisFrame() && ScrapIsFuel.UltraInputsInstance.SlamNSlide.IsPressed() && Mathf.Abs(oldPos.x - newPos.x) > 0f && Mathf.Abs(oldPos.z - newPos.z) > 0f)
			{
				timeElapsed += Time.deltaTime;
				slideTimer = 0f;
				Vector3 buildupVector = Vector3.Lerp(initialBuildup, Vector3.zero, timeElapsed / 1f);
				oldPos = newPos;
				instance.thisController.Move((direction + buildupVector) * Time.deltaTime);
				newPos = ((Component)instance).transform.position;
				momentumVector = direction + buildupVector;
				yield return null;
			}
			sliding = false;
			instance.Crouch(false);
			IngamePlayerSettings.Instance.playerInput.actions.FindAction("Move", false).Enable();
		}
	}
	[HarmonyPatch]
	internal class PlayerJumpPatch
	{
		[HarmonyTargetMethod]
		private static MethodBase targetMoveNext()
		{
			return AccessTools.Method(AccessTools.FirstInner(typeof(PlayerControllerB), (Func<Type, bool>)((Type t) => t.Name.Contains("<PlayerJump>d__374"))), "MoveNext", (Type[])null, (Type[])null);
		}

		[HarmonyPatch]
		[HarmonyTranspiler]
		[HarmonyPriority(800)]
		private static IEnumerable<CodeInstruction> MoveNextTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = instructions.ToList();
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Newobj && list[i - 1].opcode == OpCodes.Ldc_R4)
				{
					list.RemoveRange(i - 2, 4);
				}
			}
			return list.AsEnumerable();
		}
	}
}
namespace ScrapIsFuel.Input
{
	internal class UltraInputs : LcInputActions
	{
		[InputAction("<Keyboard>/f", Name = "Dash")]
		public InputAction Dash { get; set; }

		[InputAction("<Keyboard>/leftCtrl", Name = "SlamNSlide")]
		public InputAction SlamNSlide { get; set; }
	}
}
namespace ScrapIsFuel.Config
{
	[DataContract]
	internal class UltraConfigs : SyncedConfig<UltraConfigs>
	{
		[DataMember]
		public SyncedEntry<bool> FALL_DAMAGE_ENABLED { get; private set; }

		[DataMember]
		public SyncedEntry<bool> DASH_ENABLED { get; private set; }

		[DataMember]
		public SyncedEntry<float> DASH_DURATION { get; private set; }

		[DataMember]
		public SyncedEntry<float> DASH_MOMENTUM { get; private set; }

		[DataMember]
		public SyncedEntry<float> DASH_STAMINA { get; private set; }

		[DataMember]
		public SyncedEntry<int> DASH_AMPLITUDE { get; private set; }

		[DataMember]
		public SyncedEntry<bool> SLIDE_ENABLED { get; private set; }

		[DataMember]
		public SyncedEntry<float> SLIDE_JUMP_MULTIPLIER { get; private set; }

		[DataMember]
		public SyncedEntry<bool> SLAM_ENABLED { get; private set; }

		[DataMember]
		public SyncedEntry<int> SLAM_AMPLITUDE { get; private set; }

		[DataMember]
		public SyncedEntry<float> SLAM_JUMP_PERIOD { get; private set; }

		[DataMember]
		public SyncedEntry<float> SLAM_JUMP_MAX_DURATION { get; private set; }

		[DataMember]
		public SyncedEntry<int> SLAM_JUMP_DURATION_DIVISOR { get; private set; }

		[DataMember]
		public SyncedEntry<float> SLAM_JUMP_DURATION_OFFSET { get; private set; }

		[DataMember]
		public SyncedEntry<int> SLAM_JUMP_FORCE_MIN { get; private set; }

		[DataMember]
		public SyncedEntry<int> SLAM_JUMP_FORCE_MAX { get; private set; }

		[DataMember]
		public SyncedEntry<int> SLAM_JUMP_FORCE_DIVISOR { get; private set; }

		[DataMember]
		public SyncedEntry<float> SLAM_JUMP_FORCE_OFFSET { get; private set; }

		[DataMember]
		public SyncedEntry<bool> SLAM_STORAGE_ENABLED { get; private set; }

		[DataMember]
		public SyncedEntry<int> SLAM_STORAGE_HEIGHT { get; private set; }

		[DataMember]
		public SyncedEntry<int> SLAM_STORAGE_FORCE { get; private set; }

		[DataMember]
		public SyncedEntry<float> JUMP_DURATION { get; private set; }

		[DataMember]
		public SyncedEntry<int> JUMP_FORCE { get; private set; }

		[DataMember]
		public SyncedEntry<bool> WALL_CLINGING_ENABLED { get; private set; }

		[DataMember]
		public SyncedEntry<float> WALL_CLINGING_SLOWDOWN { get; private set; }

		[DataMember]
		public SyncedEntry<bool> WALL_JUMPING_ENABLED { get; private set; }

		[DataMember]
		public SyncedEntry<int> MAX_WALL_JUMPS { get; private set; }

		[DataMember]
		public SyncedEntry<bool> MOMENTUM_ENABLED { get; private set; }

		[DataMember]
		public SyncedEntry<float> MOMENTUM_PERIOD { get; private set; }

		[DataMember]
		public SyncedEntry<int> MAX_FALL_VALUE { get; private set; }

		internal UltraConfigs(ConfigFile cfg)
			: base("ScrapIsFuel")
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected O, but got Unknown
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Expected O, but got Unknown
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Expected O, but got Unknown
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Expected O, but got Unknown
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Expected O, but got Unknown
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Expected O, but got Unknown
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Expected O, but got Unknown
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Expected O, but got Unknown
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Expected O, but got Unknown
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Expected O, but got Unknown
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Expected O, but got Unknown
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Expected O, but got Unknown
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Expected O, but got Unknown
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Expected O, but got Unknown
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Expected O, but got Unknown
			//IL_056a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0574: Expected O, but got Unknown
			//IL_059d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Expected O, but got Unknown
			ConfigManager.Register<UltraConfigs>(this);
			FALL_DAMAGE_ENABLED = Extensions.BindSyncedEntry<bool>(cfg, "Fall damage", "Enabled", false, "Enables fall damage outside of slamming");
			DASH_ENABLED = Extensions.BindSyncedEntry<bool>(cfg, "Dashing", "Enabled", true, "Whether dashing is enabled");
			DASH_DURATION = Extensions.BindSyncedEntry<float>(cfg, "Dashing", "Duration", 0.075f, new ConfigDescription("How long the dash should last", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.15f), Array.Empty<object>()));
			DASH_MOMENTUM = Extensions.BindSyncedEntry<float>(cfg, "Dashing", "Momentum preservation", 0.33f, new ConfigDescription("Percentage of momentum kept from dashing", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			DASH_STAMINA = Extensions.BindSyncedEntry<float>(cfg, "Dashing", "Stamina usage", 0.33f, new ConfigDescription("How much stamina a dash consumes", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			DASH_AMPLITUDE = Extensions.BindSyncedEntry<int>(cfg, "Dashing", "Amplitude", 125, new ConfigDescription("How fast the dash should be (higher = faster)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(50, 200), Array.Empty<object>()));
			SLIDE_ENABLED = Extensions.BindSyncedEntry<bool>(cfg, "Sliding", "Enabled", true, "Whether sliding is enabled");
			SLIDE_JUMP_MULTIPLIER = Extensions.BindSyncedEntry<float>(cfg, "Slide jumping", "Multiplier", 1.0025f, new ConfigDescription("How much your momentum gets multiplied by slide jumping", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1.05f), Array.Empty<object>()));
			SLAM_ENABLED = Extensions.BindSyncedEntry<bool>(cfg, "Slamming", "Enabled", true, "Whether slamming is enabled");
			SLAM_AMPLITUDE = Extensions.BindSyncedEntry<int>(cfg, "Slamming", "Amplitude", 50, new ConfigDescription("How fast the fall from a slam is (higher = faster)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 150), Array.Empty<object>()));
			SLAM_JUMP_PERIOD = Extensions.BindSyncedEntry<float>(cfg, "Slam jumping", "Period", 0.5f, new ConfigDescription("Amount of time in which slamming gives a boost to jumping", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			SLAM_JUMP_MAX_DURATION = Extensions.BindSyncedEntry<float>(cfg, "Slam jumping", "Duration", 2.5f, new ConfigDescription("Maximum amount of time the player can be propelled upwards when slam jumping, makes the jump more floaty", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 5f), Array.Empty<object>()));
			SLAM_JUMP_DURATION_DIVISOR = Extensions.BindSyncedEntry<int>(cfg, "Slam jumping", "Duration divisor", 200, new ConfigDescription("How much slam height should be divided by to get the duration of the slam jump (lower = higher/floatier jump)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 300), Array.Empty<object>()));
			SLAM_JUMP_DURATION_OFFSET = Extensions.BindSyncedEntry<float>(cfg, "Slam jumping", "Duration offset", 0.4f, new ConfigDescription("How close the slam jump should be to the maximum amount of propelling time by default (higher = higher/floatier jump)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			SLAM_JUMP_FORCE_MIN = Extensions.BindSyncedEntry<int>(cfg, "Slam jumping", "Minimum force", 20, new ConfigDescription("Minimum starting force of the slam jump", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 39), Array.Empty<object>()));
			SLAM_JUMP_FORCE_MAX = Extensions.BindSyncedEntry<int>(cfg, "Slam jumping", "Maximum force", 40, new ConfigDescription("Maximum starting force of the slam jump", (AcceptableValueBase)(object)new AcceptableValueRange<int>(40, 80), Array.Empty<object>()));
			SLAM_JUMP_FORCE_DIVISOR = Extensions.BindSyncedEntry<int>(cfg, "Slam jumping", "Force divisor", 50, new ConfigDescription("How much slam height should be divided by to get the starting force (lower = stronger jump)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 200), Array.Empty<object>()));
			SLAM_JUMP_FORCE_OFFSET = Extensions.BindSyncedEntry<float>(cfg, "Slam jumping", "Force offset", 0.35f, new ConfigDescription("How close the slam jump should be to the maximum starting force by default (high = stronger jump)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			SLAM_STORAGE_ENABLED = Extensions.BindSyncedEntry<bool>(cfg, "Slam storage", "Enabled", true, "Whether slam storage is enabled");
			SLAM_STORAGE_HEIGHT = Extensions.BindSyncedEntry<int>(cfg, "Slam storage", "Height", 275, new ConfigDescription("What slam height slam storage should count as", (AcceptableValueBase)(object)new AcceptableValueRange<int>(150, 450), Array.Empty<object>()));
			SLAM_STORAGE_FORCE = Extensions.BindSyncedEntry<int>(cfg, "Slam storage", "Force", 100, new ConfigDescription("How powerful the initial upwards force is (higher = more powerful)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(25, 200), Array.Empty<object>()));
			JUMP_DURATION = Extensions.BindSyncedEntry<float>(cfg, "Jumping", "Duration", 0.6f, new ConfigDescription("How long the standard jump should be elongated for (higher = longer)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			JUMP_FORCE = Extensions.BindSyncedEntry<int>(cfg, "Jumping", "Force", 20, new ConfigDescription("How powerful the initial upwards force is (higher = more powerful)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 50), Array.Empty<object>()));
			WALL_CLINGING_ENABLED = Extensions.BindSyncedEntry<bool>(cfg, "Wall clinging", "Enabled", true, "Whether wall clinging is enabled");
			WALL_CLINGING_SLOWDOWN = Extensions.BindSyncedEntry<float>(cfg, "Wall clinging", "Slowdown", 1.25f, new ConfigDescription("How much wall clinging will slow down donwards velocity (1 = no slowdown)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 2f), Array.Empty<object>()));
			WALL_JUMPING_ENABLED = Extensions.BindSyncedEntry<bool>(cfg, "Wall jumping", "Enabled", true, "Whether wall jumping is enabled");
			MAX_WALL_JUMPS = Extensions.BindSyncedEntry<int>(cfg, "Wall jumping", "Max wall jumps", 3, new ConfigDescription("How many wall jumps can be performed before needing to be grounded", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), Array.Empty<object>()));
			MOMENTUM_ENABLED = Extensions.BindSyncedEntry<bool>(cfg, "Momentum", "Enabled", true, "Whether momentum is enabled");
			MOMENTUM_PERIOD = Extensions.BindSyncedEntry<float>(cfg, "Momentum", "Period", 0.25f, new ConfigDescription("How much time must pass for momentum to start dropping", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			MAX_FALL_VALUE = Extensions.BindSyncedEntry<int>(cfg, "Falling", "Maximum gravity", -50, new ConfigDescription("How big terminal velocity is (closer to zero = smaller)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-150, -1), Array.Empty<object>()));
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}