Decompiled source of zPaulins A10 Warthog v1.0.0

BepInEx/plugins/HowToFish.Warthog/HowToFish.ModKit.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("HowToFish.ModKit")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5554268e42ae4803814c23b41e24d3c196693022")]
[assembly: AssemblyProduct("HowToFish.ModKit")]
[assembly: AssemblyTitle("How to Fish - Mod Kit runtime")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace HowToFish.ModKit
{
	public static class BundleLoader
	{
		private static readonly Dictionary<string, AssetBundle> Loaded = new Dictionary<string, AssetBundle>(StringComparer.OrdinalIgnoreCase);

		public static ManualLogSource Log { get; set; }

		public static string PluginDirectoryOf(object plugin)
		{
			return Path.GetDirectoryName(plugin.GetType().Assembly.Location);
		}

		public static AssetBundle Load(object plugin, string bundleFileName)
		{
			return LoadFrom(Path.Combine(PluginDirectoryOf(plugin), bundleFileName));
		}

		public static AssetBundle LoadFrom(string fullPath)
		{
			string fullPath2 = Path.GetFullPath(fullPath);
			if (Loaded.TryGetValue(fullPath2, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			if (!File.Exists(fullPath2))
			{
				ManualLogSource log = Log;
				if (log != null)
				{
					log.LogError((object)("Asset bundle not found: " + fullPath2));
				}
				return null;
			}
			AssetBundle val = AssetBundle.LoadFromFile(fullPath2);
			if ((Object)(object)val == (Object)null)
			{
				ManualLogSource log2 = Log;
				if (log2 != null)
				{
					log2.LogError((object)("Failed to load asset bundle: " + fullPath2 + ". It was most likely built with a different Unity version than 6000.4.x."));
				}
				return null;
			}
			Loaded[fullPath2] = val;
			ManualLogSource log3 = Log;
			if (log3 != null)
			{
				log3.LogInfo((object)$"Loaded bundle {Path.GetFileName(fullPath2)} ({val.GetAllAssetNames().Length} assets)");
			}
			return val;
		}

		public static T Asset<T>(AssetBundle bundle, string name) where T : Object
		{
			if ((Object)(object)bundle == (Object)null)
			{
				return default(T);
			}
			T val = bundle.LoadAsset<T>(name);
			if ((Object)(object)val == (Object)null)
			{
				ManualLogSource log = Log;
				if (log != null)
				{
					log.LogError((object)("Asset '" + name + "' of type " + typeof(T).Name + " not found in bundle. Available: " + string.Join(", ", bundle.GetAllAssetNames())));
				}
				return default(T);
			}
			object obj = val;
			GameObject val2 = (GameObject)((obj is GameObject) ? obj : null);
			if (val2 != null)
			{
				ShaderFix.Apply(val2);
			}
			else
			{
				object obj2 = val;
				Material val3 = (Material)((obj2 is Material) ? obj2 : null);
				if (val3 != null)
				{
					ShaderFix.Apply(val3);
				}
			}
			return val;
		}

		public static GameObject Prefab(AssetBundle bundle, string name)
		{
			return BundleLoader.Asset<GameObject>(bundle, name);
		}

		public static void UnloadAll(bool unloadLoadedObjects = false)
		{
			foreach (AssetBundle value in Loaded.Values)
			{
				if ((Object)(object)value != (Object)null)
				{
					value.Unload(unloadLoadedObjects);
				}
			}
			Loaded.Clear();
		}
	}
	public static class ShaderFix
	{
		private static readonly Dictionary<string, Shader> Cache = new Dictionary<string, Shader>();

		public static bool Enabled = true;

		public static void Apply(GameObject root)
		{
			if (!Enabled || (Object)(object)root == (Object)null)
			{
				return;
			}
			Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Material[] sharedMaterials = componentsInChildren[i].sharedMaterials;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					Apply(sharedMaterials[j]);
				}
			}
		}

		public static void Apply(Material material)
		{
			if (!Enabled || (Object)(object)material == (Object)null || (Object)(object)material.shader == (Object)null)
			{
				return;
			}
			string name = ((Object)material.shader).name;
			if (!Cache.TryGetValue(name, out var value))
			{
				value = Shader.Find(name);
				Cache[name] = value;
			}
			if ((Object)(object)value == (Object)null)
			{
				ManualLogSource log = BundleLoader.Log;
				if (log != null)
				{
					log.LogWarning((object)("Shader '" + name + "' is not present in the game build; material '" + ((Object)material).name + "' will render incorrectly. Author it with a URP shader the game already uses (Universal Render Pipeline/Lit)."));
				}
			}
			else
			{
				int renderQueue = material.renderQueue;
				material.shader = value;
				material.renderQueue = renderQueue;
			}
		}
	}
}

BepInEx/plugins/HowToFish.Warthog/HowToFish.Warthog.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FishNet;
using FishNet.Broadcast;
using FishNet.Connection;
using FishNet.Managing.Client;
using FishNet.Managing.Server;
using FishNet.Object;
using FishNet.Serializing;
using FishNet.Transporting;
using HarmonyLib;
using HowToFish.ModKit;
using HowToFish.Warthog.Patches;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.InputSystem;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("zPaulin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright (c) 2026 zPaulin. All rights reserved.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ed3864f363b71b0a7f3da27f86b6fbbd7b45f789")]
[assembly: AssemblyProduct("zPaulin's A10-Warthog for How to Fish")]
[assembly: AssemblyTitle("HowToFish.Warthog")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace HowToFish.Warthog
{
	public static class Boom
	{
		public static float Delay(Vector3 from)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			ModConfig cfg = Plugin.Cfg;
			if (cfg == null || cfg.SpeedOfSound.Value <= 0f)
			{
				return 0f;
			}
			Transform val = Ears();
			if ((Object)(object)val == (Object)null)
			{
				return 0f;
			}
			return Vector3.Distance(from, val.position) / cfg.SpeedOfSound.Value;
		}

		public static void At(string clips, Vector3 point, float volume, AudioDistance distance)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_0037: 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)
			string text = Pick(clips);
			if (text != null)
			{
				float num = Delay(point);
				if (num < 0.02f || (Object)(object)WarthogRuntime.Instance == (Object)null)
				{
					Play(text, point, volume, distance);
				}
				else
				{
					((MonoBehaviour)WarthogRuntime.Instance).StartCoroutine(Later(text, point, volume, distance, num));
				}
			}
		}

		private static IEnumerator Later(string clip, Vector3 point, float volume, AudioDistance distance, float wait)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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)
			yield return (object)new WaitForSeconds(wait);
			Play(clip, point, volume, distance);
		}

		private static void Play(string clip, Vector3 point, float volume, AudioDistance distance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				AudioManager.PlayClipAt(clip, point, true, distance, volume, 0f);
			}
			catch
			{
			}
		}

		private static string Pick(string clips)
		{
			if (string.IsNullOrEmpty(clips))
			{
				return null;
			}
			string[] array = clips.Split(new char[1] { ',' });
			if (array.Length == 1)
			{
				return array[0].Trim();
			}
			for (int i = 0; i < 4; i++)
			{
				string text = array[Random.Range(0, array.Length)].Trim();
				if (text.Length > 0)
				{
					return text;
				}
			}
			return array[0].Trim();
		}

		private static Transform Ears()
		{
			try
			{
				Player localPlayer = Player.LocalPlayer;
				if ((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.Transform != (Object)null)
				{
					return localPlayer.Transform;
				}
			}
			catch
			{
			}
			Camera main = Camera.main;
			if (!((Object)(object)main == (Object)null))
			{
				return ((Component)main).transform;
			}
			return null;
		}
	}
	public static class Carrier
	{
		private static int _walkableLayer = -1;

		public static GameObject Root { get; private set; }

		public static Transform Deck { get; private set; }

		public static Transform ParkingSpot { get; private set; }

		public static bool Exists => (Object)(object)Root != (Object)null;

		public static void OnSceneLoaded(Scene scene)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (Islands.IsCarrierIsland(((Scene)(ref scene)).name) && !Exists)
			{
				Build(scene);
			}
		}

		public static void Clear()
		{
			Vendor.Clear();
			if ((Object)(object)Root != (Object)null)
			{
				Object.Destroy((Object)(object)Root);
			}
			Root = null;
			Deck = null;
			ParkingSpot = null;
		}

		private static void Build(Scene scene)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: 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)
			ModConfig cfg = Plugin.Cfg;
			Vector3 heading;
			Vector3? val = ComputePosition(out heading);
			if (!val.HasValue)
			{
				Feedback.Warn("Could not place the carrier: the island reported no position.");
				return;
			}
			Root = new GameObject("A10_Carrier");
			Root.transform.SetPositionAndRotation(val.Value, Quaternion.LookRotation(heading, Vector3.up));
			if (((Scene)(ref scene)).IsValid())
			{
				SceneManager.MoveGameObjectToScene(Root, scene);
			}
			float value = cfg.CarrierLength.Value;
			float value2 = cfg.CarrierWidth.Value;
			float value3 = cfg.CarrierDraft.Value;
			float value4 = cfg.CarrierDeckHeight.Value;
			Deck = Box("Hull", Root.transform, new Vector3(0f, (value4 - value3) * 0.5f, 0f), new Vector3(value2, value4 + value3, value), new Color(0.24f, 0.25f, 0.27f)).transform;
			float num = value2 * 0.18f;
			float num2 = Mathf.Max(value2 * 0.38f, 9.5f + num * 0.5f);
			Box("Superstructure", Root.transform, new Vector3(num2, value4 + 5f, value * 0.12f), new Vector3(num, 10f, value * 0.14f), new Color(0.34f, 0.35f, 0.37f));
			Box("Centreline", Root.transform, new Vector3(0f, value4 + 0.02f, 0f), new Vector3(1.2f, 0.04f, value * 0.86f), new Color(0.86f, 0.86f, 0.82f));
			GameObject val2 = new GameObject("ParkingSpot");
			val2.transform.SetParent(Root.transform, false);
			val2.transform.localPosition = new Vector3(0f, value4, (0f - value) * 0.36f);
			val2.transform.localRotation = Quaternion.identity;
			ParkingSpot = val2.transform;
			Gangway(cfg, value2, value, value4);
			((MonoBehaviour)WarthogRuntime.Instance).StartCoroutine(RaiseVendor(value4, value, cfg));
			ManualLogSource log = Plugin.Log;
			string[] obj = new string[5] { "Carrier on station at ", null, null, null, null };
			Vector3 value5 = val.Value;
			obj[1] = ((Vector3)(ref value5)).ToString("F0");
			obj[2] = ", ";
			obj[3] = Vector3.Distance(val.Value, Island.IslandPos).ToString("F0");
			obj[4] = " m from the island.";
			log.LogDebug((object)string.Concat(obj));
		}

		private static IEnumerator RaiseVendor(float deckHeight, float length, ModConfig cfg)
		{
			yield return null;
			if ((Object)(object)Root != (Object)null)
			{
				Vendor.Build(Root.transform, deckHeight, length, cfg);
			}
		}

		public static void ParkJet()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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)
			if (!((Object)(object)ParkingSpot == (Object)null))
			{
				JetFleet.PlaceAt(ParkingSpot.position + Vector3.up * Plugin.Cfg.GearHeight.Value, ParkingSpot.rotation);
			}
		}

		private static Vector3? ComputePosition(out Vector3 heading)
		{
			//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_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_007e: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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)
			heading = Vector3.forward;
			Vector3 islandPos = Island.IslandPos;
			Vector3 val = SpawnManager.BoatSpawnPos - islandPos;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 1f)
			{
				val = Vector3.forward;
			}
			else
			{
				((Vector3)(ref val)).Normalize();
			}
			Vector3 val2 = Vector3.Cross(Vector3.up, val);
			heading = ((Vector3)(ref val2)).normalized;
			if (((Vector3)(ref heading)).sqrMagnitude < 0.5f)
			{
				heading = Vector3.forward;
			}
			float y = WaterLevel();
			Vector3 value = islandPos + val * Plugin.Cfg.CarrierDistance.Value;
			value.y = y;
			return value;
		}

		private static float WaterLevel()
		{
			try
			{
				return WaterManager.WaterHeight;
			}
			catch
			{
				return 0f;
			}
		}

		private static void Gangway(ModConfig cfg, float width, float length, float deckHeight)
		{
			//IL_0082: 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_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_009f: 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_00aa: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//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_01ca: 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_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Clamp(cfg.RampAngle.Value, 10f, 50f);
			float num2 = Mathf.Max(cfg.RampWidth.Value, 1.5f);
			float num3 = Mathf.Clamp(cfg.RampPosition.Value, (0f - length) * 0.45f, length * 0.45f);
			float num4 = (deckHeight - 0.5f) / Mathf.Tan(num * ((float)Math.PI / 180f));
			float num5 = width * 0.5f;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(num5 + 0.05f, deckHeight, num3);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(val.x + num4, 0.5f, num3);
			Vector3 val3 = val - val2;
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			float num6 = Vector3.Distance(val2, val);
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(normalized.y, 0f - normalized.x, 0f);
			if (val4.y < 0f)
			{
				val4 = -val4;
			}
			Quaternion val5 = Quaternion.LookRotation(Vector3.forward, val4);
			Color color = default(Color);
			((Color)(ref color))..ctor(0.3f, 0.31f, 0.33f);
			Color colour = default(Color);
			((Color)(ref colour))..ctor(0.86f, 0.72f, 0.2f);
			Box("Gangway", Root.transform, (val2 + val) * 0.5f - val4 * 0.25f, new Vector3(num6, 0.5f, num2), color).transform.localRotation = val5;
			Box("GangwayFoot", Root.transform, new Vector3(num5 + num4 + 3.5f, 0.25f, num3), new Vector3(8f, 0.5f, num2 + 2f), color);
			Rails(val2, val, normalized, val4, val5, num6, num2, colour);
			Treads(val2, normalized, val4, val5, num6, num2, val.y - val2.y);
		}

		private static void Rails(Vector3 foot, Vector3 head, Vector3 axis, Vector3 normal, Quaternion tilt, float slope, float span, Color colour)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0065: 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_0075: 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_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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_00ca: 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_00f9: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Clamp(Mathf.RoundToInt(slope / 2.5f), 2, 14);
			Vector3 val = default(Vector3);
			for (int i = -1; i <= 1; i += 2)
			{
				((Vector3)(ref val))..ctor(0f, 0f, (float)i * span * 0.5f);
				Box("GangwayRail" + i, Root.transform, (foot + head) * 0.5f + normal * 0.85f + val, new Vector3(slope, 0.18f, 0.18f), colour).transform.localRotation = tilt;
				for (int j = 0; j <= num; j++)
				{
					Vector3 localPos = foot + axis * (slope * (float)j / (float)num) + normal * 0.425f + val;
					GameObject obj = Box("GangwayPost" + i + "_" + j, Root.transform, localPos, new Vector3(0.16f, 0.85f, 0.16f), colour);
					obj.transform.localRotation = tilt;
					Object.Destroy((Object)(object)obj.GetComponent<Collider>());
				}
			}
		}

		private static void Treads(Vector3 foot, Vector3 axis, Vector3 normal, Quaternion tilt, float slope, float span, float rise)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_0083: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Clamp(Mathf.RoundToInt(rise / 0.42f), 4, 40);
			Color color = default(Color);
			((Color)(ref color))..ctor(0.46f, 0.47f, 0.49f);
			for (int i = 1; i < num; i++)
			{
				Vector3 localPos = foot + axis * (slope * (float)i / (float)num) + normal * 0.05f;
				GameObject obj = Box("Tread" + i, Root.transform, localPos, new Vector3(0.12f, 0.1f, span * 0.92f), color);
				obj.transform.localRotation = tilt;
				Object.Destroy((Object)(object)obj.GetComponent<Collider>());
			}
		}

		private static GameObject Box(string name, Transform parent, Vector3 localPos, Vector3 size, Color color)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val).name = name;
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			val.transform.localScale = size;
			val.layer = WalkableLayer();
			val.tag = "Level";
			Material val2 = Mat.Solid(color);
			if ((Object)(object)val2 != (Object)null)
			{
				((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial = val2;
			}
			return val;
		}

		public static int WalkableLayer()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (_walkableLayer >= 0)
			{
				return _walkableLayer;
			}
			LayerMask canJumpOnLayers = GameInfo.CanJumpOnLayers;
			int value = ((LayerMask)(ref canJumpOnLayers)).value;
			for (int i = 0; i < 32; i++)
			{
				if ((value & (1 << i)) != 0)
				{
					string text = LayerMask.LayerToName(i);
					switch (text)
					{
					case "Player":
					case "LocalPlayer":
					case "Item":
						continue;
					}
					_walkableLayer = i;
					Plugin.Log.LogDebug((object)("Carrier hull on layer " + i + " (" + text + ")"));
					return i;
				}
			}
			_walkableLayer = 0;
			Plugin.Log.LogWarning((object)"CanJumpOnLayers was empty; falling back to Default.");
			return 0;
		}
	}
	public static class Commands
	{
		private static readonly List<JetVehicle> Spawned = new List<JetVehicle>();

		public static bool Handle(string raw)
		{
			if (string.IsNullOrEmpty(raw))
			{
				return false;
			}
			string text = raw.Trim();
			if (text.StartsWith("/"))
			{
				text = text.Substring(1);
			}
			string[] array = text.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
			if (array.Length == 0)
			{
				return false;
			}
			if (!array[0].Equals("a10", StringComparison.OrdinalIgnoreCase))
			{
				return false;
			}
			switch ((array.Length > 1) ? array[1].ToLowerInvariant() : "status")
			{
			case "status":
				Status();
				return true;
			case "spawn":
				Spawn();
				return true;
			case "clear":
				Clear();
				return true;
			case "goto":
				GoToCarrier();
				return true;
			case "fly":
				Fly();
				return true;
			case "out":
				JetControl.RequestDismount();
				return true;
			case "seat":
				Seat(array);
				return true;
			case "muzzle":
				Muzzle(array);
				return true;
			case "cam":
				Cam(array);
				return true;
			case "unstick":
				Unstick();
				return true;
			case "recover":
				Recover();
				return true;
			case "radar":
				Radar(array);
				return true;
			case "keys":
				Keys();
				return true;
			case "ui":
				Ui();
				return true;
			case "gear":
				GearInfo(array);
				return true;
			case "fx":
				Effects();
				return true;
			case "glow":
				Glow(array);
				return true;
			case "hull":
				Hull(array);
				return true;
			case "npcs":
				Npcs();
				return true;
			case "brrrt":
				Brrrt(array);
				return true;
			case "buy":
				JetSales.Request();
				return true;
			case "money":
				Money(array);
				return true;
			case "refund":
				Refund();
				return true;
			default:
				Help();
				return true;
			}
		}

		private static void Status()
		{
			Feedback.Say(Feedback.Value("zPaulin's A10-Warthog") + "   version " + Feedback.Value("1.0.0"));
			if (!JetAssets.Ready)
			{
				Feedback.Warn("The model did not load. The bundle is missing from the plugin folder, and nothing will fly until it is there.");
			}
			Feedback.Say("Island " + Feedback.Value(Islands.CurrentSceneName()) + "   carrier " + Feedback.Value(Carrier.Exists ? "on station" : "not here"));
			Feedback.Say("The A-10 is " + (JetSales.Available ? Feedback.Value("yours") : ("for sale at " + Feedback.Cash(JetSales.Price))) + "   you are carrying " + Feedback.Cash(MoneyManager.Money));
			Feedback.Say("Multiplayer " + Feedback.Value((!Plugin.Cfg.Multiplayer.Value) ? "off" : (JetNetwork.Live ? "connected" : "not connected")) + (JetCalm.Active ? ("   " + Feedback.Value(JetCalm.Count.ToString()) + " creature(s) leaving you alone") : ""));
			JetVehicle local = JetVehicle.Local;
			if ((Object)(object)local == (Object)null)
			{
				Feedback.Say((JetVehicle.All.Count == 0) ? "No aircraft in the world yet." : (Feedback.Value(JetVehicle.All.Count.ToString()) + " aircraft in the world. You are not flying."));
				return;
			}
			Feedback.Say(string.Format(CultureInfo.InvariantCulture, "Airborne at {0} km/h, {1} m up, throttle {2}.", Feedback.Value((local.Speed * 3.6f).ToString("F0", CultureInfo.InvariantCulture)), Feedback.Value(Altitude(local).ToString("F0", CultureInfo.InvariantCulture)), Feedback.Value(local.Throttle.ToString("P0", CultureInfo.InvariantCulture))));
			Feedback.Say(string.Format(CultureInfo.InvariantCulture, "{0} deg of bank, {1} G, {2} rounds left.{3}{4}", Feedback.Value(JetArcade.BankAngle(local).ToString("F0", CultureInfo.InvariantCulture)), Feedback.Value(local.GLoad.ToString("F1", CultureInfo.InvariantCulture)), Feedback.Value(local.Ammo.ToString()), local.Stalled ? "  Stalled." : "", local.OnGround ? "  Wheels down." : ""));
		}

		private static float Altitude(JetVehicle jet)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return ((Component)jet).transform.position.y - WaterManager.WaterHeight;
			}
			catch
			{
				return ((Component)jet).transform.position.y;
			}
		}

		private static void Spawn()
		{
			//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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_005a: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_008d: 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_00ac: 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)
			Player localPlayer = Player.LocalPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				Feedback.Warn("You are not in the world yet.");
				return;
			}
			Vector3 val = localPlayer.Camera.CamTransform.forward;
			val.y = 0f;
			val = ((((Vector3)(ref val)).sqrMagnitude < 0.0001f) ? Vector3.forward : ((Vector3)(ref val)).normalized);
			Vector3 position = localPlayer.Transform.position + val * 25f + Vector3.up * Plugin.Cfg.GearHeight.Value;
			JetVehicle jetVehicle = JetControl.Create("Warthog_Test_" + Spawned.Count, position, Quaternion.LookRotation(val, Vector3.up));
			if (!((Object)(object)jetVehicle == (Object)null))
			{
				Spawned.Add(jetVehicle);
				Feedback.Say("jet placed 25 m ahead - walk up to it and press the pick-up key.");
			}
		}

		private static void Clear()
		{
			int num = 0;
			foreach (JetVehicle item in Spawned)
			{
				if (!((Object)(object)item == (Object)null))
				{
					if ((Object)(object)item.Pilot != (Object)null)
					{
						item.Dismount();
					}
					Object.Destroy((Object)(object)((Component)item).gameObject);
					num++;
				}
			}
			Spawned.Clear();
			Feedback.Say("removed " + num + " jet(s).");
		}

		private static void Fly()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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)
			Player localPlayer = Player.LocalPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				Feedback.Warn("No local player yet.");
				return;
			}
			JetVehicle jetVehicle = null;
			float num = float.MaxValue;
			foreach (JetVehicle item in JetVehicle.All)
			{
				if (!((Object)(object)item == (Object)null) && !((Object)(object)item.Pilot != (Object)null))
				{
					Vector3 val = ((Component)item).transform.position - localPlayer.Transform.position;
					float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
					if (!(sqrMagnitude >= num))
					{
						num = sqrMagnitude;
						jetVehicle = item;
					}
				}
			}
			if ((Object)(object)jetVehicle == (Object)null)
			{
				Feedback.Warn("There is no free aircraft here.");
			}
			else
			{
				JetControl.RequestMount(jetVehicle, localPlayer);
			}
		}

		private static void GoToCarrier()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//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_005f: Unknown result type (might be due to invalid IL or missing references)
			if (!Carrier.Exists)
			{
				Feedback.Warn("There is no carrier here. It is stationed off " + Feedback.Value("Island5") + ".");
				return;
			}
			Player localPlayer = Player.LocalPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				Feedback.Warn("No local player yet.");
				return;
			}
			localPlayer.Movement.Teleport(Carrier.ParkingSpot.position + Vector3.up * 3f, true);
			Feedback.Good("On the carrier deck.");
		}

		private static void Seat(string[] parts)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (!Three(parts, out var v))
			{
				Feedback.Say("/a10 seat <x> <y> <z>");
				return;
			}
			Plugin.Cfg.SeatX.Value = v.x;
			Plugin.Cfg.SeatY.Value = v.y;
			Plugin.Cfg.SeatZ.Value = v.z;
			RefreshAll();
			Feedback.Say("seat = " + ((Vector3)(ref v)).ToString("F2", (IFormatProvider)CultureInfo.InvariantCulture));
		}

		private static void Muzzle(string[] parts)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (!Three(parts, out var v))
			{
				Feedback.Say("/a10 muzzle <x> <y> <z>");
				return;
			}
			Plugin.Cfg.MuzzleX.Value = v.x;
			Plugin.Cfg.MuzzleY.Value = v.y;
			Plugin.Cfg.MuzzleZ.Value = v.z;
			RefreshAll();
			Feedback.Say("muzzle = " + ((Vector3)(ref v)).ToString("F2", (IFormatProvider)CultureInfo.InvariantCulture));
		}

		private static void Cam(string[] parts)
		{
			if (parts.Length < 4 || !Num(parts[2], out var value) || !Num(parts[3], out var value2))
			{
				Feedback.Say("/a10 cam <distance> <height>");
				return;
			}
			Plugin.Cfg.CameraDistance.Value = value;
			Plugin.Cfg.CameraHeight.Value = value2;
			Feedback.Say(string.Format(CultureInfo.InvariantCulture, "camera = {0:F1} m back, {1:F1} m up", value, value2));
		}

		private static void RefreshAll()
		{
			foreach (JetVehicle item in JetVehicle.All)
			{
				if ((Object)(object)item != (Object)null)
				{
					item.RefreshAnchors();
				}
			}
		}

		private static bool Three(string[] parts, out Vector3 v)
		{
			//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)
			v = Vector3.zero;
			if (parts.Length < 5)
			{
				return false;
			}
			if (!Num(parts[2], out v.x))
			{
				return false;
			}
			if (!Num(parts[3], out v.y))
			{
				return false;
			}
			if (!Num(parts[4], out v.z))
			{
				return false;
			}
			return true;
		}

		private static bool Num(string text, out float value)
		{
			return float.TryParse(text.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out value);
		}

		private static void Money(string[] parts)
		{
			if (!Server())
			{
				Feedback.Warn("only the host can print money - MoneyManager writes the till server-side and there is one till for everyone.");
				return;
			}
			float value;
			int num = ((parts.Length > 2 && Num(parts[2], out value)) ? Mathf.RoundToInt(value) : Mathf.Max(0, JetSales.Price - MoneyManager.Money));
			if (num <= 0)
			{
				Feedback.Say("the till already covers it.");
				return;
			}
			try
			{
				MoneyManager.AddMoney(num, Player.LocalPlayer);
				Feedback.Say("added $" + num.ToString("N0", Feedback.Numbers) + ".");
			}
			catch (Exception ex)
			{
				Feedback.Warn("could not add money: " + ex.Message);
			}
		}

		private static bool Server()
		{
			try
			{
				return InstanceFinder.IsServerStarted;
			}
			catch
			{
				return true;
			}
		}

		private static void Refund()
		{
			JetSales.Refund();
			Feedback.Say("the A-10 is back on the lot - no money returned, this is for testing.");
		}

		private static void GearInfo(string[] parts)
		{
			JetVehicle jetVehicle = JetVehicle.Local ?? JetFleet.Jet;
			if ((Object)(object)jetVehicle == (Object)null || jetVehicle.Gear == null)
			{
				Feedback.Warn("no jet in the world.");
				return;
			}
			if (parts.Length > 2)
			{
				ConfigEntry<float> gearHandedness = Plugin.Cfg.GearHandedness;
				float value;
				if (parts[2].Equals("flip", StringComparison.OrdinalIgnoreCase))
				{
					gearHandedness.Value = (Mathf.RoundToInt(gearHandedness.Value) + 1) % 4;
				}
				else if (Num(parts[2], out value))
				{
					gearHandedness.Value = Mathf.Clamp(Mathf.Round(value), 0f, 3f);
				}
				jetVehicle.Gear.Rebind();
			}
			Feedback.Say("gear: " + jetVehicle.Gear.Describe() + "   key " + Plugin.Cfg.GearKey.Value);
			Feedback.Say("/a10 gear flip  |  /a10 gear <0-3>");
		}

		private static void Hull(string[] parts)
		{
			ModConfig cfg = Plugin.Cfg;
			string text = ((parts.Length > 2) ? parts[2].ToLowerInvariant() : "");
			switch (text)
			{
			case "debug":
				cfg.HullDebug.Value = !cfg.HullDebug.Value;
				Reshape();
				Feedback.Say("hull blocks " + (cfg.HullDebug.Value ? "shown" : "hidden") + ".");
				return;
			case "on":
			case "off":
				cfg.HullSolid.Value = text == "on";
				Reshape();
				Feedback.Say("solid bodywork " + text + ".");
				return;
			case "body":
			{
				if (parts.Length > 6 && Num(parts[3], out var value) && Num(parts[4], out var value2) && Num(parts[5], out var value3) && Num(parts[6], out var value4))
				{
					cfg.HullBodyWidth.Value = value;
					cfg.HullBodyHeight.Value = value2;
					cfg.HullBodyLength.Value = value3;
					cfg.HullBodyRise.Value = value4;
					Reshape();
					Feedback.Say("fuselage box moved.");
					return;
				}
				break;
			}
			}
			if (text == "wing" && parts.Length > 7 && Num(parts[3], out var value5) && Num(parts[4], out var value6) && Num(parts[5], out var value7) && Num(parts[6], out var value8) && Num(parts[7], out var value9))
			{
				cfg.HullWingSpan.Value = value5;
				cfg.HullWingThickness.Value = value6;
				cfg.HullWingChord.Value = value7;
				cfg.HullWingRise.Value = value8;
				cfg.HullWingBack.Value = value9;
				Reshape();
				Feedback.Say("wing box moved.");
			}
			else
			{
				Feedback.Say("/a10 hull debug|on|off   |   hull body <width> <height> <length> <rise>   |   hull wing <span> <thick> <chord> <rise> <back>");
				JetVehicle jetVehicle = JetVehicle.Local ?? ((JetVehicle.All.Count > 0) ? JetVehicle.All[0] : null);
				if ((Object)(object)jetVehicle != (Object)null && jetVehicle.Hull != null)
				{
					Feedback.Say(jetVehicle.Hull.Describe());
				}
				Feedback.Say("body " + Four(cfg.HullBodyWidth.Value, cfg.HullBodyHeight.Value, cfg.HullBodyLength.Value, cfg.HullBodyRise.Value) + "   solid: " + (cfg.HullSolid.Value ? "yes" : "no"));
				Feedback.Say("wing " + Four(cfg.HullWingSpan.Value, cfg.HullWingThickness.Value, cfg.HullWingChord.Value, cfg.HullWingRise.Value) + " " + cfg.HullWingBack.Value.ToString("F2", CultureInfo.InvariantCulture));
			}
		}

		private static string Four(float a, float b, float c, float d)
		{
			return a.ToString("F2", CultureInfo.InvariantCulture) + " " + b.ToString("F2", CultureInfo.InvariantCulture) + " " + c.ToString("F2", CultureInfo.InvariantCulture) + " " + d.ToString("F2", CultureInfo.InvariantCulture);
		}

		private static void Reshape()
		{
			foreach (JetVehicle item in JetVehicle.All)
			{
				if ((Object)(object)item != (Object)null && item.Hull != null)
				{
					item.Hull.Place();
				}
			}
		}

		private static void Glow(string[] parts)
		{
			ModConfig cfg = Plugin.Cfg;
			if (parts.Length > 5 && Num(parts[2], out var value) && Num(parts[3], out var value2) && Num(parts[4], out var value3) && Num(parts[5], out var value4))
			{
				cfg.TrailSpread.Value = value;
				cfg.TrailHeight.Value = value2;
				cfg.TrailBack.Value = value3;
				cfg.GlowSize.Value = value4;
				foreach (JetVehicle item in JetVehicle.All)
				{
					if ((Object)(object)item != (Object)null && item.Trails != null)
					{
						item.Trails.Place();
					}
				}
				Feedback.Say("nozzles moved.");
			}
			else
			{
				Feedback.Say("/a10 glow <sideways> <up> <back> <size>   now " + cfg.TrailSpread.Value.ToString("F2", CultureInfo.InvariantCulture) + " " + cfg.TrailHeight.Value.ToString("F2", CultureInfo.InvariantCulture) + " " + cfg.TrailBack.Value.ToString("F2", CultureInfo.InvariantCulture) + " " + cfg.GlowSize.Value.ToString("F2", CultureInfo.InvariantCulture));
			}
		}

		private static void Effects()
		{
			List<string> list = Fx.Names();
			Feedback.Say("crash: " + (Fx.Explosion() ?? "none") + "   impact: " + (Fx.Impact() ?? "none"));
			Feedback.Say(list.Count + " particle(s): " + Fx.Join(list));
			List<string> list2 = Fx.Sounds();
			Feedback.Say(list2.Count + " sound(s), full list in the log.");
			foreach (string item in list2)
			{
				Plugin.Log.LogInfo((object)("clip: " + item));
			}
		}

		private static void Npcs()
		{
			List<NPC> list = Vendor.Islanders();
			Feedback.Say("wanted: '" + Plugin.Cfg.VendorNpc.Value + "'");
			Feedback.Say(list.Count + " NPC(s): " + Vendor.Names(list));
		}

		private static void Brrrt(string[] parts)
		{
			//IL_0088: 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_008d: 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_009a: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_00c8: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			JetVehicle jetVehicle = JetFleet.Jet ?? JetVehicle.Local;
			if ((Object)(object)jetVehicle == (Object)null)
			{
				Feedback.Warn("no jet in the world to fire.");
				return;
			}
			float value;
			float num = ((parts.Length > 2 && Num(parts[2], out value)) ? Mathf.Clamp(value, 0.2f, 30f) : 3f);
			Player localPlayer = Player.LocalPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				Feedback.Warn("no local player.");
				return;
			}
			Vector3 val = (((Object)(object)jetVehicle.Muzzle != (Object)null) ? jetVehicle.Muzzle.position : ((Component)jetVehicle).transform.position);
			Vector3 val2 = localPlayer.Transform.position - val;
			Vector3 val3 = localPlayer.Transform.position - ((Vector3)(ref val2)).normalized * 7f;
			RaycastHit val4 = default(RaycastHit);
			if (Physics.Raycast(val3 + Vector3.up * 30f, Vector3.down, ref val4, 120f, LayerMask.op_Implicit(GameInfo.CanJumpOnLayers), (QueryTriggerInteraction)1))
			{
				val3 = ((RaycastHit)(ref val4)).point;
			}
			JetCannon.Demo(jetVehicle, val3, num);
			Feedback.Say(string.Format(CultureInfo.InvariantCulture, "firing at the ground {0:F0} m off for {1:F1} s. {2}", Vector3.Distance(val3, localPlayer.Transform.position), num, JetAudio.CannonReport()));
		}

		private static void Ui()
		{
			Feedback.Say("hide stats: " + Plugin.Cfg.HideVanillaStats.Value + "   hide hotbar: " + Plugin.Cfg.HideHotbar.Value);
			Feedback.Say(VanillaHud.StatsReport);
		}

		private static void Keys()
		{
			Feedback.Say("pitch W/S = " + JetInput.Binding("PlayerMove") + "   throttle = " + Plugin.Cfg.ThrottleUpKey.Value + "/" + Plugin.Cfg.ThrottleDownKey.Value);
			Feedback.Say("roll A/D = same axis   cannon = " + JetInput.Binding("PlayerLeftClick"));
			Feedback.Say("rudder left (" + Plugin.Cfg.RudderLeftAction.Value + ") = " + JetInput.Binding(Plugin.Cfg.RudderLeftAction.Value));
			Feedback.Say("rudder right (" + Plugin.Cfg.RudderRightAction.Value + ") = " + JetInput.Binding(Plugin.Cfg.RudderRightAction.Value));
			Feedback.Say("exit = " + Plugin.Cfg.ExitKey.Value + "   brakes = " + JetInput.Binding("PlayerJump") + "   gear = " + Plugin.Cfg.GearKey.Value);
		}

		private static void Radar(string[] parts)
		{
			float value;
			float value2;
			float value3;
			float value4;
			float value5;
			if (parts.Length > 2 && parts[2].Equals("retry", StringComparison.OrdinalIgnoreCase))
			{
				JetRadar.Retry();
				Feedback.Say("radar will be rebuilt on the next frame in the cockpit.");
			}
			else if (parts.Length > 3 && parts[2].Equals("chrome", StringComparison.OrdinalIgnoreCase) && Num(parts[3], out value))
			{
				Plugin.Cfg.RadarChrome.Value = Mathf.Clamp01(value);
				JetRadar.Apply();
				Feedback.Say("radar rings and sweep at " + Mathf.Clamp01(value).ToString("P0") + ".");
			}
			else if (parts.Length > 3 && parts[2].Equals("corner", StringComparison.OrdinalIgnoreCase))
			{
				Plugin.Cfg.RadarCorner.Value = parts[3];
				JetRadar.Relayout();
				Feedback.Say("radar moved to " + Plugin.Cfg.RadarCorner.Value + ".");
			}
			else if (parts.Length > 3 && parts[2].Equals("range", StringComparison.OrdinalIgnoreCase) && Num(parts[3], out value2))
			{
				Plugin.Cfg.RadarRange.Value = Mathf.Max(50f, value2);
				Feedback.Say("radar range " + Mathf.Max(50f, value2).ToString("F0") + " m.");
			}
			else if (parts.Length > 3 && parts[2].Equals("sweep", StringComparison.OrdinalIgnoreCase) && Num(parts[3], out value3))
			{
				Plugin.Cfg.RadarSweepSpeed.Value = value3;
				JetRadar.Apply();
				Feedback.Say("radar sweep at " + value3.ToString("F2") + " turns per second.");
			}
			else if (parts.Length > 3 && Num(parts[2], out value4) && Num(parts[3], out value5))
			{
				Plugin.Cfg.RadarPixels.Value = value4;
				Plugin.Cfg.RadarMargin.Value = value5;
				JetRadar.Relayout();
				Feedback.Say("radar resized.");
			}
			else
			{
				Feedback.Say("radar: " + JetRadar.Describe());
				Feedback.Say("/a10 radar <pixels> <margin> | corner <name> | range <m> | chrome <0-1> | sweep <turns/s> | retry");
			}
		}

		private static void Recover()
		{
			if (!JetSales.Available)
			{
				Feedback.Warn("Nothing to recover - the A-10 has not been bought yet.");
				return;
			}
			JetFleet.OnIslandLoaded();
			Feedback.Say(Carrier.Exists ? "a fresh jet is on the deck." : "a fresh jet is waiting by the shore.");
		}

		private static void Unstick()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			JetVehicle local = JetVehicle.Local;
			if ((Object)(object)local != (Object)null)
			{
				local.Dismount();
			}
			GameFlags.Release();
			JetInput.Reset();
			try
			{
				ShaderManager.UpdateVignette(0f, Color.black);
			}
			catch
			{
			}
			Player localPlayer = Player.LocalPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				localPlayer.Rigidbody.isKinematic = false;
			}
			Feedback.Say("released flight state - punching, pickup and movement are back.");
		}

		private static void Help()
		{
			Feedback.Say("/a10 status | spawn | clear | goto | fly | out | recover | radar | keys | ui | buy | money | refund | gear | fx | glow | npcs | brrrt | unstick");
			Feedback.Say("/a10 seat <x y z> | muzzle <x y z> | cam <dist height>");
		}
	}
	public static class Feedback
	{
		private enum Tone
		{
			Info,
			Good,
			Bad
		}

		public static readonly CultureInfo Numbers = CultureInfo.InvariantCulture;

		private static readonly Regex Tags = new Regex("<[^>]+>", RegexOptions.Compiled);

		private static bool? _rich;

		public static void Say(string message)
		{
			Write(Tone.Info, message);
		}

		public static void Good(string message)
		{
			Write(Tone.Good, message);
		}

		public static void Warn(string message)
		{
			Write(Tone.Bad, message);
		}

		public static string Key(string key)
		{
			return Paint((Plugin.Cfg == null) ? "FFFFFF" : Plugin.Cfg.ChatKeyColour.Value, "<b>" + key + "</b>");
		}

		public static string Value(string value)
		{
			return Paint((Plugin.Cfg == null) ? "FFFFFF" : Plugin.Cfg.ChatValueColour.Value, value);
		}

		public static string Value(int value)
		{
			return Value(value.ToString("N0", Numbers));
		}

		public static string Cash(int amount)
		{
			return Value("$" + amount.ToString("N0", Numbers));
		}

		private static void Write(Tone tone, string message)
		{
			string text = Tags.Replace(message, "");
			if (tone == Tone.Bad)
			{
				Plugin.Log.LogWarning((object)text);
			}
			else
			{
				Plugin.Log.LogDebug((object)text);
			}
			if (Plugin.Cfg == null || !Plugin.Cfg.ChatFeedback.Value)
			{
				return;
			}
			try
			{
				ChatManager.ChatMessage(Rich() ? Decorate(tone, message) : ("[A-10] " + text));
			}
			catch
			{
			}
		}

		private static string Decorate(Tone tone, string message)
		{
			ModConfig cfg = Plugin.Cfg;
			string hex = ((tone == Tone.Bad) ? cfg.ChatWarnColour.Value : cfg.ChatTagColour.Value);
			return Paint(hex, "<b>A-10</b>") + "  " + ((tone == Tone.Info) ? message : Paint(hex, message));
		}

		private static string Paint(string hex, string body)
		{
			return "<color=#" + hex.TrimStart(new char[1] { '#' }) + ">" + body + "</color>";
		}

		private static bool Rich()
		{
			if (_rich.HasValue)
			{
				return _rich.Value;
			}
			if (Plugin.Cfg != null && !Plugin.Cfg.ChatRichText.Value)
			{
				_rich = false;
				return false;
			}
			try
			{
				Type typeFromHandle = typeof(ChatManager);
				object obj = typeFromHandle.GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null);
				if (obj == null)
				{
					return true;
				}
				object? obj2 = typeFromHandle.GetField("_messageText", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(obj);
				TextMeshProUGUI val = (TextMeshProUGUI)((obj2 is TextMeshProUGUI) ? obj2 : null);
				_rich = (Object)(object)val == (Object)null || ((TMP_Text)val).richText;
			}
			catch
			{
				_rich = true;
			}
			return _rich.Value;
		}
	}
	public static class Fx
	{
		private static string _explosion;

		private static string _impact;

		private static bool _looked;

		private static bool _lookedImpact;

		public static string Explosion()
		{
			if (_looked)
			{
				return _explosion;
			}
			_looked = true;
			List<string> list = Names();
			if (list.Count == 0)
			{
				return null;
			}
			string value = Plugin.Cfg.CrashParticle.Value;
			if (!string.IsNullOrEmpty(value))
			{
				foreach (string item in list)
				{
					if (string.Equals(item, value, StringComparison.OrdinalIgnoreCase))
					{
						return _explosion = item;
					}
				}
				Plugin.Log.LogWarning((object)("No particle called '" + value + "'. /a10 fx lists them."));
			}
			foreach (string item2 in list)
			{
				string text = item2.ToLowerInvariant();
				if (text.Contains("explos") && !text.Contains("blood") && !text.Contains("water") && !text.Contains("lava"))
				{
					return _explosion = item2;
				}
			}
			Plugin.Log.LogWarning((object)("No explosion particle found among: " + Join(list)));
			return null;
		}

		public static string Impact()
		{
			if (_lookedImpact)
			{
				return _impact;
			}
			_lookedImpact = true;
			List<string> list = Names();
			string value = Plugin.Cfg.ImpactParticle.Value;
			if (!string.IsNullOrEmpty(value))
			{
				foreach (string item in list)
				{
					if (string.Equals(item, value, StringComparison.OrdinalIgnoreCase))
					{
						return _impact = item;
					}
				}
				Plugin.Log.LogWarning((object)("No particle called '" + value + "'. /a10 fx lists them."));
			}
			string[] array = new string[5] { "dirt", "debris", "dust", "ground", "rock" };
			foreach (string value2 in array)
			{
				foreach (string item2 in list)
				{
					if (item2.ToLowerInvariant().Contains(value2))
					{
						return _impact = item2;
					}
				}
			}
			return _impact = Explosion();
		}

		public static List<string> Sounds()
		{
			List<string> list = new List<string>();
			try
			{
				if (typeof(AudioManager).GetField("_realClips", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null) is IDictionary dictionary)
				{
					foreach (object key in dictionary.Keys)
					{
						list.Add(key.ToString());
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not read the clip list: " + ex.Message));
			}
			list.Sort();
			return list;
		}

		public static List<string> Names()
		{
			List<string> list = new List<string>();
			try
			{
				if (typeof(ParticleManager).GetField("_particles", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null) is IDictionary dictionary)
				{
					foreach (object key in dictionary.Keys)
					{
						list.Add(key.ToString());
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not read the particle list: " + ex.Message));
			}
			list.Sort();
			return list;
		}

		public static void Forget()
		{
			_looked = (_lookedImpact = false);
			_explosion = (_impact = null);
		}

		public static string Join(List<string> names)
		{
			if (names.Count != 0)
			{
				return string.Join(", ", names.ToArray());
			}
			return "(none)";
		}
	}
	public static class GameFlags
	{
		private static readonly PropertyInfo DrivingLocally = typeof(Boat).GetProperty("IsDrivingLocally", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

		private static bool _raisedByUs;

		private static bool _warned;

		public static bool RaisedByUs => _raisedByUs;

		public static void Raise()
		{
			if (Write(value: true))
			{
				_raisedByUs = true;
			}
		}

		public static void Release()
		{
			if (_raisedByUs)
			{
				Write(value: false);
				_raisedByUs = false;
			}
		}

		private static bool Write(bool value)
		{
			MethodInfo methodInfo = DrivingLocally?.GetSetMethod(nonPublic: true);
			if (methodInfo == null)
			{
				if (!_warned)
				{
					_warned = true;
					Plugin.Log.LogWarning((object)"Boat.IsDrivingLocally has no reachable setter; ground actions stay live while flying.");
				}
				return false;
			}
			methodInfo.Invoke(null, new object[1] { value });
			return true;
		}

		public static bool IsDriving()
		{
			try
			{
				return Boat.IsDrivingLocally;
			}
			catch
			{
				return false;
			}
		}
	}
	public static class ImpactFx
	{
		private class Spark
		{
			public LineRenderer Line;

			public Vector3 From;

			public Vector3 Velocity;

			public float Life;

			public float Span;
		}

		private class Puff
		{
			public Transform Root;

			public SpriteRenderer Sprite;

			public float Life;

			public float Size;
		}

		private static readonly List<Spark> LiveSparks = new List<Spark>();

		private static readonly Queue<Spark> SparkPool = new Queue<Spark>();

		private static readonly List<Puff> LivePuffs = new List<Puff>();

		private static readonly Queue<Puff> PuffPool = new Queue<Puff>();

		private static Transform _root;

		private static Material _material;

		public static void Burst(Vector3 point, Vector3 normal)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_003c: 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)
			//IL_0042: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			ModConfig cfg = Plugin.Cfg;
			SpawnPuff(point + normal * 0.2f, cfg);
			int num = Mathf.RoundToInt(cfg.ImpactSparks.Value);
			for (int i = 0; i < num; i++)
			{
				Vector3 val = Random.insideUnitSphere * 0.8f;
				Vector3 val2 = normal + val;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				SpawnSpark(point, normalized * Random.Range(cfg.ImpactSparkSpeed.Value * 0.4f, cfg.ImpactSparkSpeed.Value), cfg);
			}
		}

		public static void Tick()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0084: 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_0093: 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_009e: 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_00ca: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			float deltaTime = Time.deltaTime;
			ModConfig cfg = Plugin.Cfg;
			for (int num = LiveSparks.Count - 1; num >= 0; num--)
			{
				Spark spark = LiveSparks[num];
				spark.Life -= deltaTime;
				if (spark.Life <= 0f || (Object)(object)spark.Line == (Object)null)
				{
					RetireSpark(num);
				}
				else
				{
					spark.Velocity += Vector3.down * 22f * deltaTime;
					spark.From += spark.Velocity * deltaTime;
					float num2 = Mathf.Clamp01(spark.Life / Mathf.Max(spark.Span, 0.01f));
					Vector3 val = spark.Velocity * 0.03f;
					spark.Line.SetPosition(0, spark.From - val);
					spark.Line.SetPosition(1, spark.From);
					Color val2 = Mat.Parse(cfg.ImpactSparkColour.Value, new Color(1f, 0.72f, 0.3f));
					val2.a = num2;
					spark.Line.startColor = val2;
					spark.Line.endColor = new Color(val2.r, val2.g, val2.b, 0f);
					spark.Line.widthMultiplier = cfg.ImpactSparkWidth.Value * num2;
				}
			}
			Camera main = Camera.main;
			for (int num3 = LivePuffs.Count - 1; num3 >= 0; num3--)
			{
				Puff puff = LivePuffs[num3];
				puff.Life -= deltaTime;
				if (puff.Life <= 0f || (Object)(object)puff.Root == (Object)null)
				{
					RetirePuff(num3);
				}
				else
				{
					float num4 = 1f - Mathf.Clamp01(puff.Life / Mathf.Max(puff.Size, 0.01f));
					puff.Root.localScale = Vector3.one * cfg.ImpactPuffSize.Value * (0.35f + num4 * 1.6f);
					Transform root = puff.Root;
					root.position += Vector3.up * (1.4f * deltaTime);
					if ((Object)(object)main != (Object)null)
					{
						puff.Root.rotation = Quaternion.LookRotation(puff.Root.position - ((Component)main).transform.position);
					}
					Color color = Mat.Parse(cfg.ImpactPuffColour.Value, new Color(0.28f, 0.24f, 0.19f));
					color.a *= 1f - num4;
					puff.Sprite.color = color;
				}
			}
		}

		private static void SpawnSpark(Vector3 at, Vector3 velocity, ModConfig cfg)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_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)
			Spark spark = null;
			while (SparkPool.Count > 0 && spark == null)
			{
				Spark spark2 = SparkPool.Dequeue();
				if ((Object)(object)spark2.Line != (Object)null)
				{
					spark = spark2;
				}
			}
			if (spark == null)
			{
				GameObject val = new GameObject("Spark");
				val.transform.SetParent(Root(), false);
				LineRenderer val2 = val.AddComponent<LineRenderer>();
				val2.positionCount = 2;
				val2.useWorldSpace = true;
				val2.numCapVertices = 0;
				((Renderer)val2).material = Material();
				val2.alignment = (LineAlignment)0;
				((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)val2).receiveShadows = false;
				spark = new Spark
				{
					Line = val2
				};
			}
			spark.From = at;
			spark.Velocity = velocity;
			spark.Span = cfg.ImpactSparkLife.Value;
			spark.Life = spark.Span;
			((Renderer)spark.Line).enabled = true;
			LiveSparks.Add(spark);
		}

		private static void SpawnPuff(Vector3 at, ModConfig cfg)
		{
			//IL_008c: 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_003d: Expected O, but got Unknown
			Puff puff = null;
			while (PuffPool.Count > 0 && puff == null)
			{
				Puff puff2 = PuffPool.Dequeue();
				if ((Object)(object)puff2.Root != (Object)null)
				{
					puff = puff2;
				}
			}
			if (puff == null)
			{
				GameObject val = new GameObject("Puff");
				val.transform.SetParent(Root(), false);
				SpriteRenderer val2 = val.AddComponent<SpriteRenderer>();
				val2.sprite = Textures.Disc(96);
				((Renderer)val2).material = Material();
				puff = new Puff
				{
					Root = val.transform,
					Sprite = val2
				};
			}
			puff.Root.position = at;
			puff.Size = cfg.ImpactPuffLife.Value;
			puff.Life = puff.Size;
			((Renderer)puff.Sprite).enabled = true;
			LivePuffs.Add(puff);
		}

		private static void RetireSpark(int index)
		{
			Spark spark = LiveSparks[index];
			if ((Object)(object)spark.Line != (Object)null)
			{
				((Renderer)spark.Line).enabled = false;
			}
			LiveSparks.RemoveAt(index);
			SparkPool.Enqueue(spark);
		}

		private static void RetirePuff(int index)
		{
			Puff puff = LivePuffs[index];
			if ((Object)(object)puff.Sprite != (Object)null)
			{
				((Renderer)puff.Sprite).enabled = false;
			}
			LivePuffs.RemoveAt(index);
			PuffPool.Enqueue(puff);
		}

		private static Transform Root()
		{
			//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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			if ((Object)(object)_root != (Object)null)
			{
				return _root;
			}
			GameObject val = new GameObject("A10_Impacts")
			{
				hideFlags = (HideFlags)61
			};
			Object.DontDestroyOnLoad((Object)val);
			_root = val.transform;
			return _root;
		}

		private static Material Material()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			if ((Object)(object)_material != (Object)null)
			{
				return _material;
			}
			Shader val = Shader.Find("Sprites/Default");
			if ((Object)(object)val == (Object)null)
			{
				val = Shader.Find("Universal Render Pipeline/Unlit");
			}
			_material = new Material(val)
			{
				hideFlags = (HideFlags)61
			};
			_material.renderQueue = 3000;
			return _material;
		}

		public static void Clear()
		{
			LiveSparks.Clear();
			SparkPool.Clear();
			LivePuffs.Clear();
			PuffPool.Clear();
			if ((Object)(object)_root != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_root).gameObject);
			}
			_root = null;
		}
	}
	public static class Islands
	{
		public const string CarrierIsland = "Island5";

		public static string CurrentSceneName()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < SceneManager.sceneCount; i++)
			{
				Scene sceneAt = SceneManager.GetSceneAt(i);
				if (((Scene)(ref sceneAt)).isLoaded && ((Scene)(ref sceneAt)).name.StartsWith("Island"))
				{
					return ((Scene)(ref sceneAt)).name;
				}
			}
			return "(none)";
		}

		public static bool IsCarrierIsland(string sceneName)
		{
			return string.Equals(sceneName, "Island5", StringComparison.OrdinalIgnoreCase);
		}
	}
	public static class JetArcade
	{
		private static bool _seeded;

		public static Vector3 AimDirection { get; private set; } = Vector3.forward;

		public static void Reset()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			_seeded = false;
			AimDirection = Vector3.forward;
		}

		public static void Aim(JetVehicle jet, Vector2 mouseDelta, bool freeLook, float keyPitch)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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_0112: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//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_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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)jet == (Object)null)
			{
				return;
			}
			ModConfig cfg = Plugin.Cfg;
			Vector3 forward = ((Component)jet).transform.forward;
			if (!_seeded)
			{
				AimDirection = forward;
				_seeded = true;
			}
			if (!freeLook && (((Vector2)(ref mouseDelta)).sqrMagnitude > 0f || Mathf.Abs(keyPitch) > 0f))
			{
				Quaternion val = Basis(jet);
				float value = cfg.Sensitivity.Value;
				AimDirection = Quaternion.AngleAxis(mouseDelta.x * value, val * Vector3.up) * AimDirection;
				AimDirection = Quaternion.AngleAxis((0f - mouseDelta.y) * value, val * Vector3.right) * AimDirection;
				if (Mathf.Abs(keyPitch) > 0f)
				{
					AimDirection = Quaternion.AngleAxis(keyPitch, ((Component)jet).transform.right) * AimDirection;
				}
			}
			Vector3 aimDirection = AimDirection;
			AimDirection = ((Vector3)(ref aimDirection)).normalized;
			float value2 = cfg.Cone.Value;
			if (Vector3.Angle(forward, AimDirection) > value2)
			{
				AimDirection = Vector3.RotateTowards(forward, AimDirection, value2 * ((float)Math.PI / 180f), 0f);
			}
		}

		private static Quaternion Basis(JetVehicle jet)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_002a: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			if (JetCamera.Active)
			{
				return JetCamera.Frame;
			}
			Vector3 forward = ((Component)jet).transform.forward;
			Vector3 val = ((Mathf.Abs(forward.y) > 0.985f) ? ((Component)jet).transform.up : Vector3.up);
			return Quaternion.LookRotation(forward, val);
		}

		public static float LateralError(JetVehicle jet)
		{
			//IL_0000: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.Cross(Vector3.up, ((Component)jet).transform.forward);
			if (((Vector3)(ref val)).sqrMagnitude < 0.001f)
			{
				return 0f;
			}
			((Vector3)(ref val)).Normalize();
			return Mathf.Asin(Mathf.Clamp(Vector3.Dot(AimDirection, val), -1f, 1f)) * 57.29578f;
		}

		public static float BankAngle(JetVehicle jet)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_003a: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 forward = ((Component)jet).transform.forward;
			Vector3 val = Vector3.Cross(Vector3.up, forward);
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				return 0f;
			}
			((Vector3)(ref val)).Normalize();
			Vector3 val2 = Vector3.Cross(forward, val);
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			return (0f - Mathf.Atan2(Vector3.Dot(((Component)jet).transform.right, normalized), Vector3.Dot(((Component)jet).transform.right, val))) * 57.29578f;
		}
	}
	public static class JetAssets
	{
		private static GameObject _prefab;

		public static bool Ready => (Object)(object)_prefab != (Object)null;

		public static void Load(object plugin)
		{
			BundleLoader.Log = Plugin.Log;
			AssetBundle val = BundleLoader.Load(plugin, "warthog.bundle");
			if (!((Object)(object)val == (Object)null))
			{
				_prefab = BundleLoader.Prefab(val, "Warthog");
				if (!((Object)(object)_prefab == (Object)null))
				{
					Plugin.Log.LogDebug((object)"Jet model loaded from warthog.bundle");
				}
			}
		}

		public static GameObject CreateJet(string name)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_005b: 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_0067: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_prefab == (Object)null)
			{
				Plugin.Log.LogError((object)"Cannot create a jet: the model never loaded.");
				return null;
			}
			GameObject val = new GameObject(name);
			GameObject obj = Object.Instantiate<GameObject>(_prefab, val.transform);
			((Object)obj).name = "Model";
			ModConfig cfg = Plugin.Cfg;
			Quaternion val2 = Quaternion.Euler(0f, cfg.YawOffset.Value, 0f);
			obj.transform.localRotation = val2;
			obj.transform.localPosition = val2 * (cfg.Pivot * cfg.Scale.Value);
			obj.transform.localScale = Vector3.one * cfg.Scale.Value;
			return val;
		}

		public static Bounds BoundsOf(GameObject jet)
		{
			//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_0012: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = jet.GetComponentsInChildren<Renderer>(true);
			if (componentsInChildren.Length == 0)
			{
				return new Bounds(jet.transform.position, Vector3.zero);
			}
			Bounds bounds = componentsInChildren[0].bounds;
			for (int i = 1; i < componentsInChildren.Length; i++)
			{
				((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds);
			}
			return bounds;
		}
	}
	public static class JetAudio
	{
		public const string ClipFile = "a10-engine.wav";

		public const string CannonFile = "a10-cannon.wav";

		public const string CannonStartFile = "a10-cannon-start.wav";

		public const string CannonStopFile = "a10-cannon-stop.wav";

		public const string CannonCockpitFile = "a10-cannon-cockpit.wav";

		private static AudioClip _clip;

		private static AudioClip _cannon;

		private static AudioClip _cannonStart;

		private static AudioClip _cannonStop;

		private static AudioClip _cannonCockpit;

		private static bool _tried;

		private static AudioMixerGroup _fx;

		public static bool Ready => (Object)(object)_clip != (Object)null;

		public static bool CannonReady => (Object)(object)_cannon != (Object)null;

		public static AudioClip CannonStart => _cannonStart;

		public static AudioClip CannonStop => _cannonStop;

		public static string CannonReport()
		{
			StringBuilder stringBuilder = new StringBuilder();
			if ((Object)(object)_cannonStart == (Object)null)
			{
				stringBuilder.Append("a10-cannon-start.wav").Append(' ');
			}
			if ((Object)(object)_cannon == (Object)null)
			{
				stringBuilder.Append("a10-cannon.wav").Append(' ');
			}
			if ((Object)(object)_cannonStop == (Object)null)
			{
				stringBuilder.Append("a10-cannon-stop.wav").Append(' ');
			}
			if (stringBuilder.Length != 0)
			{
				return "missing: " + stringBuilder.ToString().Trim();
			}
			return "all three clips loaded.";
		}

		public static IEnumerator Load(string folder)
		{
			if (!_tried)
			{
				_tried = true;
				yield return LoadOne(folder, "a10-engine.wav", "A10Engine", delegate(AudioClip clip)
				{
					_clip = clip;
				});
				yield return LoadOne(folder, "a10-cannon.wav", "A10Cannon", delegate(AudioClip clip)
				{
					_cannon = clip;
				});
				yield return LoadOne(folder, "a10-cannon-start.wav", "A10CannonStart", delegate(AudioClip clip)
				{
					_cannonStart = clip;
				});
				yield return LoadOne(folder, "a10-cannon-stop.wav", "A10CannonStop", delegate(AudioClip clip)
				{
					_cannonStop = clip;
				});
				yield return LoadOne(folder, "a10-cannon-cockpit.wav", "A10CannonCockpit", delegate(AudioClip clip)
				{
					_cannonCockpit = clip;
				});
			}
		}

		private static IEnumerator LoadOne(string folder, string file, string name, Action<AudioClip> assign)
		{
			string text = Path.Combine(folder, file);
			if (!File.Exists(text))
			{
				Plugin.Log.LogDebug((object)(file + " not present - that sound stays silent. Drop the file next to the plugin to enable it."));
				yield break;
			}
			string text2 = "file:///" + text.Replace(Path.DirectorySeparatorChar, '/');
			UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(text2, TypeOf(text));
			try
			{
				yield return request.SendWebRequest();
				if ((int)request.result != 1)
				{
					Plugin.Log.LogWarning((object)(file + " failed to load: " + request.error));
					yield break;
				}
				AudioClip content = DownloadHandlerAudioClip.GetContent(request);
				if ((Object)(object)content == (Object)null)
				{
					Plugin.Log.LogWarning((object)(file + " decoded to nothing."));
					yield break;
				}
				((Object)content).name = name;
				assign(content);
				Plugin.Log.LogDebug((object)(file + " loaded (" + content.length.ToString("F2") + " s)."));
			}
			finally
			{
				((IDisposable)request)?.Dispose();
			}
		}

		private static AudioType TypeOf(string path)
		{
			string text = Path.GetExtension(path).ToLowerInvariant();
			if (!(text == ".mp3"))
			{
				if (!(text == ".ogg"))
				{
					return (AudioType)20;
				}
				return (AudioType)14;
			}
			return (AudioType)13;
		}

		public static AudioMixerGroup FxGroup()
		{
			if ((Object)(object)_fx != (Object)null)
			{
				return _fx;
			}
			try
			{
				Type typeFromHandle = typeof(AudioManager);
				object obj = typeFromHandle.GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null);
				if (obj == null)
				{
					return null;
				}
				object? obj2 = typeFromHandle.GetField("_fxGroup", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(obj);
				_fx = (AudioMixerGroup)((obj2 is AudioMixerGroup) ? obj2 : null);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("No audio mixer group, the volume slider will not reach the jet: " + ex.Message));
			}
			return _fx;
		}

		public static void Route(AudioSource source)
		{
			if (!((Object)(object)source == (Object)null) && !((Object)(object)source.outputAudioMixerGroup != (Object)null))
			{
				source.outputAudioMixerGroup = FxGroup();
			}
		}

		public static AudioSource AttachOneShot(Transform parent)
		{
			if ((Object)(object)_cannonStart == (Object)null && (Object)(object)_cannonStop == (Object)null)
			{
				return null;
			}
			AudioSource obj = Gun("CannonOneShot", parent);
			obj.loop = false;
			Route(obj);
			return obj;
		}

		public static AudioSource AttachCannon(Transform parent)
		{
			if ((Object)(object)_cannon == (Object)null)
			{
				return null;
			}
			AudioSource obj = Gun("CannonAudio", parent);
			obj.clip = _cannon;
			obj.loop = true;
			obj.volume = 0f;
			Route(obj);
			return obj;
		}

		public static AudioSource AttachCockpit(Transform parent)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			if ((Object)(object)_cannon == (Object)null)
			{
				return null;
			}
			GameObject val = new GameObject("CannonCockpit");
			val.transform.SetParent(parent, false);
			AudioSource obj = val.AddComponent<AudioSource>();
			obj.clip = (((Object)(object)_cannonCockpit != (Object)null) ? _cannonCockpit : _cannon);
			obj.loop = true;
			obj.playOnAwake = false;
			obj.volume = 0f;
			obj.spatialBlend = 0f;
			obj.dopplerLevel = 0f;
			val.AddComponent<AudioLowPassFilter>().cutoffFrequency = Plugin.Cfg.CockpitCutoff.Value;
			Route(obj);
			return obj;
		}

		private static AudioSource Gun(string name, Transform parent)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			ModConfig cfg = Plugin.Cfg;
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			AudioSource obj = val.AddComponent<AudioSource>();
			obj.playOnAwake = false;
			obj.spatialBlend = cfg.CannonSpatialBlend.Value;
			obj.rolloffMode = (AudioRolloffMode)0;
			obj.minDistance = cfg.CannonNearDistance.Value;
			obj.maxDistance = cfg.CannonRange.Value;
			obj.dopplerLevel = 1f;
			if (cfg.CannonEcho.Value > 0f)
			{
				AudioEchoFilter obj2 = val.AddComponent<AudioEchoFilter>();
				obj2.delay = cfg.CannonEchoDelay.Value;
				obj2.decayRatio = cfg.CannonEchoDecay.Value;
				obj2.wetMix = cfg.CannonEcho.Value;
				obj2.dryMix = 1f;
			}
			val.AddComponent<AudioLowPassFilter>().cutoffFrequency = 22000f;
			Route(obj);
			return obj;
		}

		public static AudioSource Attach(Transform parent)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_clip == (Object)null)
			{
				return null;
			}
			GameObject val = new GameObject("EngineAudio");
			val.transform.SetParent(parent, false);
			ModConfig cfg = Plugin.Cfg;
			AudioSource obj = val.AddComponent<AudioSource>();
			obj.clip = _clip;
			obj.loop = true;
			obj.playOnAwake = false;
			obj.volume = 0f;
			obj.spatialBlend = cfg.EngineSpatialBlend.Value;
			obj.rolloffMode = (AudioRolloffMode)0;
			obj.minDistance = cfg.EngineNearDistance.Value;
			obj.maxDistance = cfg.EngineRange.Value;
			obj.dopplerLevel = cfg.EngineDoppler.Value;
			Route(obj);
			return obj;
		}
	}
	public static class JetCalm
	{
		private class Saved
		{
			public FieldInfo[] Info;

			public float[] Values;
		}

		private static readonly string[] Fields = new string[5] { "_towardsPlayerForce", "_airTowardsPlayerForce", "_constantTowardsPlayerForce", "_flyForceTowardsPlayer", "_flyForceTowardsPlayer2" };

		private static readonly Dictionary<Component, Saved> Held = new Dictionary<Component, Saved>();

		private static readonly Dictionary<Type, FieldInfo[]> Layouts = new Dictionary<Type, FieldInfo[]>();

		private static float _next;

		private static bool _active;

		public static bool Active => _active;

		public static int Count => Held.Count;

		public static void Tick()
		{
			ModConfig cfg = Plugin.Cfg;
			if (cfg == null)
			{
				return;
			}
			if (!cfg.CalmCreatures.Value)
			{
				if (_active)
				{
					Release();
				}
			}
			else
			{
				if (Time.time < _next)
				{
					return;
				}
				_next = Time.time + 0.5f;
				if (!ShouldCalm(cfg))
				{
					if (_active)
					{
						Release();
					}
				}
				else
				{
					_active = true;
					Sweep();
				}
			}
		}

		private static bool ShouldCalm(ModConfig cfg)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)JetVehicle.Local != (Object)null)
			{
				return true;
			}
			float value = cfg.CalmAltitude.Value;
			if (value <= 0f)
			{
				return false;
			}
			float waterHeight;
			try
			{
				waterHeight = WaterManager.WaterHeight;
			}
			catch
			{
				return false;
			}
			try
			{
				foreach (Player alivePlayer in PlayerManager.AlivePlayers)
				{
					if ((Object)(object)alivePlayer != (Object)null && (Object)(object)alivePlayer.Transform != (Object)null && alivePlayer.Transform.position.y - waterHeight > value)
					{
						return true;
					}
				}
			}
			catch
			{
			}
			return false;
		}

		private static void Sweep()
		{
			AttackingFish[] array = Object.FindObjectsByType<AttackingFish>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			foreach (AttackingFish val in array)
			{
				if ((Object)(object)val == (Object)null || Held.ContainsKey((Component)(object)val))
				{
					continue;
				}
				FieldInfo[] array2 = Layout(((object)val).GetType());
				if (array2.Length != 0)
				{
					float[] array3 = new float[array2.Length];
					for (int j = 0; j < array2.Length; j++)
					{
						array3[j] = (float)array2[j].GetValue(val);
						array2[j].SetValue(val, 0f);
					}
					Held[(Component)(object)val] = new Saved
					{
						Info = array2,
						Values = array3
					};
				}
			}
		}

		public static void Release()
		{
			foreach (KeyValuePair<Component, Saved> item in Held)
			{
				if (!((Object)(object)item.Key == (Object)null))
				{
					Saved value = item.Value;
					for (int i = 0; i < value.Info.Length; i++)
					{
						value.Info[i].SetValue(item.Key, value.Values[i]);
					}
				}
			}
			Held.Clear();
			_active = false;
		}

		private static FieldInfo[] Layout(Type type)
		{
			if (Layouts.TryGetValue(type, out var value))
			{
				return value;
			}
			List<FieldInfo> list = new List<FieldInfo>();
			string[] fields = Fields;
			foreach (string name in fields)
			{
				FieldInfo fieldInfo = Find(type, name);
				if (fieldInfo != null && fieldInfo.FieldType == typeof(float))
				{
					list.Add(fieldInfo);
				}
			}
			FieldInfo[] array = list.ToArray();
			Layouts[type] = array;
			Plugin.Log.LogDebug((object)("Calm: " + type.Name + " exposes " + array.Length + " chase force(s)."));
			return array;
		}

		private static FieldInfo Find(Type type, string name)
		{
			Type type2 = type;
			while (type2 != null)
			{
				FieldInfo field = type2.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					return field;
				}
				type2 = type2.BaseType;
			}
			return null;
		}
	}
	public static class JetCamera
	{
		private static readonly FieldInfo RotField = typeof(PlayerCamera).GetField("_rot", BindingFlags.Instance | BindingFlags.NonPublic);

		private static JetVehicle _jet;

		private static Quaternion _smoothed = Quaternion.identity;

		private static Vector3 _up = Vector3.up;

		private static Vector3 _prevForward = Vector3.forward;

		private static Vector3 _prevJetUp = Vector3.up;

		private static Vector2 _free;

		private static float _originalFov;

		private static bool _active;

		public static Quaternion Frame { get; private set; } = Quaternion.identity;

		public static bool Active => _active;

		public static void Begin(JetVehicle jet)
		{
			//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: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			_jet = jet;
			_free = Vector2.zero;
			_smoothed = ((Component)jet).transform.rotation;
			_up = Vector3.up;
			Frame = ((Component)jet).transform.rotation;
			_prevForward = ((Component)jet).transform.forward;
			_prevJetUp = ((Component)jet).transform.up;
			Camera val = Camera();
			_originalFov = (((Object)(object)val != (Object)null) ? val.fieldOfView : 0f);
			_active = true;
		}

		public static void End()
		{
			Camera val = Camera();
			if ((Object)(object)val != (Object)null && _originalFov > 0f)
			{
				val.fieldOfView = _originalFov;
			}
			_jet = null;
			_active = false;
		}

		public static void Tick()
		{
			//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_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_0068: 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_007d: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_00eb: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: 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)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//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_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			if (!_active || (Object)(object)_jet == (Object)null || !_jet.FlownLocally)
			{
				return;
			}
			Player localPlayer = Player.LocalPlayer;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)localPlayer.Camera == (Object)null)
			{
				return;
			}
			Transform camTransform = localPlayer.Camera.CamTransform;
			if (!((Object)(object)camTransform == (Object)null))
			{
				ModConfig cfg = Plugin.Cfg;
				float deltaTime = Time.deltaTime;
				if (JetInput.FreeLook)
				{
					_free += JetInput.FreeLookDelta * cfg.FreeLookSensitivity.Value;
					_free.y = Mathf.Clamp(_free.y, -80f, 80f);
				}
				else
				{
					_free = Vector2.MoveTowards(_free, Vector2.zero, 220f * deltaTime);
				}
				Quaternion val = Upright(((Component)_jet).transform.forward, deltaTime, cfg);
				Quaternion val2 = AimLead(val, val, cfg);
				_smoothed = Quaternion.Slerp(_smoothed, val2, Mathf.Clamp01(deltaTime * cfg.CameraLag.Value));
				Frame = _smoothed;
				Quaternion val3 = (camTransform.rotation = _smoothed * Quaternion.Euler(0f - _free.y, _free.x, 0f));
				camTransform.position = ((Component)_jet).transform.position - val3 * Vector3.forward * cfg.CameraDistance.Value + val3 * Vector3.up * cfg.CameraHeight.Value;
				Vector3 eulerAngles = ((Quaternion)(ref val3)).eulerAngles;
				RotField?.SetValue(localPlayer.Camera, (object)new Vector3(Mathf.DeltaAngle(0f, eulerAngles.x), eulerAngles.y, 0f));
				Camera val5 = Camera();
				if (!((Object)(object)val5 == (Object)null) && !(_originalFov <= 0f))
				{
					float num = Mathf.Clamp01(_jet.Speed / Mathf.Max(cfg.MaxSpeed.Value, 1f));
					val5.fieldOfView = Mathf.Lerp(val5.fieldOfView, _originalFov + cfg.CameraFovBoost.Value * num, deltaTime * 4f);
				}
			}
		}

		private static Quaternion Upright(Vector3 forward, float dt, ModConfig cfg)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_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)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_002f: 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_007a: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing