Decompiled source of Young Sasuke v0.12.10

plugins/YoungSasuke/HenryMod.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Json;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.AI.Walker;
using EntityStates.Commando;
using EntityStates.Commando.CommandoWeapon;
using HG;
using HG.BlendableTypes;
using HenryMod.Modules;
using HenryMod.Modules.Achievements;
using HenryMod.Modules.BaseStates;
using HenryMod.Modules.Characters;
using HenryMod.Survivors.Henry;
using HenryMod.Survivors.Henry.SkillStates;
using KinematicCharacterController;
using MonoMod.RuntimeDetour;
using On.RoR2;
using On.RoR2.UI;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.Achievements;
using RoR2.Audio;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Networking;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.SurvivorMannequins;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;
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("HenryMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0bf7923822291a1fa263d37ffa9f96e346038493")]
[assembly: AssemblyProduct("HenryMod")]
[assembly: AssemblyTitle("HenryMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace HenryMod
{
	public sealed class CML2Melee : BaseSkillState
	{
		public int step;

		public bool chained;

		private OneClick click;

		private float speed;

		private float contact;

		private float chain;

		private float duration;

		private bool queued;

		private bool swingPlayed;

		private bool contactPlayed;

		private SasukeVisual visual;

		private readonly HashSet<HealthComponent> victims = new HashSet<HealthComponent>();

		private string Clip => "CML2_Primary" + (step + 1);

		private string Limb
		{
			get
			{
				if (step != 1)
				{
					if (step != 2)
					{
						if (step != 3)
						{
							return "hand.R";
						}
						return "storm_00t0_r_whand";
					}
					return "storm_00t0_l_whand";
				}
				return "foot.R";
			}
		}

		public static float Coefficient(int step)
		{
			return (SasukeTuning.Punch.Value + SasukeTuning.Kick.Value + SasukeTuning.Heel.Value) / 1.4f * 2.2f * CML2Tuning.PrimaryDps.Value * (new float[4] { 5f, 6f, 6.5f, 10f })[Mathf.Clamp(step, 0, 3)] / 27.5f;
		}

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			click = new OneClick(chained);
			speed = Mathf.Max(0.1f, ((BaseState)this).attackSpeedStat);
			chain = (new float[4] { 13f, 14f, 14f, 25f })[step] / 30f / speed;
			duration = ((step == 3) ? 25f : (new float[3] { 19f, 20f, 20f })[step]) / 30f / speed;
			contact = (new float[4] { 5f, 7f, 7f, 10f })[step] / 30f / speed;
			visual = SasukeVisual.Find(((EntityState)this).characterBody);
			if (Object.op_Implicit((Object)(object)visual))
			{
				visual.Play(Clip, speed, duration, restart: true);
			}
			((EntityState)this).characterBody.SetAimTimer(duration + 1f);
		}

		public override void FixedUpdate()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			((EntityState)this).FixedUpdate();
			if (!CML2Controller.Active(((EntityState)this).characterBody))
			{
				if (((EntityState)this).isAuthority)
				{
					((EntityState)this).outer.SetNextStateToMain();
				}
				return;
			}
			if (!swingPlayed && ((EntityState)this).fixedAge >= contact - 0.05f / speed)
			{
				swingPlayed = true;
				CML2Wire.Melee(((EntityState)this).characterBody, 2);
			}
			if (click.Queue(((EntityState)this).inputBank.skill1, ((EntityState)this).fixedAge >= contact))
			{
				queued = true;
			}
			float num = Mathf.Max(contact, ((EntityState)this).fixedAge - Time.fixedDeltaTime);
			float num2 = Mathf.Min(contact + 1f / 15f / speed, ((EntityState)this).fixedAge);
			if (num2 >= num && ((EntityState)this).fixedAge >= contact)
			{
				for (int i = 0; i <= 3; i++)
				{
					float time = Mathf.Lerp(num, num2, (float)i / 3f) * speed;
					Vector3 val = (Object.op_Implicit((Object)(object)visual) ? visual.ContactPoint(Clip, Limb, time) : (((EntityState)this).characterBody.corePosition + ((EntityState)this).inputBank.aimDirection));
					if (SasukeCombat.Hit(((EntityState)this).characterBody, val, SasukeTuning.MeleeRadius.Value, Coefficient(step), SasukeTuning.MeleeProc.Value, victims, one: false, (DamageSource)1) && NetworkServer.active)
					{
						CML2Vfx.Emit(val, 2);
						if (!contactPlayed)
						{
							contactPlayed = true;
							CML2Wire.Melee(((EntityState)this).characterBody, (byte)((step == 3) ? 6u : 5u));
						}
					}
				}
			}
			if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration && !queued && click.Held(((EntityState)this).inputBank.skill1))
			{
				queued = true;
			}
			if (((EntityState)this).isAuthority && (((EntityState)this).fixedAge >= duration || (step < 3 && queued && ((EntityState)this).fixedAge >= chain)))
			{
				((EntityState)this).outer.SetNextState((EntityState)(object)((step < 3 && queued) ? new CML2Melee
				{
					chained = true,
					step = step + 1
				} : ((CML2Melee)new Idle())));
			}
		}

		public override void OnExit()
		{
			if (Object.op_Implicit((Object)(object)visual))
			{
				visual.lockUntil = 0f;
			}
			((EntityState)this).OnExit();
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)2;
		}

		public override void OnSerialize(NetworkWriter w)
		{
			((BaseSkillState)this).OnSerialize(w);
			w.Write(step);
		}

		public override void OnDeserialize(NetworkReader r)
		{
			((BaseSkillState)this).OnDeserialize(r);
			step = r.ReadInt32();
		}
	}
	public static class CML2Fire
	{
		public static GameObject projectile;

		private static Hook detonateHook;

		public static void Prepare()
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			projectile = PrefabAPI.InstantiateClone(SasukeKit.fire, "SasukeCML2Fireball", true);
			SasukeCombat.Tag(projectile, (DamageSource)2);
			ProjectileImpactExplosion component = projectile.GetComponent<ProjectileImpactExplosion>();
			((ProjectileExplosion)component).blastRadius = SasukeTuning.FireRadius.Value * CML2Tuning.FireRadius.Value;
			((ProjectileExplosion)component).explosionEffect = CML2Vfx.fireImpact;
			projectile.GetComponent<ProjectileController>().ghostPrefab = SasukeFire01.Ghost("CML2FireballGhost", 4.3f, cml: true);
			projectile.AddComponent<CML2Projectile>();
			Content.AddProjectilePrefab(projectile);
			detonateHook = new Hook((MethodBase)typeof(ProjectileImpactExplosion).GetMethod("Detonate", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), (Delegate)(Action<Action<ProjectileImpactExplosion>, ProjectileImpactExplosion>)delegate(Action<ProjectileImpactExplosion> orig, ProjectileImpactExplosion self)
			{
				CML2Projectile component2 = ((Component)self).GetComponent<CML2Projectile>();
				if (Object.op_Implicit((Object)(object)component2) && NetworkServer.active && !component2.detonated)
				{
					component2.OnDetonate();
				}
				orig(self);
			});
		}
	}
	public sealed class CML2Projectile : MonoBehaviour
	{
		public bool detonated;

		private ProjectileController pc;

		private ProjectileDamage damage;

		private void Start()
		{
			//IL_004c: 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_0072: 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)
			pc = ((Component)this).GetComponent<ProjectileController>();
			damage = ((Component)this).GetComponent<ProjectileDamage>();
			if (!NetworkServer.active)
			{
				return;
			}
			CharacterBody val = (Object.op_Implicit((Object)(object)pc.owner) ? pc.owner.GetComponent<CharacterBody>() : null);
			bool flag = Physics.CheckSphere(((Component)this).transform.position, 0.13f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1);
			Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, 0.55f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.entityPrecise)).mask), (QueryTriggerInteraction)2);
			for (int i = 0; i < array.Length; i++)
			{
				HurtBox component = ((Component)array[i]).GetComponent<HurtBox>();
				if (Object.op_Implicit((Object)(object)val) && SasukeCombat.AttackTarget(component, val))
				{
					flag = true;
					break;
				}
			}
			if (flag)
			{
				((ProjectileExplosion)((Component)this).GetComponent<ProjectileImpactExplosion>()).Detonate();
			}
		}

		public void OnDetonate()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			if (detonated)
			{
				return;
			}
			detonated = true;
			if (!Object.op_Implicit((Object)(object)pc))
			{
				pc = ((Component)this).GetComponent<ProjectileController>();
			}
			if (!Object.op_Implicit((Object)(object)damage))
			{
				damage = ((Component)this).GetComponent<ProjectileDamage>();
			}
			if (Object.op_Implicit((Object)(object)pc.owner))
			{
				Vector3 position = ((Component)this).transform.position;
				Vector3 point;
				bool flag = FindFloor(position, out point);
				(pc.owner.GetComponent<CML2Burns>() ?? pc.owner.AddComponent<CML2Burns>()).Add(flag ? point : position, ((ProjectileExplosion)((Component)this).GetComponent<ProjectileImpactExplosion>()).blastRadius, damage.damage, damage.crit, position, !flag);
				if (SasukeTuning.Verbose)
				{
					string[] obj = new string[8]
					{
						"CML2_BURN impact=",
						((Vector3)(ref position)).ToString("F1"),
						" burn=",
						null,
						null,
						null,
						null,
						null
					};
					Vector3 val = (flag ? point : position);
					obj[3] = ((Vector3)(ref val)).ToString("F1");
					obj[4] = " drop=";
					obj[5] = (flag ? (position.y - point.y).ToString("F1") : "air");
					obj[6] = " ground=";
					obj[7] = flag.ToString();
					Log.Info(string.Concat(obj));
				}
			}
		}

		public static bool FindFloor(Vector3 p, out Vector3 point)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_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)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			point = p;
			int num = LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask);
			Vector3 val = p + Vector3.up * 0.5f;
			float num2 = 40.5f;
			RaycastHit val2 = default(RaycastHit);
			for (int i = 0; i < 6; i++)
			{
				if (!(num2 > 0f))
				{
					break;
				}
				if (!Physics.Raycast(val, Vector3.down, ref val2, num2, num, (QueryTriggerInteraction)1))
				{
					break;
				}
				if (((RaycastHit)(ref val2)).normal.y >= 0.5f)
				{
					point = ((RaycastHit)(ref val2)).point;
					return true;
				}
				num2 -= ((RaycastHit)(ref val2)).distance + 0.35f;
				val = ((RaycastHit)(ref val2)).point + Vector3.down * 0.35f;
			}
			float num3 = float.MaxValue;
			bool result = false;
			float[] array = new float[2] { 1.5f, 3.5f };
			RaycastHit val4 = default(RaycastHit);
			foreach (float num4 in array)
			{
				for (int k = 0; k < 8; k++)
				{
					float num5 = (float)k * MathF.PI / 4f;
					Vector3 val3 = p + new Vector3(Mathf.Cos(num5), 0f, Mathf.Sin(num5)) * num4 + Vector3.up * 0.5f;
					if (!Physics.Linecast(p, val3, num, (QueryTriggerInteraction)1) && Physics.Raycast(val3, Vector3.down, ref val4, 40.5f, num, (QueryTriggerInteraction)1) && !(((RaycastHit)(ref val4)).normal.y < 0.5f))
					{
						float num6 = p.y - ((RaycastHit)(ref val4)).point.y + num4;
						if (num6 < num3)
						{
							num3 = num6;
							point = ((RaycastHit)(ref val4)).point;
							result = true;
						}
					}
				}
			}
			return result;
		}
	}
	public sealed class CML2Burns : MonoBehaviour
	{
		public struct Field
		{
			public Vector3 p;

			public float radius;

			public float end;

			public float damage;

			public bool crit;

			public bool air;
		}

		private readonly List<Field> fields = new List<Field>();

		private float nextTick;

		private CharacterBody owner;

		private readonly Dictionary<HealthComponent, Field> hits = new Dictionary<HealthComponent, Field>();

		public void Add(Vector3 p, float radius, float impact, bool crit)
		{
			//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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Add(p, radius, impact, crit, p + Vector3.up * 0.3f);
		}

		public void Add(Vector3 p, float radius, float impact, bool crit, Vector3 source, bool air = false)
		{
			//IL_0089: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_00fe: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			owner = ((Component)this).GetComponent<CharacterBody>();
			float num = Mathf.Max(0.1f, CML2Tuning.BurnTick.Value);
			float num2 = Mathf.Max(num, CML2Tuning.BurnDuration.Value);
			float num3 = (air ? Mathf.Min(num2, 2.5f) : num2);
			if (fields.Count == 0)
			{
				nextTick = Time.fixedTime + num;
			}
			if (fields.Count >= 8)
			{
				fields.RemoveAt(0);
			}
			fields.Add(new Field
			{
				p = p,
				radius = (air ? (radius * 0.6f) : radius),
				end = Time.fixedTime + num3,
				damage = impact * CML2Tuning.BurnFraction.Value / (float)Mathf.Max(1, Mathf.RoundToInt(num2 / num)),
				crit = crit,
				air = air
			});
			EffectManager.SpawnEffect(CML2Vfx.burningGround, new EffectData
			{
				origin = p,
				start = source,
				scale = (air ? (radius * 0.6f) : radius),
				genericFloat = num3,
				genericUInt = (air ? 1u : 0u)
			}, true);
		}

		private void FixedUpdate()
		{
			//IL_0098: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Expected O, but got Unknown
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)owner))
			{
				return;
			}
			float now = Time.fixedTime;
			if (now + 0.001f < nextTick)
			{
				return;
			}
			nextTick += Mathf.Max(0.1f, CML2Tuning.BurnTick.Value);
			hits.Clear();
			foreach (Field field in fields)
			{
				if (now > field.end + 0.025f)
				{
					continue;
				}
				Collider[] array = Physics.OverlapSphere(field.p, field.radius, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.entityPrecise)).mask), (QueryTriggerInteraction)2);
				foreach (Collider val in array)
				{
					HurtBox component = ((Component)val).GetComponent<HurtBox>();
					if (SasukeCombat.AttackTarget(component, owner))
					{
						Vector3 val2 = val.ClosestPoint(field.p);
						if ((field.air || !(Mathf.Abs(val2.y - field.p.y) > 3.2f)) && !Physics.Linecast(field.p + Vector3.up * 0.2f, val2, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1) && (!hits.TryGetValue(component.healthComponent, out var value) || field.damage > value.damage))
						{
							hits[component.healthComponent] = field;
						}
					}
				}
			}
			foreach (KeyValuePair<HealthComponent, Field> hit in hits)
			{
				HealthComponent key = hit.Key;
				Field value2 = hit.Value;
				DamageInfo val3 = new DamageInfo
				{
					attacker = ((Component)this).gameObject,
					inflictor = ((Component)this).gameObject,
					damage = value2.damage,
					crit = value2.crit,
					procCoefficient = 0.05f,
					position = (Object.op_Implicit((Object)(object)key.body) ? key.body.corePosition : ((Component)key).transform.position),
					damageType = new DamageTypeCombo(DamageTypeCombo.op_Implicit((DamageType)0), (DamageTypeExtended)0, (DamageSource)2)
				};
				key.TakeDamage(val3);
				if (!val3.rejected)
				{
					GlobalEventManager.instance.OnHitEnemy(val3, ((Component)key).gameObject);
					GlobalEventManager.instance.OnHitAll(val3, ((Component)key).gameObject);
				}
			}
			fields.RemoveAll((Field f) => now >= f.end - 0.001f);
		}
	}
	public static class CML2Tuning
	{
		public static ConfigEntry<float> Duration;

		public static ConfigEntry<float> Cooldown;

		public static ConfigEntry<float> PrimaryDps;

		public static ConfigEntry<float> FireDamage;

		public static ConfigEntry<float> FireRadius;

		public static ConfigEntry<float> BurnDuration;

		public static ConfigEntry<float> BurnTick;

		public static ConfigEntry<float> BurnFraction;

		public static ConfigEntry<float> ChidoriDamage;

		public static ConfigEntry<float> ChidoriRadius;

		public static ConfigEntry<float> FullChargeChidoriRadius;

		public static void Init(ConfigFile c)
		{
			Duration = F(c, "Duration", 45f);
			Cooldown = F(c, "CooldownAfterEnd", 35f);
			PrimaryDps = F(c, "PrimarySustainedMultiplier", 1.75f);
			FireDamage = F(c, "FireballImpactMultiplier", 2.5f);
			FireRadius = F(c, "FireballRadiusMultiplier", 1.5f);
			BurnDuration = F(c, "BurnDuration", 6f);
			BurnTick = F(c, "BurnInterval", 0.5f);
			BurnFraction = F(c, "BurnTotalImpactFraction", 0.5f);
			ChidoriDamage = F(c, "ChidoriDamageMultiplier", 2f);
			ChidoriRadius = F(c, "ChidoriRadiusMultiplier", 1.5f);
			FullChargeChidoriRadius = F(c, "FullChargeChidoriRadiusMultiplier", 2f);
		}

		private static ConfigEntry<float> F(ConfigFile c, string n, float v)
		{
			return c.Bind<float>("Curse Mark Level 2", n, v, "CML2 only. Existing normal/Sharingan settings are unchanged.");
		}
	}
	public static class CML2Setup
	{
		public static SkillDef special;

		public static SkillDef primary;

		public static BuffDef buff;

		public static void FixSkin(SkinDef skin)
		{
			MethodInfo methodInfo = typeof(SkinDef).Assembly.GetType("RoR2.SkinDefParams")?.GetMethod("FromSkinDef", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (methodInfo != null)
			{
				typeof(SkinDef).GetField("skinDefParams")?.SetValue(skin, methodInfo.Invoke(null, new object[1] { skin }));
			}
		}

		public static void Build(GameObject body)
		{
			//IL_003c: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			Content.AddEntityState(typeof(CML2Activation));
			Content.AddEntityState(typeof(CML2Melee));
			buff = Content.CreateAndAddBuff("YoungSasukeCML2", SasukeIcons.Get("special_cml2"), new Color(0.5f, 0.15f, 0.8f), canStack: false, isDebuff: false);
			special = (SkillDef)(object)ScriptableObject.CreateInstance<CML2SkillDef>();
			special.skillName = "SasukeCurseMarkLevel2";
			special.skillNameToken = "CML2_NAME";
			special.skillDescriptionToken = "CML2_DESC";
			special.icon = SasukeIcons.Get("special_cml2");
			special.activationState = new SerializableEntityStateType(typeof(CML2Activation));
			special.activationStateMachineName = "Weapon2";
			special.baseMaxStock = 1;
			special.requiredStock = 1;
			special.stockToConsume = 1;
			special.rechargeStock = 1;
			special.baseRechargeInterval = CML2Tuning.Cooldown.Value;
			special.fullRestockOnAssign = false;
			special.resetCooldownTimerOnUse = true;
			special.mustKeyPress = true;
			special.interruptPriority = (InterruptPriority)2;
			special.isCombatSkill = true;
			((Object)special).name = special.skillName;
			Content.AddSkillDef(special);
			SkillLocator component = body.GetComponent<SkillLocator>();
			Skills.AddSkillToFamily(component.special.skillFamily, special);
			component.special.skillFamily.defaultVariantIndex = 1u;
			primary = Object.Instantiate<SkillDef>(component.primary.skillFamily.variants[0].skillDef);
			primary.skillName = "SasukeCML2Barrage";
			primary.skillNameToken = "CML2_PRIMARY";
			primary.skillDescriptionToken = "CML2_PRIMARY_DESC";
			primary.activationState = new SerializableEntityStateType(typeof(CML2Melee));
			primary.fullRestockOnAssign = false;
			primary.requiredStock = 0;
			((Object)primary).name = primary.skillName;
			Content.AddSkillDef(primary);
			LanguageAPI.Add("CML2_NAME", "Curse Mark Level 2");
			LanguageAPI.Add("CML2_DESC", "Transform for <style=cIsUtility>45 seconds</style> after a brief awakening. Gain sustained, camera-directed flight, a wing-assisted barrage, burning Fireballs and Black Chidori. <style=cIsUtility>35s</style> base recharge starts on reversion. Jump ascends; aim down + forward descends. Cannot refresh while active.");
			LanguageAPI.Add("CML2_PRIMARY", "Heavenly Demon Barrage");
			LanguageAPI.Add("CML2_PRIMARY_DESC", "Four connected wing-assisted strikes. Approximately <style=cIsDamage>1.75x</style> normal primary sustained damage, with a stronger final smash. Attack speed accelerates contacts and animation together.");
			LanguageAPI.Add("CML2_PRIMARY_DESC", $"Four source-based strikes for {CML2Melee.Coefficient(0) * 100f:0}% / {CML2Melee.Coefficient(1) * 100f:0}% / {CML2Melee.Coefficient(2) * 100f:0}% / {CML2Melee.Coefficient(3) * 100f:0}% damage. A held chain takes 2.20s at base attack speed, approximately {CML2Tuning.PrimaryDps.Value:0.##}x normal primary sustained damage. Works on the ground and in flight.");
			LanguageAPI.Add("CML2_FIRE_NAME", "Curse Mark: Great Fireball");
			LanguageAPI.Add("CML2_FIRE_DESC", $"Launch a massive Fireball for {SasukeTuning.FireDamage.Value * CML2Tuning.FireDamage.Value * 100f:0}% damage in {SasukeTuning.FireRadius.Value * CML2Tuning.FireRadius.Value:0.#}m. Suitable terrain burns for {CML2Tuning.BurnDuration.Value:0.#}s, dealing another {CML2Tuning.BurnFraction.Value * 100f:0}% of the impact over full exposure. One effective burn per caster per enemy. Cooldown and stocks are unchanged.");
			LanguageAPI.Add("CML2_CHIDORI_NAME", "Black Chidori");
			LanguageAPI.Add("CML2_CHIDORI_DESC", $"Hold to charge for {SasukeTuning.ChargeSeconds.Value:0.#}s; release to carry, contact to strike, Utility again to cancel. Deals {SasukeTuning.ChidoriMin.Value * CML2Tuning.ChidoriDamage.Value * 100f:0}% to {SasukeTuning.ChidoriMax.Value * CML2Tuning.ChidoriDamage.Value * 100f:0}% damage; {SasukeTuning.ChidoriBlast.Value * CML2Tuning.ChidoriRadius.Value:0.##}m partial / {SasukeTuning.ChidoriBlast.Value * CML2Tuning.ChidoriRadius.Value * CML2Tuning.FullChargeChidoriRadius.Value:0.##}m fully charged impact radius. Charge and carry retain flight control. Existing cooldown and proc behavior preserved.");
			LanguageAPI.Add("CML2_DESC", $"Awaken for {CML2Tuning.Duration.Value:0.#} seconds after a brief opening. Gain free flight, a four-hit wing barrage, Great Fireball and Black Chidori. {CML2Tuning.Cooldown.Value:0.#}s base recharge starts on reversion. Tap Jump for normal and item-added jumps; another press after all jumps or a 0.3s hold engages flight. Land and release Jump to reset. In flight, aim + movement steers, Jump ascends, aim down + forward descends; release movement to hover. Cannot refresh while active.");
			body.AddComponent<CML2Controller>();
			CML2Vfx.Prepare();
			CML2Fire.Prepare();
		}
	}
	public class CML2SkillDef : SkillDef
	{
		public override bool IsReady(GenericSkill slot)
		{
			CML2Controller component = ((Component)slot).GetComponent<CML2Controller>();
			if ((!Object.op_Implicit((Object)(object)component) || component.phase == 0) && !slot.characterBody.HasBuff(SasukeKit.curse))
			{
				return ((SkillDef)this).IsReady(slot);
			}
			return false;
		}

		public override void OnExecute(GenericSkill slot)
		{
			if (((SkillDef)this).IsReady(slot))
			{
				((SkillDef)this).OnExecute(slot);
			}
		}

		public override void OnFixedUpdate(GenericSkill slot, float dt)
		{
			CML2Controller component = ((Component)slot).GetComponent<CML2Controller>();
			if (!Object.op_Implicit((Object)(object)component) || component.phase == 0)
			{
				((SkillDef)this).OnFixedUpdate(slot, dt);
			}
		}

		public override void OnUnassigned(GenericSkill slot)
		{
			((Component)slot).GetComponent<CML2Controller>()?.Revert("special-replaced");
			((SkillDef)this).OnUnassigned(slot);
		}
	}
	public sealed class CML2Activation : BaseSkillState
	{
		private CML2Controller controller;

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			controller = ((EntityState)this).GetComponent<CML2Controller>();
			if (((EntityState)this).isAuthority)
			{
				EntityStateMachine[] components = ((EntityState)this).gameObject.GetComponents<EntityStateMachine>();
				foreach (EntityStateMachine val in components)
				{
					if (val.customName == "Weapon")
					{
						val.SetNextStateToMain();
					}
				}
			}
			if (NetworkServer.active)
			{
				controller?.Begin();
			}
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= 1.2f)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public override void OnExit()
		{
			if (NetworkServer.active && Object.op_Implicit((Object)(object)controller) && controller.Opening && ((EntityState)this).fixedAge < 1.18f)
			{
				controller.Revert("opening-interrupted");
			}
			((EntityState)this).OnExit();
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)7;
		}
	}
	public sealed class CML2MasterCheckpoint : MonoBehaviour
	{
		public int stock;

		public float recharge;

		public bool pending;
	}
	public sealed class CML2Controller : NetworkBehaviour
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_PreMove <>9__24_0;

			public static hook_UpdateIcon <>9__24_1;

			internal void <Install>b__24_0(orig_PreMove orig, CharacterMotor m, float dt)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				CML2Controller component = ((Component)m).GetComponent<CML2Controller>();
				Vector3 velocity = m.velocity;
				if (Object.op_Implicit((Object)(object)component))
				{
					component.Gravity();
				}
				orig.Invoke(m, dt);
				if (Object.op_Implicit((Object)(object)component) && m.hasEffectiveAuthority)
				{
					component.Flight(velocity, dt);
				}
			}

			internal void <Install>b__24_1(orig_UpdateIcon orig, BuffIcon i)
			{
				orig.Invoke(i);
				if ((Object)(object)i.buffDef == (Object)(object)CML2Setup.buff && !Object.op_Implicit((Object)(object)((Component)i).GetComponent<CML2Countdown>()))
				{
					((Component)i).gameObject.AddComponent<CML2Countdown>();
				}
			}
		}

		public byte phase;

		public float commitAt;

		public float endAt;

		public uint outfit;

		public uint activationSerial;

		private CharacterBody body;

		private SasukeVisual visual;

		private GenericSkill ownedPrimary;

		private GenericSkill specialSlot;

		private bool overrideOwned;

		private bool gravityOwned;

		private bool protectionOwned;

		private bool modelAwake;

		private float nextSync;

		private byte lastPhase;

		private bool jumpWasDown;

		private bool releaseRequired;

		private bool wasAirborne;

		private float holdTime;

		private uint flightSequence;

		private uint receivedFlightSequence;

		private EntityStateMachine flightBodyMachine;

		private GenericSkill secondaryOwned;

		private bool secondaryOverride;

		public bool Opening => phase == 1;

		public bool Transformed
		{
			get
			{
				if (phase == 2)
				{
					return Now < endAt;
				}
				return false;
			}
		}

		public float Remaining
		{
			get
			{
				if (!Transformed)
				{
					return 0f;
				}
				return Mathf.Max(0f, endAt - Now);
			}
		}

		public static float Now
		{
			get
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				if (!(NetworkManager.singleton is NetworkManagerSystem))
				{
					return Time.fixedTime;
				}
				return ((NetworkManagerSystem)NetworkManager.singleton).serverFixedTime;
			}
		}

		public bool ActiveFlight { get; private set; }

		public static bool Active(CharacterBody b)
		{
			CML2Controller cML2Controller = (Object.op_Implicit((Object)(object)b) ? ((Component)b).GetComponent<CML2Controller>() : null);
			if (Object.op_Implicit((Object)(object)cML2Controller))
			{
				return cML2Controller.Transformed;
			}
			return false;
		}

		public static void Install()
		{
			//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_0043: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			CML2Wire.Install();
			SoundBanks.Add(File.ReadAllBytes(Path.Combine(SasukeVisual.Assets, "Audio", "YoungSasukeCML2.bnk")));
			object obj = <>c.<>9__24_0;
			if (obj == null)
			{
				hook_PreMove val = delegate(orig_PreMove orig, CharacterMotor m, float dt)
				{
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					//IL_000d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0035: Unknown result type (might be due to invalid IL or missing references)
					CML2Controller component = ((Component)m).GetComponent<CML2Controller>();
					Vector3 velocity = m.velocity;
					if (Object.op_Implicit((Object)(object)component))
					{
						component.Gravity();
					}
					orig.Invoke(m, dt);
					if (Object.op_Implicit((Object)(object)component) && m.hasEffectiveAuthority)
					{
						component.Flight(velocity, dt);
					}
				};
				<>c.<>9__24_0 = val;
				obj = (object)val;
			}
			CharacterMotor.PreMove += (hook_PreMove)obj;
			object obj2 = <>c.<>9__24_1;
			if (obj2 == null)
			{
				hook_UpdateIcon val2 = delegate(orig_UpdateIcon orig, BuffIcon i)
				{
					orig.Invoke(i);
					if ((Object)(object)i.buffDef == (Object)(object)CML2Setup.buff && !Object.op_Implicit((Object)(object)((Component)i).GetComponent<CML2Countdown>()))
					{
						((Component)i).gameObject.AddComponent<CML2Countdown>();
					}
				};
				<>c.<>9__24_1 = val2;
				obj2 = (object)val2;
			}
			BuffIcon.UpdateIcon += (hook_UpdateIcon)obj2;
		}

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

		private void Start()
		{
			specialSlot = body.skillLocator.special;
			visual = SasukeVisual.Find(body);
			if (NetworkServer.active && Object.op_Implicit((Object)(object)body.master))
			{
				CML2MasterCheckpoint component = ((Component)body.master).GetComponent<CML2MasterCheckpoint>();
				if (Object.op_Implicit((Object)(object)component) && component.pending && (Object)(object)specialSlot.skillDef == (Object)(object)CML2Setup.special)
				{
					specialSlot.stock = Mathf.Min(specialSlot.stock, component.stock);
					specialSlot.rechargeStopwatch = component.recharge;
					component.pending = false;
				}
			}
		}

		public void Begin()
		{
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active && phase == 0 && body.healthComponent.alive)
			{
				specialSlot = body.skillLocator.special;
				ResetFlight();
				phase = 1;
				activationSerial++;
				((Component)this).GetComponent<SasukeAudio>()?.Awakening(activationSerial);
				outfit = body.skinIndex;
				commitAt = Now + 1.2f;
				endAt = 0f;
				body.AddBuff(Buffs.HiddenInvincibility);
				protectionOwned = true;
				((NetworkBehaviour)this).SetDirtyBit(1u);
				CML2Vfx.Emit(body.corePosition, 0);
				Log.Info("CML2_BEGIN skin=" + outfit + " time=" + Now);
			}
		}

		private void Commit()
		{
			ReleaseProtection();
			phase = 2;
			endAt = Now + CML2Tuning.Duration.Value;
			body.AddBuff(CML2Setup.buff);
			ownedPrimary = body.skillLocator.primary;
			ownedPrimary.SetSkillOverride((object)this, CML2Setup.primary, (SkillOverridePriority)4);
			overrideOwned = true;
			ApplySecondary(active: true);
			((NetworkBehaviour)this).SetDirtyBit(1u);
			Log.Info("CML2_COMMIT time=" + Now + " end=" + endAt);
		}

		private void FixedUpdate()
		{
			if (!Object.op_Implicit((Object)(object)body))
			{
				return;
			}
			if (NetworkServer.active)
			{
				if (phase != 0 && (!body.healthComponent.alive || (Object)(object)body.skillLocator.special.skillDef != (Object)(object)CML2Setup.special))
				{
					Revert("death-or-replaced");
					return;
				}
				if (Opening && Now >= commitAt)
				{
					Commit();
				}
				if (phase == 2 && Now >= endAt)
				{
					Revert("deadline");
				}
				if (phase != 0 && Now > nextSync)
				{
					nextSync = Now + 0.5f;
					((NetworkBehaviour)this).SetDirtyBit(1u);
				}
			}
			else if (phase == 2 && Now >= endAt)
			{
				ApplyModel(show: false);
				Gravity();
			}
			Gravity();
		}

		private void Update()
		{
			if (!Object.op_Implicit((Object)(object)body))
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)visual))
			{
				visual = SasukeVisual.Find(body);
			}
			bool show = Transformed || (Opening && Now >= commitAt - 0.55f);
			ApplyModel(show);
			if (lastPhase != phase)
			{
				if (phase == 1 && Object.op_Implicit((Object)(object)visual))
				{
					visual.Play("CML2_Transform", 1f, 0f, restart: true);
				}
				if (phase == 0 && Object.op_Implicit((Object)(object)visual))
				{
					visual.lockUntil = 0f;
					visual.CancelFlip();
				}
				lastPhase = phase;
			}
		}

		private void ApplyModel(bool show)
		{
			if (!Object.op_Implicit((Object)(object)visual))
			{
				return;
			}
			string[] array = new string[4] { "OriginalCostume", "ChuninCostume", "AwakenedBlueCostume", "AwakenedBlackCostume" };
			int num = ((body.skinIndex == 1) ? 1 : 0) + (show ? 2 : 0);
			for (int i = 0; i < 4; i++)
			{
				Transform val = ((Component)visual).transform.Find(array[i]);
				if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.activeSelf != (i == num))
				{
					((Component)val).gameObject.SetActive(i == num);
				}
			}
			modelAwake = show;
		}

		private void ReleaseProtection()
		{
			if (protectionOwned && NetworkServer.active && Object.op_Implicit((Object)(object)body))
			{
				body.RemoveBuff(Buffs.HiddenInvincibility);
				protectionOwned = false;
			}
		}

		private void Gravity()
		{
			//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_0085: Unknown result type (might be due to invalid IL or missing references)
			ValidateFlightLifecycle();
			if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.characterMotor))
			{
				bool flag = Transformed && ActiveFlight && !body.characterMotor.isGrounded;
				if (flag != gravityOwned)
				{
					CharacterGravityParameters gravityParameters = body.characterMotor.gravityParameters;
					gravityParameters.channeledAntiGravityGranterCount += (flag ? 1 : (-1));
					body.characterMotor.gravityParameters = gravityParameters;
					gravityOwned = flag;
				}
			}
		}

		private void Flight(Vector3 previous, float dt)
		{
			//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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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_0140: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: 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)
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.characterMotor))
			{
				return;
			}
			CharacterMotor characterMotor = body.characterMotor;
			if (Opening)
			{
				characterMotor.velocity = Vector3.zero;
			}
			else if (Transformed && ActiveFlight && !characterMotor.isGrounded)
			{
				Vector3 aimDirection = body.inputBank.aimDirection;
				Vector3 normalized = ((Vector3)(ref aimDirection)).normalized;
				Vector3 val = Vector3.ProjectOnPlane(normalized, Vector3.up);
				if (((Vector3)(ref val)).sqrMagnitude < 0.001f)
				{
					val = body.characterDirection.forward;
				}
				((Vector3)(ref val)).Normalize();
				Vector3 val2 = Vector3.Cross(Vector3.up, val);
				Vector3 moveVector = body.inputBank.moveVector;
				float num = Vector3.Dot(moveVector, val);
				float num2 = Vector3.Dot(moveVector, val2);
				Vector3 val3 = normalized * num + val2 * num2;
				if (body.inputBank.jump.down)
				{
					val3 += Vector3.up;
				}
				val3 = Vector3.ClampMagnitude(val3, 1f);
				float num3 = body.moveSpeed * (body.isSprinting ? 1.25f : 1f);
				characterMotor.velocity = Vector3.MoveTowards(previous, val3 * num3, Mathf.Max(18f, body.acceleration * 0.6f) * dt);
				characterMotor.lastVelocity = characterMotor.velocity;
			}
		}

		public void Revert(string reason, bool emitReturnEffect = true)
		{
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			if (phase == 0 && !overrideOwned && !gravityOwned && !protectionOwned)
			{
				return;
			}
			byte b = phase;
			phase = 0;
			ApplySecondary(active: false);
			ResetFlight();
			((Component)this).GetComponent<SasukeAudio>()?.StopAwakening(reason);
			endAt = 0f;
			ReleaseProtection();
			if (NetworkServer.active && Object.op_Implicit((Object)(object)body) && body.HasBuff(CML2Setup.buff))
			{
				body.RemoveBuff(CML2Setup.buff);
			}
			if (overrideOwned && Object.op_Implicit((Object)(object)ownedPrimary))
			{
				ownedPrimary.UnsetSkillOverride((object)this, CML2Setup.primary, (SkillOverridePriority)4);
				overrideOwned = false;
			}
			Gravity();
			if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.characterMotor))
			{
				CharacterMotor characterMotor = body.characterMotor;
				characterMotor.lastVelocity = characterMotor.velocity;
				characterMotor.rootMotion = Vector3.zero;
			}
			if (Object.op_Implicit((Object)(object)visual))
			{
				visual.lockUntil = 0f;
				visual.CancelFlip();
				string current = visual.current;
				if (current != null && current.StartsWith("CML2_"))
				{
					string text = ((current == "CML2_Chidori_AirSignsCharge") ? "Chidori_SignsCharge" : ((current == "CML2_Chidori_AirChargingHold") ? "Chidori_ChargingHold" : current.Substring(5)));
					if (TrackedReference.op_Implicit((TrackedReference)(object)visual.player[text]) && TrackedReference.op_Implicit((TrackedReference)(object)visual.player[current]))
					{
						float time = visual.player[current].time;
						float speed = visual.player[current].speed;
						visual.Play(text, speed, Mathf.Max(0.02f, (visual.player[text].length - time) / Mathf.Max(0.1f, speed)), restart: true);
						visual.player[text].time = time;
					}
				}
			}
			ApplyModel(show: false);
			if (NetworkServer.active)
			{
				((NetworkBehaviour)this).SetDirtyBit(1u);
				if (emitReturnEffect && b != 0 && Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent) && body.healthComponent.alive)
				{
					CML2Vfx.Emit(body.corePosition, 1);
				}
			}
			Log.Info("CML2_REVERT reason=" + reason + " time=" + Now + " stock=" + (Object.op_Implicit((Object)(object)specialSlot) ? specialSlot.stock : (-1)) + " recharge=" + (Object.op_Implicit((Object)(object)specialSlot) ? specialSlot.rechargeStopwatch : 0f));
		}

		private void OnDisable()
		{
			bool flag = phase != 0;
			Revert("body-disabled-stage-death", emitReturnEffect: false);
			if (NetworkServer.active && Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.master) && Object.op_Implicit((Object)(object)specialSlot) && (Object)(object)specialSlot.skillDef == (Object)(object)CML2Setup.special)
			{
				CML2MasterCheckpoint obj = ((Component)body.master).GetComponent<CML2MasterCheckpoint>() ?? ((Component)body.master).gameObject.AddComponent<CML2MasterCheckpoint>();
				obj.stock = specialSlot.stock;
				obj.recharge = (flag ? 0f : specialSlot.rechargeStopwatch);
				obj.pending = true;
			}
		}

		public override bool OnSerialize(NetworkWriter w, bool initial)
		{
			w.Write(phase);
			w.Write(commitAt);
			w.Write(endAt);
			w.Write(outfit);
			w.Write(ActiveFlight);
			w.Write(activationSerial);
			w.Write(receivedFlightSequence);
			return true;
		}

		public override void OnDeserialize(NetworkReader r, bool initial)
		{
			uint num = activationSerial;
			phase = r.ReadByte();
			commitAt = r.ReadSingle();
			endAt = r.ReadSingle();
			outfit = r.ReadUInt32();
			bool flag = r.ReadBoolean();
			activationSerial = r.ReadUInt32();
			uint num2 = r.ReadUInt32();
			if (!((NetworkBehaviour)this).hasAuthority || num2 >= flightSequence)
			{
				ActiveFlight = flag && Transformed;
			}
			if (!initial && activationSerial != num && phase != 0)
			{
				((Component)this).GetComponent<SasukeAudio>()?.Awakening(activationSerial);
			}
			if (phase == 0)
			{
				ResetFlight();
				((Component)this).GetComponent<SasukeAudio>()?.StopAwakening("replicated-reversion");
			}
			if (Object.op_Implicit((Object)(object)body))
			{
				ApplySecondary(phase == 2);
				if (phase == 2 && !overrideOwned)
				{
					ownedPrimary = body.skillLocator.primary;
					ownedPrimary.SetSkillOverride((object)this, CML2Setup.primary, (SkillOverridePriority)4);
					overrideOwned = true;
				}
				else if (phase == 0 && overrideOwned)
				{
					ownedPrimary.UnsetSkillOverride((object)this, CML2Setup.primary, (SkillOverridePriority)4);
					overrideOwned = false;
				}
				Gravity();
			}
		}

		public static bool Flying(CharacterBody b)
		{
			CML2Controller cML2Controller = (Object.op_Implicit((Object)(object)b) ? ((Component)b).GetComponent<CML2Controller>() : null);
			if (Object.op_Implicit((Object)(object)cML2Controller) && cML2Controller.Transformed)
			{
				return cML2Controller.ActiveFlight;
			}
			return false;
		}

		private void ResetFlight()
		{
			ActiveFlight = false;
			holdTime = 0f;
			jumpWasDown = Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.inputBank) && body.inputBank.jump.down;
			releaseRequired = jumpWasDown;
			wasAirborne = Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.characterMotor) && !body.characterMotor.isGrounded;
		}

		private void ValidateFlightLifecycle()
		{
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.characterMotor) || !Transformed)
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)flightBodyMachine))
			{
				flightBodyMachine = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Body");
			}
			if ((Object.op_Implicit((Object)(object)flightBodyMachine) && !(flightBodyMachine.state is GenericCharacterMain)) || (wasAirborne && body.characterMotor.isGrounded))
			{
				if (ActiveFlight)
				{
					SetFlight(active: false);
				}
				ResetFlight();
			}
		}

		private void SetFlight(bool active)
		{
			active = active && Transformed && Object.op_Implicit((Object)(object)body) && body.healthComponent.alive && !body.characterMotor.isGrounded;
			if (ActiveFlight != active)
			{
				ActiveFlight = active;
				Gravity();
				if (NetworkServer.active)
				{
					((NetworkBehaviour)this).SetDirtyBit(1u);
				}
				else
				{
					CML2Wire.SendFlight(this, active, ++flightSequence);
				}
				if (CML2Wire.Diagnostics)
				{
					Log.Info("R02_FLIGHT active=" + active + " jumpCount=" + body.characterMotor.jumpCount + " max=" + body.maxJumpCount + " hold=" + holdTime + " t=" + Now);
				}
			}
		}

		public bool ProcessFlightJump()
		{
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.characterMotor) || !body.characterMotor.hasEffectiveAuthority)
			{
				if (!ActiveFlight)
				{
					return Opening;
				}
				return true;
			}
			CharacterMotor characterMotor = body.characterMotor;
			bool down = body.inputBank.jump.down;
			if (!Transformed)
			{
				jumpWasDown = down;
				holdTime = 0f;
				releaseRequired = down;
				return Opening;
			}
			bool num = wasAirborne && characterMotor.isGrounded;
			wasAirborne = !characterMotor.isGrounded;
			if (num)
			{
				SetFlight(active: false);
				holdTime = 0f;
				releaseRequired = down;
			}
			if (!down)
			{
				holdTime = 0f;
				releaseRequired = false;
			}
			bool flag = down && !jumpWasDown && !releaseRequired;
			jumpWasDown = down;
			if (releaseRequired)
			{
				return true;
			}
			if (flag)
			{
				holdTime = 0f;
				if (!characterMotor.isGrounded && characterMotor.jumpCount >= body.maxJumpCount)
				{
					SetFlight(active: true);
				}
			}
			if (down)
			{
				holdTime += Time.fixedDeltaTime;
			}
			if (!characterMotor.isGrounded && down && holdTime >= 0.3f)
			{
				SetFlight(active: true);
			}
			if (!ActiveFlight)
			{
				return !flag;
			}
			return true;
		}

		internal void ReceiveFlight(bool active, uint sequence, uint activation, NetworkConnection sender)
		{
			NetworkIdentity component = ((Component)this).GetComponent<NetworkIdentity>();
			if (NetworkServer.active && Object.op_Implicit((Object)(object)component) && component.clientAuthorityOwner == sender && activation == activationSerial && sequence > receivedFlightSequence)
			{
				receivedFlightSequence = sequence;
				if (active && (!Transformed || !body.healthComponent.alive || body.characterMotor.isGrounded))
				{
					((NetworkBehaviour)this).SetDirtyBit(1u);
					return;
				}
				ActiveFlight = active;
				Gravity();
				((NetworkBehaviour)this).SetDirtyBit(1u);
			}
		}

		private void ApplySecondary(bool active)
		{
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.skillLocator))
			{
				return;
			}
			GenericSkill secondary = body.skillLocator.secondary;
			if (active && !secondaryOverride && (Object)(object)secondary.skillDef == (Object)(object)DemonWindShuriken.normal)
			{
				secondaryOwned = secondary;
				int stock = secondary.stock;
				float num = secondary.rechargeStopwatch / Mathf.Max(0.01f, secondary.finalRechargeInterval);
				secondary.SetSkillOverride((object)this, DemonWindShuriken.awakenedFire, (SkillOverridePriority)4);
				secondary.stock = Mathf.Min(stock, secondary.maxStock);
				secondary.rechargeStopwatch = num * secondary.finalRechargeInterval;
				secondaryOverride = true;
			}
			else if (!active && secondaryOverride)
			{
				bool num2 = Object.op_Implicit((Object)(object)secondaryOwned) && (Object)(object)secondaryOwned.skillDef == (Object)(object)DemonWindShuriken.awakenedFire;
				int num3 = (Object.op_Implicit((Object)(object)secondaryOwned) ? secondaryOwned.stock : 0);
				float num4 = (Object.op_Implicit((Object)(object)secondaryOwned) ? (secondaryOwned.rechargeStopwatch / Mathf.Max(0.01f, secondaryOwned.finalRechargeInterval)) : 0f);
				if (Object.op_Implicit((Object)(object)secondaryOwned))
				{
					secondaryOwned.UnsetSkillOverride((object)this, DemonWindShuriken.awakenedFire, (SkillOverridePriority)4);
				}
				if (num2 && Object.op_Implicit((Object)(object)secondaryOwned))
				{
					secondaryOwned.stock = Mathf.Min(num3, secondaryOwned.maxStock);
					secondaryOwned.rechargeStopwatch = num4 * secondaryOwned.finalRechargeInterval;
				}
				secondaryOverride = false;
				secondaryOwned = null;
			}
		}
	}
	public sealed class CML2Countdown : MonoBehaviour
	{
		private BuffIcon icon;

		private TextMeshProUGUI label;

		private void Awake()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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)
			icon = ((Component)this).GetComponent<BuffIcon>();
			GameObject val = new GameObject("CML2 remaining", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(((Component)this).transform, false);
			label = val.AddComponent<TextMeshProUGUI>();
			if (Object.op_Implicit((Object)(object)icon.stackCount))
			{
				((TMP_Text)label).font = ((TMP_Text)icon.stackCount).font;
			}
			((TMP_Text)label).fontSize = 15f;
			((TMP_Text)label).alignment = (TextAlignmentOptions)1028;
			((Graphic)label).raycastTarget = false;
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
		}

		private void LateUpdate()
		{
			BuffDisplay componentInParent = ((Component)this).GetComponentInParent<BuffDisplay>();
			CML2Controller cML2Controller = ((Object.op_Implicit((Object)(object)componentInParent) && Object.op_Implicit((Object)(object)componentInParent.source)) ? ((Component)componentInParent.source).GetComponent<CML2Controller>() : null);
			((Behaviour)label).enabled = (Object)(object)icon.buffDef == (Object)(object)CML2Setup.buff && Object.op_Implicit((Object)(object)cML2Controller) && cML2Controller.Remaining > 0f;
			if (((Behaviour)label).enabled)
			{
				((TMP_Text)label).text = Mathf.CeilToInt(cML2Controller.Remaining).ToString();
			}
		}
	}
	internal sealed class CML2FlightMessage : MessageBase
	{
		public NetworkInstanceId body;

		public bool active;

		public uint sequence;

		public uint activation;

		public override void Serialize(NetworkWriter w)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			w.Write(body);
			w.Write(active);
			w.Write(sequence);
			w.Write(activation);
		}

		public override void Deserialize(NetworkReader r)
		{
			//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)
			body = r.ReadNetworkId();
			active = r.ReadBoolean();
			sequence = r.ReadUInt32();
			activation = r.ReadUInt32();
		}
	}
	internal sealed class CML2SoundMessage : MessageBase
	{
		public NetworkInstanceId body;

		public byte kind;

		public uint sequence;

		public override void Serialize(NetworkWriter w)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			w.Write(body);
			w.Write(kind);
			w.Write(sequence);
		}

		public override void Deserialize(NetworkReader r)
		{
			//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)
			body = r.ReadNetworkId();
			kind = r.ReadByte();
			sequence = r.ReadUInt32();
		}
	}
	internal static class CML2Wire
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static NetworkMessageDelegate <>9__7_0;

			public static NetworkMessageDelegate <>9__7_1;

			internal void <Update>b__7_0(NetworkMessage n)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				CML2FlightMessage cML2FlightMessage = n.ReadMessage<CML2FlightMessage>();
				GameObject val = NetworkServer.FindLocalObject(cML2FlightMessage.body);
				if (Object.op_Implicit((Object)(object)val))
				{
					val.GetComponent<CML2Controller>()?.ReceiveFlight(cML2FlightMessage.active, cML2FlightMessage.sequence, cML2FlightMessage.activation, n.conn);
				}
			}

			internal void <Update>b__7_1(NetworkMessage n)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				CML2SoundMessage cML2SoundMessage = n.ReadMessage<CML2SoundMessage>();
				GameObject val = ClientScene.FindLocalObject(cML2SoundMessage.body);
				if (Object.op_Implicit((Object)(object)val))
				{
					val.GetComponent<SasukeAudio>()?.Melee(cML2SoundMessage.kind, cML2SoundMessage.sequence);
				}
			}
		}

		private const short FlightId = 27983;

		private const short SoundId = 27984;

		private static bool serverRegistered;

		private static readonly HashSet<NetworkClient> clients = new HashSet<NetworkClient>();

		private static uint soundSequence;

		public static bool Diagnostics;

		public static void Install()
		{
			Diagnostics = SasukeTuning.Verbose;
			RoR2Application.onUpdate += Update;
		}

		private static void Update()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//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_0091: Expected O, but got Unknown
			if (NetworkServer.active && !serverRegistered)
			{
				object obj = <>c.<>9__7_0;
				if (obj == null)
				{
					NetworkMessageDelegate val = delegate(NetworkMessage n)
					{
						//IL_0008: Unknown result type (might be due to invalid IL or missing references)
						CML2FlightMessage cML2FlightMessage = n.ReadMessage<CML2FlightMessage>();
						GameObject val3 = NetworkServer.FindLocalObject(cML2FlightMessage.body);
						if (Object.op_Implicit((Object)(object)val3))
						{
							val3.GetComponent<CML2Controller>()?.ReceiveFlight(cML2FlightMessage.active, cML2FlightMessage.sequence, cML2FlightMessage.activation, n.conn);
						}
					};
					<>c.<>9__7_0 = val;
					obj = (object)val;
				}
				NetworkServer.RegisterHandler((short)27983, (NetworkMessageDelegate)obj);
				serverRegistered = true;
			}
			if (!NetworkServer.active)
			{
				serverRegistered = false;
			}
			foreach (NetworkClient allClient in NetworkClient.allClients)
			{
				if (!clients.Add(allClient))
				{
					continue;
				}
				object obj2 = <>c.<>9__7_1;
				if (obj2 == null)
				{
					NetworkMessageDelegate val2 = delegate(NetworkMessage n)
					{
						//IL_0008: Unknown result type (might be due to invalid IL or missing references)
						CML2SoundMessage cML2SoundMessage = n.ReadMessage<CML2SoundMessage>();
						GameObject val3 = ClientScene.FindLocalObject(cML2SoundMessage.body);
						if (Object.op_Implicit((Object)(object)val3))
						{
							val3.GetComponent<SasukeAudio>()?.Melee(cML2SoundMessage.kind, cML2SoundMessage.sequence);
						}
					};
					<>c.<>9__7_1 = val2;
					obj2 = (object)val2;
				}
				allClient.RegisterHandler((short)27984, (NetworkMessageDelegate)obj2);
			}
		}

		public static void SendFlight(CML2Controller c, bool active, uint sequence)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			foreach (NetworkClient allClient in NetworkClient.allClients)
			{
				if (allClient.isConnected)
				{
					allClient.Send((short)27983, (MessageBase)(object)new CML2FlightMessage
					{
						body = ((NetworkBehaviour)c).netId,
						active = active,
						sequence = sequence,
						activation = c.activationSerial
					});
					break;
				}
			}
		}

		public static void Melee(CharacterBody body, byte kind)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active)
			{
				NetworkServer.SendToAll((short)27984, (MessageBase)(object)new CML2SoundMessage
				{
					body = ((Component)body).GetComponent<NetworkIdentity>().netId,
					kind = kind,
					sequence = ++soundSequence
				});
			}
		}
	}
	public static class CML2Revision02BodySampler
	{
		public static Quaternion SampleRotation(ClipData clip, int boneIndex, float phase01)
		{
			//IL_0067: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			if (clip == null || clip.frames == null || clip.frames.Length < 2)
			{
				throw new ArgumentException("Revision02 requires a sampled body cycle");
			}
			float num = Mathf.Repeat(phase01, 1f) * (float)(clip.frames.Length - 1);
			int num2 = Mathf.FloorToInt(num);
			int num3 = Mathf.Min(num2 + 1, clip.frames.Length - 1);
			return Quaternion.Slerp(SasukeVisual.Rot(clip.frames[num2].bones[boneIndex].q), SasukeVisual.Rot(clip.frames[num3].bones[boneIndex].q), num - (float)num2);
		}
	}
	public static class CML2ChidoriPalette
	{
		private static Material black;

		private static Material white;

		public static Material Black
		{
			get
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				if (!Object.op_Implicit((Object)(object)black))
				{
					black = SasukeEffects.Glow(new Color(0.01f, 0.01f, 0.01f));
					((Object)black).name = "CML2 neutral opaque black lightning";
					black.SetFloat("_EmPower", 0f);
					if (black.HasProperty("_SpecularStrength"))
					{
						black.SetFloat("_SpecularStrength", 0f);
					}
				}
				return black;
			}
		}

		public static Material White
		{
			get
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				if (!Object.op_Implicit((Object)(object)white))
				{
					white = SasukeEffects.Glow(Color.white);
					((Object)white).name = "CML2 neutral white lightning";
				}
				return white;
			}
		}
	}
	public static class CML2Vfx
	{
		public static GameObject fireImpact;

		public static GameObject chidoriImpact;

		public static GameObject burningGround;

		public static GameObject awakening;

		public static GameObject reversion;

		public static GameObject melee;

		public static Material flame;

		public static Material smoke;

		public static Material chakra;

		public static void Prepare()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			flame = Cloud(fire: true);
			smoke = Cloud(fire: false);
			chakra = SasukeEffects.Transparent();
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false);
			Color[] array = (Color[])(object)new Color[4096];
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					Vector2 val2 = new Vector2(((float)j - 31.5f) / 31.5f, ((float)i - 31.5f) / 31.5f);
					float magnitude = ((Vector2)(ref val2)).magnitude;
					float num = Mathf.Clamp01(1f - magnitude);
					array[i * 64 + j] = new Color(1f, 1f, 1f, num * num);
				}
			}
			val.SetPixels(array);
			val.Apply();
			chakra.mainTexture = (Texture)(object)val;
			chakra.SetFloat("_Boost", 1.4f);
			fireImpact = SasukeFire01.Impact("CML2FireBlast01", cml: true);
			chidoriImpact = Prefab("CML2BlackChidoriImpact", 4);
			burningGround = Prefab("CML2BurningGround", 5);
			awakening = Prefab("CML2Awakening", 0);
			reversion = Prefab("CML2Reversion", 1);
			melee = Prefab("CML2MeleeImpact", 2);
		}

		private static Material Cloud(bool fire)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			Material val = SasukeEffects.Transparent();
			Texture2D val2 = new Texture2D(128, 128, (TextureFormat)4, false);
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num = ((float)j - 63.5f) / 63.5f;
					float num2 = ((float)i - 63.5f) / 63.5f;
					float num3 = Mathf.PerlinNoise((float)j * 0.061f, (float)i * 0.061f) * 0.6f + Mathf.PerlinNoise((float)j * 0.143f + 9f, (float)i * 0.143f) * 0.25f;
					float num4 = Mathf.Clamp01((1f - Mathf.Sqrt(num * num + num2 * num2)) * 3.3f - 0.65f + num3 * 0.6f);
					float num5 = (fire ? Mathf.Lerp(0.55f, 1f, num3) : Mathf.Lerp(0.45f, 0.85f, num3));
					val2.SetPixel(j, i, new Color(num5 * num4, num5 * num4, num5 * num4, num4));
				}
			}
			((Texture)val2).wrapMode = (TextureWrapMode)1;
			val2.Apply();
			val.mainTexture = (Texture)(object)val2;
			val.SetInt("_DstBlend", fire ? 1 : 10);
			val.SetFloat("_Boost", fire ? 2.5f : 1f);
			return val;
		}

		private static GameObject Prefab(string name, int kind)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.AddComponent<EffectComponent>().applyScale = false;
			val.AddComponent<VFXAttributes>().DoNotPool = true;
			val.AddComponent<CML2VisualEffect>().kind = kind;
			GameObject obj = PrefabAPI.InstantiateClone(val, name + "Prefab", false);
			Object.DestroyImmediate((Object)(object)val);
			Content.CreateAndAddEffectDef(obj);
			return obj;
		}

		public static void Emit(Vector3 p, int kind)
		{
			//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_0020: 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_0037: Expected O, but got Unknown
			EffectManager.SpawnEffect((GameObject)(kind switch
			{
				1 => reversion, 
				0 => awakening, 
				_ => melee, 
			}), new EffectData
			{
				origin = p,
				scale = 1f
			}, true);
		}
	}
	public sealed class CML2BurnFeed : MonoBehaviour
	{
		public ParticleSystem patch;

		public Vector3 source;

		public Vector3 fallback;

		public Vector3 destination;

		public float duration;

		private ParticleSystem stream;

		private float begin;

		private bool arrived;

		private void Start()
		{
			//IL_000c: 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_001c: 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_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)
			begin = Time.time;
			if (Physics.Linecast(source, destination, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
			{
				source = fallback;
			}
			stream = SasukeStormFire.GroundStream(((Component)this).gameObject);
			((Component)stream).transform.position = source;
			stream.Play();
		}

		private void Update()
		{
			//IL_002e: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			if (arrived)
			{
				return;
			}
			float num = Mathf.Clamp01((Time.time - begin) / duration);
			((Component)stream).transform.position = Vector3.Lerp(source, destination, num);
			if (num >= 1f)
			{
				arrived = true;
				stream.Stop(false, (ParticleSystemStopBehavior)1);
				if (Object.op_Implicit((Object)(object)patch))
				{
					patch.Play();
					patch.Emit(8);
				}
				Object.Destroy((Object)(object)((Component)stream).gameObject, 0.4f);
				Object.Destroy((Object)(object)this);
			}
		}
	}
	public sealed class CML2VisualEffect : MonoBehaviour
	{
		public int kind;

		private static readonly List<CML2VisualEffect> active = new List<CML2VisualEffect>();

		private readonly List<ParticleSystem> particles = new List<ParticleSystem>();

		private float start;

		private float end;

		private bool revealPuff;

		private float radius;

		private readonly List<LineRenderer> arcs = new List<LineRenderer>();

		private ParticleSystem Puff(string name, Material mat, Vector3 local, float size, float life, Color color, int count, float speed = 0f)
		{
			//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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_010a: 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)
			//IL_0119: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(((Component)this).transform, false);
			val.transform.localPosition = local;
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			val2.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = val2.main;
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).duration = 1f;
			((MainModule)(ref main)).maxParticles = count;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(life * 0.6f, life);
			((MainModule)(ref main)).startSize = new MinMaxCurve(size * 0.5f, size);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(speed);
			((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, 6.28f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(color);
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = size * 0.3f;
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).enabled = false;
			ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val3 = new Gradient();
			val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(Color.white, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(0.85f, 0f),
				new GradientAlphaKey(0.45f, 0.4f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3);
			((Renderer)((Component)val2).GetComponent<ParticleSystemRenderer>()).sharedMaterial = mat;
			val2.Play();
			val2.Emit(count);
			particles.Add(val2);
			return val2;
		}

		private void Start()
		{
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0817: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0600: Unknown result type (might be due to invalid IL or missing references)
			//IL_061d: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_065b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0666: Unknown result type (might be due to invalid IL or missing references)
			//IL_067a: Unknown result type (might be due to invalid IL or missing references)
			//IL_067f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0861: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Unknown result type (might be due to invalid IL or missing references)
			//IL_0536: Unknown result type (might be due to invalid IL or missing references)
			//IL_0542: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: Unknown result type (might be due to invalid IL or missing references)
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_0556: Unknown result type (might be due to invalid IL or missing references)
			//IL_055b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_0568: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_057c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_069a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_089a: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_078b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_091c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0918: Unknown result type (might be due to invalid IL or missing references)
			//IL_0953: Unknown result type (might be due to invalid IL or missing references)
			//IL_0974: Unknown result type (might be due to invalid IL or missing references)
			//IL_0979: Unknown result type (might be due to invalid IL or missing references)
			//IL_0984: Unknown result type (might be due to invalid IL or missing references)
			//IL_0989: Unknown result type (might be due to invalid IL or missing references)
			//IL_0993: Unknown result type (might be due to invalid IL or missing references)
			//IL_0998: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a7: Unknown result type (might be due to invalid IL or missing references)
			active.RemoveAll((CML2VisualEffect x) => !Object.op_Implicit((Object)(object)x));
			if (active.Count >= 24)
			{
				CML2VisualEffect cML2VisualEffect = active[0];
				active.RemoveAt(0);
				if (Object.op_Implicit((Object)(object)cML2VisualEffect))
				{
					Object.Destroy((Object)(object)((Component)cML2VisualEffect).gameObject);
				}
			}
			active.Add(this);
			start = Time.time;
			EffectComponent component = ((Component)this).GetComponent<EffectComponent>();
			radius = component.effectData.scale;
			end = start + ((kind == 5) ? (CML2Tuning.BurnDuration.Value + 1f) : ((kind == 3) ? 2.5f : ((kind == 0) ? 1.2f : 0.9f)));
			if (kind == 3)
			{
				Vector3 local = default(Vector3);
				for (int num = 0; num < 3; num++)
				{
					for (int num2 = 0; num2 < 8; num2++)
					{
						float num3 = (float)num2 * MathF.PI / 4f + (float)num * 0.3f;
						float num4 = radius * num switch
						{
							1 => 0.33f, 
							0 => 0.55f, 
							_ => 0.13f, 
						};
						((Vector3)(ref local))..ctor(Mathf.Cos(num3) * num4, (float)num * 2.1f, Mathf.Sin(num3) * num4);
						Puff("Layered fire burst", CML2Vfx.flame, local, (num == 2) ? 3f : 4.2f, 0.8f, new Color(1f, 0.25f, 0.015f), 12, 2f);
						Puff("Rolling smoke", CML2Vfx.smoke, local, 3f, 1.8f, new Color(0.17f, 0.12f, 0.12f, 0.65f), 8, 1.3f);
					}
				}
				Puff("Pressure embers", CML2Vfx.flame, Vector3.zero, 0.16f, 1.1f, new Color(1f, 0.75f, 0.2f), 80, 14f);
				Puff("Short debris", CML2Vfx.smoke, Vector3.zero, 0.12f, 0.65f, new Color(0.22f, 0.15f, 0.11f), 24, 10f);
				SasukeAudio.FireImpact(((Component)this).gameObject);
				return;
			}
			if (kind == 5 && component.effectData.genericUInt == 1)
			{
				end = start + component.effectData.genericFloat + 1f;
				for (int num5 = 0; num5 < 9; num5++)
				{
					Vector3 local2 = ((num5 == 0) ? Vector3.zero : (Random.insideUnitSphere * radius * 0.45f));
					ParticleSystem obj = Puff("Airborne fire", CML2Vfx.flame, local2, 2f, 0.55f, new Color(1f, 0.28f, 0.025f, 0.7f), 18, 0.6f);
					obj.Stop(true, (ParticleSystemStopBehavior)0);
					SasukeStormFire.GroundFlame(obj);
					EmissionModule emission = obj.emission;
					((EmissionModule)(ref emission)).enabled = true;
					((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(10f);
					MainModule main = obj.main;
					((MainModule)(ref main)).loop = true;
					((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.15f);
					obj.Play();
				}
				return;
			}
			if (kind == 5)
			{
				int num6 = 25;
				RaycastHit val = default(RaycastHit);
				for (int num7 = 0; num7 < num6; num7++)
				{
					float num8 = (float)num7 * 2.399963f;
					float num9 = radius * Mathf.Sqrt((float)num7 / (float)num6);
					if (Physics.Raycast(((Component)this).transform.position + new Vector3(Mathf.Cos(num8) * num9, 2f, Mathf.Sin(num8) * num9), Vector3.down, ref val, 4f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1) && ((RaycastHit)(ref val)).normal.y > 0.5f && !Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.3f, ((RaycastHit)(ref val)).point + Vector3.up * 0.3f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
					{
						ParticleSystem val2 = Puff("Terrain fire", CML2Vfx.flame, ((RaycastHit)(ref val)).point - ((Component)this).transform.position + Vector3.up * 0.25f, 2f, 0.55f, new Color(1f, 0.28f, 0.025f, 0.7f), 18, 0.6f);
						val2.Stop(true, (ParticleSystemStopBehavior)0);
						SasukeStormFire.GroundFlame(val2);
						EmissionModule emission2 = val2.emission;
						((EmissionModule)(ref emission2)).enabled = true;
						((EmissionModule)(ref emission2)).rateOverTime = MinMaxCurve.op_Implicit(12f);
						MainModule main2 = val2.main;
						((MainModule)(ref main2)).loop = true;
						CML2BurnFeed cML2BurnFeed = ((Component)this).gameObject.AddComponent<CML2BurnFeed>();
						cML2BurnFeed.patch = val2;
						cML2BurnFeed.source = component.effectData.start;
						cML2BurnFeed.fallback = ((Component)this).transform.position + Vector3.up * 0.3f;
						cML2BurnFeed.destination = ((RaycastHit)(ref val)).point + Vector3.up * 0.25f;
						cML2BurnFeed.duration = 0.18f + 0.22f * (num9 / Mathf.Max(1f, radius));
					}
				}
				return;
			}
			if (kind == 4)
			{
				Puff("Neutral black pressure", CML2Vfx.smoke, Vector3.zero, Mathf.Min(3f, radius * 0.35f), 0.55f, new Color(0.015f, 0.015f, 0.015f, 0.85f), 36, 4f);
				Puff("Neutral white flash", CML2Vfx.chakra, Vector3.zero, 1.1f, 0.16f, Color.white, 16, 3f);
				for (int num10 = 0; num10 < 24; num10++)
				{
					LineRenderer val3 = BlackArc("Black Chidori interior", num10 % 4 == 0, 8);
					Vector3 val4 = Random.onUnitSphere * radius * Random.Range(0.6f, 0.97f);
					for (int num11 = 0; num11 < 8; num11++)
					{
						float num12 = (float)num11 / 7f;
						Vector3 val5 = ((num11 == 0 || num11 == 7) ? Vector3.zero : (Random.insideUnitSphere * Mathf.Min(0.45f, radius * 0.045f)));
						val3.SetPosition(num11, val4 * num12 + val5);
					}
				}
				for (int num13 = 0; num13 < 3; num13++)
				{
					LineRenderer val6 = BlackArc("Black Chidori radius boundary", num13 == 1, 49);
					float startWidth = (val6.endWidth = ((num13 == 1) ? 0.035f : 0.085f));
					val6.startWidth = startWidth;
					for (int num15 = 0; num15 < 49; num15++)
					{
						float num16 = (float)num15 * MathF.PI * 2f / 48f;
						val6.SetPosition(num15, (Vector3)(num13 switch
						{
							1 => new Vector3(Mathf.Cos(num16), Mathf.Sin(num16), 0f), 
							0 => new Vector3(Mathf.Cos(num16), 0f, Mathf.Sin(num16)), 
							_ => new Vector3(0f, Mathf.Cos(num16), Mathf.Sin(num16)), 
						}) * radius);
					}
				}
				Util.PlaySound("Play_mage_m2_impact", ((Component)this).gameObject);
				return;
			}
			Color val7 = default(Color);
			((Color)(ref val7))..ctor(0.4f, 0.07f, 0.65f, 0.7f);
			Puff("Dark chakra", CML2Vfx.smoke, Vector3.zero, (kind == 0) ? 2.1f : ((float)((kind != 4) ? 1 : 3)), (kind == 0) ? 1.1f : 0.65f, new Color(0.08f, 0.025f, 0.12f, 0.8f), (kind == 0) ? 70 : 40, (kind == 4) ? 5f : 1.3f);
			Puff("Chakra edge", CML2Vfx.chakra, Vector3.zero, (kind == 4) ? 1.6f : 0.8f, 0.4f, val7, 45, (kind == 4) ? 8 : 2);
			if (kind == 4 || kind == 0)
			{
				for (int num17 = 0; num17 < 18; num17++)
				{
					GameObject val8 = new GameObject("Branching violet arc");
					val8.transform.SetParent(((Component)this).transform, false);
					LineRenderer val9 = val8.AddComponent<LineRenderer>();
					((Renderer)val9).sharedMaterial = SasukeEffects.Glow((num17 % 3 == 0) ? Color.white : val7);
					val9.positionCount = 7;
					val9.useWorldSpace = false;
					val9.startWidth = 0.035f;
					val9.endWidth = 0.005f;
					Vector3 val10 = Random.onUnitSphere * ((kind == 4) ? (radius * 0.8f) : 1.5f);
					for (int num18 = 0; num18 < 7; num18++)
					{
						val9.SetPosition(num18, val10 * (float)num18 / 6f + Random.insideUnitSphere * 0.15f);
					}
					arcs.Add(val9);
				}
			}
			if (kind == 1)
			{
				if (!Object.op_Implicit((Object)(object)((Component)this).GetComponent<AkGameObj>()))
				{
					((Component)this).gameObject.AddComponent<AkGameObj>();
				}
				AkSoundEngine.PostEvent((kind == 0) ? "Play_YSCML2_awaken" : "Play_YSCML2_revert", ((Component)this).gameObject);
			}
			else if (kind != 0 && kind != 2)
			{
				Util.PlaySound((kind == 4) ? "Play_mage_m2_impact" : ((kind == 0) ? "Play_voidman_m2_chargeUp" : "Play_loader_m1_impact"), ((Component)this).gameObject);
			}
		}

		private LineRenderer BlackArc(string name, bool white, int count)
		{
			//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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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)
			GameObject val = new GameObject(name);
			val.transform.SetParent(((Component)this).transform, false);
			LineRenderer val2 = val.AddComponent<LineRenderer>();
			((Renderer)val2).sharedMaterial = (white ? CML2ChidoriPalette.White : CML2ChidoriPalette.Black);
			val2.useWorldSpace = false;
			val2.positionCount = count;
			val2.startWidth = (white ? 0.04f : 0.12f);
			val2.endWidth = (white ? 0.012f : 0.04f);
			Color startColor = (val2.endColor = Color.white);
			val2.startColor = startColor;
			arcs.Add(val2);
			return val2;
		}

		private void Update()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			float num = Time.time - start;
			if (kind == 0 && !revealPuff && num >= 0.5f)
			{
				revealPuff = true;
				Puff("Awakened wing reveal cover", CML2Vfx.smoke, new Vector3(0f, 0.1f, 0f), 3.4f, 0.65f, new Color(0.08f, 0.025f, 0.12f, 0.95f), 90, 0.5f);
			}
			if (kind == 5 && num > end - start - 1f)
			{
				foreach (ParticleSystem particle in particles)
				{
					if (Object.op_Implicit((Object)(object)particle))
					{
						particle.Stop(false, (ParticleSystemStopBehavior)1);
					}
				}
			}
			if (num > ((kind == 4) ? 0.3f : 0.22f))
			{
				foreach (LineRenderer arc in arcs)
				{
					if (Object.op_Implicit((Object)(object)arc))
					{
						((Renderer)arc).enabled = false;
					}
				}
			}
			if (Time.time > end)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void OnDestroy()
		{
			active.Remove(this);
			if (kind == 4)
			{
				return;
			}
			foreach (LineRenderer arc in arcs)
			{
				if (Object.op_Implicit((Object)(object)arc))
				{
					Object.Destroy((Object)(object)((Renderer)arc).sharedMaterial);
				}
			}
		}
	}
	public static class DemonWindShuriken
	{
		[Serializable]
		public class Part
		{
			public string name;

			public float[] v;

			public float[] n;

			public float[] uv;

			public int[] tri;
		}

		[Serializable]
		public class Geometry
		{
			public Part[] meshes;
		}

		public static SkillDef normal;

		public static SkillDef awakenedFire;

		public static GameObject projectile;

		private static Mesh mesh;

		private static Material material;

		public static GameObject remnant;

		public const float VisualGrowth = 1.22f;

		public static float DiscRadius;

		public static void Setup(GameObject body)
		{
			//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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Expected O, but got Unknown
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Expected O, but got Unknown
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Expected O, but got Unknown
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Expected O, but got Unknown
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			//IL_056c: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0583: Expected O, but got Unknown
			//IL_058d: Expected O, but got Unknown
			GenericSkill secondary = body.GetComponent<SkillLocator>().secondary;
			SkillDef skillDef = secondary.skillFamily.variants[0].skillDef;
			normal = (SkillDef)(object)ScriptableObject.CreateInstance<SasukeAttackSkillDef>();
			normal.skillName = "SasukeDemonWind";
			((Object)normal).name = normal.skillName;
			normal.skillNameToken = "SASUKE_DEMON_WIND";
			normal.skillDescriptionToken = "SASUKE_DEMON_WIND_DESC";
			normal.icon = SasukeIcons.Get("secondary_shuriken");
			normal.activationState = new SerializableEntityStateType(typeof(DemonWindThrow));
			normal.activationStateMachineName = "Weapon";
			normal.baseMaxStock = 1;
			normal.requiredStock = 1;
			normal.stockToConsume = 1;
			normal.rechargeStock = 1;
			normal.baseRechargeInterval = SasukeUpdateTuning.ShurikenCooldown.Value;
			normal.fullRestockOnAssign = false;
			normal.resetCooldownTimerOnUse = true;
			normal.mustKeyPress = t