Decompiled source of AscendantEnchantmentsTest v1.0.8

plugins/AscendantEnchantments.dll

Decompiled a month 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 BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using EpicLoot;
using EpicLoot.src.Magic.MagicItemEffects.Helpers;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyVersion("1.0.3.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AscendantEnchantments
{
	internal static class AudioFeedback
	{
		private sealed class Request
		{
			public string Cue;

			public Vector3 Point;
		}

		private sealed class Voice
		{
			public GameObject Go;

			public Component Source;

			public double End;
		}

		internal static readonly Dictionary<string, string> Clips = new Dictionary<string, string>
		{
			{ "Ice", "ZAIceshatterHit" },
			{ "Explosion", "CC_SuperExplosion" },
			{ "Slash", "Player_Movement_Sword_Hit_M_02" },
			{ "Spear", "Player_Movement_Sword_Hit_M_02" },
			{ "Ready", "Player_Movement_Sword_Hit_Overlay_M_04" },
			{ "SpearSmoke", "Player_Movement_Sword_Hit_Overlay_M_04" }
		};

		private static readonly Queue<Request> pending = new Queue<Request>();

		private static readonly List<Voice> voices = new List<Voice>();

		private static readonly Dictionary<string, Object> clips = new Dictionary<string, Object>();

		private static readonly Dictionary<string, double> lastPlayed = new Dictionary<string, double>();

		private static double scanAt;

		private static Type clipType;

		private static Type sourceType;

		internal static void Enqueue(string cue, Vector3 point)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (Clips.ContainsKey(cue) && pending.Count < 32)
			{
				pending.Enqueue(new Request
				{
					Cue = cue,
					Point = point
				});
			}
		}

		internal static void Update()
		{
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: 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_0179: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				pending.Clear();
				return;
			}
			voices.RemoveAll((Voice v) => !Object.op_Implicit((Object)(object)v.Go));
			if (clipType == null)
			{
				clipType = AccessTools.TypeByName("UnityEngine.AudioClip");
			}
			if (sourceType == null)
			{
				sourceType = AccessTools.TypeByName("UnityEngine.AudioSource");
			}
			if (clipType == null || sourceType == null)
			{
				return;
			}
			if (Plugin.Now >= scanAt && (pending.Count > 0 || clips.Count < 5))
			{
				scanAt = Plugin.Now + 5.0;
				Object[] array = Resources.FindObjectsOfTypeAll(clipType);
				foreach (Object val in array)
				{
					if (Object.op_Implicit(val) && Clips.ContainsValue(val.name))
					{
						clips[val.name] = val;
					}
				}
			}
			if (voices.Count < 16 && ((pending.Count > 0 && !voices.Exists((Voice v) => Object.op_Implicit((Object)(object)v.Go) && v.End <= Plugin.Now)) || !((Character)Player.m_localPlayer).InAttack()))
			{
				GameObject val2 = new GameObject("AAE_PooledAudio");
				Component val3 = val2.AddComponent(sourceType);
				sourceType.GetProperty("playOnAwake").SetValue(val3, false, null);
				sourceType.GetProperty("spatialBlend").SetValue(val3, 1f, null);
				sourceType.GetProperty("minDistance").SetValue(val3, 3f, null);
				sourceType.GetProperty("maxDistance").SetValue(val3, 45f, null);
				voices.Add(new Voice
				{
					Go = val2,
					Source = val3
				});
			}
			while (pending.Count > 0)
			{
				Request request = pending.Dequeue();
				if (Vector3.Distance(((Component)Player.m_localPlayer).transform.position, request.Point) > 60f || (lastPlayed.TryGetValue(request.Cue, out var value) && Plugin.Now - value < 0.04) || !clips.TryGetValue(Clips[request.Cue], out var value2) || !Object.op_Implicit(value2))
				{
					continue;
				}
				Voice voice = voices.Find((Voice v) => Object.op_Implicit((Object)(object)v.Go) && v.End <= Plugin.Now);
				if (voice != null)
				{
					try
					{
						voice.Go.transform.position = request.Point;
						sourceType.GetProperty("clip").SetValue(voice.Source, value2, null);
						sourceType.GetProperty("volume").SetValue(voice.Source, (request.Cue == "SpearSmoke") ? 0.55f : ((request.Cue == "Slash") ? 0.5f : ((request.Cue == "Ready") ? 0.8f : 0.85f)), null);
						float num2 = ((request.Cue == "SpearSmoke") ? 0.7f : ((request.Cue == "Ready") ? 1.4f : 1f));
						sourceType.GetProperty("pitch").SetValue(voice.Source, num2, null);
						sourceType.GetMethod("Play", Type.EmptyTypes).Invoke(voice.Source, null);
						voice.End = Plugin.Now + (double)((float)clipType.GetProperty("length").GetValue(value2, null) / num2) + 0.05;
						lastPlayed[request.Cue] = Plugin.Now;
					}
					catch (Exception)
					{
					}
				}
			}
		}

		internal static void Clear()
		{
			pending.Clear();
			foreach (Voice voice in voices)
			{
				if (Object.op_Implicit((Object)(object)voice.Go))
				{
					Object.Destroy((Object)(object)voice.Go);
				}
			}
			voices.Clear();
			lastPlayed.Clear();
		}
	}
	internal static class Migration
	{
		internal static void Apply(string folder)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			string text = Path.Combine(folder, "settings.json");
			if (!File.Exists(text))
			{
				return;
			}
			JObject val = JObject.Parse(File.ReadAllText(text));
			if ((int?)val["Revision"] >= 10)
			{
				return;
			}
			int valueOrDefault = ((int?)val["Revision"]).GetValueOrDefault();
			JObject val2 = (JObject)val["Effects"];
			if (val2 == null)
			{
				throw new Exception("Missing Effects in settings.json");
			}
			string text2 = Path.Combine(folder, (valueOrDefault < 2) ? "backup-0.1.0" : ((valueOrDefault < 3) ? "backup-0.1.1" : ((valueOrDefault < 4) ? "backup-0.1.3" : ((valueOrDefault < 5) ? "backup-0.1.4" : ((valueOrDefault < 6) ? "backup-0.1.5" : ((valueOrDefault < 7) ? "backup-0.1.6" : ((valueOrDefault < 8) ? "backup-0.1.7" : ((valueOrDefault < 9) ? "backup-1.0.0" : "backup-1.0.1"))))))));
			Directory.CreateDirectory(text2);
			if (!File.Exists(Path.Combine(text2, "settings.json")))
			{
				File.Copy(text, Path.Combine(text2, "settings.json"));
			}
			if (valueOrDefault < 2)
			{
				val2["Overdrive"][(object)"Chance"] = JToken.op_Implicit(0.1f);
				val2["Impact"][(object)"Chance"] = JToken.op_Implicit(0.4f);
				val2["Impact"][(object)"Duration"] = JToken.op_Implicit(5f);
				val2["Gale"][(object)"Delay"] = JToken.op_Implicit(0.05f);
				val2["Gale"][(object)"Multiplier"] = JToken.op_Implicit(0.2f);
				val2["Gale"][(object)"ActionSpeed"] = JToken.op_Implicit(10f);
			}
			if (valueOrDefault < 3)
			{
				val2["Impact"][(object)"Duration"] = JToken.op_Implicit(4f);
				val2["Gale"][(object)"Delay"] = JToken.op_Implicit(0.1f);
				val2["Gale"][(object)"Duration"] = JToken.op_Implicit(5f);
			}
			if (valueOrDefault < 4)
			{
				val2["Ruler"][(object)"Chance"] = JToken.op_Implicit(0.3f);
				val2["Impact"][(object)"Chance"] = JToken.op_Implicit(0.4f);
				val2["Impact"][(object)"ReloadSpeed"] = JToken.op_Implicit(4f);
			}
			if (valueOrDefault < 5)
			{
				val2["Rampage"][(object)"Chance"] = JToken.op_Implicit(0.5f);
				val2["Flurry"][(object)"Multiplier"] = JToken.op_Implicit(0.4f);
				val2["Oracle"][(object)"Multiplier"] = JToken.op_Implicit(1.6f);
			}
			if (valueOrDefault < 6)
			{
				val2["DeepSleep"][(object)"Chance"] = JToken.op_Implicit(0.3f);
				val2["DeepSleep"][(object)"Multiplier"] = JToken.op_Implicit(1.8f);
				val2["Ruler"][(object)"FieldDuration"] = JToken.op_Implicit(5f);
				val2["Ruler"][(object)"FieldMultiplier"] = JToken.op_Implicit(0.05f);
				val2["Impact"][(object)"Duration"] = JToken.op_Implicit(Math.Max(0.1f, (((float?)val2["Impact"][(object)"Duration"]) ?? 4f) - 1f));
			}
			if (valueOrDefault < 7)
			{
				val2["Ruler"][(object)"FieldMultiplier"] = JToken.op_Implicit(0.1f);
				val2["Rampage"][(object)"Multiplier"] = JToken.op_Implicit(0.9f);
				val2["Flurry"][(object)"Multiplier"] = JToken.op_Implicit(0.5f);
				val2["Gale"][(object)"Duration"] = JToken.op_Implicit(6f);
				val2["Gale"][(object)"Multiplier"] = JToken.op_Implicit(0.3f);
				val2["Chariot"][(object)"Radius"] = JToken.op_Implicit(5.7f);
			}
			if (valueOrDefault < 8)
			{
				val2["Rampage"][(object)"Count"] = JToken.op_Implicit(2);
				val2["Rampage"][(object)"MaxCount"] = JToken.op_Implicit(5);
				val2["Overdrive"][(object)"Chance"] = JToken.op_Implicit(0.15f);
				val2["Overdrive"][(object)"HasteMax"] = JToken.op_Implicit(2);
				val2["Flurry"][(object)"Multiplier"] = JToken.op_Implicit(0.6f);
				val2["Chariot"][(object)"Cooldown"] = JToken.op_Implicit(10);
				val2["Gale"][(object)"Duration"] = JToken.op_Implicit(8);
			}
			if (valueOrDefault < 9)
			{
				val2["Rampage"][(object)"Chance"] = JToken.op_Implicit(0.4f);
				val2["Rampage"][(object)"GeneratedProcChance"] = JToken.op_Implicit(0.2f);
			}
			val2["Rampage"][(object)"Multiplier"] = JToken.op_Implicit(0.8f);
			val["Revision"] = JToken.op_Implicit(10);
			Settings settings = JsonConvert.DeserializeObject<Settings>(((object)val).ToString());
			settings.Validate();
			foreach (Kind value in Enum.GetValues(typeof(Kind)))
			{
				val2[value.ToString()] = (JToken)(object)JObject.FromObject((object)settings.Effects[value]);
			}
			foreach (Kind value2 in Enum.GetValues(typeof(Kind)))
			{
				string text3 = Path.Combine(folder, "effects", value2.ToString() + ".json");
				if (!File.Exists(text3))
				{
					continue;
				}
				JObject val3 = JObject.Parse(File.ReadAllText(text3));
				double? num = (double?)val3["SelectionWeight"];
				if (!num.HasValue || !(Math.Abs(num.Value - 0.18) > 1E-06) || !(Math.Abs(num.Value - 0.15) > 1E-06))
				{
					val3["SelectionWeight"] = JToken.op_Implicit(0.3);
					Directory.CreateDirectory(Path.Combine(text2, "effects"));
					string text4 = Path.Combine(text2, "effects", value2.ToString() + ".json");
					if (!File.Exists(text4))
					{
						File.Copy(text3, text4);
					}
					File.WriteAllText(text3, ((JToken)val3).ToString((Formatting)1, Array.Empty<JsonConverter>()));
				}
			}
			File.WriteAllText(text, ((JToken)val).ToString((Formatting)1, Array.Empty<JsonConverter>()));
			UpdateText(folder, text2, "Korean", new string[6][]
			{
				new string[3] { "aae_ruler_desc", "공격 시 일정 확률로 얼음검을 떨어뜨려 주변 적에게 피해를 주고 크게 둔화시킵니다.", "공격 시 일정 확률로 얼음검을 떨어뜨려 주변 적을 둔화시키고 얼음 장판을 남깁니다." },
				new string[3] { "aae_oracle_desc", "특수공격 시 자신과 아군을 치유하는 성역을 생성합니다.", "특수공격으로 주변 적을 베고 자신과 아군을 치유하는 성역을 생성합니다." },
				new string[3] { "aae_chariot_desc", "특수공격으로 다음 한 발을 특수탄으로 바꿉니다. 발사하면 세 발의 추가탄이 쏟아집니다.", "특수공격으로 특수탄을 장전합니다. 탄이 닿은 곳에 세 발의 추가탄이 쏟아집니다." },
				new string[3] { "aae_flurry_desc", "5회 적중할 때마다 적을 빠르게 다섯 번 추가로 베어냅니다.", "5회 적중할 때마다 주변 적을 빠르게 다섯 번 베어냅니다." },
				new string[3] { "aae_impact_desc", "공격 시 일정 확률로 무지개 폭발을 세 번 일으키고 마법 장판을 남깁니다.", "공격 시 일정 확률로 무지개 폭발을 세 번 일으키고 마법 장판을 남기며, 다음 재장전이 크게 빨라집니다." },
				new string[3] { "aae_chariot_desc", "특수공격으로 다음 한 발을 특수탄으로 바꿉니다. 명중하면 세 발의 추적탄이 쏟아집니다.", "특수공격으로 특수탄을 장전합니다. 탄이 닿은 곳에 세 발의 추가탄이 쏟아집니다." }
			});
			UpdateText(folder, text2, "English", new string[6][]
			{
				new string[3] { "aae_ruler_desc", "Hits may drop an ice blade, damaging and greatly slowing nearby enemies.", "Hits may drop an ice blade, slowing nearby enemies and leaving a damaging frost field." },
				new string[3] { "aae_oracle_desc", "Secondary attacks create a sanctuary that heals you and allies.", "Secondary attacks slash nearby enemies and create a sanctuary that heals you and allies." },
				new string[3] { "aae_chariot_desc", "Secondary attack empowers your next shot. Firing releases three additional rounds.", "Secondary attack loads a special round. Three additional rounds descend on its impact point." },
				new string[3] { "aae_flurry_desc", "Every fifth hit unleashes five rapid extra slashes.", "Every fifth hit unleashes five rapid slashes against nearby enemies." },
				new string[3] { "aae_impact_desc", "Hits may trigger three rainbow explosions and leave a magic field.", "Hits may trigger three rainbow explosions, leave a magic field, and greatly speed up your next reload." },
				new string[3] { "aae_chariot_desc", "Secondary attack empowers your next shot. On impact, three seeking rounds descend.", "Secondary attack loads a special round. Three additional rounds descend on its impact point." }
			});
			UpdateText(folder, text2, "Korean", new string[1][] { new string[3] { "aae_impact_desc", "공격 시 일정 확률로 무지개 폭발을 세 번 일으키고 마법 장판을 남기며, 다음 재장전이 크게 빨라집니다.", "공격 시 일정 확률로 무지개 폭발을 세 번 일으키고 마법 장판을 남기며, 다음 충전이 크게 빨라집니다." } });
			UpdateText(folder, text2, "English", new string[1][] { new string[3] { "aae_impact_desc", "Hits may trigger three rainbow explosions, leave a magic field, and greatly speed up your next reload.", "Hits may trigger three rainbow explosions, leave a magic field, and greatly speed up your next recharge." } });
			UpdateText(folder, text2, "Korean", new string[1][] { new string[3] { "aae_chariot_desc", "특수공격으로 특수탄을 장전합니다. 탄이 닿은 곳에 세 발의 추가탄이 쏟아집니다.", "특수탄 적중 시 세 발의 폭발탄이 대상을 추적합니다. 빗나가면 착탄 지점을 공격합니다." } });
			UpdateText(folder, text2, "English", new string[1][] { new string[3] { "aae_chariot_desc", "Secondary attack loads a special round. Three additional rounds descend on its impact point.", "Special rounds call down three explosive rounds that track the enemy hit, or strike the impact point on a miss." } });
			UpdateText(folder, text2, "Korean", new string[1][] { new string[3] { "aae_rampage_desc", "공격 시 일정 확률로 추적창을 소환합니다. 추적창은 최대 5개까지 유지됩니다.", "공격 시 일정 확률로 추적창 2개를 소환합니다. 창으로 적을 처치하면 최대 5개까지 보충됩니다." } });
			UpdateText(folder, text2, "English", new string[1][] { new string[3] { "aae_rampage_desc", "Hits may summon a seeking spear. Up to five spears can remain active.", "Hits may summon two seeking spears. Spear kills replenish your spears up to five." } });
			UpdateText(folder, text2, "Korean", new string[1][] { new string[3] { "aae_rampage_desc", "공격 시 일정 확률로 추적창 2개를 소환합니다. 창으로 적을 처치하면 최대 5개까지 보충됩니다.", "공격 시 추적창 2개를 소환할 수 있습니다. 창의 적중으로도 발동하며, 창으로 처치하면 최대 5개까지 보충됩니다." } });
			UpdateText(folder, text2, "English", new string[1][] { new string[3] { "aae_rampage_desc", "Hits may summon two seeking spears. Spear kills replenish your spears up to five.", "Hits may summon two seeking spears. Spear hits can also trigger this effect; spear kills replenish up to five." } });
		}

		private static void UpdateText(string folder, string backup, string language, string[][] changes)
		{
			string text = Path.Combine(folder, "localizations", language + ".json");
			if (!File.Exists(text))
			{
				return;
			}
			JObject val = JObject.Parse(File.ReadAllText(text));
			bool flag = false;
			foreach (string[] array in changes)
			{
				if ((string)val[array[0]] == array[1])
				{
					val[array[0]] = JToken.op_Implicit(array[2]);
					flag = true;
				}
			}
			if (flag)
			{
				string text2 = Path.Combine(backup, "localizations");
				Directory.CreateDirectory(text2);
				if (!File.Exists(Path.Combine(text2, language + ".json")))
				{
					File.Copy(text, Path.Combine(text2, language + ".json"));
				}
				File.WriteAllText(text, ((JToken)val).ToString((Formatting)1, Array.Empty<JsonConverter>()));
			}
		}
	}
	internal static class ReloadTuning
	{
		internal const float EitrCost = 30f;

		private static readonly FieldInfo Run = AccessTools.Field(typeof(Character), "m_run");

		private static readonly FieldInfo Move = AccessTools.Field(typeof(Character), "m_moveDir");

		private static readonly FieldInfo Queue = AccessTools.Field(typeof(Player), "m_actionQueue");

		private static readonly ConditionalWeakTable<object, object> paid = new ConditionalWeakTable<object, object>();

		[ThreadStatic]
		internal static Player Checking;

		internal static bool Sprinting(Player p)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Character)p).IsRunning())
			{
				if ((bool)Run.GetValue(p))
				{
					Vector3 val = (Vector3)Move.GetValue(p);
					return ((Vector3)(ref val)).sqrMagnitude > 0.0001f;
				}
				return false;
			}
			return true;
		}

		internal static bool IsStaff(ItemData w)
		{
			if (Object.op_Implicit((Object)(object)w?.m_dropPrefab))
			{
				return ((Object)w.m_dropPrefab).name == "PrisvalliaIlluminant_CL";
			}
			return false;
		}

		internal static object Action(Player p)
		{
			if (!(Queue.GetValue(p) is IList list))
			{
				return null;
			}
			foreach (object item in list)
			{
				if (Convert.ToInt32(AccessTools.Field(item.GetType(), "m_type").GetValue(item)) == 2 && AccessTools.Field(item.GetType(), "m_item").GetValue(item) == ((Humanoid)p).GetCurrentWeapon())
				{
					return item;
				}
			}
			return null;
		}

		internal static bool Active(Player p)
		{
			if (!Object.op_Implicit((Object)(object)p) || ((Character)p).InAttack())
			{
				return false;
			}
			ItemData currentWeapon = ((Humanoid)p).GetCurrentWeapon();
			if (!IsStaff(currentWeapon) && (!Object.op_Implicit((Object)(object)currentWeapon?.m_dropPrefab) || !(((Object)currentWeapon.m_dropPrefab).name == "RavalonAnnihilating_CL")))
			{
				return false;
			}
			IList list = Queue.GetValue(p) as IList;
			object obj = Action(p);
			if (list != null && list.Count > 0 && list[0] == obj && (float)AccessTools.Field(typeof(Player), "m_actionQueuePause").GetValue(p) <= 0f)
			{
				return (string)AccessTools.Field(typeof(Player), "m_actionAnimation").GetValue(p) == (string)AccessTools.Field(obj.GetType(), "m_animation").GetValue(obj);
			}
			return false;
		}

		internal static bool CanQueue(Player p)
		{
			if (IsStaff(((Humanoid)p).GetCurrentWeapon()))
			{
				if (!Sprinting(p))
				{
					if (Action(p) == null)
					{
						return p.GetEitr() >= 30f;
					}
					return true;
				}
				return false;
			}
			return true;
		}

		internal static void Prepare(Player p)
		{
			if (IsStaff(((Humanoid)p).GetCurrentWeapon()))
			{
				object obj = Action(p);
				if (obj != null)
				{
					AccessTools.Field(obj.GetType(), "m_eitrDrain").SetValue(obj, 0f);
				}
			}
		}

		internal static bool TryCharge(Player p)
		{
			object obj = Action(p);
			if (obj == null)
			{
				return false;
			}
			if (paid.TryGetValue(obj, out var _))
			{
				return true;
			}
			if (p.GetEitr() < 30f)
			{
				return false;
			}
			AccessTools.Field(obj.GetType(), "m_eitrDrain").SetValue(obj, 0f);
			((Character)p).UseEitr(30f);
			paid.Add(obj, new object());
			return true;
		}
	}
	[HarmonyPatch(typeof(Player), "UpdateWeaponLoading")]
	internal static class StaffLoadingScope
	{
		[HarmonyPrefix]
		private static void Prefix(Player __instance, ItemData weapon, out Player __state)
		{
			__state = ReloadTuning.Checking;
			if (Plugin.Ready && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && ReloadTuning.IsStaff(weapon))
			{
				ReloadTuning.Checking = __instance;
			}
		}

		[HarmonyFinalizer]
		private static Exception Finalizer(Player __state, Exception __exception)
		{
			ReloadTuning.Checking = __state;
			return __exception;
		}
	}
	[HarmonyPatch(typeof(Character), "TryUseEitr")]
	internal static class StaffLoadingProbe
	{
		[HarmonyPrefix]
		private static bool Prefix(Character __instance, float eitrUse, ref bool __result)
		{
			if (!Object.op_Implicit((Object)(object)ReloadTuning.Checking) || (Object)(object)__instance != (Object)(object)ReloadTuning.Checking || eitrUse != ((Humanoid)ReloadTuning.Checking).GetCurrentWeapon().m_shared.m_attack.m_reloadEitrDrain)
			{
				return true;
			}
			__result = ReloadTuning.CanQueue(ReloadTuning.Checking);
			return false;
		}
	}
	[HarmonyPatch(typeof(Player), "QueueReloadAction")]
	internal static class FlatStaffRecharge
	{
		[HarmonyPrefix]
		private static bool Prefix(Player __instance)
		{
			if (Plugin.Ready && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				return ReloadTuning.CanQueue(__instance);
			}
			return true;
		}

		[HarmonyPostfix]
		private static void Postfix(Player __instance)
		{
			if (Plugin.Ready && (Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				ReloadTuning.Prepare(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(Player), "UpdateActionQueue")]
	internal static class StaffRechargeExecution
	{
		[HarmonyPrefix]
		private static bool Prefix(Player __instance, float dt)
		{
			if (!Plugin.Ready || (Object)(object)__instance != (Object)(object)Player.m_localPlayer || !ReloadTuning.IsStaff(((Humanoid)__instance).GetCurrentWeapon()))
			{
				return true;
			}
			ReloadTuning.Prepare(__instance);
			object obj = ReloadTuning.Action(__instance);
			IList list = AccessTools.Field(typeof(Player), "m_actionQueue").GetValue(__instance) as IList;
			if (obj == null || list == null || list.Count == 0 || list[0] != obj)
			{
				return true;
			}
			if (ReloadTuning.Sprinting(__instance))
			{
				list.Remove(obj);
				return true;
			}
			if (dt <= 0f || ((Character)__instance).InAttack() || (float)AccessTools.Field(typeof(Player), "m_actionQueuePause").GetValue(__instance) > 0f)
			{
				return true;
			}
			if (!ReloadTuning.TryCharge(__instance))
			{
				list.Remove(obj);
				return true;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Aoe), "Awake")]
	internal static class ShorterPrisvalliaField
	{
		[HarmonyPostfix]
		private static void Postfix(Aoe __instance)
		{
			if (Plugin.Ready && ((Object)((Component)__instance).gameObject).name == "Prisvallia_Aoe(Clone)")
			{
				__instance.m_ttl = Math.Max(0.1f, __instance.m_ttl - 1f);
			}
		}
	}
	internal static class VisualMaterial
	{
		internal static Material Create()
		{
			//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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//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_010f: Expected O, but got Unknown
			Shader val = Shader.Find("Legacy Shaders/Particles/Additive") ?? Shader.Find("Particles/Standard Unlit");
			if (Object.op_Implicit((Object)(object)val))
			{
				Material val2 = new Material(val);
				val2.SetInt("_SrcBlend", 5);
				val2.SetInt("_DstBlend", 1);
				val2.SetInt("_ZWrite", 0);
				val2.renderQueue = 3100;
				return val2;
			}
			GameObject val3 = (Object.op_Implicit((Object)(object)ZNetScene.instance) ? ZNetScene.instance.GetPrefab("Excevior_ShredSpecial") : null);
			Material val4 = (Object.op_Implicit((Object)(object)val3) ? (from r in val3.GetComponentsInChildren<Renderer>(true)
				where ((object)r).GetType().Name == "ParticleSystemRenderer"
				select r).SelectMany((Renderer r) => r.sharedMaterials).FirstOrDefault((Func<Material, bool>)((Material m) => Object.op_Implicit((Object)(object)m))) : null);
			if (Object.op_Implicit((Object)(object)val4))
			{
				return new Material(val4)
				{
					renderQueue = 3100
				};
			}
			return null;
		}
	}
	internal static class StaminaPolicy
	{
		internal static bool IsStartProbe(float amount, float computed)
		{
			if (computed > 0f && !float.IsNaN(computed))
			{
				return Math.Abs(amount - (computed + 0.1f)) < 1E-05f;
			}
			return false;
		}

		internal static bool CanAfford(float current, float cost)
		{
			return current >= cost;
		}
	}
	internal static class RuleFields
	{
		internal static readonly Dictionary<Kind, string[]> Used = new Dictionary<Kind, string[]>
		{
			{
				Kind.Ruler,
				new string[9] { "Weapon", "Chance", "Multiplier", "Radius", "Duration", "Delay", "FieldDuration", "FieldMultiplier", "Slow" }
			},
			{
				Kind.Rampage,
				new string[7] { "Weapon", "Chance", "GeneratedProcChance", "Multiplier", "Duration", "Count", "MaxCount" }
			},
			{
				Kind.FlameKing,
				new string[5] { "Weapon", "Chance", "Multiplier", "Radius", "Delay" }
			},
			{
				Kind.Oracle,
				new string[5] { "Weapon", "Multiplier", "Radius", "Duration", "Heal" }
			},
			{
				Kind.DeepSleep,
				new string[3] { "Weapon", "Chance", "Multiplier" }
			},
			{
				Kind.Flurry,
				new string[6] { "Weapon", "Multiplier", "Radius", "Delay", "Count", "MaxCount" }
			},
			{
				Kind.Overdrive,
				new string[6] { "Weapon", "Chance", "Multiplier", "Duration", "HasteStep", "HasteMax" }
			},
			{
				Kind.Impact,
				new string[9] { "Weapon", "Chance", "Multiplier", "Radius", "Duration", "Delay", "Count", "SecondaryMultiplier", "ReloadSpeed" }
			},
			{
				Kind.Gale,
				new string[6] { "Weapon", "Multiplier", "Duration", "Delay", "Cooldown", "ActionSpeed" }
			},
			{
				Kind.Chariot,
				new string[6] { "Weapon", "Multiplier", "Radius", "Count", "SecondaryMultiplier", "Cooldown" }
			}
		};

		internal static Kind KindFor(string weapon)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<Kind, Rule> effect in Settings.Defaults().Effects)
			{
				if (effect.Value.Weapon == weapon)
				{
					return effect.Key;
				}
			}
			throw new JsonSerializationException("Unknown effect weapon: " + weapon);
		}

		internal static FieldInfo Field(string name)
		{
			return typeof(Rule).GetField(name, BindingFlags.Instance | BindingFlags.Public);
		}

		internal static void Validate(Kind kind, Rule rule)
		{
			string[] array = Used[kind];
			foreach (string text in array)
			{
				if (!(text == "Weapon"))
				{
					double num = Convert.ToDouble(Field(text).GetValue(rule));
					if (double.IsNaN(num) || double.IsInfinity(num) || num < 0.0)
					{
						throw new Exception("Invalid " + kind.ToString() + "." + text);
					}
					bool flag = false;
					switch (text)
					{
					case "Chance":
					case "GeneratedProcChance":
						flag = num > 1.0;
						break;
					case "Slow":
						flag = num >= 1.0;
						break;
					case "Delay":
					case "Duration":
						flag = num <= 0.0;
						break;
					case "FieldDuration":
						flag = num <= 0.0 || num > 30.0;
						break;
					case "Count":
					case "MaxCount":
						flag = num < 1.0 || num > 20.0;
						break;
					case "Radius":
						flag = num > 30.0;
						break;
					case "HasteMax":
						flag = num > 3.0;
						break;
					case "ReloadSpeed":
						flag = num < 1.0 || num > 10.0;
						break;
					case "ActionSpeed":
						flag = num < 1.0 || num > 20.0;
						break;
					}
					if (flag)
					{
						throw new Exception("Unsafe range " + kind.ToString() + "." + text);
					}
				}
			}
		}
	}
	public sealed class RuleJsonConverter : JsonConverter
	{
		public override bool CanConvert(Type type)
		{
			return type == typeof(Rule);
		}

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			if (value == null)
			{
				writer.WriteNull();
				return;
			}
			Rule rule = (Rule)value;
			Kind key = RuleFields.KindFor(rule.Weapon);
			writer.WriteStartObject();
			string[] array = RuleFields.Used[key];
			foreach (string text in array)
			{
				writer.WritePropertyName(text);
				serializer.Serialize(writer, RuleFields.Field(text).GetValue(rule));
			}
			writer.WriteEndObject();
		}

		public override object ReadJson(JsonReader reader, Type type, object existing, JsonSerializer serializer)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			if ((int)reader.TokenType == 11)
			{
				return null;
			}
			JObject val = JObject.Load(reader);
			Kind key = RuleFields.KindFor((string)val["Weapon"]);
			Rule rule = Settings.Defaults().Effects[key];
			string[] array = RuleFields.Used[key];
			JToken val2 = default(JToken);
			foreach (string text in array)
			{
				if (val.TryGetValue(text, ref val2))
				{
					FieldInfo fieldInfo = RuleFields.Field(text);
					fieldInfo.SetValue(rule, val2.ToObject(fieldInfo.FieldType, serializer));
				}
			}
			return rule;
		}
	}
	internal static class ChariotStorage
	{
		internal const string Key = "aae_chariot_loaded";

		internal static bool Ready(IDictionary<string, string> data)
		{
			if (data != null && data.TryGetValue("aae_chariot_loaded", out var value))
			{
				return value == "1";
			}
			return false;
		}

		internal static void Store(IDictionary<string, string> data)
		{
			data["aae_chariot_loaded"] = "1";
		}

		internal static void Consume(IDictionary<string, string> data)
		{
			if (data != null)
			{
				data.Remove("aae_chariot_loaded");
				if (data.ContainsKey("crossbowLoaded"))
				{
					data["crossbowLoaded"] = "false";
				}
			}
		}
	}
	internal sealed class DeferredQueue<T>
	{
		private readonly Queue<T> queue = new Queue<T>();

		internal void Add(T entry)
		{
			queue.Enqueue(entry);
		}

		internal void Clear()
		{
			queue.Clear();
		}

		internal void Drain(Action<T> execute, Action<Exception> failed)
		{
			int count = queue.Count;
			while (count-- > 0 && queue.Count > 0)
			{
				T obj = queue.Dequeue();
				try
				{
					execute(obj);
				}
				catch (Exception obj2)
				{
					failed(obj2);
				}
			}
		}
	}
	internal sealed class FieldGeneration
	{
		private long current;

		internal long Replace()
		{
			return ++current;
		}

		internal bool IsCurrent(long id)
		{
			return id == current;
		}
	}
	internal static class EffectPalette
	{
		private static Color? seravi;

		private static Color? excevior;

		private static Color? quel;

		internal static Color Quel
		{
			get
			{
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				Color? val = quel;
				if (!val.HasValue)
				{
					Color? val2 = (quel = Sample("AAE_QuelImpact", new Color(0.4f, 0.9f, 1f)));
					return val2.Value;
				}
				return val.GetValueOrDefault();
			}
		}

		internal static Color Seravi
		{
			get
			{
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				Color? val = seravi;
				if (!val.HasValue)
				{
					Color? val2 = (seravi = Sample("Seravi_DeificStrike1", new Color(1f, 0.75f, 0.15f)));
					return val2.Value;
				}
				return val.GetValueOrDefault();
			}
		}

		internal static Color Excevior
		{
			get
			{
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				Color? val = excevior;
				if (!val.HasValue)
				{
					Color? val2 = (excevior = Sample("Excevior_SpecialStrike", new Color(0.6f, 0.15f, 1f)));
					return val2.Value;
				}
				return val.GetValueOrDefault();
			}
		}

		internal static Color Sample(string name, Color fallback)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Visuals.Resolve(name);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return fallback;
			}
			foreach (Material item in val.GetComponentsInChildren<Renderer>(true).SelectMany((Renderer r) => r.sharedMaterials))
			{
				if (Object.op_Implicit((Object)(object)item) && item.HasProperty("_EmissionColor"))
				{
					Color color = item.GetColor("_EmissionColor");
					if (Saturated(color))
					{
						return Normalize(color);
					}
				}
			}
			Component[] componentsInChildren = val.GetComponentsInChildren<Component>(true);
			foreach (Component val2 in componentsInChildren)
			{
				if (!Object.op_Implicit((Object)(object)val2) || !(((object)val2).GetType().FullName == "UnityEngine.ParticleSystem"))
				{
					continue;
				}
				object value = ((object)val2).GetType().GetProperty("main").GetValue(val2, null);
				object value2 = value.GetType().GetProperty("startColor").GetValue(value, null);
				string[] array = new string[3] { "colorMax", "colorMin", "color" };
				foreach (string name2 in array)
				{
					PropertyInfo property = value2.GetType().GetProperty(name2);
					if (property != null)
					{
						Color c = (Color)property.GetValue(value2, null);
						if (Saturated(c))
						{
							return Normalize(c);
						}
					}
				}
			}
			foreach (Material item2 in val.GetComponentsInChildren<Renderer>(true).SelectMany((Renderer r) => r.sharedMaterials))
			{
				if (!Object.op_Implicit((Object)(object)item2))
				{
					continue;
				}
				string[] array = new string[3] { "_EmissionColor", "_TintColor", "_Color" };
				foreach (string text in array)
				{
					if (item2.HasProperty(text))
					{
						Color color2 = item2.GetColor(text);
						if (Saturated(color2))
						{
							return Normalize(color2);
						}
					}
				}
			}
			return fallback;
		}

		private static bool Saturated(Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return Mathf.Max(c.r, Mathf.Max(c.g, c.b)) - Mathf.Min(c.r, Mathf.Min(c.g, c.b)) > 0.12f;
		}

		private static Color Normalize(Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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)
			float num = Mathf.Max(c.r, Mathf.Max(c.g, c.b));
			return new Color(c.r / num, c.g / num, c.b / num, 0.8f);
		}
	}
	internal static class SlashFeedback
	{
		private sealed class Slot
		{
			public GameObject Go;

			public Component[] Particles;

			public readonly List<Material> Materials = new List<Material>();

			public int Frame;

			public double End;

			public bool Ready;
		}

		private sealed class Sequence
		{
			public Vector3 Point;

			public Vector3 Direction;

			public int Left;

			public int Index;

			public float Delay;

			public float Radius;

			public double Next;
		}

		private static readonly List<Slot> slots = new List<Slot>();

		private static readonly List<Sequence> sequences = new List<Sequence>();

		private static GameObject staging;

		private static double retry;

		private static bool Forbidden(Component c)
		{
			if (Object.op_Implicit((Object)(object)c))
			{
				if (!(c is MonoBehaviour) && !((object)c).GetType().Name.Contains("Collider") && !(((object)c).GetType().Name == "Rigidbody") && !(((object)c).GetType().Name == "AudioSource"))
				{
					return ((object)c).GetType().Name == "Light";
				}
				return true;
			}
			return false;
		}

		internal static void Enqueue(Vector3 point, Vector3 direction, int count, float delay, float radius)
		{
			//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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && !(Vector3.Distance(point, ((Component)Player.m_localPlayer).transform.position) > 65f) && sequences.Count < 16)
			{
				sequences.Add(new Sequence
				{
					Point = point,
					Direction = ((((Vector3)(ref direction)).sqrMagnitude > 0.01f) ? direction : Vector3.forward),
					Left = count,
					Delay = delay,
					Radius = radius,
					Next = Plugin.Now
				});
			}
		}

		private static void Warm()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: 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_01d2: 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_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			if (slots.Count >= 12 || Plugin.Now < retry || ((Character)Player.m_localPlayer).InAttack() || sequences.Count > 0)
			{
				return;
			}
			GameObject val = Visuals.Resolve("Seravi_DeificStrike1");
			if (!Object.op_Implicit((Object)(object)val))
			{
				retry = Plugin.Now + 3.0;
				return;
			}
			if (!Object.op_Implicit((Object)(object)staging))
			{
				staging = new GameObject("AAE_SlashStaging");
				staging.SetActive(false);
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, staging.transform, false);
			val2.SetActive(false);
			Slot slot = new Slot
			{
				Go = val2,
				Frame = Time.frameCount
			};
			slots.Add(slot);
			Component[] componentsInChildren = val2.GetComponentsInChildren<Component>(true);
			foreach (Component val3 in componentsInChildren)
			{
				if (Forbidden(val3))
				{
					Behaviour val4 = (Behaviour)(object)((val3 is Behaviour) ? val3 : null);
					if (val4 != null)
					{
						val4.enabled = false;
					}
					Object.Destroy((Object)(object)val3);
				}
			}
			slot.Particles = (from c in val2.GetComponentsInChildren<Component>(true)
				where Object.op_Implicit((Object)(object)c) && ((object)c).GetType().FullName == "UnityEngine.ParticleSystem"
				select c).ToArray();
			componentsInChildren = slot.Particles;
			foreach (Component val5 in componentsInChildren)
			{
				object value = ((object)val5).GetType().GetProperty("main").GetValue(val5, null);
				value.GetType().GetProperty("maxParticles").SetValue(value, 64, null);
				PropertyInfo property = value.GetType().GetProperty("startColor");
				property.SetValue(value, Activator.CreateInstance(property.PropertyType, (object)new Color(EffectPalette.Excevior.r, EffectPalette.Excevior.g, EffectPalette.Excevior.b, 1f)), null);
				object value2 = ((object)val5).GetType().GetProperty("colorOverLifetime").GetValue(val5, null);
				value2.GetType().GetProperty("enabled").SetValue(value2, false, null);
			}
			Renderer[] componentsInChildren2 = val2.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer obj in componentsInChildren2)
			{
				obj.shadowCastingMode = (ShadowCastingMode)0;
				obj.receiveShadows = false;
				Material[] materials = obj.materials;
				foreach (Material val6 in materials)
				{
					slot.Materials.Add(val6);
					string[] array = new string[7] { "_Color", "_TintColor", "_BaseColor", "_EmissionColor", "_color1", "_color2", "_RendererColor" };
					foreach (string text in array)
					{
						if (val6.HasProperty(text))
						{
							val6.SetColor(text, new Color(EffectPalette.Excevior.r * 1.35f, EffectPalette.Excevior.g * 1.35f, EffectPalette.Excevior.b * 1.35f, 1f));
						}
					}
				}
			}
		}

		internal static void Update()
		{
			//IL_0375: 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_022b: 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_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				sequences.Clear();
				return;
			}
			for (int num = slots.Count - 1; num >= 0; num--)
			{
				if (!Object.op_Implicit((Object)(object)slots[num].Go))
				{
					foreach (Material material in slots[num].Materials)
					{
						if (Object.op_Implicit((Object)(object)material))
						{
							Object.Destroy((Object)(object)material);
						}
					}
					slots.RemoveAt(num);
				}
			}
			try
			{
				Warm();
			}
			catch (Exception ex)
			{
				retry = Plugin.Now + 30.0;
				Plugin.Log.LogWarning((object)("Slash warmup failed: " + ex.Message));
			}
			foreach (Slot slot2 in slots)
			{
				if (Object.op_Implicit((Object)(object)slot2.Go))
				{
					if (!slot2.Ready && Time.frameCount > slot2.Frame && !slot2.Go.GetComponentsInChildren<Component>(true).Any(Forbidden))
					{
						slot2.Ready = true;
						slot2.Go.transform.SetParent((Transform)null, true);
					}
					if (slot2.End <= Plugin.Now && slot2.Go.activeSelf)
					{
						slot2.Go.SetActive(false);
					}
				}
			}
			for (int num2 = sequences.Count - 1; num2 >= 0; num2--)
			{
				Sequence sequence = sequences[num2];
				if (!(Plugin.Now < sequence.Next))
				{
					Slot slot = slots.Find((Slot s) => s.Ready && Object.op_Implicit((Object)(object)s.Go) && s.End <= Plugin.Now);
					if (slot != null)
					{
						slot.Go.transform.position = sequence.Point;
						slot.Go.transform.rotation = Quaternion.LookRotation(sequence.Direction) * Quaternion.Euler(0f, 0f, (float)((sequence.Index % 5 - 2) * 22));
						slot.Go.transform.localScale = Vector3.one * Mathf.Clamp(sequence.Radius / 4f, 0.25f, 3f);
						slot.End = Plugin.Now + 0.28;
						slot.Go.SetActive(true);
						Component[] particles = slot.Particles;
						foreach (Component val in particles)
						{
							if (Object.op_Implicit((Object)(object)val))
							{
								((object)val).GetType().GetMethod("Clear", new Type[1] { typeof(bool) })?.Invoke(val, new object[1] { false });
								((object)val).GetType().GetMethod("Play", new Type[1] { typeof(bool) })?.Invoke(val, new object[1] { false });
							}
						}
					}
					AudioFeedback.Enqueue("Slash", sequence.Point);
					sequence.Left--;
					sequence.Index++;
					sequence.Next = Plugin.Now + (double)sequence.Delay;
					if (sequence.Left <= 0)
					{
						sequences.RemoveAt(num2);
					}
				}
			}
		}

		internal static void Clear()
		{
			foreach (Slot slot in slots)
			{
				if (Object.op_Implicit((Object)(object)slot.Go))
				{
					Object.Destroy((Object)(object)slot.Go);
				}
				foreach (Material material in slot.Materials)
				{
					if (Object.op_Implicit((Object)(object)material))
					{
						Object.Destroy((Object)(object)material);
					}
				}
			}
			slots.Clear();
			sequences.Clear();
			if (Object.op_Implicit((Object)(object)staging))
			{
				Object.Destroy((Object)(object)staging);
			}
			retry = 0.0;
		}
	}
	[HarmonyPatch(typeof(Character), "RPC_Damage")]
	internal static class ControlHit
	{
		[HarmonyPrefix]
		[HarmonyPriority(800)]
		private static void Prefix(Character __instance, HitData hit)
		{
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!Plugin.Tags.TryGetValue(hit, out var value) || !value.Generated)
				{
					return;
				}
				ZNetView val = Plugin.View(__instance);
				if ((Object)(object)val == (Object)null || !val.IsOwner())
				{
					return;
				}
				ZDO zDO = val.GetZDO();
				double timeSeconds = ZNet.instance.GetTimeSeconds();
				if (value.Kind == Kind.Ruler && !value.Special)
				{
					zDO.Set("aae_slow_end", (long)((timeSeconds + (double)Plugin.Rule(value.Kind).Duration) * 1000.0));
				}
				if (value.Kind == Kind.DeepSleep)
				{
					float num = (float)AccessTools.Field(typeof(Character), "m_staggerDamageFactor").GetValue(__instance);
					string value2 = ((Object)((Component)__instance).gameObject).name.Replace("(Clone)", "");
					if (num <= 0f || Plugin.ConfigValues.StaggerImmunePrefabs.Contains(value2))
					{
						hit.ApplyModifier(2f);
						return;
					}
					zDO.Set("aae_sleep_end", (long)((timeSeconds + 10.0) * 1000.0));
					__instance.Stagger(hit.m_dir);
				}
			}
			catch (Exception e)
			{
				CombatFault.Report("Hit control", e);
			}
		}
	}
	internal static class ControlState
	{
		internal static bool Active(Character c, string key)
		{
			ZNetView val = Plugin.View(c);
			if ((Object)(object)val != (Object)null && val.IsValid() && (Object)(object)ZNet.instance != (Object)null)
			{
				return (double)val.GetZDO().GetLong(key, 0L) / 1000.0 > ZNet.instance.GetTimeSeconds();
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Character), "GetJogSpeedFactor")]
	internal static class SlowJog
	{
		[HarmonyPostfix]
		private static void Postfix(Character __instance, ref float __result)
		{
			if (ControlState.Active(__instance, "aae_slow_end"))
			{
				__result *= 1f - Plugin.Rule(Kind.Ruler).Slow;
			}
		}
	}
	[HarmonyPatch(typeof(Character), "GetRunSpeedFactor")]
	internal static class SlowRun
	{
		[HarmonyPostfix]
		private static void Postfix(Character __instance, ref float __result)
		{
			if (ControlState.Active(__instance, "aae_slow_end"))
			{
				__result *= 1f - Plugin.Rule(Kind.Ruler).Slow;
			}
		}
	}
	internal static class AnimationSpeed
	{
		internal static double Modify(Character c, double speed)
		{
			if (!Plugin.Ready || !Object.op_Implicit((Object)(object)c))
			{
				return speed;
			}
			if (c.IsStaggering() && ControlState.Active(c, "aae_sleep_end"))
			{
				speed *= 0.5;
			}
			else if (c.InAttack() && ControlState.Active(c, "aae_slow_end"))
			{
				speed *= (double)(1f - Plugin.Rule(Kind.Ruler).Slow);
			}
			if (c.IsPlayer() && c.InAttack() && ControlState.Active(c, "aae_haste_end"))
			{
				speed *= (double)(1f + Plugin.View(c).GetZDO().GetFloat("aae_haste", 0f));
			}
			if (c.IsPlayer() && ControlState.Active(c, "aae_storm_end") && (c.InAttack() || (float)AccessTools.Field(typeof(Humanoid), "m_attackDrawTime").GetValue(c) > 0f))
			{
				speed *= (double)Plugin.Rule(Kind.Gale).ActionSpeed;
			}
			if ((Object)(object)c == (Object)(object)Player.m_localPlayer && ReloadTuning.Active((Player)(object)((c is Player) ? c : null)))
			{
				speed = Math.Max(1.0, speed);
				if (ImpactReload.Active((Player)(object)((c is Player) ? c : null)))
				{
					speed *= (double)Plugin.Rule(Kind.Impact).ReloadSpeed;
				}
			}
			return speed;
		}
	}
	[HarmonyPatch(typeof(Character), "CustomFixedUpdate")]
	internal static class StaggerClock
	{
		private static readonly HashSet<int> entered = new HashSet<int>();

		[HarmonyPostfix]
		private static void Postfix(Character __instance)
		{
			if (!ControlState.Active(__instance, "aae_sleep_end"))
			{
				return;
			}
			ZNetView val = Plugin.View(__instance);
			if (!((Object)(object)val == (Object)null) && val.IsOwner())
			{
				if (__instance.IsStaggering())
				{
					entered.Add(((Object)__instance).GetInstanceID());
				}
				else if (entered.Remove(((Object)__instance).GetInstanceID()))
				{
					val.GetZDO().Set("aae_sleep_end", 0L);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Player), "SetWeaponLoaded")]
	internal static class ShellReloadComplete
	{
		[HarmonyPostfix]
		private static void Postfix(Player __instance, ItemData weapon)
		{
			if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				Runtime.Loaded(weapon);
			}
		}
	}
	[HarmonyPatch(typeof(Player), "UpdateAttackBowDraw")]
	internal static class AutomaticBow
	{
		private static readonly FieldInfo Hold = AccessTools.Field(typeof(Character), "m_attackHold");

		private static readonly FieldInfo Draw = AccessTools.Field(typeof(Humanoid), "m_attackDrawTime");

		[HarmonyPrefix]
		private static void Prefix(Player __instance, out int __state)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			__state = 0;
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !Runtime.StormActive)
			{
				return;
			}
			bool num = (bool)Hold.GetValue(__instance);
			float num2 = (float)Draw.GetValue(__instance);
			if (!num)
			{
				Draw.SetValue(__instance, 0f);
				string text = ((Humanoid)__instance).GetCurrentWeapon()?.m_shared.m_attack.m_drawAnimationState;
				if (!string.IsNullOrEmpty(text))
				{
					ZSyncAnimation val = (ZSyncAnimation)AccessTools.Field(typeof(Character), "m_zanim").GetValue(__instance);
					if (Object.op_Implicit((Object)(object)val))
					{
						val.SetBool(text, false);
					}
				}
			}
			else if (num2 >= Plugin.Rule(Kind.Gale).Delay)
			{
				Hold.SetValue(__instance, false);
				__state = 1;
			}
			else if (num2 < 0f)
			{
				Draw.SetValue(__instance, 0f);
			}
		}

		[HarmonyFinalizer]
		private static Exception Finalizer(Player __instance, int __state, Exception __exception)
		{
			if (__state == 1)
			{
				Hold.SetValue(__instance, true);
				Draw.SetValue(__instance, 0f);
			}
			return __exception;
		}
	}
	[HarmonyPatch(typeof(Humanoid), "GetAttackDrawPercentage")]
	internal static class DrawPercent
	{
		[HarmonyPostfix]
		private static void Postfix(Humanoid __instance, ref float __result)
		{
			if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && Runtime.StormActive)
			{
				__result = Mathf.Clamp01((float)AccessTools.Field(typeof(Humanoid), "m_attackDrawTime").GetValue(__instance) / Plugin.Rule(Kind.Gale).Delay);
			}
		}
	}
	[HarmonyPatch(typeof(Attack), "UseAmmo")]
	internal static class FreeArrows
	{
		[HarmonyPrefix]
		private static bool Prefix(Attack __instance, ref ItemData ammoItem, ref bool __result)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if (!Runtime.StormActive || (Object)(Character)Context.CharacterField.GetValue(__instance) != (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			object? value = Context.Weapon.GetValue(__instance);
			ItemData val = (ItemData)((value is ItemData) ? value : null);
			if ((Object)(object)val?.m_dropPrefab == (Object)null || ((Object)val.m_dropPrefab).name != Plugin.Rule(Kind.Gale).Weapon)
			{
				return true;
			}
			object? obj = AccessTools.Method(typeof(Attack), "FindAmmo", (Type[])null, (Type[])null).Invoke(null, new object[2]
			{
				Player.m_localPlayer,
				val
			});
			ammoItem = (ItemData)((obj is ItemData) ? obj : null);
			if (ammoItem == null)
			{
				return true;
			}
			AccessTools.Field(typeof(Attack), "m_ammoItem").SetValue(__instance, ammoItem);
			__result = true;
			return false;
		}
	}
	internal static class SourceWeapons
	{
		private sealed class Entry
		{
			internal Stamp Stamp;

			internal double End;
		}

		private static readonly Dictionary<long, Entry> entries = new Dictionary<long, Entry>();

		internal static void Remember(Stamp s)
		{
			if (s != null && s.SourceWeapon != null)
			{
				if (entries.Count >= 4096)
				{
					Prune();
				}
				if (entries.Count < 4096)
				{
					entries[s.Ticket] = new Entry
					{
						Stamp = s.Copy(),
						End = Plugin.Now + 240.0
					};
				}
			}
		}

		internal static void Restore(Stamp s)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (s != null && Object.op_Implicit((Object)(object)Player.m_localPlayer) && !(s.Player != ((Character)Player.m_localPlayer).GetZDOID()) && entries.TryGetValue(s.Ticket, out var value) && !(value.End <= Plugin.Now) && !(value.Stamp.Player != s.Player) && !(value.Stamp.Weapon != s.Weapon) && value.Stamp.Kind == s.Kind)
			{
				s.SourceWeapon = value.Stamp.SourceWeapon;
			}
		}

		internal static void Prune()
		{
			List<long> list = new List<long>();
			foreach (KeyValuePair<long, Entry> entry in entries)
			{
				if (entry.Value.End <= Plugin.Now)
				{
					list.Add(entry.Key);
				}
			}
			foreach (long item in list)
			{
				entries.Remove(item);
			}
		}

		internal static void Clear()
		{
			entries.Clear();
		}
	}
	internal sealed class SourceWeaponScope : IDisposable
	{
		private static readonly MethodInfo setter = AccessTools.PropertySetter(typeof(HitSource), "FiringWeapon");

		private readonly ItemData previous;

		private readonly bool entered;

		internal SourceWeaponScope(Stamp stamp)
		{
			try
			{
				if (stamp == null)
				{
					return;
				}
				ItemData val = stamp.SourceWeapon;
				if (val == null)
				{
					SourceWeapons.Restore(stamp);
					val = stamp.SourceWeapon;
				}
				if (val == null && Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					ItemData currentWeapon = ((Humanoid)Player.m_localPlayer).GetCurrentWeapon();
					if (Object.op_Implicit((Object)(object)currentWeapon?.m_dropPrefab) && ((Object)currentWeapon.m_dropPrefab).name == stamp.Weapon)
					{
						val = currentWeapon;
					}
				}
				if (val != null && !(setter == null))
				{
					previous = HitSource.FiringWeapon;
					setter.Invoke(null, new object[1] { val });
					entered = true;
				}
			}
			catch (Exception e)
			{
				CombatFault.Report("Source weapon attribution", e);
			}
		}

		public void Dispose()
		{
			if (entered)
			{
				try
				{
					setter.Invoke(null, new object[1] { previous });
				}
				catch (Exception e)
				{
					CombatFault.Report("Source weapon context restore", e);
				}
			}
		}
	}
	internal static class CrossbowCompatibility
	{
		internal static bool Begin(ItemData item)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			if (item?.m_shared?.m_attack == null)
			{
				return false;
			}
			if (!item.m_shared.m_attack.m_requiresReload)
			{
				if (!item.m_customData.TryGetValue("crossbowLoaded_changed", out var value) || !bool.TryParse(value, out var result) || !result)
				{
					return false;
				}
				SharedData val = (SharedData)AccessTools.Method(typeof(object), "MemberwiseClone", (Type[])null, (Type[])null).Invoke(item.m_shared, null);
				val.m_attack = item.m_shared.m_attack.Clone();
				val.m_attack.m_requiresReload = true;
				item.m_shared = val;
			}
			item.m_customData.Remove("crossbowLoaded_changed");
			if (item.m_customData.ContainsKey("crossbowLoaded"))
			{
				item.m_customData["crossbowLoaded"] = "false";
			}
			return true;
		}
	}
	internal sealed class SpecialPressGate
	{
		private bool down;

		internal bool Poll(bool pressed, bool held)
		{
			bool flag = pressed || held;
			bool result = flag && !down;
			down = flag;
			return result;
		}

		internal void Reset()
		{
			down = false;
		}
	}
	internal static class DefinitionDefaults
	{
		internal static string Create(Kind kind, Rule rule)
		{
			string text = "aae_" + kind.ToString().ToLowerInvariant();
			return JsonConvert.SerializeObject((object)new
			{
				Type = "AAE_" + kind,
				DisplayText = "$" + text,
				Description = "$" + text + "_desc",
				Requirements = new
				{
					AllowedItemNames = new string[1] { rule.Weapon },
					AllowedRarities = new string[1] { "Ancient" },
					ExclusiveSelf = true
				},
				SelectionWeight = 0.3,
				CanBeRunified = false,
				Prefixes = new string[1] { "$" + text },
				Suffixes = new string[0]
			}, (Formatting)1);
		}
	}
	[HarmonyPatch(typeof(HitData), "ApplyResistance")]
	internal static class InstantElement
	{
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(HitData __instance)
		{
			if (Plugin.Tags.TryGetValue(__instance, out var value) && value.Generated)
			{
				if (value.Kind == Kind.FlameKing || value.Kind == Kind.Impact)
				{
					__instance.m_damage.m_damage += __instance.m_damage.m_fire;
					__instance.m_damage.m_fire = 0f;
				}
				if (value.Kind == Kind.Ruler)
				{
					__instance.m_damage.m_damage += __instance.m_damage.m_frost;
					__instance.m_damage.m_frost = 0f;
				}
			}
		}
	}
	public enum Kind
	{
		Ruler,
		Rampage,
		FlameKing,
		Oracle,
		DeepSleep,
		Flurry,
		Overdrive,
		Impact,
		Gale,
		Chariot
	}
	[JsonConverter(typeof(RuleJsonConverter))]
	public sealed class Rule
	{
		public string Weapon;

		public float Chance = 0.2f;

		public float Multiplier = 1f;

		public float Radius = 4f;

		public float Duration = 3f;

		public float Delay = 0.1f;

		public float Cooldown = 15f;

		public float SecondaryMultiplier = 1f;

		public float FieldDuration = 5f;

		public float FieldMultiplier = 0.05f;

		public float GeneratedProcChance;

		public int Count = 1;

		public int MaxCount = 5;

		public float ActionSpeed = 1f;

		public float ReloadSpeed = 1f;

		public float Slow = 0.6f;

		public float HasteStep = 0.1f;

		public float HasteMax = 1f;

		public float Heal = 0.1f;
	}
	public sealed class Settings
	{
		public Dictionary<Kind, Rule> Effects = new Dictionary<Kind, Rule>();

		public int Revision;

		public string[] StaggerImmunePrefabs = new string[0];

		public static Settings Defaults()
		{
			return new Settings
			{
				Revision = 10,
				Effects = 
				{
					[Kind.Ruler] = new Rule
					{
						Weapon = "QuelTaliaAwakened_CL",
						Chance = 0.3f,
						Multiplier = 2f,
						Delay = 0.5f,
						FieldMultiplier = 0.1f
					},
					[Kind.Rampage] = new Rule
					{
						Weapon = "HastielRageborn_CL",
						Chance = 0.4f,
						GeneratedProcChance = 0.2f,
						Multiplier = 0.8f,
						Duration = 10f,
						Count = 2,
						MaxCount = 5
					},
					[Kind.FlameKing] = new Rule
					{
						Weapon = "IgnaviusInfernal_CL",
						Multiplier = 1.5f,
						Delay = 0.6f
					},
					[Kind.Oracle] = new Rule
					{
						Weapon = "SeraviDeific_CL",
						Chance = 1f,
						Multiplier = 1.6f,
						Duration = 5f,
						Delay = 1f
					},
					[Kind.DeepSleep] = new Rule
					{
						Weapon = "MavanharFearborn_CL",
						Chance = 0.3f,
						Multiplier = 1.8f
					},
					[Kind.Flurry] = new Rule
					{
						Weapon = "ExceviorPenumbral_CL",
						Chance = 1f,
						Multiplier = 0.6f,
						Count = 5,
						MaxCount = 5
					},
					[Kind.Overdrive] = new Rule
					{
						Weapon = "ZiraluxEffulgent_CL",
						Chance = 0.15f,
						Multiplier = 0.2f,
						Duration = 10f,
						HasteMax = 2f
					},
					[Kind.Impact] = new Rule
					{
						Weapon = "PrisvalliaIlluminant_CL",
						Chance = 0.4f,
						ReloadSpeed = 4f,
						Multiplier = 0.5f,
						Count = 3,
						Duration = 3f,
						SecondaryMultiplier = 0.2f
					},
					[Kind.Gale] = new Rule
					{
						Weapon = "NyphrionWindblessed_CL",
						Chance = 1f,
						Multiplier = 0.3f,
						Duration = 8f,
						Delay = 0.1f,
						ActionSpeed = 10f
					},
					[Kind.Chariot] = new Rule
					{
						Weapon = "RavalonAnnihilating_CL",
						Chance = 1f,
						Radius = 5.7f,
						Multiplier = 3f,
						Count = 3,
						SecondaryMultiplier = 1f,
						Cooldown = 10f
					}
				}
			};
		}

		public void Validate()
		{
			if (Effects == null || Effects.Count != 10 || StaggerImmunePrefabs == null)
			{
				throw new Exception("Expected ten effects and an immunity list");
			}
			foreach (Kind value in Enum.GetValues(typeof(Kind)))
			{
				if (!Effects.ContainsKey(value))
				{
					throw new Exception("Missing " + value);
				}
				Rule rule = Effects[value];
				if (rule == null)
				{
					throw new Exception("Missing rule " + value);
				}
				if (rule.Weapon != Defaults().Effects[value].Weapon)
				{
					throw new Exception("Weapon binding is fixed: " + value);
				}
				RuleFields.Validate(value, rule);
			}
		}
	}
	internal sealed class Stamp
	{
		public Kind Kind;

		public long Ticket;

		public ZDOID Player;

		public float Power;

		public bool Generated;

		public bool Secondary;

		public bool Special;

		public string Weapon;

		[JsonIgnore]
		internal ItemData SourceWeapon;

		public Stamp Copy()
		{
			return (Stamp)MemberwiseClone();
		}
	}
	public static class DamagePolicy
	{
		public static float SleepMultiplier(bool immune, float configured)
		{
			return configured * (float)((!immune) ? 1 : 2);
		}

		public static bool TickCount(ref int count, int threshold)
		{
			count++;
			if (count < threshold)
			{
				return false;
			}
			count = 0;
			return true;
		}
	}
	internal static class BalancePolicy
	{
		internal const float RechargeEitr = 30f;
	}
	internal static class LavaPolicy
	{
		internal static bool IsLavaExplosion(string prefab)
		{
			if (!(prefab == "Ignavius_Aoe"))
			{
				return prefab == "Ignavius_Aoe(Clone)";
			}
			return true;
		}
	}
	internal sealed class ShotCooldown
	{
		internal double ReadyAt { get; private set; }

		internal void Fired(double now, float duration)
		{
			ReadyAt = now + (double)Math.Max(0f, duration);
		}

		internal void Clear()
		{
			ReadyAt = 0.0;
		}
	}
	internal static class Visuals
	{
		private sealed class Entry
		{
			public string Name;

			public GameObject Go;

			public double End;

			public double Start;

			public double RevealAt;

			public ZDOID Follow;

			public Vector3 Position;

			public Vector3 Offset;

			public Vector3 Velocity;

			public Vector3 InitialScale;

			public Color Color;

			public float Size;

			public int PreparedFrame;

			public bool Prepared;

			public bool PhysicalRemoved;

			public bool Live;

			public bool Sword;

			public bool Aura;

			public bool Moving;

			public bool Orbit;

			public string MotionKey;

			public long MotionId;

			public Vector3? Destination;

			public Quaternion Axis = Quaternion.identity;

			public Transform SwordTip;

			public ZDOID Target;

			public ZDOID Actor;

			public float Speed;

			public List<Material> Materials = new List<Material>();
		}

		internal const string Annihilation = "AAE_AnnihilationRound";

		internal const string BowAura = "AAE_BowAura";

		internal const string QuelImpact = "AAE_QuelImpact";

		internal const string LightSlash = "AAE_LightSlash";

		internal const string OracleField = "AAE_OracleField";

		internal const string SpearImpact = "AAE_SpearImpact";

		internal const string IceShock = "AAE_IceShock";

		internal const string RulerGround = "AAE_RulerGround";

		internal const string Ignition = "AAE_Ignition";

		internal const string FlameBurst = "AAE_FlameBurst";

		internal const string FlameShock = "AAE_FlameShock";

		internal const string FlameExplosion = "AAE_FlameExplosion";

		internal static readonly HashSet<string> Allowed = new HashSet<string>
		{
			"QuelTaliaAwakened_CL", "HastielRageborn_Projectile", "Ignavius_BasicStrike", "Ravalon_UltraExplosion", "Ziralux_ScatterLightning", "Excevior_ShredSpecial", "Prisvallia_Explosion1", "Prisvallia_Explosion2", "Prisvallia_Aoe", "Ravalon_FiringShot",
			"AAE_AnnihilationRound", "AAE_BowAura", "AAE_QuelImpact", "AAE_LightSlash", "AAE_OracleField", "AAE_SpearImpact", "AAE_IceShock", "AAE_RulerGround", "AAE_Ignition", "AAE_FlameBurst",
			"AAE_FlameShock", "AAE_FlameExplosion"
		};

		private static GameObject staging;

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

		private static readonly Dictionary<ZDOID, long> fields = new Dictionary<ZDOID, long>();

		internal static void Spawn(string name, Vector3 pos, Color color, float life, float size, ZDOID follow)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_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_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: 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_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)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && !(name == "AAE_LightSlash"))
			{
				if (name == "AAE_IceShock")
				{
					Shockwave.Enqueue(pos, size);
				}
				else if (name == "AAE_FlameShock")
				{
					Shockwave.Enqueue(pos, size, new Color(1f, 0.3f, 0.025f, 0.85f), 0.45f);
				}
				else if (active.Count < 96 && Allowed.Contains(name) && (!(name == "AAE_Ignition") || active.Count((Entry x) => x.Name == "AAE_Ignition") < 24) && ((!(name == "AAE_FlameExplosion") && !(name == "AAE_FlameBurst")) || active.Count((Entry x) => x.Name == name) < 12))
				{
					Character val = Plugin.Find(follow);
					active.Add(new Entry
					{
						Name = name,
						Position = pos,
						Color = color,
						Size = size,
						End = Plugin.Now + (double)life,
						Start = Plugin.Now,
						Follow = follow,
						Offset = (Object.op_Implicit((Object)(object)val) ? (pos - val.GetCenterPoint()) : Vector3.zero),
						Sword = (name == "QuelTaliaAwakened_CL"),
						Aura = (name == "AAE_BowAura")
					});
				}
			}
		}

		internal unsafe static void ReplaceRulerField(ZDOID actor, long generation, Vector3 pos, float duration)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (fields.TryGetValue(actor, out var value) && generation <= value)
			{
				return;
			}
			fields[actor] = generation;
			ZDOID val = actor;
			string text = "field:" + ((object)(*(ZDOID*)(&val))/*cast due to .constrained prefix*/).ToString();
			foreach (Entry item in active)
			{
				if (item.MotionKey == text)
				{
					item.End = 0.0;
				}
			}
			int count = active.Count;
			Spawn("AAE_RulerGround", pos + Vector3.up * 0.1f, Color.white, duration, Mathf.Max(0.01f, Plugin.Rule(Kind.Ruler).Radius / 5f), default(ZDOID));
			if (active.Count > count)
			{
				active[active.Count - 1].MotionKey = text;
			}
		}

		internal static GameObject Resolve(string name)
		{
			if (name == "AAE_FlameExplosion")
			{
				return Resolve("Ravalon_UltraExplosion");
			}
			if (name == "AAE_Ignition")
			{
				GameObject val = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab("IgnaviusInfernal_CL") : null);
				Transform val2 = (Object.op_Implicit((Object)(object)val) ? ((IEnumerable<Transform>)val.GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "IgnaviusFlames")) : null);
				if (!Object.op_Implicit((Object)(object)val2))
				{
					return null;
				}
				return ((Component)val2).gameObject;
			}
			if (name == "AAE_FlameBurst")
			{
				GameObject val3 = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab("IgnaviusInfernal_CL") : null);
				GameObject val4 = ((!Object.op_Implicit((Object)(object)val3)) ? null : val3.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_secondaryAttack.m_attackProjectile);
				if (!Object.op_Implicit((Object)(object)val4))
				{
					return null;
				}
				return ((IEnumerable<EffectData>)val4.GetComponent<Projectile>()?.m_hitEffects.m_effectPrefabs).FirstOrDefault((Func<EffectData, bool>)((EffectData x) => Object.op_Implicit((Object)(object)x.m_prefab) && ((Object)x.m_prefab).name == "Ignavius_InfernalStrike"))?.m_prefab;
			}
			if (name == "AAE_RulerGround")
			{
				GameObject val5 = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab("MavanharFearborn_CL") : null);
				if (!Object.op_Implicit((Object)(object)val5))
				{
					return null;
				}
				return val5.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_secondaryAttack.m_spawnOnHit;
			}
			if (name == "AAE_OracleField")
			{
				return Resolve("Prisvallia_Aoe");
			}
			if (name == "Seravi_DeificStrike1" || name == "Excevior_SpecialStrike")
			{
				GameObject val6 = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab((name == "Seravi_DeificStrike1") ? "SeraviDeific_CL" : "ExceviorPenumbral_CL") : null);
				GameObject val7 = ((!Object.op_Implicit((Object)(object)val6)) ? null : val6.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_secondaryAttack.m_attackProjectile);
				GameObject val8 = ((IEnumerable<EffectData>)(Object.op_Implicit((Object)(object)val7) ? val7.GetComponent<Projectile>() : null)?.m_hitEffects.m_effectPrefabs).FirstOrDefault((Func<EffectData, bool>)((EffectData x) => Object.op_Implicit((Object)(object)x.m_prefab) && ((Object)x.m_prefab).name == name))?.m_prefab;
				if (Object.op_Implicit((Object)(object)val8))
				{
					return val8;
				}
			}
			if (name == "AAE_SpearImpact")
			{
				GameObject val9 = Resolve("HastielRageborn_Projectile");
				if (!Object.op_Implicit((Object)(object)val9))
				{
					return null;
				}
				return ((IEnumerable<EffectData>)val9.GetComponent<Projectile>()?.m_hitEffects.m_effectPrefabs).FirstOrDefault((Func<EffectData, bool>)((EffectData x) => Object.op_Implicit((Object)(object)x.m_prefab) && Object.op_Implicit((Object)(object)x.m_prefab.GetComponentInChildren<Renderer>(true))))?.m_prefab;
			}
			if (name == "AAE_QuelImpact")
			{
				GameObject val10 = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab("QuelTaliaAwakened_CL") : null);
				GameObject val11 = ((!Object.op_Implicit((Object)(object)val10)) ? null : val10.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_secondaryAttack.m_attackProjectile);
				return ((IEnumerable<EffectData>)(Object.op_Implicit((Object)(object)val11) ? val11.GetComponent<Projectile>() : null)?.m_hitEffects.m_effectPrefabs).FirstOrDefault((Func<EffectData, bool>)((EffectData x) => Object.op_Implicit((Object)(object)x.m_prefab) && Object.op_Implicit((Object)(object)x.m_prefab.GetComponentInChildren<Renderer>(true))))?.m_prefab;
			}
			if (name == "AAE_AnnihilationRound")
			{
				GameObject val12 = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab("RavalonGunboltT3_CL") : null);
				return (Object.op_Implicit((Object)(object)val12) ? val12.GetComponent<ItemDrop>() : null)?.m_itemData.m_shared.m_attack.m_attackProjectile;
			}
			if (name == "AAE_BowAura")
			{
				return null;
			}
			GameObject val13 = (Object.op_Implicit((Object)(object)ZNetScene.instance) ? ZNetScene.instance.GetPrefab(name) : null);
			if (!Object.op_Implicit((Object)(object)val13) && Object.op_Implicit((Object)(object)ObjectDB.instance))
			{
				val13 = ObjectDB.instance.GetItemPrefab(name);
			}
			return val13;
		}

		private static bool Forbidden(Component c)
		{
			if (Object.op_Implicit((Object)(object)c))
			{
				if (!(c is MonoBehaviour) && !((object)c).GetType().Name.Contains("Collider") && !(((object)c).GetType().Name == "Rigidbody"))
				{
					return ((object)c).GetType().Name == "AudioSource";
				}
				return true;
			}
			return false;
		}

		private static void Prepare(Entry e)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = (e.Aura ? null : Resolve(e.Name));
			if (!e.Aura && !Object.op_Implicit((Object)(object)val))
			{
				e.End = 0.0;
				return;
			}
			if (!Object.op_Implicit((Object)(object)staging))
			{
				staging = new GameObject("AAE_InactiveVisualStaging");
				staging.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)staging);
			}
			if (e.Aura)
			{
				e.Go = new GameObject("AAE_BowSparkles");
				e.Go.SetActive(false);
				e.Go.transform.SetParent(staging.transform, false);
				BuildAura(e.Go);
			}
			else
			{
				e.Go = Object.Instantiate<GameObject>(val, staging.transform, false);
				e.Go.SetActive(false);
			}
			Component[] componentsInChildren = e.Go.GetComponentsInChildren<Component>(true);
			foreach (Component val2 in componentsInChildren)
			{
				if (Forbidden(val2))
				{
					Behaviour val3 = (Behaviour)(object)((val2 is Behaviour) ? val2 : null);
					if (Object.op_Implicit((Object)(object)val3))
					{
						val3.enabled = false;
					}
					PropertyInfo property = ((object)val2).GetType().GetProperty("enabled");
					if (property != null && property.CanWrite && property.PropertyType == typeof(bool))
					{
						property.SetValue(val2, false, null);
					}
					if (val2 is MonoBehaviour && !(val2 is ZNetView))
					{
						Object.Destroy((Object)(object)val2);
					}
				}
			}
			if (e.Name == "AAE_OracleField")
			{
				e.Color = EffectPalette.Seravi;
			}
			if (e.Name == "AAE_RulerGround")
			{
				e.Color = EffectPalette.Quel;
			}
			if (e.Name == "HastielRageborn_Projectile")
			{
				e.Color = new Color(0.055f, 0.065f, 0.08f, 0.42f);
			}
			e.Prepared = true;
			e.PreparedFrame = Time.frameCount;
		}

		private static void BuildAura(GameObject go)
		{
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			Type type = AccessTools.TypeByName("UnityEngine.ParticleSystem");
			if (type == null)
			{
				throw new Exception("ParticleSystem unavailable");
			}
			Component obj = go.AddComponent(type);
			object value = type.GetProperty("main").GetValue(obj, null);
			var array = new[]
			{
				new
				{
					Key = "startLifetime",
					Value = 0.25f
				},
				new
				{
					Key = "startSize",
					Value = 0.065f
				},
				new
				{
					Key = "startSpeed",
					Value = 0.25f
				}
			};
			foreach (var anon in array)
			{
				PropertyInfo property = value.GetType().GetProperty(anon.Key);
				property.SetValue(value, Activator.CreateInstance(property.PropertyType, anon.Value), null);
			}
			value.GetType().GetProperty("maxParticles").SetValue(value, 24, null);
			object value2 = type.GetProperty("emission").GetValue(obj, null);
			PropertyInfo property2 = value2.GetType().GetProperty("rateOverTime");
			property2.SetValue(value2, Activator.CreateInstance(property2.PropertyType, 40f), null);
			object value3 = type.GetProperty("shape").GetValue(obj, null);
			value3.GetType().GetProperty("enabled").SetValue(value3, false, null);
			Renderer component = go.GetComponent<Renderer>();
			Shader val = Shader.Find("Legacy Shaders/Particles/Additive") ?? Shader.Find("Particles/Standard Unlit");
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)val))
			{
				component.material = new Material(val);
			}
		}

		private static void Activate(Entry e)
		{
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0503: Unknown result type (might be due to invalid IL or missing references)
			//IL_0519: Unknown result type (might be due to invalid IL or missing references)
			//IL_0524: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0625: Unknown result type (might be due to invalid IL or missing references)
			//IL_062a: Unknown result type (might be due to invalid IL or missing references)
			//IL_062f: Unknown result type (might be due to invalid IL or missing references)
			//IL_058b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0604: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Unknown result type (might be due to invalid IL or missing references)
			//IL_060e: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ba: 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_0125: 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_08bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c9: 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_08fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_090d: 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_091d: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0948: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0723: Unknown result type (might be due to invalid IL or missing references)
			//IL_0728: Unknown result type (might be due to invalid IL or missing references)
			//IL_072c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0731: Unknown result type (might be due to invalid IL or missing references)
			//IL_0744: Unknown result type (might be due to invalid IL or missing references)
			//IL_0749: Unknown result type (might be due to invalid IL or missing references)
			//IL_074d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0752: Unknown result type (might be due to invalid IL or missing references)
			//IL_0757: Unknown result type (might be due to invalid IL or missing references)
			//IL_075c: Unknown result type (might be due to invalid IL or missing references)
			//IL_076a: Unknown result type (might be due to invalid IL or missing references)
			//IL_076c: 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_0775: Unknown result type (might be due to invalid IL or missing references)
			//IL_077a: Unknown result type (might be due to invalid IL or missing references)
			//IL_077f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0784: Unknown result type (might be due to invalid IL or missing references)
			//IL_096b: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0804: Unknown result type (might be due to invalid IL or missing references)
			//IL_0808: Unknown result type (might be due to invalid IL or missing references)
			//IL_080d: Unknown result type (might be due to invalid IL or missing references)
			//IL_080f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0816: Unknown result type (might be due to invalid IL or missing references)
			//IL_0986: Unknown result type (might be due to invalid IL or missing references)
			//IL_0988: Unknown result type (might be due to invalid IL or missing references)
			//IL_098e: 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_0951: Unknown result type (might be due to invalid IL or missing references)
			//IL_0961: Unknown result type (might be due to invalid IL or missing references)
			//IL_0966: Unknown result type (might be due to invalid IL or missing references)
			//IL_082f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0836: Unknown result type (might be due to invalid IL or missing references)
			//IL_081f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0826: Unknown result type (might be due to invalid IL or missing references)
			//IL_0846: Unknown result type (might be due to invalid IL or missing references)
			//IL_083f: Unknown result type (might be due to invalid IL or missing references)
			//IL_084d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0852: Unknown result type (might be due to invalid IL or missing references)
			//IL_0866: Unknown result type (might be due to invalid IL or missing references)
			//IL_0868: Unknown result type (might be due to invalid IL or missing references)
			//IL_086d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0872: Unknown result type (might be due to invalid IL or missing references)
			//IL_0877: Unknown result type (might be due to invalid IL or missing references)
			//IL_087c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0881: Unknown result type (might be due to invalid IL or missing references)
			//IL_0886: Unknown result type (might be due to invalid IL or missing references)
			//IL_088b: Unknown result type (might be due to invalid IL or missing references)
			if (!e.PhysicalRemoved)
			{
				Component[] componentsInChildren = e.Go.GetComponentsInChildren<Component>(true);
				foreach (Component val in componentsInChildren)
				{
					if (Forbidden(val))
					{
						Object.Destroy((Object)(object)val);
					}
				}
				e.PhysicalRemoved = true;
				e.PreparedFrame = Time.frameCount;
				return;
			}
			if (e.Go.GetComponentsInChildren<Component>(true).Any(Forbidden))
			{
				if (Time.frameCount > e.PreparedFrame + 3)
				{
					e.End = 0.0;
				}
				return;
			}
			Renderer[] componentsInChildren2 = e.Go.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren2)
			{
				Material[] materials = val2.materials;
				foreach (Material val3 in materials)
				{
					e.Materials.Add(val3);
					if (e.Name == "AAE_QuelImpact")
					{
						string[] array = new string[3] { "_Color", "_TintColor", "_BaseColor" };
						foreach (string text in array)
						{
							if (val3.HasProperty(text))
							{
								Color color = val3.GetColor(text);
								color.a *= 0.6f;
								val3.SetColor(text, color);
							}
						}
					}
					else
					{
						if (e.Color == Color.white)
						{
							continue;
						}
						if ((e.Sword || e.Name == "HastielRageborn_Projectile") && ((object)val2).GetType().Name != "ParticleSystemRenderer")
						{
							Shader val4 = Shader.Find("Standard") ?? Shader.Find("Legacy Shaders/Transparent/Diffuse");
							if (Object.op_Implicit((Object)(object)val4))
							{
								val3.shader = val4;
							}
						}
						string[] array = new string[6] { "_Color", "_TintColor", "_BaseColor", "_color1", "_color2", "_RendererColor" };
						foreach (string text2 in array)
						{
							if (val3.HasProperty(text2))
							{
								val3.SetColor(text2, e.Color);
							}
						}
						if (val3.HasProperty("_EmissionColor"))
						{
							val3.SetColor("_EmissionColor", e.Color * 1.25f);
						}
						if (e.Color.a < 1f && (e.Sword || e.Name == "HastielRageborn_Projectile") && ((object)val2).GetType().Name != "ParticleSystemRenderer")
						{
							val3.SetFloat("_Mode", 3f);
							val3.SetInt("_SrcBlend", 5);
							val3.SetInt("_DstBlend", 10);
							val3.SetInt("_ZWrite", 0);
							val3.DisableKeyword("_ALPHATEST_ON");
							val3.DisableKeyword("_ALPHAPREMULTIPLY_ON");
							val3.EnableKeyword("_ALPHABLEND_ON");
							val3.SetOverrideTag("RenderType", "Transparent");
							val3.renderQueue = 3000;
						}
					}
				}
			}
			if (e.Color != Color.white)
			{
				Component[] componentsInChildren = e.Go.GetComponentsInChildren<Component>(true);
				foreach (Component val5 in componentsInChildren)
				{
					if (Object.op_Implicit((Object)(object)val5) && ((object)val5).GetType().FullName == "UnityEngine.ParticleSystem")
					{
						object value = ((object)val5).GetType().GetProperty("main").GetValue(val5, null);
						if (e.Name == "AAE_Ignition" || e.Name == "AAE_FlameExplosion" || e.Name == "AAE_FlameBurst")
						{
							value.GetType().GetProperty("maxParticles").SetValue(value, 96, null);
						}
						if (e.Name == "AAE_Ignition")
						{
							value.GetType().GetProperty("loop").SetValue(value, true, null);
							PropertyInfo property = value.GetType().GetProperty("startLifetime");
							property.SetValue(value, Activator.CreateInstance(property.PropertyType, 0.45f), null);
						}
						PropertyInfo property2 = value.GetType().GetProperty("startColor");
						property2.SetValue(value, Activator.CreateInstance(property2.PropertyType, e.Color), null);
						object value2 = ((object)val5).GetType().GetProperty("colorOverLifetime").GetValue(val5, null);
						value2.GetType().GetProperty("enabled").SetValue(value2, false, null);
					}
				}
			}
			e.Go.transform.position = e.Position;
			Transform transform = e.Go.transform;
			transform.localScale *= e.Size;
			e.Go.transform.SetParent((Transform)null, true);
			if (e.Sword)
			{
				Transform val6 = ((IEnumerable<Transform>)e.Go.GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "tip" && Object.op_Implicit((Object)(object)t.parent) && Object.op_Implicit((Object)(object)t.parent.Find("base"))));
				if (Object.op_Implicit((Object)(object)val6))
				{
					Vector3 val7 = val6.position - val6.parent.Find("base").position;
					e.Go.transform.rotation = Quaternion.FromToRotation(((Vector3)(ref val7)).normalized, Vector3.down) * e.Go.transform.rotation;
					e.SwordTip = val6;
					Transform transform2 = e.Go.transform;
					transform2.position += e.Position - val6.position;
				}
				else
				{
					e.Go.transform.rotation = Quaternion.LookRotation(Vector3.down, Vector3.forward);
				}
			}
			if (e.Name == "HastielRageborn_Projectile")
			{
				Transform val8 = ((IEnumerable<Transform>)e.Go.GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "tip" && Object.op_Implicit((Object)(object)t.parent) && Object.op_Implicit((Object)(object)t.parent.Find("base"))));
				MeshFilter[] componentsInChildren3 = e.Go.GetComponentsInChildren<MeshFilter>(true);
				MeshFilter val9 = ((IEnumerable<MeshFilter>)componentsInChildren3).FirstOrDefault((Func<MeshFilter, bool>)((MeshFilter f) => ((Object)f).name == "Blade" && Object.op_Implicit((Object)(object)f.sharedMesh)));
				MeshFilter val10 = ((IEnumerable<MeshFilter>)componentsInChildren3).FirstOrDefault((Func<MeshFilter, bool>)((MeshFilter f) => ((Object)f).name == "PoleHandle" && Object.op_Implicit((Object)(object)f.sharedMesh)));
				MeshFilter val11 = ((IEnumerable<MeshFilter>)componentsInChildren3).FirstOrDefault((Func<MeshFilter, bool>)((MeshFilter f) => Object.op_Implicit((Object)(object)f.sharedMesh)));
				Bounds bounds;
				if (Object.op_Implicit((Object)(object)val9) && Object.op_Implicit((Object)(object)val10))
				{
					Transform transform3 = ((Component)val9).transform;
					bounds = val9.sharedMesh.bounds;
					Vector3 val12 = transform3.TransformPoint(((Bounds)(ref bounds)).center);
					Transform transform4 = ((Component)val10).transform;
					bounds = val10.sharedMesh.bounds;
					Vector3 val13 = val12 - transform4.TransformPoint(((Bounds)(ref bounds)).center);
					Vector3 val14 = e.Go.transform.InverseTransformDirection(val13);
					e.Axis = Quaternion.FromToRotation(((Vector3)(ref val14)).normalized, Vector3.forward);
				}
				else if (Object.op_Implicit((Object)(object)val8))
				{
					Vector3 val15 = e.Go.transform.InverseTransformDirection(val8.position - val8.parent.Find("base").position);
					e.Axis = Quaternion.FromToRotation(-((Vector3)(ref val15)).normalized, Vector3.forward);
				}
				else if (Object.op_Implicit((Object)(object)val11))
				{
					bounds = val11.sharedMesh.bounds;
					Vector3 size = ((Bounds)(ref bounds)).size;
					Vector3 val16 = ((size.x > size.y && size.x > size.z) ? Vector3.right : ((size.y > size.z) ? Vector3.up : Vector3.forward));
					Vector3 val17 = e.Go.transform.InverseTransformDirection(((Component)val11).transform.TransformDirection(val16));
					e.Axis = Quaternion.FromToRotation(-((Vector3)(ref val17)).normalized, Vector3.forward);
				}
			}
			if (e.Name == "HastielRageborn_Projectile" && e.Moving && e.Orbit)
			{
				Character val18 = Plugin.Find(e.Actor);
				Character val19 = Plugin.Find(e.Target);
				if (Object.op_Implicit((Object)(object)val18))
				{
					if (e.Speed <= 0f)
					{
						e.Position = HoverPoint(val18, e.MotionId);
						e.Go.transform.position = e.Position;
						e.Velocity = Vector3.zero;
					}
					Vector3 val20 = ((e.Speed > 0f && Object.op_Implicit((Object)(object)val19) && !val19.IsDead()) ? (val19.GetCenterPoint() - e.Go.transform.position) : ((Component)val18).transform.forward);
					if (((Vector3)(ref val20)).sqrMagnitude > 0.0001f)
					{
						e.Go.transform.rotation = Quaternion.LookRotation(val20) * e.Axis;
					}
				}
			}
			if (e.Name == "AAE_Ignition")
			{
				e.Go.transform.rotation = Quaternion.identity;
			}
			e.InitialScale = e.Go.transform.localScale;
			e.Live = true;
			if (e.Name == "HastielRageborn_Projectile")
			{
				SpearSmoke.Burst(e.Go);
				e.RevealAt = Plugin.Now + 0.12;
			}
			else
			{
				e.Go.SetActive(true);
			}
		}

		internal unsafe static void Motion(ZDOID actor, long id, string visual, Vector3 pos, ZDOID target, float duration, float speed, bool orbit, Vector3? destination = null)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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_00d1: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			ZDOID val = actor;
			string key = ((object)(*(ZDOID*)(&val))/*cast due to .constrained prefix*/).ToString() + ":" + id;
			Entry entry = active.FirstOrDefault((Entry x) => x.MotionKey == key);
			if (duration == 0f)
			{
				if (entry != null)
				{
					entry.End = 0.0;
				}
				return;
			}
			if (entry == null)
			{
				int count = active.Count;
				Spawn(visual, pos, Color.white, duration, orbit ? 0.38f : 1f, default(ZDOID));
				if (active.Count == count)
				{
					return;
				}
				entry = active[active.Count - 1];
			}
			if (Object.op_Implicit((Object)(object)entry.Go))
			{
				entry.Go.transform.position = pos;
			}
			else
			{
				entry.Position = pos;
			}
			entry.MotionKey = key;
			entry.MotionId = id;
			entry.Destination = destination;
			entry.Target = target;
			entry.Actor = actor;
			entry.Speed = speed;
			entry.Moving = true;
			entry.Orbit = orbit;
			entry.End = Plugin.Now + (double)duration;
		}

		private static void Remove(Entry e, bool feedback = true)
		{
			if (feedback && e.Live && Object.op_Implicit((Object)(object)e.Go) && e.Name == "HastielRageborn_Projectile")
			{
				SpearSmoke.Burst(e.Go);
			}
			if (Object.op_Implicit((Object)(object)e.Go))
			{
				Object.Destroy((Object)(object)e.Go);
			}
			foreach (Material material in e.Materials)
			{
				if (Object.op_Implicit((Object)(object)material))
				{
					Object.Destroy((Object)(object)material);
				}
			}
			active.Remove(e);
		}

		internal static void Update()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: 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_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing