Decompiled source of Aneis Runicos v1.3.2

plugins/AnelMago.dll

Decompiled an hour ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("AnelMago")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AnelMago")]
[assembly: AssemblyTitle("AnelMago")]
[assembly: AssemblyVersion("1.0.0.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 AnelMago
{
	public static class Assassino
	{
		public static bool Ligado;

		public static float Fim;

		private static bool eraFantasma;

		private static readonly FieldInfo campoFantasma = AccessTools.Field(typeof(Player), "m_ghostMode");

		private static readonly MethodInfo metodoFantasma = AccessTools.Method(typeof(Player), "SetGhostMode", new Type[1] { typeof(bool) }, (Type[])null);

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

		private static void Dizer(string chave, string texto, bool aviso)
		{
			if (jaDisse.Add(chave))
			{
				if (aviso)
				{
					AnelMagoPlugin.Log.LogWarning((object)("Assassino: " + texto));
				}
				else
				{
					AnelMagoPlugin.Log.LogInfo((object)("Assassino: " + texto));
				}
			}
		}

		public static void Usar(Player jogador)
		{
			if (Recargas.Tentar(jogador, "Assassino", AnelMagoPlugin.AssassinoRecarga.Value))
			{
				if (!Ligado)
				{
					eraFantasma = LerFantasma(jogador);
				}
				DefinirFantasma(jogador, ligar: true);
				Sons.Tocar(jogador, "Assassino");
				Movimento.Aplicar(jogador, AnelMagoPlugin.AssassinoVelocidade.Value);
				Transparencia.Aplicar(jogador, AnelMagoPlugin.AssassinoOpacidade.Value);
				Fim = Time.time + AnelMagoPlugin.AssassinoDuracao.Value;
				Ligado = true;
				AnelEfeitos.Aplicar(jogador, "Assassino");
			}
		}

		public static void Encerrar(Player jogador)
		{
			if (!Ligado)
			{
				return;
			}
			Ligado = false;
			Fim = 0f;
			try
			{
				if ((Object)(object)jogador != (Object)null)
				{
					if (!eraFantasma)
					{
						DefinirFantasma(jogador, ligar: false);
					}
					Movimento.Restaurar(jogador);
					AnelEfeitos.Remover(jogador, "Assassino");
				}
			}
			catch (Exception ex)
			{
				Dizer("encerrar", "erro ao encerrar: " + ex.Message, aviso: true);
			}
			Transparencia.Restaurar();
		}

		private static bool LerFantasma(Player jogador)
		{
			try
			{
				return campoFantasma != null && (bool)campoFantasma.GetValue(jogador);
			}
			catch
			{
				return false;
			}
		}

		private static void DefinirFantasma(Player jogador, bool ligar)
		{
			try
			{
				if (metodoFantasma != null)
				{
					metodoFantasma.Invoke(jogador, new object[1] { ligar });
					Dizer("ghost", "modo fantasma via metodo SetGhostMode", aviso: false);
				}
				else if (campoFantasma != null)
				{
					campoFantasma.SetValue(jogador, ligar);
					Dizer("ghost", "modo fantasma via campo m_ghostMode", aviso: false);
				}
				else
				{
					Dizer("ghost", "nao achei SetGhostMode nem m_ghostMode em Player (criaturas NAO vao ignorar)", aviso: true);
				}
			}
			catch (Exception ex)
			{
				Dizer("ghosterro", "falhou ao mudar o modo fantasma: " + ex.Message, aviso: true);
			}
		}
	}
	public static class Transparencia
	{
		private class Guardado
		{
			public Renderer Renderer;

			public Material[] Originais;

			public Material[] Copias;
		}

		private static readonly List<Guardado> guardados = new List<Guardado>();

		private static readonly HashSet<Renderer> vistos = new HashSet<Renderer>();

		private static readonly string[] NomesShader = new string[3] { "Standard", "Legacy Shaders/Transparent/Diffuse", "Sprites/Default" };

		private static Shader shader;

		private static bool buscou = false;

		private static float alfa = 1f;

		public static void Aplicar(Player jogador, float opacidade)
		{
			alfa = opacidade;
			if (alfa >= 0.99f)
			{
				return;
			}
			if (!buscou)
			{
				buscou = true;
				string[] nomesShader = NomesShader;
				foreach (string text in nomesShader)
				{
					shader = Shader.Find(text);
					if ((Object)(object)shader != (Object)null)
					{
						AnelMagoPlugin.Log.LogInfo((object)("Assassino: transparencia usando o shader " + text));
						break;
					}
				}
				if ((Object)(object)shader == (Object)null)
				{
					AnelMagoPlugin.Log.LogWarning((object)"Assassino: nenhum shader com transparencia encontrado (o personagem nao vai ficar transparente)");
				}
			}
			Varrer(jogador);
		}

		public static void Varrer(Player jogador)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)shader == (Object)null || alfa >= 0.99f || (Object)(object)jogador == (Object)null)
			{
				return;
			}
			Renderer[] componentsInChildren = ((Component)jogador).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if ((Object)(object)val == (Object)null || vistos.Contains(val) || !((object)val).GetType().Name.Contains("MeshRenderer"))
				{
					continue;
				}
				vistos.Add(val);
				try
				{
					Material[] sharedMaterials = val.sharedMaterials;
					Material[] array = (Material[])(object)new Material[sharedMaterials.Length];
					for (int j = 0; j < sharedMaterials.Length; j++)
					{
						if (!((Object)(object)sharedMaterials[j] == (Object)null))
						{
							Material val2 = new Material(sharedMaterials[j]);
							val2.shader = shader;
							ConfigurarFade(val2);
							if (val2.HasProperty("_Color"))
							{
								Color color = val2.color;
								color.a = alfa;
								val2.color = color;
							}
							array[j] = val2;
						}
					}
					val.sharedMaterials = array;
					guardados.Add(new Guardado
					{
						Renderer = val,
						Originais = sharedMaterials,
						Copias = array
					});
				}
				catch (Exception ex)
				{
					AnelMagoPlugin.Log.LogWarning((object)("Assassino: falha na transparencia de uma peca: " + ex.Message));
				}
			}
		}

		private static void ConfigurarFade(Material m)
		{
			if (m.HasProperty("_Mode"))
			{
				m.SetFloat("_Mode", 2f);
			}
			if (m.HasProperty("_SrcBlend"))
			{
				m.SetInt("_SrcBlend", 5);
			}
			if (m.HasProperty("_DstBlend"))
			{
				m.SetInt("_DstBlend", 10);
			}
			if (m.HasProperty("_ZWrite"))
			{
				m.SetInt("_ZWrite", 0);
			}
			m.DisableKeyword("_ALPHATEST_ON");
			m.EnableKeyword("_ALPHABLEND_ON");
			m.DisableKeyword("_ALPHAPREMULTIPLY_ON");
			m.renderQueue = 3000;
		}

		public static void Restaurar()
		{
			foreach (Guardado guardado in guardados)
			{
				try
				{
					if ((Object)(object)guardado.Renderer != (Object)null)
					{
						guardado.Renderer.sharedMaterials = guardado.Originais;
					}
					Material[] copias = guardado.Copias;
					foreach (Material val in copias)
					{
						if ((Object)(object)val != (Object)null)
						{
							Object.Destroy((Object)(object)val);
						}
					}
				}
				catch
				{
				}
			}
			guardados.Clear();
			vistos.Clear();
		}
	}
	[HarmonyPatch(typeof(Player), "Update")]
	public static class Player_Assassino_Patch
	{
		private static float proximaVarredura;

		private static void Postfix(Player __instance)
		{
			if (Assassino.Ligado && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				if (((Character)__instance).IsDead() || Time.time >= Assassino.Fim)
				{
					Assassino.Encerrar(__instance);
				}
				else if (Time.time >= proximaVarredura)
				{
					proximaVarredura = Time.time + 0.5f;
					Transparencia.Varrer(__instance);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Character), "Damage")]
	public static class Character_Furtivo_Patch
	{
		private static void Prefix(Character __instance, HitData hit)
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			if (!Assassino.Ligado || hit == null)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)__instance == (Object)(object)localPlayer || (Object)(object)hit.GetAttacker() != (Object)(object)localPlayer)
			{
				return;
			}
			float backstabBonus = hit.m_backstabBonus;
			if (backstabBonus <= 1f)
			{
				ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon();
				if (currentWeapon != null && currentWeapon.m_shared != null)
				{
					backstabBonus = currentWeapon.m_shared.m_backstabBonus;
				}
			}
			if (backstabBonus > 1f)
			{
				((DamageTypes)(ref hit.m_damage)).Modify(backstabBonus);
			}
			AnelMagoPlugin.Log.LogInfo((object)("Assassino: golpe furtivo, dano x" + backstabBonus.ToString("0.##")));
			hit.m_backstabBonus = 1f;
			Sons.Tocar("AssassinoGolpe", __instance.GetCenterPoint() - Vector3.up);
			Assassino.Encerrar(localPlayer);
		}
	}
	public static class Sons
	{
		private static ConfigEntry<bool> ligarSons;

		private static ConfigEntry<bool> ligarVisuais;

		private static readonly Dictionary<string, ConfigEntry<string>> sons = new Dictionary<string, ConfigEntry<string>>();

		private static readonly Dictionary<string, ConfigEntry<string>> visuais = new Dictionary<string, ConfigEntry<string>>();

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

		private static void Dizer(string chave, string texto, bool aviso)
		{
			if (jaDisse.Add(chave))
			{
				if (aviso)
				{
					AnelMagoPlugin.Log.LogWarning((object)("Sons: " + texto));
				}
				else
				{
					AnelMagoPlugin.Log.LogInfo((object)("Sons: " + texto));
				}
			}
		}

		public static void Configurar(ConfigFile cfg)
		{
			ligarSons = cfg.Bind<bool>("Sons", "Ligado", true, "Liga os efeitos sonoros das habilidades");
			ligarVisuais = cfg.Bind<bool>("Visuais", "Ligado", true, "Liga os efeitos visuais (partículas) das habilidades");
			Som(cfg, "Equipar", "sfx_gui_craftitem_end,sfx_gui_moveitem", "Som ao equipar um anel");
			Som(cfg, "Desequipar", "sfx_gui_moveitem", "Som ao desequipar um anel");
			Som(cfg, "Pronto", "sfx_Potion_stamina_Start", "Som quando a recarga de uma habilidade termina");
			Som(cfg, "Mago", "sfx_stafffrostorbs_cast,sfx_weapons_lightning_enable,sfx_staff_lightning_charge", "Som do éter infinito");
			Som(cfg, "Arqueiro", "sfx_dodge,sfx_fenring_jump_start", "Som do dash");
			Som(cfg, "Assassino", "sfx_demister_start,sfx_staffspiritcaller_cast", "Som ao ficar invisível");
			Som(cfg, "AssassinoGolpe", "", "Som do golpe furtivo (o efeito visual fx_backstab já tem som próprio)");
			Som(cfg, "Tank", "sfx_dverger_vo_attack,sfx_goblinbrute_shout", "Som do grito de guerra do Tank");
			Som(cfg, "Guerreiro", "sfx_asksvin_alert,sfx_fader_charredsummon_roar,sfx_trollfire_roar", "Som do rugido do Berserk");
			Visual(cfg, "Pronto", "", "Efeito visual quando a recarga termina");
			Visual(cfg, "Mago", "vfx_Potion_eitr_minor", "Efeito visual do éter infinito (pintado com a cor do anel do Mago)");
			Visual(cfg, "Fraqueza", "vfx_BloodHit", "Efeito visual em cada criatura que recebe a fraqueza do Tank");
			Visual(cfg, "Arqueiro", "fx_perfectdodge,vfx_perfectblock", "Efeito visual do dash (aparece na saída e na chegada)");
			Visual(cfg, "Assassino", "vfx_ghost_death,vfx_wraith_death", "Efeito visual ao ficar invisível");
			Visual(cfg, "AssassinoGolpe", "fx_backstab", "Efeito visual do golpe furtivo");
			Visual(cfg, "Tank", "fx_guardstone_activate,vfx_blocked", "Efeito visual da provocação do Tank");
			Visual(cfg, "Guerreiro", "fx_Adrenaline1,vfx_Potion_health_medium", "Efeito visual do Berserk");
		}

		private static void Som(ConfigFile cfg, string chave, string padrao, string descricao)
		{
			sons[chave] = cfg.Bind<string>("Sons", chave, padrao, descricao + ". Nomes de efeitos do jogo separados por vírgula; toca o primeiro que existir. Vazio = nenhum.");
		}

		private static void Visual(ConfigFile cfg, string chave, string padrao, string descricao)
		{
			visuais[chave] = cfg.Bind<string>("Visuais", chave, padrao, descricao + ". Nomes de efeitos do jogo separados por vírgula; usa o primeiro que existir. Vazio = nenhum.");
		}

		public static void Tocar(Player jogador, string chave)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)jogador == (Object)null))
			{
				Tocar(chave, ((Component)jogador).transform.position);
			}
		}

		public static void Tocar(Player jogador, string chave, Color tinta)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)jogador == (Object)null))
			{
				Tocar(chave, ((Component)jogador).transform.position, tinta);
			}
		}

		public static void Tocar(string chave, Vector3 onde)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Tocar(chave, onde, null);
		}

		public static void Tocar(string chave, Vector3 onde, Color? tinta)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (ligarSons != null && ligarSons.Value)
				{
					Criar(sons, chave, onde, "som", null);
				}
				if (ligarVisuais != null && ligarVisuais.Value)
				{
					Criar(visuais, chave, onde + Vector3.up, "visual", tinta);
				}
			}
			catch (Exception ex)
			{
				Dizer("erro" + chave, "falhou em " + chave + ": " + ex.Message, aviso: true);
			}
		}

		public static void SoVisual(string chave, Vector3 onde)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (ligarVisuais != null && ligarVisuais.Value)
				{
					Criar(visuais, chave, onde, "visual", null);
				}
			}
			catch (Exception ex)
			{
				Dizer("erro" + chave, "falhou em " + chave + ": " + ex.Message, aviso: true);
			}
		}

		private static void Criar(Dictionary<string, ConfigEntry<string>> lista, string chave, Vector3 onde, string tipo, Color? tinta)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			if (!lista.TryGetValue(chave, out var value))
			{
				return;
			}
			string text = value.Value ?? "";
			if (text.Trim().Length == 0)
			{
				return;
			}
			string[] array = text.Split(new char[1] { ',' });
			for (int i = 0; i < array.Length; i++)
			{
				string text2 = array[i].Trim();
				if (text2.Length == 0)
				{
					continue;
				}
				GameObject val = Achar(text2);
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				GameObject val2 = Object.Instantiate<GameObject>(val, onde, Quaternion.identity);
				Dizer(tipo + chave, tipo + " de " + chave + " = " + text2, aviso: false);
				if (tinta.HasValue)
				{
					try
					{
						Tingir(val2, tinta.Value);
					}
					catch (Exception ex)
					{
						Dizer("tinta" + chave, "nao deu para pintar " + text2 + ": " + ex.Message, aviso: true);
					}
				}
				if ((Object)(object)val2.GetComponent<TimedDestruction>() == (Object)null)
				{
					if ((Object)(object)val2.GetComponent<ZNetView>() == (Object)null)
					{
						Object.Destroy((Object)(object)val2, 15f);
					}
					else
					{
						val2.AddComponent<TimedDestruction>().Trigger(15f);
					}
				}
				return;
			}
			Dizer("falta" + tipo + chave, "nenhum " + tipo + " encontrado para " + chave + " (" + text + ")", aviso: true);
		}

		private static void Tingir(GameObject obj, Color tinta)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			float h = default(float);
			float num = default(float);
			float num2 = default(float);
			Color.RGBToHSV(tinta, ref h, ref num, ref num2);
			ParticleSystem[] componentsInChildren = obj.GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem obj2 in componentsInChildren)
			{
				MainModule main = obj2.main;
				((MainModule)(ref main)).startColor = Matiz(((MainModule)(ref main)).startColor, h);
				ColorOverLifetimeModule colorOverLifetime = obj2.colorOverLifetime;
				if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled)
				{
					((ColorOverLifetimeModule)(ref colorOverLifetime)).color = Matiz(((ColorOverLifetimeModule)(ref colorOverLifetime)).color, h);
				}
			}
			string[] array = new string[3] { "_Color", "_TintColor", "_EmissionColor" };
			Renderer[] componentsInChildren2 = obj.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Material[] materials = componentsInChildren2[i].materials;
				foreach (Material val in materials)
				{
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					string[] array2 = array;
					foreach (string text in array2)
					{
						if (val.HasProperty(text))
						{
							val.SetColor(text, Matiz(val.GetColor(text), h));
						}
					}
				}
			}
			Light[] componentsInChildren3 = obj.GetComponentsInChildren<Light>(true);
			foreach (Light obj3 in componentsInChildren3)
			{
				obj3.color = Matiz(obj3.color, h);
			}
		}

		private static Color Matiz(Color c, float h)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			float num = default(float);
			float num2 = default(float);
			float num3 = default(float);
			Color.RGBToHSV(c, ref num, ref num2, ref num3);
			if (num2 < 0.08f)
			{
				return c;
			}
			Color result = Color.HSVToRGB(h, num2, num3, true);
			result.a = c.a;
			return result;
		}

		private static Gradient Matiz(Gradient g, float h)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			if (g == null)
			{
				return null;
			}
			GradientColorKey[] colorKeys = g.colorKeys;
			for (int i = 0; i < colorKeys.Length; i++)
			{
				colorKeys[i].color = Matiz(colorKeys[i].color, h);
			}
			Gradient val = new Gradient
			{
				mode = g.mode
			};
			val.SetKeys(colorKeys, g.alphaKeys);
			return val;
		}

		private static MinMaxGradient Matiz(MinMaxGradient g, float h)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected I4, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystemGradientMode mode = ((MinMaxGradient)(ref g)).mode;
			switch ((int)mode)
			{
			case 0:
				((MinMaxGradient)(ref g)).color = Matiz(((MinMaxGradient)(ref g)).color, h);
				break;
			case 2:
				((MinMaxGradient)(ref g)).colorMin = Matiz(((MinMaxGradient)(ref g)).colorMin, h);
				((MinMaxGradient)(ref g)).colorMax = Matiz(((MinMaxGradient)(ref g)).colorMax, h);
				break;
			case 1:
			case 4:
				((MinMaxGradient)(ref g)).gradient = Matiz(((MinMaxGradient)(ref g)).gradient, h);
				break;
			case 3:
				((MinMaxGradient)(ref g)).gradientMin = Matiz(((MinMaxGradient)(ref g)).gradientMin, h);
				((MinMaxGradient)(ref g)).gradientMax = Matiz(((MinMaxGradient)(ref g)).gradientMax, h);
				break;
			}
			return g;
		}

		private static GameObject Achar(string nome)
		{
			GameObject val = null;
			if ((Object)(object)ZNetScene.instance != (Object)null)
			{
				val = ZNetScene.instance.GetPrefab(nome);
			}
			if ((Object)(object)val == (Object)null)
			{
				try
				{
					val = PrefabManager.Instance.GetPrefab(nome);
				}
				catch
				{
					val = null;
				}
			}
			return val;
		}
	}
	public static class Movimento
	{
		private static readonly string[] Campos = new string[4] { "m_speed", "m_walkSpeed", "m_runSpeed", "m_crouchSpeed" };

		private static readonly Dictionary<FieldInfo, float> originais = new Dictionary<FieldInfo, float>();

		public static void Aplicar(Player jogador, float multiplicador)
		{
			if (originais.Count > 0)
			{
				Restaurar(jogador);
			}
			string[] campos = Campos;
			foreach (string text in campos)
			{
				FieldInfo fieldInfo = AccessTools.Field(typeof(Character), text);
				if (fieldInfo == null || fieldInfo.FieldType != typeof(float))
				{
					AnelMagoPlugin.Log.LogWarning((object)("Movimento: campo " + text + " nao encontrado"));
					continue;
				}
				float num = (float)fieldInfo.GetValue(jogador);
				originais[fieldInfo] = num;
				fieldInfo.SetValue(jogador, num * multiplicador);
			}
		}

		public static void Restaurar(Player jogador)
		{
			foreach (KeyValuePair<FieldInfo, float> originai in originais)
			{
				originai.Key.SetValue(jogador, originai.Value);
			}
			originais.Clear();
		}
	}
	public static class Dash
	{
		public static float ImuneAte;

		public static float EfeitoAte;

		public static bool BonusPronto;

		public static bool Imune => Time.time < ImuneAte;

		public static bool EfeitoAtivo => Time.time < EfeitoAte;

		public static bool BonusAtivo
		{
			get
			{
				if (BonusPronto)
				{
					return EfeitoAtivo;
				}
				return false;
			}
		}

		private static int Mascara => LayerMask.GetMask(new string[4] { "Default", "static_solid", "terrain", "piece" });

		public static void ConsumirBonus()
		{
			BonusPronto = false;
		}

		public static void Encerrar(Player jogador)
		{
			EfeitoAte = 0f;
			BonusPronto = false;
			AnelEfeitos.Remover(jogador, "Arqueiro");
		}

		public static void Usar(Player jogador)
		{
			//IL_001e: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			if (Recargas.Tentar(jogador, "Arqueiro", AnelMagoPlugin.DashRecarga.Value))
			{
				Vector3 position = ((Component)jogador).transform.position;
				Vector3 val = DirecaoOlhar(jogador);
				float num = AnelMagoPlugin.DashDistancia.Value;
				RaycastHit val2 = default(RaycastHit);
				if (Physics.Raycast(position + Vector3.up, val, ref val2, num + 1f, Mascara))
				{
					num = Mathf.Max(0f, ((RaycastHit)(ref val2)).distance - 0.8f);
				}
				Vector3 val3 = position + val * num;
				RaycastHit val4 = default(RaycastHit);
				if (Physics.Raycast(val3 + Vector3.up * 8f, Vector3.down, ref val4, 60f, Mascara))
				{
					val3.y = ((RaycastHit)(ref val4)).point.y + 0.1f;
				}
				((Component)jogador).transform.position = val3;
				Rigidbody component = ((Component)jogador).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.position = val3;
					component.linearVelocity = Vector3.zero;
				}
				Physics.SyncTransforms();
				Sons.Tocar("Arqueiro", position);
				if (Vector3.Distance(position, val3) > 2f)
				{
					Sons.Tocar("Arqueiro", val3);
				}
				ImuneAte = Time.time + AnelMagoPlugin.DashImunidade.Value;
				float value = AnelMagoPlugin.DashBonusPrazo.Value;
				EfeitoAte = ((value > 0f) ? (Time.time + value) : float.MaxValue);
				BonusPronto = true;
				AnelEfeitos.Aplicar(jogador, "Arqueiro");
			}
		}

		private static Vector3 DirecaoOlhar(Player jogador)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.forward : ((Component)jogador).transform.forward);
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
			{
				val = ((Component)jogador).transform.forward;
				val.y = 0f;
			}
			return ((Vector3)(ref val)).normalized;
		}
	}
	[HarmonyPatch(typeof(Character), "RPC_Damage")]
	public static class Character_Imunidade_Patch
	{
		private static bool Prefix(Character __instance)
		{
			if (Dash.Imune && (Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Character), "Damage")]
	public static class Character_Bonus_Patch
	{
		private static bool avisou;

		private static void Prefix(Character __instance, HitData hit)
		{
			if (!Dash.EfeitoAtivo || hit == null)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)__instance == (Object)(object)localPlayer) && !((Object)(object)hit.GetAttacker() != (Object)(object)localPlayer))
			{
				((DamageTypes)(ref hit.m_damage)).Modify(AnelMagoPlugin.DashMultiplicador.Value);
				if (!avisou)
				{
					avisou = true;
					AnelMagoPlugin.Log.LogInfo((object)("Arqueiro: golpe com dano x" + AnelMagoPlugin.DashMultiplicador.Value.ToString("0.##")));
				}
			}
		}
	}
	[HarmonyPatch(typeof(Player), "Update")]
	public static class Player_AnimacaoRapida_Patch
	{
		private static readonly FieldInfo campoPuxar = AccessTools.Field(typeof(Player), "m_attackDrawTime");

		private static readonly FieldInfo campoAnimador = AccessTools.Field(typeof(Character), "m_animator");

		private static PropertyInfo propVelocidade;

		private static bool acelerado = false;

		private static bool iniciou = false;

		private static bool temArco;

		private static SkillType tipoArco;

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

		private static void Dizer(string chave, string texto, bool aviso)
		{
			if (jaDisse.Add(chave))
			{
				if (aviso)
				{
					AnelMagoPlugin.Log.LogWarning((object)("Animacao rapida: " + texto));
				}
				else
				{
					AnelMagoPlugin.Log.LogInfo((object)("Animacao rapida: " + texto));
				}
			}
		}

		private static void Postfix(Player __instance)
		{
			if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				if (Dash.EfeitoAtivo && PuxandoArco(__instance))
				{
					DefinirVelocidadeAnimacao(__instance, AnelMagoPlugin.ArcoVelocidade.Value);
					SomarCarga(__instance);
				}
				else if (Berserk.Ligado && ((Character)__instance).InAttack() && AnelMagoPlugin.BerserkVelocidadeAtaque.Value != 1f)
				{
					DefinirVelocidadeAnimacao(__instance, AnelMagoPlugin.BerserkVelocidadeAtaque.Value);
				}
				else if (acelerado)
				{
					DefinirVelocidadeAnimacao(__instance, 1f);
				}
			}
		}

		private static bool PuxandoArco(Player jogador)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			ItemData currentWeapon = ((Humanoid)jogador).GetCurrentWeapon();
			if (currentWeapon == null || currentWeapon.m_shared == null)
			{
				return false;
			}
			if (!iniciou)
			{
				iniciou = true;
				temArco = Enum.TryParse<SkillType>("Bows", out tipoArco);
			}
			if (!temArco || currentWeapon.m_shared.m_skillType != tipoArco)
			{
				return false;
			}
			if (!((Character)jogador).InAttack())
			{
				return LerCarga(jogador) > 0f;
			}
			return true;
		}

		private static float LerCarga(Player jogador)
		{
			if (campoPuxar == null)
			{
				return 0f;
			}
			try
			{
				return (float)campoPuxar.GetValue(jogador);
			}
			catch
			{
				return 0f;
			}
		}

		private static void SomarCarga(Player jogador)
		{
			if (campoPuxar == null)
			{
				Dizer("carga", "campo m_attackDrawTime nao encontrado (so a animacao foi acelerada)", aviso: true);
				return;
			}
			try
			{
				float num = (float)campoPuxar.GetValue(jogador);
				if (num > 0f)
				{
					campoPuxar.SetValue(jogador, num + Time.deltaTime * (AnelMagoPlugin.ArcoVelocidade.Value - 1f));
				}
			}
			catch (Exception ex)
			{
				Dizer("carga", "falhou ao somar a carga: " + ex.Message, aviso: true);
			}
		}

		private static void DefinirVelocidadeAnimacao(Player jogador, float velocidade)
		{
			try
			{
				if (campoAnimador == null)
				{
					Dizer("anim", "campo m_animator nao encontrado em Character", aviso: true);
					return;
				}
				object value = campoAnimador.GetValue(jogador);
				if (value == null)
				{
					return;
				}
				if (propVelocidade == null)
				{
					propVelocidade = value.GetType().GetProperty("speed");
				}
				if (propVelocidade == null)
				{
					Dizer("anim", "propriedade speed nao encontrada no animador", aviso: true);
					return;
				}
				propVelocidade.SetValue(value, velocidade, null);
				acelerado = velocidade != 1f;
				if (acelerado)
				{
					Dizer("ativo", "animacao acelerada", aviso: false);
				}
			}
			catch (Exception ex)
			{
				Dizer("anim", "falhou: " + ex.Message, aviso: true);
			}
		}
	}
	public static class AnelDesenho
	{
		private const int N = 128;

		private const float RX = 47f;

		private const float RY = 27f;

		private const float RXI = 39f;

		private const float RYI = 20f;

		private const float H = 22f;

		private const float CYT = 11f;

		private const float CYB = -11f;

		private const float GIRO = 14f;

		private const float ESCALA = 1.13f;

		private const float PEDRA = 1.18f;

		private static readonly float[][] Runas = new float[8][]
		{
			new float[12]
			{
				0.5f, 0f, 0.5f, 1f, 0.5f, 1f, 0.15f, 0.62f, 0.5f, 1f,
				0.85f, 0.62f
			},
			new float[8] { 0.8f, 1f, 0.2f, 0.5f, 0.2f, 0.5f, 0.8f, 0f },
			new float[8] { 0.1f, 0f, 0.9f, 1f, 0.1f, 1f, 0.9f, 0f },
			new float[12]
			{
				0.25f, 0f, 0.25f, 1f, 0.25f, 0.45f, 0.85f, 0.75f, 0.25f, 0.72f,
				0.8f, 1f
			},
			new float[12]
			{
				0.2f, 0f, 0.2f, 1f, 0.2f, 1f, 0.8f, 0.7f, 0.8f, 0.7f,
				0.8f, 0f
			},
			new float[12]
			{
				0.3f, 0f, 0.3f, 1f, 0.3f, 0.78f, 0.8f, 0.5f, 0.8f, 0.5f,
				0.3f, 0.22f
			},
			new float[12]
			{
				0.8f, 1f, 0.25f, 0.66f, 0.25f, 0.66f, 0.75f, 0.34f, 0.75f, 0.34f,
				0.2f, 0f
			},
			new float[8] { 0.3f, 0f, 0.3f, 1f, 0.3f, 1f, 0.8f, 0.6f }
		};

		private static readonly float[] FrenteOnde = new float[4] { -0.68f, -0.37f, 0.37f, 0.68f };

		private static readonly int[] FrenteRuna = new int[4] { 3, 5, 0, 6 };

		private static readonly float[] DentroOnde = new float[5] { -1.02f, -0.52f, 0f, 0.52f, 1.02f };

		private static readonly int[] DentroRuna = new int[5] { 4, 1, 2, 7, 0 };

		private const float PCX = 0f;

		private const float PCY = -27f;

		private const float PFX = -1f;

		private const float PFY = 1f;

		private static readonly float[] PedraX = new float[8] { -8f, -3f, 5f, 9f, 8f, 2f, -5f, -9f };

		private static readonly float[] PedraY = new float[8] { -9f, -14f, -13f, -5f, 7f, 13f, 12f, 3f };

		private static readonly float[] PedraLuz = new float[8] { 0.5f, 0.42f, 0.55f, 0.68f, 0.86f, 1f, 0.95f, 0.75f };

		private const float CordaOnde = 1.02f;

		private const float CordaLargura = 0.19f;

		public static Sprite CriarIcone(Color pedra)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			try
			{
				Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false)
				{
					wrapMode = (TextureWrapMode)1,
					filterMode = (FilterMode)1
				};
				val.SetPixels(Pixels(pedra));
				val.Apply();
				return Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 100f);
			}
			catch (Exception ex)
			{
				AnelMagoPlugin.Log.LogWarning((object)("Nao consegui desenhar o icone do anel: " + ex.Message));
				return null;
			}
		}

		public static Color[] Pixels(Color pedra)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			float matiz = default(float);
			float sat = default(float);
			float num = default(float);
			Color.RGBToHSV(pedra, ref matiz, ref sat, ref num);
			float num2 = Mathf.Cos((float)Math.PI * 7f / 90f);
			float num3 = Mathf.Sin((float)Math.PI * 7f / 90f);
			Color[] array = (Color[])(object)new Color[16384];
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num4 = 0f;
					float num5 = 0f;
					float num6 = 0f;
					float num7 = 0f;
					for (int k = 0; k < 3; k++)
					{
						for (int l = 0; l < 3; l++)
						{
							float num8 = ((float)j + ((float)l + 0.5f) / 3f - 64f) / 1.13f;
							float num9 = ((float)i + ((float)k + 0.5f) / 3f - 67f) / 1.13f;
							Color val = Amostra(num8 * num2 + num9 * num3, (0f - num8) * num3 + num9 * num2, pedra, matiz, sat);
							num4 += val.r * val.a;
							num5 += val.g * val.a;
							num6 += val.b * val.a;
							num7 += val.a;
						}
					}
					array[i * 128 + j] = ((num7 > 0f) ? new Color(num4 / num7, num5 / num7, num6 / num7, num7 / 9f) : new Color(0f, 0f, 0f, 0f));
				}
			}
			return array;
		}

		private static Color Amostra(float x, float y, Color pedra, float matiz, float sat)
		{
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0780: Unknown result type (might be due to invalid IL or missing references)
			//IL_0785: Unknown result type (might be due to invalid IL or missing references)
			//IL_0789: Unknown result type (might be due to invalid IL or missing references)
			//IL_0790: Unknown result type (might be due to invalid IL or missing references)
			//IL_0797: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: 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_0611: Unknown result type (might be due to invalid IL or missing references)
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			//IL_0618: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_0629: Unknown result type (might be due to invalid IL or missing references)
			//IL_0652: Unknown result type (might be due to invalid IL or missing references)
			//IL_0654: Unknown result type (might be due to invalid IL or missing references)
			//IL_066e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0673: Unknown result type (might be due to invalid IL or missing references)
			//IL_067b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0687: Unknown result type (might be due to invalid IL or missing references)
			//IL_0693: Unknown result type (might be due to invalid IL or missing references)
			float num = Quad(x / 47f) + Quad((y - 11f) / 27f);
			float num2 = Quad(x / 39f) + Quad((y - 11f) / 20f);
			float num3 = Quad(x / 47f) + Quad((y - -11f) / 27f);
			float num4 = Quad(x / 39f) + Quad((y - -11f) / 20f);
			int num5 = 0;
			if (num < 1f)
			{
				if (num2 >= 1f)
				{
					num5 = 2;
				}
				else if (num4 >= 1f)
				{
					num5 = 3;
				}
			}
			else if (num3 < 1f || (Mathf.Abs(x) < 47f && y > -11f && y < 11f))
			{
				num5 = 1;
			}
			float num6 = (x - 0f) / 1.18f;
			float num7 = (y - -27f) / 1.18f;
			int num8 = Face(num6, num7);
			bool flag = num8 < 0 && Face((num6 - -1f) / 1.13f + -1f, (num7 - 1f) / 1.13f + 1f) >= 0;
			if (flag && num5 == 0)
			{
				flag = false;
			}
			if (num5 == 0 && num8 < 0)
			{
				return new Color(0f, 0f, 0f, 0f);
			}
			Color val = default(Color);
			((Color)(ref val))..ctor(0f, 0f, 0f, 0f);
			Color b = Mistura(pedra, new Color(1f, 1f, 1f, 1f), 0.35f);
			if (num5 != 0)
			{
				float num9 = 999f;
				bool flag2 = false;
				float num10 = 0f;
				float num11 = 0f;
				float num17;
				float num18;
				float num16;
				switch (num5)
				{
				case 1:
				{
					float num22 = Mathf.Clamp(x / 47f, -1f, 1f);
					float num23 = Mathf.Sqrt(1f - num22 * num22);
					float num24 = Mathf.Asin(num22);
					float num25 = (y - (11f - 27f * num23 - 22f)) / 22f;
					num16 = 0.3f + 0.7f * Mathf.Max(0f, -0.45f * num22 + 0.8f * num23);
					num16 *= 0.85f + 0.15f * num25;
					if (num25 > 0.9f)
					{
						num16 += 0.1f;
					}
					num17 = num24 * 47f;
					num18 = num25 * 22f;
					for (int j = 0; j < FrenteOnde.Length; j++)
					{
						float num26 = DistanciaDaRuna(FrenteRuna[j], (num24 - FrenteOnde[j]) / 0.24f + 0.5f, (num25 - 0.2f) / 0.6f, 11.28f * Mathf.Cos(FrenteOnde[j]), 13.200001f);
						if (num26 < num9)
						{
							num9 = num26;
						}
					}
					float num27 = (Mathf.Abs(num24) - 1.02f) / 0.19f;
					if (Mathf.Abs(num27) < 1f)
					{
						flag2 = true;
						num10 = num27;
						num11 = num25 * 22f;
					}
					break;
				}
				case 2:
				{
					float num20 = Mathf.Atan2(x / 47f, (0f - (y - 11f)) / 27f);
					num16 = 0.78f - 0.14f * (x / 47f) + ((y < 11f) ? 0.08f : (-0.06f));
					num17 = x;
					num18 = y + 200f;
					float num21 = (Mathf.Abs(num20) - 1.02f) / 0.19f;
					if (Mathf.Abs(num21) < 1f)
					{
						flag2 = true;
						num10 = num21;
						num11 = Mathf.Sqrt(num) * 40f;
					}
					break;
				}
				default:
				{
					float num12 = Mathf.Clamp(x / 39f, -1f, 1f);
					float num13 = Mathf.Sqrt(1f - num12 * num12);
					float num14 = Mathf.Asin(num12);
					float num15 = (11f + 20f * num13 - y) / 22f;
					num16 = (0.16f + 0.42f * Mathf.Max(0f, 0.45f * num12 + 0.8f * num13)) * (1f - 0.35f * num15);
					if (num15 < 0.08f)
					{
						num16 += 0.05f;
					}
					num17 = num14 * 39f + 500f;
					num18 = num15 * 22f;
					for (int i = 0; i < DentroOnde.Length; i++)
					{
						float num19 = DistanciaDaRuna(DentroRuna[i], (num14 - DentroOnde[i]) / 0.3f + 0.5f, 1f - (num15 - 0.16f) / 0.56f, 11.700001f * Mathf.Cos(DentroOnde[i]), 12.32f);
						if (num19 < num9)
						{
							num9 = num19;
						}
					}
					break;
				}
				}
				num16 *= 0.89f + 0.22f * Acaso(Mathf.Floor(num17 / 3f), Mathf.Floor(num18 / 3f));
				if (flag2)
				{
					float num28 = num10 + 1f;
					float num29 = Mathf.Floor(num28);
					float num30 = num28 - num29;
					float num31 = 0.6f + 0.4f * Mathf.Sin(num30 * (float)Math.PI);
					float num32 = 0.74f + 0.26f * Mathf.Sin(num11 * 0.85f + ((num29 == 0f) ? num30 : (0f - num30)) * 3.2f);
					float num33 = Mathf.Clamp(num16 * 1.5f, 0.38f, 1.05f) * num31 * num32;
					((Color)(ref val))..ctor(0.62f * num33, 0.44f * num33, 0.25f * num33, 1f);
				}
				else
				{
					((Color)(ref val))..ctor(0.36f * num16, 0.4f * num16, 0.47f * num16, 1f);
					float num34 = Mathf.Clamp01(1.05f - num9);
					float t = Mathf.Clamp01(1f - num9 / 3.5f) * 0.22f;
					val = Mistura(val, pedra, t);
					val = Mistura(val, b, num34 * 0.92f);
					if (num5 != 3)
					{
						float num35 = Mathf.Sqrt(Quad(num6 / 12f) + Quad(num7 / 16.5f));
						val = Mistura(val, pedra, Mathf.Clamp01((1.45f - num35) / 0.45f) * 0.45f);
					}
					if (flag)
					{
						((Color)(ref val))..ctor(pedra.r * 0.22f, pedra.g * 0.22f, pedra.b * 0.25f, 1f);
					}
				}
			}
			if (num8 >= 0)
			{
				float num36 = PedraLuz[num8];
				if (Face((num6 - -1f) / 0.45f + -1f, (num7 - 1f) / 0.45f + 1f) >= 0)
				{
					num36 = Mathf.Min(1f, num36 + 0.18f);
				}
				for (int k = 0; k < PedraX.Length; k++)
				{
					if (DistanciaDoTraco(num6, num7, -1f, 1f, PedraX[k], PedraY[k]) < 0.6f)
					{
						num36 = Mathf.Min(1f, num36 + 0.1f);
						break;
					}
				}
				Color val2 = Color.HSVToRGB(matiz, Mathf.Clamp01(sat * (1.25f - 0.62f * num36 * num36)), Mathf.Lerp(0.38f, 1f, num36));
				((Color)(ref val))..ctor(val2.r, val2.g, val2.b, 1f);
			}
			return val;
		}

		private static float Quad(float v)
		{
			return v * v;
		}

		private static Color Mistura(Color a, Color b, float t)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			t = Mathf.Clamp01(t);
			return new Color(a.r + (b.r - a.r) * t, a.g + (b.g - a.g) * t, a.b + (b.b - a.b) * t, a.a);
		}

		private static float Acaso(float x, float y)
		{
			float num = Mathf.Sin(x * 12.9898f + y * 78.233f) * 43758.547f;
			return num - Mathf.Floor(num);
		}

		private static float DistanciaDaRuna(int qual, float a, float b, float largura, float altura)
		{
			if (a < -0.6f || a > 1.6f || b < -0.6f || b > 1.6f)
			{
				return 999f;
			}
			float[] array = Runas[qual];
			float num = 999f;
			for (int i = 0; i + 3 < array.Length; i += 4)
			{
				float num2 = DistanciaDoTraco(a * largura, b * altura, array[i] * largura, array[i + 1] * altura, array[i + 2] * largura, array[i + 3] * altura);
				if (num2 < num)
				{
					num = num2;
				}
			}
			return num;
		}

		private static float DistanciaDoTraco(float px, float py, float ax, float ay, float bx, float by)
		{
			float num = bx - ax;
			float num2 = by - ay;
			float num3 = num * num + num2 * num2;
			float num4 = ((num3 > 0f) ? Mathf.Clamp01(((px - ax) * num + (py - ay) * num2) / num3) : 0f);
			float num5 = px - (ax + num * num4);
			float num6 = py - (ay + num2 * num4);
			return Mathf.Sqrt(num5 * num5 + num6 * num6);
		}

		private static int Face(float qx, float qy)
		{
			if (qx < -10f || qx > 10f || qy < -15f || qy > 14f)
			{
				return -1;
			}
			int num = PedraX.Length;
			for (int i = 0; i < num; i++)
			{
				int num2 = (i + 1) % num;
				float num3 = Lado(qx, qy, -1f, 1f, PedraX[i], PedraY[i]);
				float num4 = Lado(qx, qy, PedraX[i], PedraY[i], PedraX[num2], PedraY[num2]);
				float num5 = Lado(qx, qy, PedraX[num2], PedraY[num2], -1f, 1f);
				if (num3 >= 0f && num4 >= 0f && num5 >= 0f)
				{
					return i;
				}
			}
			return -1;
		}

		private static float Lado(float px, float py, float ax, float ay, float bx, float by)
		{
			return (bx - ax) * (py - ay) - (by - ay) * (px - ax);
		}

		public static void TrocarModelo(GameObject prefab, Color cor)
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: 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_0177: 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)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)prefab == (Object)null)
				{
					return;
				}
				MeshFilter val = null;
				float num = 0f;
				MeshFilter[] componentsInChildren = prefab.GetComponentsInChildren<MeshFilter>(true);
				Bounds bounds;
				foreach (MeshFilter val2 in componentsInChildren)
				{
					if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.sharedMesh == (Object)null) && !((Object)(object)((Component)val2).GetComponent<MeshRenderer>() == (Object)null))
					{
						bounds = val2.sharedMesh.bounds;
						Vector3 extents = ((Bounds)(ref bounds)).extents;
						float magnitude = ((Vector3)(ref extents)).magnitude;
						if ((Object)(object)val == (Object)null || magnitude > num)
						{
							val = val2;
							num = magnitude;
						}
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					AnelMagoPlugin.Log.LogWarning((object)"Modelo do anel: malha da joia nao encontrada (o item no chao continua com cara de joia)");
					return;
				}
				bounds = val.sharedMesh.bounds;
				Vector3 extents2 = ((Bounds)(ref bounds)).extents;
				float num2 = Mathf.Max(extents2.x, Mathf.Max(extents2.y, extents2.z)) * 0.85f;
				if (num2 <= 0f)
				{
					return;
				}
				componentsInChildren = prefab.GetComponentsInChildren<MeshFilter>(true);
				foreach (MeshFilter val3 in componentsInChildren)
				{
					if (!((Object)(object)val3 == (Object)(object)val))
					{
						MeshRenderer component = ((Component)val3).GetComponent<MeshRenderer>();
						if ((Object)(object)component != (Object)null)
						{
							((Renderer)component).enabled = false;
						}
					}
				}
				val.sharedMesh = CriarAnel(num2);
				MeshRenderer component2 = ((Component)val).GetComponent<MeshRenderer>();
				Material sharedMaterial = ((Renderer)component2).sharedMaterial;
				Material val4 = NovoMaterial(sharedMaterial, "AnelMago_ferro", new Color(0.3f, 0.33f, 0.39f), cor * 0.12f, 0.7f, 0.45f);
				Material val5 = NovoMaterial(sharedMaterial, "AnelMago_cristal", cor, cor * 0.8f, 0.1f, 0.9f);
				((Renderer)component2).sharedMaterials = (Material[])(object)new Material[2] { val4, val5 };
			}
			catch (Exception ex)
			{
				AnelMagoPlugin.Log.LogWarning((object)("Modelo do anel: nao consegui trocar a malha: " + ex.Message));
			}
		}

		private static Material NovoMaterial(Material original, string nome, Color cor, Color luzPropria, float metal, float liso)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			Material val = (((Object)(object)original != (Object)null) ? new Material(original) : new Material(Shader.Find("Standard")));
			((Object)val).name = nome;
			if (val.HasProperty("_MainTex"))
			{
				val.SetTexture("_MainTex", (Texture)null);
			}
			if (val.HasProperty("_BumpMap"))
			{
				val.SetTexture("_BumpMap", (Texture)null);
			}
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", cor);
			}
			if (val.HasProperty("_EmissionColor"))
			{
				val.SetColor("_EmissionColor", luzPropria);
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", metal);
			}
			if (val.HasProperty("_Glossiness"))
			{
				val.SetFloat("_Glossiness", liso);
			}
			return val;
		}

		private static Mesh CriarAnel(float raio)
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Expected O, but got Unknown
			float num = raio * 0.13f;
			float num2 = raio * 0.36f;
			int num3 = 11;
			int num4 = 29 * num3;
			Vector3[] array = (Vector3[])(object)new Vector3[num4 + 24];
			Vector3[] array2 = (Vector3[])(object)new Vector3[array.Length];
			Vector2[] array3 = (Vector2[])(object)new Vector2[array.Length];
			int[] array4 = new int[1680];
			int[] array5 = new int[24];
			for (int i = 0; i <= 28; i++)
			{
				float num5 = (float)i / 28f * (float)Math.PI * 2f;
				float num6 = Mathf.Cos(num5);
				float num7 = Mathf.Sin(num5);
				for (int j = 0; j <= 10; j++)
				{
					float num8 = (float)j / 10f * (float)Math.PI * 2f;
					float num9 = Mathf.Cos(num8);
					float num10 = Mathf.Sin(num8);
					int num11 = i * num3 + j;
					float num12 = raio + num * num9;
					array[num11] = new Vector3(num12 * num6, num2 * num10, num12 * num7);
					Vector3 val = new Vector3(num9 * num6 * num2, num10 * num, num9 * num7 * num2);
					array2[num11] = ((Vector3)(ref val)).normalized;
					array3[num11] = new Vector2((float)i / 28f, (float)j / 10f);
				}
			}
			int num13 = 0;
			for (int k = 0; k < 28; k++)
			{
				for (int l = 0; l < 10; l++)
				{
					int num14 = k * num3 + l;
					int num15 = num14 + 1;
					int num16 = num14 + num3;
					int num17 = num16 + 1;
					array4[num13++] = num14;
					array4[num13++] = num15;
					array4[num13++] = num16;
					array4[num13++] = num15;
					array4[num13++] = num17;
					array4[num13++] = num16;
				}
			}
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(raio + num, 0f, 0f);
			float num18 = raio * 0.34f;
			float num19 = raio * 0.48f;
			float num20 = raio * 0.26f;
			Vector3 p = val2 + new Vector3(0f, num19, 0f);
			Vector3 p2 = val2 - new Vector3(0f, num19, 0f);
			Vector3[] array6 = (Vector3[])(object)new Vector3[4]
			{
				val2 + new Vector3(num18, 0f, 0f),
				val2 + new Vector3(0f, 0f, num20),
				val2 - new Vector3(num18, 0f, 0f),
				val2 - new Vector3(0f, 0f, num20)
			};
			int v = num4;
			int t = 0;
			for (int m = 0; m < 4; m++)
			{
				Vector3 val3 = array6[m];
				Vector3 val4 = array6[(m + 1) % 4];
				v = Triangulo(array, array2, array3, array5, ref t, v, p, val3, val4, val2);
				v = Triangulo(array, array2, array3, array5, ref t, v, p2, val4, val3, val2);
			}
			Mesh val5 = new Mesh
			{
				name = "AnelMago_anel",
				vertices = array,
				normals = array2,
				uv = array3,
				subMeshCount = 2
			};
			val5.SetTriangles(array4, 0);
			val5.SetTriangles(array5, 1);
			val5.RecalculateBounds();
			return val5;
		}

		private static int Triangulo(Vector3[] vertices, Vector3[] normais, Vector2[] uvs, int[] tris, ref int t, int v, Vector3 p0, Vector3 p1, Vector3 p2, Vector3 centro)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.Cross(p1 - p0, p2 - p0);
			Vector3 val2 = ((Vector3)(ref val)).normalized;
			if (Vector3.Dot(val2, (p0 + p1 + p2) / 3f - centro) < 0f)
			{
				Vector3 val3 = p1;
				p1 = p2;
				p2 = val3;
				val2 = -val2;
			}
			vertices[v] = p0;
			vertices[v + 1] = p1;
			vertices[v + 2] = p2;
			normais[v] = val2;
			normais[v + 1] = val2;
			normais[v + 2] = val2;
			uvs[v] = new Vector2(0.5f, 1f);
			uvs[v + 1] = new Vector2(0f, 0f);
			uvs[v + 2] = new Vector2(1f, 0f);
			tris[t++] = v;
			tris[t++] = v + 1;
			tris[t++] = v + 2;
			return v + 3;
		}
	}
	public static class AnelDrops
	{
		public static int OrdemDoBoss(string nomeDoPrefab)
		{
			string[] array = (AnelMagoPlugin.DropBosses.Value ?? "").Split(new char[1] { ',' });
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Split(new char[1] { '|' });
				for (int j = 0; j < array2.Length; j++)
				{
					if (string.Equals(array2[j].Trim(), nomeDoPrefab, StringComparison.OrdinalIgnoreCase))
					{
						return i;
					}
				}
			}
			return -1;
		}

		public static float Chance(int ordem)
		{
			return Mathf.Clamp(AnelMagoPlugin.DropPrimeiroBoss.Value + AnelMagoPlugin.DropAumento.Value * (float)ordem, 0f, 100f);
		}

		public static string ClasseDoMob(string nomeDoPrefab)
		{
			string[] array = (AnelMagoPlugin.DropMobs.Value ?? "").Split(new char[1] { ',' });
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Split(new char[1] { ':' });
				if (array2.Length == 2 && string.Equals(array2[0].Trim(), nomeDoPrefab, StringComparison.OrdinalIgnoreCase))
				{
					return array2[1].Trim();
				}
			}
			return null;
		}

		public static GameObject AnelAleatorio()
		{
			string[] nomesDasClasses = AnelItens.NomesDasClasses;
			return AnelDaClasse(nomesDasClasses[Random.Range(0, nomesDasClasses.Length)]);
		}

		public static GameObject AnelDaClasse(string classe)
		{
			string text = "Anel" + classe;
			GameObject val = null;
			if ((Object)(object)ZNetScene.instance != (Object)null)
			{
				val = ZNetScene.instance.GetPrefab(text);
			}
			if ((Object)(object)val == (Object)null && (Object)(object)ObjectDB.instance != (Object)null)
			{
				val = ObjectDB.instance.GetItemPrefab(text);
			}
			return val;
		}
	}
	[HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")]
	public static class CharacterDrop_Aneis_Patch
	{
		private static void Postfix(CharacterDrop __instance, List<KeyValuePair<GameObject, int>> __result)
		{
			try
			{
				if ((Object)(object)__instance == (Object)null || __result == null)
				{
					return;
				}
				string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject);
				if (AnelMagoPlugin.DropMobsLigado.Value)
				{
					string text = AnelDrops.ClasseDoMob(prefabName);
					if (text != null)
					{
						float num = Mathf.Clamp(AnelMagoPlugin.DropMobsChance.Value, 0f, 100f);
						if (!(Random.Range(0f, 100f) >= num))
						{
							GameObject val = AnelDrops.AnelDaClasse(text);
							if ((Object)(object)val == (Object)null)
							{
								AnelMagoPlugin.Log.LogWarning((object)("Drop: anel da classe '" + text + "' nao encontrado (confira MobsEAneis na config)"));
								return;
							}
							__result.Add(new KeyValuePair<GameObject, int>(val, 1));
							AnelMagoPlugin.Log.LogInfo((object)("Drop: " + prefabName + " dropou " + ((Object)val).name));
						}
						return;
					}
				}
				if (!AnelMagoPlugin.DropLigado.Value)
				{
					return;
				}
				int num2 = AnelDrops.OrdemDoBoss(prefabName);
				if (num2 < 0 || __result.Count == 0)
				{
					return;
				}
				float num3 = AnelDrops.Chance(num2);
				float num4 = Random.Range(0f, 100f);
				bool flag = num4 < num3;
				AnelMagoPlugin.Log.LogInfo((object)("Drop: " + prefabName + " morreu, chance de anel " + num3.ToString("0.#") + "%, sorteio " + num4.ToString("0.0") + (flag ? " -> DROPOU" : " -> nao dropou")));
				if (flag)
				{
					GameObject val2 = AnelDrops.AnelAleatorio();
					if ((Object)(object)val2 == (Object)null)
					{
						AnelMagoPlugin.Log.LogWarning((object)"Drop: item do anel nao encontrado");
						return;
					}
					__result.Add(new KeyValuePair<GameObject, int>(val2, 1));
					AnelMagoPlugin.Log.LogInfo((object)("Drop: " + prefabName + " dropou " + ((Object)val2).name));
				}
			}
			catch (Exception ex)
			{
				AnelMagoPlugin.Log.LogWarning((object)("Drop: erro ao sortear o anel: " + ex.Message));
			}
		}
	}
	public static class AnelEfeitos
	{
		public static readonly int HashFraqueza = StringExtensionMethods.GetStableHashCode("SE_AnelFraqueza");

		public static int Hash(string classe)
		{
			return StringExtensionMethods.GetStableHashCode("SE_Anel" + classe);
		}

		public static void Registrar(string classe, Sprite icone)
		{
			try
			{
				float num = 0f;
				switch (classe)
				{
				default:
					return;
				case "Mago":
					num = AnelMagoPlugin.Duracao.Value;
					break;
				case "Arqueiro":
					num = AnelMagoPlugin.DashBonusPrazo.Value;
					break;
				case "Assassino":
					num = AnelMagoPlugin.AssassinoDuracao.Value;
					break;
				case "Tank":
					num = AnelMagoPlugin.TankDuracao.Value;
					break;
				case "Guerreiro":
					num = AnelMagoPlugin.BerserkDuracao.Value;
					break;
				}
				Criar(classe, AnelTextos.NomeDaHabilidade(classe), AnelTextos.Dica(classe), num, icone);
				if (classe == "Tank")
				{
					Criar("Fraqueza", "Fraqueza", AnelTextos.DicaFraqueza(), AnelMagoPlugin.TankFraquezaDuracao.Value, icone);
				}
			}
			catch (Exception ex)
			{
				AnelMagoPlugin.Log.LogError((object)("Falha ao criar o efeito de " + classe + ": " + ex.Message));
			}
		}

		private static void Criar(string classe, string titulo, string dica, float duracao, Sprite icone)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			StatusEffect val = ScriptableObject.CreateInstance<StatusEffect>();
			((Object)val).name = "SE_Anel" + classe;
			val.m_name = titulo;
			val.m_tooltip = dica;
			val.m_icon = icone;
			val.m_ttl = duracao;
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(val, false));
			AnelMagoPlugin.Log.LogInfo((object)("Efeito SE_Anel" + classe + " criado"));
		}

		public static void Aplicar(Player jogador, string classe)
		{
			SEMan sEMan = ((Character)jogador).GetSEMan();
			if (sEMan != null)
			{
				sEMan.AddStatusEffect(Hash(classe), true, 0, 0f, (short)(-1));
			}
		}

		public static void Remover(Player jogador, string classe)
		{
			SEMan sEMan = ((Character)jogador).GetSEMan();
			if (sEMan != null)
			{
				sEMan.RemoveStatusEffect(Hash(classe), true);
			}
		}
	}
	[HarmonyPatch(typeof(Skills), "GetSkillLevel")]
	public static class Skills_Mago_Patch
	{
		private static bool iniciou;

		private static bool temElemental;

		private static bool temSangue;

		private static SkillType elemental;

		private static SkillType sangue;

		private static void Iniciar()
		{
			iniciou = true;
			temElemental = Enum.TryParse<SkillType>("ElementalMagic", out elemental);
			temSangue = Enum.TryParse<SkillType>("BloodMagic", out sangue);
		}

		private static void Postfix(object[] __args, ref float __result)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (EterInfinito.Ativo && __args != null && __args.Length != 0 && __args[0] is SkillType)
			{
				if (!iniciou)
				{
					Iniciar();
				}
				SkillType val = (SkillType)__args[0];
				if ((temElemental && val == elemental) || (temSangue && val == sangue))
				{
					__result += AnelMagoPlugin.MagoBonusHabilidade.Value;
				}
			}
		}
	}
	public static class AnelEstado
	{
		private const string Marca = "anel_equipado";

		private static float ultimaTroca = -9999f;

		public static string Classe(ItemData item)
		{
			if (item == null || item.m_shared == null)
			{
				return null;
			}
			string text = (((Object)(object)item.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : null);
			if (text != null)
			{
				text = text.Replace("(Clone)", "");
				if (text.StartsWith("Anel") && text.Length > 4)
				{
					return text.Substring(4);
				}
			}
			return AnelTextos.ClassePeloNome(item.m_shared.m_name);
		}

		public static bool EhAnel(ItemData item)
		{
			return Classe(item) != null;
		}

		public static bool Equipado(ItemData item)
		{
			if (item != null && item.m_customData != null && item.m_customData.TryGetValue("anel_equipado", out var value))
			{
				return value == "1";
			}
			return false;
		}

		private static void Marcar(ItemData item, bool valor)
		{
			if (valor)
			{
				item.m_customData["anel_equipado"] = "1";
			}
			else
			{
				item.m_customData.Remove("anel_equipado");
			}
		}

		public static string ClasseEquipada(Player jogador)
		{
			foreach (ItemData allItem in ((Humanoid)jogador).GetInventory().GetAllItems())
			{
				if (EhAnel(allItem) && Equipado(allItem))
				{
					return Classe(allItem);
				}
			}
			return null;
		}

		private static void LimparDuplicados(Player jogador)
		{
			bool flag = false;
			foreach (ItemData allItem in ((Humanoid)jogador).GetInventory().GetAllItems())
			{
				if (EhAnel(allItem) && Equipado(allItem))
				{
					if (!flag)
					{
						flag = true;
					}
					else
					{
						Marcar(allItem, valor: false);
					}
				}
			}
		}

		public static void Alternar(Player jogador, ItemData item)
		{
			LimparDuplicados(jogador);
			if (Equipado(item))
			{
				Marcar(item, valor: false);
				ultimaTroca = Time.realtimeSinceStartup;
				((Character)jogador).Message((MessageType)2, item.m_shared.m_name + " desequipado", 0, (Sprite)null, false);
				Sons.Tocar(jogador, "Desequipar");
				return;
			}
			string text = ClasseEquipada(jogador);
			if (text != null)
			{
				((Character)jogador).Message((MessageType)2, "Desequipe o " + AnelTextos.NomeDoAnel(text) + " antes de equipar outro", 0, (Sprite)null, false);
				return;
			}
			float num = ultimaTroca + AnelMagoPlugin.EsperaDeTroca() - Time.realtimeSinceStartup;
			if (num > 0f)
			{
				((Character)jogador).Message((MessageType)2, "Aguarde " + Mathf.CeilToInt(num) + "s para equipar um anel", 0, (Sprite)null, false);
				return;
			}
			Marcar(item, valor: true);
			((Character)jogador).Message((MessageType)2, item.m_shared.m_name + " equipado", 0, (Sprite)null, false);
			Sons.Tocar(jogador, "Equipar");
		}
	}
	[HarmonyPatch]
	public static class Humanoid_UseItem_Patch
	{
		public static IEnumerable<MethodBase> TargetMethods()
		{
			return (from m in AccessTools.GetDeclaredMethods(typeof(Humanoid))
				where m.Name == "UseItem"
				select m).Cast<MethodBase>();
		}

		public static bool Prefix(Humanoid __instance, object[] __args)
		{
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			foreach (object obj in __args)
			{
				ItemData val = (ItemData)((obj is ItemData) ? obj : null);
				if (val != null && AnelEstado.EhAnel(val))
				{
					AnelEstado.Alternar(Player.m_localPlayer, val);
					return false;
				}
			}
			return true;
		}
	}
	public static class Moldura
	{
		private static FieldInfo campoInv;

		private static FieldInfo campoEls;

		private static bool descobriuGrade;

		private static FieldInfo campoPos;

		private static FieldInfo campoEquipado;

		private static FieldInfo campoObjeto;

		private static bool descobriuSlot;

		private static bool desistiu;

		private static bool disseAnel;

		private static string ListarCampos(IEnumerable<FieldInfo> campos)
		{
			return string.Join(", ", campos.Select((FieldInfo f) => f.FieldType.Name + " " + f.Name).ToArray());
		}

		private static FieldInfo Campo(List<FieldInfo> campos, string nome)
		{
			return campos.FirstOrDefault((FieldInfo f) => f.Name == nome);
		}

		private static void DescobrirGrade()
		{
			descobriuGrade = true;
			List<FieldInfo> declaredFields = AccessTools.GetDeclaredFields(typeof(InventoryGrid));
			campoInv = Campo(declaredFields, "m_inventory") ?? declaredFields.FirstOrDefault((FieldInfo f) => f.FieldType == typeof(Inventory));
			campoEls = Campo(declaredFields, "m_elements") ?? declaredFields.FirstOrDefault((FieldInfo f) => f.FieldType.IsGenericType && f.FieldType.GetGenericArguments()[0].Name.Contains("Element"));
			if (campoInv == null || campoEls == null)
			{
				desistiu = true;
				AnelMagoPlugin.Log.LogWarning((object)("Moldura: campos da grade nao encontrados (sem moldura de equipado). Campos de InventoryGrid: " + ListarCampos(declaredFields)));
			}
		}

		private static void DescobrirSlot(Type tipo)
		{
			descobriuSlot = true;
			List<FieldInfo> declaredFields = AccessTools.GetDeclaredFields(tipo);
			campoPos = Campo(declaredFields, "m_pos") ?? declaredFields.FirstOrDefault((FieldInfo f) => f.FieldType == typeof(Vector2i));
			campoEquipado = Campo(declaredFields, "m_equiped") ?? declaredFields.FirstOrDefault((FieldInfo f) => f.Name.ToLower().Contains("equip"));
			campoObjeto = Campo(declaredFields, "m_go") ?? declaredFields.FirstOrDefault((FieldInfo f) => f.FieldType == typeof(GameObject));
			AnelMagoPlugin.Log.LogInfo((object)("Moldura: slot " + tipo.Name + ": posicao=" + ((campoPos != null) ? campoPos.Name : "(nenhum)") + ", moldura=" + ((campoEquipado != null) ? campoEquipado.Name : "(nenhum)") + ", objeto=" + ((campoObjeto != null) ? campoObjeto.Name : "(nenhum)")));
			if (campoPos == null || (campoEquipado == null && campoObjeto == null))
			{
				desistiu = true;
				AnelMagoPlugin.Log.LogWarning((object)("Moldura: campos do slot nao encontrados (sem moldura de equipado). Campos do slot: " + ListarCampos(declaredFields)));
			}
		}

		private static bool Definir(object el, bool ligar)
		{
			GameObject val = null;
			Behaviour val2 = null;
			if (campoEquipado != null)
			{
				object value = campoEquipado.GetValue(el);
				val2 = (Behaviour)((value is Behaviour) ? value : null);
				Component val3 = (Component)((value is Component) ? value : null);
				val = (GameObject)(((Object)(object)val3 != (Object)null) ? val3.gameObject : ((value is GameObject) ? value : null));
			}
			if ((Object)(object)val == (Object)null && campoObjeto != null)
			{
				object? value2 = campoObjeto.GetValue(el);
				GameObject val4 = (GameObject)((value2 is GameObject) ? value2 : null);
				if ((Object)(object)val4 != (Object)null)
				{
					Transform val5 = val4.transform.Find("equiped");
					if ((Object)(object)val5 != (Object)null)
					{
						val = ((Component)val5).gameObject;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = val.GetComponent<Behaviour>();
			}
			if (ligar && !val.activeSelf)
			{
				val.SetActive(true);
			}
			if ((Object)(object)val2 != (Object)null && val2.enabled != ligar)
			{
				val2.enabled = ligar;
			}
			return true;
		}

		public static void Aplicar(InventoryGrid grade)
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)grade == (Object)null || desistiu)
			{
				return;
			}
			try
			{
				if (!descobriuGrade)
				{
					DescobrirGrade();
				}
				if (desistiu)
				{
					return;
				}
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null)
				{
					return;
				}
				object? value = campoInv.GetValue(grade);
				Inventory val = (Inventory)((value is Inventory) ? value : null);
				IEnumerable enumerable = campoEls.GetValue(grade) as IEnumerable;
				if (val == null || enumerable == null || val != ((Humanoid)localPlayer).GetInventory())
				{
					return;
				}
				foreach (object item in enumerable)
				{
					if (item == null)
					{
						continue;
					}
					if (!descobriuSlot)
					{
						DescobrirSlot(item.GetType());
					}
					if (desistiu)
					{
						break;
					}
					Vector2i val2 = (Vector2i)campoPos.GetValue(item);
					ItemData itemAt = val.GetItemAt(val2.x, val2.y);
					if (itemAt != null && AnelEstado.EhAnel(itemAt))
					{
						bool ligar = AnelEstado.Equipado(itemAt);
						if (!Definir(item, ligar))
						{
							desistiu = true;
							AnelMagoPlugin.Log.LogWarning((object)"Moldura: objeto da moldura nao encontrado no slot (sem moldura de equipado)");
							break;
						}
						if (!disseAnel)
						{
							disseAnel = true;
							AnelMagoPlugin.Log.LogInfo((object)"Moldura: funcionando (anel encontrado no inventario)");
						}
					}
				}
			}
			catch (Exception ex)
			{
				desistiu = true;
				AnelMagoPlugin.Log.LogWarning((object)("Moldura: erro, moldura desligada: " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGrid), "UpdateGui")]
	public static class InventoryGrid_UpdateGui_Patch
	{
		private static void Postfix(InventoryGrid __instance)
		{
			Moldura.Aplicar(__instance);
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "Update")]
	public static class InventoryGui_Update_Patch
	{
		private static readonly FieldInfo campoJogador = AccessTools.GetDeclaredFields(typeof(InventoryGui)).FirstOrDefault((FieldInfo f) => f.Name == "m_playerGrid");

		private static void Postfix(InventoryGui __instance)
		{
			if (InventoryGui.IsVisible())
			{
				Moldura.Aplicar((InventoryGrid)((campoJogador == null) ? null : /*isinst with value type is only supported in some contexts*/));
			}
		}
	}
	public static class Berserk
	{
		public static bool Ligado;

		public static float Fim;

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

		public static void Dizer(string chave, string texto, bool aviso)
		{
			if (jaDisse.Add(chave))
			{
				if (aviso)
				{
					AnelMagoPlugin.Log.LogWarning((object)("Guerreiro: " + texto));
				}
				else
				{
					AnelMagoPlugin.Log.LogInfo((object)("Guerreiro: " + texto));
				}
			}
		}

		public static void Usar(Player jogador)
		{
			if (!Recargas.Tentar(jogador, "Guerreiro", AnelMagoPlugin.BerserkRecarga.Value))
			{
				return;
			}
			Ligado = true;
			Fim = Time.time + AnelMagoPlugin.BerserkDuracao.Value;
			float num = Mathf.Clamp01(AnelMagoPlugin.BerserkCustoDeVida.Value);
			if (num > 0f)
			{
				try
				{
					((Character)jogador).SetHealth(Mathf.Max(1f, ((Character)jogador).GetHealth() * (1f - num)));
				}
				catch (Exception ex)
				{
					Dizer("vida", "nao deu para tirar a vida: " + ex.Message, aviso: true);
				}
			}
			Movimento.Aplicar(jogador, AnelMagoPlugin.BerserkVelocidade.Value);
			AnelEfeitos.Aplicar(jogador, "Guerreiro");
			Sons.Tocar(jogador, "Guerreiro");
		}

		public static void Encerrar(Player jogador)
		{
			if (!Ligado)
			{
				return;
			}
			Ligado = false;
			Fim = 0f;
			try
			{
				if ((Object)(object)jogador != (Object)null)
				{
					Movimento.Restaurar(jogador);
					AnelEfeitos.Remover(jogador, "Guerreiro");
				}
			}
			catch (Exception ex)
			{
				Dizer("encerrar", "erro ao encerrar: " + ex.Message, aviso: true);
			}
		}

		public static float BonusDeDano(Player jogador)
		{
			float num = 1f - Mathf.Clamp01(((Character)jogador).GetHealthPercentage());
			return Mathf.Lerp(AnelMagoPlugin.BerserkDanoBase.Value, AnelMagoPlugin.BerserkDanoMax.Value, num);
		}
	}
	[HarmonyPatch(typeof(Player), "Update")]
	public static class Player_Berserk_Patch
	{
		private static void Postfix(Player __instance)
		{
			if (Berserk.Ligado && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && (((Character)__instance).IsDead() || Time.time >= Berserk.Fim))
			{
				Berserk.Encerrar(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "Damage")]
	public static class Character_BerserkDano_Patch
	{
		private static void Prefix(Character __instance, HitData hit)
		{
			if (Berserk.Ligado && hit != null)
			{
				Player localPlayer = Player.m_localPlayer;
				if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)__instance == (Object)(object)localPlayer) && !((Object)(object)hit.GetAttacker() != (Object)(object)localPlayer))
				{
					float num = Berserk.BonusDeDano(localPlayer);
					((DamageTypes)(ref hit.m_damage)).Modify(1f + num);
					Berserk.Dizer("dano", "primeiro golpe com dano +" + (num * 100f).ToString("0") + "%", aviso: false);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Character), "RPC_Damage")]
	public static class Character_BerserkRecebido_Patch
	{
		private static void Prefix(Character __instance, object[] __args)
		{
			if (!Berserk.Ligado || (Object)(object)__instance != (Object)(object)Player.m_localPlayer || __args == null)
			{
				return;
			}
			foreach (object obj in __args)
			{
				HitData val = (HitData)((obj is HitData) ? obj : null);
				if (val != null)
				{
					((DamageTypes)(ref val.m_damage)).Modify(AnelMagoPlugin.BerserkDanoRecebido.Value);
					break;
				}
			}
		}
	}
	public static class AnelItens
	{
		private static readonly string[] Classes = new string[5] { "Mago", "Guerreiro", "Assassino", "Arqueiro", "Tank" };

		private static readonly Color[] Cores = (Color[])(object)new Color[5]
		{
			new Color(0.3f, 0.62f, 1f),
			new Color(0.95f, 0.18f, 0.14f),
			new Color(0.66f, 0.3f, 0.95f),
			new Color(0.3f, 0.85f, 0.32f),
			new Color(1f, 0.62f, 0.12f)
		};

		public static string[] NomesDasClasses => Classes;

		public static Color Cor(string classe)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			int num = Array.IndexOf(Classes, classe);
			if (num < 0)
			{
				return Color.white;
			}
			return Cores[num];
		}

		public static void Registrar()
		{
			PrefabManager.OnVanillaPrefabsAvailable += Criar;
		}

		private static void Criar()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			PrefabManager.OnVanillaPrefabsAvailable -= Criar;
			for (int i = 0; i < Classes.Length; i++)
			{
				try
				{
					CustomItem val = new CustomItem("Anel" + Classes[i], "CrownJewel");
					SharedData shared = val.ItemDrop.m_itemData.m_shared;
					shared.m_name = AnelTextos.NomeDoAnel(Classes[i]);
					shared.m_description = AnelTextos.Descricao(Classes[i]);
					shared.m_maxStackSize = 1;
					shared.m_weight = 0.5f;
					shared.m_value = 0;
					Sprite val2 = AnelDesenho.CriarIcone(Cores[i]);
					if ((Object)(object)val2 != (Object)null)
					{
						shared.m_icons = (Sprite[])(object)new Sprite[1] { val2 };
					}
					if (AnelMagoPlugin.ModeloDeAnel.Value)
					{
						AnelDesenho.TrocarModelo(val.ItemPrefab, Cores[i]);
					}
					if ((Object)(object)val2 == (Object)null && shared.m_icons != null && shared.m_icons.Length != 0)
					{
						val2 = shared.m_icons[0];
					}
					AnelEfeitos.Registrar(Classes[i], val2);
					ItemManager.Instance.AddItem(val);
					AnelMagoPlugin.Log.LogInfo((object)("Item Anel" + Classes[i] + " criado"));
				}
				catch (Exception ex)
				{
					AnelMagoPlugin.Log.LogError((object)("Falha ao criar Anel" + Classes[i] + ": " + ex.Message));
				}
			}
		}
	}
	[BepInPlugin("seunome.valheim.anelmago", "Anéis Rúnicos", "1.3.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class AnelMagoPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static ConfigEntry<KeyCode> Tecla;

		internal static ConfigEntry<float> TrocaSegundos;

		internal static ConfigEntry<bool> ModeloDeAnel;

		internal static ConfigEntry<bool> AvisoPronto;

		internal static ConfigEntry<float> Duracao;

		internal static ConfigEntry<float> Recarga;

		internal static ConfigEntry<float> MagoBonusHabilidade;

		internal static ConfigEntry<float> MagoMultiplicadorDano;

		internal static ConfigEntry<bool> ModoTeste;

		internal static ConfigEntry<float> TesteRecarga;

		internal static ConfigEntry<float> DashDistancia;

		internal static ConfigEntry<float> DashImunidade;

		internal static ConfigEntry<float> DashMultiplicador;

		internal static ConfigEntry<float> DashBonusPrazo;

		internal static ConfigEntry<float> DashRecarga;

		internal static ConfigEntry<float> ArcoVelocidade;

		internal static ConfigEntry<float> AssassinoDuracao;

		internal static ConfigEntry<float> AssassinoRecarga;

		internal static ConfigEntry<float> AssassinoVelocidade;

		internal static ConfigEntry<float> AssassinoOpacidade;

		internal static ConfigEntry<float> AssassinoEscuridao;

		internal static ConfigEntry<float> TankDuracao;

		internal static ConfigEntry<float> TankRecarga;

		internal static ConfigEntry<float> TankRaio;

		internal static ConfigEntry<float> TankReducaoBase;

		internal static ConfigEntry<float> TankDefesaPorDez;

		internal static ConfigEntry<float> TankDefesaMax;

		internal static ConfigEntry<float> TankVelocidade;

		internal static ConfigEntry<float> TankFraqueza;

		internal static ConfigEntry<float> TankFraquezaDuracao;

		internal static ConfigEntry<bool> DropLigado;

		internal static ConfigEntry<float> DropPrimeiroBoss;

		internal static ConfigEntry<float> DropAumento;

		internal static ConfigEntry<string> DropBosses;

		internal static ConfigEntry<bool> DropMobsLigado;

		internal static ConfigEntry<float> DropMobsChance;

		internal static ConfigEntry<string> DropMobs;

		internal static ConfigEntry<float> BerserkDuracao;

		internal static ConfigEntry<float> BerserkRecarga;

		internal static ConfigEntry<float> BerserkDanoBase;

		internal static ConfigEntry<float> BerserkDanoMax;

		internal static ConfigEntry<float> BerserkDanoRecebido;

		internal static ConfigEntry<float> BerserkCustoDeVida;

		internal static ConfigEntry<float> BerserkVelocidadeAtaque;

		internal static ConfigEntry<float> BerserkVelocidade;

		internal static ConfigEntry<float> BerserkVermelho;

		private void Awake()
		{
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_0687: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Tecla = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Habilidade", "Tecla", (KeyCode)113, "Tecla que ativa a habilidade do anel equipado");
			Duracao = ((BaseUnityPlugin)this).Config.Bind<float>("Habilidade", "DuracaoSegundos", 5f, "Mago: duração do éter infinito");
			Recarga = ((BaseUnityPlugin)this).Config.Bind<float>("Habilidade", "RecargaSegundos", 30f, "Mago: tempo até poder usar de novo");
			TrocaSegundos = ((BaseUnityPlugin)this).Config.Bind<float>("Anel", "TrocaDeAnelSegundos", 10f, "Espera entre equipar/desequipar anéis");
			ModeloDeAnel = ((BaseUnityPlugin)this).Config.Bind<bool>("Anel", "ModeloDeAnel", true, "Troca o modelo da joia por um anel quando o item está no chão (precisa reiniciar o jogo para mudar)");
			AvisoPronto = ((BaseUnityPlugin)this).Config.Bind<bool>("Habilidade", "AvisarQuandoPronta", true, "Mostra um aviso (e toca um som) quando a recarga de uma habilidade termina");
			MagoBonusHabilidade = ((BaseUnityPlugin)this).Config.Bind<float>("Habilidade", "MagoBonusDeHabilidade", 30f, "Mago: pontos de habilidade somados em Magia Elemental e Magia de Sangue durante o éter infinito");
			MagoMultiplicadorDano = ((BaseUnityPlugin)this).Config.Bind<float>("Habilidade", "MagoMultiplicadorDeDano", 2f, "Mago: multiplicador do dano das magias (Magia Elemental e Magia de Sangue) durante o éter infinito (2 = dobro)");
			ModoTeste = ((BaseUnityPlugin)this).Config.Bind<bool>("Teste", "ModoDeTeste", false, "Liga o modo de teste: todas as habilidades recarregam em TesteRecargaSegundos e a troca de anel não tem espera. Desligue para jogar com as recargas normais.");
			TesteRecarga = ((BaseUnityPlugin)this).Config.Bind<float>("Teste", "TesteRecargaSegundos", 5f, "Recarga de todas as habilidades no modo de teste");
			DashDistancia = ((BaseUnityPlugin)this).Config.Bind<float>("Arqueiro", "DashDistanciaMetros", 12f, "Distância do teleporte do dash");
			DashImunidade = ((BaseUnityPlugin)this).Config.Bind<float>("Arqueiro", "DashImunidadeSegundos", 1f, "Tempo sem receber dano depois do dash");
			DashMultiplicador = ((BaseUnityPlugin)this).Config.Bind<float>("Arqueiro", "DashMultiplicadorDano", 2f, "Multiplicador de dano do próximo ataque depois do dash (2 = dobro)");
			DashBonusPrazo = ((BaseUnityPlugin)this).Config.Bind<float>("Arqueiro", "DashBonusPrazoSegundos", 10f, "Duração do efeito do dash: tempo para usar o ataque com bônus e para o arco rápido (0 = sem prazo)");
			DashRecarga = ((BaseUnityPlugin)this).Config.Bind<float>("Arqueiro", "DashRecargaSegundos", 10f, "Arqueiro: tempo até poder usar o dash de novo");
			ArcoVelocidade = ((BaseUnityPlugin)this).Config.Bind<float>("Arqueiro", "DashVelocidadeDoArco", 1.5f, "Velocidade de puxar o arco durante o efeito do dash (1.5 = 50% mais rápido)");
			AssassinoDuracao = ((BaseUnityPlugin)this).Config.Bind<float>("Assassino", "InvisibilidadeDuracaoSegundos", 15f, "Duração máxima da invisibilidade (ela acaba antes se você atacar)");
			AssassinoRecarga = ((BaseUnityPlugin)this).Config.Bind<float>("Assassino", "InvisibilidadeRecargaSegundos", 30f, "Assassino: tempo até poder usar a invisibilidade de novo");
			AssassinoVelocidade = ((BaseUnityPlugin)this).Config.Bind<float>("Assassino", "InvisibilidadeVelocidade", 1.15f, "Velocidade de movimento enquanto invisível (1.15 = 15% mais rápido)");
			AssassinoOpacidade = ((BaseUnityPlugin)this).Config.Bind<float>("Assassino", "InvisibilidadeOpacidade", 0.25f, "Opacidade do personagem enquanto invisível (0 = some, 1 = sem efeito visual)");
			AssassinoEscuridao = ((BaseUnityPlugin)this).Config.Bind<float>("Assassino", "InvisibilidadeVinhetaPreta", 0.95f, "Força da vinheta preta nas bordas da tela enquanto invisível (0 = desligado, 1 = bem escuro)");
			TankDuracao = ((BaseUnityPlugin)this).Config.Bind<float>("Tank", "DuracaoSegundos", 20f, "Duração do efeito do Tank");
			TankRecarga = ((BaseUnityPlugin)this).Config.Bind<float>("Tank", "RecargaSegundos", 45f, "Tank: tempo até poder usar de novo");
			TankRaio = ((BaseUnityPlugin)this).Config.Bind<float>("Tank", "RaioProvocarMetros", 20f, "Distância em que as criaturas são provocadas");
			TankReducaoBase = ((BaseUnityPlugin)this).Config.Bind<float>("Tank", "ReducaoDeDanoBase", 0.3f, "Redução de dano base (0.30 = 30%)");
			TankDefesaPorDez = ((BaseUnityPlugin)this).Config.Bind<float>("Tank", "DefesaExtraPorDezPorCentoDeVida", 0.05f, "Redução extra a cada 10% da vida máxima perdida durante o efeito (0.05 = 5%)");
			TankDefesaMax = ((BaseUnityPlugin)this).Config.Bind<float>("Tank", "DefesaExtraMaxima", 0.3f, "Limite da redução extra (0.30 = 30%, somando com a base dá 60%)");
			TankVelocidade = ((BaseUnityPlugin)this).Config.Bind<float>("Tank", "Velocidade", 0.9f, "Velocidade de movimento durante o efeito (0.90 = 10% mais lento)");
			TankFraqueza = ((BaseUnityPlugin)this).Config.Bind<float>("Tank", "FraquezaDanoRecebido", 1.5f, "Fraqueza: as criaturas no raio recebem esse multiplicador de dano de qualquer jogador (1.5 = 50% a mais)");
			TankFraquezaDuracao = ((BaseUnityPlugin)this).Config.Bind<float>("Tank", "FraquezaDuracaoSegundos", 20f, "Quanto tempo a fraqueza fica nas criaturas");
			BerserkDuracao = ((BaseUnityPlugin)this).Config.Bind<float>("Guerreiro", "BerserkDuracaoSegundos", 15f, "Duração do Berserk");
			BerserkRecarga = ((BaseUnityPlugin)this).Config.Bind<float>("Guerreiro", "BerserkRecargaSegundos", 60f, "Guerreiro: tempo até poder usar o Berserk de novo");
			BerserkDanoBase = ((BaseUnityPlugin)this).Config.Bind<float>("Guerreiro", "BerserkDanoExtraBase", 0.25f, "Dano extra com a vida cheia (0.25 = +25%)");
			BerserkDanoMax = ((BaseUnityPlugin)this).Config.Bind<float>("Guerreiro", "BerserkDanoExtraMaximo", 0.75f, "Dano extra com a vida quase zerada (0.75 = +75%); entre os dois o bônus cresce conforme a vida cai");
			BerserkDanoRecebido = ((BaseUnityPlugin)this).Config.Bind<float>("Guerreiro", "BerserkDanoRecebido", 1.2f, "Multiplicador do dano que você recebe durante o Berserk (1.20 = 20% a mais)");
			BerserkCustoDeVida = ((BaseUnityPlugin)this).Config.Bind<float>("Guerreiro", "BerserkCustoDeVida", 0.5f, "Parte da vida atual que você perde ao ativar o Berserk (0.5 = cai pela metade, 0 = nada)");
			BerserkVelocidadeAtaque = ((BaseUnityPlugin)this).Config.Bind<float>("Guerreiro", "BerserkVelocidadeDeAtaque", 1.15f, "Velocidade dos ataques durante o Berserk (1.15 = 15% mais rápido)");
			BerserkVelocidade = ((BaseUnityPlugin)this).Config.Bind<float>("Guerreiro", "BerserkVelocidade", 1.1f, "Velocidade de movimento durante o Berserk (1.10 = 10% mais rápido)");
			BerserkVermelho = ((BaseUnityPlugin)this).Config.Bind<float>("Guerreiro", "BerserkVermelhoNaTela", 0.45f, "Força do vermelho nas bordas da tela durante o Berserk (0 = desligado, 1 = bem forte)");
			DropLigado = ((BaseUnityPlugin)this).Config.Bind<bool>("Drop", "BossesDropamAneis", true, "Os bosses podem dropar um anel aleatório ao morrer (sempre 1 unidade, mesmo com estrelas)");
			DropPrimeiroBoss = ((BaseUnityPlugin)this).Config.Bind<float>("Drop", "ChanceDoPrimeiroBoss", 2f, "Chance de drop do primeiro boss da lista, em % (2 = 2%)");
			DropAumento = ((BaseUnityPlugin)this).Config.Bind<float>("Drop", "AumentoPorBoss", 2f, "Quanto a chance sobe a cada boss seguinte da lista, em % (2 = 2%, 4%, 6%...)");
			DropBosses = ((BaseUnityPlugin)this).Config.Bind<string>("Drop", "OrdemDosBosses", "Eikthyr,gd_king,Bonemass,Dragon,GoblinKing,SeekerQueen,Fader,FrozenKing|FrozenKing_p2|FrozenKing_p3", "Bosses na ordem de progressão (nomes internos do jogo, separados por vírgula). O primeiro usa a chance inicial e cada um depois soma o aumento. Use | para vários nomes do mesmo boss.");
			DropMobsLigado = ((BaseUnityPlugin)this).Config.Bind<bool>("Drop", "MobsDropamAneis", true, "Algumas criaturas comuns podem dropar o anel da classe ligada a elas (sempre 1 unidade)");
			DropMobsChance = ((BaseUnityPlugin)this).Config.Bind<float>("Drop", "ChanceDosMobs", 0.1f, "Chance de drop das criaturas comuns, em % (0.1 = 0,1%, ou seja, 1 em 1000)");
			DropMobs = ((BaseUnityPlugin)this).Config.Bind<string>("Drop", "MobsEAneis", "Ghost:Assassino,StoneGolem:Tank,GoblinBrute:Guerreiro,Charred_Archer:Arqueiro,Charred_Mage:Mago", "Criatura:Classe do anel, separados por vírgula (nomes internos). Ghost = Fantasma, StoneGolem = Golem de Pedra, GoblinBrute = Fuling Berserker, Charred_Archer = Atirador Carbonizado, Charred_Mage = Feiticeiro Carbonizado.");
			Sons.Configurar(((BaseUnityPlugin)this).Config);
			AnelItens.Registrar();
			Harmony harmony = new Harmony("seunome.valheim.anelmago");
			Aplicar(harmony, typeof(Player_Update_Patch));
			Aplicar(harmony, typeof(Player_HaveEitr_Patch));
			Aplicar(harmony, typeof(Player_UseEitr_Patch)