Decompiled source of Dagon v1.4.1

plugins/Dagon/Dagon.dll

Decompiled 8 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using EntityStates;
using GojoSatoruMod.Components;
using GojoSatoruMod.Content;
using GojoSatoruMod.Dagon.Components;
using GojoSatoruMod.Dagon.Content;
using GojoSatoruMod.Dagon.States;
using GojoSatoruMod.Dagon.Visuals;
using GojoSatoruMod.Guide;
using GojoSatoruMod.States;
using GojoSatoruMod.Visuals;
using KinematicCharacterController;
using On.RoR2;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RoR2;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Dagon")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.4.1.0")]
[assembly: AssemblyInformationalVersion("1.4.1+821034880680daa23233a71eadd31af6da27dc72")]
[assembly: AssemblyProduct("Dagon")]
[assembly: AssemblyTitle("Dagon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace GojoSatoruMod.Dagon
{
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency("dev.marmennz.satorugojo", "1.4.1")]
	[BepInPlugin("dev.marmennz.dagon", "Dagon", "1.4.1")]
	public sealed class DagonPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "dev.marmennz.dagon";

		public const string PluginVersion = "1.4.1";

		public const string PluginName = "Dagon";

		private void Awake()
		{
			if (JujutsuCoreContract.Accepts(1, "Dagon", "1.4.1", ((BaseUnityPlugin)this).Logger))
			{
				int num = JujutsuStartup.FailureMark();
				JujutsuStartup.UseHost((MonoBehaviour)(object)this);
				JujutsuAssetPaths.AddPlugin(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location));
				JujutsuStartup.Step("Dagon's text", (Action)DagonLanguage.Register);
				JujutsuStartup.Step("Dagon's assets", (Action)DagonAssets.Initialize);
				JujutsuStartup.Step("Dagon's buffs", (Action)DagonBuffs.Register);
				JujutsuStartup.Step("Dagon's sounds", (Func<IEnumerator>)DagonAssets.LoadSounds);
				JujutsuStartup.Step("Dagon's bubble", (Action)DagonBubble.Initialize);
				JujutsuStartup.Step("Dagon's bubble shell", (Action)DagonBubbleFx.Initialize);
				JujutsuStartup.Step("Dagon's Bathynomus", (Action)DagonBathynomusSync.Initialize);
				JujutsuStartup.Survivor("Dagon", (Action)DagonSurvivor.Initialize);
				JujutsuStartup.Loaded("Dagon", "1.4.1", num, ((BaseUnityPlugin)this).Logger);
			}
		}
	}
	internal static class GeneratedVersion
	{
		internal const string Value = "1.4.1";
	}
}
namespace GojoSatoruMod.Dagon.Visuals
{
	internal static class DagonBubbleFx
	{
		internal const float FormSeconds = 0.3f;

		internal const float ReleaseSeconds = 0.12f;

		private static readonly Color Tint = new Color(1f, 1f, 1f, 1f);

		private const int Sheet = 128;

		private const float Tiling = 2.5f;

		private static Texture2D texture;

		private static Texture2D ramp;

		private static Material material;

		private static bool materialResolved;

		private static bool hooked;

		private static Texture2D Texture
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)texture))
				{
					return texture = Build();
				}
				return texture;
			}
		}

		private static Texture2D Ramp
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)ramp))
				{
					return ramp = BuildRamp();
				}
				return ramp;
			}
		}

		internal static Material Material
		{
			get
			{
				//IL_003e: 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_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Expected O, but got Unknown
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				if (materialResolved)
				{
					return material;
				}
				materialResolved = true;
				Material brittleMaterial = CharacterModel.brittleMaterial;
				if (!Object.op_Implicit((Object)(object)brittleMaterial))
				{
					JujutsuLog log = Plugin.Log;
					if (log != null)
					{
						log.LogWarning((object)"bubble: material missing brittleOverlay=unloaded armour=ok visual=off", "C:\\Users\\user\\Documents\\risk of rain 2\\src\\Dagon\\Visuals\\DagonBubbleShell.cs");
					}
					return null;
				}
				material = new Material(brittleMaterial)
				{
					name = "matDagonBubble",
					hideFlags = (HideFlags)61
				};
				material.SetColor("_TintColor", Tint);
				material.SetTexture("_MainTex", (Texture)(object)Texture);
				material.SetTextureScale("_MainTex", Vector2.one * 2.5f);
				material.SetTexture("_RemapTex", (Texture)(object)Ramp);
				JujutsuLog log2 = Plugin.Log;
				if (log2 != null)
				{
					Shader shader = material.shader;
					string obj = ((shader != null) ? ((Object)shader).name : null);
					Texture2D obj2 = Texture;
					string arg = ((obj2 != null) ? ((Object)obj2).name : null);
					object arg2 = 2.5f;
					Texture2D obj3 = Ramp;
					log2.LogInfo((object)("bubble: material built shader=" + obj + " " + $"sheet={arg} tiling={arg2:0.0} ramp={((obj3 != null) ? ((Object)obj3).name : null)}"), "C:\\Users\\user\\Documents\\risk of rain 2\\src\\Dagon\\Visuals\\DagonBubbleShell.cs");
				}
				return material;
			}
		}

		internal static void Initialize()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if (!hooked)
			{
				hooked = true;
				CharacterBody.OnBuffFirstStackGained += new hook_OnBuffFirstStackGained(Wrap);
			}
		}

		private static void Wrap(orig_OnBuffFirstStackGained original, CharacterBody self, BuffDef buffDef)
		{
			original.Invoke(self, buffDef);
			if (!Object.op_Implicit((Object)(object)DagonBuffs.Bubble) || (Object)(object)buffDef != (Object)(object)DagonBuffs.Bubble || !Object.op_Implicit((Object)(object)self))
			{
				return;
			}
			try
			{
				DagonBubbleSkin.Cast(self);
			}
			catch (Exception arg)
			{
				JujutsuLog log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)$"bubble: draw failed body={((Object)self).name} armour=ok ex={arg}", "C:\\Users\\user\\Documents\\risk of rain 2\\src\\Dagon\\Visuals\\DagonBubbleShell.cs");
				}
			}
		}

		private static Texture2D Build()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false)
			{
				name = "texDagonBubble",
				wrapMode = (TextureWrapMode)0
			};
			Color32[] array = (Color32[])(object)new Color32[16384];
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num = (float)j / 128f;
					float num2 = (float)i / 128f;
					float num3 = 0.5f + 0.28f * Mathf.Sin((num * 3f + num2) * MathF.PI * 2f) * Mathf.Sin((num2 * 2f - num) * MathF.PI * 2f) + 0.22f * Mathf.Sin((num + num2 * 4f) * MathF.PI * 2f);
					num3 = Mathf.Clamp01(num3);
					byte b = (byte)((0.35f + 0.65f * num3) * 255f);
					array[i * 128 + j] = new Color32(b, b, b, b);
				}
			}
			val.SetPixels32(array);
			val.Apply();
			return val;
		}

		private static Texture2D BuildRamp()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(64, 1, (TextureFormat)4, false)
			{
				name = "rampDagonBubble",
				wrapMode = (TextureWrapMode)1
			};
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.05f, 0.28f, 0.3f, 0.4f);
			Color val3 = default(Color);
			((Color)(ref val3))..ctor(0.75f, 1f, 0.97f, 1f);
			for (int i = 0; i < 64; i++)
			{
				float num = (float)i / 63f;
				val.SetPixel(i, 0, Color.Lerp(val2, val3, num * num));
			}
			val.Apply();
			return val;
		}
	}
	internal sealed class DagonBubbleSkin : MonoBehaviour
	{
		private const float PatienceSeconds = 0.5f;

		private static readonly int ExternalAlpha = Shader.PropertyToID("_ExternalAlpha");

		private static readonly float[] ShellSpans = new float[2] { 1f, 0.9f };

		private static readonly float[] ShellAlphas = new float[2] { 0.2f, 0.13f };

		private static bool failureLogged;

		private static bool shellReported;

		private CharacterBody body;

		private TemporaryOverlayInstance overlay;

		private Transform shellRoot;

		private Material[] shellMaterials;

		private Color[] shellColours;

		private bool shellsTried;

		private float age;

		private float waited;

		private float alpha;

		private float releasing = -1f;

		internal static void Cast(CharacterBody wearer)
		{
			if (Object.op_Implicit((Object)(object)wearer) && !failureLogged)
			{
				DagonBubbleSkin dagonBubbleSkin = ((Component)wearer).GetComponent<DagonBubbleSkin>();
				if (!Object.op_Implicit((Object)(object)dagonBubbleSkin))
				{
					dagonBubbleSkin = ((Component)wearer).gameObject.AddComponent<DagonBubbleSkin>();
				}
				((Behaviour)dagonBubbleSkin).enabled = true;
				dagonBubbleSkin.Begin();
			}
		}

		private void Awake()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
		}

		private void Begin()
		{
			age = alpha * 0.3f;
			waited = 0f;
			releasing = -1f;
		}

		private void Update()
		{
			try
			{
				Draw();
			}
			catch (Exception arg)
			{
				failureLogged = true;
				JujutsuLog log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)$"bubble: drawing failed state=off armour=ok ex={arg}", "C:\\Users\\user\\Documents\\risk of rain 2\\src\\Dagon\\Visuals\\DagonBubbleShell.cs");
				}
				Sleep();
			}
		}

		private void Draw()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			bool flag = overlay != null;
			if (!flag && waited <= 0.5f)
			{
				flag = Attach();
				if (!flag)
				{
					waited += Time.deltaTime;
				}
			}
			if (!shellsTried)
			{
				BuildShells();
			}
			if (!flag && !Object.op_Implicit((Object)(object)shellRoot))
			{
				if (waited > 0.5f)
				{
					Sleep();
				}
				return;
			}
			if (Object.op_Implicit((Object)(object)shellRoot) && Object.op_Implicit((Object)(object)body))
			{
				shellRoot.position = body.corePosition;
				shellRoot.Rotate(0f, 14f * Time.deltaTime, 0f, (Space)0);
				shellRoot.localScale = Vector3.one * (1f + Mathf.Sin(Time.time * 2.4f) * 0.02f);
			}
			if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)DagonBuffs.Bubble) && body.HasBuff(DagonBuffs.Bubble))
			{
				releasing = -1f;
				age += Time.deltaTime;
				SetAlpha(JujutsuEase.OutCubic(Mathf.Clamp01(age / 0.3f)));
				return;
			}
			if (releasing < 0f)
			{
				releasing = 0f;
				Burst();
			}
			releasing += Time.deltaTime;
			float num = Mathf.Clamp01(releasing / 0.12f);
			SetAlpha(1f - JujutsuEase.InQuad(num));
			if (num >= 1f)
			{
				Sleep();
			}
		}

		private void Sleep()
		{
			Detach();
			DestroyShells();
			waited = 0f;
			releasing = -1f;
			age = 0f;
			alpha = 0f;
			((Behaviour)this).enabled = false;
		}

		private void BuildShells()
		{
			//IL_0036: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			shellsTried = true;
			if (!Object.op_Implicit((Object)(object)body))
			{
				return;
			}
			float num = Mathf.Max(1.15f, body.bestFitRadius * 0.72f);
			Transform transform = new GameObject("DagonBubbleSphere").transform;
			transform.position = body.corePosition;
			shellMaterials = (Material[])(object)new Material[ShellSpans.Length];
			shellColours = (Color[])(object)new Color[ShellSpans.Length];
			int num2 = 0;
			for (int i = 0; i < ShellSpans.Length; i++)
			{
				Color colour = DagonLanguage.Colour;
				colour.a = ShellAlphas[i];
				Skin val = GojoEffectVisual.BuildSkin("matDagonBubbleWall" + i, colour, (JujutsuFxLayer)((i == 0) ? 1 : 2), JujutsuFxTextures.Grain);
				if (val != null && Object.op_Implicit((Object)(object)val.Material))
				{
					GameObject obj = JujutsuPrimitives.Sphere("DagonBubbleWall_" + i, transform.position, false);
					obj.transform.SetParent(transform, false);
					obj.transform.localPosition = Vector3.zero;
					obj.transform.localScale = Vector3.one * (num * 2f * ShellSpans[i]);
					Renderer component = obj.GetComponent<Renderer>();
					JujutsuFxMaterials.PrepareRenderer(component);
					component.sharedMaterial = val.Material;
					JujutsuFxMaterials.Claim(obj, val.Material);
					shellMaterials[i] = val.Material;
					shellColours[i] = colour;
					num2++;
				}
			}
			if (num2 == 0)
			{
				Object.Destroy((Object)(object)((Component)transform).gameObject);
				shellMaterials = null;
				shellColours = null;
				return;
			}
			shellRoot = transform;
			SetAlpha(alpha);
			if (!shellReported)
			{
				shellReported = true;
				JujutsuLog log = Plugin.Log;
				if (log != null)
				{
					log.LogInfo((object)$"bubble: sphere built walls={num2} radius={num:0.00} body={((Object)body).name}", "C:\\Users\\user\\Documents\\risk of rain 2\\src\\Dagon\\Visuals\\DagonBubbleShell.cs");
				}
			}
		}

		private void DestroyShells()
		{
			if (Object.op_Implicit((Object)(object)shellRoot))
			{
				Object.Destroy((Object)(object)((Component)shellRoot).gameObject);
			}
			shellRoot = null;
			shellMaterials = null;
			shellColours = null;
			shellsTried = false;
		}

		private bool Attach()
		{
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.modelLocator))
			{
				return false;
			}
			Transform modelTransform = body.modelLocator.modelTransform;
			if (!Object.op_Implicit((Object)(object)modelTransform))
			{
				return false;
			}
			CharacterModel component = ((Component)modelTransform).GetComponent<CharacterModel>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return false;
			}
			Material material = DagonBubbleFx.Material;
			if (!Object.op_Implicit((Object)(object)material))
			{
				return false;
			}
			overlay = TemporaryOverlayManager.AddOverlay(((Component)modelTransform).gameObject);
			overlay.originalMaterial = material;
			overlay.animateShaderAlpha = false;
			overlay.duration = 0f;
			overlay.destroyComponentOnEnd = true;
			overlay.destroyObjectOnEnd = false;
			overlay.AddToCharacterModel(component);
			NoItemDisplaysController.Keep(overlay.materialInstance);
			SetAlpha(0f);
			return true;
		}

		private void Burst()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//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)
			if (Object.op_Implicit((Object)(object)body))
			{
				float num = Mathf.Max(0.6f, body.radius);
				JujutsuMotes.Burst(body.corePosition, Vector3.up, DagonLanguage.Colour, num, (JujutsuMoteKind)1, 10);
				JujutsuImpact.Strike(body.corePosition, Vector3.up, DagonLanguage.Colour, num + 0.6f, 0.3f, false, true);
			}
		}

		private void SetAlpha(float value)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			alpha = Mathf.Clamp01(value);
			Material val = overlay?.materialInstance;
			if (Object.op_Implicit((Object)(object)val))
			{
				val.SetFloat(ExternalAlpha, alpha);
			}
			if (shellMaterials == null)
			{
				return;
			}
			for (int i = 0; i < shellMaterials.Length; i++)
			{
				if (Object.op_Implicit((Object)(object)shellMaterials[i]))
				{
					Color val2 = shellColours[i];
					val2.a *= alpha;
					JujutsuFxMaterials.SetTint(shellMaterials[i], val2, 1f);
				}
			}
		}

		private void OnDestroy()
		{
			Detach();
			DestroyShells();
		}

		private void Detach()
		{
			if (overlay != null)
			{
				NoItemDisplaysController.Forget(overlay.materialInstance);
				overlay.Destroy();
				overlay = null;
			}
		}
	}
	internal static class DagonClipWork
	{
		internal const string SendR = "SendR";

		internal const string SendL = "SendL";

		internal const string SendBig = "SendBig";

		internal const string Thrust = "Thrust";

		internal const string Bubble = "Bubble";

		internal const string Tide = "Tide";

		internal const string Heave = "Heave";

		internal const float SendPoint = 0.1f;

		internal const float SendFrom = 0.02f;

		internal const float SendBigPalms = 0.12f;

		internal const float SendBigFrom = 0.03f;

		internal const float ThrustOut = 0.2f;

		internal const float BubbleWide = 0.2f;

		internal const float TidePlant = 0.22f;

		internal const float HeaveTop = 0.25f;

		internal const float SeamFloor = 0.035f;

		internal const float SeamCeiling = 0.12f;

		private static readonly HashSet<string> reported = new HashSet<string>();

		internal static float SpeedFor(float anchor, float from, float fireSeconds)
		{
			return Mathf.Max(0.05f, (anchor - from) / Mathf.Max(0.01f, fireSeconds));
		}

		internal static bool Loop(CharacterBody body, string clip, float fromSeconds, float speed, float upperBlendSeconds)
		{
			SukunaMixamoAnimationDriver val = Driver(body);
			bool flag = Object.op_Implicit((Object)(object)val) && val.LoopClip(clip, fromSeconds, speed, upperBlendSeconds);
			Report(val, clip, flag);
			return flag;
		}

		internal static void Release(CharacterBody body)
		{
			SukunaMixamoAnimationDriver val = Driver(body);
			if (Object.op_Implicit((Object)(object)val))
			{
				val.ReleaseClip();
			}
		}

		private static SukunaMixamoAnimationDriver Driver(CharacterBody body)
		{
			Transform val = ((Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.modelLocator)) ? body.modelLocator.modelTransform : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			return ((Component)val).GetComponentInChildren<SukunaMixamoAnimationDriver>(true);
		}

		private static void Report(SukunaMixamoAnimationDriver driver, string clip, bool taken)
		{
			if (!taken && reported.Add(clip ?? string.Empty))
			{
				Plugin.Log.LogInfo((object)("[DagonClipWork] clip '" + clip + "' not held " + (Object.op_Implicit((Object)(object)driver) ? "(not in his library)" : "(no animation driver on the model)") + ": he casts from his locomotion pose."), "C:\\Users\\user\\Documents\\risk of rain 2\\src\\Dagon\\Visuals\\DagonClipWork.cs");
			}
		}
	}
	internal sealed class DagonFishBody
	{
		internal enum Kind
		{
			Piranha,
			Serpent,
			Isopod,
			Hunter,
			Shark
		}

		private sealed class Form
		{
			internal readonly List<float> S = new List<float>(384);

			internal readonly List<float> Along = new List<float>(384);

			internal readonly List<float> Right = new List<float>(384);

			internal readonly List<float> Up = new List<float>(384);

			internal readonly List<byte> Group = new List<byte>(384);

			internal readonly List<Vector2> Uv = new List<Vector2>(384);

			internal readonly List<int> Tris = new List<int>(2048);

			internal float[] Stations;

			internal int[] StationOf;

			internal int[] TriArray;

			internal Vector3? LureBulb;

			internal int Push(float s, float along, float right, float up, Vector2 uv, byte group = 0)
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				S.Add(s);
				Along.Add(along);
				Right.Add(right);
				Up.Add(up);
				Uv.Add(uv);
				Group.Add(group);
				return S.Count - 1;
			}

			internal void Tri(int a, int b, int c)
			{
				Tris.Add(a);
				Tris.Add(b);
				Tris.Add(c);
				Tris.Add(c);
				Tris.Add(b);
				Tris.Add(a);
			}

			internal void Quad(int a, int b, int c, int d)
			{
				Tri(a, b, c);
				Tri(a, c, d);
			}

			internal void Seal()
			{
				Dictionary<int, int> dictionary = new Dictionary<int, int>();
				List<float> list = new List<float>();
				StationOf = new int[S.Count];
				for (int i = 0; i < S.Count; i++)
				{
					int key = Mathf.RoundToInt(S[i] * 10000f);
					if (!dictionary.TryGetValue(key, out var value))
					{
						value = list.Count;
						list.Add(S[i]);
						dictionary.Add(key, value);
					}
					StationOf[i] = value;
				}
				Stations = list.ToArray();
				TriArray = Tris.ToArray();
			}
		}

		private const float LureFlare = 0.22f;

		private const byte GroupBody = 0;

		private const byte GroupUpperJaw = 1;

		private const byte GroupLowerJaw = 2;

		private static Form piranhaForm;

		private static Form serpentForm;

		private static Form isopodForm;

		private static Form sharkForm;

		private readonly Form form;

		private readonly float scale;

		private GameObject host;

		private Mesh mesh;

		private Transform lure;

		private readonly List<Vector3> scratch;

		private readonly Vector3[] framePos;

		private readonly Vector3[] frameFwd;

		private readonly Vector3[] frameSide;

		private readonly Vector3[] frameLift;

		private readonly float[] sortKeys;

		private readonly int[] sortOrder;

		private readonly int[] sortedTris;

		private const float SharkWidthRatio = 0.8f;

		private const float SharkSnoutLength = 0.17f;

		private const float SharkJawLength = 0.105f;

		private const float IsopodHeadEnd = 0.185f;

		private const float IsopodPereonEnd = 0.7f;

		private const float IsopodPleonEnd = 0.8f;

		private const int IsopodPlates = 7;

		private const int IsopodPleonPlates = 4;

		private const float IsopodTrailWidth = 1.075f;

		private const float IsopodTrailHeight = 1.04f;

		private const float IsopodLeadWidth = 0.955f;

		private const float IsopodLeadHeight = 0.97f;

		private const float IsopodTrailAlong = -0.01f;

		private const float IsopodTrailSweep = 0.038f;

		private const float IsopodHeadSweep = 0.05f;

		private const float IsopodBelly = 0.35f;

		private const float IsopodFlatten = 0.75f;

		internal GameObject Host => host;

		internal float Swell { get; set; } = 1f;

		internal float Grow { get; set; } = 1f;

		private DagonFishBody(Form form, float scale, GameObject host, Mesh mesh, Transform lure)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			this.form = form;
			this.scale = scale;
			this.host = host;
			this.mesh = mesh;
			this.lure = lure;
			scratch = new List<Vector3>(form.S.Count);
			for (int i = 0; i < form.S.Count; i++)
			{
				scratch.Add(Vector3.zero);
			}
			framePos = (Vector3[])(object)new Vector3[form.Stations.Length];
			frameFwd = (Vector3[])(object)new Vector3[form.Stations.Length];
			frameSide = (Vector3[])(object)new Vector3[form.Stations.Length];
			frameLift = (Vector3[])(object)new Vector3[form.Stations.Length];
			int num = form.TriArray.Length / 6;
			sortKeys = new float[num];
			sortOrder = new int[num];
			sortedTris = new int[form.TriArray.Length];
		}

		internal static DagonFishBody Create(Kind kind, string name, float bodyLength)
		{
			//IL_00b4: 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_00d1: Expected O, but got Unknown
			//IL_015e: 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_0189: Unknown result type (might be due to invalid IL or missing references)
			Form form;
			Texture2D val;
			switch (kind)
			{
			case Kind.Serpent:
				form = serpentForm ?? (serpentForm = BuildSerpent());
				val = DagonFishSkin.Serpent;
				break;
			case Kind.Isopod:
				form = isopodForm ?? (isopodForm = BuildIsopod());
				val = DagonFishSkin.Isopod;
				break;
			case Kind.Hunter:
				form = piranhaForm ?? (piranhaForm = BuildPiranha());
				val = DagonFishSkin.Hunter;
				break;
			case Kind.Shark:
				form = sharkForm ?? (sharkForm = BuildShark());
				val = DagonFishSkin.Shark;
				break;
			default:
				form = piranhaForm ?? (piranhaForm = BuildPiranha());
				val = DagonFishSkin.Piranha;
				break;
			}
			Material val2 = JujutsuFxMaterials.CreateBlendedMaterial("mat" + name, DagonFishSkin.PaperTint, val);
			if (!Object.op_Implicit((Object)(object)val2))
			{
				return null;
			}
			GameObject val3 = new GameObject(name);
			MeshFilter obj = val3.AddComponent<MeshFilter>();
			MeshRenderer val4 = val3.AddComponent<MeshRenderer>();
			Mesh val5 = JujutsuFxMesh.Create(name);
			val5.SetVertices(BindPose(form));
			val5.SetUVs(0, form.Uv);
			val5.SetTriangles(form.Tris, 0, true);
			obj.sharedMesh = val5;
			JujutsuFxMaterials.PrepareRenderer((Renderer)(object)val4);
			((Renderer)val4).sharedMaterial = val2;
			JujutsuFxMaterials.Claim(val3, val2);
			Transform val6 = null;
			if (form.LureBulb.HasValue)
			{
				Skin val7 = default(Skin);
				val6 = GojoEffectVisual.BuildFlare(val3.transform, name + "Lure", new Color(1f, 0.82f, 0.35f), (JujutsuFxLayer)1, 0f, ref val7);
				if (Object.op_Implicit((Object)(object)val6))
				{
					val6.localScale = Vector3.one * (0.22f * bodyLength);
					JujutsuFxMaterials.Claim(val3, val7.Material);
				}
			}
			return new DagonFishBody(form, bodyLength, val3, val5, val6);
		}

		private static List<Vector3> BindPose(Form form)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>(form.S.Count);
			for (int i = 0; i < form.S.Count; i++)
			{
				list.Add(new Vector3(form.Right[i], form.Up[i], form.Along[i] - form.S[i]));
			}
			return list;
		}

		internal void Redraw(Func<float, Vector3> spine, Vector3 fallbackForward, float gapeUpperDegrees, float gapeLowerDegrees, Vector3? upHint = null)
		{
			//IL_0032: 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_0037: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: 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_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: 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_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: 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_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: 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_0386: 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)
			if (!Object.op_Implicit((Object)(object)host) || (Object)(object)mesh == (Object)null)
			{
				return;
			}
			Vector3 val = (Vector3)(((??)upHint) ?? Vector3.up);
			if (((Vector3)(ref val)).sqrMagnitude < 1E-06f)
			{
				val = Vector3.up;
			}
			((Vector3)(ref val)).Normalize();
			for (int i = 0; i < form.Stations.Length; i++)
			{
				float num = form.Stations[i];
				framePos[i] = spine(num);
				Vector3 val2 = spine(Mathf.Max(num - 0.01f, 0f)) - spine(Mathf.Min(num + 0.01f, 1f));
				if (((Vector3)(ref val2)).sqrMagnitude < 1E-08f)
				{
					val2 = fallbackForward;
				}
				((Vector3)(ref val2)).Normalize();
				Vector3 val3 = Vector3.Cross(val2, val);
				if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f)
				{
					val3 = Vector3.Cross(val2, Vector3.right);
				}
				((Vector3)(ref val3)).Normalize();
				frameFwd[i] = val2;
				frameSide[i] = val3;
				frameLift[i] = Vector3.Cross(val3, val2);
			}
			float num2 = gapeUpperDegrees * (MathF.PI / 180f);
			float num3 = gapeLowerDegrees * (MathF.PI / 180f);
			float num4 = Mathf.Cos(num2);
			float num5 = Mathf.Sin(num2);
			float num6 = Mathf.Cos(num3);
			float num7 = Mathf.Sin(num3);
			float num8 = scale * Grow;
			for (int j = 0; j < form.S.Count; j++)
			{
				float num9 = form.Along[j] * num8;
				float num10 = form.Up[j] * num8;
				switch (form.Group[j])
				{
				case 1:
				{
					float num12 = num9;
					num9 = num12 * num4 - num10 * num5;
					num10 = num12 * num5 + num10 * num4;
					break;
				}
				case 2:
				{
					float num11 = num9;
					num9 = num11 * num6 + num10 * num7;
					num10 = (0f - num11) * num7 + num10 * num6;
					break;
				}
				}
				int num13 = form.StationOf[j];
				scratch[j] = framePos[num13] + frameFwd[num13] * num9 + frameSide[num13] * (form.Right[j] * num8 * Swell) + frameLift[num13] * (num10 * Swell);
			}
			mesh.SetVertices(scratch);
			mesh.RecalculateBounds();
			SortForCamera();
			if (Object.op_Implicit((Object)(object)lure) && form.LureBulb.HasValue)
			{
				Vector3 value = form.LureBulb.Value;
				int num14 = NearestStation(value.x);
				lure.position = framePos[num14] + frameFwd[num14] * (value.y * num8) + frameLift[num14] * (value.z * num8);
				lure.localScale = Vector3.one * (0.22f * num8);
			}
		}

		private void SortForCamera()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetCamera(out var eye))
			{
				Vector3 val = eye * 3f;
				int[] triArray = form.TriArray;
				int num = sortKeys.Length;
				for (int i = 0; i < num; i++)
				{
					int num2 = i * 6;
					Vector3 val2 = scratch[triArray[num2]] + scratch[triArray[num2 + 1]] + scratch[triArray[num2 + 2]];
					float[] array = sortKeys;
					int num3 = i;
					Vector3 val3 = val2 - val;
					array[num3] = 0f - ((Vector3)(ref val3)).sqrMagnitude;
					sortOrder[i] = i;
				}
				Array.Sort(sortKeys, sortOrder);
				for (int j = 0; j < num; j++)
				{
					Array.Copy(triArray, sortOrder[j] * 6, sortedTris, j * 6, 6);
				}
				mesh.SetTriangles(sortedTris, 0, false);
			}
		}

		private static bool TryGetCamera(out Vector3 eye)
		{
			//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_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)
			ReadOnlyCollection<CameraRigController> readOnlyInstancesList = CameraRigController.readOnlyInstancesList;
			for (int i = 0; i < readOnlyInstancesList.Count; i++)
			{
				CameraRigController val = readOnlyInstancesList[i];
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.sceneCam))
				{
					eye = ((Component)val.sceneCam).transform.position;
					return true;
				}
			}
			eye = Vector3.zero;
			return false;
		}

		private int NearestStation(float s)
		{
			int result = 0;
			float num = float.MaxValue;
			for (int i = 0; i < form.Stations.Length; i++)
			{
				float num2 = Mathf.Abs(form.Stations[i] - s);
				if (num2 < num)
				{
					num = num2;
					result = i;
				}
			}
			return result;
		}

		internal void Destroy()
		{
			if (Object.op_Implicit((Object)(object)mesh))
			{
				Object.Destroy((Object)(object)mesh);
			}
			if (Object.op_Implicit((Object)(object)host))
			{
				Object.Destroy((Object)(object)host);
			}
			host = null;
			mesh = null;
			lure = null;
		}

		private static float Interp(float s, float[] xs, float[] ys)
		{
			if (s <= xs[0])
			{
				return ys[0];
			}
			for (int i = 1; i < xs.Length; i++)
			{
				if (s <= xs[i])
				{
					float num = (s - xs[i - 1]) / (xs[i] - xs[i - 1]);
					return Mathf.Lerp(ys[i - 1], ys[i], num);
				}
			}
			return ys[^1];
		}

		private static int[] EllipseRing(Form form, float s, float along, float halfWidth, float halfHeight, float u, int segments, float vLo = 0.004f, float vHi = 0.436f)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			int[] array = new int[segments + 1];
			for (int i = 0; i <= segments; i++)
			{
				float num = (float)i / (float)segments;
				float num2 = num * MathF.PI * 2f;
				array[i] = form.Push(s, along, (0f - Mathf.Sin(num2)) * halfWidth, (0f - Mathf.Cos(num2)) * halfHeight, new Vector2(u, vLo + (vHi - vLo) * num), 0);
			}
			return array;
		}

		private static int[] ShellRing(Form form, float s, float along, float halfWidth, float halfHeight, float belly, float sweep, float u, int segments, float vLo = 0.004f, float vHi = 0.436f)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			int[] array = new int[segments + 1];
			for (int i = 0; i <= segments; i++)
			{
				float num = (float)i / (float)segments;
				float num2 = num * MathF.PI * 2f;
				float num3 = 0f - Mathf.Sin(num2);
				float num4 = 0f - Mathf.Cos(num2);
				float num5 = Mathf.Abs(num3);
				array[i] = form.Push(s, along - sweep * Mathf.Pow(num5, 1.5f), Mathf.Sign(num3) * Mathf.Pow(num5, 0.75f) * halfWidth, (num4 >= 0f) ? (num4 * halfHeight) : (num4 * belly), new Vector2(u, vLo + (vHi - vLo) * num), 0);
			}
			return array;
		}

		private static void Stitch(Form form, int[] a, int[] b)
		{
			for (int i = 0; i < a.Length - 1; i++)
			{
				form.Quad(a[i], a[i + 1], b[i + 1], b[i]);
			}
		}

		private static void BuildJaw(Form form, byte group, float sign, float halfWidth, float halfHeight, float length, int rings)
		{
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			float num = ((sign > 0f) ? 0.624f : 0.714f);
			float num2 = ((sign > 0f) ? 0.706f : 0.796f);
			int[] array = null;
			for (int i = 0; i <= rings; i++)
			{
				float num3 = (float)i / (float)rings;
				float along = num3 * length;
				float num4 = 1f - 0.55f * Mathf.Pow(num3, 1.6f);
				float num5 = halfWidth * num4;
				float num6 = halfHeight * num4 * (1f - 0.3f * num3);
				int[] array2 = new int[7];
				for (int j = 0; j <= 6; j++)
				{
					float num7 = (float)j / 6f;
					float num8 = (num7 - 0.5f) * MathF.PI;
					array2[j] = form.Push(0f, along, Mathf.Sin(num8) * num5, sign * Mathf.Cos(num8) * num6, new Vector2(num3, num + (num2 - num) * num7), group);
				}
				if (array != null)
				{
					Stitch(form, array, array2);
				}
				array = array2;
			}
			int c = form.Push(0f, length * 1.05f, 0f, sign * halfHeight * 0.1f, new Vector2(0.995f, (num + num2) * 0.5f), group);
			for (int k = 0; k < array.Length - 1; k++)
			{
				form.Tri(array[k], array[k + 1], c);
			}
		}

		private static void BuildTeeth(Form form, byte group, float sign, float halfWidth, float halfHeight, float length, int count, float tooth)
		{
			//IL_00c9: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: 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_01cf: Unknown result type (might be due to invalid IL or missing references)
			Vector2 uv = default(Vector2);
			((Vector2)(ref uv))..ctor(0.955f, 0.94f);
			Vector2 uv2 = default(Vector2);
			((Vector2)(ref uv2))..ctor(0.995f, 0.94f);
			Vector2 uv3 = default(Vector2);
			((Vector2)(ref uv3))..ctor(0.975f, 0.995f);
			for (int i = 0; i < count; i++)
			{
				float num = ((float)i + 0.7f) / ((float)count + 0.7f);
				float num2 = num * length * 0.96f;
				float num3 = 1f - 0.55f * Mathf.Pow(num, 1.6f);
				float num4 = halfWidth * num3 * 0.88f;
				for (int j = -1; j <= 1; j += 2)
				{
					float num5 = (float)j * num4 * Mathf.Cos(num * 0.9f);
					float num6 = sign * halfHeight * 0.06f * (1f - num);
					int a = form.Push(0f, num2 - tooth * 0.55f, num5, num6, uv, group);
					int b = form.Push(0f, num2 + tooth * 0.55f, num5, num6, uv2, group);
					int c = form.Push(0f, num2 + tooth * 0.1f, num5 * 0.9f, num6 - sign * tooth * 1.6f, uv3, group);
					form.Tri(a, b, c);
				}
			}
			for (int k = -1; k <= 1; k += 2)
			{
				float num7 = length * 1.04f;
				float num8 = (float)k * 0.5f * halfWidth * 0.35f;
				float num9 = sign * halfHeight * 0.05f;
				int a2 = form.Push(0f, num7 - tooth * 0.6f, num8, num9, uv, group);
				int b2 = form.Push(0f, num7 + tooth * 0.4f, num8, num9, uv2, group);
				int c2 = form.Push(0f, num7, num8 * 0.9f, num9 - sign * tooth * 1.7f, uv3, group);
				form.Tri(a2, b2, c2);
			}
		}

		private static void FinFan(Form form, float s, float along0, float baseLow, float baseHigh, float[] angles, float[] radii, float u0, float u1)
		{
			//IL_004f: 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)
			int num = angles.Length;
			int[] array = new int[num];
			int[] array2 = new int[num];
			for (int i = 0; i < num; i++)
			{
				float num2 = (float)i / (float)(num - 1);
				float num3 = Mathf.Lerp(baseLow, baseHigh, num2);
				float num4 = Mathf.Lerp(u0, u1, num2);
				array[i] = form.Push(s, along0, 0f, num3, new Vector2(num4, 0.445f), 0);
				array2[i] = form.Push(s, along0 - Mathf.Cos(angles[i]) * radii[i], 0f, num3 + Mathf.Sin(angles[i]) * radii[i], new Vector2(num4, 0.615f), 0);
			}
			for (int j = 0; j < num - 1; j++)
			{
				form.Quad(array[j], array2[j], array2[j + 1], array[j + 1]);
			}
		}

		private static void FinFanFlat(Form form, float s, float along0, float rightInner, float rightOuter, float up0, float[] angles, float[] radii, float mirror, float u0, float u1)
		{
			//IL_004f: 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)
			int num = angles.Length;
			int[] array = new int[num];
			int[] array2 = new int[num];
			for (int i = 0; i < num; i++)
			{
				float num2 = (float)i / (float)(num - 1);
				float num3 = Mathf.Lerp(rightInner, rightOuter, num2) * mirror;
				float num4 = Mathf.Lerp(u0, u1, num2);
				array[i] = form.Push(s, along0, num3, up0, new Vector2(num4, 0.46f), 0);
				array2[i] = form.Push(s, along0 - Mathf.Cos(angles[i]) * radii[i], num3 + Mathf.Sin(angles[i]) * radii[i] * mirror, up0, new Vector2(num4, 0.57f), 0);
			}
			for (int j = 0; j < num - 1; j++)
			{
				form.Quad(array[j], array2[j], array2[j + 1], array[j + 1]);
			}
		}

		private static void Limb(Form form, float s, float mirror, Vector3 hip, Vector3 knee, Vector3 claw, float width, float u0, float u1)
		{
			//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_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_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_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_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_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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = hip + knee;
			Vector3[] array = (Vector3[])(object)new Vector3[3]
			{
				hip,
				val,
				val + claw
			};
			float[] array2 = new float[3]
			{
				width,
				width * 0.55f,
				0f
			};
			int num = -1;
			int b = -1;
			Vector2 uv = default(Vector2);
			for (int i = 0; i < array.Length; i++)
			{
				float num2 = (float)i / (float)(array.Length - 1);
				float num3 = array2[i] * 0.5f;
				((Vector2)(ref uv))..ctor(Mathf.Lerp(u0, u1, num2), Mathf.Lerp(0.47f, 0.555f, num2));
				int num4 = form.Push(s, array[i].z + num3, array[i].x * mirror, array[i].y, uv, 0);
				int num5 = form.Push(s, array[i].z - num3, array[i].x * mirror, array[i].y, uv, 0);
				if (num >= 0)
				{
					form.Quad(num, b, num5, num4);
				}
				num = num4;
				b = num5;
			}
		}

		private static void SideFin(Form form, float s, float right0, float up0, float sweep, float length, float drop, float u0, float u1, float mirror)
		{
			//IL_0013: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			int a = form.Push(s, 0f, right0 * mirror, up0, new Vector2(u0, 0.445f), 0);
			int b = form.Push(s + 0.001f, (0f - length) * 0.55f, right0 * mirror, up0 + 0.004f, new Vector2(u1, 0.445f), 0);
			int c = form.Push(s, 0f - length, (right0 + sweep) * mirror, up0 - drop, new Vector2((u0 + u1) * 0.5f, 0.615f), 0);
			form.Tri(a, b, c);
		}

		private static void Crest(Form form, float s0, float s1, int spikes, float height, Func<float, float> halfHeightAt, float sign = 1f)
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Max(6, spikes * 4);
			int[] array = new int[num + 1];
			int[] array2 = new int[num + 1];
			for (int i = 0; i <= num; i++)
			{
				float num2 = (float)i / (float)num;
				float num3 = Mathf.Lerp(s0, s1, num2);
				float num4 = 0.2f + num2 * 0.6f;
				float num5 = Mathf.Pow(Mathf.Abs(Mathf.Sin(num2 * MathF.PI * (float)spikes)), 0.6f);
				float num6 = Mathf.Pow(Mathf.Min(1f, Mathf.Min(num2, 1f - num2) * 3.5f), 0.7f);
				float num7 = height * (0.35f + 0.65f * num5) * num6;
				float num8 = sign * halfHeightAt(num3) * 0.92f;
				array[i] = form.Push(num3, 0f, 0f, num8, new Vector2(num4, 0.445f), 0);
				array2[i] = form.Push(num3, (0f - num7) * 0.35f, 0f, num8 + sign * num7, new Vector2(num4, 0.615f), 0);
			}
			for (int j = 0; j < num; j++)
			{
				form.Quad(array[j], array2[j], array2[j + 1], array[j + 1]);
			}
		}

		private static void RibbonFin(Form form, float s0, float s1, int points, Func<float, float> heightAt, Func<float, float> halfHeightAt, float sign)
		{
			//IL_006e: 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)
			int[] array = new int[points + 1];
			int[] array2 = new int[points + 1];
			for (int i = 0; i <= points; i++)
			{
				float num = (float)i / (float)points;
				float num2 = Mathf.Lerp(s0, s1, num);
				float num3 = 0.15f + num * 0.7f;
				float num4 = sign * halfHeightAt(num2) * 0.92f;
				float num5 = heightAt(num);
				array[i] = form.Push(num2, 0f, 0f, num4, new Vector2(num3, 0.445f), 0);
				array2[i] = form.Push(num2, (0f - num5) * 0.25f, 0f, num4 + sign * num5, new Vector2(num3, 0.615f), 0);
			}
			for (int j = 0; j < points; j++)
			{
				form.Quad(array[j], array2[j], array2[j + 1], array[j + 1]);
			}
		}

		private static void Lure(Form form, float s0, Func<float, float> halfHeightAt, float length)
		{
			//IL_001a: 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_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_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_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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.016f * length;
			Vector2[] array = (Vector2[])(object)new Vector2[4]
			{
				new Vector2(0f, 0f),
				new Vector2(-0.02f, 0.1f),
				new Vector2(-0.09f, 0.17f),
				new Vector2(-0.18f, 0.19f)
			};
			Vector2 uv = default(Vector2);
			((Vector2)(ref uv))..ctor(0.945f, 0.62f);
			float num2 = halfHeightAt(s0) * 0.96f;
			int num3 = -1;
			int b = -1;
			for (int i = 0; i < array.Length; i++)
			{
				float num4 = num * (1f - 0.5f * (float)i / (float)(array.Length - 1));
				float along = (0f - array[i].x) * length;
				float up = num2 + array[i].y * length;
				int num5 = form.Push(s0, along, 0f - num4, up, uv, 0);
				int num6 = form.Push(s0, along, num4, up, uv, 0);
				if (num3 >= 0)
				{
					form.Quad(num3, b, num6, num5);
				}
				num3 = num5;
				b = num6;
			}
			float num7 = (0f - array[^1].x) * length;
			float num8 = num2 + array[^1].y * length;
			float num9 = 0.035f * length;
			Vector2 uv2 = default(Vector2);
			((Vector2)(ref uv2))..ctor(0.96f, 0.65f);
			Vector2 uv3 = default(Vector2);
			((Vector2)(ref uv3))..ctor(0.985f, 0.65f);
			int a = form.Push(s0, num7, 0f, num8 + num9, uv2, 0);
			int a2 = form.Push(s0, num7, 0f, num8 - num9, uv2, 0);
			int num10 = form.Push(s0, num7 + num9, 0f, num8, uv3, 0);
			int num11 = form.Push(s0, num7 - num9, 0f, num8, uv3, 0);
			int num12 = form.Push(s0, num7, 0f - num9, num8, uv3, 0);
			int num13 = form.Push(s0, num7, num9, num8, uv3, 0);
			int[] array2 = new int[5] { num10, num12, num11, num13, num10 };
			for (int j = 0; j < 4; j++)
			{
				form.Tri(a, array2[j], array2[j + 1]);
				form.Tri(a2, array2[j + 1], array2[j]);
			}
			form.LureBulb = new Vector3(s0, num7, num8);
		}

		private static Form BuildPiranha()
		{
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			Form form = new Form();
			float[] array = new float[9] { 0f, 0.1f, 0.22f, 0.36f, 0.52f, 0.68f, 0.82f, 0.92f, 1f };
			float[] hx = new float[9] { 0f, 0.1f, 0.22f, 0.36f, 0.52f, 0.68f, 0.82f, 0.92f, 1f };
			float[] hy = new float[9] { 0.33f, 0.37f, 0.39f, 0.395f, 0.35f, 0.26f, 0.14f, 0.08f, 0.06f };
			int[][] array2 = new int[array.Length][];
			for (int i = 0; i < array.Length; i++)
			{
				float num = array[i];
				array2[i] = EllipseRing(form, num, 0f, H(num) * Wr(num), H(num), num, 12);
			}
			for (int j = 0; j < array2.Length - 1; j++)
			{
				Stitch(form, array2[j], array2[j + 1]);
			}
			int c = form.Push(1f, -0.02f, 0f, 0f, new Vector2(0.99f, 0.22f), 0);
			for (int k = 0; k < 12; k++)
			{
				form.Tri(array2[^1][k], array2[^1][k + 1], c);
			}
			int[] array3 = EllipseRing(form, 0.02f, 0.01f, H(0f) * Wr(0f) * 0.9f, H(0f) * 0.9f, 0.9f, 12, 0.81f, 0.99f);
			Stitch(form, array2[0], array3);
			int c2 = form.Push(0.17f, 0f, 0f, 0f, new Vector2(0.03f, 0.9f), 0);
			for (int l = 0; l < 12; l++)
			{
				form.Tri(array3[l], array3[l + 1], c2);
			}
			float num2 = H(0f) * Wr(0f);
			float num3 = H(0f);
			BuildJaw(form, 1, 1f, num2 * 0.99f, num3 * 0.92f, 0.26f, 4);
			BuildJaw(form, 2, -1f, num2 * 0.99f, num3 * 0.85f, 0.23f, 4);
			BuildTeeth(form, 1, 1f, num2 * 0.99f, num3 * 0.92f, 0.26f, 4, 0.052f);
			BuildTeeth(form, 2, -1f, num2 * 0.99f, num3 * 0.85f, 0.23f, 3, 0.052f);
			float[] array4 = new float[9];
			float[] array5 = new float[9];
			for (int m = 0; m < 9; m++)
			{
				float num4 = (float)m / 8f;
				array5[m] = (0.34f - 0.13f * (1f - Mathf.Pow(Mathf.Abs((array4[m] = Mathf.Lerp(-1.05f, 1.05f, num4)) / 1.05f), 1.4f))) * 1f;
			}
			FinFan(form, 1f, -0.005f, (0f - H(1f)) * 0.9f, H(1f) * 0.9f, array4, array5, 0.1f, 0.9f);
			Crest(form, 0.38f, 0.78f, 3, 0.19f, H);
			SideFin(form, 0.17f, H(0.17f) * Wr(0.17f) * 0.95f, (0f - H(0.17f)) * 0.15f, 0.07f, 0.17f, 0.06f, 0.3f, 0.5f, 1f);
			SideFin(form, 0.17f, H(0.17f) * Wr(0.17f) * 0.95f, (0f - H(0.17f)) * 0.15f, 0.07f, 0.17f, 0.06f, 0.3f, 0.5f, -1f);
			SideFin(form, 0.56f, H(0.56f) * Wr(0.56f) * 0.6f, (0f - H(0.56f)) * 0.85f, 0.03f, 0.12f, 0.08f, 0.55f, 0.7f, 1f);
			SideFin(form, 0.56f, H(0.56f) * Wr(0.56f) * 0.6f, (0f - H(0.56f)) * 0.85f, 0.03f, 0.12f, 0.08f, 0.55f, 0.7f, -1f);
			Lure(form, 0.1f, H, 1f);
			form.Seal();
			return form;
			float H(float s)
			{
				return Interp(s, hx, hy) * 1f;
			}
			static float Wr(float s)
			{
				return 0.5f - 0.1f * s;
			}
		}

		private static Form BuildSerpent()
		{
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			Form form = new Form();
			float[] array = new float[12]
			{
				0f, 0.04f, 0.1f, 0.18f, 0.28f, 0.4f, 0.52f, 0.64f, 0.76f, 0.86f,
				0.94f, 1f
			};
			float[] hx = new float[9] { 0f, 0.04f, 0.1f, 0.18f, 0.28f, 0.52f, 0.76f, 0.94f, 1f };
			float[] hy = new float[9] { 0.04f, 0.056f, 0.072f, 0.082f, 0.086f, 0.08f, 0.06f, 0.036f, 0.024f };
			int[][] array2 = new int[array.Length][];
			for (int i = 0; i < array.Length; i++)
			{
				float num = array[i];
				array2[i] = EllipseRing(form, num, 0f, H(num) * 0.76f, H(num), num, 12);
			}
			for (int j = 0; j < array2.Length - 1; j++)
			{
				Stitch(form, array2[j], array2[j + 1]);
			}
			RibbonFin(form, 0.55f, 1f, 10, (float q) => (0.02f + 0.05f * Mathf.Pow(q, 1.3f)) * 1f, H, 1f);
			RibbonFin(form, 0.62f, 1f, 8, (float q) => (0.015f + 0.035f * Mathf.Pow(q, 1.3f)) * 1f, H, -1f);
			float[] array3 = new float[11];
			float[] array4 = new float[11];
			for (int num2 = 0; num2 < 11; num2++)
			{
				float num3 = (float)num2 / 10f;
				array4[num2] = (0.085f + 0.02f * Mathf.Cos((array3[num2] = Mathf.Lerp(-1.35f, 1.35f, num3)) * 1.1f)) * 1f;
			}
			FinFan(form, 1f, -0.002f, (0f - H(1f)) * 0.8f, H(1f) * 0.8f, array3, array4, 0.1f, 0.9f);
			int c = form.Push(1f, -0.008f, 0f, 0f, new Vector2(0.99f, 0.22f), 0);
			for (int num4 = 0; num4 < 12; num4++)
			{
				form.Tri(array2[^1][num4], array2[^1][num4 + 1], c);
			}
			int[] array5 = EllipseRing(form, 0.012f, 0.004f, H(0f) * 0.76f * 0.88f, H(0f) * 0.88f, 0.9f, 12, 0.81f, 0.99f);
			Stitch(form, array2[0], array5);
			int c2 = form.Push(0.08f, 0f, 0f, 0f, new Vector2(0.03f, 0.9f), 0);
			for (int num5 = 0; num5 < 12; num5++)
			{
				form.Tri(array5[num5], array5[num5 + 1], c2);
			}
			float halfWidth = H(0f) * 0.76f;
			float num6 = H(0f);
			BuildJaw(form, 1, 1f, halfWidth, num6 * 0.95f, 0.15f, 5);
			BuildJaw(form, 2, -1f, halfWidth, num6 * 0.85f, 0.135f, 5);
			BuildTeeth(form, 1, 1f, halfWidth, num6 * 0.95f, 0.15f, 5, 0.03f);
			BuildTeeth(form, 2, -1f, halfWidth, num6 * 0.85f, 0.135f, 4, 0.03f);
			float[] array6 = new float[6] { 0f, 0.03f, 0.065f, 0.1f, 0.13f, 0.155f };
			float[] array7 = new float[6] { 0.01f, 0.075f, 0.125f, 0.105f, 0.045f, 0.012f };
			int[] array8 = new int[array6.Length];
			int[] array9 = new int[array6.Length];
			for (int num7 = 0; num7 < array6.Length; num7++)
			{
				float num8 = (float)num7 / (float)(array6.Length - 1);
				float s = 0.24f + array6[num7];
				array8[num7] = form.Push(s, 0f, 0f, H(s) * 0.9f, new Vector2(0.2f + num8 * 0.5f, 0.445f), 0);
				array9[num7] = form.Push(s, (0f - array7[num7]) * 0.55f * 1f, 0f, H(s) * 0.9f + array7[num7] * 1f, new Vector2(0.2f + num8 * 0.5f, 0.615f), 0);
			}
			for (int num9 = 0; num9 < array6.Length - 1; num9++)
			{
				form.Quad(array8[num9], array9[num9], array9[num9 + 1], array8[num9 + 1]);
			}
			Crest(form, 0.46f, 0.56f, 2, 0.035f, H);
			SideFin(form, 0.13f, H(0.13f) * 0.76f * 0.9f, (0f - H(0.13f)) * 0.3f, 0.025f, 0.1f, 0.04f, 0.3f, 0.5f, 1f);
			SideFin(form, 0.13f, H(0.13f) * 0.76f * 0.9f, (0f - H(0.13f)) * 0.3f, 0.025f, 0.1f, 0.04f, 0.3f, 0.5f, -1f);
			form.Seal();
			return form;
			float H(float s2)
			{
				return Interp(s2, hx, hy) * 1f;
			}
		}

		private static void BuildSnout(Form form, float halfWidth, float halfHeight, float length, int rings)
		{
			//IL_0173: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.624f;
			float num2 = 0.706f;
			float num3 = 0.755f;
			int[] array = null;
			int a = -1;
			int b = -1;
			for (int i = 0; i <= rings; i++)
			{
				float num4 = (float)i / (float)rings;
				float along = num4 * length;
				float num5 = 1f - 0.92f * Mathf.Pow(num4, 1.3f);
				float num6 = halfWidth * num5;
				float num7 = halfHeight * num5 * (1f - 0.25f * num4);
				float num8 = num4 * 0.5f;
				int[] array2 = new int[7];
				for (int j = 0; j <= 6; j++)
				{
					float num9 = (float)j / 6f;
					float num10 = (num9 - 0.5f) * MathF.PI;
					array2[j] = form.Push(0f, along, Mathf.Sin(num10) * num6, Mathf.Cos(num10) * num7, new Vector2(num8, num + (num2 - num) * num9), 1);
				}
				int num11 = form.Push(0f, along, 0f - num6, 0f, new Vector2(num8, num3), 1);
				int num12 = form.Push(0f, along, num6, 0f, new Vector2(num8, num3), 1);
				if (array != null)
				{
					Stitch(form, array, array2);
					form.Quad(a, b, num12, num11);
				}
				array = array2;
				a = num11;
				b = num12;
			}
			int c = form.Push(0f, length * 1.04f, 0f, halfHeight * 0.02f, new Vector2(0.5f, (num + num2) * 0.5f), 1);
			for (int k = 0; k < array.Length - 1; k++)
			{
				form.Tri(array[k], array[k + 1], c);
			}
			form.Tri(a, b, c);
		}

		private static void Blade(Form form, float baseS, float[] profileS, float[] profileH, float sweep, Func<float, float> halfHeightAt, float sign = 1f)
		{
			//IL_0061: 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)
			int num = profileS.Length;
			int[] array = new int[num];
			int[] array2 = new int[num];
			for (int i = 0; i < num; i++)
			{
				float num2 = (float)i / (float)(num - 1);
				float num3 = baseS + profileS[i];
				float num4 = sign * halfHeightAt(num3) * 0.9f;
				array[i] = form.Push(num3, 0f, 0f, num4, new Vector2(0.2f + num2 * 0.5f, 0.445f), 0);
				array2[i] = form.Push(num3, (0f - profileH[i]) * sweep, 0f, num4 + sign * profileH[i], new Vector2(0.2f + num2 * 0.5f, 0.615f), 0);
			}
			for (int j = 0; j < num - 1; j++)
			{
				form.Quad(array[j], array2[j], array2[j + 1], array[j + 1]);
			}
		}

		private static Form BuildShark()
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			Form form = new Form();
			float[] stations = new float[11]
			{
				0f, 0.06f, 0.14f, 0.24f, 0.36f, 0.5f, 0.64f, 0.76f, 0.86f, 0.93f,
				1f
			};
			float[] hy = new float[11]
			{
				0.086f, 0.104f, 0.12f, 0.132f, 0.135f, 0.123f, 0.101f, 0.076f, 0.051f, 0.035f,
				0.026f
			};
			int[][] array = new int[stations.Length][];
			for (int i = 0; i < stations.Length; i++)
			{
				float num = stations[i];
				array[i] = EllipseRing(form, num, 0f, H(num) * 0.8f, H(num), num, 12);
			}
			for (int j = 0; j < array.Length - 1; j++)
			{
				Stitch(form, array[j], array[j + 1]);
			}
			int c = form.Push(1f, -0.008f, 0f, 0f, new Vector2(0.99f, 0.22f), 0);
			for (int k = 0; k < 12; k++)
			{
				form.Tri(array[^1][k], array[^1][k + 1], c);
			}
			int[] array2 = EllipseRing(form, 0.012f, 0.004f, H(0f) * 0.8f * 0.88f, H(0f) * 0.88f, 0.9f, 12, 0.81f, 0.99f);
			Stitch(form, array[0], array2);
			int c2 = form.Push(0.09f, 0f, 0f, 0f, new Vector2(0.03f, 0.9f), 0);
			for (int l = 0; l < 12; l++)
			{
				form.Tri(array2[l], array2[l + 1], c2);
			}
			float num2 = H(0f) * 0.8f;
			float num3 = H(0f);
			BuildSnout(form, num2, num3 * 0.98f, 0.17f, 5);
			BuildJaw(form, 2, -1f, num2 * 0.96f, num3 * 0.8f, 0.105f, 4);
			BuildTeeth(form, 1, 1f, num2 * 0.96f, num3 * 0.8f, 0.105f, 6, 0.024f);
			BuildTeeth(form, 2, -1f, num2 * 0.96f, num3 * 0.8f, 0.105f, 5, 0.022f);
			Blade(form, 0.27f, new float[6] { 0f, 0.04f, 0.085f, 0.125f, 0.155f, 0.175f }, new float[6] { 0.012f, 0.095f, 0.175f, 0.16f, 0.075f, 0.014f }, 0.8f, H);
			Blade(form, 0.7f, new float[4] { 0f, 0.02f, 0.045f, 0.065f }, new float[4] { 0.006f, 0.04f, 0.034f, 0.006f }, 0.9f, H);
			Blade(form, 0.74f, new float[4] { 0f, 0.02f, 0.04f, 0.055f }, new float[4] { 0.005f, 0.03f, 0.026f, 0.005f }, 0.9f, H, -1f);
			for (int m = -1; m <= 1; m += 2)
			{
				SideFin(form, 0.2f, H(0.2f) * 0.8f * 0.85f, (0f - H(0.2f)) * 0.5f, 0.21f, 0.26f, 0.085f, 0.3f, 0.5f, m);
				SideFin(form, 0.6f, H(0.6f) * 0.8f * 0.6f, (0f - H(0.6f)) * 0.8f, 0.06f, 0.1f, 0.035f, 0.55f, 0.7f, m);
			}
			float[] array3 = new float[13];
			float[] array4 = new float[13];
			for (int n = 0; n < 13; n++)
			{
				float num4 = (float)n / 12f;
				float num5 = (array3[n] = Mathf.Lerp(-0.95f, 1.1f, num4));
				array4[n] = ((num5 >= 0f) ? ((0.055f + 0.265f * Mathf.Pow(num5 / 1.1f, 1.6f)) * 1f) : ((0.055f + 0.135f * Mathf.Pow((0f - num5) / 0.95f, 1.6f)) * 1f));
			}
			FinFan(form, 1f, -0.004f, (0f - H(1f)) * 0.8f, H(1f) * 0.8f, array3, array4, 0.1f, 0.9f);
			form.Seal();
			return form;
			float H(float s)
			{
				return Interp(s, stations, hy) * 1f;
			}
		}

		private static Form BuildIsopod()
		{
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0503: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ea: 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_0612: Unknown result type (might be due to invalid IL or missing references)
			//IL_0614: Unknown result type (might be due to invalid IL or missing references)
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			Form f = new Form();
			float[] hwx = new float[15]
			{
				0f, 0.03f, 0.08f, 0.15f, 0.22f, 0.3f, 0.4f, 0.5f, 0.58f, 0.66f,
				0.72f, 0.8f, 0.88f, 0.94f, 1f
			};
			float[] hwy = new float[15]
			{
				0.095f, 0.15f, 0.19f, 0.212f, 0.226f, 0.24f, 0.249f, 0.25f, 0.245f, 0.232f,
				0.205f, 0.182f, 0.168f, 0.13f, 0.075f
			};
			float[] hhx = new float[13]
			{
				0f, 0.03f, 0.08f, 0.15f, 0.22f, 0.32f, 0.45f, 0.58f, 0.7f, 0.8f,
				0.88f, 0.94f, 1f
			};
			float[] hhy = new float[13]
			{
				0.034f, 0.064f, 0.09f, 0.108f, 0.12f, 0.13f, 0.133f, 0.13f, 0.116f, 0.092f,
				0.07f, 0.052f, 0.03f
			};
			List<int[]> rings = new List<int[]>(48);
			float[] array = new float[5] { 0f, 0.025f, 0.06f, 0.11f, 0.155f };
			for (int i = 0; i < array.Length; i++)
			{
				Ring(array[i], 0f, 1f, 1f, 0f);
			}
			Ring(0.185f, -0.01f, 1.075f, 1.04f, 0.05f);
			float num = 0.07357143f;
			float num2 = 0.025000006f;
			float num3 = 0.185f;
			for (int j = 0; j < 11; j++)
			{
				float num4 = ((j < 7) ? (0.185f + num * (float)(j + 1)) : (0.7f + num2 * (float)(j - 7 + 1)));
				Ring(num3, 0f, 0.955f, 0.97f, 0f);
				Ring((num3 + num4) * 0.5f, 0f, 1f, 1f, 0f);
				Ring(num4, -0.01f, 1.075f, 1.04f, 0.038f);
				num3 = num4;
			}
			Ring(0.8f, 0f, 0.955f, 0.97f, 0f);
			float[] array2 = new float[4] { 0.86f, 0.91f, 0.955f, 0.985f };
			for (int k = 0; k < array2.Length; k++)
			{
				Ring(array2[k], 0f, 1f, 1f, 0f);
			}
			for (int l = 0; l < rings.Count - 1; l++)
			{
				Stitch(f, rings[l], rings[l + 1]);
			}
			int[] array3 = rings[rings.Count - 1];
			int c = f.Push(1f, -0.004f, 0f, H(1f) * 0.2f, new Vector2(0.99f, 0.22f), 0);
			for (int m = 0; m < 16; m++)
			{
				f.Tri(array3[m], array3[m + 1], c);
			}
			int[] array4 = ShellRing(f, 0.02f, 0.005f, W(0f) * 0.46f, H(0f) * 0.62f, H(0f) * 0.3f, 0f, 0.9f, 16, 0.81f, 0.99f);
			Stitch(f, rings[0], array4);
			int c2 = f.Push(0.062f, 0f, 0f, (0f - H(0f)) * 0.16f, new Vector2(0.03f, 0.9f), 0);
			for (int n = 0; n < 16; n++)
			{
				f.Tri(array4[n], array4[n + 1], c2);
			}
			float halfWidth = W(0f) * 0.44f;
			float num5 = H(0f) * 0.58f;
			BuildJaw(f, 1, 1f, halfWidth, num5 * 0.95f, 0.04f, 3);
			BuildJaw(f, 2, -1f, halfWidth, num5 * 0.85f, 0.036f, 3);
			BuildTeeth(f, 1, 1f, halfWidth, num5 * 0.95f, 0.04f, 2, 0.014f);
			BuildTeeth(f, 2, -1f, halfWidth, num5 * 0.85f, 0.036f, 2, 0.014f);
			Vector3 hip = default(Vector3);
			for (int num6 = 0; num6 < 7; num6++)
			{
				float s = 0.185f + num * ((float)num6 + 0.5f);
				float num7 = (0.82f + 0.06f * (float)num6) * 1f;
				((Vector3)(ref hip))..ctor(W(s) * 0.88f, (0f - H(s)) * 0.3f, 0f);
				Vector3 knee = new Vector3(0.085f, -0.075f, 0.022f - 0.013f * (float)num6) * num7;
				Vector3 claw = new Vector3(0.058f, -0.032f, -0.07f - 0.016f * (float)num6) * num7;
				Limb(f, s, 1f, hip, knee, claw, 0.026f * num7, 0.3f, 0.8f);
				Limb(f, s, -1f, hip, knee, claw, 0.026f * num7, 0.3f, 0.8f);
			}
			Vector3 hip2 = default(Vector3);
			((Vector3)(ref hip2))..ctor(W(0.05f) * 0.8f, (0f - H(0.05f)) * 0.1f, 0f);
			Vector3 knee2 = new Vector3(0.085f, 0.008f, 0.12f) * 1f;
			Vector3 claw2 = new Vector3(0.095f, -0.012f, 0.13f) * 1f;
			Limb(f, 0.05f, 1f, hip2, knee2, claw2, 0.018f, 0.1f, 0.6f);
			Limb(f, 0.05f, -1f, hip2, knee2, claw2, 0.018f, 0.1f, 0.6f);
			float[] angles = new float[5] { -0.05f, 0.18f, 0.42f, 0.66f, 0.92f };
			float[] radii = new float[5] { 0.18f, 0.19f, 0.195f, 0.18f, 0.15f };
			FinFanFlat(f, 0.86f, -0.015f, W(0.86f) * 0.3f, W(0.86f) * 0.98f, (0f - H(0.86f)) * 0.1f, angles, radii, 1f, 0.12f, 0.88f);
			FinFanFlat(f, 0.86f, -0.015f, W(0.86f) * 0.3f, W(0.86f) * 0.98f, (0f - H(0.86f)) * 0.1f, angles, radii, -1f, 0.12f, 0.88f);
			f.Seal();
			return f;
			float H(float s2)
			{
				return Interp(s2, hhx, hhy) * 1f;
			}
			void Ring(float num8, float along, float w, float h, float sweep)
			{
				rings.Add(ShellRing(f, num8, along * 1f, W(num8) * w, H(num8) * h, H(num8) * 0.35f, sweep * 1f, num8, 16));
			}
			float W(float s2)
			{
				return Interp(s2, hwx, hwy) * 1f;
			}
		}
	}
	internal static class DagonFishSkin
	{
		private sealed class Palette
		{
			internal Color Back;

			internal Color Flank;

			internal Color Belly;

			internal Color Fin;

			internal Color GlowEdge;

			internal Color Lip;

			internal float[] Seams;

			internal float SeamWidth = 0.01f;
		}

		internal const float BodyV = 0.44f;

		internal const float FinV0 = 0.44f;

		internal const float FinV1 = 0.62f;

		internal const float JawV0 = 0.62f;

		internal const float JawMid = 0.71f;

		internal const float JawV1 = 0.8f;

		internal const float MawV0 = 0.8f;

		internal static readonly Color PaperTint = new Color(0.5f, 0.5f, 0.5f, 1f);

		private static readonly Palette PiranhaPalette = new Palette
		{
			Back = new Color(0.13f, 0.04f, 0.26f),
			Flank = new Color(0.46f, 0.18f, 0.66f),
			Belly = new Color(0.9f, 0.82f, 0.96f),
			Fin = new Color(0.55f, 0.28f, 0.74f),
			GlowEdge = new Color(0.93f, 0.8f, 1f),
			Lip = new Color(0.88f, 0.52f, 0.78f)
		};

		private static readonly Palette HunterPalette = new Palette
		{
			Back = new Color(0.24f, 0.02f, 0.04f),
			Flank = new Color(0.8f, 0.13f, 0.12f),
			Belly = new Color(0.98f, 0.8f, 0.66f),
			Fin = new Color(0.94f, 0.34f, 0.14f),
			GlowEdge = new Color(1f, 0.86f, 0.55f),
			Lip = new Color(0.88f, 0.52f, 0.78f)
		};

		private static readonly Palette SharkPalette = new Palette
		{
			Back = new Color(0.07f, 0.11f, 0.17f),
			Flank = new Color(0.36f, 0.5f, 0.6f),
			Belly = new Color(0.93f, 0.95f, 0.94f),
			Fin = new Color(0.16f, 0.24f, 0.33f),
			GlowEdge = new Color(0.7f, 0.85f, 0.95f),
			Lip = new Color(0.8f, 0.62f, 0.68f),
			Seams = new float[8] { 0.3f, 0.38f, 0.46f, 0.54f, 0.62f, 0.7f, 0.78f, 0.86f },
			SeamWidth = 0.016f
		};

		private static readonly Palette SerpentPalette = new Palette
		{
			Back = new Color(0.03f, 0.17f, 0.07f),
			Flank = new Color(0.17f, 0.52f, 0.22f),
			Belly = new Color(0.82f, 0.94f, 0.78f),
			Fin = new Color(0.26f, 0.62f, 0.28f),
			GlowEdge = new Color(0.8f, 1f, 0.76f),
			Lip = new Color(0.74f, 0.42f, 0.64f)
		};

		private static readonly Palette IsopodPalette = new Palette
		{
			Back = new Color(0.4f, 0.31f, 0.43f),
			Flank = new Color(0.82f, 0.64f, 0.6f),
			Belly = new Color(0.95f, 0.91f, 0.83f),
			Fin = new Color(0.87f, 0.79f, 0.64f),
			GlowEdge = new Color(0.98f, 0.93f, 0.82f),
			Lip = new Color(0.88f, 0.52f, 0.78f),
			Seams = new float[12]
			{
				0.185f, 0.259f, 0.332f, 0.406f, 0.479f, 0.553f, 0.626f, 0.7f, 0.725f, 0.75f,
				0.775f, 0.8f
			}
		};

		internal static readonly Color SwarmGlow = new Color(0.62f, 0.22f, 0.95f);

		internal static readonly Color HunterGlow = new Color(1f, 0.32f, 0.18f);

		internal static readonly Color SharkGlow = new Color(0.45f, 0.7f, 0.95f);

		internal static readonly Color SerpentGlow = new Color(0.3f, 0.85f, 0.4f);

		internal static readonly Color IsopodGlow = new Color(0.95f, 0.75f, 0.8f);

		private static readonly Color Maw = new Color(0.34f, 0.07f, 0.16f);

		private static readonly Color Throat = new Color(0.09f, 0.02f, 0.05f);

		private static readonly Color Ivory = new Color(0.97f, 0.95f, 0.86f);

		private static readonly Color Amber = new Color(1f, 0.78f, 0.25f);

		private static readonly Color Ink = new Color(0.03f, 0.05f, 0.06f);

		private static Texture2D piranha;

		private static Texture2D hunter;

		private static Texture2D shark;

		private static Texture2D serpent;

		private static Texture2D isopod;

		internal static Texture2D Piranha
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)piranha))
				{
					return piranha = JujutsuFxTextures.Build("texDagonPiranhaSkin", 192, (Func<float, float, Color32>)((float u, float v) => Shade(u, v, serpentStyle: false, PiranhaPalette)));
				}
				return piranha;
			}
		}

		internal static Texture2D Hunter
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)hunter))
				{
					return hunter = JujutsuFxTextures.Build("texDagonHunterSkin", 192, (Func<float, float, Color32>)((float u, float v) => Shade(u, v, serpentStyle: false, HunterPalette)));
				}
				return hunter;
			}
		}

		internal static Texture2D Shark
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)shark))
				{
					return shark = JujutsuFxTextures.Build("texDagonSharkSkin", 192, (Func<float, float, Color32>)((float u, float v) => Shade(u, v, serpentStyle: true, SharkPalette)));
				}
				return shark;
			}
		}

		internal static Texture2D Serpent
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)serpent))
				{
					return serpent = JujutsuFxTextures.Build("texDagonSerpentSkin", 192, (Func<float, float, Color32>)((float u, float v) => Shade(u, v, serpentStyle: true, SerpentPalette)));
				}
				return serpent;
			}
		}

		internal static Texture2D Isopod
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)isopod))
				{
					return isopod = JujutsuFxTextures.Build("texDagonIsopodSkin", 192, (Func<float, float, Color32>)((float u, float v) => Shade(u, v, serpentStyle: false, IsopodPalette)));
				}
				return isopod;
			}
		}

		private static Color32 Shade(float u, float v, bool serpentStyle, Palette palette)
		{
			//IL_007a: 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_001f: 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_0018: 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_00a8: 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_0058: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			if (u > 0.93f)
			{
				if (v > 0.93f)
				{
					return ToColor32((v > 0.965f) ? (Ivory * 0.82f) : Ivory, 1f);
				}
				if (v > 0.6f && v < 0.7f)
				{
					return ToColor32(Color.Lerp(Color.white, Amber, 0.35f), 1f);
				}
			}
			if (v < 0.44f)
			{
				return Body(u, v / 0.44f, serpentStyle, palette);
			}
			if (v < 0.62f)
			{
				return FinMembrane(u, (v - 0.44f) / 0.18f, palette);
			}
			if (v < 0.8f)
			{
				return Jaw(u, v, palette);
			}
			return MawInterior(u);
		}

		private static Color32 Body(float u, float th, bool serpentStyle, Palette palette)
		{
			//IL_003c: 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_0063: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: 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_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: 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_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: 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_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			float num = 1f - Mathf.Abs(th - 0.5f) * 2f;
			Color val = ((num > 0.62f) ? Color.Lerp(palette.Flank, palette.Back, (Mathf.Clamp(num, 0.62f, 0.92f) - 0.62f) / 0.3f) : Color.Lerp(palette.Belly, palette.Flank, num / 0.62f));
			float num2 = (Value(u * 8f, th * 8f, 7) * 0.6f + Value(u * 19f, th * 19f, 23) * 0.4f - 0.5f) * (serpentStyle ? 0.3f : 0.2f) * Mathf.Clamp01((num - 0.4f) / 0.4f);
			val *= 1f + num2;
			float num3 = Mathf.Floor(th * 30f);
			float num4 = u * 34f + num3 % 2f * 0.5f;
			float num5 = Mathf.Sqrt(Sq(num4 - Mathf.Floor(num4) - 0.5f) + Sq(Mathf.Repeat(th * 30f, 1f) - 0.15f));
			float num6 = Mathf.Clamp01(1f - Mathf.Abs(num5 - 0.42f) * 9f) * 0.045f * Mathf.Clamp01((num - 0.3f) / 0.3f) * Mathf.Clamp01((0.85f - num) / 0.2f);
			val *= 1f - num6;
			float num7 = Mathf.Sin(u * MathF.PI * 2f * (serpentStyle ? 34f : 16f)) * 0.5f + 0.5f;
			float num8 = Mathf.Clamp01((0.3f - num) / 0.3f) * 0.16f;
			val = Color.Lerp(val, palette.Belly, Mathf.Clamp01(num7 * num8 * 1.2f));
			float num9 = ((u > 0.16f && u < 0.92f) ? (Mathf.Exp(0f - Sq((num - 0.55f) / 0.022f)) * 0.45f) : 0f);
			val = Color.Lerp(val, Ink, num9);
			int num10 = (serpentStyle ? 5 : 2);
			float num11 = 0f;
			for (int i = 0; i < num10; i++)
			{
				float num12 = (serpentStyle ? 0.12f : 0.15f) + (float)i * 0.03f;
				float num13 = Mathf.Abs(u - num12 - (num - 0.55f) * 0.06f);
				num11 = Mathf.Max(num11, Mathf.Clamp01(1f - num13 * 110f) * Mathf.Exp(0f - Sq((num - 0.55f) / 0.17f)));
			}
			val = Color.Lerp(val, Ink, num11 * 0.75f);
			if (palette.Seams != null)
			{
				float num14 = 0f;
				for (int j = 0; j < palette.Seams.Length; j++)
				{
					num14 = Mathf.Max(num14, Mathf.Exp(0f - Sq((u - palette.Seams[j]) / palette.SeamWidth)));
				}
				val = Color.Lerp(val, Ink, num14 * 0.55f * Mathf.Clamp01((num - 0.18f) / 0.28f));
			}
			float num15 = (serpentStyle ? 0.045f : 0.06f);
			float num16 = (serpentStyle ? 0.022f : 0.05f);
			float num17 = (serpentStyle ? 0.9f : 1.4f);
			for (int k = 0; k < 2; k++)
			{
				float num18 = ((k == 0) ? 0.31f : 0.69f);
				float num19 = Mathf.Sqrt(Sq(u - num15) + Sq((th - num18) * num17));
				if (num19 < num16 * 1.25f)
				{
					val = Ink;
				}
				if (num19 < num16)
				{
					val = Amber;
				}
				if (num19 < num16 * 0.46f)
				{
					val = Ink;
				}
				if (Mathf.Sqrt(Sq(u - num15 + num16 * 0.24f) + Sq((th - num18) * num17 + num16 * 0.28f)) < num16 * 0.16f)
				{
					val = Color.white;
				}
			}
			return ToColor32(val, 1f);
		}

		private static Color32 FinMembrane(float u, float fv, Palette palette)
		{
			//IL_0026: 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_0057: 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_0074: 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)
			float num = Mathf.Sin(u * MathF.PI * 2f * 22f) * 0.5f + 0.5f;
			Color colour = Color.Lerp(palette.Fin * (0.7f + 0.4f * fv) * (1f - 0.38f * num * Mathf.Clamp01(fv * 1.4f)), palette.GlowEdge, Mathf.Clamp01((fv - 0.8f) / 0.2f));
			float alpha = Mathf.Clamp01((1.04f - fv) / 0.14f) * 0.92f;
			return ToColor32(colour, alpha);
		}

		private static Color32 Jaw(float u, float v, Palette palette)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0056: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			Color val = ((v < 0.71f) ? (palette.Back * 0.9f + palette.Flank * 0.35f) : (palette.Belly * 0.75f + palette.Flank * 0.35f));
			val.a = 1f;
			float num = Mathf.Clamp01((u - 0.55f) / 0.3f);
			Color val2 = Color.Lerp(val, palette.Lip, num);
			if (Mathf.Abs(u - 0.55f) < 0.022f || u > 0.94f)
			{
				val2 = Ink * 0.6f + val2 * 0.2f;
			}
			float num2 = Mathf.Sin(v * MathF.PI * 2f * 60f) * 0.5f + 0.5f;
			val2 *= 1f - 0.14f * num2 * num;
			return ToColor32(val2, 1f);
		}

		private static Color32 MawInterior(float u)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			Color val = Color.Lerp(Throat, Maw, u);
			float num = (Mathf.Sin(u * MathF.PI * 2f * 12f) * 0.5f + 0.5f) * Mathf.Clamp01(u * 1.5f);
			return ToColor32(val * (1f + 0.3f * num), 1f);
		}

		private static float Sq(float x)
		{
			return x * x;
		}

		private static Color32 ToColor32(Color colour, float alpha)
		{
			//IL_0000: 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_002e: 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)
			return new Color32((byte)Mathf.RoundToInt(Mathf.Clamp01(colour.r) * 255f), (byte)Mathf.RoundToInt(Mathf.Clamp01(colour.g) * 255f), (byte)Mathf.RoundToInt(Mathf.Clamp01(colour.b) * 255f), (byte)Mathf.RoundToInt(Mathf.Clamp01(alpha) * 255f));
		}

		private static float Value(float x, float y, int seed)
		{
			int num = Mathf.FloorToInt(x);
			int num2 = Mathf.FloorToInt(y);
			float num3 = Smooth(x - (float)num);
			float num4 = Smooth(y - (float)num2);
			float num5 = Hash(num, num2, seed);
			float num6 = Hash(num + 1, num2, seed);
			float num7 = Hash(num, num2 + 1, seed);
			float num8 = Hash(num + 1, num2 + 1, seed);
			return Mathf.Lerp(Mathf.Lerp(num5, num6, num3), Mathf.Lerp(num7, num8, num3), num4);
		}

		private static float Smooth(float t)
		{
			return t * t * (3f - 2f * t);
		}

		private static float Hash(int x, int y, int seed)
		{
			int num = x * 374761393 + y * 668265263 + seed * 1442695040;
			int num2 = (num ^ (num >> 13)) * 1274126177;
			return (float)((num2 ^ (num2 >> 16)) & 0xFFFFFF) / 16777215f;
		}
	}
}
namespace GojoSatoruMod.Dagon.States
{
	public sealed class DagonBathynomusState : DagonCastState
	{
		internal const float GrabRadius = 15f;

		private const float Duration = 0.6f;

		private const float FireAt = 0.25f;

		private const float HuntRange = 80f;

		internal const float HuntConeDegrees = 15f;

		private const float OpenAirReach = 40f;

		private static readonly HashSet<HealthComponent> nothingExcluded = new HashSet<HealthComponent>();

		private bool fired;

		private Vector3 aimOrigin;

		private Vector3 aimDirection;

		private byte throwId;

		private NetworkInstanceId victimId;

		private Vector3 aimPoint;

		private bool fromWire;

		public override void OnEnter()
		{
			//IL_0057: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004b: Unknown result type (might be due to invalid IL or missing references)
			((BaseState)this).OnEnter();
			((EntityState)this).characterBody.SetAimTimer(1f);
			if (!fromWire)
			{
				Ray aimRay = ((BaseState)this).GetAimRay();
				aimOrigin = ((Ray)(ref aimRay)).origin;
				aimDirection = ((Ray)(ref aimRay)).direction;
				throwId = DagonBathynomusKey.NextThrowId();
				Choose(aimRay);
			}
			JujutsuSfxAssets.PlayLightWhoosh(((EntityState)this).characterBody.corePosition, 0.9f);
			TakeClip("Heave", 0f, 0.25f, 0.25f);
		}

		private void Choose(Ray aim)
		{
			//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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			TeamIndex team = ((BaseState)this).GetTeam();
			RaycastHit val = default(RaycastHit);
			aimPoint = (Physics.Raycast(aim, ref val, 80f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1) ? ((RaycastHit)(ref val)).point : (((Ray)(ref aim)).origin + ((Ray)(ref aim)).direction * 40f));
			CharacterBody val2 = DagonHunt.First(team, aim, 80f, 15f);
			if (!Object.op_Implicit((Object)(object)val2))
			{
				val2 = DagonHunt.Nearest(team, aimPoint, Vector3.zero, 15f, nothingExcluded);
			}
			victimId = ((Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.networkIdentity)) ? val2.networkIdentity.netId : NetworkInstanceId.Invalid);
		}

		public override void OnSerialize(NetworkWriter writer)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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)
			((BaseSkillState)this).OnSerialize(writer);
			writer.Write(aimOrigin);
			writer.Write(aimDirection);
			writer.Write(throwId);
			writer.Write(victimId);
			writer.Write(aimPoint);
		}

		public override void OnDeserialize(NetworkReader reader)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			((BaseSkillState)this).OnDeserialize(reader);
			aimOrigin = reader.ReadVector3();
			aimDirection = reader.ReadVector3();
			throwId = reader.ReadByte();
			victimId = reader.ReadNetworkId();
			aimPoint = reader.ReadVector3();
			fromWire = true;
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (!fired && ((EntityState)this).fixedAge >= 0.25f)
			{
				fired = true;
				Fire();
			}
			if (((EntityState)this).fixedAge >= 0.6f && ((EntityState)this).isAuthority)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		private void Fire()
		{
			//IL_0020: 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_0043: 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_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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (!fromWire)
			{
				DagonBathynomusKey.NoteThrow(((EntityState)this).gameObject, throwId);
			}
			DagonBathynomusController.Launch(((EntityState)this).gameObject, ((BaseState)this).GetTeam(), Victim(), aimPoint, ((BaseState)this).damageStat, throwId);
			JujutsuMotes.Burst(aimOrigin + aimDirection * 1.8f, aimDirection, DagonFishSkin.IsopodGlow, 1.6f, (JujutsuMoteKind)1, 12);
		}

		private CharacterBody Victim()
		{
			//IL_0001: 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)
			if (DagonBathynomusSync.Missing(victimId))
			{
				return null;
			}
			GameObject val = Util.FindNetworkObject(victimId);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			return val.GetComponent<CharacterBody>();
		}

		public override void OnExit()
		{
			if (!fired && ((EntityState)this).isAuthority)
			{
				CursedEnergySkillDef.Refund(((BaseSkillState)this).activatorSkillSlot);
			}
			base.OnExit();
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)2;
		}
	}
	public abstract class DagonCastState : BaseSkillState, IPosedState
	{
		protected bool heldClip;

		bool IPosedState.DrivesPose => heldClip;

		GojoCpuPose IPosedState.Pose => (GojoCpuPose)0;

		float IPosedState.PosePhase => 0f;

		float IPosedState.PoseBob => 0f;

		float IPosedState.PosePitch => 0f;

		bool IPosedState.HoldsSlashPose => false;

		int IPosedState.PosePriority => 20;

		protected bool TakeClip(string clip, float fromSeconds, float anchorSeconds, float fireSeconds)
		{
			float speed = DagonClipWork.SpeedFor(anchorSeconds, fromSeconds, fireSeconds);
			float upperBlendSeconds = Mathf.Clamp(fireSeconds - Time.fixedDeltaTime, 0.035f, 0.12f);
			return heldClip = DagonClipWork.Loop(((EntityState)this).characterBody, clip, fromSeconds, speed, upperBlendSeconds);
		}

		public override void OnExit()
		{
			if (heldClip)
			{
				DagonClipWork.Release(((EntityState)this).characterBody);
				heldClip = false;
			}
			((EntityState)this).OnExit();
		}
	}
	public sealed class DagonSwarmState : DagonCastState
	{
		private const float BaseDuration = 0.6f;

		private const float FireShare = 0.15f;

		internal const float Coefficient = 1f;

		private const float HunterLockRange = 60f;

		internal const float HunterLockConeDegrees = 20f;

		private const float AimReach = 80f;

		private const float AimBodyRadius = 1f;

		private const float Ripple = 0.02f;

		private static readonly float[] Across = new float[6] { 0f, -0.35f, 0.35f, -0.6f, 0.6f, 0f };

		private static readonly float[] Lift = new float[6] { 0f, 0.18f, 0.18f, -0.15f, -0.15f, 0.3f };

		private static readonly float[] Pace = new float[6] { 1f, 0.98f, 0.98f, 0.96f, 0.96f, 1.02f };

		private static readonly List<CharacterBody> candidates = new List<CharacterBody>(1);

		private static readonly List<DagonShoal.Thrown> thrown = new List<DagonShoal.Thrown>(6);

		private float duration;

		private bool fired;

		private Vector3 aimOrigin;

		private Vector3 aimDirection;

		private DagonShoal.Order order;

		private bool fromWire;

		public override void OnEnter()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0142: Unknown result type (might be due to invalid IL or missing references)
			((BaseState)this).OnEnter();
			duration = 0.6f / ((BaseState)this).attackSpeedStat;
			((EntityState)this).characterBody.SetAimTimer(duration + 0.6f);
			if (!fromWire)
			{
				Ray aimRay = ((BaseState)this).GetAimRay();
				aimOrigin = ((Ray)(ref aimRay)).origin;
				aimDirection = ((Ray)(ref aimRay)).direction;
				DagonShoal component = ((EntityState)this).GetComponent<DagonShoal>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					this.order = new DagonShoal.Order
					{
						Count = 6
					};
				}
				else if (!component.TryCollect(out this.order))
				{
					this.order = component.Plan(fresh: true);
					component.TryCollect(out var _);
				}
			}
			if (!this.order.IsEmpty)
			{
				string clip = (this.order.Big ? "SendBig" : ((((this.order.Head / 6) & 1) == 0) ? "SendR" : "SendL"));
				float anchorSeconds = (this.order.Big ? 0.12f : 0.1f);
				float fromSeconds = (this.order.Big ? 0.03f : 0.02f);
				TakeClip(clip, fromSeconds, anchorSeconds, duration * 0.15f);
				if (((EntityState)this).isAuthority)
				{
					DagonAssets.PlaySwarmCall(((EntityState)this).characterBody.corePosition);
				}
			}
		}

		public override void OnSerialize(NetworkWriter writer)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			((BaseSkillState)this).OnSerialize(writer);
			writer.Write(aimOrigin);
			writer.Write(aimDirection);
			writer.Write(order.Head);
			writer.Write((byte)(order.Count | (order.Big ? 128 : 0)));
			writer