Decompiled source of MapParachute v1.0.0

Parachute Map.dll

Decompiled 14 hours 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.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Parachute Map")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Go Go Gadget Parachue Map")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0")]
[assembly: AssemblyProduct("Parachute Map")]
[assembly: AssemblyTitle("Parachute Map")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
[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 BigWalkParachuteMod
{
	[BepInPlugin("com.gogogadgetjustice.bigwalk.parachute", "BigWalk Parachute Mod", "1.0.0")]
	public class ParachuteMod : BasePlugin
	{
		internal static ManualLogSource Logger;

		public static ConfigEntry<KeyCode> ParachuteToggleKey;

		public static ConfigEntry<float> ConfigTerminalDescentSpeed;

		public static ConfigEntry<float> ConfigDeployHeightThreshold;

		public static ConfigEntry<bool> EnableAirHorizontalGlideBoost;

		public static ConfigEntry<float> SoftLandingGraceSeconds;

		public override void Load()
		{
			//IL_00c4: 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_00d3: Expected O, but got Unknown
			Logger = ((BasePlugin)this).Log;
			ParachuteToggleKey = ((BasePlugin)this).Config.Bind<KeyCode>("Controls", "Toggle Key", (KeyCode)120, "Manual fallback bypass trigger button.");
			ConfigTerminalDescentSpeed = ((BasePlugin)this).Config.Bind<float>("Physics Tuning", "Terminal Descent Speed", -2.5f, "Maximum velocity allowed while parachuting.");
			ConfigDeployHeightThreshold = ((BasePlugin)this).Config.Bind<float>("Safety Check", "Grounded Height Distance", 1.5f, "Auto-shutoff ground buffer proximity threshold.");
			EnableAirHorizontalGlideBoost = ((BasePlugin)this).Config.Bind<bool>("Features", "Air Glide Drift Control", true, "Softens air friction for drifting adjustments.");
			SoftLandingGraceSeconds = ((BasePlugin)this).Config.Bind<float>("Physics Tuning", "Soft Landing Grace Seconds", 0.5f, "How long ignoreFalling stays enabled after the parachute is lowered (prevents impact stumbles).");
			ClassInjector.RegisterTypeInIl2Cpp<ParachutePhysicsController>();
			GameObject val = new GameObject("ParachuteModPhysicsHost")
			{
				hideFlags = (HideFlags)61
			};
			Object.DontDestroyOnLoad((Object)(object)val);
			val.AddComponent<ParachutePhysicsController>();
			Logger.LogInfo((object)"==================================================");
			Logger.LogInfo((object)"  Big Walk Parachute Mod Loaded Successfully!     ");
			Logger.LogInfo((object)"==================================================");
		}
	}
	public class ParachutePhysicsController : MonoBehaviour
	{
		private bool _manualBypassActive = false;

		private Rigidbody _targetedPlayerRb;

		private PlayerFaller _targetedPlayerFaller;

		private float _searchTimer = 0f;

		private KeyCode _toggleButton;

		private float _terminalFallLimit;

		private float _groundCheckDistance;

		private bool _softLandingEngaged = false;

		private bool _isMapDeployedOverhead = false;

		private float _softLandingGraceTimer = 0f;

		private Prop _cachedHeldProp;

		private float _propRefreshTimer = 0f;

		private const float PropRefreshInterval = 0.5f;

		public ParachutePhysicsController(IntPtr ptr)
			: base(ptr)
		{
		}

		public void Start()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			_toggleButton = ParachuteMod.ParachuteToggleKey.Value;
			_terminalFallLimit = ParachuteMod.ConfigTerminalDescentSpeed.Value;
			_groundCheckDistance = ParachuteMod.ConfigDeployHeightThreshold.Value;
			LocateActivePlayerRigidbody();
		}

		public void Update()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			if (Input.GetKeyDown(_toggleButton))
			{
				_manualBypassActive = !_manualBypassActive;
				ManualLogSource logger = ParachuteMod.Logger;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(39, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ParachuteMod] Manual hotkey override: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(_manualBypassActive);
				}
				logger.LogInfo(val);
			}
			if ((Object)(object)_targetedPlayerRb == (Object)null)
			{
				_searchTimer -= Time.deltaTime;
				if (_searchTimer <= 0f)
				{
					LocateActivePlayerRigidbody();
					_searchTimer = 1.5f;
				}
			}
		}

		public void FixedUpdate()
		{
			if ((Object)(object)_targetedPlayerRb == (Object)null)
			{
				return;
			}
			UpdateMapState();
			if (_manualBypassActive || _isMapDeployedOverhead)
			{
				_softLandingGraceTimer = ParachuteMod.SoftLandingGraceSeconds.Value;
				EngageSoftLanding();
				if (!IsPlayerGrounded())
				{
					ApplyDescentClamp();
				}
			}
			else if (_softLandingGraceTimer > 0f)
			{
				_softLandingGraceTimer -= Time.fixedDeltaTime;
			}
			else
			{
				DisengageSoftLanding();
			}
		}

		private void ApplyDescentClamp()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_00b5: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			Vector3 linearVelocity = _targetedPlayerRb.linearVelocity;
			if (linearVelocity.y < _terminalFallLimit)
			{
				linearVelocity.y = _terminalFallLimit;
			}
			if (ParachuteMod.EnableAirHorizontalGlideBoost.Value)
			{
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(linearVelocity.x, 0f, linearVelocity.z);
				Vector3 val2 = ((Component)_targetedPlayerRb).transform.forward * 0.15f;
				val += val2;
				float num = 6f;
				if (((Vector3)(ref val)).magnitude > num)
				{
					val = ((Vector3)(ref val)).normalized * num;
				}
				linearVelocity.x = val.x;
				linearVelocity.z = val.z;
			}
			_targetedPlayerRb.linearVelocity = linearVelocity;
		}

		private void EngageSoftLanding()
		{
			if (!_softLandingEngaged && _targetedPlayerFaller != null)
			{
				_targetedPlayerFaller.ignoreFalling = true;
				_softLandingEngaged = true;
			}
		}

		private void DisengageSoftLanding()
		{
			if (_softLandingEngaged)
			{
				if (_targetedPlayerFaller != null)
				{
					_targetedPlayerFaller.ignoreFalling = false;
				}
				_softLandingEngaged = false;
			}
		}

		private void UpdateMapState()
		{
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			_isMapDeployedOverhead = false;
			if ((Object)(object)_targetedPlayerRb == (Object)null)
			{
				return;
			}
			_propRefreshTimer -= Time.fixedDeltaTime;
			if ((Object)(object)_cachedHeldProp == (Object)null || _propRefreshTimer <= 0f)
			{
				_propRefreshTimer = 0.5f;
				_cachedHeldProp = null;
				Prop[] array = Il2CppArrayBase<Prop>.op_Implicit(((Component)_targetedPlayerRb).GetComponentsInChildren<Prop>(true));
				Prop[] array2 = array;
				foreach (Prop val in array2)
				{
					if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null)
					{
						string name = ((Object)((Component)val).gameObject).name;
						if (name.Contains("Map") || name.Contains("Folding"))
						{
							_cachedHeldProp = val;
							break;
						}
					}
				}
			}
			if ((Object)(object)_cachedHeldProp != (Object)null && (Object)(object)((Component)_cachedHeldProp).gameObject != (Object)null)
			{
				float num = ((Component)_cachedHeldProp).transform.position.y - ((Component)_targetedPlayerRb).transform.position.y;
				if (num > 0.8f)
				{
					_isMapDeployedOverhead = true;
				}
			}
		}

		private void LocateActivePlayerRigidbody()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			Rigidbody[] array = Il2CppArrayBase<Rigidbody>.op_Implicit(Object.FindObjectsOfType<Rigidbody>());
			Rigidbody[] array2 = array;
			bool flag = default(bool);
			foreach (Rigidbody val in array2)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null && ((Object)((Component)val).gameObject).name.StartsWith("PlayerCharacter "))
				{
					_targetedPlayerRb = val;
					_targetedPlayerFaller = ((Component)val).GetComponent<PlayerFaller>() ?? ((Component)val).GetComponentInParent<PlayerFaller>() ?? ((Component)val).GetComponentInChildren<PlayerFaller>();
					ManualLogSource logger = ParachuteMod.Logger;
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(34, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ParachuteMod] Bound to player: '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)((Component)val).gameObject).name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
					}
					logger.LogInfo(val2);
					break;
				}
			}
		}

		private bool IsPlayerGrounded()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//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_0037: 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_0039: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_targetedPlayerRb == (Object)null)
			{
				return true;
			}
			Vector3 val = _targetedPlayerRb.position + Vector3.up * 0.2f;
			RaycastHit[] array = Il2CppArrayBase<RaycastHit>.op_Implicit((Il2CppArrayBase<RaycastHit>)(object)Physics.RaycastAll(val, Vector3.down, _groundCheckDistance + 0.2f));
			RaycastHit[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val2 = array2[i];
				if ((Object)(object)((RaycastHit)(ref val2)).collider != (Object)null && !((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(((Component)_targetedPlayerRb).transform))
				{
					return true;
				}
			}
			return false;
		}
	}
}