Decompiled source of Miyabi Mercenary v0.8.7

plugins/MiyabiMercenary/MiyabiMercenary.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using RoR2.Projectile;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MiyabiMercenary")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MiyabiMercenary")]
[assembly: AssemblyTitle("MiyabiMercenary")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MiyabiMercenary
{
	internal static class HandPose
	{
		internal static readonly Dictionary<string, Quaternion> Grip = new Dictionary<string, Quaternion>
		{
			{
				"右人指1",
				new Quaternion(-0.022945f, -0.086405f, -0.469021f, 0.87865f)
			},
			{
				"右人指2",
				new Quaternion(-0.031197f, -0.11748f, -0.637701f, 0.760633f)
			},
			{
				"右人指3",
				new Quaternion(-0.022945f, -0.086405f, -0.469021f, 0.87865f)
			},
			{
				"右中指1",
				new Quaternion(-0.024751f, -0.093204f, -0.505929f, 0.857167f)
			},
			{
				"右中指2",
				new Quaternion(-0.033383f, -0.12571f, -0.682373f, 0.71934f)
			},
			{
				"右中指3",
				new Quaternion(-0.024751f, -0.093204f, -0.505929f, 0.857167f)
			},
			{
				"右薬指1",
				new Quaternion(-0.025195f, -0.094878f, -0.515011f, 0.851544f)
			},
			{
				"右薬指2",
				new Quaternion(-0.03391f, -0.127694f, -0.693145f, 0.708586f)
			},
			{
				"右薬指3",
				new Quaternion(-0.025195f, -0.094878f, -0.515011f, 0.851544f)
			},
			{
				"右小指1",
				new Quaternion(-0.025856f, -0.097366f, -0.52852f, 0.842922f)
			},
			{
				"右小指2",
				new Quaternion(-0.034685f, -0.130614f, -0.708996f, 0.692143f)
			},
			{
				"右小指3",
				new Quaternion(-0.025856f, -0.097366f, -0.52852f, 0.842922f)
			},
			{
				"右親指0",
				new Quaternion(0.11015f, -0.077662f, -0.079418f, 0.987688f)
			},
			{
				"右親指1",
				new Quaternion(0.269459f, -0.189984f, -0.194279f, 0.92388f)
			},
			{
				"右親指2",
				new Quaternion(0.325132f, -0.229236f, -0.234419f, 0.887011f)
			},
			{
				"左人指1",
				new Quaternion(-0.021601f, 0.086751f, 0.469021f, 0.87865f)
			},
			{
				"左人指2",
				new Quaternion(-0.02937f, 0.11795f, 0.637702f, 0.760633f)
			},
			{
				"左人指3",
				new Quaternion(-0.021601f, 0.086751f, 0.469021f, 0.87865f)
			},
			{
				"左中指1",
				new Quaternion(-0.023301f, 0.093577f, 0.505929f, 0.857167f)
			},
			{
				"左中指2",
				new Quaternion(-0.031428f, 0.126213f, 0.682373f, 0.71934f)
			},
			{
				"左中指3",
				new Quaternion(-0.023301f, 0.093577f, 0.505929f, 0.857167f)
			},
			{
				"左薬指1",
				new Quaternion(-0.02372f, 0.095257f, 0.515011f, 0.851544f)
			},
			{
				"左薬指2",
				new Quaternion(-0.031924f, 0.128205f, 0.693145f, 0.708586f)
			},
			{
				"左薬指3",
				new Quaternion(-0.02372f, 0.095257f, 0.515011f, 0.851544f)
			},
			{
				"左小指1",
				new Quaternion(-0.024342f, 0.097756f, 0.52852f, 0.842922f)
			},
			{
				"左小指2",
				new Quaternion(-0.032654f, 0.131137f, 0.708996f, 0.692143f)
			},
			{
				"左小指3",
				new Quaternion(-0.024342f, 0.097756f, 0.52852f, 0.842922f)
			},
			{
				"左親指0",
				new Quaternion(0.111343f, 0.075942f, 0.079418f, 0.987688f)
			},
			{
				"左親指1",
				new Quaternion(0.272378f, 0.185775f, 0.19428f, 0.92388f)
			},
			{
				"左親指2",
				new Quaternion(0.328653f, 0.224157f, 0.23442f, 0.887011f)
			}
		};
	}
	internal sealed class ItemDisplayHider
	{
		private readonly HashSet<ItemDisplay> seen = new HashSet<ItemDisplay>();

		private readonly List<Renderer> renderers = new List<Renderer>();

		private readonly List<bool> rendererFlags = new List<bool>();

		private readonly List<Light> lights = new List<Light>();

		private readonly List<bool> lightFlags = new List<bool>();

		internal void Scan(Transform model)
		{
			ItemDisplay[] componentsInChildren = ((Component)model).GetComponentsInChildren<ItemDisplay>(true);
			foreach (ItemDisplay val in componentsInChildren)
			{
				if (!Object.op_Implicit((Object)(object)val) || !seen.Add(val))
				{
					continue;
				}
				Renderer[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val2 in componentsInChildren2)
				{
					if (Object.op_Implicit((Object)(object)val2))
					{
						renderers.Add(val2);
						rendererFlags.Add(val2.forceRenderingOff);
						val2.forceRenderingOff = true;
					}
				}
				Light[] componentsInChildren3 = ((Component)val).GetComponentsInChildren<Light>(true);
				foreach (Light val3 in componentsInChildren3)
				{
					if (Object.op_Implicit((Object)(object)val3))
					{
						lights.Add(val3);
						lightFlags.Add(((Behaviour)val3).enabled);
						((Behaviour)val3).enabled = false;
					}
				}
			}
		}

		internal void KeepHidden()
		{
			for (int i = 0; i < renderers.Count; i++)
			{
				if (Object.op_Implicit((Object)(object)renderers[i]))
				{
					renderers[i].forceRenderingOff = true;
				}
			}
			for (int j = 0; j < lights.Count; j++)
			{
				if (Object.op_Implicit((Object)(object)lights[j]))
				{
					((Behaviour)lights[j]).enabled = false;
				}
			}
		}

		internal void Restore()
		{
			for (int i = 0; i < renderers.Count; i++)
			{
				try
				{
					if (Object.op_Implicit((Object)(object)renderers[i]))
					{
						renderers[i].forceRenderingOff = rendererFlags[i];
					}
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Miyabi item display restore: " + ex));
				}
			}
			for (int j = 0; j < lights.Count; j++)
			{
				try
				{
					if (Object.op_Implicit((Object)(object)lights[j]))
					{
						((Behaviour)lights[j]).enabled = lightFlags[j];
					}
				}
				catch (Exception ex2)
				{
					Plugin.Log.LogWarning((object)("Miyabi item display light restore: " + ex2));
				}
			}
			renderers.Clear();
			rendererFlags.Clear();
			lights.Clear();
			lightFlags.Clear();
			seen.Clear();
		}
	}
	internal static class MenuPose
	{
		internal const float ScabbardGrip = 0.7f;

		internal const float SheathedKatana = 1.25f;

		internal static readonly Dictionary<string, Quaternion> Bones = new Dictionary<string, Quaternion>
		{
			{
				"下半身",
				new Quaternion(0f, 0.087156f, 0f, 0.996195f)
			},
			{
				"上半身",
				new Quaternion(0f, 0.087156f, 0f, 0.996195f)
			},
			{
				"上半身2",
				new Quaternion(0f, -0.121869f, 0f, 0.992546f)
			},
			{
				"頭",
				new Quaternion(-0.034426f, -0.051374f, 0.026766f, 0.997727f)
			},
			{
				"左足",
				new Quaternion(-0.033363f, 0.002079f, 0.012721f, 0.99936f)
			},
			{
				"左ひざ",
				new Quaternion(0.00662f, -0.00031f, -0.001026f, 0.999978f)
			},
			{
				"左足首",
				new Quaternion(0.026209f, -0.045418f, -0.012847f, 0.998542f)
			},
			{
				"右足",
				new Quaternion(-0.01447f, -0.000858f, -0.001759f, 0.999893f)
			},
			{
				"右ひざ",
				new Quaternion(-0.010146f, 0.00017f, -0.01046f, 0.999894f)
			},
			{
				"右足首",
				new Quaternion(0.025114f, -0.042783f, 0.011144f, 0.998707f)
			},
			{
				"左腕",
				new Quaternion(-0.007692f, -0.01088f, 0.364737f, 0.931015f)
			},
			{
				"左ひじ",
				new Quaternion(-0.325638f, 0.487627f, 0.23856f, 0.774125f)
			},
			{
				"左手首",
				new Quaternion(-0.400695f, 0.816284f, 0.006041f, 0.416039f)
			},
			{
				"右腕",
				new Quaternion(-0.014342f, 0.00216f, -0.377092f, 0.926062f)
			},
			{
				"右ひじ",
				new Quaternion(-0.013781f, -0.020993f, -0.026088f, 0.999344f)
			}
		};

		internal static readonly Dictionary<string, Quaternion> SitBones = new Dictionary<string, Quaternion>
		{
			{
				"上半身",
				new Quaternion(-0.034899f, 0f, 0f, 0.999391f)
			},
			{
				"頭",
				new Quaternion(-0.017442f, -0.001826f, 0.034852f, 0.999239f)
			},
			{
				"左足",
				new Quaternion(-0.656177f, 0.037971f, -0.101191f, 0.746826f)
			},
			{
				"左ひざ",
				new Quaternion(0.592692f, -0.04467f, 0.118187f, 0.795458f)
			},
			{
				"左足首",
				new Quaternion(0.079356f, -0.01442f, -0.014578f, 0.996635f)
			},
			{
				"右足",
				new Quaternion(-0.658765f, -0.038855f, 0.101517f, 0.744455f)
			},
			{
				"右ひざ",
				new Quaternion(0.597992f, 0.044283f, -0.119462f, 0.791312f)
			},
			{
				"右足首",
				new Quaternion(0.075964f, 0.01577f, 0.01454f, 0.99688f)
			},
			{
				"左腕",
				new Quaternion(-0.115886f, 0.146091f, 0.363204f, 0.912859f)
			},
			{
				"左ひじ",
				new Quaternion(-0.195818f, 0.285689f, 0.027791f, 0.937691f)
			},
			{
				"左手首",
				new Quaternion(0.586056f, 0.355085f, -0.032015f, 0.727619f)
			},
			{
				"右腕",
				new Quaternion(-0.117729f, -0.144104f, -0.356305f, 0.915653f)
			},
			{
				"右ひじ",
				new Quaternion(-0.20016f, -0.282574f, -0.028772f, 0.937688f)
			},
			{
				"右手首",
				new Quaternion(-0.581216f, 0.364688f, -0.032102f, -0.726746f)
			},
			{
				"Q_0_0",
				new Quaternion(-0.62932f, 0f, -0f, 0.777146f)
			},
			{
				"Q_0_1",
				new Quaternion(-0.458008f, 0.018146f, -0.259503f, 0.850034f)
			},
			{
				"Q_0_2",
				new Quaternion(-0.171081f, 0.017313f, -0.247589f, 0.953484f)
			},
			{
				"Q_0_3",
				new Quaternion(-0.020925f, 0.006964f, -0.099593f, 0.994784f)
			},
			{
				"Q_0_4",
				new Quaternion(0.008928f, 0.002786f, -0.039843f, 0.999162f)
			},
			{
				"Q_0_5",
				new Quaternion(0.011013f, 0.000786f, -0.011234f, 0.999876f)
			},
			{
				"Q_0_7",
				new Quaternion(0.011013f, -0.000786f, 0.011234f, 0.999876f)
			},
			{
				"Q_0_8",
				new Quaternion(0.008928f, -0.002786f, 0.039843f, 0.999162f)
			},
			{
				"Q_0_9",
				new Quaternion(-0.020925f, -0.006964f, 0.099593f, 0.994784f)
			},
			{
				"Q_0_10",
				new Quaternion(-0.171081f, -0.017313f, 0.247589f, 0.953484f)
			},
			{
				"Q_0_11",
				new Quaternion(-0.458008f, -0.018146f, 0.259503f, 0.850034f)
			}
		};

		internal static Mesh ChairMesh;

		internal static Vector3 ChairScabbardMouth;

		internal static Quaternion ChairScabbardRot = Quaternion.identity;

		internal static float SitDrop;

		private static bool chairTried;

		internal static bool LoadChair()
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)ChairMesh))
			{
				return true;
			}
			if (chairTried)
			{
				return false;
			}
			chairTried = true;
			try
			{
				BinaryReader r = new BinaryReader(File.OpenRead(Path.Combine(Plugin.AssetsDir, "miyabi_chair.bin")));
				try
				{
					if (new string(r.ReadChars(8)) != "MCHAIR01")
					{
						throw new InvalidDataException("bad miyabi_chair.bin");
					}
					int num = r.ReadInt32();
					Vector3[] array = (Vector3[])(object)new Vector3[num];
					Vector3[] array2 = (Vector3[])(object)new Vector3[num];
					for (int i = 0; i < num; i++)
					{
						array[i] = V();
					}
					for (int j = 0; j < num; j++)
					{
						array2[j] = V();
					}
					int num2 = r.ReadInt32();
					int[] array3 = new int[num2];
					for (int k = 0; k < num2; k++)
					{
						array3[k] = r.ReadInt32();
					}
					Mesh val = new Mesh
					{
						name = "MiyabiChair",
						hideFlags = (HideFlags)32
					};
					if (num > 65000)
					{
						val.indexFormat = (IndexFormat)1;
					}
					val.vertices = array;
					val.normals = array2;
					val.uv = (Vector2[])(object)new Vector2[num];
					val.triangles = array3;
					val.RecalculateBounds();
					val.RecalculateTangents();
					ChairScabbardMouth = V();
					ChairScabbardRot = new Quaternion(r.ReadSingle(), r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
					SitDrop = r.ReadSingle();
					ChairMesh = val;
					return true;
				}
				finally
				{
					if (r != null)
					{
						((IDisposable)r).Dispose();
					}
				}
				Vector3 V()
				{
					//IL_0021: Unknown result type (might be due to invalid IL or missing references)
					return new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Miyabi chair unavailable, standing pose used: " + ex.Message));
				return false;
			}
		}
	}
	internal sealed class MiyabiData
	{
		internal sealed class Bone
		{
			public string Name;

			public int Parent;

			public Vector3 Pos;

			public int InheritFrom;

			public float InheritRatio;
		}

		internal sealed class Particle
		{
			public int Bone;

			public Vector3 Tip;

			public int Parent;

			public int Anchor;

			public int Group;

			public float Limit;

			public float Stiff;

			public float Drag;

			public float Grav;

			public float Radius;
		}

		internal sealed class Collider
		{
			public int Bone;

			public Vector3 A;

			public Vector3 B;

			public float Radius;
		}

		internal sealed class Gun
		{
			public Mesh Mesh;

			public Vector3 Muzzle;
		}

		public Bone[] Bones;

		public Mesh Body;

		public string[] SubmeshTextures;

		public Dictionary<int, Quaternion> FingerCurl = new Dictionary<int, Quaternion>();

		public Vector3[] Palm = (Vector3[])(object)new Vector3[2];

		public Gun[] Guns = new Gun[2];

		public Particle[] Particles;

		public (int a, int b, float rest)[] Links;

		public Collider[] Colliders;

		public Dictionary<string, int> Index = new Dictionary<string, int>();

		public int this[string name]
		{
			get
			{
				if (!Index.TryGetValue(name, out var value))
				{
					return -1;
				}
				return value;
			}
		}

		private static Vector3 V(BinaryReader r)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
		}

		private static string S(BinaryReader r)
		{
			return Encoding.UTF8.GetString(r.ReadBytes(r.ReadInt32()));
		}

		public static MiyabiData Load(string path)
		{
			//IL_0079: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: 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_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Expected O, but got Unknown
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: 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_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f5: 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_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0606: Unknown result type (might be due to invalid IL or missing references)
			//IL_060b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Expected O, but got Unknown
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			MiyabiData miyabiData = new MiyabiData();
			using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path));
			if (Encoding.ASCII.GetString(binaryReader.ReadBytes(8)) != "MIYABI01")
			{
				throw new InvalidDataException("bad miyabi.bin");
			}
			int num = binaryReader.ReadInt32();
			miyabiData.Bones = new Bone[num];
			for (int i = 0; i < num; i++)
			{
				miyabiData.Bones[i] = new Bone
				{
					Name = S(binaryReader),
					Parent = binaryReader.ReadInt32(),
					Pos = V(binaryReader),
					InheritFrom = binaryReader.ReadInt32(),
					InheritRatio = binaryReader.ReadSingle()
				};
				miyabiData.Index[miyabiData.Bones[i].Name] = i;
			}
			int num2 = binaryReader.ReadInt32();
			Vector3[] array = (Vector3[])(object)new Vector3[num2];
			Vector3[] array2 = (Vector3[])(object)new Vector3[num2];
			Vector2[] array3 = (Vector2[])(object)new Vector2[num2];
			BoneWeight[] array4 = (BoneWeight[])(object)new BoneWeight[num2];
			for (int j = 0; j < num2; j++)
			{
				array[j] = V(binaryReader);
			}
			for (int k = 0; k < num2; k++)
			{
				array2[k] = V(binaryReader);
			}
			for (int l = 0; l < num2; l++)
			{
				array3[l] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle());
			}
			for (int m = 0; m < num2; m++)
			{
				int boneIndex = binaryReader.ReadInt32();
				int boneIndex2 = binaryReader.ReadInt32();
				int boneIndex3 = binaryReader.ReadInt32();
				int boneIndex4 = binaryReader.ReadInt32();
				int num3 = m;
				BoneWeight val = default(BoneWeight);
				((BoneWeight)(ref val)).boneIndex0 = boneIndex;
				((BoneWeight)(ref val)).boneIndex1 = boneIndex2;
				((BoneWeight)(ref val)).boneIndex2 = boneIndex3;
				((BoneWeight)(ref val)).boneIndex3 = boneIndex4;
				((BoneWeight)(ref val)).weight0 = binaryReader.ReadSingle();
				((BoneWeight)(ref val)).weight1 = binaryReader.ReadSingle();
				((BoneWeight)(ref val)).weight2 = binaryReader.ReadSingle();
				((BoneWeight)(ref val)).weight3 = binaryReader.ReadSingle();
				array4[num3] = val;
			}
			Mesh val2 = new Mesh
			{
				name = "MiyabiBody",
				indexFormat = (IndexFormat)1
			};
			val2.vertices = array;
			val2.normals = array2;
			val2.uv = array3;
			val2.boneWeights = array4;
			int num4 = (val2.subMeshCount = binaryReader.ReadInt32());
			miyabiData.SubmeshTextures = new string[num4];
			for (int n = 0; n < num4; n++)
			{
				miyabiData.SubmeshTextures[n] = S(binaryReader);
				int num6 = binaryReader.ReadInt32();
				int[] array5 = new int[num6];
				for (int num7 = 0; num7 < num6; num7++)
				{
					array5[num7] = binaryReader.ReadInt32();
				}
				val2.SetTriangles(array5, n);
			}
			Matrix4x4[] array6 = (Matrix4x4[])(object)new Matrix4x4[num];
			for (int num8 = 0; num8 < num; num8++)
			{
				array6[num8] = Matrix4x4.Translate(-miyabiData.Bones[num8].Pos);
			}
			val2.bindposes = array6;
			val2.RecalculateBounds();
			val2.RecalculateTangents();
			((Object)val2).hideFlags = (HideFlags)32;
			miyabiData.Body = val2;
			int num9 = binaryReader.ReadInt32();
			for (int num10 = 0; num10 < num9; num10++)
			{
				int key = binaryReader.ReadInt32();
				miyabiData.FingerCurl[key] = new Quaternion(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
			}
			miyabiData.Palm[0] = V(binaryReader);
			miyabiData.Palm[1] = V(binaryReader);
			for (int num11 = 0; num11 < 2; num11++)
			{
				int num12 = binaryReader.ReadInt32();
				Vector3[] array7 = (Vector3[])(object)new Vector3[num12];
				Vector3[] array8 = (Vector3[])(object)new Vector3[num12];
				Vector2[] array9 = (Vector2[])(object)new Vector2[num12];
				for (int num13 = 0; num13 < num12; num13++)
				{
					array7[num13] = V(binaryReader);
				}
				for (int num14 = 0; num14 < num12; num14++)
				{
					array8[num14] = V(binaryReader);
				}
				for (int num15 = 0; num15 < num12; num15++)
				{
					array9[num15] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle());
				}
				int num16 = binaryReader.ReadInt32();
				int[] array10 = new int[num16];
				for (int num17 = 0; num17 < num16; num17++)
				{
					array10[num17] = binaryReader.ReadInt32();
				}
				Mesh val3 = new Mesh
				{
					name = ((num11 == 0) ? "MiyabiKatana" : "MiyabiScabbard")
				};
				val3.vertices = array7;
				val3.normals = array8;
				val3.uv = array9;
				val3.triangles = array10;
				val3.RecalculateBounds();
				val3.RecalculateTangents();
				((Object)val3).hideFlags = (HideFlags)32;
				miyabiData.Guns[num11] = new Gun
				{
					Mesh = val3,
					Muzzle = V(binaryReader)
				};
			}
			int num18 = binaryReader.ReadInt32();
			miyabiData.Particles = new Particle[num18];
			for (int num19 = 0; num19 < num18; num19++)
			{
				Particle particle = new Particle
				{
					Bone = binaryReader.ReadInt32(),
					Tip = V(binaryReader),
					Parent = binaryReader.ReadInt32(),
					Anchor = binaryReader.ReadInt32(),
					Group = binaryReader.ReadInt32()
				};
				particle.Limit = binaryReader.ReadSingle();
				particle.Stiff = binaryReader.ReadSingle();
				particle.Drag = binaryReader.ReadSingle();
				particle.Grav = binaryReader.ReadSingle();
				particle.Radius = binaryReader.ReadSingle();
				miyabiData.Particles[num19] = particle;
			}
			int num20 = binaryReader.ReadInt32();
			miyabiData.Links = new(int, int, float)[num20];
			for (int num21 = 0; num21 < num20; num21++)
			{
				miyabiData.Links[num21] = (a: binaryReader.ReadInt32(), b: binaryReader.ReadInt32(), rest: binaryReader.ReadSingle());
			}
			int num22 = binaryReader.ReadInt32();
			miyabiData.Colliders = new Collider[num22];
			for (int num23 = 0; num23 < num22; num23++)
			{
				miyabiData.Colliders[num23] = new Collider
				{
					Bone = binaryReader.ReadInt32(),
					A = V(binaryReader),
					B = V(binaryReader),
					Radius = binaryReader.ReadSingle()
				};
			}
			return miyabiData;
		}
	}
	internal static class MiyabiAssets
	{
		private static MiyabiData data;

		private static readonly Dictionary<string, Texture2D> textures = new Dictionary<string, Texture2D>();

		internal static bool Failed;

		internal static MiyabiData Data
		{
			get
			{
				if (data != null && !Object.op_Implicit((Object)(object)data.Body))
				{
					data = null;
				}
				if (data == null && !Failed)
				{
					try
					{
						data = MiyabiData.Load(Path.Combine(Plugin.AssetsDir, "miyabi.bin"));
					}
					catch (Exception ex)
					{
						Failed = true;
						Plugin.Log.LogError((object)("Could not load miyabi.bin: " + ex));
					}
				}
				return data;
			}
		}

		internal static Texture2D Texture(string file)
		{
			//IL_001d: 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_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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			if (textures.TryGetValue(file, out var value) && Object.op_Implicit((Object)(object)value))
			{
				return value;
			}
			value = new Texture2D(2, 2, (TextureFormat)4, true)
			{
				name = file,
				wrapMode = (TextureWrapMode)0,
				anisoLevel = 4,
				hideFlags = (HideFlags)32
			};
			try
			{
				ImageConversion.LoadImage(value, File.ReadAllBytes(Path.Combine(Plugin.AssetsDir, file)), true);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Could not load texture " + file + ": " + ex.Message));
			}
			textures[file] = value;
			return value;
		}
	}
	public sealed class MiyabiEyeMark : MonoBehaviour
	{
		private static readonly FieldInfo exposeInstance = AccessTools.Field(typeof(CharacterBody), "mercExposeEffectInstance");

		private static readonly FieldInfo visualState = AccessTools.Field(typeof(TemporaryVisualEffect), "visualState");

		private static FieldRef<CharacterBody, TemporaryVisualEffect> getExpose;

		private static readonly HashSet<int> marked = new HashSet<int>();

		private static Material material;

		private static Texture2D texture;

		private static bool failed;

		private static readonly int TintId = Shader.PropertyToID("_TintColor");

		private TemporaryVisualEffect tve;

		private readonly List<Renderer> hidden = new List<Renderer>();

		private Transform eye;

		private ParticleSystemRenderer eyeRenderer;

		private MaterialPropertyBlock block;

		private float age;

		private float outTime = -1f;

		private const float Size = 1.7f;

		internal static void Install(Harmony h)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			if (exposeInstance == null)
			{
				Plugin.Log.LogWarning((object)"Miyabi eye mark: CharacterBody.mercExposeEffectInstance not found");
				return;
			}
			MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(CharacterBody), "UpdateAllTemporaryVisualEffects", (Type[])null, (Type[])null);
			if (methodInfo == null)
			{
				Plugin.Log.LogWarning((object)"Miyabi eye mark: UpdateAllTemporaryVisualEffects not found");
				return;
			}
			h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(MiyabiEyeMark), "AfterVisuals", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Plugin.Log.LogInfo((object)"Miyabi eye mark hook installed");
		}

		private static void AfterVisuals(CharacterBody __instance)
		{
			try
			{
				if (Plugin.EyeMark.Value && MiyabiFx.Live != 0)
				{
					if (getExpose == null)
					{
						getExpose = AccessTools.FieldRefAccess<CharacterBody, TemporaryVisualEffect>("mercExposeEffectInstance");
					}
					TemporaryVisualEffect val = getExpose.Invoke(__instance);
					if (Object.op_Implicit((Object)(object)val) && !marked.Contains(((Object)val).GetInstanceID()) && Object.op_Implicit((Object)(object)Material()) && !Object.op_Implicit((Object)(object)((Component)val).GetComponent<MiyabiEyeMark>()))
					{
						((Component)val).gameObject.AddComponent<MiyabiEyeMark>();
						marked.Add(((Object)val).GetInstanceID());
					}
				}
			}
			catch (Exception ex)
			{
				if (!failed)
				{
					failed = true;
					Plugin.Log.LogWarning((object)("Miyabi eye mark unavailable: " + ex));
				}
			}
		}

		private static Material Material()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)material))
			{
				return material;
			}
			if (failed)
			{
				return null;
			}
			texture = MiyabiFxAssets.LoadTexture("miyabi_fx_eye.png");
			Material val = Plugin.LoadAsset<Material>("RoR2/Base/Merc/matOmniHitspark2Merc.mat");
			if (!Object.op_Implicit((Object)(object)texture) || !Object.op_Implicit((Object)(object)val))
			{
				failed = true;
				Plugin.Log.LogWarning((object)"Miyabi eye mark: texture or base material missing");
				return null;
			}
			Material m = new Material(val)
			{
				name = "matMiyabiEyeMark",
				hideFlags = (HideFlags)32
			};
			m.mainTexture = (Texture)(object)texture;
			string[] array = new string[7] { "VERTEXCOLOR", "USE_CLOUDS", "CLOUDOFFSET", "VERTEXALPHA", "FADECLOSE", "VERTEXOFFSET", "FRESNEL" };
			foreach (string text in array)
			{
				m.DisableKeyword(text);
			}
			m.EnableKeyword("DISABLEREMAP");
			F("_DisableRemapOn", 1f);
			F("_VertexColorOn", 0f);
			F("_SrcBlend", 5f);
			F("_DstBlend", 10f);
			F("_InternalSimpleBlendMode", 1f);
			F("_Boost", 1f);
			F("_AlphaBoost", 1f);
			F("_AlphaBias", 0f);
			F("_ExternalAlpha", 1f);
			F("_Fade", 1f);
			F("_ZTest", 8f);
			F("_Cull", 0f);
			m.SetColor(TintId, Color.white);
			material = m;
			return m;
			void F(string p, float v)
			{
				if (m.HasProperty(p))
				{
					m.SetFloat(p, v);
				}
			}
		}

		private void Start()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Expected O, but got Unknown
			//IL_01c5: 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_01df: Unknown result type (might be due to invalid IL or missing references)
			tve = ((Component)this).GetComponent<TemporaryVisualEffect>();
			Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (!val.forceRenderingOff)
				{
					val.forceRenderingOff = true;
					hidden.Add(val);
				}
			}
			GameObject val2 = new GameObject("MiyabiEye");
			val2.layer = ((Component)this).gameObject.layer;
			eye = val2.transform;
			Transform val3 = ((Object.op_Implicit((Object)(object)tve) && Object.op_Implicit((Object)(object)tve.visualTransform)) ? tve.visualTransform : ((Component)this).transform);
			eye.SetParent(val3, false);
			ParticleSystem obj = val2.AddComponent<ParticleSystem>();
			obj.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = obj.main;
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).duration = 1f;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(100000f);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(1.7f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.white);
			((MainModule)(ref main)).maxParticles = 1;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0;
			((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0;
			EmissionModule emission = obj.emission;
			((EmissionModule)(ref emission)).enabled = false;
			ShapeModule shape = obj.shape;
			((ShapeModule)(ref shape)).enabled = false;
			eyeRenderer = val2.GetComponent<ParticleSystemRenderer>();
			((Renderer)eyeRenderer).sharedMaterial = material;
			eyeRenderer.renderMode = (ParticleSystemRenderMode)0;
			eyeRenderer.maxParticleSize = 2f;
			((Renderer)eyeRenderer).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)eyeRenderer).receiveShadows = false;
			block = new MaterialPropertyBlock();
			obj.Play(true);
			EmitParams val4 = default(EmitParams);
			((EmitParams)(ref val4)).position = Vector3.zero;
			((EmitParams)(ref val4)).applyShapeToPosition = false;
			obj.Emit(val4, 1);
			Apply(0.35f, 0f);
		}

		private void Apply(float scale, float alpha)
		{
			//IL_0014: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)eye))
			{
				eye.localScale = Vector3.one * scale;
				block.SetColor(TintId, new Color(1f, 1f, 1f, Mathf.Clamp01(alpha)));
				((Renderer)eyeRenderer).SetPropertyBlock(block);
			}
		}

		private void LateUpdate()
		{
			if (!Object.op_Implicit((Object)(object)eye))
			{
				return;
			}
			foreach (Renderer item in hidden)
			{
				if (Object.op_Implicit((Object)(object)item) && !item.forceRenderingOff)
				{
					item.forceRenderingOff = true;
				}
			}
			float deltaTime = Time.deltaTime;
			age += deltaTime;
			bool flag = false;
			try
			{
				flag = Object.op_Implicit((Object)(object)tve) && visualState != null && Convert.ToInt32(visualState.GetValue(tve)) != 0;
			}
			catch
			{
			}
			if (flag && outTime < 0f)
			{
				outTime = 0f;
			}
			if (outTime >= 0f)
			{
				outTime += deltaTime;
				float num = Mathf.Clamp01(outTime / 0.14f);
				Apply(1f + 0.35f * num, 1f - num);
			}
			else
			{
				float scale = ((age < 0.1f) ? Mathf.Lerp(0.35f, 1.15f, Ease(age / 0.1f)) : ((!(age < 0.16f)) ? (1f + 0.03f * Mathf.Sin((age - 0.16f) * (float)Math.PI * 2f * 0.7f)) : Mathf.Lerp(1.15f, 1f, Ease((age - 0.1f) / 0.06f))));
				Apply(scale, Mathf.Clamp01(age / 0.08f));
			}
		}

		private static float Ease(float t)
		{
			t = Mathf.Clamp01(t);
			return 1f - (1f - t) * (1f - t);
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)tve))
			{
				marked.Remove(((Object)tve).GetInstanceID());
			}
			foreach (Renderer item in hidden)
			{
				if (Object.op_Implicit((Object)(object)item))
				{
					item.forceRenderingOff = false;
				}
			}
			if (Object.op_Implicit((Object)(object)eye))
			{
				Object.Destroy((Object)(object)((Component)eye).gameObject);
			}
		}
	}
	internal static class MiyabiFxAssets
	{
		internal static bool Ready;

		internal static Texture2D Ramp;

		internal static Texture2D Flame;

		internal static Texture2D Star;

		internal static Texture2D Streak;

		internal static Texture2D Mote;

		internal static Texture2D Crack;

		internal static Texture2D Ring;

		internal static Texture2D Swipe;

		internal static Material MatFlame;

		internal static Material MatStar;

		internal static Material MatStreak;

		internal static Material MatMote;

		internal static Material MatCrack;

		internal static Material MatRing;

		private static GameObject holder;

		private static readonly Dictionary<GameObject, GameObject> swaps = new Dictionary<GameObject, GameObject>();

		private static readonly Dictionary<GameObject, GameObject> heavy = new Dictionary<GameObject, GameObject>();

		private static readonly Dictionary<GameObject, GameObject> originals = new Dictionary<GameObject, GameObject>();

		private static readonly Dictionary<Material, Material> recolored = new Dictionary<Material, Material>();

		private static readonly HashSet<GameObject> registered = new HashSet<GameObject>();

		private const string Merc = "RoR2/Base/Merc/";

		internal static void Prepare()
		{
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Expected O, but got Unknown
			Ramp = Load("miyabi_fx_ramp.png", clamp: true, mips: false);
			Flame = Load("miyabi_fx_flame.png", clamp: true, mips: true);
			Star = Load("miyabi_fx_star.png", clamp: true, mips: true);
			Streak = Load("miyabi_fx_streak.png", clamp: true, mips: true);
			Mote = Load("miyabi_fx_mote.png", clamp: true, mips: true);
			Crack = Load("miyabi_fx_crack.png", clamp: true, mips: true);
			Ring = Load("miyabi_fx_ring.png", clamp: true, mips: true);
			Swipe = Load("miyabi_fx_swipe.png", clamp: true, mips: true);
			Material val = Plugin.LoadAsset<Material>("RoR2/Base/Merc/matOmniHitspark2Merc.mat");
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)Ramp))
			{
				Plugin.Log.LogWarning((object)"Miyabi frost effects unavailable (base material or textures missing)");
				return;
			}
			MatFlame = Particle(val, "matMiyabiFrostFlame", (Texture)(object)Flame, 1.35f);
			MatStar = Particle(val, "matMiyabiFrostStar", (Texture)(object)Star, 2.6f);
			MatStreak = Particle(val, "matMiyabiFrostStreak", (Texture)(object)Streak, 2.4f);
			MatMote = Particle(val, "matMiyabiFrostMote", (Texture)(object)Mote, 2.2f);
			MatCrack = Particle(val, "matMiyabiFrostCrack", (Texture)(object)Crack, 1.7f);
			MatRing = Particle(val, "matMiyabiFrostRing", (Texture)(object)Ring, 2f);
			holder = new GameObject("MiyabiFxPrefabs");
			holder.SetActive(false);
			((Object)holder).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)holder);
			string[] array = new string[4] { "MercSwordSlash", "MercSwordFinisherSlash", "MercSwordSlashWhirlwind", "MercSwordUppercutSlash" };
			foreach (string n in array)
			{
				Copy(n, delegate(GameObject src, GameObject c)
				{
					FrostSwing(c, (n == "MercSwordFinisherSlash") ? 3f : 2.6f);
				});
			}
			Copy("MercAssaulterEffect", delegate(GameObject src, GameObject c)
			{
				Recolor(c);
			});
			Copy("OmniImpactVFXSlashMercEvis", delegate(GameObject src, GameObject c)
			{
				Recolor(c);
				HitExtras(c, big: true);
			});
			array = new string[3] { "OmniImpactVFXSlashMerc", "ImpactMercAssaulter", "ImpactMercFocusedAssault" };
			foreach (string n2 in array)
			{
				Copy(n2, delegate(GameObject src, GameObject c)
				{
					Recolor(c);
					HitExtras(c, n2 != "OmniImpactVFXSlashMerc");
				});
			}
			GameObject val2 = Plugin.LoadAsset<GameObject>("RoR2/Base/Merc/OmniImpactVFXSlashMerc.prefab");
			if (Object.op_Implicit((Object)(object)val2))
			{
				GameObject val3 = Make(val2, "OmniImpactVFXSlashMercHeavyMiyabi", delegate(GameObject x)
				{
					Recolor(x);
					HitExtras(x, big: true);
				});
				if (Object.op_Implicit((Object)(object)val3))
				{
					heavy[val2] = val3;
				}
			}
			Ready = swaps.Count > 0;
			Plugin.Log.LogInfo((object)$"Miyabi frost effects prepared: {swaps.Count} effect copies ({registered.Count} registered), {recolored.Count} recolored materials");
		}

		internal static Texture2D LoadTexture(string file)
		{
			return Load(file, clamp: true, mips: true);
		}

		private static Texture2D Load(string file, bool clamp, bool mips)
		{
			//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_003b: 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_0050: Expected O, but got Unknown
			//IL_0051: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			string path = Path.Combine(Plugin.AssetsDir, file);
			if (!File.Exists(path))
			{
				Plugin.Log.LogWarning((object)("Missing " + file));
				return null;
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, mips)
			{
				name = file,
				hideFlags = (HideFlags)32
			};
			ImageConversion.LoadImage(val, File.ReadAllBytes(path), false);
			((Texture)val).wrapMode = (TextureWrapMode)(clamp ? 1 : 0);
			((Texture)val).filterMode = (FilterMode)1;
			val.Apply(mips, true);
			return val;
		}

		private static void Set(Material m, string p, float v)
		{
			if (m.HasProperty(p))
			{
				m.SetFloat(p, v);
			}
		}

		private static Material Particle(Material source, string name, Texture main, float boost)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(source)
			{
				name = name,
				hideFlags = (HideFlags)32
			};
			val.mainTexture = main;
			val.SetTexture("_RemapTex", (Texture)(object)Ramp);
			val.SetColor("_TintColor", Color.white);
			val.EnableKeyword("VERTEXCOLOR");
			Set(val, "_VertexColorOn", 1f);
			string[] array = new string[7] { "USE_CLOUDS", "CLOUDOFFSET", "VERTEXALPHA", "DISABLEREMAP", "FADECLOSE", "VERTEXOFFSET", "FRESNEL" };
			foreach (string text in array)
			{
				val.DisableKeyword(text);
			}
			Set(val, "_SrcBlend", 1f);
			Set(val, "_DstBlend", 1f);
			Set(val, "_InternalSimpleBlendMode", 0f);
			Set(val, "_Boost", boost);
			Set(val, "_AlphaBoost", 1f);
			Set(val, "_AlphaBias", 0f);
			Set(val, "_ExternalAlpha", 1f);
			Set(val, "_Fade", 1f);
			Set(val, "_Cull", 0f);
			Set(val, "_ZTest", 4f);
			return val;
		}

		private static void Copy(string name, Action<GameObject, GameObject> edit)
		{
			GameObject src = Plugin.LoadAsset<GameObject>("RoR2/Base/Merc/" + name + ".prefab");
			if (Object.op_Implicit((Object)(object)src))
			{
				GameObject val = Make(src, name + "Miyabi", delegate(GameObject x)
				{
					edit(src, x);
				});
				if (Object.op_Implicit((Object)(object)val))
				{
					swaps[src] = val;
				}
			}
		}

		private static GameObject Make(GameObject src, string name, Action<GameObject> edit)
		{
			try
			{
				GameObject val = Object.Instantiate<GameObject>(src, holder.transform);
				((Object)val).name = name;
				edit(val);
				originals[val] = src;
				if (Object.op_Implicit((Object)(object)val.GetComponent<EffectComponent>()))
				{
					if (ContentAddition.AddEffect(val))
					{
						registered.Add(val);
					}
					else
					{
						Plugin.Log.LogWarning((object)("Miyabi effect not registered: " + name));
					}
				}
				return val;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Miyabi effect copy failed: " + name + " " + ex));
				return null;
			}
		}

		internal static GameObject Swap(GameObject original, bool heavyHit = false)
		{
			if (!Ready || !Object.op_Implicit((Object)(object)original))
			{
				return original;
			}
			if (originals.TryGetValue(original, out var value))
			{
				original = value;
			}
			if (heavyHit && heavy.TryGetValue(original, out var value2) && Object.op_Implicit((Object)(object)value2) && registered.Contains(value2))
			{
				return value2;
			}
			if (swaps.TryGetValue(original, out var value3) && Object.op_Implicit((Object)(object)value3))
			{
				if (Object.op_Implicit((Object)(object)value3.GetComponent<EffectComponent>()) && !registered.Contains(value3))
				{
					return original;
				}
				return value3;
			}
			return original;
		}

		internal static GameObject Original(GameObject maybeCopy)
		{
			if (!Object.op_Implicit((Object)(object)maybeCopy) || !originals.TryGetValue(maybeCopy, out var value))
			{
				return maybeCopy;
			}
			return value;
		}

		private static bool IsRemap(Material m)
		{
			if (Object.op_Implicit((Object)(object)m) && Object.op_Implicit((Object)(object)m.shader) && ((Object)m.shader).name.IndexOf("Cloud Remap", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return m.HasProperty("_RemapTex");
			}
			return false;
		}

		private static Material RecolorMaterial(Material m)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (!IsRemap(m))
			{
				return m;
			}
			if (recolored.TryGetValue(m, out var value))
			{
				return value;
			}
			value = new Material(m)
			{
				name = ((Object)m).name + "_MiyabiFrost",
				hideFlags = (HideFlags)32
			};
			value.SetTexture("_RemapTex", (Texture)(object)Ramp);
			Color color = value.GetColor("_TintColor");
			value.SetColor("_TintColor", new Color(1f, 1f, 1f, color.a));
			recolored[m] = value;
			return value;
		}

		internal static void RecolorInstance(GameObject root)
		{
			if (Ready)
			{
				Recolor(root);
			}
		}

		private static void Recolor(GameObject root)
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				Material[] sharedMaterials = val.sharedMaterials;
				bool flag = false;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					Material val2 = RecolorMaterial(sharedMaterials[j]);
					if ((Object)(object)val2 != (Object)(object)sharedMaterials[j])
					{
						sharedMaterials[j] = val2;
						flag = true;
					}
				}
				if (flag)
				{
					val.sharedMaterials = sharedMaterials;
				}
				ParticleSystemRenderer val3 = (ParticleSystemRenderer)(object)((val is ParticleSystemRenderer) ? val : null);
				if (val3 != null && Object.op_Implicit((Object)(object)val3.trailMaterial))
				{
					val3.trailMaterial = RecolorMaterial(val3.trailMaterial);
				}
			}
			ParticleSystem[] componentsInChildren2 = root.GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem obj in componentsInChildren2)
			{
				MainModule main = obj.main;
				((MainModule)(ref main)).startColor = Ice(((MainModule)(ref main)).startColor);
				ColorOverLifetimeModule colorOverLifetime = obj.colorOverLifetime;
				if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled)
				{
					((ColorOverLifetimeModule)(ref colorOverLifetime)).color = Ice(((ColorOverLifetimeModule)(ref colorOverLifetime)).color);
				}
			}
			TrailRenderer[] componentsInChildren3 = root.GetComponentsInChildren<TrailRenderer>(true);
			foreach (TrailRenderer obj2 in componentsInChildren3)
			{
				obj2.colorGradient = Ice(obj2.colorGradient);
			}
			LineRenderer[] componentsInChildren4 = root.GetComponentsInChildren<LineRenderer>(true);
			foreach (LineRenderer obj3 in componentsInChildren4)
			{
				obj3.colorGradient = Ice(obj3.colorGradient);
			}
			Light[] componentsInChildren5 = root.GetComponentsInChildren<Light>(true);
			foreach (Light val4 in componentsInChildren5)
			{
				((Behaviour)val4).enabled = false;
				val4.intensity = 0f;
				val4.range = 0f;
				if ((Object)(object)((Component)val4).transform != (Object)(object)root.transform)
				{
					((Component)val4).gameObject.SetActive(false);
				}
			}
		}

		private static Color Ice(Color c)
		{
			//IL_000f: 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)
			return new Color(1f, 1f, 1f, c.a);
		}

		private static Gradient Ice(Gradient g)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004a: Expected O, but got Unknown
			if (g == null)
			{
				return g;
			}
			GradientColorKey[] colorKeys = g.colorKeys;
			for (int i = 0; i < colorKeys.Length; i++)
			{
				colorKeys[i].color = Color.white;
			}
			Gradient val = new Gradient
			{
				mode = g.mode
			};
			val.SetKeys(colorKeys, g.alphaKeys);
			return val;
		}

		private static MinMaxGradient Ice(MinMaxGradient g)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected I4, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007e: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystemGradientMode mode = ((MinMaxGradient)(ref g)).mode;
			switch ((int)mode)
			{
			case 0:
				return new MinMaxGradient(Ice(((MinMaxGradient)(ref g)).color));
			case 2:
				return new MinMaxGradient(Ice(((MinMaxGradient)(ref g)).colorMin), Ice(((MinMaxGradient)(ref g)).colorMax));
			case 1:
				return new MinMaxGradient(Ice(((MinMaxGradient)(ref g)).gradient));
			case 3:
				return new MinMaxGradient(Ice(((MinMaxGradient)(ref g)).gradientMin), Ice(((MinMaxGradient)(ref g)).gradientMax));
			case 4:
			{
				MinMaxGradient result = default(MinMaxGradient);
				((MinMaxGradient)(ref result))..ctor(Ice(((MinMaxGradient)(ref g)).gradient));
				((MinMaxGradient)(ref result)).mode = (ParticleSystemGradientMode)4;
				return result;
			}
			default:
				return g;
			}
		}

		private static void FrostSwing(GameObject root, float boost)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystemRenderer[] componentsInChildren = root.GetComponentsInChildren<ParticleSystemRenderer>(true);
			foreach (ParticleSystemRenderer val in componentsInChildren)
			{
				Material[] sharedMaterials = ((Renderer)val).sharedMaterials;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					Material val2 = sharedMaterials[j];
					if (IsRemap(val2) && ((Object)val2).name.StartsWith("matMercSwipe", StringComparison.Ordinal))
					{
						bool flag = Object.op_Implicit((Object)(object)val.mesh) && ((Object)val.mesh).name == "MercSwordSwipe1Mesh" && Object.op_Implicit((Object)(object)Swipe);
						Material val3 = new Material(val2)
						{
							name = ((Object)val2).name + (flag ? "_MiyabiCrescent" : "_MiyabiFrost"),
							hideFlags = (HideFlags)32
						};
						val3.SetTexture("_RemapTex", (Texture)(object)Ramp);
						val3.SetColor("_TintColor", Color.white);
						Set(val3, "_Boost", boost);
						Set(val3, "_AlphaBias", 0f);
						if (flag)
						{
							val3.mainTexture = (Texture)(object)Swipe;
							Set(val3, "_AlphaBoost", 1.25f);
							Set(val3, "_DistortionStrength", 0.1f);
						}
						else
						{
							Set(val3, "_AlphaBoost", 2.6f);
							Set(val3, "_DistortionStrength", 0.3f);
						}
						sharedMaterials[j] = val3;
					}
				}
				((Renderer)val).sharedMaterials = sharedMaterials;
			}
			Recolor(root);
		}

		private static void HitExtras(GameObject root, bool big)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: 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)
			float num = (big ? 1f : 0.62f);
			Shrink(Burst(root.transform, "MiyabiHitStar", MatStar, 1, 0.16f, 0.22f, 1.5f * num + 0.6f, 0f), AnimationCurve.EaseInOut(0f, 0.5f, 1f, 0f), 0.15f);
			ParticleSystem obj = Burst(root.transform, "MiyabiHitStreaks", MatStreak, (!big) ? 1 : 3, 0.14f, 0.22f, 1f, 0f);
			MainModule main = obj.main;
			((MainModule)(ref main)).startSize3D = true;
			((MainModule)(ref main)).startSizeX = new MinMaxCurve(big ? 5.5f : 3.2f, big ? 8f : 4.2f);
			((MainModule)(ref main)).startSizeY = new MinMaxCurve(big ? 0.16f : 0.1f, big ? 0.22f : 0.13f);
			((MainModule)(ref main)).startSizeZ = MinMaxCurve.op_Implicit(1f);
			((MainModule)(ref main)).startRotation = new MinMaxCurve(-0.7f, 0.7f);
			Shrink(obj, AnimationCurve.Linear(0f, 1f, 1f, 0.6f), 0f);
			ParticleSystem obj2 = Burst(root.transform, "MiyabiHitFlames", MatFlame, big ? 7 : 4, 0.24f, 0.36f, 0f, 0f);
			MainModule main2 = obj2.main;
			((MainModule)(ref main2)).startSize = new MinMaxCurve(0.2f * num + 0.08f, 0.34f * num + 0.1f);
			((MainModule)(ref main2)).startSpeed = new MinMaxCurve(0.4f, 1.6f);
			((MainModule)(ref main2)).gravityModifier = MinMaxCurve.op_Implicit(-0.35f);
			ShapeModule shape = obj2.shape;
			((ShapeModule)(ref shape)).enabled = true;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = 0.45f * num + 0.15f;
			FlameSheet(obj2);
			ParticleSystem obj3 = Burst(root.transform, "MiyabiHitMotes", MatMote, big ? 16 : 8, 0.3f, 0.6f, 0f, 0f);
			MainModule main3 = obj3.main;
			((MainModule)(ref main3)).startSize = new MinMaxCurve(0.06f, 0.14f);
			((MainModule)(ref main3)).startSpeed = new MinMaxCurve(3f, 8f * num + 1f);
			((MainModule)(ref main3)).gravityModifier = MinMaxCurve.op_Implicit(0.25f);
			ShapeModule shape2 = obj3.shape;
			((ShapeModule)(ref shape2)).enabled = true;
			((ShapeModule)(ref shape2)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape2)).radius = 0.2f;
			LimitVelocityOverLifetimeModule limitVelocityOverLifetime = obj3.limitVelocityOverLifetime;
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).enabled = true;
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).limit = MinMaxCurve.op_Implicit(1.5f);
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).dampen = 0.15f;
			if (big)
			{
				ParticleSystem val = Burst(root.transform, "MiyabiHitCrack", MatCrack, 1, 0.9f, 0.9f, 3f, 0f);
				((Component)val).GetComponent<ParticleSystemRenderer>().renderMode = (ParticleSystemRenderMode)2;
				MainModule main4 = val.main;
				((MainModule)(ref main4)).playOnAwake = false;
				((MainModule)(ref main4)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
				Shrink(val, AnimationCurve.EaseInOut(0f, 0.55f, 0.25f, 1f), 0f);
				FadeLate(val);
				root.AddComponent<MiyabiGroundCrack>().crack = val;
			}
		}

		internal static ParticleSystem Burst(Transform parent, string name, Material mat, int count, float lifeMin, float lifeMax, float size, float speed)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			val2.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = val2.main;
			((MainModule)(ref main)).duration = 1f;
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).playOnAwake = true;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(lifeMin, lifeMax);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(size);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(speed);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.white);
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0;
			((MainModule)(ref main)).maxParticles = Math.Max(4, count * 2);
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).enabled = true;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
			((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1]
			{
				new Burst(0f, (short)count)
			});
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).enabled = false;
			Fade(val2);
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			((Renderer)component).sharedMaterial = mat;
			component.renderMode = (ParticleSystemRenderMode)0;
			component.maxParticleSize = 4f;
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component).receiveShadows = false;
			return val2;
		}

		internal static void Fade(ParticleSystem ps)
		{
			//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_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_001e: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val = new Gradient();
			val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(Color.white, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(0.85f, 0.45f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val);
		}

		private static void FadeLate(ParticleSystem ps)
		{
			//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_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_001e: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val = new Gradient();
			val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(Color.white, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(0.9f, 0.6f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val);
		}

		internal static void Shrink(ParticleSystem ps, AnimationCurve curve, float unused)
		{
			//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_0017: Unknown result type (might be due to invalid IL or missing references)
			SizeOverLifetimeModule sizeOverLifetime = ps.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, curve);
		}

		internal static void FlameSheet(ParticleSystem ps)
		{
			//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_004f: Unknown result type (might be due to invalid IL or missing references)
			TextureSheetAnimationModule textureSheetAnimation = ps.textureSheetAnimation;
			((TextureSheetAnimationModule)(ref textureSheetAnimation)).enabled = true;
			((TextureSheetAnimationModule)(ref textureSheetAnimation)).mode = (ParticleSystemAnimationMode)0;
			((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesX = 4;
			((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesY = 2;
			((TextureSheetAnimationModule)(ref textureSheetAnimation)).animation = (ParticleSystemAnimationType)0;
			((TextureSheetAnimationModule)(ref textureSheetAnimation)).frameOverTime = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0f, 1f, 1f));
			((TextureSheetAnimationModule)(ref textureSheetAnimation)).cycleCount = 1;
		}
	}
	public sealed class MiyabiGroundCrack : MonoBehaviour
	{
		public ParticleSystem crack;

		private void OnEnable()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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 (Object.op_Implicit((Object)(object)crack))
			{
				crack.Stop(true, (ParticleSystemStopBehavior)0);
				Vector3 val = ((Component)this).transform.position + Vector3.up * 0.5f;
				Vector3 down = Vector3.down;
				LayerIndex world = LayerIndex.world;
				RaycastHit val2 = default(RaycastHit);
				if (Physics.Raycast(val, down, ref val2, 5f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1))
				{
					((Component)crack).transform.position = ((RaycastHit)(ref val2)).point + ((RaycastHit)(ref val2)).normal * 0.04f;
					crack.Play(true);
				}
			}
		}
	}
	[DefaultExecutionOrder(10001)]
	public sealed class MiyabiFx : MonoBehaviour
	{
		internal enum Swing
		{
			Light,
			Finisher,
			Whirlwind,
			Uppercut
		}

		internal static int Live;

		private MiyabiModel owner;

		private ParticleSystem flames;

		private ParticleSystem motes;

		private ParticleSystem stars;

		private ParticleSystem streaks;

		private ParticleSystem rings;

		private Vector3 lastBase;

		private Vector3 lastTip;

		private bool haveBlade;

		private float swingTime;

		private float dashTime;

		private Vector3 dashDir;

		private float carry;

		private static readonly Vector3 BladeBase = new Vector3(0f, 2.6f, 0.45f);

		private static readonly Vector3 BladeTip = new Vector3(0f, 11f, 0.45f);

		private Transform[] bodyPoints = (Transform[])(object)new Transform[0];

		private Vector3 evisCentre;

		private float evisTime;

		private bool Shown
		{
			get
			{
				if (Object.op_Implicit((Object)(object)owner) && owner.IsActive && owner.IsVisible)
				{
					return Plugin.FrostVfx.Value;
				}
				return false;
			}
		}

		private bool Running
		{
			get
			{
				if (Object.op_Implicit((Object)(object)owner) && owner.IsActive)
				{
					return Plugin.FrostVfx.Value;
				}
				return false;
			}
		}

		private void OnEnable()
		{
			Live++;
		}

		private void OnDisable()
		{
			Live = Math.Max(0, Live - 1);
		}

		internal static MiyabiFx Create(MiyabiModel model, Transform parent, Transform[] body)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (!MiyabiFxAssets.Ready)
			{
				return null;
			}
			GameObject val = new GameObject("MiyabiFx")
			{
				layer = ((Component)parent).gameObject.layer
			};
			val.transform.SetParent(parent, false);
			MiyabiFx miyabiFx = val.AddComponent<MiyabiFx>();
			miyabiFx.owner = model;
			miyabiFx.bodyPoints = Array.FindAll(body, (Transform t) => Object.op_Implicit((Object)(object)t));
			miyabiFx.Build();
			return miyabiFx;
		}

		private ParticleSystem Emitter(string name, Material mat, int max, ParticleSystemRenderMode mode = (ParticleSystemRenderMode)0)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//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)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.layer = ((Component)this).gameObject.layer;
			val.transform.SetParent(((Component)this).transform, false);
			ParticleSystem obj = val.AddComponent<ParticleSystem>();
			obj.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = obj.main;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).playOnAwake = true;
			((MainModule)(ref main)).duration = 1f;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)2;
			((MainModule)(ref main)).maxParticles = max;
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.white);
			EmissionModule emission = obj.emission;
			((EmissionModule)(ref emission)).enabled = false;
			ShapeModule shape = obj.shape;
			((ShapeModule)(ref shape)).enabled = false;
			MiyabiFxAssets.Fade(obj);
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			((Renderer)component).sharedMaterial = mat;
			component.renderMode = mode;
			component.maxParticleSize = 4f;
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component).receiveShadows = false;
			obj.Play(true);
			return obj;
		}

		private void Build()
		{
			//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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			flames = Emitter("FrostFlames", MiyabiFxAssets.MatFlame, 500, (ParticleSystemRenderMode)0);
			MiyabiFxAssets.FlameSheet(flames);
			MainModule main = flames.main;
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.3f);
			motes = Emitter("FrostMotes", MiyabiFxAssets.MatMote, 300, (ParticleSystemRenderMode)0);
			MainModule main2 = motes.main;
			((MainModule)(ref main2)).gravityModifier = MinMaxCurve.op_Implicit(0.2f);
			LimitVelocityOverLifetimeModule limitVelocityOverLifetime = motes.limitVelocityOverLifetime;
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).enabled = true;
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).limit = MinMaxCurve.op_Implicit(1.2f);
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).dampen = 0.12f;
			stars = Emitter("FrostStars", MiyabiFxAssets.MatStar, 16, (ParticleSystemRenderMode)0);
			MiyabiFxAssets.Shrink(stars, AnimationCurve.EaseInOut(0f, 0.6f, 1f, 0f), 0f);
			streaks = Emitter("FrostFlares", MiyabiFxAssets.MatStreak, 16, (ParticleSystemRenderMode)0);
			MainModule main3 = streaks.main;
			((MainModule)(ref main3)).startSize3D = true;
			MiyabiFxAssets.Shrink(streaks, AnimationCurve.Linear(0f, 1f, 1f, 0.7f), 0f);
			rings = Emitter("FrostRings", MiyabiFxAssets.MatRing, 8, (ParticleSystemRenderMode)2);
			MiyabiFxAssets.Shrink(rings, AnimationCurve.EaseInOut(0f, 0.25f, 1f, 1f), 0f);
		}

		internal void OnSwing(Swing kind)
		{
			//IL_0034: 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_0057: 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_0065: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			if (!Shown)
			{
				return;
			}
			swingTime = kind switch
			{
				Swing.Light => 0.3f, 
				Swing.Finisher => 0.42f, 
				_ => 0.38f, 
			};
			Vector3 position = ((Component)owner).transform.position;
			switch (kind)
			{
			case Swing.Finisher:
				BladeBurst(6);
				break;
			case Swing.Whirlwind:
			{
				if (Ground(position, out var p2))
				{
					Ring(p2, 4.2f);
					FlameCircle(p2, 1.3f, 10);
				}
				break;
			}
			case Swing.Uppercut:
			{
				if (Ground(position, out var p))
				{
					Ring(p, 3f);
				}
				for (int i = 0; i < 10; i++)
				{
					Flame(position + Flat(Random.insideUnitCircle * 0.6f) + Vector3.up * Random.Range(0f, 0.6f), Vector3.up * Random.Range(4f, 8f), Random.Range(0.24f, 0.4f), Random.Range(0.28f, 0.42f));
				}
				break;
			}
			}
		}

		internal void OnDashStart(Vector3 dir)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_005d: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if (Shown)
			{
				dashDir = ((((Vector3)(ref dir)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref dir)).normalized : ((Component)owner).transform.forward);
				dashTime = 0.6f;
				Flare(Chest(), 1f);
				if (Ground(((Component)owner).transform.position, out var p))
				{
					Ring(p, 3.6f);
				}
				for (int i = 0; i < 18; i++)
				{
					Mote(Chest(), Random.onUnitSphere * Random.Range(3f, 8f));
				}
			}
		}

		internal void OnEvisStart()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_004b: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (Running)
			{
				evisCentre = Chest();
				evisTime = 1.1f;
				Flare(evisCentre, 1.1f);
				if (Ground(((Component)owner).transform.position, out var p))
				{
					Ring(p, 6f);
					FlameCircle(p, 2.2f, 14);
				}
				for (int i = 0; i < 24; i++)
				{
					Mote(evisCentre, Random.onUnitSphere * Random.Range(4f, 9f));
				}
			}
		}

		internal void OnEvisEnd()
		{
			//IL_0016: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			evisTime = 0f;
			if (Running)
			{
				Flare(Chest(), 0.9f);
				if (Ground(((Component)owner).transform.position, out var p))
				{
					Ring(p, 4f);
				}
				for (int i = 0; i < 10; i++)
				{
					BodyFlame(1.6f);
				}
			}
		}

		internal void OnThrow()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (Shown)
			{
				swingTime = 0.35f;
				BladeBurst(8);
				Transform katanaTransform = owner.KatanaTransform;
				if (Object.op_Implicit((Object)(object)katanaTransform))
				{
					Flare(katanaTransform.TransformPoint(BladeTip), 0.55f);
				}
			}
		}

		internal void OnDashEnd()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!Shown)
			{
				dashTime = 0f;
				return;
			}
			dashTime = 0f;
			Flare(Chest(), 0.65f);
			for (int i = 0; i < 6; i++)
			{
				BodyFlame(1.4f);
			}
		}

		private void LateUpdate()
		{
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_03b8: 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_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: 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_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: 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_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			if (evisTime > 0f && Running)
			{
				evisTime -= Time.deltaTime;
				for (int i = 0; i < 3; i++)
				{
					Vector2 val = Random.insideUnitCircle * 2.6f;
					Vector3 p = evisCentre + new Vector3(val.x, Random.Range(-0.6f, 1f), val.y);
					Flame(p, new Vector3(0f - val.y, 0f, val.x) * 1.4f + Vector3.up * Random.Range(0.4f, 1.4f), Random.Range(0.2f, 0.36f), Random.Range(0.25f, 0.4f));
				}
				if (Random.value < 0.5f)
				{
					Mote(evisCentre + Random.insideUnitSphere * 2f, Random.onUnitSphere * 4f);
				}
				if (Random.value < 0.08f)
				{
					EmitParams val2 = default(EmitParams);
					((EmitParams)(ref val2)).position = evisCentre + Random.insideUnitSphere * 1.5f;
					((EmitParams)(ref val2)).startSize3D = new Vector3(Random.Range(4f, 7f), 0.14f, 1f);
					((EmitParams)(ref val2)).startLifetime = 0.16f;
					((EmitParams)(ref val2)).startColor = Color32.op_Implicit(Color.white);
					((EmitParams)(ref val2)).rotation = Random.Range(-60f, 60f);
					((EmitParams)(ref val2)).applyShapeToPosition = false;
					EmitParams val3 = val2;
					streaks.Emit(val3, 1);
				}
			}
			if (!Shown)
			{
				haveBlade = false;
				swingTime = (dashTime = 0f);
				return;
			}
			float deltaTime = Time.deltaTime;
			Transform katanaTransform = owner.KatanaTransform;
			if (Object.op_Implicit((Object)(object)katanaTransform))
			{
				Vector3 val4 = katanaTransform.TransformPoint(BladeBase);
				Vector3 val5 = katanaTransform.TransformPoint(BladeTip);
				if (haveBlade && swingTime > 0f)
				{
					Vector3 val6 = val5 - lastTip;
					float magnitude = ((Vector3)(ref val6)).magnitude;
					carry += magnitude / 0.32f;
					int num = Mathf.Min(5, (int)carry);
					carry -= num;
					Vector3 val7 = ((deltaTime > 0.0001f) ? ((val5 - lastTip) / deltaTime) : Vector3.zero);
					for (int j = 0; j < num; j++)
					{
						float num2 = ((float)j + Random.value) / (float)Mathf.Max(1, num);
						float num3 = Mathf.Sqrt(Random.Range(0.08f, 1f));
						Vector3 p2 = Vector3.Lerp(Vector3.Lerp(lastBase, lastTip, num3), Vector3.Lerp(val4, val5, num3), num2);
						Flame(p2, val7 * 0.04f + Vector3.up * Random.Range(0.5f, 1.4f), Random.Range(0.16f, 0.3f) * (0.6f + 0.5f * num3), Random.Range(0.2f, 0.32f));
						if (Random.value < 0.25f)
						{
							Mote(p2, val7 * 0.08f + Random.onUnitSphere * 1.5f);
						}
					}
				}
				else
				{
					carry = 0f;
				}
				lastBase = val4;
				lastTip = val5;
				haveBlade = true;
			}
			if (dashTime > 0f)
			{
				for (int k = 0; k < 2; k++)
				{
					BodyFlame(1f);
				}
				if (Random.value < 0.6f)
				{
					Mote(Chest() + Random.insideUnitSphere * 0.4f, -dashDir * Random.Range(2f, 5f) + Random.onUnitSphere);
				}
			}
			swingTime -= deltaTime;
			dashTime -= deltaTime;
		}

		internal void Wisp(Vector3 p, Vector3 v)
		{
			//IL_000a: 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)
			if (Shown)
			{
				Flame(p, v, Random.Range(0.12f, 0.22f), Random.Range(0.28f, 0.4f));
			}
		}

		private void Flame(Vector3 p, Vector3 v, float size, float life)
		{
			//IL_0002: 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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			EmitParams val = default(EmitParams);
			((EmitParams)(ref val)).position = p;
			((EmitParams)(ref val)).velocity = v;
			((EmitParams)(ref val)).startSize = size;
			((EmitParams)(ref val)).startLifetime = life;
			((EmitParams)(ref val)).startColor = Color32.op_Implicit(Color.white);
			((EmitParams)(ref val)).rotation = Random.Range(-25f, 25f);
			((EmitParams)(ref val)).applyShapeToPosition = false;
			EmitParams val2 = val;
			flames.Emit(val2, 1);
		}

		private void Mote(Vector3 p, Vector3 v)
		{
			//IL_0002: 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_0012: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			EmitParams val = default(EmitParams);
			((EmitParams)(ref val)).position = p;
			((EmitParams)(ref val)).velocity = v;
			((EmitParams)(ref val)).startSize = Random.Range(0.05f, 0.12f);
			((EmitParams)(ref val)).startLifetime = Random.Range(0.3f, 0.65f);
			((EmitParams)(ref val)).startColor = Color32.op_Implicit(Color.white);
			((EmitParams)(ref val)).applyShapeToPosition = false;
			EmitParams val2 = val;
			motes.Emit(val2, 1);
		}

		private void BodyFlame(float strength)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			if (bodyPoints.Length != 0)
			{
				Transform obj = bodyPoints[Random.Range(0, bodyPoints.Length)];
				Transform val = bodyPoints[Random.Range(0, bodyPoints.Length)];
				Vector3 p = Vector3.Lerp(obj.position, val.position, Random.value) + Random.insideUnitSphere * 0.15f;
				Flame(p, -dashDir * Random.Range(1.5f, 4f) * strength + Vector3.up * Random.Range(0.3f, 1.2f), Random.Range(0.18f, 0.34f), Random.Range(0.22f, 0.36f));
			}
		}

		private void BladeBurst(int n)
		{
			//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_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_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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			Transform katanaTransform = owner.KatanaTransform;
			if (Object.op_Implicit((Object)(object)katanaTransform))
			{
				for (int i = 0; i < n; i++)
				{
					Vector3 p = Vector3.Lerp(katanaTransform.TransformPoint(BladeBase), katanaTransform.TransformPoint(BladeTip), Random.Range(0.2f, 1f));
					Flame(p, Random.onUnitSphere * 0.8f + Vector3.up * 1.2f, Random.Range(0.22f, 0.38f), Random.Range(0.25f, 0.38f));
				}
			}
		}

		private void FlameCircle(Vector3 c, float radius, int n)
		{
			//IL_003e: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Vector3 val = default(Vector3);
			for (int i = 0; i < n; i++)
			{
				float num = ((float)i + Random.value * 0.5f) / (float)n * (float)Math.PI * 2f;
				((Vector3)(ref val))..ctor(Mathf.Cos(num), 0f, Mathf.Sin(num));
				Flame(c + val * radius + Vector3.up * 0.15f, val * 1.5f + Vector3.up * Random.Range(1f, 2.2f), Random.Range(0.25f, 0.42f), Random.Range(0.28f, 0.4f));
			}
		}

		private void Ring(Vector3 p, float size)
		{
			//IL_0002: 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_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_001a: 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 re