Decompiled source of JetpackHMD v1.2.1

JetpackHMD.dll

Decompiled 5 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Rumi")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+aa4ed3d2398535d4afad1f8a9f9a33ecf65dabfd")]
[assembly: AssemblyProduct("JetpackHMD")]
[assembly: AssemblyTitle("JetpackHMD")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace Rumi.JetpackHMD
{
	[BepInPlugin("Rumi.JetpackHMD", "JetpackHMD", "1.2.1")]
	public class JetpackHMD : BaseUnityPlugin
	{
		public const string modGuid = "Rumi.JetpackHMD";

		public const string modName = "JetpackHMD";

		public const string modVersion = "1.2.1";

		private static Assembly? _currentAssembly;

		private static string? _assemblyName;

		public const string mainAssetBundleName = "JetpackHMD";

		public static Assembly currentAssembly => _currentAssembly ?? (_currentAssembly = Assembly.GetExecutingAssembly());

		public static string assemblyName => _assemblyName ?? (_assemblyName = currentAssembly.FullName.Split(',')[0]);

		public static ManualLogSource? logger { get; private set; }

		public static ConfigFile? config { get; private set; }

		public static JetpackHMDConfig? uiConfig { get; private set; }

		public static Harmony harmony { get; } = new Harmony("Rumi.JetpackHMD");


		public static JetpackHMDManager? manager { get; private set; }

		public static AssetBundle? mainAssetBundle { get; private set; }

		private void Awake()
		{
			logger = ((BaseUnityPlugin)this).Logger;
			config = ((BaseUnityPlugin)this).Config;
			ManualLogSource? obj = logger;
			if (obj != null)
			{
				obj.LogInfo((object)"Start loading plugin...");
			}
			ManualLogSource? obj2 = logger;
			if (obj2 != null)
			{
				obj2.LogInfo((object)"Config Loading...");
			}
			try
			{
				uiConfig = new JetpackHMDConfig(config);
			}
			catch (Exception ex)
			{
				uiConfig = null;
				ManualLogSource? obj3 = logger;
				if (obj3 != null)
				{
					obj3.LogWarning((object)ex);
				}
				ManualLogSource? obj4 = logger;
				if (obj4 != null)
				{
					obj4.LogWarning((object)"Failed to load config file\nSettings will be loaded with defaults!");
				}
			}
			ManualLogSource? obj5 = logger;
			if (obj5 != null)
			{
				obj5.LogInfo((object)"Asset Bundle Loading...");
			}
			if (mainAssetBundle == null)
			{
				mainAssetBundle = LoadMainAssetBundle();
			}
			ManualLogSource? obj6 = logger;
			if (obj6 != null)
			{
				obj6.LogInfo((object)"PlayerControllerB Patch...");
			}
			harmony.PatchAll(typeof(JetpackHMDPatches));
			ManualLogSource? obj7 = logger;
			if (obj7 != null)
			{
				obj7.LogInfo((object)"OnSceneRelayLoaded Event registration...");
			}
			SceneManager.sceneLoaded += OnSceneRelayLoaded;
			ManualLogSource? obj8 = logger;
			if (obj8 != null)
			{
				obj8.LogInfo((object)"Plugin JetpackHMD is loaded!");
			}
		}

		private static void OnSceneRelayLoaded(Scene scene, LoadSceneMode loadMode)
		{
			if (((Scene)(ref scene)).name == "SampleSceneRelay")
			{
				UILoad();
			}
		}

		public static void UILoad()
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			JetpackHMDManager.MetaData metaData = default(JetpackHMDManager.MetaData);
			metaData.getEnableEvent = delegate
			{
				if ((Object)(object)JetpackHMDPatches.playerControllerB != (Object)null && JetpackHMDPatches.playerControllerB.jetpackControls)
				{
					JetpackHMDConfig? jetpackHMDConfig = uiConfig;
					if (jetpackHMDConfig == null || jetpackHMDConfig.enableTulipSnakes)
					{
						return true;
					}
					if (JetpackHMDPatches.playerControllerB.isHoldingObject)
					{
						return JetpackHMDPatches.playerControllerB.currentlyHeldObjectServer is JetpackItem;
					}
					return false;
				}
				return false;
			};
			metaData.getEnableWarningEvent = () => (Object)(object)JetpackHMDPatches.playerControllerB != (Object)null && JetpackHMDPatches.playerControllerB.jetpackControls && JetpackHMDPatches.playerControllerB.isHoldingObject && JetpackHMDPatches.playerControllerB.currentlyHeldObjectServer is JetpackItem;
			metaData.getScaleEvent = () => uiConfig?.scale ?? 1.5f;
			metaData.color = Color32.op_Implicit(new Color32((byte)(uiConfig?.colorR ?? 0), (byte)(uiConfig?.colorG ?? 255), (byte)(uiConfig?.colorB ?? 0), (byte)(uiConfig?.colorA ?? 255)));
			metaData.roll = new JetpackHMDRoll.MetaData
			{
				getTargetTransform = GetPlayerTransform
			};
			metaData.pitchMeter = new JetpackHMDPitchMeter.MetaData
			{
				getTargetTransform = GetPlayerTransform,
				posSpacing = (uiConfig?.pitchMeterPosSpacing ?? 75f),
				numberSpacing = (uiConfig?.pitchMeterNumberSpacing ?? 10),
				minusPitchMeterPrefab = LoadPrefab("Minus Pitch Meter"),
				plusPitchMeterPrefab = LoadPrefab("Plus Pitch Meter")
			};
			metaData.speedText = new JetpackHMDSpeedText.MetaData
			{
				getSpeedEvent = GetSpeed,
				multiplier = (uiConfig?.speedometerMultiplier ?? 1f)
			};
			metaData.speedometer = new JetpackHMDSpeedometer.MetaData
			{
				getSpeedEvent = GetSpeed,
				multiplier = (uiConfig?.speedometerMultiplier ?? 1f),
				numberSpacing = (uiConfig?.speedometerNumberSpacing ?? 10),
				speedMeterPrefab = LoadPrefab("Speedometer")
			};
			metaData.altitude = new JetpackHMDAltitude.MetaData
			{
				getTargetTransform = GetPlayerTransform,
				multiplier = (uiConfig?.altimeterMultiplier ?? 1f)
			};
			metaData.altimeter = new JetpackHMDAltimeter.MetaData
			{
				getTargetTransform = GetPlayerTransform,
				multiplier = (uiConfig?.altimeterMultiplier ?? 1f),
				numberSpacing = (uiConfig?.altimeterNumberSpacing ?? 10),
				altimeterPrefab = LoadPrefab("Altimeter")
			};
			metaData.headingIndicator = new JetpackHMDHeadingIndicator.MetaData
			{
				getTargetTransform = GetPlayerTransform
			};
			metaData.accelerationIndicator = new JetpackHMDAccelerationIndicator.MetaData
			{
				getSpeedEvent = () => ((Object)(object)JetpackHMDPatches.playerControllerB != (Object)null) ? ((Vector3)(ref JetpackHMDPatches.playerControllerB.externalForces)).magnitude : 0f,
				multiplier = (uiConfig?.speedometerMultiplier ?? 1f)
			};
			metaData.verticalSpeedIndicator = new JetpackHMDVerticalSpeedIndicator.MetaData
			{
				getSpeedEvent = () => ((Object)(object)JetpackHMDPatches.playerControllerB != (Object)null) ? JetpackHMDPatches.playerControllerB.thisController.velocity.y : 0f,
				multiplier = (uiConfig?.speedometerMultiplier ?? 1f)
			};
			JetpackHMDManager.MetaData metaData2 = metaData;
			GameObject val = GameObject.Find("IngamePlayerHUD");
			GameObject val2 = LoadPrefab("Jetpack HMD");
			if ((Object)(object)val == (Object)null)
			{
				ManualLogSource? obj = logger;
				if (obj != null)
				{
					obj.LogFatal((object)"lethalHUD is null");
				}
			}
			else if ((Object)(object)val2 == (Object)null)
			{
				ManualLogSource? obj2 = logger;
				if (obj2 != null)
				{
					obj2.LogFatal((object)"jetpackHMDGameObject == null");
				}
			}
			else
			{
				if ((Object)(object)manager == (Object)null)
				{
					manager = Object.Instantiate<GameObject>(val2, val.transform).AddComponent<JetpackHMDManager>();
				}
				manager.Init(metaData2);
			}
			static Transform? GetPlayerTransform()
			{
				if (!((Object)(object)JetpackHMDPatches.playerControllerB != (Object)null))
				{
					return null;
				}
				return ((Component)JetpackHMDPatches.playerControllerB).transform;
			}
			static float GetSpeed()
			{
				//IL_0017: 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)
				if ((Object)(object)JetpackHMDPatches.playerControllerB != (Object)null)
				{
					Vector3 velocity = JetpackHMDPatches.playerControllerB.thisController.velocity;
					return ((Vector3)(ref velocity)).magnitude;
				}
				return 0f;
			}
		}

		private static GameObject? LoadPrefab(string prefabName)
		{
			try
			{
				if ((Object)(object)mainAssetBundle == (Object)null)
				{
					ManualLogSource? obj = logger;
					if (obj != null)
					{
						obj.LogError((object)$"{mainAssetBundle} is null");
					}
					return null;
				}
				return mainAssetBundle.LoadAsset<GameObject>(prefabName);
			}
			catch (Exception ex)
			{
				ManualLogSource? obj2 = logger;
				if (obj2 != null)
				{
					obj2.LogError((object)ex);
				}
				ManualLogSource? obj3 = logger;
				if (obj3 != null)
				{
					obj3.LogError((object)("\"" + prefabName + "\" Prefab load failure"));
				}
				return null;
			}
		}

		public static AssetBundle? LoadMainAssetBundle()
		{
			string text = "Rumi.JetpackHMD.JetpackHMD";
			try
			{
				using Stream stream = currentAssembly.GetManifestResourceStream(text);
				return AssetBundle.LoadFromStream(stream);
			}
			catch (Exception ex)
			{
				ManualLogSource? obj = logger;
				if (obj != null)
				{
					obj.LogFatal((object)ex);
				}
				ManualLogSource? obj2 = logger;
				if (obj2 != null)
				{
					obj2.LogFatal((object)("Main Asset bundle loading failed (Path : " + text));
				}
				return null;
			}
		}
	}
	public class JetpackHMDConfig
	{
		private readonly ConfigEntry<float> _scale;

		private readonly ConfigEntry<float> _pitchMeterPosSpacing;

		private readonly ConfigEntry<int> _pitchMeterNumberSpacing;

		private readonly ConfigEntry<float> _speedometerMultiplier;

		private readonly ConfigEntry<int> _speedometerNumberSpacing;

		private readonly ConfigEntry<float> _altimeterMultiplier;

		private readonly ConfigEntry<int> _altimeterNumberSpacing;

		private readonly ConfigEntry<int> _colorR;

		private readonly ConfigEntry<int> _colorG;

		private readonly ConfigEntry<int> _colorB;

		private readonly ConfigEntry<int> _colorA;

		private readonly ConfigEntry<bool> _enableTulipSnakes;

		public float scale
		{
			get
			{
				return _scale?.Value ?? 0.75f;
			}
			set
			{
				_scale.Value = value;
			}
		}

		public float pitchMeterPosSpacing
		{
			get
			{
				return _pitchMeterPosSpacing?.Value ?? 75f;
			}
			set
			{
				_pitchMeterPosSpacing.Value = value;
			}
		}

		public int pitchMeterNumberSpacing
		{
			get
			{
				return _pitchMeterNumberSpacing?.Value ?? 10;
			}
			set
			{
				_pitchMeterNumberSpacing.Value = value;
			}
		}

		public float speedometerMultiplier
		{
			get
			{
				return _speedometerMultiplier?.Value ?? 1f;
			}
			set
			{
				_speedometerMultiplier.Value = value;
			}
		}

		public int speedometerNumberSpacing
		{
			get
			{
				return _speedometerNumberSpacing?.Value ?? 10;
			}
			set
			{
				_speedometerNumberSpacing.Value = value;
			}
		}

		public float altimeterMultiplier
		{
			get
			{
				return _altimeterMultiplier?.Value ?? 1f;
			}
			set
			{
				_altimeterMultiplier.Value = value;
			}
		}

		public int altimeterNumberSpacing
		{
			get
			{
				return _altimeterNumberSpacing?.Value ?? 10;
			}
			set
			{
				_altimeterNumberSpacing.Value = value;
			}
		}

		public int colorR
		{
			get
			{
				return _colorR?.Value ?? 0;
			}
			set
			{
				_colorR.Value = value;
			}
		}

		public int colorG
		{
			get
			{
				return _colorG?.Value ?? 255;
			}
			set
			{
				_colorG.Value = value;
			}
		}

		public int colorB
		{
			get
			{
				return _colorB?.Value ?? 0;
			}
			set
			{
				_colorB.Value = value;
			}
		}

		public int colorA
		{
			get
			{
				return _colorA?.Value ?? 255;
			}
			set
			{
				_colorA.Value = value;
			}
		}

		public bool enableTulipSnakes
		{
			get
			{
				return _enableTulipSnakes?.Value ?? true;
			}
			set
			{
				_enableTulipSnakes.Value = value;
			}
		}

		public JetpackHMDConfig(ConfigFile config)
		{
			_scale = config.Bind<float>("General", "Scale", 1.5f, "Adjust the overall UI scale");
			_colorR = config.Bind<int>("General", "R Color", 0, "");
			_colorR.SettingChanged += delegate
			{
				JetpackHMD.UILoad();
			};
			_colorG = config.Bind<int>("General", "G Color", 255, "");
			_colorG.SettingChanged += delegate
			{
				JetpackHMD.UILoad();
			};
			_colorB = config.Bind<int>("General", "B Color", 0, "");
			_colorB.SettingChanged += delegate
			{
				JetpackHMD.UILoad();
			};
			_colorA = config.Bind<int>("General", "A Color", 255, "");
			_colorA.SettingChanged += delegate
			{
				JetpackHMD.UILoad();
			};
			_enableTulipSnakes = config.Bind<bool>("General", "Tulip Snake Enable", true, "Displays UI even when flying as Tulip Snake");
			_enableTulipSnakes.SettingChanged += delegate
			{
				JetpackHMD.UILoad();
			};
			_pitchMeterPosSpacing = config.Bind<float>("Pitch Meter", "Pos Spacing", 75f, (ConfigDescription)null);
			_pitchMeterPosSpacing.SettingChanged += delegate
			{
				JetpackHMD.UILoad();
			};
			_pitchMeterNumberSpacing = config.Bind<int>("Pitch Meter", "Number Spacing", 10, (ConfigDescription)null);
			_pitchMeterNumberSpacing.SettingChanged += delegate
			{
				JetpackHMD.UILoad();
			};
			_speedometerMultiplier = config.Bind<float>("Speedometer", "Multiplier", 1f, (ConfigDescription)null);
			_speedometerMultiplier.SettingChanged += delegate
			{
				JetpackHMD.UILoad();
			};
			_speedometerNumberSpacing = config.Bind<int>("Speedometer", "Number Spacing", 10, (ConfigDescription)null);
			_speedometerNumberSpacing.SettingChanged += delegate
			{
				JetpackHMD.UILoad();
			};
			_altimeterMultiplier = config.Bind<float>("Altimeter", "Multiplier", 1f, (ConfigDescription)null);
			_altimeterMultiplier.SettingChanged += delegate
			{
				JetpackHMD.UILoad();
			};
			_altimeterNumberSpacing = config.Bind<int>("Altimeter", "Number Spacing", 10, (ConfigDescription)null);
			_altimeterNumberSpacing.SettingChanged += delegate
			{
				JetpackHMD.UILoad();
			};
			try
			{
				LethalConfigPatch();
			}
			catch (FileNotFoundException ex)
			{
				ManualLogSource? logger = JetpackHMD.logger;
				if (logger != null)
				{
					logger.LogError((object)ex);
				}
				ManualLogSource? logger2 = JetpackHMD.logger;
				if (logger2 != null)
				{
					logger2.LogWarning((object)"Lethal Config Patch Fail! (This is not a bug and occurs when LethalConfig is not present)");
				}
			}
			catch (Exception ex2)
			{
				ManualLogSource? logger3 = JetpackHMD.logger;
				if (logger3 != null)
				{
					logger3.LogError((object)ex2);
				}
				ManualLogSource? logger4 = JetpackHMD.logger;
				if (logger4 != null)
				{
					logger4.LogError((object)"Lethal Config Patch Fail!");
				}
			}
		}

		private void LethalConfigPatch()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_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_00ce: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Expected O, but got Unknown
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Expected O, but got Unknown
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Expected O, but got Unknown
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Expected O, but got Unknown
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Expected O, but got Unknown
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Expected O, but got Unknown
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Expected O, but got Unknown
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Expected O, but got Unknown
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Expected O, but got Unknown
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Expected O, but got Unknown
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Expected O, but got Unknown
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Expected O, but got Unknown
			ConfigEntry<float> obj = _scale;
			FloatSliderOptions val = new FloatSliderOptions();
			((BaseRangeOptions<float>)val).Min = 0.5f;
			((BaseRangeOptions<float>)val).Max = 2f;
			((BaseOptions)val).RequiresRestart = false;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(obj, val));
			ConfigEntry<int> obj2 = _colorR;
			IntSliderOptions val2 = new IntSliderOptions();
			((BaseRangeOptions<int>)val2).Min = 0;
			((BaseRangeOptions<int>)val2).Max = 255;
			((BaseOptions)val2).RequiresRestart = false;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(obj2, val2));
			ConfigEntry<int> obj3 = _colorG;
			IntSliderOptions val3 = new IntSliderOptions();
			((BaseRangeOptions<int>)val3).Min = 0;
			((BaseRangeOptions<int>)val3).Max = 255;
			((BaseOptions)val3).RequiresRestart = false;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(obj3, val3));
			ConfigEntry<int> obj4 = _colorB;
			IntSliderOptions val4 = new IntSliderOptions();
			((BaseRangeOptions<int>)val4).Min = 0;
			((BaseRangeOptions<int>)val4).Max = 255;
			((BaseOptions)val4).RequiresRestart = false;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(obj4, val4));
			ConfigEntry<int> obj5 = _colorA;
			IntSliderOptions val5 = new IntSliderOptions();
			((BaseRangeOptions<int>)val5).Min = 0;
			((BaseRangeOptions<int>)val5).Max = 255;
			((BaseOptions)val5).RequiresRestart = false;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(obj5, val5));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(_enableTulipSnakes, false));
			ConfigEntry<float> obj6 = _pitchMeterPosSpacing;
			FloatSliderOptions val6 = new FloatSliderOptions();
			((BaseRangeOptions<float>)val6).Min = 10f;
			((BaseRangeOptions<float>)val6).Max = 200f;
			((BaseOptions)val6).RequiresRestart = false;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(obj6, val6));
			ConfigEntry<int> obj7 = _pitchMeterNumberSpacing;
			IntSliderOptions val7 = new IntSliderOptions();
			((BaseRangeOptions<int>)val7).Min = 1;
			((BaseRangeOptions<int>)val7).Max = 360;
			((BaseOptions)val7).RequiresRestart = false;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(obj7, val7));
			ConfigEntry<float> obj8 = _speedometerMultiplier;
			FloatSliderOptions val8 = new FloatSliderOptions();
			((BaseRangeOptions<float>)val8).Min = 0.125f;
			((BaseRangeOptions<float>)val8).Max = 4f;
			((BaseOptions)val8).RequiresRestart = false;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(obj8, val8));
			ConfigEntry<int> obj9 = _speedometerNumberSpacing;
			IntSliderOptions val9 = new IntSliderOptions();
			((BaseRangeOptions<int>)val9).Min = 1;
			((BaseRangeOptions<int>)val9).Max = 100;
			((BaseOptions)val9).RequiresRestart = false;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(obj9, val9));
			ConfigEntry<float> obj10 = _altimeterMultiplier;
			FloatSliderOptions val10 = new FloatSliderOptions();
			((BaseRangeOptions<float>)val10).Min = 0.125f;
			((BaseRangeOptions<float>)val10).Max = 4f;
			((BaseOptions)val10).RequiresRestart = false;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(obj10, val10));
			ConfigEntry<int> obj11 = _altimeterNumberSpacing;
			IntSliderOptions val11 = new IntSliderOptions();
			((BaseRangeOptions<int>)val11).Min = 1;
			((BaseRangeOptions<int>)val11).Max = 100;
			((BaseOptions)val11).RequiresRestart = false;
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(obj11, val11));
		}
	}
	internal class JetpackHMDPatches
	{
		public static PlayerControllerB? playerControllerB;

		[HarmonyPatch(typeof(PlayerControllerB), "Awake")]
		[HarmonyPostfix]
		private static void PlayerControllerB_Awake_Postfix(ref PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject) && __instance.isPlayerControlled && !__instance.isPlayerDead)
			{
				playerControllerB = __instance;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		private static void PlayerControllerB_Update_Postfix(ref PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject) && __instance.isPlayerControlled && !__instance.isPlayerDead)
			{
				playerControllerB = __instance;
			}
		}
	}
	public sealed class JetpackHMDAccelerationIndicator : MonoBehaviour
	{
		public struct MetaData
		{
			public Func<float> getSpeedEvent;

			public float multiplier;
		}

		private float multiplier = 1f;

		private TMP_Text? text;

		private float realSpeed;

		private event Func<float>? getSpeedEvent;

		public void Init(MetaData metaData)
		{
			this.getSpeedEvent = metaData.getSpeedEvent;
			multiplier = metaData.multiplier;
			text = ((Component)this).GetComponent<TMP_Text>();
		}

		private void Update()
		{
			if (!((Object)(object)text == (Object)null))
			{
				realSpeed = Mathf.Lerp(realSpeed, (this.getSpeedEvent?.Invoke() * multiplier).GetValueOrDefault(), 7.5f * Time.smoothDeltaTime);
				text.text = "<voffset=2.5><size=11>ACC</size></voffset> " + Mathf.Round(realSpeed);
			}
		}
	}
	public sealed class JetpackHMDAltimeter : MonoBehaviour
	{
		public struct MetaData
		{
			public Func<Transform?> getTargetTransform;

			public float multiplier;

			public int numberSpacing;

			public GameObject? altimeterPrefab;
		}

		private float multiplier;

		private const float posSpacing = 66f;

		private int numberSpacing;

		private float altitude;

		private event Func<Transform?>? getTargetTransform;

		public void Init(MetaData metaData)
		{
			//IL_009a: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)metaData.altimeterPrefab == (Object)null)
			{
				return;
			}
			Transform child = ((Component)this).transform.GetChild("Offset");
			if ((Object)(object)child == (Object)null)
			{
				return;
			}
			this.getTargetTransform = metaData.getTargetTransform;
			multiplier = metaData.multiplier;
			numberSpacing = metaData.numberSpacing;
			for (int i = 1; i < child.childCount; i++)
			{
				Object.Destroy((Object)(object)((Component)child.GetChild(i)).gameObject);
			}
			if (numberSpacing > 0)
			{
				float num = 0f;
				for (int j = numberSpacing; j <= 500; j += numberSpacing)
				{
					RectTransform val = (RectTransform)Object.Instantiate<GameObject>(metaData.altimeterPrefab, child).transform;
					val.anchoredPosition = new Vector2(0f, num);
					((Component)((Transform)val).GetChild(0)).GetComponent<TMP_Text>().text = j.ToString();
					num += 66f;
				}
			}
		}

		private void LateUpdate()
		{
			//IL_0097: 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)
			Transform val = this.getTargetTransform?.Invoke();
			if (!((Object)(object)val == (Object)null))
			{
				altitude = Mathf.Lerp(altitude, Mathf.Clamp((val.GetAltitude() * multiplier) ?? 500f, 0f, 500f), 7.5f * Time.smoothDeltaTime);
				((RectTransform)((Component)this).transform).anchoredPosition = new Vector2(0f, (0f - altitude) * 66f / (float)numberSpacing);
			}
		}
	}
	public sealed class JetpackHMDAltitude : MonoBehaviour
	{
		public struct MetaData
		{
			public Func<Transform?> getTargetTransform;

			public float multiplier;
		}

		private float multiplier = 1f;

		private Transform? digit100;

		private Transform? digit10;

		private Transform? digit1;

		private Transform? digit0_01;

		private float realAltitude;

		private event Func<Transform?>? getTargetTransform;

		public void Init(MetaData metaData)
		{
			Transform child = ((Component)this).transform.GetChild("Offset");
			if (!((Object)(object)child == (Object)null))
			{
				this.getTargetTransform = metaData.getTargetTransform;
				multiplier = metaData.multiplier;
				digit100 = child.GetChild(0);
				digit10 = child.GetChild(1);
				digit1 = child.GetChild(2);
				digit0_01 = child.GetChild(3);
			}
		}

		private void LateUpdate()
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			Transform val = this.getTargetTransform?.Invoke();
			if (!((Object)(object)val == (Object)null) && !((Object)(object)digit100 == (Object)null) && !((Object)(object)digit10 == (Object)null) && !((Object)(object)digit1 == (Object)null) && !((Object)(object)digit0_01 == (Object)null))
			{
				realAltitude = Mathf.Lerp(realAltitude, Mathf.Clamp((val.GetAltitude() * multiplier) ?? 999f, 0f, 999f), 7.5f * Time.smoothDeltaTime);
				RectTransform val2 = (RectTransform)digit100;
				float num = realAltitude * 0.01f;
				num = Mathf.Floor(num) + Mathf.Clamp01((Mathf.Repeat(num, 1f) - 0.99f) * 100f);
				if (num >= 1f)
				{
					val2.anchoredPosition = new Vector2(-22f, (0f - (Mathf.Repeat(num, 10f) + 2f)) * 17.7f);
				}
				else
				{
					val2.anchoredPosition = new Vector2(-22f, (0f - num) * 17.7f);
				}
				RectTransform val3 = (RectTransform)digit10;
				float num2 = realAltitude * 0.1f;
				num2 = Mathf.Floor(num2) + Mathf.Clamp01((Mathf.Repeat(num2, 1f) - 0.9f) * 10f);
				if (num2 >= 1f)
				{
					val3.anchoredPosition = new Vector2(-11f, (0f - (Mathf.Repeat(num2, 10f) + 2f)) * 17.7f);
				}
				else
				{
					val3.anchoredPosition = new Vector2(-11f, (0f - num2) * 17.7f);
				}
				((RectTransform)digit1).anchoredPosition = new Vector2(0f, (0f - Mathf.Repeat(Mathf.Clamp(realAltitude, 0f, float.MaxValue), 10f)) * 17.7f);
				RectTransform val4 = (RectTransform)digit0_01;
				float num3 = Mathf.Clamp(realAltitude * 5f, 0f, float.MaxValue);
				val4.anchoredPosition = new Vector2(11.5f, (0f - Mathf.Repeat(num3, 5f)) * 7.965f);
			}
		}
	}
	public sealed class JetpackHMDHeadingIndicator : MonoBehaviour
	{
		public struct MetaData
		{
			public Func<Transform?> getTargetTransform;
		}

		private float realYaw;

		private event Func<Transform?>? getTargetTransform;

		public void Init(MetaData metaData)
		{
			this.getTargetTransform = metaData.getTargetTransform;
		}

		private void Update()
		{
			//IL_001e: 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_003c: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0069: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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_00cd: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			Transform val = this.getTargetTransform?.Invoke();
			if (!((Object)(object)val == (Object)null))
			{
				Quaternion val2 = val.rotation * Quaternion.Euler(-90f, 0f, 0f);
				if (val.eulerAngles.x <= 0.1f)
				{
					val2 *= Quaternion.Euler(0.01f, 0f, 0f);
				}
				else if (val.eulerAngles.x >= 359.9f)
				{
					val2 *= Quaternion.Euler(-0.01f, 0f, 0f);
				}
				if (val.eulerAngles.x >= 180f && val.eulerAngles.x <= 180.1f)
				{
					val2 *= Quaternion.Euler(0.01f, 0f, 0f);
				}
				else if (val.eulerAngles.x >= 179.9f && val.eulerAngles.x <= 180f)
				{
					val2 *= Quaternion.Euler(-0.01f, 0f, 0f);
				}
				realYaw = Mathf.LerpAngle(realYaw, Mathf.Atan2(2f * (val2.y * val2.w + val2.x * val2.z), 1f - 2f * (val2.x * val2.x + val2.y * val2.y)) * 57.29578f, 7.5f * Time.smoothDeltaTime);
				((Component)this).transform.localEulerAngles = new Vector3(0f, 0f, realYaw);
			}
		}
	}
	public sealed class JetpackHMDManager : MonoBehaviour
	{
		public struct MetaData
		{
			public Func<bool> getEnableEvent;

			public Func<bool> getEnableWarningEvent;

			public Func<float> getScaleEvent;

			public JetpackHMDRoll.MetaData roll;

			public JetpackHMDPitchMeter.MetaData pitchMeter;

			public JetpackHMDSpeedText.MetaData speedText;

			public JetpackHMDSpeedometer.MetaData speedometer;

			public JetpackHMDAltitude.MetaData altitude;

			public JetpackHMDAltimeter.MetaData altimeter;

			public JetpackHMDAccelerationIndicator.MetaData accelerationIndicator;

			public JetpackHMDVerticalSpeedIndicator.MetaData verticalSpeedIndicator;

			public JetpackHMDHeadingIndicator.MetaData headingIndicator;

			public Color color;
		}

		private CanvasGroup? canvasGroup;

		private CanvasGroup? jetpackMeterContainer;

		private bool jetpackWarningCompatibleDisable = true;

		private MetaData metaData;

		private void OnEnable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Canvas.preWillRenderCanvases += new WillRenderCanvases(ScaleUpdate);
		}

		private void OnDisable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Canvas.preWillRenderCanvases -= new WillRenderCanvases(ScaleUpdate);
		}

		private void Update()
		{
			if ((Object)(object)canvasGroup == (Object)null)
			{
				return;
			}
			Func<bool> getEnableEvent = metaData.getEnableEvent;
			if (getEnableEvent != null && getEnableEvent())
			{
				canvasGroup.alpha = Mathf.Lerp(canvasGroup.alpha, 1f, 4f * Time.smoothDeltaTime);
				if (canvasGroup.alpha >= 0.99f)
				{
					canvasGroup.alpha = 1f;
				}
				Transform child = ((Component)this).transform.GetChild(0);
				if ((Object)(object)child != (Object)null && !((Component)child).gameObject.activeSelf)
				{
					((Component)child).gameObject.SetActive(true);
				}
			}
			else
			{
				canvasGroup.alpha = Mathf.MoveTowards(canvasGroup.alpha, 0f, 4f * Time.smoothDeltaTime);
				Transform child2 = ((Component)this).transform.GetChild(0);
				if (canvasGroup.alpha <= 0f && (Object)(object)child2 != (Object)null && ((Component)child2).gameObject.activeSelf)
				{
					((Component)child2).gameObject.SetActive(false);
				}
			}
		}

		private void LateUpdate()
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)canvasGroup == (Object)null)
			{
				return;
			}
			if (!jetpackWarningCompatibleDisable)
			{
				GameObject val = null;
				GameObject[] array = Object.FindObjectsByType<GameObject>((FindObjectsInactive)1, (FindObjectsSortMode)0);
				foreach (GameObject val2 in array)
				{
					if (((Object)val2).name == "jetpackMeterContainer")
					{
						val = val2;
					}
				}
				if ((Object)(object)val != (Object)null)
				{
					jetpackMeterContainer = val.GetComponent<CanvasGroup>();
					if ((Object)(object)jetpackMeterContainer != (Object)null)
					{
						RectTransform val3 = (RectTransform)((Component)jetpackMeterContainer).transform;
						val3.anchorMin = new Vector2(0.59f, 0.5f);
						val3.anchorMax = new Vector2(0.59f, 0.5f);
						val3.sizeDelta = new Vector2(18f, 78.5f);
						val3.pivot = new Vector2(0f, 0.5f);
					}
				}
				jetpackWarningCompatibleDisable = true;
			}
			if (!((Object)(object)jetpackMeterContainer != (Object)null))
			{
				return;
			}
			if (canvasGroup.alpha > 0f && !((Component)jetpackMeterContainer).gameObject.activeSelf)
			{
				((Component)jetpackMeterContainer).gameObject.SetActive(true);
			}
			Func<bool> getEnableWarningEvent = metaData.getEnableWarningEvent;
			if (getEnableWarningEvent != null && getEnableWarningEvent())
			{
				jetpackMeterContainer.alpha = Mathf.Lerp(jetpackMeterContainer.alpha, 1f, 4f * Time.smoothDeltaTime);
				if (jetpackMeterContainer.alpha >= 0.99f)
				{
					jetpackMeterContainer.alpha = 1f;
				}
			}
			else
			{
				jetpackMeterContainer.alpha = Mathf.MoveTowards(jetpackMeterContainer.alpha, 0f, 4f * Time.smoothDeltaTime);
			}
			float num = Mathf.Clamp(metaData.getScaleEvent?.Invoke() ?? 1f, 0.5f, 2f) * 0.5f;
			((RectTransform)((Component)jetpackMeterContainer).transform).anchoredPosition = new Vector2(72f * num, 0f);
		}

		private void ScaleUpdate()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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)
			float num = Mathf.Clamp(metaData.getScaleEvent?.Invoke() ?? 1f, 0.5f, 2f) * 0.5f;
			RectTransform val = (RectTransform)((Component)this).transform;
			((Transform)val).localScale = Vector3.one * num;
			Rect rect = ((RectTransform)((Transform)val).parent).rect;
			Vector3 val2 = Vector2.op_Implicit(((Rect)(ref rect)).size / num);
			val.SetSizeWithCurrentAnchors((Axis)0, val2.x);
			val.SetSizeWithCurrentAnchors((Axis)1, val2.y);
		}

		public void Init(MetaData metaData)
		{
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			this.metaData = metaData;
			canvasGroup = ((Component)this).GetComponent<CanvasGroup>();
			jetpackWarningCompatibleDisable = false;
			ScaleUpdate();
			Transform child = ((Component)this).transform.GetChild(0);
			if ((Object)(object)child != (Object)null)
			{
				Transform child2 = child.GetChild("Roll Mask");
				if ((Object)(object)child2 != (Object)null)
				{
					Transform child3 = child2.GetChild("Roll");
					if ((Object)(object)child3 != (Object)null)
					{
						JetpackHMDRoll jetpackHMDRoll = default(JetpackHMDRoll);
						if (!((Component)child3).gameObject.TryGetComponent<JetpackHMDRoll>(ref jetpackHMDRoll))
						{
							jetpackHMDRoll = ((Component)child3).gameObject.AddComponent<JetpackHMDRoll>();
						}
						jetpackHMDRoll.Init(metaData.roll);
						Transform child4 = child3.GetChild("Pitch Meter");
						if ((Object)(object)child4 != (Object)null)
						{
							JetpackHMDPitchMeter jetpackHMDPitchMeter = default(JetpackHMDPitchMeter);
							if (!((Component)child4).gameObject.TryGetComponent<JetpackHMDPitchMeter>(ref jetpackHMDPitchMeter))
							{
								jetpackHMDPitchMeter = ((Component)child4).gameObject.AddComponent<JetpackHMDPitchMeter>();
							}
							jetpackHMDPitchMeter.Init(metaData.pitchMeter);
						}
					}
				}
				Transform child5 = child.GetChild("Speed Mask");
				if ((Object)(object)child5 != (Object)null)
				{
					Transform child6 = child5.GetChild("Speed Text");
					if ((Object)(object)child6 != (Object)null)
					{
						JetpackHMDSpeedText jetpackHMDSpeedText = default(JetpackHMDSpeedText);
						if (!((Component)child6).gameObject.TryGetComponent<JetpackHMDSpeedText>(ref jetpackHMDSpeedText))
						{
							jetpackHMDSpeedText = ((Component)child6).gameObject.AddComponent<JetpackHMDSpeedText>();
						}
						jetpackHMDSpeedText.Init(metaData.speedText);
					}
					Transform child7 = child5.GetChild("Speedometer Mask");
					if ((Object)(object)child7 != (Object)null)
					{
						Transform child8 = child7.GetChild("Speedometer");
						if ((Object)(object)child8 != (Object)null)
						{
							JetpackHMDSpeedometer jetpackHMDSpeedometer = default(JetpackHMDSpeedometer);
							if (!((Component)child8).gameObject.TryGetComponent<JetpackHMDSpeedometer>(ref jetpackHMDSpeedometer))
							{
								jetpackHMDSpeedometer = ((Component)child8).gameObject.AddComponent<JetpackHMDSpeedometer>();
							}
							jetpackHMDSpeedometer.Init(metaData.speedometer);
						}
					}
				}
				Transform child9 = child.GetChild("Altitude Mask");
				if ((Object)(object)child9 != (Object)null)
				{
					Transform child10 = child9.GetChild("Altitude");
					if ((Object)(object)child10 != (Object)null)
					{
						JetpackHMDAltitude jetpackHMDAltitude = default(JetpackHMDAltitude);
						if (!((Component)child10).gameObject.TryGetComponent<JetpackHMDAltitude>(ref jetpackHMDAltitude))
						{
							jetpackHMDAltitude = ((Component)child10).gameObject.AddComponent<JetpackHMDAltitude>();
						}
						jetpackHMDAltitude.Init(metaData.altitude);
					}
					Transform child11 = child9.GetChild("Altimeter Mask");
					if ((Object)(object)child11 != (Object)null)
					{
						Transform child12 = child11.GetChild("Altimeter");
						if ((Object)(object)child12 != (Object)null)
						{
							JetpackHMDAltimeter jetpackHMDAltimeter = default(JetpackHMDAltimeter);
							if (!((Component)child12).gameObject.TryGetComponent<JetpackHMDAltimeter>(ref jetpackHMDAltimeter))
							{
								jetpackHMDAltimeter = ((Component)child12).gameObject.AddComponent<JetpackHMDAltimeter>();
							}
							jetpackHMDAltimeter.Init(metaData.altimeter);
						}
					}
				}
				Transform child13 = child.GetChild("Acceleration Indicator");
				if ((Object)(object)child13 != (Object)null)
				{
					JetpackHMDAccelerationIndicator jetpackHMDAccelerationIndicator = default(JetpackHMDAccelerationIndicator);
					if (!((Component)child13).TryGetComponent<JetpackHMDAccelerationIndicator>(ref jetpackHMDAccelerationIndicator))
					{
						jetpackHMDAccelerationIndicator = ((Component)child13).gameObject.AddComponent<JetpackHMDAccelerationIndicator>();
					}
					jetpackHMDAccelerationIndicator.Init(metaData.accelerationIndicator);
				}
				Transform child14 = child.GetChild("Vertical Speed Indicator");
				if ((Object)(object)child14 != (Object)null)
				{
					JetpackHMDVerticalSpeedIndicator jetpackHMDVerticalSpeedIndicator = default(JetpackHMDVerticalSpeedIndicator);
					if (!((Component)child14).TryGetComponent<JetpackHMDVerticalSpeedIndicator>(ref jetpackHMDVerticalSpeedIndicator))
					{
						jetpackHMDVerticalSpeedIndicator = ((Component)child14).gameObject.AddComponent<JetpackHMDVerticalSpeedIndicator>();
					}
					jetpackHMDVerticalSpeedIndicator.Init(metaData.verticalSpeedIndicator);
				}
				Transform child15 = child.GetChild("Heading Indicator Mask");
				if ((Object)(object)child15 != (Object)null)
				{
					Transform child16 = child15.GetChild("Heading Indicator");
					if ((Object)(object)child16 != (Object)null)
					{
						JetpackHMDHeadingIndicator jetpackHMDHeadingIndicator = default(JetpackHMDHeadingIndicator);
						if (!((Component)child16).gameObject.TryGetComponent<JetpackHMDHeadingIndicator>(ref jetpackHMDHeadingIndicator))
						{
							jetpackHMDHeadingIndicator = ((Component)child16).gameObject.AddComponent<JetpackHMDHeadingIndicator>();
						}
						jetpackHMDHeadingIndicator.Init(metaData.headingIndicator);
					}
				}
			}
			Graphic[] componentsInChildren = ((Component)this).GetComponentsInChildren<Graphic>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].color = metaData.color;
			}
		}
	}
	public sealed class JetpackHMDPitchMeter : MonoBehaviour
	{
		public struct MetaData
		{
			public Func<Transform?> getTargetTransform;

			public float posSpacing;

			public int numberSpacing;

			public GameObject? minusPitchMeterPrefab;

			public GameObject? plusPitchMeterPrefab;
		}

		private float posSpacing;

		private int numberSpacing;

		private float pitch;

		private event Func<Transform?>? getTargetTransform;

		public void Init(MetaData metaData)
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)metaData.minusPitchMeterPrefab == (Object)null || (Object)(object)metaData.plusPitchMeterPrefab == (Object)null)
			{
				return;
			}
			this.getTargetTransform = metaData.getTargetTransform;
			posSpacing = metaData.posSpacing;
			numberSpacing = metaData.numberSpacing;
			for (int i = 1; i < ((Component)this).transform.childCount; i++)
			{
				Object.Destroy((Object)(object)((Component)((Component)this).transform.GetChild(i)).gameObject);
			}
			if (metaData.numberSpacing > 0)
			{
				float num = 0f;
				int num2 = 0;
				while (num2 < 180)
				{
					num += posSpacing;
					num2 += numberSpacing;
					GameObject obj = Object.Instantiate<GameObject>(metaData.minusPitchMeterPrefab, ((Component)this).transform);
					((RectTransform)obj.transform).anchoredPosition = new Vector2(0f, 0f - num);
					TMP_Text component = ((Component)obj.transform.GetChild(0)).GetComponent<TMP_Text>();
					TMP_Text component2 = ((Component)obj.transform.GetChild(1)).GetComponent<TMP_Text>();
					component.text = num2.ToString();
					component2.text = num2.ToString();
					GameObject obj2 = Object.Instantiate<GameObject>(metaData.plusPitchMeterPrefab, ((Component)this).transform);
					((RectTransform)obj2.transform).anchoredPosition = new Vector2(0f, num);
					TMP_Text component3 = ((Component)obj2.transform.GetChild(0)).GetComponent<TMP_Text>();
					TMP_Text component4 = ((Component)obj2.transform.GetChild(1)).GetComponent<TMP_Text>();
					component3.text = num2.ToString();
					component4.text = num2.ToString();
				}
			}
		}

		private void LateUpdate()
		{
			//IL_001e: 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_003c: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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)
			//IL_00ab: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_0135: 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)
			Transform val = this.getTargetTransform?.Invoke();
			if (!((Object)(object)val == (Object)null))
			{
				Quaternion val2 = val.rotation * Quaternion.Euler(-90f, 0f, 0f);
				if (val.eulerAngles.x <= 0.1f)
				{
					val2 *= Quaternion.Euler(0.04f, 0f, 0f);
				}
				else if (val.eulerAngles.x >= 359.9f)
				{
					val2 *= Quaternion.Euler(-0.04f, 0f, 0f);
				}
				float num = Mathf.Asin(2f * (val2.x * val2.w - val2.y * val2.z)) * 57.29578f;
				if ((num + 90f >= -0.08f && num + 90f <= 0.08f) || !float.IsNormal(pitch))
				{
					pitch = Mathf.LerpAngle(pitch, -90f, 7.5f * Time.smoothDeltaTime);
				}
				else
				{
					pitch = Mathf.LerpAngle(pitch, num, 7.5f * Time.smoothDeltaTime);
				}
				((RectTransform)((Component)this).transform).anchoredPosition = new Vector2(0f, pitch * posSpacing / (float)numberSpacing);
			}
		}
	}
	public sealed class JetpackHMDRoll : MonoBehaviour
	{
		public struct MetaData
		{
			public Func<Transform?> getTargetTransform;
		}

		private float roll;

		private event Func<Transform?>? getTargetTransform;

		public void Init(MetaData metaData)
		{
			this.getTargetTransform = metaData.getTargetTransform;
		}

		private void LateUpdate()
		{
			//IL_001e: 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_003c: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0069: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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_00cd: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			Transform val = this.getTargetTransform?.Invoke();
			if (!((Object)(object)val == (Object)null))
			{
				Quaternion val2 = val.rotation * Quaternion.Euler(-90f, 0f, 0f);
				if (val.eulerAngles.x <= 0.1f)
				{
					val2 *= Quaternion.Euler(0.01f, 0f, 0f);
				}
				else if (val.eulerAngles.x >= 359.9f)
				{
					val2 *= Quaternion.Euler(-0.01f, 0f, 0f);
				}
				if (val.eulerAngles.x >= 180f && val.eulerAngles.x <= 180.1f)
				{
					val2 *= Quaternion.Euler(0.01f, 0f, 0f);
				}
				else if (val.eulerAngles.x >= 179.9f && val.eulerAngles.x <= 180f)
				{
					val2 *= Quaternion.Euler(-0.01f, 0f, 0f);
				}
				roll = Mathf.LerpAngle(roll, (0f - Mathf.Atan2(2f * (val2.x * val2.y + val2.z * val2.w), 1f - 2f * (val2.x * val2.x + val2.z * val2.z))) * 57.29578f, 7.5f * Time.smoothDeltaTime);
				if ((roll >= 0.01f && roll <= 0.01f) || !float.IsNormal(roll))
				{
					roll = 0f;
				}
				((Component)this).transform.localEulerAngles = new Vector3(0f, 0f, roll);
			}
		}
	}
	public sealed class JetpackHMDSpeedometer : MonoBehaviour
	{
		public struct MetaData
		{
			public Func<float> getSpeedEvent;

			public float multiplier;

			public int numberSpacing;

			public GameObject? speedMeterPrefab;
		}

		private float multiplier;

		private const float posSpacing = 66f;

		private int numberSpacing;

		private float speed;

		private event Func<float>? getSpeedEvent;

		public void Init(MetaData metaData)
		{
			//IL_009a: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)metaData.speedMeterPrefab == (Object)null)
			{
				return;
			}
			Transform child = ((Component)this).transform.GetChild("Offset");
			if ((Object)(object)child == (Object)null)
			{
				return;
			}
			this.getSpeedEvent = metaData.getSpeedEvent;
			multiplier = metaData.multiplier;
			numberSpacing = metaData.numberSpacing;
			for (int i = 1; i < child.childCount; i++)
			{
				Object.Destroy((Object)(object)((Component)child.GetChild(i)).gameObject);
			}
			if (numberSpacing > 0)
			{
				float num = 0f;
				for (int j = numberSpacing; j <= 200; j += numberSpacing)
				{
					RectTransform val = (RectTransform)Object.Instantiate<GameObject>(metaData.speedMeterPrefab, child).transform;
					val.anchoredPosition = new Vector2(0f, num);
					((Component)((Transform)val).GetChild(0)).GetComponent<TMP_Text>().text = j.ToString();
					num += 66f;
				}
			}
		}

		private void LateUpdate()
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			speed = Mathf.Lerp(speed, Mathf.Clamp((this.getSpeedEvent?.Invoke() * multiplier).GetValueOrDefault(), 0f, 200f), 7.5f * Time.smoothDeltaTime);
			((RectTransform)((Component)this).transform).anchoredPosition = new Vector2(0f, (0f - speed) * 66f / (float)numberSpacing);
		}
	}
	public sealed class JetpackHMDSpeedText : MonoBehaviour
	{
		public struct MetaData
		{
			public Func<float> getSpeedEvent;

			public float multiplier;
		}

		private float multiplier = 1f;

		private Transform? digit100;

		private Transform? digit10;

		private Transform? digit1;

		private float realSpeed;

		private event Func<float>? getSpeedEvent;

		public void Init(MetaData metaData)
		{
			Transform child = ((Component)this).transform.GetChild("Offset");
			if (!((Object)(object)child == (Object)null))
			{
				this.getSpeedEvent = metaData.getSpeedEvent;
				multiplier = metaData.multiplier;
				digit100 = child.GetChild(0);
				digit10 = child.GetChild(1);
				digit1 = child.GetChild(2);
			}
		}

		private void LateUpdate()
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_012b: 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_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)digit100 == (Object)null) && !((Object)(object)digit10 == (Object)null) && !((Object)(object)digit1 == (Object)null))
			{
				realSpeed = Mathf.Lerp(realSpeed, Mathf.Clamp((this.getSpeedEvent?.Invoke() * multiplier).GetValueOrDefault(), 0f, 999f), 7.5f * Time.smoothDeltaTime);
				RectTransform val = (RectTransform)digit100;
				float num = realSpeed * 0.01f;
				num = Mathf.Floor(num) + Mathf.Clamp01((Mathf.Repeat(num, 1f) - 0.99f) * 100f);
				if (num >= 1f)
				{
					val.anchoredPosition = new Vector2(-22f, (0f - (Mathf.Repeat(num, 10f) + 2f)) * 17.7f);
				}
				else
				{
					val.anchoredPosition = new Vector2(-22f, (0f - num) * 17.7f);
				}
				RectTransform val2 = (RectTransform)digit10;
				float num2 = realSpeed * 0.1f;
				num2 = Mathf.Floor(num2) + Mathf.Clamp01((Mathf.Repeat(num2, 1f) - 0.9f) * 10f);
				if (num2 >= 1f)
				{
					val2.anchoredPosition = new Vector2(-11f, (0f - (Mathf.Repeat(num2, 10f) + 2f)) * 17.7f);
				}
				else
				{
					val2.anchoredPosition = new Vector2(-11f, (0f - num2) * 17.7f);
				}
				((RectTransform)digit1).anchoredPosition = new Vector2(0f, (0f - Mathf.Repeat(Mathf.Clamp(realSpeed, 0f, float.MaxValue), 10f)) * 17.7f);
			}
		}
	}
	public static class JetpackHMDUtility
	{
		public static Transform? GetChild(this Transform transform, string name)
		{
			for (int i = 0; i < transform.childCount; i++)
			{
				Transform child = transform.GetChild(i);
				if ((Object)(object)child != (Object)null && ((Object)child).name == name)
				{
					return child;
				}
			}
			return null;
		}

		public static float? GetAltitude(this Transform transform)
		{
			//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)
			//IL_0058: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit[] array = Physics.RaycastAll(transform.position, Vector3.down, 1000f, ~LayerMask.GetMask(new string[6] { "Player", "Enemies", "LineOfSight", "PlaceableShipObjects", "PhysicsObject", "MapHazards" }), (QueryTriggerInteraction)1);
			if (array.Length != 0)
			{
				float y2 = transform.position.y;
				RaycastHit val = array.Aggregate((RaycastHit x, RaycastHit y) => (!(((RaycastHit)(ref x)).point.y > ((RaycastHit)(ref y)).point.y)) ? y : x);
				return y2 - ((RaycastHit)(ref val)).point.y;
			}
			return null;
		}
	}
	public sealed class JetpackHMDVerticalSpeedIndicator : MonoBehaviour
	{
		public struct MetaData
		{
			public Func<float> getSpeedEvent;

			public float multiplier;
		}

		private float multiplier = 1f;

		private TMP_Text? text;

		private float realSpeed;

		private event Func<float>? getSpeedEvent;

		public void Init(MetaData metaData)
		{
			this.getSpeedEvent = metaData.getSpeedEvent;
			multiplier = metaData.multiplier;
			text = ((Component)this).GetComponent<TMP_Text>();
		}

		private void Update()
		{
			if (!((Object)(object)text == (Object)null))
			{
				realSpeed = Mathf.Lerp(realSpeed, (this.getSpeedEvent?.Invoke() * multiplier).GetValueOrDefault(), 7.5f * Time.smoothDeltaTime);
				text.text = Mathf.Round(realSpeed) + " VS";
			}
		}
	}
}