Decompiled source of Kaiju Project v0.2.2

kaiju project.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DM;
using HarmonyLib;
using KaijuProject.Unified;
using Landfall.MonoBatch;
using Landfall.TABS;
using Landfall.TABS.AI;
using Landfall.TABS.GameMode;
using Landfall.TABS.GameState;
using Landfall.TABS.UnitPlacement;
using TFBGames;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;

[assembly: AssemblyInformationalVersion("0.2.0")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyTitle("kaiju project")]
[assembly: AssemblyProduct("kaiju project")]
[assembly: AssemblyDescription("Godzilla 1954, Mothra 1961 and Mothra Larva 1961 in one BepInEx assembly")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyVersion("0.2.0.0")]
namespace KaijuProject.Unified
{
	internal static class KaijuResourceManifest
	{
		internal const string CacheTag = "0.2.0-66a1f1fd7692f70b";

		internal static readonly KaijuAsset[] Assets = new KaijuAsset[8]
		{
			new KaijuAsset("Kaiju.Project.Asset.00.gz", "Adult/Mothra1961.unitydata", 147938860L, "3A43DA486C543E1587E2D7D4847E49080FDE99C48DCCDB73660200416C9B6476"),
			new KaijuAsset("Kaiju.Project.Asset.01.gz", "Larva/MothraLarva1961.unitydata", 11492238L, "4518751794FD4A4500D673361AA5C70999E7764AA7DCFC1B1FD086A8083491EE"),
			new KaijuAsset("Kaiju.Project.Asset.02.gz", "Larva/LarvaSkin.png", 1189030L, "2C862A68611CA01FF21538BC8BDC957B6B15D5B616833A3E06F31A72B5B81A5B"),
			new KaijuAsset("Kaiju.Project.Asset.03.gz", "Larva/LarvaIcon.png", 233024L, "2D64A101029407C7B4DED6177BC210088B26B8A527C6052B32F31C3E5C078D31"),
			new KaijuAsset("Kaiju.Project.Asset.04.gz", "Larva/LarvaBodyImpact.wav", 211724L, "5A5217ABF25AA5C9C01B95BD881CCF49823B0440A863BD1EAD1032C30B0DCD5D"),
			new KaijuAsset("Kaiju.Project.Asset.05.gz", "SharedAudio/Mothra_(1961)_Roar_01.ogg", 56315L, "B310E8599A3EE0914096F7BB1A3744F70746D7F21C2BE051A811A86758036992"),
			new KaijuAsset("Kaiju.Project.Asset.06.gz", "SharedAudio/Mothra_Roars_Showa.ogg", 21276L, "6A7005350C16B10AE39DFA73192B53FD495D492AF24A5B553AB5275D834C7399"),
			new KaijuAsset("Kaiju.Project.Asset.07.gz", "SharedAudio/Showa_Mothra_SFX.ogg", 31436L, "613BF951F145F79539F82CF6F5CB5B35598A825089FBAA6392C1645670151732")
		};
	}
	internal sealed class KaijuAsset
	{
		internal readonly string Resource;

		internal readonly string Relative;

		internal readonly string Sha256;

		internal readonly long Bytes;

		internal KaijuAsset(string resource, string relative, long bytes, string sha)
		{
			Resource = resource;
			Relative = relative;
			Bytes = bytes;
			Sha256 = sha;
		}
	}
	public static class KaijuResources
	{
		private static readonly object Gate = new object();

		private static string root;

		public static string CacheRoot
		{
			get
			{
				Prepare();
				return root;
			}
		}

		public static string AdultAssetPath => Path.Combine(CacheRoot, "Adult", "Mothra1961.unitydata");

		public static string LarvaAssetFolder => Path.Combine(CacheRoot, "Larva");

		public static string SharedAudioFolder => Path.Combine(CacheRoot, "SharedAudio");

		private static bool Valid(string path, KaijuAsset asset)
		{
			if (!File.Exists(path) || new FileInfo(path).Length != asset.Bytes)
			{
				return false;
			}
			using FileStream inputStream = File.OpenRead(path);
			using SHA256 sHA = SHA256.Create();
			return BitConverter.ToString(sHA.ComputeHash(inputStream)).Replace("-", "").Equals(asset.Sha256, StringComparison.OrdinalIgnoreCase);
		}

		private static void Prepare()
		{
			lock (Gate)
			{
				if (root != null)
				{
					return;
				}
				string fullPath = Path.GetFullPath(Path.Combine(Paths.BepInExRootPath, "cache", "KaijuProject", "0.2.0-66a1f1fd7692f70b"));
				Directory.CreateDirectory(fullPath);
				string value = fullPath + Path.DirectorySeparatorChar;
				KaijuAsset[] assets = KaijuResourceManifest.Assets;
				foreach (KaijuAsset kaijuAsset in assets)
				{
					string fullPath2 = Path.GetFullPath(Path.Combine(fullPath, kaijuAsset.Relative.Replace('/', Path.DirectorySeparatorChar)));
					if (!fullPath2.StartsWith(value, StringComparison.OrdinalIgnoreCase))
					{
						throw new InvalidDataException("Kaiju resource path escapes cache");
					}
					if (Valid(fullPath2, kaijuAsset))
					{
						continue;
					}
					Directory.CreateDirectory(Path.GetDirectoryName(fullPath2));
					string text = fullPath2 + ".tmp-" + Guid.NewGuid().ToString("N");
					try
					{
						using (Stream stream = typeof(KaijuResources).Assembly.GetManifestResourceStream(kaijuAsset.Resource))
						{
							if (stream == null)
							{
								throw new InvalidDataException("Missing Kaiju resource " + kaijuAsset.Resource);
							}
							using GZipStream gZipStream = new GZipStream(stream, CompressionMode.Decompress);
							using FileStream destination = new FileStream(text, FileMode.CreateNew, FileAccess.Write, FileShare.None);
							gZipStream.CopyTo(destination);
						}
						if (!Valid(text, kaijuAsset))
						{
							throw new InvalidDataException("Kaiju asset integrity mismatch: " + kaijuAsset.Relative);
						}
						if (File.Exists(fullPath2))
						{
							File.Delete(fullPath2);
						}
						File.Move(text, fullPath2);
					}
					finally
					{
						if (File.Exists(text))
						{
							File.Delete(text);
						}
					}
				}
				root = fullPath;
			}
		}
	}
}
namespace Mothra1961.Flight
{
	internal sealed class MothraAnimationDriver
	{
		public readonly Dictionary<string, Transform> Bones;

		private readonly GameObject visual;

		private readonly Animation animation;

		private readonly Dictionary<string, Quaternion> rest;

		private float bank;

		public MothraAnimationDriver(GameObject v)
		{
			visual = v;
			animation = v.GetComponent<Animation>();
			animation.Stop();
			((Behaviour)animation).enabled = false;
			Bones = v.GetComponentsInChildren<Transform>().ToDictionary((Transform t) => ((Object)t).name);
			rest = Bones.ToDictionary((KeyValuePair<string, Transform> p) => p.Key, (KeyValuePair<string, Transform> p) => p.Value.localRotation);
		}

		public Quaternion RestRotation(string name)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return rest[name];
		}

		public void Sample(FlightState state, float age, float clock, float yawRate, float ground, float altitude, FlightSettings cfg)
		{
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			object obj;
			switch (state)
			{
			default:
				obj = ((Mathf.Abs(yawRate) > 0.08f) ? "AirTurn" : "Flight");
				break;
			case FlightState.Attacking:
				obj = "Attack";
				break;
			case FlightState.Landing:
				obj = "Landing";
				break;
			case FlightState.Takeoff:
				obj = "Takeoff";
				break;
			case FlightState.Placement:
			case FlightState.Grounded:
				obj = "Idle";
				break;
			}
			string text = (string)obj;
			AnimationClip clip = animation.GetClip(text);
			float num;
			switch (text)
			{
			default:
				num = Mathf.Min(age, clip.length);
				break;
			case "Flight":
			case "AirTurn":
			case "Idle":
				num = clock % clip.length;
				break;
			}
			float num2 = num;
			clip.SampleAnimation(visual, num2);
			Transform val = Bones["Root"];
			float num3;
			switch (text)
			{
			default:
				num3 = 0f;
				break;
			case "Landing":
				num3 = 90f * (1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.1f, 6.2f, age)));
				break;
			case "Takeoff":
				num3 = 90f * Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.9f, 6.4f, age));
				break;
			case "Flight":
			case "AirTurn":
			case "Attack":
				num3 = 90f;
				break;
			}
			float num4 = num3;
			val.localPosition = new Vector3(0f, Mathf.Clamp(val.localPosition.y - num4, -1.2f, 1.2f), 0f);
			val.localRotation = rest["Root"];
			float num5 = Mathf.InverseLerp(13.75f, 38.5f, altitude - ground);
			bank = Mathf.Lerp(bank, Mathf.Clamp((0f - yawRate) * 57.29578f / cfg.TurnSpeed * cfg.MaximumBank, 0f - cfg.MaximumBank, cfg.MaximumBank) * num5, 1f - Mathf.Exp((0f - Time.fixedDeltaTime) * 4f));
			Transform val2 = Bones["Body"];
			Quaternion val3 = Quaternion.Inverse(rest["Body"]) * val2.localRotation;
			float num6 = Mathf.DeltaAngle(0f, ((Quaternion)(ref val3)).eulerAngles.x);
			val2.localRotation = rest["Body"] * Quaternion.Euler(num6 * num5, 0f, bank);
			if (!(num5 < 0.999f) || !(text != "Idle"))
			{
				return;
			}
			foreach (KeyValuePair<string, Transform> bone in Bones)
			{
				if (bone.Key.StartsWith("Wing.") || bone.Key.StartsWith("Edge."))
				{
					bone.Value.localRotation = Quaternion.Slerp(rest[bone.Key], bone.Value.localRotation, num5);
					if (bone.Key.StartsWith("Wing.") && bone.Key.EndsWith(".01"))
					{
						bool flag = bone.Key.Contains(".L.");
						bone.Value.rotation = Quaternion.AngleAxis(flag ? (-10f * (1f - num5)) : (10f * (1f - num5)), visual.transform.forward) * bone.Value.rotation;
					}
				}
			}
		}
	}
	public static class MothraAssets
	{
		private static GameObject template;

		public static readonly Dictionary<string, Bounds> BoneBounds = new Dictionary<string, Bounds>();

		public static GameObject CreateVisual(string path)
		{
			if ((Object)(object)template == (Object)null)
			{
				Load(path);
			}
			GameObject val = Object.Instantiate<GameObject>(template);
			((Object)val).hideFlags = (HideFlags)0;
			((Object)val).name = "Mothra1961 Visual";
			val.SetActive(true);
			return val;
		}

		private static string Str(BinaryReader r)
		{
			int num = r.ReadInt32();
			if (num < 0 || num > 256)
			{
				throw new InvalidDataException("Invalid name");
			}
			return Encoding.UTF8.GetString(r.ReadBytes(num));
		}

		private static Matrix4x4 Mat(BinaryReader r)
		{
			//IL_0002: 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)
			Matrix4x4 result = default(Matrix4x4);
			for (int i = 0; i < 4; i++)
			{
				for (int j = 0; j < 4; j++)
				{
					((Matrix4x4)(ref result))[i, j] = r.ReadSingle();
				}
			}
			return result;
		}

		private static void Load(string path)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//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_00e3: 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_00ef: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: 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_028a: 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_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Expected O, but got Unknown
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Expected O, but got Unknown
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cc: Expected O, but got Unknown
			//IL_0598: Unknown result type (might be due to invalid IL or missing references)
			//IL_059d: Unknown result type (might be due to invalid IL or missing references)
			//IL_062a: Unknown result type (might be due to invalid IL or missing references)
			//IL_062f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fd: Expected O, but got Unknown
			//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
			using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path));
			if (Encoding.ASCII.GetString(binaryReader.ReadBytes(8)) != "MOTHRA02")
			{
				throw new InvalidDataException("Invalid Mothra asset");
			}
			int num = binaryReader.ReadInt32();
			int num2 = binaryReader.ReadInt32();
			int num3 = binaryReader.ReadInt32();
			if (num != 111 || num2 < 3 || num2 > 5000000 || num3 < 1 || num3 > 512)
			{
				throw new InvalidDataException("Invalid counts");
			}
			template = new GameObject("Mothra shared asset template");
			template.SetActive(false);
			((Object)template).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)template);
			Transform[] array = (Transform[])(object)new Transform[num];
			Matrix4x4[] array2 = (Matrix4x4[])(object)new Matrix4x4[num];
			string[] array3 = new string[num];
			for (int i = 0; i < num; i++)
			{
				string text = Str(binaryReader);
				int num4 = binaryReader.ReadInt32();
				Matrix4x4 val = Mat(binaryReader);
				ref Matrix4x4 reference = ref array2[i];
				reference = Mat(binaryReader);
				Transform transform = new GameObject(text).transform;
				transform.SetParent((num4 < 0) ? template.transform : array[num4], false);
				transform.localPosition = Vector4.op_Implicit(((Matrix4x4)(ref val)).GetColumn(3));
				transform.localRotation = ((Matrix4x4)(ref val)).rotation;
				transform.localScale = ((Matrix4x4)(ref val)).lossyScale;
				array[i] = transform;
				array3[i] = ((num4 < 0) ? "" : (array3[num4] + "/")) + text;
			}
			Vector3[] array4 = (Vector3[])(object)new Vector3[num2];
			Vector3[] array5 = (Vector3[])(object)new Vector3[num2];
			BoneWeight[] array6 = (BoneWeight[])(object)new BoneWeight[num2];
			for (int j = 0; j < num2; j++)
			{
				ref Vector3 reference2 = ref array4[j];
				reference2 = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
				ref Vector3 reference3 = ref array5[j];
				reference3 = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
				BoneWeight val2 = default(BoneWeight);
				((BoneWeight)(ref val2)).boneIndex0 = binaryReader.ReadInt32();
				((BoneWeight)(ref val2)).boneIndex1 = binaryReader.ReadInt32();
				((BoneWeight)(ref val2)).boneIndex2 = binaryReader.ReadInt32();
				((BoneWeight)(ref val2)).boneIndex3 = binaryReader.ReadInt32();
				((BoneWeight)(ref val2)).weight0 = binaryReader.ReadSingle();
				((BoneWeight)(ref val2)).weight1 = binaryReader.ReadSingle();
				((BoneWeight)(ref val2)).weight2 = binaryReader.ReadSingle();
				((BoneWeight)(ref val2)).weight3 = binaryReader.ReadSingle();
				BoneWeight val3 = val2;
				array6[j] = val3;
				Transform val4 = array[((BoneWeight)(ref val3)).boneIndex0];
				Vector3 val5 = val4.InverseTransformPoint(array4[j]);
				if (BoneBounds.TryGetValue(((Object)val4).name, out var value))
				{
					((Bounds)(ref value)).Encapsulate(val5);
					BoneBounds[((Object)val4).name] = value;
				}
				else
				{
					BoneBounds.Add(((Object)val4).name, new Bounds(val5, Vector3.one * 0.02f));
				}
			}
			Mesh val6 = new Mesh();
			((Object)val6).name = "Mothra indexed skinned mesh";
			val6.indexFormat = (IndexFormat)1;
			Mesh val7 = val6;
			val7.vertices = array4;
			val7.normals = array5;
			val7.boneWeights = array6;
			val7.bindposes = array2;
			val7.subMeshCount = num3;
			Material[] array7 = (Material[])(object)new Material[num3];
			Color color = default(Color);
			for (int k = 0; k < num3; k++)
			{
				((Color)(ref color))..ctor(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
				int num5 = binaryReader.ReadInt32();
				int[] array8 = new int[num5];
				for (int l = 0; l < num5; l++)
				{
					array8[l] = binaryReader.ReadInt32();
				}
				val7.SetTriangles(array8, k);
				int num6 = k;
				Material val8 = new Material(Shader.Find("Standard"));
				val8.color = color;
				array7[num6] = val8;
				array7[k].SetFloat("_Glossiness", 0.08f);
				array7[k].SetFloat("_Metallic", 0f);
			}
			val7.RecalculateBounds();
			SkinnedMeshRenderer val9 = template.AddComponent<SkinnedMeshRenderer>();
			val9.sharedMesh = val7;
			((Renderer)val9).sharedMaterials = array7;
			val9.bones = array;
			val9.rootBone = array[0];
			val9.localBounds = new Bounds(new Vector3(0f, 15f, 0f), new Vector3(300f, 230f, 170f));
			val9.updateWhenOffscreen = true;
			Animation val10 = template.AddComponent<Animation>();
			val10.playAutomatically = false;
			((Behaviour)val10).enabled = false;
			val10.cullingType = (AnimationCullingType)0;
			int num7 = binaryReader.ReadInt32();
			string[] array9 = new string[10] { "localPosition.x", "localPosition.y", "localPosition.z", "localRotation.x", "localRotation.y", "localRotation.z", "localRotation.w", "localScale.x", "localScale.y", "localScale.z" };
			for (int m = 0; m < num7; m++)
			{
				string text2 = Str(binaryReader);
				binaryReader.ReadSingle();
				bool flag = binaryReader.ReadInt32() != 0;
				int num8 = binaryReader.ReadInt32();
				Keyframe[][] array10 = new Keyframe[num * 10][];
				for (int n = 0; n < array10.Length; n++)
				{
					array10[n] = (Keyframe[])(object)new Keyframe[num8];
				}
				for (int num9 = 0; num9 < num8; num9++)
				{
					float num10 = binaryReader.ReadSingle();
					for (int num11 = 0; num11 < num; num11++)
					{
						for (int num12 = 0; num12 < 10; num12++)
						{
							ref Keyframe reference4 = ref array10[num11 * 10 + num12][num9];
							reference4 = new Keyframe(num10, binaryReader.ReadSingle());
						}
					}
				}
				AnimationClip val11 = new AnimationClip();
				((Object)val11).name = text2;
				val11.legacy = true;
				val11.frameRate = 30f;
				val11.wrapMode = (WrapMode)(flag ? 2 : 8);
				AnimationClip val12 = val11;
				for (int num13 = 0; num13 < num; num13++)
				{
					for (int num14 = 0; num14 < 10; num14++)
					{
						Keyframe[] array11 = array10[num13 * 10 + num14];
						for (int num15 = 0; num15 < num8; num15++)
						{
							Keyframe val13 = array11[num15];
							((Keyframe)(ref val13)).inTangent = ((num15 > 0) ? ((((Keyframe)(ref val13)).value - ((Keyframe)(ref array11[num15 - 1])).value) / (((Keyframe)(ref val13)).time - ((Keyframe)(ref array11[num15 - 1])).time)) : 0f);
							((Keyframe)(ref val13)).outTangent = ((num15 + 1 < num8) ? ((((Keyframe)(ref array11[num15 + 1])).value - ((Keyframe)(ref val13)).value) / (((Keyframe)(ref array11[num15 + 1])).time - ((Keyframe)(ref val13)).time)) : 0f);
							array11[num15] = val13;
						}
						val12.SetCurve(array3[num13], typeof(Transform), array9[num14], new AnimationCurve(array11));
					}
				}
				val12.EnsureQuaternionContinuity();
				val10.AddClip(val12, text2);
			}
			if (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length)
			{
				throw new InvalidDataException("Trailing asset data");
			}
		}
	}
	public static class MothraCallBank
	{
		public static readonly string[] Files = new string[3] { "Mothra_(1961)_Roar_01.ogg", "Mothra_Roars_Showa.ogg", "Showa_Mothra_SFX.ogg" };

		public static readonly AudioClip[] Clips = (AudioClip[])(object)new AudioClip[3];

		private static readonly int[] ready = new int[3];

		private static bool requested;

		public static int ReadyCount { get; private set; }

		public static IEnumerator Load(string directory, Action<string> log)
		{
			if (requested)
			{
				yield break;
			}
			requested = true;
			for (int i = 0; i < Files.Length; i++)
			{
				string path = Path.Combine(directory, Files[i]);
				if (!File.Exists(path))
				{
					log("MOTHRA_CALL_MISSING " + Files[i]);
					continue;
				}
				UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(new Uri(path).AbsoluteUri, (AudioType)14);
				try
				{
					DownloadHandlerAudioClip handler = (DownloadHandlerAudioClip)request.downloadHandler;
					handler.streamAudio = false;
					yield return request.SendWebRequest();
					if (request.isNetworkError || request.isHttpError)
					{
						log("MOTHRA_CALL_DECODE_FAILED " + Files[i] + ": " + request.error);
						continue;
					}
					AudioClip clip = DownloadHandlerAudioClip.GetContent(request);
					if ((Object)(object)clip == (Object)null || clip.length <= 0f)
					{
						log("MOTHRA_CALL_EMPTY " + Files[i]);
						continue;
					}
					((Object)clip).name = Files[i];
					Clips[i] = clip;
					ready[ReadyCount++] = i;
					log("MOTHRA_CALL_READY file=" + Files[i] + " duration=" + clip.length + " channels=" + clip.channels);
				}
				finally
				{
					((IDisposable)request)?.Dispose();
				}
			}
		}

		public static int LoadedIndex(int slot)
		{
			if (slot < 0 || slot >= ReadyCount)
			{
				return -1;
			}
			return ready[slot];
		}
	}
	public sealed class MothraCallClock
	{
		public const double Interval = 9.0;

		private readonly Random random;

		private double elapsed;

		public double Elapsed => elapsed;

		public MothraCallClock(int seed)
		{
			random = new Random(seed);
		}

		public void Reset()
		{
			elapsed = 0.0;
		}

		public int Advance(float delta, bool active, int choices)
		{
			if (!active)
			{
				Reset();
				return -1;
			}
			if (delta <= 0f || float.IsNaN(delta) || float.IsInfinity(delta))
			{
				return -1;
			}
			elapsed += delta;
			if (elapsed + 1E-06 < 9.0)
			{
				return -1;
			}
			elapsed = Math.Max(0.0, elapsed - 9.0);
			if (elapsed >= 9.0)
			{
				elapsed %= 9.0;
			}
			if (choices <= 0)
			{
				return -1;
			}
			return random.Next(choices);
		}
	}
	[DisallowMultipleComponent]
	public sealed class MothraCallAudio : MonoBehaviour
	{
		private MothraCallClock clock;

		public MothraFlightController Flight { get; private set; }

		public AudioSource Source { get; private set; }

		public int PlaybackCount { get; private set; }

		public int LastClipIndex { get; private set; }

		public event Action<int, float> Played;

		public void Initialize(MothraFlightController flight)
		{
			if ((Object)(object)Flight != (Object)null)
			{
				throw new InvalidOperationException("Mothra call audio already initialized");
			}
			Flight = flight;
			clock = new MothraCallClock(Environment.TickCount ^ ((Object)this).GetInstanceID());
			LastClipIndex = -1;
			AudioSource[] componentsInChildren = ((Component)flight.Owner).GetComponentsInChildren<AudioSource>(true);
			Source = ((Component)flight.Bone("Head")).gameObject.AddComponent<AudioSource>();
			Source.playOnAwake = false;
			Source.loop = false;
			Source.spatialBlend = 1f;
			Source.rolloffMode = (AudioRolloffMode)1;
			Source.minDistance = 30f;
			Source.maxDistance = 600f;
			Source.dopplerLevel = 0f;
			Source.pitch = 1f;
			Source.volume = 0.85f;
			Source.priority = 80;
			Source.ignoreListenerPause = false;
			AudioSource[] array = componentsInChildren;
			foreach (AudioSource val in array)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)val.outputAudioMixerGroup != (Object)null)
				{
					Source.outputAudioMixerGroup = val.outputAudioMixerGroup;
					break;
				}
			}
		}

		private void Update()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			if ((Object)(object)Flight == (Object)null || !MothraFlightController.Alive(Flight.Owner))
			{
				Stop();
				((Behaviour)this).enabled = false;
				return;
			}
			GameStateManager service = ServiceLocator.GetService<GameStateManager>();
			if (service == null || (int)service.GameState != 1)
			{
				clock.Reset();
				if (Source.isPlaying)
				{
					Source.Stop();
				}
				return;
			}
			int num = clock.Advance(Time.deltaTime, active: true, MothraCallBank.ReadyCount);
			if (num < 0)
			{
				return;
			}
			int num2 = MothraCallBank.LoadedIndex(num);
			AudioClip val = ((num2 >= 0) ? MothraCallBank.Clips[num2] : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Source.Stop();
			Source.clip = val;
			Source.Play();
			LastClipIndex = num2;
			PlaybackCount++;
			Action<int, float> played = this.Played;
			if (played == null)
			{
				return;
			}
			Delegate[] invocationList = played.GetInvocationList();
			for (int i = 0; i < invocationList.Length; i++)
			{
				Action<int, float> action = (Action<int, float>)invocationList[i];
				try
				{
					action(num2, Time.time);
				}
				catch (Exception ex)
				{
					Debug.LogException(ex);
				}
			}
		}

		private void Stop()
		{
			if (clock != null)
			{
				clock.Reset();
			}
			if ((Object)(object)Source != (Object)null)
			{
				Source.Stop();
			}
		}

		private void OnDisable()
		{
			Stop();
		}

		private void OnDestroy()
		{
			Stop();
			if ((Object)(object)Source != (Object)null)
			{
				Object.Destroy((Object)(object)Source);
			}
		}
	}
	public enum MothraSkill
	{
		None,
		Wind,
		DiveAlign,
		DiveStrike,
		DiveRecover,
		Basic
	}
	[DefaultExecutionOrder(-100)]
	public sealed class MothraCombat : MonoBehaviour
	{
		public const float BaseDamage = 3300f;

		public const float WindDuration = 25f;

		public const float WindCooldown = 40f;

		public const float DiveCooldown = 15f;

		public const float WindRange = 2000f;

		public const float WindDamageRatio = 0.15f;

		public const float WindLargeMultiplier = 1.2f;

		public const float DivePrimaryMultiplier = 13f;

		public const float DiveCollateralMultiplier = 5f;

		private const float Size = 0.55f;

		public bool Automatic = true;

		private readonly HashSet<Unit> struck = new HashSet<Unit>();

		private MothraEffects fx;

		private MothraWindMotion windMotion;

		private MothraDiveMotion diveMotion;

		private MothraDiveEffects diveFx;

		private float diveSpeed;

		private float divePitch;

		private Vector3 lastDiveVelocity;

		private bool initialized;

		private float tick;

		private float basicDelay;

		private float chooseAt;

		private float focusAt;

		private float windScan;

		private float recoveryAltitude;

		private float noProgress;

		private int castTicks;

		private MothraSkill planned;

		private Vector3 previousHead;

		private Vector3 diveDirection;

		private Vector3 windForward;

		private Vector3 windAim;

		private Vector3 plannedWindAim;

		private readonly Collider[] diveContacts = (Collider[])(object)new Collider[256];

		private readonly HashSet<Unit> diveUnits = new HashSet<Unit>();

		public MothraFlightController Flight { get; private set; }

		public MothraSkill Skill { get; private set; }

		public Unit Locked { get; private set; }

		public Unit Focus { get; private set; }

		public float WindRemaining { get; private set; }

		public float DiveRemaining { get; private set; }

		public float Age { get; private set; }

		public int WindTicks { get; private set; }

		public int DiveHits { get; private set; }

		public int BasicHits { get; private set; }

		public int TargetSwitches { get; private set; }

		public int WindReaims { get; private set; }

		public int DiveAttempts { get; private set; }

		public int BasicAttempts { get; private set; }

		public bool IsApproaching { get; private set; }

		public bool IsRepositioning { get; private set; }

		public Vector3 WindDirection => windForward;

		public Vector3 WindAimDirection => windAim;

		public float DiveSpeed => diveSpeed;

		public event Action<Unit, float, string> DamageApplied;

		private float DivePosePitch(float desired)
		{
			divePitch = Mathf.MoveTowardsAngle(divePitch, desired, Time.fixedDeltaTime * 110f);
			return divePitch;
		}

		public void Initialize(MothraFlightController flight)
		{
			Flight = flight;
			flight.Settings.AutoAttack = false;
			fx = ((Component)this).gameObject.AddComponent<MothraEffects>();
			fx.Initialize(flight);
			windMotion = new MothraWindMotion(flight);
			diveMotion = new MothraDiveMotion(flight);
			diveFx = ((Component)this).gameObject.AddComponent<MothraDiveEffects>();
			flight.Order.AfterPose = Pose;
			initialized = true;
		}

		private bool Enemy(Unit u)
		{
			//IL_001c: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			if (MothraFlightController.Alive(u) && (Object)(object)u != (Object)(object)Flight.Owner && u.Team != Flight.Owner.Team)
			{
				return Finite(MothraFlightController.Position(u));
			}
			return false;
		}

		private static bool Finite(Vector3 p)
		{
			if (!float.IsNaN(p.x) && !float.IsNaN(p.y) && !float.IsNaN(p.z))
			{
				return !float.IsInfinity(((Vector3)(ref p)).sqrMagnitude);
			}
			return false;
		}

		private Vector3 HeadPoint()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Flight.MouthPosition;
		}

		private void SetFocus(Unit u)
		{
			if (!((Object)(object)Focus == (Object)(object)u))
			{
				Focus = u;
				focusAt = Time.time;
				TargetSwitches++;
				Flight.SetTarget(u);
			}
		}

		public static bool InWind(Vector3 origin, Vector3 forward, Vector3 point, float radius)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: 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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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)
			Vector3 val = point - origin;
			float num = Vector3.Dot(val, forward);
			if (num < 0f - radius || num > 2000f + radius)
			{
				return false;
			}
			float num2 = Vector3.Dot(val, Vector3.Cross(Vector3.up, forward));
			if (Mathf.Abs(num2) <= 66f + Mathf.Max(0f, num) * 0.35f + radius)
			{
				return Mathf.Abs(val.y) <= 120f + Mathf.Max(0f, num) * 0.15f + radius;
			}
			return false;
		}

		public static float WindFalloff(float distance)
		{
			if (float.IsNaN(distance) || float.IsInfinity(distance))
			{
				return 0f;
			}
			return Mathf.Clamp01(1f - Mathf.Max(0f, distance) * 0.05f / 100f);
		}

		public static float WindDamage(float distance, bool large)
		{
			return 495.00003f * WindFalloff(distance) * (large ? 1.2f : 1f);
		}

		public static float SweepDistance(Vector3 a, Vector3 b, Vector3 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: 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_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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = b - a;
			float num = ((((Vector3)(ref val)).sqrMagnitude > 0.001f) ? Mathf.Clamp01(Vector3.Dot(p - a, val) / ((Vector3)(ref val)).sqrMagnitude) : 0f);
			return Vector3.Distance(a + val * num, p);
		}

		public MothraSkill Preferred()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			MothraRoster.Choose(Flight.Owner, Flight.Body.position, out var high, out var near, out var low);
			return Decide(high, near, low);
		}

		private MothraSkill Decide(Unit high, Unit near, int low)
		{
			if ((Object)(object)high != (Object)null && DiveRemaining <= 0f)
			{
				return MothraSkill.DiveAlign;
			}
			if (low >= MothraPlugin.CrowdThreshold && WindRemaining <= 0f)
			{
				return MothraSkill.Wind;
			}
			if (WindRemaining <= 0f && (Object)(object)near != (Object)null)
			{
				return MothraSkill.Wind;
			}
			if (DiveRemaining <= 0f && (Object)(object)near != (Object)null)
			{
				return MothraSkill.DiveAlign;
			}
			if (!((Object)(object)near != (Object)null) || !(WindRemaining > 0f) || !(DiveRemaining > 0f))
			{
				return MothraSkill.None;
			}
			return MothraSkill.Basic;
		}

		private void SelectPlan()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			MothraRoster.Choose(Flight.Owner, Flight.Body.position, out var high, out var near, out var low);
			planned = Decide(high, near, low);
			Unit val = ((planned == MothraSkill.DiveAlign && (Object)(object)high != (Object)null) ? high : near);
			if ((Object)(object)val == (Object)null)
			{
				SetFocus(null);
				return;
			}
			bool flag = planned == MothraSkill.DiveAlign && (Object)(object)high != (Object)null;
			if (Enemy(Focus) && (!flag || MothraRoster.Info(Focus).High))
			{
				Vector3 val2 = MothraFlightController.Position(Focus) - Flight.Body.position;
				float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
				Vector3 val3 = MothraFlightController.Position(val) - Flight.Body.position;
				float sqrMagnitude2 = ((Vector3)(ref val3)).sqrMagnitude;
				if (Time.time - focusAt < 2f || sqrMagnitude2 > sqrMagnitude * 0.65f * 0.65f)
				{
					val = Focus;
				}
			}
			SetFocus(val);
			if (planned == MothraSkill.Wind)
			{
				plannedWindAim = BestWindHeading(out var _);
			}
		}

		public bool Begin(MothraSkill skill, Unit target)
		{
			//IL_00d9: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: 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_0145: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			if (!initialized || !Enemy(target) || Skill != MothraSkill.None || MothraReferences.Silenced(Flight.Owner))
			{
				return false;
			}
			if (skill != MothraSkill.Wind && skill != MothraSkill.DiveAlign && skill != MothraSkill.Basic)
			{
				return false;
			}
			if ((skill == MothraSkill.Wind && WindRemaining > 0f) || (skill == MothraSkill.DiveAlign && DiveRemaining > 0f) || (skill == MothraSkill.Basic && (WindRemaining <= 0f || DiveRemaining <= 0f)))
			{
				return false;
			}
			Locked = target;
			SetFocus(target);
			Flight.SetTarget(target);
			Skill = skill;
			Age = 0f;
			tick = 0f;
			castTicks = 0;
			windScan = Time.time + 0.7f;
			struck.Clear();
			previousHead = HeadPoint();
			Vector3 val = Vector3.ProjectOnPlane(MothraFlightController.Position(target) - Flight.Body.position, Vector3.up);
			windAim = ((Vector3)(ref val)).normalized;
			if (((Vector3)(ref windAim)).sqrMagnitude < 0.1f)
			{
				windAim = ((Component)this).transform.forward;
			}
			windForward = ((Component)this).transform.forward;
			diveDirection = windAim;
			noProgress = 0f;
			bool isApproaching = (IsRepositioning = false);
			IsApproaching = isApproaching;
			if (skill == MothraSkill.DiveAlign)
			{
				DiveAttempts++;
				diveSpeed = 16f;
				divePitch = 0f;
				lastDiveVelocity = Flight.Body.velocity;
			}
			if (skill == MothraSkill.Basic)
			{
				BasicAttempts++;
			}
			return true;
		}

		private void Finish()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			if (Skill == MothraSkill.Wind)
			{
				WindRemaining = 40f;
			}
			if (Skill == MothraSkill.DiveRecover || Skill == MothraSkill.DiveAlign || Skill == MothraSkill.DiveStrike)
			{
				DiveRemaining = 15f;
			}
			if (Skill == MothraSkill.Basic)
			{
				basicDelay = 2.8f;
			}
			Skill = MothraSkill.None;
			Age = 0f;
			chooseAt = 0f;
			Flight.Order.Active = false;
			bool isApproaching = (IsRepositioning = false);
			IsApproaching = isApproaching;
			fx.Wind(on: false, Vector3.zero, Vector3.forward);
		}

		private void Recover()
		{
			//IL_002b: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0092: Unknown result type (might be due to invalid IL or missing references)
			if (Skill != MothraSkill.DiveRecover)
			{
				Vector3 val = Vector3.ProjectOnPlane((((Vector3)(ref lastDiveVelocity)).sqrMagnitude > 1f) ? lastDiveVelocity : ((Component)this).transform.forward, Vector3.up);
				diveDirection = ((Vector3)(ref val)).normalized;
				Skill = MothraSkill.DiveRecover;
				Age = 0f;
				recoveryAltitude = Mathf.Min(Flight.GroundHeight + Flight.Settings.MaximumAltitude, Mathf.Max(Flight.GroundHeight + 52.25f, Flight.Body.position.y + 19.25f));
			}
		}

		private void Defaults()
		{
			//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)
			MothraFlightOrder order = Flight.Order;
			order.Active = true;
			order.DirectVelocity = false;
			order.AnimationRate = 1f;
			order.Pitch = 0f;
			order.Acceleration = 14f;
			order.ClimbSpeed = 20f;
			order.TurnSpeed = 48f;
			order.FloorMargin = Flight.Settings.MinimumAltitude;
			order.Altitude = Flight.GroundHeight + 35.75f;
			order.Velocity = Vector3.zero;
			bool isApproaching = (IsRepositioning = false);
			IsApproaching = isApproaching;
		}

		private void FixedUpdate()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Invalid comparison between Unknown and I4
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_052e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0533: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0928: Unknown result type (might be due to invalid IL or missing references)
			//IL_092d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0934: Unknown result type (might be due to invalid IL or missing references)
			//IL_096a: Unknown result type (might be due to invalid IL or missing references)
			//IL_096f: Unknown result type (might be due to invalid IL or missing references)
			//IL_056c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0571: Unknown result type (might be due to invalid IL or missing references)
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_068c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0691: Unknown result type (might be due to invalid IL or missing references)
			//IL_0696: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_055c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_0554: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a7c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a81: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0700: Unknown result type (might be due to invalid IL or missing references)
			//IL_0703: Unknown result type (might be due to invalid IL or missing references)
			//IL_0708: Unknown result type (might be due to invalid IL or missing references)
			//IL_070d: Unknown result type (might be due to invalid IL or missing references)
			//IL_070f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0711: Unknown result type (might be due to invalid IL or missing references)
			//IL_0716: Unknown result type (might be due to invalid IL or missing references)
			//IL_071b: Unknown result type (might be due to invalid IL or missing references)
			//IL_071e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0720: Unknown result type (might be due to invalid IL or missing references)
			//IL_0779: Unknown result type (might be due to invalid IL or missing references)
			//IL_0784: Unknown result type (might be due to invalid IL or missing references)
			//IL_0789: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_083e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0843: Unknown result type (might be due to invalid IL or missing references)
			//IL_084a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0850: Unknown result type (might be due to invalid IL or missing references)
			//IL_085c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0861: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_088a: Unknown result type (might be due to invalid IL or missing references)
			//IL_088f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0621: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			if (!initialized)
			{
				return;
			}
			if (!MothraFlightController.Alive(Flight.Owner) || Flight.State == FlightState.Dead)
			{
				Skill = MothraSkill.None;
				Flight.Order.Active = false;
				fx.StopAll();
				((Behaviour)this).enabled = false;
				return;
			}
			GameStateManager service = ServiceLocator.GetService<GameStateManager>();
			if (service == null || (int)service.GameState != 1)
			{
				return;
			}
			float fixedDeltaTime = Time.fixedDeltaTime;
			WindRemaining = Mathf.Max(0f, WindRemaining - fixedDeltaTime);
			DiveRemaining = Mathf.Max(0f, DiveRemaining - fixedDeltaTime);
			basicDelay = Mathf.Max(0f, basicDelay - fixedDeltaTime);
			MothraRoster.Refresh();
			if (Flight.State == FlightState.Placement || Flight.State == FlightState.Takeoff)
			{
				return;
			}
			bool flag = MothraReferences.Silenced(Flight.Owner);
			if (flag)
			{
				if (Skill == MothraSkill.Wind || Skill == MothraSkill.Basic)
				{
					Finish();
				}
				else if (Skill == MothraSkill.DiveAlign || Skill == MothraSkill.DiveStrike)
				{
					Recover();
				}
			}
			if (Skill == MothraSkill.None)
			{
				if (!Automatic || flag)
				{
					Flight.Order.Active = false;
					return;
				}
				if (!Enemy(Focus) || Time.time >= chooseAt)
				{
					chooseAt = Time.time + 0.25f;
					SelectPlan();
				}
				if (!Enemy(Focus))
				{
					Flight.Order.Active = false;
					return;
				}
				Defaults();
				PlanMovement();
				if (Skill == MothraSkill.None)
				{
					return;
				}
			}
			Age += fixedDeltaTime;
			Defaults();
			MothraFlightOrder order = Flight.Order;
			bool flag2 = Enemy(Locked);
			Vector3 val = (flag2 ? MothraFlightController.Position(Locked) : (Flight.Body.position + ((Component)this).transform.forward * 80f));
			Vector3 val2 = (order.Facing = Vector3.ProjectOnPlane(val - Flight.Body.position, Vector3.up));
			if (Skill == MothraSkill.Wind)
			{
				if (Time.time >= windScan)
				{
					windScan = Time.time + 0.7f;
					Unit selected;
					Vector3 direction = BestWindHeading(out selected);
					float num = WindScore(windAim);
					float num2 = WindScore(direction);
					if (((Vector3)(ref direction)).sqrMagnitude > 0.1f && (!flag2 || num < 0.1f || num2 > num + Mathf.Max(0.5f, num * 0.15f)))
					{
						windAim = direction;
						WindReaims++;
						if (Enemy(selected))
						{
							Locked = selected;
							SetFocus(selected);
						}
					}
				}
				if (Enemy(Locked))
				{
					Vector3 val3 = Vector3.ProjectOnPlane(MothraFlightController.Position(Locked) - Flight.Body.position, Vector3.up);
					if (((Vector3)(ref val3)).sqrMagnitude > 0.01f)
					{
						Vector3 normalized = ((Vector3)(ref val3)).normalized;
						if (Vector3.Angle(windAim, normalized) > 1f)
						{
							WindReaims++;
						}
						windAim = normalized;
					}
				}
				order.Facing = windAim;
				order.TurnSpeed = 35f;
				windForward = ((Component)this).transform.forward;
				order.Altitude = Mathf.Max(Flight.GroundHeight + 35.75f, Enemy(Locked) ? (MothraFlightController.Position(Locked).y - Flight.Settings.BodyCenter) : Flight.Body.position.y);
				order.AnimationRate = 1f;
				order.Pitch = -1.5f * MothraWindBeat.Sample(Age).Envelope;
				fx.Wind(on: true, Flight.Body.position + Vector3.up * Flight.Settings.BodyCenter, windForward, Age);
				tick += fixedDeltaTime;
				while (tick >= 0.19999f && castTicks < 125)
				{
					tick -= 0.2f;
					WindTick();
				}
				if (Age >= 24.999f)
				{
					Finish();
				}
				return;
			}
			if (Skill == MothraSkill.DiveAlign)
			{
				if (!flag2)
				{
					Recover();
					return;
				}
				float num3 = (order.Altitude = Mathf.Min(Flight.GroundHeight + Flight.Settings.MaximumAltitude, Mathf.Max(Flight.GroundHeight + 52.25f, val.y + 38.5f)));
				lastDiveVelocity = Flight.Body.velocity;
				float magnitude = ((Vector3)(ref val2)).magnitude;
				order.Velocity = ((magnitude < 41.25f) ? (-((Vector3)(ref val2)).normalized * 12f) : ((magnitude > 93.5f) ? HeadingVelocity(val2, 24f) : Vector3.zero));
				order.Pitch = DivePosePitch(8f * Mathf.SmoothStep(0f, 1f, Age / 2f));
				if (Age >= 2.4f && Mathf.Abs(Flight.Body.position.y - num3) < 12f && Vector3.Angle(((Component)this).transform.forward, val2) < 18f && magnitude < 300f)
				{
					Skill = MothraSkill.DiveStrike;
					Age = 0f;
					diveDirection = ((Component)this).transform.forward;
					previousHead = HeadPoint();
					noProgress = 0f;
				}
				else if (Age > 12f)
				{
					Recover();
				}
				return;
			}
			if (Skill == MothraSkill.DiveStrike)
			{
				if (!flag2 || struck.Contains(Locked))
				{
					Recover();
					return;
				}
				val = ContactPoint(Locked, HeadPoint());
				Rigidbody mainRig = Locked.data.mainRig;
				Vector3 val4 = (((Object)(object)mainRig != (Object)null) ? Vector3.ClampMagnitude(mainRig.velocity, 100f) : Vector3.zero);
				val += val4 * Mathf.Clamp(Vector3.Distance(HeadPoint(), val) / 180f, 0.05f, 0.3f);
				Vector3 val5 = val - HeadPoint();
				val2 = (order.Facing = Vector3.ProjectOnPlane(val5, Vector3.up));
				order.FloorMargin = 2.2f;
				order.Acceleration = 190f;
				order.ClimbSpeed = 110f;
				order.TurnSpeed = 120f;
				order.DirectVelocity = true;
				diveSpeed = Mathf.Min(120f, diveSpeed + 32f * fixedDeltaTime);
				order.Velocity = ((Vector3)(ref val5)).normalized * diveSpeed;
				order.Altitude = Mathf.Max(Flight.GroundHeight + order.FloorMargin, Flight.Body.position.y + val5.y);
				order.Pitch = DivePosePitch(Mathf.Clamp(Mathf.Atan2(0f - order.Velocity.y, Mathf.Max(1f, ((Vector3)(ref val2)).magnitude)) * 57.29578f + 6f * Mathf.InverseLerp(16f, 110f, diveSpeed), -15f, 50f));
				order.AnimationRate = 1f;
				lastDiveVelocity = Flight.Body.velocity;
				SweepDive(previousHead, HeadPoint());
				previousHead = HeadPoint();
				if (Skill != MothraSkill.DiveStrike)
				{
					return;
				}
				if (Age > 1f)
				{
					Vector3 velocity = Flight.Body.velocity;
					if (((Vector3)(ref velocity)).magnitude < 1f)
					{
						noProgress += fixedDeltaTime;
						goto IL_08ba;
					}
				}
				noProgress = 0f;
				goto IL_08ba;
			}
			if (Skill == MothraSkill.DiveRecover)
			{
				order.Altitude = Mathf.Max(recoveryAltitude, Flight.GroundHeight + Flight.Settings.MinimumAltitude + 10f);
				order.Acceleration = 85f;
				order.ClimbSpeed = 65f;
				order.Facing = diveDirection;
				order.Velocity = diveDirection * Mathf.Lerp(Mathf.Max(24f, diveSpeed * 0.55f), 18f, Mathf.Clamp01(Age / 3f));
				order.Pitch = DivePosePitch(-14f * (1f - Mathf.Clamp01(Age / 4f)) + 8f * Mathf.Sin(Mathf.Clamp01(Age / 0.45f) * (float)Math.PI));
				order.FloorMargin = 2.2f;
				if ((Age >= 4f && Flight.Body.position.y >= Flight.GroundHeight + Flight.Settings.MinimumAltitude + 8f) || Age >= 7f)
				{
					Finish();
				}
			}
			else
			{
				if (Skill != MothraSkill.Basic)
				{
					return;
				}
				if (!flag2)
				{
					Finish();
					return;
				}
				FollowContact(Locked);
				order.Pitch += 4f * Mathf.Sin(Mathf.Clamp01(Age / 2f) * (float)Math.PI);
				BasicContact();
				previousHead = HeadPoint();
				if (Age >= 2f)
				{
					Finish();
				}
			}
			return;
			IL_08ba:
			if (noProgress > 0.85f)
			{
				Recover();
			}
		}

		private void PlanMovement()
		{
			//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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_0038: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00e5: 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_0091: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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)
			MothraFlightOrder order = Flight.Order;
			Vector3 val = MothraFlightController.Position(Focus);
			Vector3 val2 = Vector3.ProjectOnPlane(val - Flight.Body.position, Vector3.up);
			float magnitude = ((Vector3)(ref val2)).magnitude;
			order.Facing = val2;
			if (planned == MothraSkill.Basic)
			{
				if (basicDelay > 0f)
				{
					Reposition(Focus);
					return;
				}
				FollowContact(Focus);
				if (Vector3.Angle(((Component)this).transform.forward, val2) < 35f && Contact(HeadPoint(), HeadPoint(), Focus, 4.7025f))
				{
					Begin(MothraSkill.Basic, Focus);
				}
				else
				{
					IsApproaching = true;
				}
			}
			else if (planned == MothraSkill.Wind)
			{
				Vector3 facing = plannedWindAim;
				if (((Vector3)(ref facing)).sqrMagnitude > 0.1f)
				{
					order.Facing = facing;
				}
				if (magnitude > 1850f)
				{
					Approach(Focus);
				}
				else if (Vector3.Angle(((Component)this).transform.forward, order.Facing) > 18f)
				{
					IsApproaching = true;
				}
				else if (Begin(MothraSkill.Wind, Focus))
				{
					windAim = ((Vector3)(ref order.Facing)).normalized;
				}
			}
			else if (planned == MothraSkill.DiveAlign)
			{
				if (magnitude > 230f)
				{
					Approach(Focus);
				}
				else
				{
					Begin(MothraSkill.DiveAlign, Focus);
				}
			}
			else
			{
				order.Active = false;
			}
		}

		private Vector3 HeadingVelocity(Vector3 toward, float speed)
		{
			//IL_0006: 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_002b: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Clamp01((Vector3.Dot(((Component)this).transform.forward, ((Vector3)(ref toward)).normalized) - 0.1f) / 0.9f);
			return ((Vector3)(ref toward)).normalized * speed * num;
		}

		private void Approach(Unit u)
		{
			//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)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0044: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			IsApproaching = true;
			MothraFlightOrder order = Flight.Order;
			Vector3 val = MothraFlightController.Position(u);
			order.Velocity = HeadingVelocity(order.Facing = Vector3.ProjectOnPlane(val - Flight.Body.position, Vector3.up), Flight.Settings.MaximumSpeed);
			order.Altitude = Mathf.Max(Flight.GroundHeight + Flight.Settings.MinimumAltitude, val.y - Flight.Settings.BodyCenter);
		}

		private void FollowContact(Unit u)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_001a: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_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_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_0057: 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_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_00d7: Unknown result type (might be due to invalid IL or missing references)
			MothraFlightOrder order = Flight.Order;
			Vector3 val = ContactPoint(u, HeadPoint());
			Vector3 toward = Vector3.ProjectOnPlane(val - HeadPoint(), Vector3.up);
			order.Facing = Vector3.ProjectOnPlane(MothraFlightController.Position(u) - Flight.Body.position, Vector3.up);
			order.FloorMargin = 2.2f;
			order.ClimbSpeed = 26f;
			order.Altitude = Mathf.Max(Flight.GroundHeight + order.FloorMargin, val.y - 5.5f);
			order.Velocity = HeadingVelocity(toward, Mathf.Min(24f, Mathf.Sqrt(28f * Mathf.Max(0f, ((Vector3)(ref toward)).magnitude - 2.2f))));
			order.Pitch = Mathf.Clamp(Mathf.Atan2(HeadPoint().y - val.y, Mathf.Max(6f, ((Vector3)(ref toward)).magnitude)) * 57.29578f * 0.4f, 0f, 18f);
		}

		private void Reposition(Unit target)
		{
			//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)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_00b3: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			IsRepositioning = true;
			MothraFlightOrder order = Flight.Order;
			Vector3 val = MothraFlightController.Position(target);
			Vector3 val2 = Vector3.ProjectOnPlane(val - Flight.Body.position, Vector3.up);
			float magnitude = ((Vector3)(ref val2)).magnitude;
			float num = 23.1f + Mathf.Min(15f, MothraRoster.Info(target).Radius);
			order.Facing = val2;
			order.Velocity = ((magnitude > num * 2f) ? HeadingVelocity(val2, 18f) : Vector3.ClampMagnitude(Vector3.Cross(Vector3.up, ((Vector3)(ref val2)).normalized) * 8f + ((Vector3)(ref val2)).normalized * Mathf.Clamp((magnitude - num) * 0.7f, -8f, 10f), 15f));
			order.Altitude = Mathf.Max(Flight.GroundHeight + 22f, val.y + 11f);
			order.FloorMargin = Flight.Settings.MinimumAltitude;
			order.Acceleration = 10f;
			order.ClimbSpeed = 16f;
		}

		private Vector3 PredictedContact(Unit u)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_002b: 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_0023: 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_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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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)
			Vector3 val = ContactPoint(u, HeadPoint());
			Rigidbody mainRig = u.data.mainRig;
			Vector3 val2 = (((Object)(object)mainRig != (Object)null) ? Vector3.ClampMagnitude(mainRig.velocity, 60f) : Vector3.zero);
			float num = Mathf.Clamp(Vector3.Distance(HeadPoint(), val) / 65f, 0.1f, 1.1f);
			return val + val2 * num;
		}

		private Vector3 ContactPoint(Unit u, Vector3 from)
		{
			//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_0070: 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_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_0046: 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_0048: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			Vector3 result = MothraFlightController.Position(u);
			float num = float.MaxValue;
			Collider[] shapes = MothraRoster.Info(u).Shapes;
			foreach (Collider val in shapes)
			{
				if ((Object)(object)val != (Object)null && val.enabled && !val.isTrigger)
				{
					Vector3 val2 = val.ClosestPoint(from);
					Vector3 val3 = val2 - from;
					float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						result = val2;
					}
				}
			}
			return result;
		}

		private bool Contact(Vector3 a, Vector3 b, Unit u, float radius)
		{
			//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_0014: 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_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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			MothraUnitInfo mothraUnitInfo = MothraRoster.Info(u);
			if (mothraUnitInfo.Shapes.Length == 0)
			{
				return SweepDistance(a, b, MothraFlightController.Position(u)) <= radius;
			}
			Collider[] shapes = mothraUnitInfo.Shapes;
			foreach (Collider val in shapes)
			{
				if ((Object)(object)val != (Object)null && val.enabled && !val.isTrigger)
				{
					Vector3 p = val.ClosestPoint((a + b) * 0.5f);
					if (SweepDistance(a, b, p) <= radius)
					{
						return true;
					}
				}
			}
			return false;
		}

		private float WindScore(Vector3 direction)
		{
			//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_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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_009d: 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)
			if (((Vector3)(ref direction)).sqrMagnitude < 0.1f)
			{
				return 0f;
			}
			float num = 0f;
			Vector3 val = Flight.Body.position + Vector3.up * Flight.Settings.BodyCenter;
			Unit[] units = MothraRoster.Units;
			foreach (Unit u in units)
			{
				if (Enemy(u))
				{
					MothraUnitInfo mothraUnitInfo = MothraRoster.Info(u);
					Vector3 val2 = MothraFlightController.Position(u);
					if (InWind(val, direction, val2, mothraUnitInfo.Radius))
					{
						num += (mothraUnitInfo.High ? 1.25f : 1f) * WindFalloff(Vector3.Dot(val2 - val, direction));
					}
				}
			}
			return num;
		}

		private Vector3 BestWindHeading(out Unit selected)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: 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_00bd: 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_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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: 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_01a7: 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)
			selected = (Enemy(Focus) ? Focus : null);
			Vector3 val = ((Component)this).transform.forward;
			float num = WindScore(val);
			if ((Object)(object)selected != (Object)null)
			{
				Vector3 val2 = Vector3.ProjectOnPlane(MothraFlightController.Position(selected) - Flight.Body.position, Vector3.up);
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				float num2 = WindScore(normalized);
				if (num2 > num)
				{
					val = normalized;
					num = num2;
				}
			}
			int num3 = Mathf.Max(1, MothraRoster.Units.Length / 12);
			int num4 = 0;
			for (int i = 0; i < MothraRoster.Units.Length; i += num3)
			{
				if (num4 >= 12)
				{
					break;
				}
				Unit val3 = MothraRoster.Units[i];
				if (Enemy(val3))
				{
					num4++;
					Vector3 val4 = Vector3.ProjectOnPlane(MothraFlightController.Position(val3) - Flight.Body.position, Vector3.up);
					Vector3 normalized2 = ((Vector3)(ref val4)).normalized;
					float num5 = WindScore(normalized2);
					if (num5 > num + 0.05f)
					{
						val = normalized2;
						num = num5;
						selected = val3;
					}
				}
			}
			if ((Object)(object)selected == (Object)null && num > 0f)
			{
				float num6 = float.MaxValue;
				Vector3 val5 = Flight.Body.position + Vector3.up * Flight.Settings.BodyCenter;
				Unit[] units = MothraRoster.Units;
				foreach (Unit val6 in units)
				{
					if (Enemy(val6) && InWind(val5, val, MothraFlightController.Position(val6), MothraRoster.Info(val6).Radius))
					{
						Vector3 val7 = MothraFlightController.Position(val6) - val5;
						float sqrMagnitude = ((Vector3)(ref val7)).sqrMagnitude;
						if (sqrMagnitude < num6)
						{
							num6 = sqrMagnitude;
							selected = val6;
						}
					}
				}
			}
			if (!(num > 0f))
			{
				return Vector3.zero;
			}
			return val;
		}

		public void WindTick()
		{
			//IL_0027: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			castTicks++;
			WindTicks++;
			Vector3 val = Flight.Body.position + Vector3.up * Flight.Settings.BodyCenter;
			windForward = ((Component)this).transform.forward;
			Unit[] units = MothraRoster.Units;
			foreach (Unit u in units)
			{
				if (Enemy(u))
				{
					MothraUnitInfo mothraUnitInfo = MothraRoster.Info(u);
					Vector3 val2 = MothraFlightController.Position(u);
					if (InWind(val, windForward, val2, mothraUnitInfo.Radius))
					{
						bool flag = mothraUnitInfo.Height >= MothraReferences.SamuraiHeight || mothraUnitInfo.Mass >= MothraReferences.MammothMass;
						float distance = Vector3.Dot(val2 - val, windForward);
						Deal(u, WindDamage(distance, flag), "Wind", val2, (mothraUnitInfo.Mass < MothraReferences.MammothMass && !flag) ? 3.2f : 0.35f);
					}
				}
			}
		}

		public void SweepDive(Vector3 a, Vector3 b)
		{
			//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_00af: 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_0117: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			if (Skill != MothraSkill.DiveStrike)
			{
				return;
			}
			diveUnits.Clear();
			int num = Physics.OverlapCapsuleNonAlloc(a, b, 3.3000002f, diveContacts, -1, (QueryTriggerInteraction)1);
			for (int i = 0; i < num; i++)
			{
				Collider val = diveContacts[i];
				if (!((Object)(object)val == (Object)null))
				{
					Unit componentInParent = ((Component)val).GetComponentInParent<Unit>();
					if (Enemy(componentInParent))
					{
						diveUnits.Add(componentInParent);
					}
				}
			}
			foreach (Unit diveUnit in diveUnits)
			{
				if ((Object)(object)diveUnit != (Object)(object)Locked && !struck.Contains(diveUnit) && !MothraRoster.Info(diveUnit).High)
				{
					DiveContact(diveUnit, ContactPoint(diveUnit, b));
				}
			}
			if (Enemy(Locked) && (diveUnits.Contains(Locked) || Contact(a, b, Locked, 3.3000002f)))
			{
				DiveContact(Locked, ContactPoint(Locked, b));
			}
		}

		public void DiveContact(Unit u, Vector3 point)
		{
			//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_00b7: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			if ((Skill == MothraSkill.DiveStrike || Skill == MothraSkill.DiveAlign) && Enemy(u) && !struck.Contains(u) && (!((Object)(object)u != (Object)(object)Locked) || !MothraRoster.Info(u).High))
			{
				struck.Add(u);
				bool flag = (Object)(object)u == (Object)(object)Locked;
				Vector3 velocity = Flight.Body.velocity;
				float speed = Mathf.Max(((Vector3)(ref velocity)).magnitude, ((Vector3)(ref lastDiveVelocity)).magnitude);
				if (flag)
				{
					Recover();
				}
				Deal(u, 3300f * (flag ? 13f : 5f), flag ? "DivePrimary" : "DiveCollateral", point, 0f);
				DiveHits++;
				if (flag)
				{
					diveFx.Impact(point, lastDiveVelocity, Flight.GroundHeight, speed);
				}
			}
		}

		private void BasicContact()
		{
			//IL_0046: 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_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)
			if (Age > 0.55f && Age < 1.6f && Enemy(Locked) && !struck.Contains(Locked) && Contact(previousHead, HeadPoint(), Locked, 4.9500003f))
			{
				struck.Add(Locked);
				Deal(Locked, 3300f * Random.Range(1.05f, 1.75f), "Basic", ContactPoint(Locked, HeadPoint()), 3f);
				BasicHits++;
			}
		}

		private void Deal(Unit u, float amount, string kind, Vector3 point, float kick)
		{
			//IL_006c: 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_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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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_0117: 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_0157: Unknown result type (might be due to invalid IL or missing references)
			if (!Enemy(u) || (Object)(object)u.data.healthHandler == (Object)null || MothraReferences.Silenced(Flight.Owner))
			{
				return;
			}
			Vector3 normalized;
			if (!(kind == "Wind"))
			{
				Vector3 val = Vector3.ProjectOnPlane(MothraFlightController.Position(u) - Flight.Body.position, Vector3.up);
				normalized = ((Vector3)(ref val)).normalized;
			}
			else
			{
				normalized = windForward;
			}
			Vector3 val2 = normalized;
			if (amount > 0f)
			{
				if (kind == "Wind")
				{
					MothraWindFeedback.Damage(u, amount, val2, Flight.Owner);
				}
				else
				{
					((Damagable)u.data.healthHandler).TakeDamage(amount, val2, Flight.Owner, (DamageType)2);
				}
			}
			switch (kind)
			{
			case "Wind":
				MothraRoster.PushWind(u, val2, MothraWindBeat.Sample(Age).DownPower);
				break;
			case "DivePrimary":
			case "DiveCollateral":
			{
				MothraDiveEffects mothraDiveEffects = diveFx;
				Vector3 direction = lastDiveVelocity;
				Vector3 velocity = Flight.Body.velocity;
				mothraDiveEffects.Push(u, direction, Mathf.Max(((Vector3)(ref velocity)).magnitude, ((Vector3)(ref lastDiveVelocity)).magnitude));
				break;
			}
			default:
				MothraRoster.Push(u, val2, kick, 35f);
				break;
			}
			if (kind == "Basic")
			{
				fx.Impact(point, (kind == "Basic") ? 12 : 36);
			}
			this.DamageApplied?.Invoke(u, amount, kind);
		}

		private void Pose()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: 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_00c1: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			if (Skill == MothraSkill.Basic)
			{
				float num = Mathf.Sin(Mathf.Clamp01((Age - 0.2f) / 1.5f) * (float)Math.PI);
				Transform val = Flight.Bone("Head");
				Quaternion localRotation = val.localRotation;
				val.localRotation = localRotation * Quaternion.Euler(6f * num, Mathf.Sin(Age * 5f) * 18f * num, -8f * num);
				if (HeadPoint().y < Flight.GroundHeight + 0.25f)
				{
					val.localRotation = localRotation;
				}
				BasicContact();
				previousHead = HeadPoint();
			}
			if (Skill == MothraSkill.DiveStrike)
			{
				SweepDive(previousHead, HeadPoint());
				previousHead = HeadPoint();
			}
			windMotion.Apply(Skill == MothraSkill.Wind, Age, Time.fixedDeltaTime);
			MothraDiveMotion mothraDiveMotion = diveMotion;
			MothraSkill skill = Skill;
			float age = Age;
			Vector3 velocity = Flight.Body.velocity;
			mothraDiveMotion.Apply(skill, age, ((Vector3)(ref velocity)).magnitude);
		}

		private void OnDisable()
		{
			if ((Object)(object)Flight != (Object)null)
			{
				Flight.Order.Active = false;
				Flight.Order.AfterPose = null;
			}
			if ((Object)(object)fx != (Object)null)
			{
				fx.StopAll();
			}
		}
	}
	public static class MothraDimensions
	{
		public const float Scale = 0.55f;

		public const float RestingHeight = 14.3f;

		public const float Wingspan = 128.54198f;

		public static readonly Vector3 MouthRest = new Vector3(0f, 10f, 20f);

		public static Vector3 Scaled(Vector3 value)
		{
			//IL_0000: 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)
			return value * 0.55f;
		}
	}
	public sealed class MothraDiveEffects : MonoBehaviour
	{
		private static readonly FieldInfo curveField = typeof(ScreenShake).GetField("dropOffCurve", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly List<MothraDiveEffects> all = new List<MothraDiveEffects>();

		private readonly Vector3[] vertices = (Vector3[])(object)new Vector3[130];

		private readonly Color[] colors = (Color[])(object)new Color[130];

		private Mesh mesh;

		private GameObject ring;

		private ParticleSystem dust;

		private float life = -1f;

		private Vector3 hit;

		private Vector3 forward;

		public int Bursts { get; private set; }

		public int ShakeCalls { get; private set; }

		public float LastKick { get; private set; }

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0027: 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_002f: Expected O, but got Unknown
			//IL_0034: Expected O, but got Unknown
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			//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_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: 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_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Expected O, but got Unknown
			//IL_0246: 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_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: 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)
			all.Add(this);
			ring = new GameObject("Mothra pooled dive air impact");
			MeshFilter obj = ring.AddComponent<MeshFilter>();
			Mesh val = new Mesh();
			Mesh sharedMesh = val;
			mesh = val;
			obj.sharedMesh = sharedMesh;
			mesh.MarkDynamic();
			MeshRenderer val2 = ring.AddComponent<MeshRenderer>();
			((Renderer)val2).sharedMaterial = MothraWindAssets.Haze;
			((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)val2).receiveShadows = false;
			Vector2[] array = (Vector2[])(object)new Vector2[130];
			int[] array2 = new int[384];
			for (int i = 0; i <= 64; i++)
			{
				for (int j = 0; j < 2; j++)
				{
					int num = i * 2 + j;
					ref Vector2 reference = ref array[num];
					reference = new Vector2((float)i / 64f, (j == 0) ? 0.3f : 0.7f);
					if (i < 64 && j == 0)
					{
						int num2 = i * 6;
						array2[num2] = num;
						array2[num2 + 1] = num + 2;
						array2[num2 + 2] = num + 1;
						array2[num2 + 3] = num + 1;
						array2[num2 + 4] = num + 2;
						array2[num2 + 5] = num + 3;
					}
				}
			}
			mesh.vertices = vertices;
			mesh.uv = array;
			mesh.colors = colors;
			mesh.triangles = array2;
			ring.SetActive(false);
			GameObject val3 = new GameObject("Mothra dive ground impact dust");
			val3.transform.SetParent(((Component)this).transform, false);
			dust = val3.AddComponent<ParticleSystem>();
			dust.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = dust.main;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).maxParticles = 64;
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.15f);
			EmissionModule emission = dust.emission;
			((EmissionModule)(ref emission)).enabled = false;
			ShapeModule shape = dust.shape;
			((ShapeModule)(ref shape)).enabled = false;
			ColorOverLifetimeModule colorOverLifetime = dust.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val4 = new Gradient();
			val4.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(Color.white, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(0.6f, 0.4f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val4);
			((Renderer)val3.GetComponent<ParticleSystemRenderer>()).sharedMaterial = MothraWindAssets.Dust;
			dust.Play();
		}

		public void Impact(Vector3 p, Vector3 heading, float ground, float speed)
		{
			//IL_000f: 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_0033: 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_0038: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Un