Decompiled source of DynamicFlight v1.1.0

Mods/DynamicFlight.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using DynamicFlight;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using MelonLoader;
using MelonLoader.Preferences;
using UnityEngine;
using UnityEngine.XR;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(DynamicFlightMod), "DynamicFlight", "1.0.0", "Astronoz", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: AssemblyTitle("DynamicFlight")]
[assembly: AssemblyDescription("Dynamic flight mod for BONELAB")]
[assembly: MelonInfo(typeof(DynamicFlightMod), "DynamicFlight", "1.1.0", "Astronoz", null)]
[assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace DynamicFlight;

public class DynamicFlightMod : MelonMod
{
	private const string CategoryName = "DynamicFlight";

	private MelonPreferences_Category _prefCat;

	private MelonPreferences_Entry<bool> _prefEnabled;

	private MelonPreferences_Entry<float> _prefMoveSpeed;

	private MelonPreferences_Entry<float> _prefVerticalSpeed;

	private MelonPreferences_Entry<float> _prefDamping;

	private MelonPreferences_Entry<bool> _prefNoclipEnabled;

	private MelonPreferences_Entry<float> _prefSpeedMultiplier;

	private MelonPreferences_Entry<float> _prefSonicBoomSpeed;

	private MelonPreferences_Entry<bool> _prefSonicBoomEnabled;

	private bool _isFlying;

	private Vector3 _currentVelocity = Vector3.zero;

	private float _lastBPressTime;

	private float _doubleTapDelay = 0.35f;

	private bool _isSpeedBoosted;

	private float _currentSpeedMultiplier = 1f;

	private float _speedBuildUp;

	private float _speedBuildUpRate = 2f;

	private float _lastLeftTriggerPressTime;

	private float _lastRightTriggerPressTime;

	private bool _leftTriggerPressed;

	private bool _rightTriggerPressed;

	private bool _isNoclip;

	private float _lastThumbstickPressTime;

	private List<Collider> _disabledColliders = new List<Collider>();

	private float[] _savedDrags;

	private bool _physicsModified;

	private float _currentSpeed;

	private bool _hasTriggeredSonicBoom;

	private float _sonicBoomCooldown;

	private float _sonicBoomCooldownTime = 10f;

	private float _repeatingShockwaveTimer;

	private float _repeatingShockwaveInterval = 1f;

	private bool _isInSonicBoomMode;

	public override void OnInitializeMelon()
	{
		_prefCat = MelonPreferences.CreateCategory("DynamicFlight");
		_prefEnabled = _prefCat.CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_prefMoveSpeed = _prefCat.CreateEntry<float>("MoveSpeed", 15f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_prefVerticalSpeed = _prefCat.CreateEntry<float>("VerticalSpeed", 10f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_prefDamping = _prefCat.CreateEntry<float>("Damping", 3f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_prefNoclipEnabled = _prefCat.CreateEntry<bool>("NoclipEnabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_prefSpeedMultiplier = _prefCat.CreateEntry<float>("SpeedMultiplier", 2f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_prefSonicBoomSpeed = _prefCat.CreateEntry<float>("SonicBoomSpeed", 100f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		_prefSonicBoomEnabled = _prefCat.CreateEntry<bool>("SonicBoomEnabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		try
		{
			SetupBoneMenu();
		}
		catch (Exception value)
		{
			((MelonBase)this).LoggerInstance.Error($"BoneMenu FAILED: {value}");
		}
		((MelonBase)this).LoggerInstance.Msg("DynamicFlight initialized! Double-tap B to fly. Double-tap BOTH triggers for speed boost.");
	}

	private void SetupBoneMenu()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		Page obj = Menu.CurrentPage.CreatePage("Dynamic Flight", Color.cyan, 0, true);
		obj.CreateBool("Mod Enabled", Color.green, _prefEnabled.Value, (Action<bool>)delegate(bool val)
		{
			_prefEnabled.Value = val;
			_prefCat.SaveToFile(true);
			if (!val && _isFlying)
			{
				StopFlying();
			}
		});
		obj.CreateFloat("Move Speed", Color.white, _prefMoveSpeed.Value, 5f, 5f, 100f, (Action<float>)delegate(float val)
		{
			_prefMoveSpeed.Value = val;
			_prefCat.SaveToFile(true);
		});
		obj.CreateFloat("Vertical Speed", Color.white, _prefVerticalSpeed.Value, 5f, 5f, 100f, (Action<float>)delegate(float val)
		{
			_prefVerticalSpeed.Value = val;
			_prefCat.SaveToFile(true);
		});
		obj.CreateFloat("Damping", Color.white, _prefDamping.Value, 1f, 0f, 30f, (Action<float>)delegate(float val)
		{
			_prefDamping.Value = val;
			_prefCat.SaveToFile(true);
		});
		obj.CreateFloat("Speed Multiplier", Color.magenta, _prefSpeedMultiplier.Value, 1f, 1f, 5f, (Action<float>)delegate(float val)
		{
			_prefSpeedMultiplier.Value = val;
			_prefCat.SaveToFile(true);
		});
		obj.CreateBool("Sonic Boom", Color.cyan, _prefSonicBoomEnabled.Value, (Action<bool>)delegate(bool val)
		{
			_prefSonicBoomEnabled.Value = val;
			_prefCat.SaveToFile(true);
			if (!val)
			{
				_isInSonicBoomMode = false;
				_repeatingShockwaveTimer = 0f;
			}
		});
		obj.CreateFloat("Sonic Boom Speed", Color.cyan, _prefSonicBoomSpeed.Value, 50f, 50f, 300f, (Action<float>)delegate(float val)
		{
			_prefSonicBoomSpeed.Value = val;
			_prefCat.SaveToFile(true);
		});
		obj.CreateBool("Noclip Enabled", Color.green, _prefNoclipEnabled.Value, (Action<bool>)delegate(bool val)
		{
			_prefNoclipEnabled.Value = val;
			_prefCat.SaveToFile(true);
			if (!val && _isNoclip)
			{
				DisableNoclip();
			}
		});
		((MelonBase)this).LoggerInstance.Msg("BoneMenu created!");
	}

	public override void OnUpdate()
	{
		SonicBoomShockwave.Tick();
		if (!_prefEnabled.Value || !Player.HandsExist)
		{
			return;
		}
		if (Player.RightController.GetBButtonDown())
		{
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime - _lastBPressTime <= _doubleTapDelay)
			{
				if (_isFlying)
				{
					StopFlying();
				}
				else
				{
					StartFlying();
				}
				_lastBPressTime = 0f;
			}
			else
			{
				_lastBPressTime = unscaledTime;
			}
		}
		if (_isFlying)
		{
			bool triggerPressed = GetTriggerPressed((XRNode)4);
			bool triggerPressed2 = GetTriggerPressed((XRNode)5);
			if (triggerPressed && !_leftTriggerPressed)
			{
				float unscaledTime2 = Time.unscaledTime;
				if (unscaledTime2 - _lastLeftTriggerPressTime <= _doubleTapDelay)
				{
					if (triggerPressed2)
					{
						ToggleSpeedBoost();
					}
					_lastLeftTriggerPressTime = 0f;
				}
				else
				{
					_lastLeftTriggerPressTime = unscaledTime2;
				}
				_leftTriggerPressed = true;
			}
			else if (!triggerPressed)
			{
				_leftTriggerPressed = false;
			}
			if (triggerPressed2 && !_rightTriggerPressed)
			{
				float unscaledTime3 = Time.unscaledTime;
				if (unscaledTime3 - _lastRightTriggerPressTime <= _doubleTapDelay)
				{
					if (triggerPressed)
					{
						ToggleSpeedBoost();
					}
					_lastRightTriggerPressTime = 0f;
				}
				else
				{
					_lastRightTriggerPressTime = unscaledTime3;
				}
				_rightTriggerPressed = true;
			}
			else if (!triggerPressed2)
			{
				_rightTriggerPressed = false;
			}
		}
		if (!_prefNoclipEnabled.Value || !_isFlying || !Player.RightController.GetThumbStickDown())
		{
			return;
		}
		float unscaledTime4 = Time.unscaledTime;
		if (unscaledTime4 - _lastThumbstickPressTime <= _doubleTapDelay)
		{
			if (_isNoclip)
			{
				DisableNoclip();
			}
			else
			{
				EnableNoclip();
			}
			_lastThumbstickPressTime = 0f;
		}
		else
		{
			_lastThumbstickPressTime = unscaledTime4;
		}
	}

	private bool GetTriggerPressed(XRNode node)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		InputDevice deviceAtXRNode = InputDevices.GetDeviceAtXRNode(node);
		float num = default(float);
		if (((InputDevice)(ref deviceAtXRNode)).isValid && ((InputDevice)(ref deviceAtXRNode)).TryGetFeatureValue(CommonUsages.trigger, ref num))
		{
			return num > 0.5f;
		}
		return false;
	}

	public override void OnFixedUpdate()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: 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)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: 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_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//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_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		if (!_isFlying)
		{
			return;
		}
		PhysicsRig physicsRig = Player.PhysicsRig;
		if ((Object)(object)physicsRig == (Object)null)
		{
			return;
		}
		Transform head = Player.Head;
		Vector3 forward = head.forward;
		Vector3 right = head.right;
		Vector2 thumbStickAxis = Player.LeftController.GetThumbStickAxis();
		Vector2 thumbStickAxis2 = Player.RightController.GetThumbStickAxis();
		UpdateSpeedBoost();
		float num = _prefMoveSpeed.Value * _currentSpeedMultiplier;
		float num2 = _prefVerticalSpeed.Value * _currentSpeedMultiplier;
		Vector3 zero = Vector3.zero;
		zero += forward * thumbStickAxis.y * num;
		zero += right * thumbStickAxis.x * num;
		zero += Vector3.up * thumbStickAxis2.y * num2;
		float value = _prefDamping.Value;
		_currentVelocity = Vector3.Lerp(_currentVelocity, zero, Time.fixedDeltaTime * value * 2f);
		_currentSpeed = ((Vector3)(ref _currentVelocity)).magnitude;
		if (_prefSonicBoomEnabled.Value)
		{
			CheckSonicBoom();
			if (_isInSonicBoomMode)
			{
				_repeatingShockwaveTimer += Time.fixedDeltaTime;
				if (_repeatingShockwaveTimer >= _repeatingShockwaveInterval)
				{
					_repeatingShockwaveTimer = 0f;
					TriggerRepeatingShockwave();
				}
			}
		}
		Rigidbody[] allBodyRigidbodies = GetAllBodyRigidbodies(physicsRig);
		foreach (Rigidbody val in allBodyRigidbodies)
		{
			if ((Object)(object)val != (Object)null)
			{
				val.velocity = _currentVelocity;
				val.useGravity = false;
				val.angularVelocity = Vector3.zero;
			}
		}
	}

	private void CheckSonicBoom()
	{
		if (_sonicBoomCooldown > 0f)
		{
			_sonicBoomCooldown -= Time.fixedDeltaTime;
		}
		float value = _prefSonicBoomSpeed.Value;
		if (_currentSpeed >= value && _sonicBoomCooldown <= 0f && !_hasTriggeredSonicBoom)
		{
			_hasTriggeredSonicBoom = true;
			_sonicBoomCooldown = _sonicBoomCooldownTime;
			_isInSonicBoomMode = true;
			_repeatingShockwaveTimer = 0f;
			TriggerSonicBoom();
		}
		else if (_currentSpeed < value && _isInSonicBoomMode)
		{
			_isInSonicBoomMode = false;
			_repeatingShockwaveTimer = 0f;
		}
		else if (_currentSpeed < value)
		{
			_hasTriggeredSonicBoom = false;
		}
	}

	private void TriggerSonicBoom()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: 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_0041: Unknown result type (might be due to invalid IL or missing references)
		Transform head = Player.Head;
		if (!((Object)(object)head == (Object)null))
		{
			Vector3 position = head.position;
			float radius = Mathf.Clamp(_currentSpeed / 10f, 5f, 30f) * 9f;
			SonicBoomShockwave.Spawn(position, radius);
			ApplyShockwaveForce(position, radius);
		}
	}

	private void TriggerRepeatingShockwave()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: 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_0041: Unknown result type (might be due to invalid IL or missing references)
		Transform head = Player.Head;
		if (!((Object)(object)head == (Object)null))
		{
			Vector3 position = head.position;
			float radius = Mathf.Clamp(_currentSpeed / 12f, 4f, 25f) * 9f;
			SonicBoomShockwave.Spawn(position, radius);
			ApplyShockwaveForce(position, radius);
		}
	}

	private void ApplyShockwaveForce(Vector3 position, float radius)
	{
		//IL_001c: 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_0082: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: 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)
		float num = Mathf.Clamp(_currentSpeed * 0.5f, 50f, 500f);
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(position, radius));
		HashSet<int> hashSet = new HashSet<int>();
		Collider[] array2 = array;
		foreach (Collider val in array2)
		{
			if (!((Object)(object)val == (Object)null) && !val.isTrigger)
			{
				Rigidbody componentInParent = ((Component)val).GetComponentInParent<Rigidbody>();
				if ((Object)(object)componentInParent != (Object)null && !componentInParent.isKinematic && hashSet.Add(((Object)componentInParent).GetInstanceID()))
				{
					float num2 = Vector3.Distance(position, componentInParent.position);
					float num3 = 1f - Mathf.Clamp01(num2 / radius);
					float num4 = num * num3 * 2f;
					Vector3 val2 = componentInParent.position - position;
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					componentInParent.AddForce(normalized * num4, (ForceMode)1);
				}
			}
		}
	}

	private void UpdateSpeedBoost()
	{
		float num = (_isSpeedBoosted ? _prefSpeedMultiplier.Value : 1f);
		if (_isSpeedBoosted)
		{
			_speedBuildUp += Time.fixedDeltaTime * _speedBuildUpRate;
			_speedBuildUp = Mathf.Min(_speedBuildUp, 1f);
			_currentSpeedMultiplier = Mathf.Lerp(1f, num, _speedBuildUp);
		}
		else
		{
			_speedBuildUp -= Time.fixedDeltaTime * _speedBuildUpRate * 1.5f;
			_speedBuildUp = Mathf.Max(_speedBuildUp, 0f);
			_currentSpeedMultiplier = Mathf.Lerp(1f, num, _speedBuildUp);
		}
		_currentSpeedMultiplier = Mathf.Clamp(_currentSpeedMultiplier, 1f, _prefSpeedMultiplier.Value);
	}

	private void ToggleSpeedBoost()
	{
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: 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_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Expected O, but got Unknown
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: 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: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Expected O, but got Unknown
		_isSpeedBoosted = !_isSpeedBoosted;
		if (_isSpeedBoosted)
		{
			_speedBuildUp = 0f;
			((MelonBase)this).LoggerInstance.Msg($"SPEED BOOST ON - Building up to {_prefSpeedMultiplier.Value}x");
			Notifier.Send(new Notification
			{
				Title = NotificationText.op_Implicit("Speed Boost"),
				Message = NotificationText.op_Implicit($"BOOSTING to {_prefSpeedMultiplier.Value}x!"),
				ShowTitleOnPopup = true,
				PopupLength = 1.5f,
				Type = (NotificationType)3
			});
		}
		else
		{
			((MelonBase)this).LoggerInstance.Msg("SPEED BOOST OFF - Returning to 1x");
			Notifier.Send(new Notification
			{
				Title = NotificationText.op_Implicit("Speed Boost"),
				Message = NotificationText.op_Implicit("Returning to normal speed"),
				ShowTitleOnPopup = true,
				PopupLength = 1.5f,
				Type = (NotificationType)2
			});
		}
	}

	private Rigidbody[] GetAllBodyRigidbodies(PhysicsRig physRig)
	{
		List<Rigidbody> list = new List<Rigidbody>();
		if ((Object)(object)physRig.torso != (Object)null)
		{
			AddIfNotNull(list, physRig.torso.rbPelvis);
			AddIfNotNull(list, physRig.torso.rbSpine);
			AddIfNotNull(list, physRig.torso.rbChest);
			AddIfNotNull(list, physRig.torso.rbNeck);
			AddIfNotNull(list, physRig.torso.rbHead);
		}
		if ((Object)(object)physRig.softbody != (Object)null)
		{
			AddIfNotNull(list, physRig.softbody.rbArmUpperLf);
			AddIfNotNull(list, physRig.softbody.rbArmUpperRt);
			AddIfNotNull(list, physRig.softbody.rbForearmLf);
			AddIfNotNull(list, physRig.softbody.rbForearmRt);
			AddIfNotNull(list, physRig.softbody.rbSoftHandLf);
			AddIfNotNull(list, physRig.softbody.rbSoftHandRt);
		}
		AddIfNotNull(list, physRig.rbKnee);
		AddIfNotNull(list, physRig.rbFeet);
		return list.ToArray();
	}

	private void AddIfNotNull(List<Rigidbody> list, Rigidbody rb)
	{
		if ((Object)(object)rb != (Object)null)
		{
			list.Add(rb);
		}
	}

	private void StartFlying()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//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_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Expected O, but got Unknown
		PhysicsRig physicsRig = Player.PhysicsRig;
		if (!((Object)(object)physicsRig == (Object)null))
		{
			_isFlying = true;
			_currentVelocity = Vector3.zero;
			_currentSpeedMultiplier = 1f;
			_isSpeedBoosted = false;
			_speedBuildUp = 0f;
			_hasTriggeredSonicBoom = false;
			_sonicBoomCooldown = 0f;
			_isInSonicBoomMode = false;
			_repeatingShockwaveTimer = 0f;
			Rigidbody[] allBodyRigidbodies = GetAllBodyRigidbodies(physicsRig);
			_savedDrags = new float[allBodyRigidbodies.Length];
			for (int i = 0; i < allBodyRigidbodies.Length; i++)
			{
				_savedDrags[i] = allBodyRigidbodies[i].drag;
				allBodyRigidbodies[i].useGravity = false;
				allBodyRigidbodies[i].drag = 0f;
			}
			_physicsModified = true;
			((MelonBase)this).LoggerInstance.Msg("FLY ON");
			Notifier.Send(new Notification
			{
				Title = NotificationText.op_Implicit("Dynamic Flight"),
				Message = NotificationText.op_Implicit("Flight ON"),
				ShowTitleOnPopup = true,
				PopupLength = 1.5f,
				Type = (NotificationType)3
			});
		}
	}

	private void StopFlying()
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: 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_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Expected O, but got Unknown
		_isFlying = false;
		_isSpeedBoosted = false;
		_currentSpeedMultiplier = 1f;
		_speedBuildUp = 0f;
		_hasTriggeredSonicBoom = false;
		_isInSonicBoomMode = false;
		_repeatingShockwaveTimer = 0f;
		if (_isNoclip)
		{
			DisableNoclip();
		}
		RestorePhysics();
		((MelonBase)this).LoggerInstance.Msg("FLY OFF");
		Notifier.Send(new Notification
		{
			Title = NotificationText.op_Implicit("Dynamic Flight"),
			Message = NotificationText.op_Implicit("Flight OFF"),
			ShowTitleOnPopup = true,
			PopupLength = 1.5f,
			Type = (NotificationType)2
		});
	}

	private void RestorePhysics()
	{
		if (!_physicsModified)
		{
			return;
		}
		PhysicsRig physicsRig = Player.PhysicsRig;
		if (!((Object)(object)physicsRig == (Object)null))
		{
			Rigidbody[] allBodyRigidbodies = GetAllBodyRigidbodies(physicsRig);
			for (int i = 0; i < allBodyRigidbodies.Length && i < _savedDrags.Length; i++)
			{
				allBodyRigidbodies[i].useGravity = true;
				allBodyRigidbodies[i].drag = _savedDrags[i];
			}
			_physicsModified = false;
		}
	}

	private void EnableNoclip()
	{
		//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)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Expected O, but got Unknown
		PhysicsRig physicsRig = Player.PhysicsRig;
		if ((Object)(object)physicsRig == (Object)null)
		{
			return;
		}
		_disabledColliders.Clear();
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit(((Component)physicsRig).gameObject.GetComponentsInChildren<Collider>(true));
		foreach (Collider val in array)
		{
			if ((Object)(object)val != (Object)null && val.enabled)
			{
				val.enabled = false;
				_disabledColliders.Add(val);
			}
		}
		_isNoclip = true;
		((MelonBase)this).LoggerInstance.Msg($"NOCLIP ON - disabled {_disabledColliders.Count} colliders");
		Notifier.Send(new Notification
		{
			Title = NotificationText.op_Implicit("Dynamic Flight"),
			Message = NotificationText.op_Implicit("Noclip ON"),
			ShowTitleOnPopup = true,
			PopupLength = 1.5f,
			Type = (NotificationType)3
		});
	}

	private void DisableNoclip()
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: 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_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Expected O, but got Unknown
		foreach (Collider disabledCollider in _disabledColliders)
		{
			if ((Object)(object)disabledCollider != (Object)null)
			{
				disabledCollider.enabled = true;
			}
		}
		_disabledColliders.Clear();
		_isNoclip = false;
		((MelonBase)this).LoggerInstance.Msg("NOCLIP OFF");
		Notifier.Send(new Notification
		{
			Title = NotificationText.op_Implicit("Dynamic Flight"),
			Message = NotificationText.op_Implicit("Noclip OFF"),
			ShowTitleOnPopup = true,
			PopupLength = 1.5f,
			Type = (NotificationType)2
		});
	}
}
public static class SonicBoomShockwave
{
	private static GameObject _obj = null;

	private static float _timer = 0f;

	private static float _scale = 0f;

	private static float _targetRadius = 8f;

	public static void Spawn(Vector3 pos, float radius)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Expected O, but got Unknown
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_obj != (Object)null)
		{
			Object.Destroy((Object)(object)_obj);
			_obj = null;
		}
		_obj = GameObject.CreatePrimitive((PrimitiveType)0);
		((Object)_obj).name = "SonicBoom_Shockwave";
		_obj.transform.position = pos;
		_obj.transform.localScale = Vector3.one * 0.1f;
		Collider component = _obj.GetComponent<Collider>();
		if ((Object)(object)component != (Object)null)
		{
			Object.Destroy((Object)(object)component);
		}
		MeshRenderer component2 = _obj.GetComponent<MeshRenderer>();
		if ((Object)(object)component2 != (Object)null)
		{
			Material val = new Material(Shader.Find("Sprites/Default"));
			val.color = new Color(0.6f, 0.8f, 1f, 0.4f);
			val.SetFloat("_Mode", 3f);
			val.SetInt("_SrcBlend", 5);
			val.SetInt("_DstBlend", 10);
			val.SetInt("_ZWrite", 0);
			val.EnableKeyword("_ALPHABLEND_ON");
			val.renderQueue = 3000;
			((Renderer)component2).material = val;
		}
		_scale = 0.1f;
		_timer = 0.3f;
		_targetRadius = radius;
	}

	public static void Tick()
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		if (_timer <= 0f)
		{
			return;
		}
		_timer -= Time.deltaTime;
		_scale += Time.deltaTime * _targetRadius * 3f;
		if ((Object)(object)_obj != (Object)null)
		{
			_obj.transform.localScale = Vector3.one * _scale;
			MeshRenderer component = _obj.GetComponent<MeshRenderer>();
			if ((Object)(object)component != (Object)null)
			{
				float num = Mathf.Clamp01(_timer / 0.3f) * 0.4f;
				((Renderer)component).material.color = new Color(0.6f, 0.8f, 1f, num);
			}
		}
		if (_timer <= 0f && (Object)(object)_obj != (Object)null)
		{
			Object.Destroy((Object)(object)_obj);
			_obj = null;
		}
	}
}