Decompiled source of MushokuTenseiCore v2.5.9

plugins/MT.Core/MT.Core.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using MT.Core.Commands;
using MT.Core.Compat;
using MT.Core.Diario;
using MT.Core.Especialidades;
using MT.Core.I18n;
using MT.Core.Mana;
using MT.Core.Rueda;
using MT.Core.Touki;
using MT.Core.Vfx;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("MT.Core")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ffb23be1655489b43ebd87164178fc39ecbb9f14")]
[assembly: AssemblyProduct("MT.Core")]
[assembly: AssemblyTitle("MT.Core")]
[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 MT.Core
{
	public static class AtaqueSeguro
	{
		public static readonly List<Func<Player, bool>> OcupadoAProposito = new List<Func<Player, bool>>();

		private static float _fallaDesde = -1f;

		private static Attack _visto;

		private static float _vistoDesde;

		public static event Action<Player> Reiniciar;

		internal static bool Ocupado(Player p)
		{
			foreach (Func<Player, bool> item in OcupadoAProposito)
			{
				try
				{
					if (item(p))
					{
						return true;
					}
				}
				catch
				{
				}
			}
			return false;
		}

		public static bool AtaqueReal(Player p, Attack a)
		{
			//IL_007d: 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_0090: Invalid comparison between Unknown and I4
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Invalid comparison between Unknown and I4
			if (a == null || a.IsDone())
			{
				return false;
			}
			ItemData val = Campos.AtaqueArma.Invoke(a);
			ItemData currentWeapon = ((Humanoid)p).GetCurrentWeapon();
			if (val != null && currentWeapon != null && val != currentWeapon)
			{
				return false;
			}
			if (a != _visto)
			{
				_visto = a;
				_vistoDesde = Time.time;
			}
			if (Time.time - _vistoDesde <= 3f || a.m_loopingAttack || ((Character)p).IsDrawingBow())
			{
				return true;
			}
			SkillType? val2 = currentWeapon?.m_shared.m_skillType;
			if ((int)val2.GetValueOrDefault() != 8)
			{
				return (int)val2.GetValueOrDefault() == 14;
			}
			return true;
		}

		public static void Liberar(Player p, string motivo)
		{
			if ((Object)(object)p == (Object)null)
			{
				return;
			}
			BloqueoClic.Liberar();
			try
			{
				AtaqueSeguro.Reiniciar?.Invoke(p);
			}
			catch (Exception ex)
			{
				MTCorePlugin.Log.LogError((object)("AtaqueSeguro: " + ex));
			}
			Attack val = Campos.AtaqueActual.Invoke((Humanoid)(object)p);
			if (val != null && !AtaqueReal(p, val))
			{
				try
				{
					val.Stop();
				}
				catch
				{
				}
				Campos.AtaqueActual.Invoke((Humanoid)(object)p) = null;
				val = null;
			}
			if (((Character)p).InAttack() && val == null)
			{
				ZSyncAnimation val2 = Campos.Anim.Invoke((Character)(object)p);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.SetTrigger("attack_abort");
					val2.SetBool("attack_rapidfire", false);
				}
			}
			Animator val3 = Campos.Animador.Invoke((Character)(object)p);
			if ((Object)(object)val3 != (Object)null && val3.speed < 0.05f)
			{
				val3.speed = 1f;
			}
			_fallaDesde = -1f;
			MTCorePlugin.Log.LogInfo((object)("[Ataque] desbloqueado: " + motivo));
		}

		internal static void Resultado(Player p, bool salio)
		{
			if (salio)
			{
				_fallaDesde = -1f;
			}
			else if (!ZInput.GetButton("Attack") && !ZInput.GetButton("SecondaryAttack"))
			{
				_fallaDesde = -1f;
			}
			else if (AtaqueReal(p, Campos.AtaqueActual.Invoke((Humanoid)(object)p)) || RuedaHabilidades.Abierta || DiarioVentana.Abierto || ((Character)p).IsStaggering() || ((Character)p).InDodge() || Agotamiento.IsCollapsed(p) || BloqueoClic.Bloquea || Ocupado(p))
			{
				_fallaDesde = -1f;
			}
			else if (_fallaDesde < 0f)
			{
				_fallaDesde = Time.time;
			}
			else if (Time.time - _fallaDesde >= 0.5f)
			{
				Liberar(p, "pulsabas atacar y no salía");
			}
		}
	}
	[HarmonyPatch(typeof(Humanoid), "StartAttack")]
	public static class AtaqueSeguroPatch
	{
		[HarmonyPriority(0)]
		private static void Postfix(Humanoid __instance, bool __result)
		{
			Player val = (Player)(object)((__instance is Player) ? __instance : null);
			if (val != null && (Object)(object)val == (Object)(object)Player.m_localPlayer)
			{
				AtaqueSeguro.Resultado(val, __result);
			}
		}
	}
	[HarmonyPatch(typeof(Humanoid), "EquipItem")]
	public static class AtaqueSeguroEquipPatch
	{
		private static void Postfix(Humanoid __instance, ItemData item, bool __result)
		{
			if (__result && item != null)
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null && !((Object)(object)val != (Object)(object)Player.m_localPlayer) && item.IsWeapon())
				{
					AtaqueSeguro.Liberar(val, "cambio de arma");
				}
			}
		}
	}
	public class DesatascarCommand : ConsoleCommand
	{
		public override string Name => "mt_unstuck";

		public override string Help => "If you can't attack or cast: clears every attack lock of the MT mods";

		public override void Run(string[] args)
		{
			AtaqueSeguro.Liberar(Player.m_localPlayer, "mt_unstuck");
			Console.instance.Print("OK");
		}
	}
	public class AyudaTeclas : MonoBehaviour
	{
		private GUIStyle _estilo;

		private string _texto;

		private string _idioma;

		private KeyCode _diario;

		private KeyCode _grimorio;

		private void OnGUI()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ee: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected O, but got Unknown
			if ((int)Event.current.type != 7 || !CoreConfig.AyudaTeclas.Value)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && !((Character)localPlayer).IsDead() && !((Object)(object)Hud.instance == (Object)null) && Hud.instance.IsVisible() && !Hud.IsUserHidden() && !InventoryGui.IsVisible() && !Menu.IsVisible() && !Minimap.IsOpen() && !Console.IsVisible())
			{
				bool flag = Chainloader.PluginInfos.ContainsKey("mushokutensei.magia");
				if (_texto == null || _idioma != Tr.Current || _diario != MTKeys.Diario.Value || _grimorio != MTKeys.MenuHechizos.Value)
				{
					_idioma = Tr.Current;
					_diario = MTKeys.Diario.Value;
					_grimorio = MTKeys.MenuHechizos.Value;
					_texto = string.Format("[{0}] {1}", _diario, Tr.Get("core_hint_diario")) + (flag ? string.Format("    [{0}] {1}", _grimorio, Tr.Get("core_hint_grimorio")) : "");
				}
				if (_estilo == null)
				{
					_estilo = new GUIStyle(GUI.skin.label)
					{
						alignment = (TextAnchor)8,
						fontStyle = (FontStyle)1
					};
				}
				float scale = MTGui.Scale;
				_estilo.fontSize = Mathf.RoundToInt(15f * scale);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor((float)Screen.width - 520f * scale, (float)Screen.height - 34f * scale, 500f * scale, 26f * scale);
				Color color = GUI.color;
				GUI.color = new Color(0f, 0f, 0f, 0.75f);
				GUI.Label(new Rect(((Rect)(ref val)).x + 1f, ((Rect)(ref val)).y + 1f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), _texto, _estilo);
				GUI.color = new Color(1f, 0.9f, 0.7f, 0.85f);
				GUI.Label(val, _texto, _estilo);
				GUI.color = color;
			}
		}
	}
	public class BloqueoClic : MonoBehaviour
	{
		private static bool _activo;

		public static float BloqueadoHasta;

		private static readonly FieldRef<Player, float> ColaAtaque = AccessTools.FieldRefAccess<Player, float>("m_queuedAttackTimer");

		private static readonly FieldRef<Player, float> ColaSecundario = AccessTools.FieldRefAccess<Player, float>("m_queuedSecondAttackTimer");

		private static bool MenuAbierto
		{
			get
			{
				if (!DiarioVentana.Abierto)
				{
					return DiarioVentana.OtroMenuAbierto?.Invoke() ?? false;
				}
				return true;
			}
		}

		private static bool Pulsado
		{
			get
			{
				if (!ZInput.GetMouseButton(0) && !ZInput.GetMouseButton(1) && !ZInput.GetButton("Attack"))
				{
					return ZInput.GetButton("SecondaryAttack");
				}
				return true;
			}
		}

		public static bool Bloquea
		{
			get
			{
				if (!_activo || !Pulsado)
				{
					return Time.time < BloqueadoHasta;
				}
				return true;
			}
		}

		public static void Liberar()
		{
			_activo = false;
			BloqueadoHasta = 0f;
		}

		public static void Bloquear(float duracion = 0.35f)
		{
			_activo = true;
			BloqueadoHasta = Mathf.Max(BloqueadoHasta, Time.time + duracion);
		}

		public static void VaciarCola(Player p)
		{
			if (!((Object)(object)p == (Object)null))
			{
				ColaAtaque.Invoke(p) = 0f;
				ColaSecundario.Invoke(p) = 0f;
			}
		}

		private void Update()
		{
			if (MenuAbierto || Bloquea)
			{
				VaciarCola(Player.m_localPlayer);
			}
			if (MenuAbierto)
			{
				if (Pulsado)
				{
					_activo = true;
				}
			}
			else if (!Pulsado && Time.time >= BloqueadoHasta)
			{
				_activo = false;
			}
		}
	}
	[HarmonyPatch(typeof(Humanoid), "StartAttack")]
	public static class BloqueoClicAtaquePatch
	{
		[HarmonyPriority(800)]
		private static bool Prefix(Humanoid __instance, ref bool __result)
		{
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || (!BloqueoClic.Bloquea && !RuedaHabilidades.Abierta))
			{
				return true;
			}
			BloqueoClic.VaciarCola(Player.m_localPlayer);
			__result = false;
			return false;
		}
	}
	public static class Campos
	{
		public static readonly FieldRef<SEMan, Character> SEManPersonaje = AccessTools.FieldRefAccess<SEMan, Character>("m_character");

		public static readonly FieldRef<Character, bool> Corriendo = AccessTools.FieldRefAccess<Character, bool>("m_run");

		public static readonly FieldRef<Character, Rigidbody> Cuerpo = AccessTools.FieldRefAccess<Character, Rigidbody>("m_body");

		public static readonly FieldRef<Character, ZSyncAnimation> Anim = AccessTools.FieldRefAccess<Character, ZSyncAnimation>("m_zanim");

		public static readonly FieldRef<Character, float> AlturaMaxAire = AccessTools.FieldRefAccess<Character, float>("m_maxAirAltitude");

		public static readonly FieldRef<Character, CapsuleCollider> Colision = AccessTools.FieldRefAccess<Character, CapsuleCollider>("m_collider");

		public static readonly FieldRef<Character, Vector3> DirMovimiento = AccessTools.FieldRefAccess<Character, Vector3>("m_moveDir");

		public static readonly FieldRef<Humanoid, ItemData> Pecho = AccessTools.FieldRefAccess<Humanoid, ItemData>("m_chestItem");

		public static readonly FieldRef<Humanoid, ItemData> ManoDerecha = AccessTools.FieldRefAccess<Humanoid, ItemData>("m_rightItem");

		public static readonly FieldRef<Humanoid, ItemData> ManoIzquierda = AccessTools.FieldRefAccess<Humanoid, ItemData>("m_leftItem");

		public static readonly FieldRef<Skills, Player> SkillsJugador = AccessTools.FieldRefAccess<Skills, Player>("m_player");

		public static readonly FieldRef<VisEquipment, GameObject> InstanciaIzquierda = AccessTools.FieldRefAccess<VisEquipment, GameObject>("m_leftItemInstance");

		public static readonly FieldRef<Character, Animator> Animador = AccessTools.FieldRefAccess<Character, Animator>("m_animator");

		public static readonly FieldRef<Character, HitData> UltimoGolpe = AccessTools.FieldRefAccess<Character, HitData>("m_lastHit");

		public static readonly FieldRef<Humanoid, VisEquipment> VisEquipo = AccessTools.FieldRefAccess<Humanoid, VisEquipment>("m_visEquipment");

		public static readonly FieldRef<Humanoid, Attack> AtaqueActual = AccessTools.FieldRefAccess<Humanoid, Attack>("m_currentAttack");

		public static readonly FieldRef<Humanoid, bool> AtaqueSecundario = AccessTools.FieldRefAccess<Humanoid, bool>("m_currentAttackIsSecondary");

		public static readonly FieldRef<Attack, Humanoid> AtaquePersonaje = AccessTools.FieldRefAccess<Attack, Humanoid>("m_character");

		public static readonly FieldRef<Attack, ItemData> AtaqueArma = AccessTools.FieldRefAccess<Attack, ItemData>("m_weapon");

		public static readonly FieldRef<Attack, int> AtaqueCadena = AccessTools.FieldRefAccess<Attack, int>("m_currentAttackCainLevel");

		public static readonly FieldRef<VisEquipment, GameObject> InstanciaDerecha = AccessTools.FieldRefAccess<VisEquipment, GameObject>("m_rightItemInstance");

		public static readonly FieldRef<MeleeWeaponTrail, bool> EstelaEmite = AccessTools.FieldRefAccess<MeleeWeaponTrail, bool>("_emit");

		public static readonly FieldRef<StatusEffect, float> TiempoEfecto = AccessTools.FieldRefAccess<StatusEffect, float>("m_time");

		private static readonly FieldRef<List<PrivateArea>> _guardasRef = AccessTools.StaticFieldRefAccess<List<PrivateArea>>(AccessTools.Field(typeof(PrivateArea), "m_allAreas"));

		private static readonly Func<PrivateArea, Vector3, float, bool> _dentro = AccessTools.MethodDelegate<Func<PrivateArea, Vector3, float, bool>>(AccessTools.Method(typeof(PrivateArea), "IsInside", (Type[])null, (Type[])null), (object)null, true);

		private static readonly Func<Skills, SkillType, Skill> _getSkill = AccessTools.MethodDelegate<Func<Skills, SkillType, Skill>>(AccessTools.Method(typeof(Skills), "GetSkill", (Type[])null, (Type[])null), (object)null, true);

		private static readonly FieldInfo _textos = AccessTools.Field(typeof(DamageText), "m_worldTexts");

		private static FieldInfo _campoTexto;

		public static List<PrivateArea> Guardas
		{
			get
			{
				if (_guardasRef == null)
				{
					return null;
				}
				return _guardasRef.Invoke();
			}
		}

		public static bool DentroDeGuarda(PrivateArea a, Vector3 pos, float radius)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return _dentro(a, pos, radius);
		}

		public static Skill Skill(Player p, SkillType type)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			Skills val = (((Object)(object)p != (Object)null) ? ((Character)p).GetSkills() : null);
			if (!((Object)(object)val != (Object)null))
			{
				return null;
			}
			return _getSkill(val, type);
		}

		public static Skill Skill(Skills skills, SkillType type)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)skills != (Object)null))
			{
				return null;
			}
			return _getSkill(skills, type);
		}

		public static TMP_Text UltimoTextoDano(DamageText dt)
		{
			if ((Object)(object)dt == (Object)null || _textos == null)
			{
				return null;
			}
			if (!(_textos.GetValue(dt) is IList { Count: not 0 } list))
			{
				return null;
			}
			object obj = list[list.Count - 1];
			if (obj == null)
			{
				return null;
			}
			if (_campoTexto == null)
			{
				_campoTexto = AccessTools.Field(obj.GetType(), "m_textField");
			}
			object? obj2 = _campoTexto?.GetValue(obj);
			return (TMP_Text)((obj2 is TMP_Text) ? obj2 : null);
		}

		public static bool EsLocal(SEMan seman)
		{
			if (seman != null)
			{
				return (Object)(object)SEManPersonaje.Invoke(seman) == (Object)(object)Player.m_localPlayer;
			}
			return false;
		}
	}
	public static class CoreConfig
	{
		public enum ModoMuerte
		{
			Clasico,
			Equilibrado,
			Protegido
		}

		public enum ModoAgotamiento
		{
			Anime,
			Suave
		}

		public static ConfigEntry<int> LucesMagicasMax;

		public static ConfigEntry<float> ReservaInicial;

		public static ConfigEntry<float> ReservaMaxima;

		public static ConfigEntry<float> ReservaExponente;

		public static ConfigEntry<float> ManaPorPuntoDeExperiencia;

		public static ConfigEntry<float> BonusVaciarse;

		public static ConfigEntry<float> TalentoNacimiento;

		public static ConfigEntry<int> RanurasComida;

		public static ConfigEntry<bool> NadoRelajado;

		public static ConfigEntry<bool> AyudaTeclas;

		public static ConfigEntry<bool> RugidoManto;

		public static ConfigEntry<float> SaltoAhorroBase;

		public static ConfigEntry<float> CargaEntrenadaMax;

		public static ConfigEntry<float> EntrenoVelocidad;

		public static ConfigEntry<float> EntrenoMaxDia;

		public static ConfigEntry<float> DescansoMult;

		public static ConfigEntry<float> DescansoMana;

		public static ConfigEntry<float> DescansoManaLaplace;

		public static ConfigEntry<float> ProbLaplace;

		public static ConfigEntry<float> ProbLaplaceNivel;

		public static ConfigEntry<float> RegenLaplace;

		public static ConfigEntry<float> ProbGranReserva;

		public static ConfigEntry<float> RegenManaMult;

		public static ConfigEntry<float> CargaPorCuerpo;

		public static ConfigEntry<float> CargaPorToki;

		public static ConfigEntry<float> CargaTopeSinToki;

		public static ConfigEntry<float> CargaTopeConToki;

		public static ConfigEntry<float> CuerpoMinimoDespertar;

		public static ConfigEntry<float> CuerpoDespertarSeguro;

		public static ConfigEntry<float> ProbabilidadMinima;

		public static ConfigEntry<float> ProbabilidadMaxima;

		public static ConfigEntry<float> VidaCrisis;

		public static ConfigEntry<float> EnfriamientoCrisis;

		public static ConfigEntry<float> AguanteStaminaMax;

		public static ConfigEntry<float> CurvaAguante;

		public static ConfigEntry<float> ConversionEsfuerzo;

		public static ConfigEntry<float> MultCombate;

		public static ConfigEntry<float> MultPeligro;

		public static ConfigEntry<float> EsfuerzoCarga;

		public static ConfigEntry<float> EsfuerzoClima;

		public static ConfigEntry<float> PenalidadSinDormir;

		public static ConfigEntry<float> TrasnochadoRegen;

		public static ConfigEntry<int> NivelesTokiPorNoche;

		public static ConfigEntry<int> RitmoMaximo;

		public static ConfigEntry<string> GremioKillsPorRango;

		public static ConfigEntry<bool> DiarioPierdeHojas;

		public static ConfigEntry<float> StaminaPorNivelToki;

		public static ConfigEntry<float> SaltoCosto;

		public static ConfigEntry<float> SaltoCostoMin;

		public static ConfigEntry<float> StaminaRegenBase;

		public static ConfigEntry<float> VidaRegenBase;

		public static ConfigEntry<float> VelAtaqueBase;

		public static ConfigEntry<float> VelAtaquePorNivel;

		public static ConfigEntry<float> VelAtaqueMantoPorNivel;

		public static ConfigEntry<float> VelAtaquePunos;

		public static ConfigEntry<float> VelAtaqueTope;

		public static ConfigEntry<float> PasivaDano;

		public static ConfigEntry<float> PasivaVelocidad;

		public static ConfigEntry<float> PasivaSalto;

		public static ConfigEntry<float> PasivaStamina;

		public static ConfigEntry<float> StaminaAtaquePorNivel;

		public static ConfigEntry<float> PasivaDanoBase;

		public static ConfigEntry<float> PasivaVelocidadBase;

		public static ConfigEntry<float> PasivaSaltoBase;

		public static ConfigEntry<float> PasivaStaminaBase;

		public static ConfigEntry<float> TambaleoPorNivel;

		public static ConfigEntry<float> DominioSinManto;

		public static ConfigEntry<float> DominioConManto;

		public static ConfigEntry<float> CaidaBase;

		public static ConfigEntry<float> ToukiXpFisica;

		public static ConfigEntry<float> NadoTokiBase;

		public static ConfigEntry<float> NadoTokiPorNivel;

		public static ConfigEntry<float> LaplaceMult;

		public static ConfigEntry<float> LaplaceTokiMult;

		public static ConfigEntry<float> ManaPorRango;

		public static ConfigEntry<float> ManaPorMeditacion;

		public static ConfigEntry<float> ManaPorControl;

		public static ConfigEntry<float> TopeGeneral;

		public static ConfigEntry<float> TopeDiosDragon;

		public static ConfigEntry<float> XpAlAire;

		public static ConfigEntry<float> XpGolpeObjeto;

		public static ConfigEntry<float> XpMatar;

		public static ConfigEntry<float> XpEspecialista;

		public static ConfigEntry<float> TalarBase;

		public static ConfigEntry<float> TalarPorNivel;

		public static ConfigEntry<float> TopeStamina;

		public static ConfigEntry<float> TopeMana;

		public static ConfigEntry<float> ManaPorNivelToki;

		public static ConfigEntry<float> NadoMantoPorNivel;

		public static ConfigEntry<float> DanoObjetosPorNivel;

		public static ConfigEntry<float> PunosExtra;

		public static ConfigEntry<float> CostoActivar;

		public static ConfigEntry<bool> AuraPunos;

		public static ConfigEntry<bool> LlamasParticulas;

		public static ConfigEntry<float> AuraManosTamano;

		public static ConfigEntry<float> AuraGrosor;

		public static ConfigEntry<float> AuraRelleno;

		public static ConfigEntry<float> CaidaVidaPorNivel;

		public static ConfigEntry<float> CaidaVidaMinima;

		public static ConfigEntry<float> VidaPorCuerpo;

		public static ConfigEntry<float> StaminaEntrenadaMax;

		public static ConfigEntry<float> CaidaPorNivel;

		public static ConfigEntry<float> StaminaRegenPorNivel;

		public static ConfigEntry<float> VidaMaxPorNivel;

		public static ConfigEntry<bool> TextoXp;

		public static ConfigEntry<bool> NumerosXp;

		public static ConfigEntry<float> VidaRegenPorNivel;

		public static ConfigEntry<float> VidaRegenPlanaBase;

		public static ConfigEntry<float> VidaRegenPlanaPorNivel;

		public static ConfigEntry<float> VidaRegenEnCombate;

		public static ConfigEntry<float> VidaRegenCombateSegundos;

		public static ConfigEntry<float> VidaRegenMeditandoTope;

		public static ConfigEntry<float> BarraBase;

		public static ConfigEntry<float> BarraPorNivel;

		public static ConfigEntry<float> PerdidaTransferencia;

		public static ConfigEntry<float> MantenerQuieto;

		public static ConfigEntry<float> MantenerCorriendo;

		public static ConfigEntry<float> CostoGolpe;

		public static ConfigEntry<float> CostoSalto;

		public static ConfigEntry<float> VelocidadPorNivel;

		public static ConfigEntry<float> StaminaCorrerPorNivel;

		public static ConfigEntry<float> SaltoPorNivel;

		public static ConfigEntry<float> DanoPorNivel;

		public static ConfigEntry<float> AmortiguarPorNivel;

		public static ConfigEntry<float> DurezaPorNivel;

		public static ConfigEntry<float> SalvarGolpeMortal;

		public static ConfigEntry<float> SalvarSinManto;

		public static ConfigEntry<float> VidaMantoPorNivel;

		public static ConfigEntry<float> SorpresaPorNivel;

		public static ConfigEntry<float> ControlMaxReduccion;

		public static ConfigEntry<bool> ReflejoActivo;

		public static ConfigEntry<float> HitoReflejoGolpes;

		public static ConfigEntry<float> HitoNaturalMinutos;

		public static ConfigEntry<float> HitoMaestriaDano;

		public static ConfigEntry<bool> ToukiNaturalActivo;

		public static ConfigEntry<ModoMuerte> Muerte;

		public static ConfigEntry<bool> BarraManaSiempre;

		public static ConfigEntry<bool> AuraVisible;

		public static ConfigEntry<bool> NumerosDanoColor;

		public static ConfigEntry<float> NumerosDanoRojo;

		public static ConfigEntry<bool> DebugEntrenamiento;

		public static ConfigEntry<float> BarraX;

		public static ConfigEntry<float> BarraY;

		public static ConfigEntry<float> MeditacionCosto;

		public static ConfigEntry<float> MeditacionTopeReserva;

		public static ConfigEntry<float> MeditacionMinutosDiarios;

		public static ConfigEntry<float> BuffManaPorNivel;

		public static ConfigEntry<float> BuffRegenPorNivel;

		public static ConfigEntry<ModoAgotamiento> Agotamiento;

		public static ConfigEntry<bool> DescuentosGremio;

		public static void Bind(ConfigFile cfg)
		{
			//IL_059c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a9: Expected O, but got Unknown
			//IL_05a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: Expected O, but got Unknown
			//IL_066d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0672: Unknown result type (might be due to invalid IL or missing references)
			//IL_067a: Expected O, but got Unknown
			//IL_067a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0684: Expected O, but got Unknown
			//IL_06a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b0: Expected O, but got Unknown
			//IL_06b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ba: Expected O, but got Unknown
			//IL_0b82: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b87: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8f: Expected O, but got Unknown
			//IL_0b8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b99: Expected O, but got Unknown
			//IL_1071: Unknown result type (might be due to invalid IL or missing references)
			//IL_1076: Unknown result type (might be due to invalid IL or missing references)
			//IL_107e: Expected O, but got Unknown
			//IL_107e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1088: Expected O, but got Unknown
			//IL_10ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_10b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_10ba: Expected O, but got Unknown
			//IL_10ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_10c4: Expected O, but got Unknown
			//IL_10e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_10e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_10f0: Expected O, but got Unknown
			//IL_10f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_10fa: Expected O, but got Unknown
			AyudaTeclas = cfg.Bind<bool>("1. General", "AyudaTeclas", true, "Muestra abajo a la derecha las teclas del Diario y del Grimorio.");
			BarraBase = Admin(cfg, "4. Manto", "BarraBase", 0.25f, "Tamaño de la barra naranja (fracción del maná máximo) = base + nivel × por nivel.");
			BarraPorNivel = Admin(cfg, "4. Manto", "BarraPorNivel", 0.05f, "Aumento del tamaño de la barra naranja por nivel de tōki.");
			PerdidaTransferencia = Admin(cfg, "4. Manto", "PerdidaTransferencia", 0.1f, "Maná que se pierde al cargar o al devolver la barra naranja.");
			MantenerQuieto = Admin(cfg, "4. Manto", "MantenerQuieto", 0.5f, "Tōki por segundo con el manto activo, quieto o caminando.");
			MantenerCorriendo = Admin(cfg, "4. Manto", "MantenerCorriendo", 1.5f, "Tōki por segundo con el manto activo, corriendo.");
			CostoGolpe = Admin(cfg, "4. Manto", "CostoGolpe", 2f, "Tōki por golpe o disparo reforzado.");
			CostoSalto = Admin(cfg, "4. Manto", "CostoSalto", 1f, "Tōki por salto reforzado.");
			VelocidadPorNivel = Admin(cfg, "4. Manto", "VelocidadPorNivel", 0.04f, "Velocidad al correr por nivel con el manto (Nv 10 → +40 %).");
			StaminaCorrerPorNivel = Admin(cfg, "4. Manto", "StaminaCorrerPorNivel", 0.04f, "Reducción de stamina al correr por nivel con el manto (Nv 10 → −40 %).");
			VelAtaqueBase = Admin(cfg, "3. Tōki pasivo", "AtaqueVelBase", 0.02f, "Velocidad de ataque extra solo por tener el tōki despierto (puños, espada y cualquier arma).");
			VelAtaquePorNivel = Admin(cfg, "3. Tōki pasivo", "AtaqueVelPorNivel", 0.01f, "Velocidad de ataque por nivel de tōki, siempre. Nv 10 → +12 % con la base.");
			VelAtaqueMantoPorNivel = Admin(cfg, "4. Manto", "AtaqueVelPorNivel", 0.015f, "Velocidad de ataque extra por nivel con el manto activo (Nv 10 → +15 %).");
			VelAtaquePunos = Admin(cfg, "4. Manto", "AtaqueVelPunos", 0.25f, "Los puños sin arma ganan este extra sobre el bonus del tōki (0,25 = +25 % del bonus).");
			VelAtaqueTope = Admin(cfg, "4. Manto", "AtaqueVelTope", 0.4f, "Tope de velocidad de ataque sumando tōki, puños y estilos de espada (0,4 = +40 %).");
			StaminaAtaquePorNivel = Admin(cfg, "4. Manto", "StaminaAtaquePorNivel", 0.04f, "Reducción de stamina al atacar por nivel con el manto (Nv 10 → −40 %).");
			SaltoPorNivel = Admin(cfg, "4. Manto", "SaltoPorNivelToki", 0.05f, "Altura de salto por nivel de tōki con el manto (Nv 10 → +50 %).");
			DanoPorNivel = Admin(cfg, "4. Manto", "DanoPorNivel", 0.05f, "Daño físico cuerpo a cuerpo por nivel con el manto (Nv 10 → +50 %; a distancia, menos).");
			PasivaDano = Admin(cfg, "3. Tōki pasivo", "DanoPorNivel", 0.015f, "Daño físico por nivel de tōki, siempre (sin manto). Nv 10 → +15 %.");
			PasivaVelocidad = Admin(cfg, "3. Tōki pasivo", "VelocidadPorNivel", 0.01f, "Velocidad al moverse por nivel de tōki, siempre. Nv 10 → +10 %.");
			PasivaSalto = Admin(cfg, "3. Tōki pasivo", "SaltoPorNivel", 0.015f, "Altura de salto por nivel de tōki, siempre. Nv 10 → +15 %.");
			PasivaStamina = Admin(cfg, "3. Tōki pasivo", "StaminaGastoPorNivel", 0.02f, "Menos stamina en todo (correr, atacar, bloquear, esquivar, nadar, sigilo, herramientas) por nivel de tōki. Se suma a la base.");
			PasivaDanoBase = Admin(cfg, "3. Tōki pasivo", "DanoBase", 0.05f, "Daño físico extra solo por tener el tōki despierto (Nv 1 → +6.5 %, Nv 10 → +20 %).");
			PasivaVelocidadBase = Admin(cfg, "3. Tōki pasivo", "VelocidadBase", 0.1f, "Velocidad extra solo por tener el tōki despierto (Nv 1 → +11 %, Nv 10 → +20 %).");
			PasivaSaltoBase = Admin(cfg, "3. Tōki pasivo", "SaltoBase", 0.05f, "Altura de salto extra solo por tener el tōki despierto (Nv 1 → +6.5 %, Nv 10 → +20 %).");
			PasivaStaminaBase = Admin(cfg, "3. Tōki pasivo", "StaminaGastoBase", 0.1f, "Menos stamina en todo solo por tener el tōki despierto (Nv 1 → −12 %, Nv 10 → −30 %).");
			TambaleoPorNivel = Admin(cfg, "3. Tōki pasivo", "TambaleoPorNivel", 0.025f, "Menos tambaleo al recibir golpes por nivel de tōki (Nv 10 → −25 %).");
			CaidaBase = Admin(cfg, "3. Tōki pasivo", "CaidaBase", 0.5f, "Menos daño de caída solo por tener el tōki despierto (+ CaidaPorNivel; tope −90 %). Lo que quede se paga con maná azul y, si no hay, con vida.");
			NadoTokiBase = Admin(cfg, "3. Tōki pasivo", "NadoPasivoBase", 0.3f, "Velocidad al nadar extra solo por tener el tōki despierto, sin manto (+30 %).");
			NadoTokiPorNivel = Admin(cfg, "3. Tōki pasivo", "NadoPasivoPorNivel", 0.05f, "Velocidad al nadar extra por nivel de tōki, sin manto (Nv 1 → +35 %, Nv 10 → +80 %).");
			DominioSinManto = Admin(cfg, "3. Tōki pasivo", "DominioSinManto", 0.15f, "Experiencia de Dominio por cada punto de experiencia física (armas, correr, saltar, nadar, bloquear, talar, picar) sin el manto.");
			DominioConManto = Admin(cfg, "3. Tōki pasivo", "DominioConManto", 0.4f, "Lo mismo con el manto activo.");
			ToukiXpFisica = Admin(cfg, "3. Tōki pasivo", "ExperienciaFisica", 2f, "Multiplicador de experiencia de las habilidades físicas (armas, correr, saltar, nadar, sigilo, bloquear, talar, picar) con el tōki despierto.");
			AmortiguarPorNivel = Admin(cfg, "4. Manto", "Amortiguar", 0.06f, "Daño físico que amortigua el manto por nivel (Nv 4 → 24 %, Nv 10 → 60 %), pagando tōki.");
			DurezaPorNivel = Admin(cfg, "3. Tōki pasivo", "DurezaPorNivel", 0.02f, "Cuerpo endurecido: daño físico recibido menos por nivel, siempre, gratis (Nv 10 → −20 %). La armadura se suma encima.");
			SalvarGolpeMortal = Admin(cfg, "4. Manto", "EnfriamientoGolpeMortal", 60f, "Con el manto activo, un golpe mortal te deja con vida (CaidaVidaMinima) gastando la barra naranja. Segundos hasta repetirlo (0 = desactivado).");
			SalvarSinManto = Admin(cfg, "3. Tōki pasivo", "EnfriamientoGolpeMortalSinManto", 180f, "Tōki despierto sin manto: también resiste un golpe mortal, con este enfriamiento menos 10 s por nivel (Nv 1 → 170 s, Nv 10 → 80 s). 0 = desactivado.");
			VidaMantoPorNivel = Admin(cfg, "4. Manto", "VidaMantoPorNivel", 0.015f, "Vida máxima extra (fracción) por nivel con el manto activo.");
			SorpresaPorNivel = Admin(cfg, "3. Tōki pasivo", "SorpresaPorNivel", 0.03f, "Reducción de daño de golpes por la espalda por nivel.");
			ControlMaxReduccion = Admin(cfg, "1. Maná", "ControlMaxReduccion", 0.4f, "Reducción de costos con Control del maná 100.");
			HitoReflejoGolpes = Admin(cfg, "5. Hitos", "ReflejoGolpes", 25f, "Reflejo (Nv 4): golpes por la espalda o caídas sobrevividos gracias al tōki.");
			HitoNaturalMinutos = Admin(cfg, "5. Hitos", "NaturalMinutos", 30f, "Tōki natural (Nv 7): minutos en total con el manto activo.");
			HitoMaestriaDano = Admin(cfg, "5. Hitos", "MaestriaDano", 10000f, "Maestría (Nv 10): daño total amortiguado con el tōki.");
			LucesMagicasMax = cfg.Bind<int>("Rendimiento", "LucesMagicasMax", 6, "Máximo de luces de hechizos y técnicas encendidas a la vez (las más cercanas). Las demás se siguen viendo sin alumbrar. 0 = sin tope.");
			ReflejoActivo = cfg.Bind<bool>("5. Hitos", "Reflejo", true, "Nv 4: el tōki se activa solo un instante ante golpes por sorpresa y caídas (paga del maná azul).");
			ToukiNaturalActivo = cfg.Bind<bool>("5. Hitos", "ToukiNatural", true, "Nv 7: manto débil siempre activo, a cambio de reservar maná máximo.");
			Muerte = cfg.Bind<ModoMuerte>("6. Muerte", "Modo", ModoMuerte.Equilibrado, new ConfigDescription("Pérdida de las habilidades MT al morir: Clasico (como Valheim), Equilibrado (la mitad), Protegido (nada).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			MeditacionCosto = Admin(cfg, "8. Meditación", "CostoPorSegundo", 2f, "Maná que circula (se gasta) por segundo meditando.");
			MeditacionTopeReserva = Admin(cfg, "8. Meditación", "TopeReserva", 30f, "Hasta este nivel de Reserva, meditar la hace crecer; después solo da el buff.");
			MeditacionMinutosDiarios = Admin(cfg, "8. Meditación", "MinutosDiarios", 10f, "Minutos por día del juego con experiencia completa; después, al 25 %.");
			BuffManaPorNivel = Admin(cfg, "8. Meditación", "BuffManaPorNivel", 0.03f, "Mente en calma: maná máximo extra por nivel de meditación.");
			BuffRegenPorNivel = Admin(cfg, "8. Meditación", "BuffRegenPorNivel", 0.05f, "Mente en calma: regeneración de maná extra por nivel de meditación.");
			Agotamiento = cfg.Bind<ModoAgotamiento>("9. Agotamiento", "Modo", ModoAgotamiento.Anime, new ConfigDescription("Anime: colapso, agotamiento y desmayo si se repite. Suave: solo 10 s sin regenerar maná.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			DescuentosGremio = cfg.Bind<bool>("10. Gremio", "Descuentos", true, new ConfigDescription("Descuentos con los comerciantes según el rango del Gremio.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			DebugEntrenamiento = cfg.Bind<bool>("7. Interfaz", "AvisosEntrenamiento", true, "Mostrar en pantalla y en el log lo que entrenas al golpear árboles y rocas (para pruebas).");
			BarraManaSiempre = cfg.Bind<bool>("7. Interfaz", "BarraManaSiempreVisible", true, "Mostrar siempre la barra azul de maná (el juego la oculta cuando está llena).");
			AuraVisible = cfg.Bind<bool>("7. Interfaz", "AuraToki", true, "Aura de tōki con el manto: llamas de fuego envolviendo todo el cuerpo (shader propio).");
			CaidaVidaPorNivel = Admin(cfg, "3. Tōki pasivo", "CaidaVidaPorNivel", 0.08f, "Si el maná no alcanza para la caída, lo que baja de vida se reduce esto por nivel de tōki (Nv 10 → −80 %).");
			CaidaVidaMinima = Admin(cfg, "3. Tōki pasivo", "CaidaVidaMinima", 5f, "Con el tōki despierto, una caída nunca te mata: te deja como mínimo con esta vida.");
			AuraPunos = cfg.Bind<bool>("7. Interfaz", "AuraPunos", false, "Además, brillo de fuego envolviendo cada puño.");
			AuraGrosor = cfg.Bind<float>("7. Interfaz", "AuraGrosor", 0.035f, "Cuánto sobresale el aura del cuerpo (metros).");
			AuraRelleno = cfg.Bind<float>("7. Interfaz", "AuraRelleno", 0.15f, "Llamas por dentro de la silueta: 0 = solo el contorno arde, 1 = todo el cuerpo cubierto.");
			AuraManosTamano = cfg.Bind<float>("7. Interfaz", "AuraManosTamano", 0.18f, "Tamaño del brillo de tōki en cada puño (metros).");
			LlamasParticulas = cfg.Bind<bool>("7. Interfaz", "LlamasParticulas", false, "Además, llamas de partículas saliendo del cuerpo y las manos.");
			NumerosDanoColor = cfg.Bind<bool>("7. Interfaz", "NumerosDeDanoConColor", true, "Colorear los números de daño del juego de amarillo (poco) a rojo (mucho).");
			NumerosDanoRojo = cfg.Bind<float>("7. Interfaz", "NumerosDeDanoRojoDesde", 150f, "Daño a partir del cual el número sale rojo del todo.");
			BarraX = cfg.Bind<float>("7. Interfaz", "BarraTokiX", 0.5f, "Posición horizontal de la barra naranja (0 = izquierda, 1 = derecha).");
			BarraY = cfg.Bind<float>("7. Interfaz", "BarraTokiY", 0.93f, "Posición vertical de la barra naranja (0 = arriba, 1 = abajo).");
			ReservaInicial = Admin(cfg, "1. Maná", "ReservaInicial", 30f, "Maná propio con Reserva 0.");
			if (Mathf.Approximately(ReservaInicial.Value, 10f))
			{
				ReservaInicial.Value = 30f;
			}
			ReservaMaxima = Admin(cfg, "1. Maná", "ReservaMaxima", 300f, "Maná propio con Reserva 100 (sin comida ni el resto de fuentes).");
			ManaPorRango = Admin(cfg, "1. Maná", "ManaPorRangoMagico", 1.2f, "Maná por punto de tu mejor rango mágico (0–100; Dios = 100 → +120).");
			ManaPorMeditacion = Admin(cfg, "1. Maná", "ManaPorMeditacion", 0.3f, "Maná por nivel de Meditación (100 → +30).");
			ManaPorControl = Admin(cfg, "1. Maná", "ManaPorControl", 0.3f, "Maná por nivel de Control del maná (100 → +30).");
			TopeGeneral = Admin(cfg, "1. Maná", "TopeVidaStaminaMana", 700f, "Máximo de vida, stamina y maná con todo (comida, tōki, talento…).");
			XpAlAire = Admin(cfg, "11. Experiencia", "AlAire", 0.1f, "Experiencia del arma por practicar al aire (1 ataque por segundo cuenta).");
			XpGolpeObjeto = Admin(cfg, "11. Experiencia", "GolpearObjetos", 0.3f, "Experiencia del arma al golpear árboles, rocas y objetos (2 veces por segundo como mucho).");
			XpMatar = Admin(cfg, "11. Experiencia", "Matar", 1f, "Experiencia extra del arma al matar (× vida del enemigo / 50, entre 0.5 y 6; jefes ×3).");
			XpEspecialista = Admin(cfg, "11. Experiencia", "Especialista", 1.25f, "Tu arma principal (habilidad de combate más alta) gana esta experiencia extra.");
			TalarBase = Admin(cfg, "3. Tōki pasivo", "TalarBase", 0.4f, "Con el tōki despierto, parte del daño físico de cualquier golpe también tala árboles y pica rocas (40 % + TalarPorNivel).");
			TalarPorNivel = Admin(cfg, "3. Tōki pasivo", "TalarPorNivel", 0.06f, "Por nivel de tōki (Nv 10 → 100 %). La fuerza cuenta como herramienta de nivel 1 + nivel/2.");
			TopeStamina = Admin(cfg, "1. Maná", "TopeStamina", 700f, "Máximo de stamina con todo (comida, tōki, entrenamiento).");
			TopeMana = Admin(cfg, "1. Maná", "TopeMana", 700f, "Máximo de maná con todo (comida, reserva, tōki, talento).");
			ManaPorNivelToki = Admin(cfg, "3. Tōki pasivo", "ManaPorNivelToki", 15f, "Maná máximo extra por nivel de tōki (Nv 10 → +150). El tōki también es maná.");
			NadoMantoPorNivel = Admin(cfg, "4. Manto", "NadoPorNivel", 0.04f, "Velocidad al nadar por nivel con el manto (Nv 10 → +40 %), además de la pasiva.");
			DanoObjetosPorNivel = Admin(cfg, "4. Manto", "DanoObjetosPorNivel", 0.05f, "Daño a árboles, rocas y objetos por nivel con el manto (Nv 10 → +50 %).");
			PunosExtra = Admin(cfg, "4. Manto", "MultiplicadorPunos", 1.5f, "Los puños aprovechan más el tōki: su bonus de daño se multiplica por esto.");
			CostoActivar = Admin(cfg, "4. Manto", "CostoActivar", 10f, "Maná azul que cuesta encender el manto (aparte de lo que pasa a la barra naranja).");
			TopeDiosDragon = Admin(cfg, "1. Maná", "TopeDiosDragon", 1000f, "Máximo de vida, stamina y maná con el Dios Dragón.");
			ReservaExponente = Admin(cfg, "1. Maná", "ReservaExponente", 0.7f, "Curva de la reserva: menor = crece más rápido al principio.");
			ManaPorPuntoDeExperiencia = Admin(cfg, "1. Maná", "ManaPorPuntoDeExperiencia", 5f, "Maná gastado para ganar 1 punto de experiencia de Reserva.");
			BonusVaciarse = Admin(cfg, "1. Maná", "BonusVaciarse", 1.25f, "Multiplicador de experiencia si el gasto te deja por debajo del 10 % de maná.");
			NadoRelajado = Admin2(cfg, "8. Meditación", "NadoRelajado", value: true, "Nadar despacio no gasta stamina y la recupera; solo nadar rápido (correr) la gasta. Sin muerte por ahogo.");
			RanurasComida = cfg.Bind<int>("8. Meditación", "RanurasComida", 5, new ConfigDescription("Comidas distintas que puedes tener a la vez (Valheim: 3). Entre 3 y 8.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(3, 8), new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			SaltoAhorroBase = Admin(cfg, "3. Tōki pasivo", "SaltoAhorroBase", 0.5f, "(Ya no se usa: ver SaltoCosto.)");
			SaltoCosto = Admin(cfg, "3. Tōki pasivo", "SaltoCosto", 2f, "Stamina por salto sin tōki y sin entrenar (Valheim: 10). Con el manto activo: 0.");
			SaltoCostoMin = Admin(cfg, "3. Tōki pasivo", "SaltoCostoMinimo", 1f, "Stamina por salto muy entrenado (Saltar + Aguante = 100) o con el tōki despierto.");
			CargaEntrenadaMax = Admin(cfg, "3. Tōki pasivo", "CargaEntrenadaTope", 100f, "Peso extra que se gana entrenando (+1 a +5 por esfuerzo). Con cuerpo (+50) y tōki (+50), el total llega a +200.");
			EntrenoVelocidad = Admin(cfg, "3. Tōki pasivo", "VelocidadEntrenamiento", 1f, "Multiplicador de lo rápido que crece el cuerpo entrenando (stamina entrenada y Aguante).");
			EntrenoMaxDia = Admin(cfg, "3. Tōki pasivo", "StaminaEntrenadaPorDia", 15f, "Máximo de stamina que se gana entrenando por día del juego.");
			DescansoMana = Admin(cfg, "8. Meditación", "DescansoManaFuerza", 6f, "El bonus de descanso vale esto más para el maná (6 → Descansado ×2.5, sentado ×4, junto al fuego ×5.5, en la cama ×8.5).");
			DescansoManaLaplace = Admin(cfg, "8. Meditación", "DescansoManaLaplace", 1.5f, "Con el Factor de Laplace, el bonus de descanso del maná es aún mayor (1.5 → sentado ×5.5, fuego ×7.75, cama ×12.25).");
			DescansoMult = Admin(cfg, "8. Meditación", "Descanso", 1f, "Fuerza del bonus de descanso (1 = normal, 0 = sin bonus). Descansado +25 %, sentado +50 %, junto al fuego +25 %, en la cama +100 % a toda la regeneración.");
			ProbLaplace = Admin(cfg, "1. Maná", "ProbFactorLaplace", 0.015f, "Probabilidad de nacer con el Factor de Laplace (reserva ×2.5, sin tōki).");
			LaplaceTokiMult = Admin(cfg, "1. Maná", "LaplaceToki", 0.5f, "Con el Factor de Laplace el tōki sí despierta y crece, pero más lento: probabilidad de despertar y Dominio × esto (0 = nunca, como en la novela).");
			LaplaceMult = Admin(cfg, "1. Maná", "ReservaLaplace", 1.7f, "Multiplicador de la reserva con el Factor de Laplace (1.7 ≈ 255 de maná propio con Reserva 100). Su Reserva crece +50 % más rápido.");
			ProbLaplaceNivel = Admin(cfg, "1. Maná", "ProbLaplacePorNivel", 0f, "Probabilidad de despertar el Factor de Laplace cada vez que sube la Reserva (solo con el tōki dormido).");
			RegenLaplace = Admin(cfg, "1. Maná", "RegeneracionLaplaceExtra", 1.25f, "Factor de Laplace: su regeneración escala con su reserva (×ReservaLaplace) y además se multiplica por esto (1.25 = +25 %): se llena antes que la de un mago normal.");
			ProbGranReserva = Admin(cfg, "1. Maná", "ProbGranReserva", 0.2f, "Probabilidad de nacer con gran reserva (×1.5).");
			RegenManaMult = Admin(cfg, "1. Maná", "RegeneracionMana", 0.6f, "Multiplicador de la regeneración de maná (0.6 = −40 %: menos magia, más estrategia).");
			CargaPorCuerpo = Admin(cfg, "3. Tōki pasivo", "CargaPorNivelDeCuerpo", 1f, "Peso que puedes cargar por punto de Nivel de Cuerpo (100 → +100). Con el entrenamiento: +200 sin tōki.");
			CargaTopeSinToki = Admin(cfg, "3. Tōki pasivo", "CargaExtraTopeSinToki", 200f, "Máximo peso extra que da MT sin tōki. Mochilas de otros mods suman aparte.");
			CargaTopeConToki = Admin(cfg, "3. Tōki pasivo", "CargaExtraTopeConToki", 600f, "Máximo peso extra que da MT con tōki. Mochilas de otros mods suman aparte.");
			CargaPorToki = Admin(cfg, "3. Tōki pasivo", "CargaPorNivelDeToki", 40f, "Peso que puedes cargar por nivel de tōki (10 → +400; +600 en total).");
			TalentoNacimiento = Admin(cfg, "2. Despertar", "TalentoNacimiento", 0.01f, "Probabilidad (una sola tirada por personaje) de nacer con el tōki despierto.");
			CuerpoMinimoDespertar = Admin(cfg, "2. Despertar", "CuerpoMinimo", 12f, "Nivel de Cuerpo desde el que puede despertar el tōki.");
			CuerpoDespertarSeguro = Admin(cfg, "2. Despertar", "CuerpoTope", 25f, "Nivel de Cuerpo en el que la probabilidad de despertar llega a su tope (99 %). Nunca es seguro.");
			ProbabilidadMinima = Admin(cfg, "2. Despertar", "ProbabilidadMinima", 0.03f, "Probabilidad por tirada con el Cuerpo mínimo.");
			ProbabilidadMaxima = Admin(cfg, "2. Despertar", "ProbabilidadTope", 0.99f, "Probabilidad por tirada con el Nivel de Cuerpo tope (máx. 0.99: nunca es 100 %).");
			VidaCrisis = Admin(cfg, "2. Despertar", "VidaCrisis", 0.2f, "Momento de crisis: sobrevivir con menos de esta fracción de vida da una tirada doble.");
			EnfriamientoCrisis = Admin(cfg, "2. Despertar", "EnfriamientoCrisis", 600f, "Segundos entre tiradas de crisis.");
			StaminaEntrenadaMax = Admin(cfg, "3. Tōki pasivo", "StaminaEntrenadaMax", 60f, "Stamina máxima que se gana entrenando (esfuerzos de verdad), aparte del Aguante. Con Aguante: +200 sin tōki.");
			VidaPorCuerpo = Admin(cfg, "3. Tōki pasivo", "VidaPorNivelDeCuerpo", 0.2f, "Vida máxima extra por punto de Nivel de Cuerpo (100 → +20), con o sin tōki.");
			AguanteStaminaMax = Admin(cfg, "3. Tōki pasivo", "AguanteStaminaMax", 140f, "Stamina máxima extra con Aguante 100 (lenta al principio, ver CurvaAguante).");
			CurvaAguante = Admin(cfg, "3. Tōki pasivo", "CurvaAguante", 1.5f, "Exponente de la estamina por Aguante: 1.5 = nivel 25 → +17, 50 → +50, 100 → +140. 0.5 era la curva vieja (rápida al principio).");
			ConversionEsfuerzo = Admin(cfg, "3. Tōki pasivo", "ConversionEsfuerzo", 375f, "Esfuerzo (estamina gastada y extras) por cada punto de estamina entrenada que se consolida al dormir. Un día normal (~1500) ≈ +4 al principio.");
			MultCombate = Admin(cfg, "3. Tōki pasivo", "MultCombate", 2f, "El esfuerzo cuenta ×N durante un combate real (golpeaste o te golpearon hace menos de 8 s).");
			MultPeligro = Admin(cfg, "3. Tōki pasivo", "MultPeligro", 4f, "El esfuerzo cuenta ×N en combate con menos del 30 % de vida («a vida o muerte»).");
			EsfuerzoCarga = Admin(cfg, "3. Tōki pasivo", "EsfuerzoCarga", 5f, "Esfuerzo por segundo sobrecargado o tirando del carro; cargando más del 60 % del peso, una parte.");
			EsfuerzoClima = Admin(cfg, "3. Tōki pasivo", "EsfuerzoClima", 1.5f, "Esfuerzo por segundo por cada estado de frío, congelación o mojado.");
			PenalidadSinDormir = Admin(cfg, "3. Tōki pasivo", "PenalidadSinDormir", 0.25f, "Parte del esfuerzo guardado que se pierde por cada noche sin dormir en una cama (mínimo se aprovecha el 25 %).");
			TrasnochadoRegen = Admin(cfg, "3. Tōki pasivo", "TrasnochadoRegen", 0.1f, "Con 3 o más noches sin dormir, la estamina se recupera este porcentaje más lento.");
			DiarioPierdeHojas = cfg.Bind<bool>("Interfaz", "DiarioPierdeHojas", true, "Al morir se pierden las 3 entradas más viejas de la Crónica (nunca los capítulos ni los jefes).");
			GremioKillsPorRango = cfg.Bind<string>("4. Gremio", "EnemigosPorRango", "20,60,150,300,500", new ConfigDescription("Enemigos vencidos (1★ = 2, 2★ = 3, jefe = 10) para los rangos E, D, C, B y A del Gremio. A pide además Moder; S pide Yagluth.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			RitmoMaximo = cfg.Bind<int>("0. Estilo", "RitmoMaximo", 5, new ConfigDescription("Ritmo máximo que puede elegir cada jugador en el diario («Mi camino»): 1 = todos en Equilibrado, 5 = hasta ×5. El crecimiento va ×ritmo, la comodidad a la mitad y el poder a una quinta parte; los topes nunca cambian.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			NivelesTokiPorNoche = cfg.Bind<int>("3. Tōki pasivo", "NivelesTokiPorNoche", 1, new ConfigDescription("Niveles de tōki que pueden subir cada vez que duermes (el tōki despierta en nivel 1).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			StaminaPorNivelToki = Admin(cfg, "3. Tōki pasivo", "StaminaPorNivelToki", 20f, "Stamina máxima extra por nivel de tōki (Nv 10 → +200; con el entrenamiento y la comida, hasta +500).");
			CaidaPorNivel = Admin(cfg, "3. Tōki pasivo", "CaidaPorNivel", 0.05f, "Reducción de daño de caída por nivel de tōki.");
			StaminaRegenBase = Admin(cfg, "3. Tōki pasivo", "StaminaRegenBase", 0.5f, "Regeneración de stamina extra solo por tener el tōki despierto (0.50 = +50 %).");
			StaminaRegenPorNivel = Admin(cfg, "3. Tōki pasivo", "StaminaRegenPorNivel", 0.05f, "Regeneración de stamina extra por nivel (Nv 1 → +55 %, Nv 10 → +100 %).");
			TextoXp = cfg.Bind<bool>("Interfaz", "TextoExperiencia", true, "Flechitas «↑» sobre el personaje al ganar experiencia o entrenamiento.");
			RugidoManto = cfg.Bind<bool>("Interfaz", "RugidoAlEncenderManto", true, "Al encender el manto de tōki: pose de reto, grito y estallido de aire.");
			NumerosXp = cfg.Bind<bool>("Interfaz", "NumerosExperiencia", false, "Además de las flechitas, el número «+N XP». Apagado por defecto: el progreso se lee en el Diario (F4).");
			VidaMaxPorNivel = Admin(cfg, "3. Tōki pasivo", "VidaMaxPorNivel", 15f, "Vida máxima extra por nivel de tōki (Nv 10 → +150).");
			VidaRegenBase = Admin(cfg, "3. Tōki pasivo", "VidaRegenBase", 0.25f, "Regeneración de vida extra solo por tener el tōki despierto (0.25 = +25 %).");
			VidaRegenPorNivel = Admin(cfg, "3. Tōki pasivo", "VidaRegenPorNivel", 0.03f, "Regeneración de vida extra por nivel (Nv 1 → +28 %, Nv 10 → +55 %).");
			VidaRegenPlanaBase = Admin(cfg, "3. Tōki pasivo", "VidaRegenPlanaBase", 0.001f, "Vida que regeneras por segundo, en fracción de la vida máxima, solo por tener el tōki despierto (0.001 = 0,1 %/s), aunque no hayas comido.");
			VidaRegenPlanaPorNivel = Admin(cfg, "3. Tōki pasivo", "VidaRegenPlanaPorNivel", 0.0002f, "Vida por segundo extra por nivel de tōki (Nv 10 → 0,3 %/s de la vida máxima).");
			VidaRegenEnCombate = Admin(cfg, "3. Tōki pasivo", "VidaRegenEnCombate", 0.25f, "En combate (te golpearon hace poco) la regeneración propia del tōki se multiplica por esto (0.25 = un cuarto).");
			VidaRegenCombateSegundos = Admin(cfg, "3. Tōki pasivo", "VidaRegenCombateSegundos", 8f, "Segundos sin recibir daño para volver a regenerar del todo.");
			VidaRegenMeditandoTope = Admin(cfg, "3. Tōki pasivo", "VidaRegenMeditandoTope", 0.003f, "Meditando se regenera el doble, hasta este tope por segundo (0.003 = 0,3 %/s de la vida máxima).");
		}

		private static ConfigEntry<bool> Admin2(ConfigFile cfg, string section, string key, bool value, string description)
		{
			//IL_000f: 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_001c: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			return cfg.Bind<bool>(section, key, value, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
		}

		private static ConfigEntry<float> Admin(ConfigFile cfg, string section, string key, float value, string description)
		{
			//IL_000f: 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_001c: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			return cfg.Bind<float>(section, key, value, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
		}
	}
	[HarmonyPatch(typeof(Humanoid), "StartAttack")]
	public static class DiagnosticoAtaquePatch
	{
		private static float _ultimo;

		private static readonly FieldRef<Character, Animator> Anim = AccessTools.FieldRefAccess<Character, Animator>("m_animator");

		private static readonly MethodInfo MinorAction = AccessTools.Method(typeof(Character), "InMinorAction", (Type[])null, (Type[])null);

		private static readonly MethodInfo KnockedBack = AccessTools.Method(typeof(Character), "IsKnockedBack", (Type[])null, (Type[])null);

		[HarmonyPriority(0)]
		private static void Postfix(Humanoid __instance, bool secondaryAttack, bool __result)
		{
			Player val = (Player)(object)((__instance is Player) ? __instance : null);
			if (!__result && !((Object)(object)val == (Object)null) && !((Object)(object)val != (Object)(object)Player.m_localPlayer) && !(Time.time - _ultimo < 2f) && (ZInput.GetButton("Attack") || ZInput.GetButton("SecondaryAttack")))
			{
				_ultimo = Time.time;
				ItemData currentWeapon = ((Humanoid)val).GetCurrentWeapon();
				Animator val2 = Anim.Invoke((Character)(object)val);
				string arg = string.Join(",", from s in ((Character)val).GetSEMan().GetStatusEffects()
					select ((Object)s).name.Replace("(Clone)", ""));
				MTCorePlugin.Log.LogWarning((object)($"[Ataque bloqueado] secundario={secondaryAttack} enAtaque={((Character)val).InAttack()} esquiva={((Character)val).InDodge()} puedeMover={((Character)val).CanMove()} " + $"empujado={KnockedBack?.Invoke(val, null)} tambaleo={((Character)val).IsStaggering()} accionMenor={MinorAction?.Invoke(val, null)} " + string.Format("arma={0} durabilidad={1:0.#}/{2:0.#} ", currentWeapon?.m_shared.m_name ?? "ninguna", currentWeapon?.m_durability ?? 0f, (currentWeapon == null) ? 0f : currentWeapon.GetMaxDurability()) + $"bloqueoClic={BloqueoClic.Bloquea} rueda={RuedaHabilidades.Abierta} colapso={Agotamiento.IsCollapsed(val)} " + $"animVel={(((Object)(object)val2 == (Object)null) ? (-1f) : val2.speed):0.###} efectos=[{arg}]"));
			}
		}
	}
	public class DesatascarAtaque : MonoBehaviour
	{
		private float _congelado;

		private float _fantasma;

		private static readonly FieldRef<Character, Animator> Anim = AccessTools.FieldRefAccess<Character, Animator>("m_animator");

		private void Update()
		{
			Player localPlayer = Player.m_localPlayer;
			Animator val = (((Object)(object)localPlayer != (Object)null) ? Anim.Invoke((Character)(object)localPlayer) : null);
			if ((Object)(object)val != (Object)null && !((Character)localPlayer).IsDead() && ((Character)localPlayer).InAttack())
			{
				if (!AtaqueSeguro.AtaqueReal(localPlayer, Campos.AtaqueActual.Invoke((Humanoid)(object)localPlayer)) && !AtaqueSeguro.Ocupado(localPlayer))
				{
					_fantasma += Time.deltaTime;
				}
				else
				{
					_fantasma = 0f;
				}
				if (_fantasma > 1f)
				{
					_fantasma = 0f;
					AtaqueSeguro.Liberar(localPlayer, "animación de ataque sin ataque real más de 1 s");
				}
			}
			else
			{
				_fantasma = 0f;
			}
			if ((Object)(object)val == (Object)null || !((Character)localPlayer).InAttack() || val.speed > 0.05f)
			{
				_congelado = 0f;
				return;
			}
			_congelado += Time.deltaTime;
			if (!(_congelado < 2f))
			{
				_congelado = 0f;
				val.speed = 1f;
				MTCorePlugin.Log.LogWarning((object)"[Ataque bloqueado] animación de ataque congelada más de 2 s: velocidad restaurada.");
			}
		}
	}
	public static class Estado
	{
		public static bool Levitando;
	}
	[BepInPlugin("mushokutensei.core", "MT Core", "2.2.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[SynchronizationMode(/*Could not decode attribute arguments.*/)]
	public class MTCorePlugin : BaseUnityPlugin
	{
		public const string Guid = "mushokutensei.core";

		public const string Version = "2.2.3";

		public static ManualLogSource Log;

		private static void Paso(string que, Action accion)
		{
			try
			{
				accion();
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"MT Core: falló «{que}» al cargar (el resto sigue): {arg}");
			}
		}

		private void Awake()
		{
			Tr.Load(typeof(MTCorePlugin).Assembly, Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location));
			Log = ((BaseUnityPlugin)this).Logger;
			CoreConfig.Bind(((BaseUnityPlugin)this).Config);
			MTKeys.Bind(((BaseUnityPlugin)this).Config);
			string iconDir = (Arte.Dir = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Icons"));
			MTSkills.Register(iconDir);
			SE_ToukiPasivo.Register(MTSkills.LoadIcon(iconDir, "insignia_toki_despierto") ?? MTSkills.LoadIcon(iconDir, "touki_pasivo"));
			SE_Talento.Register(iconDir);
			SE_MenteEnCalma.Register(MTSkills.LoadIcon(iconDir, "mente_en_calma"));
			SE_Agotamiento.Register(MTSkills.LoadIcon(iconDir, "agotamiento"));
			Paso("teclas del manto", MantoController.RegisterInput);
			Paso("tecla de meditar", Meditacion.RegisterInput);
			((Component)this).gameObject.AddComponent<MantoController>();
			((Component)this).gameObject.AddComponent<RugidoToki>();
			((Component)this).gameObject.AddComponent<DesatascarAtaque>();
			((Component)this).gameObject.AddComponent<Meditacion>();
			((Component)this).gameObject.AddComponent<EspecialidadesController>();
			((Component)this).gameObject.AddComponent<NadoController>();
			((Component)this).gameObject.AddComponent<ProgresoFisico>();
			((Component)this).gameObject.AddComponent<DescansoNocturno>();
			SE_Trasnochado.Register(MTSkills.LoadIcon(iconDir, "trasnochado") ?? MTSkills.LoadIcon(iconDir, "agotamiento"));
			MTBundle.Load(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location));
			((Component)this).gameObject.AddComponent<RendimientoController>();
			((Component)this).gameObject.AddComponent<ToukiAura>();
			((Component)this).gameObject.AddComponent<ToukiManos>();
			((Component)this).gameObject.AddComponent<ToukiPunos>();
			((Component)this).gameObject.AddComponent<ToukiCuerpo>();
			Paso("diario", delegate
			{
				PaginasCore.Registrar();
				PaginaCamino.Registrar();
				GuiaInicio.RegistrarPagina();
				((Component)this).gameObject.AddComponent<PreguntaCamino>();
				((Component)this).gameObject.AddComponent<DiarioVentana>();
			});
			Paso("rueda de habilidades", delegate
			{
				((Component)this).gameObject.AddComponent<RuedaHabilidades>();
			});
			((Component)this).gameObject.AddComponent<BloqueoClic>();
			((Component)this).gameObject.AddComponent<AyudaTeclas>();
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new PerfCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new DesatascarCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AliasCommand("mt_status", "Show mana, Body Level and Toki", (ConsoleCommand)(object)new EstadoCommand()));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AliasCommand("mt_specialties", "Show your specialties, ranks and the Guild", (ConsoleCommand)(object)new EspecialidadesCommand()));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AliasCommand("mt_awaken", "[cheat] Awaken your Toki now", (ConsoleCommand)(object)new DespertarCommand()));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AliasCommand("mt_sleep", "[cheat] Put your Toki back to sleep (to test the awakening again)", (ConsoleCommand)(object)new DormirCommand()));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AliasCommand("mt_level", "[cheat] mt_level <reserve|control|mastery|meditation> <0-100>", (ConsoleCommand)(object)new NivelCommand()));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AliasCommand("mt_boss", "[cheat] mt_boss <key> — register a defeated boss (e.g. defeated_eikthyr)", (ConsoleCommand)(object)new JefeCommand()));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AliasCommand("mt_milestone", "[cheat] mt_milestone <reflex|natural|mastery> — complete a milestone achievement (still needs the Toki level)", (ConsoleCommand)(object)new HitoCommand()));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AliasCommand("mt_talent", "[cheat] mt_talent <normal|greatreserve|laplace> — change your birth talent", (ConsoleCommand)(object)new TalentoCommand()));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ManaCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new SleepTrainCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new JournalSizeCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new JournalFillCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AliasCommand("mt_dragon_god", "[cheat] mt_dragon_god <on|off> — force the Dragon God caps (1000 health, stamina and mana) for testing", (ConsoleCommand)(object)new DiosDragonCommand()));
			Parches.Aplicar("mushokutensei.core", ((object)this).GetType().Assembly, ((BaseUnityPlugin)this).Logger);
			ModCompat.Report();
			Log.LogInfo((object)"MT Core 2.2.3 cargado");
		}
	}
	public static class MTGui
	{
		public static readonly Color Oro = new Color(1f, 0.72f, 0.36f);

		public static readonly Color Texto = new Color(0.93f, 0.9f, 0.84f);

		public static readonly Color Gris = new Color(0.65f, 0.63f, 0.6f);

		public static readonly Color Naranja = new Color(1f, 0.55f, 0.12f);

		public static readonly Color Azul = new Color(0.45f, 0.7f, 1f);

		public static readonly Color Rojo = new Color(1f, 0.35f, 0.3f);

		private static Font _font;

		private static float _fontRetry;

		private static Texture2D _white;

		private static Texture2D _panel;

		private static Texture2D _border;

		private static GUIStyle _style;

		private static readonly string[] SinAveria = new string[6] { "Russian", "Ukrainian", "Chinese", "Chinese_Trad", "Japanese", "Korean" };

		public static float Scale => Mathf.Clamp((float)Screen.height / 1080f, 0.75f, 2f);

		private static Font ValheimFont()
		{
			if (Array.IndexOf(SinAveria, Tr.Current) >= 0)
			{
				return null;
			}
			if ((Object)(object)_font != (Object)null)
			{
				return _font;
			}
			if (Time.unscaledTime < _fontRetry)
			{
				return null;
			}
			_fontRetry = Time.unscaledTime + 5f;
			Font[] source = Resources.FindObjectsOfTypeAll<Font>();
			_font = ((IEnumerable<Font>)source).FirstOrDefault((Func<Font, bool>)((Font f) => ((Object)f).name.Contains("AveriaSerifLibre-Bold"))) ?? ((IEnumerable<Font>)source).FirstOrDefault((Func<Font, bool>)((Font f) => ((Object)f).name.StartsWith("Averia"))) ?? ((IEnumerable<Font>)source).FirstOrDefault((Func<Font, bool>)((Font f) => ((Object)f).name.Contains("Norse")));
			return _font;
		}

		private static Texture2D Solid(Color c)
		{
			//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_000f: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 1)
			{
				hideFlags = (HideFlags)61
			};
			val.SetPixel(0, 0, c);
			val.Apply();
			return val;
		}

		private static void Init()
		{
			//IL_000e: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_white != (Object)null))
			{
				_white = Solid(Color.white);
				_panel = Solid(new Color(0.08f, 0.07f, 0.06f, 0.78f));
				_border = Solid(new Color(0.55f, 0.4f, 0.2f, 0.9f));
			}
		}

		public static GUIStyle Style(int size, Color color, TextAnchor anchor = (TextAnchor)3, bool bold = false)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_006a: 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)
			Init();
			if (_style == null)
			{
				_style = new GUIStyle(GUI.skin.label)
				{
					richText = true,
					wordWrap = false
				};
			}
			_style.font = ValheimFont();
			_style.fontSize = Mathf.RoundToInt((float)size * Scale);
			_style.fontStyle = (FontStyle)(bold ? 1 : 0);
			_style.alignment = anchor;
			_style.normal.textColor = color;
			return _style;
		}

		public static void Label(Rect r, string text, int size, Color color, TextAnchor anchor = (TextAnchor)3, bool bold = false)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = Style(size, new Color(0f, 0f, 0f, 0.85f), anchor, bold);
			GUI.Label(new Rect(((Rect)(ref r)).x + 1.5f, ((Rect)(ref r)).y + 1.5f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), StripColors(text), val);
			val = Style(size, color, anchor, bold);
			GUI.Label(r, text, val);
		}

		private static string StripColors(string s)
		{
			return Regex.Replace(s, "<color=[^>]*>|</color>", "");
		}

		public static void Panel(Rect r)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			Init();
			GUI.color = Color.white;
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x - 2f, ((Rect)(ref r)).y - 2f, ((Rect)(ref r)).width + 4f, ((Rect)(ref r)).height + 4f), (Texture)(object)_border);
			GUI.DrawTexture(r, (Texture)(object)_panel);
		}

		public static void Bar(Rect r, float fill, Color color)
		{
			//IL_0021: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			Init();
			fill = Mathf.Clamp01(fill);
			GUI.color = new Color(0.55f, 0.4f, 0.2f, 0.9f);
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x - 2f, ((Rect)(ref r)).y - 2f, ((Rect)(ref r)).width + 4f, ((Rect)(ref r)).height + 4f), (Texture)(object)_white);
			GUI.color = new Color(0.05f, 0.05f, 0.05f, 0.85f);
			GUI.DrawTexture(r, (Texture)(object)_white);
			GUI.color = color;
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width * fill, ((Rect)(ref r)).height), (Texture)(object)_white);
			GUI.color = new Color(1f, 1f, 1f, 0.25f);
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width * fill, ((Rect)(ref r)).height * 0.35f), (Texture)(object)_white);
			GUI.color = Color.white;
		}

		public static void Icon(Rect r, Sprite sprite, float alpha = 1f)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)sprite == (Object)null))
			{
				Color color = GUI.color;
				GUI.color = new Color(1f, 1f, 1f, alpha * color.a);
				Texture2D texture = sprite.texture;
				Rect textureRect = sprite.textureRect;
				GUI.DrawTextureWithTexCoords(r, (Texture)(object)texture, new Rect(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height));
				GUI.color = color;
			}
		}

		public static string Hex(Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return ColorUtility.ToHtmlStringRGB(c);
		}
	}
	public static class MTKeys
	{
		public static ConfigEntry<bool> RuedaConAlt;

		public static ConfigEntry<KeyCode> Manto;

		public static ConfigEntry<KeyCode> Meditar;

		public static ConfigEntry<KeyCode> Paso;

		public static ConfigEntry<KeyCode> Lanzar;

		public static ConfigEntry<KeyCode> SiguienteHechizo;

		public static ConfigEntry<KeyCode> OcultarHechizo;

		public static ConfigEntry<KeyCode> MenuHechizos;

		public static ConfigEntry<KeyCode> Levitar;

		public static ConfigEntry<KeyCode> Aterrizar;

		public static ConfigEntry<KeyCode> Diario;

		public static ConfigEntry<KeyCode> Tecnicas;

		public static ConfigEntry<KeyCode> Rueda;

		public static void Bind(ConfigFile cfg)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Invalid comparison between Unknown and I4
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Invalid comparison between Unknown and I4
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Invalid comparison between Unknown and I4
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Invalid comparison between Unknown and I4
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Invalid comparison between Unknown and I4
			Manto = cfg.Bind<KeyCode>("0. Teclas", "Manto", (KeyCode)282, "Cargar el manto de tōki (mantener para apagarlo).");
			Meditar = cfg.Bind<KeyCode>("0. Teclas", "Meditar", (KeyCode)104, "Meditar / dejar de meditar. Sentarse con X solo descansa (recupera maná sin gastarlo).");
			if ((int)Meditar.Value == 0)
			{
				Meditar.Value = (KeyCode)104;
			}
			Paso = cfg.Bind<KeyCode>("0. Teclas", "PasoDeToki", (KeyCode)122, "Paso de Tōki (mod MT Paso).");
			if ((int)Paso.Value == 284)
			{
				Paso.Value = (KeyCode)122;
			}
			Lanzar = cfg.Bind<KeyCode>("0. Teclas", "LanzarHechizoTecla", (KeyCode)0, "Tecla opcional para lanzar el hechizo seleccionado (MT Magia). Por defecto ninguna: se lanza con el clic izquierdo y la varita o el bastón. ");
			SiguienteHechizo = cfg.Bind<KeyCode>("0. Teclas", "SiguienteHechizo", (KeyCode)280, "Siguiente hechizo; con Alt, el anterior (mod MT Magia).");
			MenuHechizos = cfg.Bind<KeyCode>("0. Teclas", "MenuHechizos", (KeyCode)284, "Abrir o cerrar el menú del grimorio: todos tus hechizos y los 9 favoritos (mod MT Magia).");
			if ((int)MenuHechizos.Value == 290)
			{
				MenuHechizos.Value = (KeyCode)284;
			}
			Levitar = cfg.Bind<KeyCode>("0. Teclas", "Levitar", (KeyCode)106, "Empezar a levitar (necesitas conocer Levitar, su rango y un foco en la mano) (mod MT Magia).");
			Aterrizar = cfg.Bind<KeyCode>("0. Teclas", "Aterrizar", (KeyCode)107, "Dejar de levitar y bajar sin daño de caída (mod MT Magia).");
			Diario = cfg.Bind<KeyCode>("0. Teclas", "Diario", (KeyCode)285, "Abrir o cerrar el Diario del aventurero: crónica, cuerpo y tōki, magia, espada y recetas.");
			if ((int)Diario.Value == 289)
			{
				Diario.Value = (KeyCode)285;
			}
			Tecnicas = cfg.Bind<KeyCode>("0. Teclas", "TecnicasEspada", (KeyCode)289, "Abrir el diario en la página de técnicas de espada; ahí se asignan a Alt + 1–9 (mod MT Espada).");
			if ((int)Tecnicas.Value == 291)
			{
				Tecnicas.Value = (KeyCode)289;
			}
			Rueda = cfg.Bind<KeyCode>("0. Teclas", "RuedaHabilidades", (KeyCode)113, "Mantener esta tecla: rueda de habilidades (técnicas con un arma, hechizos con bastón o varita). Soltar para usar. Mientras se pulsa, no activa «correr automático».");
			RuedaConAlt = cfg.Bind<bool>("0. Teclas", "RuedaConAlt", false, "Pedir también Alt para abrir la rueda (Alt + tecla), por si quieres dejar la tecla sola para otra cosa.");
			if ((int)Rueda.Value == 103)
			{
				Rueda.Value = (KeyCode)113;
			}
			OcultarHechizo = cfg.Bind<KeyCode>("0. Teclas", "OcultarHechizo", (KeyCode)281, "Ocultar/activar el hechizo seleccionado en el grimorio; con Alt, mostrar u ocultar la lista de ocultos (mod MT Magia).");
		}

		public static bool Down(ConfigEntry<KeyCode> k)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return ZInput.GetKeyDown(k.Value, false);
		}

		public static bool Held(ConfigEntry<KeyCode> k)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return ZInput.GetKey(k.Value, false);
		}

		public static bool Up(ConfigEntry<KeyCode> k)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return ZInput.GetKeyUp(k.Value, false);
		}
	}
	public static class MTSkills
	{
		public static SkillType Reserva;

		public static SkillType Control;

		public static SkillType Dominio;

		public static SkillType Meditacion;

		public static SkillType Aguante;

		public static void Register(string iconDir)
		{
			//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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Reserva = Add("reserva", Tr.Token("core_skill_reserva"), Tr.Token("core_skill_reserva_d"), iconDir);
			Control = Add("control", Tr.Token("core_skill_control"), Tr.Token("core_skill_control_d"), iconDir);
			Dominio = Add("dominio", Tr.Token("core_skill_dominio"), Tr.Token("core_skill_dominio_d"), iconDir);
			Aguante = Add("aguante", Tr.Token("core_skill_aguante"), Tr.Token("core_skill_aguante_d"), iconDir);
			Meditacion = Add("meditacion", Tr.Token("core_skill_meditacion"), Tr.Token("core_skill_meditacion_d"), iconDir);
		}

		private static SkillType Add(string id, string name, string description, string iconDir)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			return SkillManager.Instance.AddSkill(new SkillConfig
			{
				Identifier = "mushokutensei.core." + id,
				Name = name,
				Description = description,
				Icon = LoadIcon(iconDir, id),
				IncreaseStep = 1f
			});
		}

		public static Sprite LoadIcon(string iconDir, string name)
		{
			string text = Path.Combine(iconDir, name + ".png");
			if (!File.Exists(text))
			{
				return null;
			}
			return AssetUtils.LoadSpriteFromFile(text);
		}
	}
	public static class Mundo
	{
		public static string Id
		{
			get
			{
				long num = 0L;
				try
				{
					if ((Object)(object)ZNet.instance != (Object)null)
					{
						num = ZNet.instance.GetWorldUID();
					}
				}
				catch
				{
					num = 0L;
				}
				if (num == 0L)
				{
					return null;
				}
				return num.ToString(CultureInfo.InvariantCulture);
			}
		}

		public static string Dia(int dia)
		{
			return (Id ?? "0") + "/" + dia.ToString(CultureInfo.InvariantCulture);
		}

		public static bool Cambio(Player p, string key)
		{
			string id = Id;
			if ((Object)(object)p == (Object)null || id == null)
			{
				return false;
			}
			if (p.m_customData.TryGetValue(key, out var value) && value == id)
			{
				return false;
			}
			p.m_customData[key] = id;
			return true;
		}
	}
	[HarmonyPatch(typeof(DamageText), "AddInworldText")]
	public static class NumerosDanoPatch
	{
		private static readonly Color Amarillo = new Color(1f, 0.92f, 0.35f);

		private static readonly Color Naranja = new Color(1f, 0.6f, 0.15f);

		private static readonly Color Rojo = new Color(1f, 0.2f, 0.15f);

		private static void Postfix(DamageText __instance, TextType type, string text)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			if (CoreConfig.NumerosDanoColor.Value && ((int)type == 0 || (int)type == 2 || (int)type == 1 || (int)type == 7) && (float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || float.TryParse(text, NumberStyles.Float, CultureInfo.CurrentCulture, out result)))
			{
				TMP_Text val = Campos.UltimoTextoDano(__instance);
				if (!((Object)(object)val == (Object)null))
				{
					float num = Mathf.InverseLerp(Mathf.Log(5f), Mathf.Log(CoreConfig.NumerosDanoRojo.Value), Mathf.Log(Mathf.Max(result, 1f)));
					Color color = ((num < 0.5f) ? Color.Lerp(Amarillo, Naranja, num * 2f) : Color.Lerp(Naranja, Rojo, (num - 0.5f) * 2f));
					color.a = ((Graphic)val).color.a;
					((Graphic)val).color = color;
				}
			}
		}
	}
	public static class Parches
	{
		public static int Aplicar(string guid, Assembly asm, ManualLogSource log)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			Harmony val = new Harmony(guid);
			int num = 0;
			Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(asm);
			foreach (Type type in typesFromAssembly)
			{
				try
				{
					val.CreateClassProcessor(type).Patch();
				}
				catch (Exception ex)
				{
					num++;
					log.LogError((object)("Parche " + type.FullName + " no aplicado (el resto sí): " + (ex.InnerException ?? ex).Message));
				}
			}
			return num;
		}
	}
	public static class Rangos
	{
		public const int Count = 7;

		public static string[] Names
		{
			get
			{
				string[] array = new string[7];
				for (int i = 0; i < 7; i++)
				{
					array[i] = Name(i);
				}
				return array;
			}
		}

		public static string Name(int rank)
		{
			return Tr.Get("core_rank_" + rank);
		}
	}
	public static class RedVfx
	{
		private sealed class Tipo
		{
			public Action<ZPackage, object> Escribir;

			public Func<ZPackage, object> Leer;
		}

		internal sealed class Metodo
		{
			public MethodInfo Info;

			public ParameterInfo[] Params;

			public Func<object[], bool> EnviarSi;
		}

		private const string Rpc = "MT_RedVfx";

		private const float Radio = 100f;

		private const int MaxPorSegundo = 40;

		private static readonly Dictionary<Type, Tipo> _tipos;

		private static readonly Dictionary<MethodBase, int> _ids;

		private static readonly Dictionary<int, Metodo> _metodos;

		private static int _profundidad;

		private static int _enviados;

		internal static int Intentos;

		public static bool SoloComprobar;

		private static float _segundo;

		public static Action<ZPackage> EscribirContexto;

		public static Action<ZPackage> LeerContexto;

		public static Action RestaurarContexto;

		private static readonly object NoEncontrado;

		private static Harmony _harmony;

		public static int Registrados => _metodos.Count;

		public static bool Replicando { get; private set; }

		static RedVfx()
		{
			_tipos = new Dictionary<Type, Tipo>();
			_ids = new Dictionary<MethodBase, int>();
			_metodos = new Dictionary<int, Metodo>();
			NoEncontrado = new object();
			Registrar(delegate(ZPackage z, float v)
			{
				z.Write(v);
			}, (ZPackage z) => z.ReadSingle());
			Registrar(delegate(ZPackage z, int v)
			{
				z.Write(v);
			}, (ZPackage z) => z.ReadInt());
			Registrar(delegate(ZPackage z, bool v)
			{
				z.Write(v);
			}, (ZPackage z) => z.ReadBool());
			Registrar(delegate(ZPackage z, string v)
			{
				z.Write(v ?? "");
			}, (ZPackage z) => z.ReadString());
			Registrar(delegate(ZPackage z, Vector3 v)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				z.Write(v);
			}, (ZPackage z) => z.ReadVector3());
			Registrar(delegate(ZPackage z, Quaternion v)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				z.Write(v);
			}, (ZPackage z) => z.ReadQuaternion());
			Registrar<Color>(delegate(ZPackage z, Color v)
			{
				//IL_0001: 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_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				z.Write(v.r);
				z.Write(v.g);
				z.Write(v.b);
				z.Write(v.a);
			}, (ZPackage z) => new Color(z.ReadSingle(), z.ReadSingle(), z.ReadSingle(), z.ReadSingle()));
			_tipos[typeof(Character)] = new Tipo
			{
				Escribir = delegate(ZPackage z, object o)
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					z.Write(Zdo((Character)((o is Character) ? o : null)));
				},
				Leer = (ZPackage z) => Buscar(z.ReadZDOID(), (Character c) => c)
			};
			_tipos[typeof(Player)] = new Tipo
			{
				Escribir = delegate(ZPackage z, object o)
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					z.Write(Zdo((Character)((o is Player) ? o : null)));
				},
				Leer = (ZPackage z) => Buscar(z.ReadZDOID(), (Character c) => (c is Player) ? c : null)
			};
			_tipos[typeof(Transform)] = new Tipo
			{
				Escribir = delegate(ZPackage z, object o)
				{
					//IL_0013: Unknown result type (might be due to invalid IL or missing references)
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					z.Write(Zdo(((Object)((o is Transform) ? o : null) != (Object)null) ? ((Component)(Transform)o).GetComponentInParent<Character>() : null));
				},
				Leer = (ZPackage z) => Buscar(z.ReadZDOID(), (Character c) => ((Component)c).transform)
			};
		}

		private static ZDOID Zdo(Character c)
		{
			//IL_0010: 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)
			if (!((Object)(object)c != (Object)null))
			{
				return ZDOID.None;
			}
			return c.GetZDOID();
		}

		private static object Buscar(ZDOID id, Func<Character, object> convertir)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (id == ZDOID.None)
			{
				return null;
			}
			GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.FindInstance(id) : null);
			Character val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Character>() : null);
			return (((Object)(object)val2 != (Object)null) ? convertir(val2) : null) ?? NoEncontrado;
		}

		public static void Registrar<T>(Action<ZPackage, T> escribir, Func<ZPackage, T> leer)
		{
			_tipos[typeof(T)] = new Tipo
			{
				Escribir = delegate(ZPackage z, object o)
				{
					escribir(z, (T)o);
				},
				Leer = (ZPackage z) => leer(z)
			};
		}

		public static void RegistrarPlano(Type t)
		{
			FieldInfo[] campos = Array.FindAll(t.GetFields(BindingFlags.Instance | BindingFlags.Public), (FieldInfo f) => !f.IsInitOnly);
			Array.Sort(campos, (FieldInfo a, FieldInfo b) => string.CompareOrdinal(a.Name, b.Name));
			_tipos[t] = new Tipo
			{
				Escribir = delegate(ZPackage z, object o)
				{
					z.Write(o != null);
					if (o != null)
					{
						FieldInfo[] array = campos;
						foreach (FieldInfo fieldInfo in array)
						{
							EscribirValor(z, fieldInfo.FieldType, fieldInfo.GetValue(o));
						}
					}
				},
				Leer = delegate(ZPackage z)
				{
					if (!z.ReadBool())
					{
						return (object)null;
					}
					object obj = Activator.CreateInstance(t);
					FieldInfo[] array = campos;
					foreach (FieldInfo fieldInfo in array)
					{
						fieldInfo.SetValue(obj, LeerValor(z, fieldInfo.FieldType));
					}
					return obj;
				}
			};
		}

		private static bool Soportado(Type t)
		{
			Type type = Nullable.GetUnderlyingType(t) ?? t;
			if (!type.IsEnum)
			{
				return _tipos.ContainsKey(type);
			}
			return true;
		}

		private static void EscribirValor(ZPackage z, Type t, object v)
		{
			Type underlyingType = Nullable.GetUnderlyingType(t);
			if (underlyingType != null)
			{
				z.Write(v != null);
				if (v == null)
				{
					return;
				}
				t = underlyingType;
			}
			Tipo value;
			if (t.IsEnum)
			{
				z.Write(Convert.ToInt32(v));
			}
			else if (_tipos.TryGetValue(t, out value))
			{
				value.Escribir(z, v);
			}
		}

		private static object LeerValor(ZPackage z, Type t)
		{
			Type underlyingType = Nullable.GetUnderlyingType(t);
			if (underlyingType != null)
			{
				if (!z.ReadBool())
				{
					return null;
				}
				t = underlyingType;
			}
			if (t.IsEnum)
			{
				return Enum.ToObject(t, z.ReadInt());
			}
			if (!_tipos.TryGetValue(t, out var value))
			{
				return null;
			}
			return value.Leer(z);
		}

		public static void Visual(MethodInfo m, Func<object[], bool> enviarSi = null, params Type[] ignorar)
		{
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Expected O, but got Unknown
			//IL_01ca: Expected O, but got Unknown
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			if (m == null)
			{
				MTCorePlugin.Log.LogWarning((object)"RedVfx: método nulo");
				return;
			}
			ParameterInfo[] parameters = m.GetParameters();
			ParameterInfo[] array = parameters;
			foreach (ParameterInfo parameterInfo in array)
			{
				if (!Soportado(parameterInfo.ParameterType) && Array.IndexOf(ignorar, parameterInfo.ParameterType) < 0)
				{
					MTCorePlugin.Log.LogWarning((object)("RedVfx: " + m.DeclaringType?.Name + "." + m.Name + " tiene un parámetro no enviable (" + parameterInfo.ParameterType.Name + "); no se replica."));
					return;
				}
			}
			int stableHashCode = StringExtensionMethods.GetStableHashCode(m.DeclaringType?.FullName + "." + m.Name + "(" + string.Join(",", Array.ConvertAll(parameters, (ParameterInfo p) => p.ParameterType.FullName)) + ")");
			if (_metodos.ContainsKey(stableHashCode))
			{
				return;
			}
			_ids[m] = stableHashCode;
			_metodos[stableHashCode] = new Metodo
			{
				Info = m,
				Params = parameters,
				EnviarSi = enviarSi
			};
			if (!SoloComprobar)
			{
				if (_harmony == null)
				{
					_harmony = new Harmony("mushokutensei.redvfx");
				}
				_harmony.Patch((MethodBase)m, new HarmonyMethod(typeof(RedVfx), "Prefijo", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(RedVfx), "Final", (Type[])null), (HarmonyMethod)null);
			}
		}

		public static void Visual(Type tipo, string nombre, Func<object[], bool> enviarSi = null, params Type[] ignorar)
		{
			try
			{
				Visual(AccessTools.Method(tipo, nombre, (Type[])null, (Type[])null), enviarSi, ignorar);
			}
			catch (Exception ex)
			{
				MTCorePlugin.Log.LogWarning((object)("RedVfx: " + tipo.Name + "." + nombre + " no registrado: " + ex.Message));
			}
		}

		private static void Prefijo(MethodBase __originalMethod, object[] __args)
		{
			try
			{
				if (_profundidad == 0 && !Replicando)
				{
					Intentos++;
					Enviar(__originalMethod, __args);
				}
			}
			catch (Exception ex)
			{
				MTCorePlugin.Log.LogWarning((object)("RedVfx (enviar): " + ex.Message));
			}
			_profundidad++;
		}

		private static void Final()
		{
			if (_profundidad > 0)
			{
				_profundidad--;
			}
		}

		private static void Enviar(MethodBase m, object[] args)
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			if (ZRoutedRpc.instance != null && !((Object)(object)ZNet.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && ZNet.instance.GetPeers().Count != 0 && _ids.TryGetValue(m, out var value) && _metodos.TryGetValue(value, out var value2) && (value2.EnviarSi == null || value2.EnviarSi(args)))
			{
				if (Time.unscaledTime >= _segundo)
				{
					_segundo = Time.unscaledTime + 1f;
					_enviados = 0;
				}
				if (++_enviados <= 40)
				{
					ZRoutedRpc.instance.InvokeRoutedRPC(0L, "MT_RedVfx", new object[1] { Empaquetar(value, value2, args, ((Component)Player.m_localPlayer).transform.position) });
				}
			}
		}

		internal static ZPackage Empaquetar(int id, Metodo met, object[] args, Vector3 desde)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//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_001a: Expected O, but got Unknown
			ZPackage val = new ZPackage();
			val.Write(id);
			val.Write(desde);
			ZPackage val2 = new ZPackage();
			EscribirContexto?.Invoke(val2);
			val.Write(val2);
			for (int i = 0; i < met.Params.Length; i++)
			{
				Type parameterType = met.Params[i].ParameterType;
				if (Soportado(parameterType))
				{
					EscribirValor(val, parameterType, args[i]);
				}
			}
			return val;
		}

		internal static object[] Desempaquetar(ZPackage z, out Metodo met, out Vector3 desde, out ZPackage ctx, out bool falta)
		{
			//IL_0013: 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)
			met = null;
			ctx = null;
			falta = false;
			int key = z.ReadInt();
			desde = z.ReadVector3();
			if (!_metodos.TryGetValue(key, out met))
			{
				return null;
			}
			ctx = z.ReadPackage();
			object[] array = new object[met.Params.Length];
			for (int i = 0; i < array.Length; i++)
			{
				Type parameterType = met.Params[i].ParameterType;
				array[i] = (Soportado(parameterType) ? LeerValor(z, parameterType) : null);
				if (array[i] == NoEncontrado)
				{
					falta = true;
					return array;
				}
			}
			return array;
		}

		internal static Metodo Registrado(MethodBase m)
		{
			if (!_ids.TryGetValue(m, out var value))
			{
				return null;
			}
			return _metodos[value];
		}

		internal static int IdDe(MethodBase m)
		{
			if (!_ids.TryGetValue(m, out var value))
			{
				return 0;
			}
			return value;
		}

		private static void Recibir(long remitente, ZPackage z)
		{
			//IL_0039: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			if (ZRoutedRpc.instance == null || remitente == ZDOMan.GetSessionID())
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			try
			{
				Metodo met;
				Vector3 desde;
				ZPackage ctx;
				bool falta;
				object[] array = Desempaquetar(z, out met, out desde, out ctx, out falta);
				if (array == null || falta)
				{
					return;
				}
				Vector3 val = desde - ((Component)localPlayer).transform.position;
				if (((Vector3)(ref val)).sqrMagnitude > 10000f)
				{
					return;
				}
				Replicando = true;
				try
				{
					LeerContexto?.Invoke(ctx);
					met.Info.Invoke(null, array);
				}
				finally
				{
					Replicando = false;
					RestaurarContexto?.Invoke();
				}
			}
			catch (Exception ex)
			{
				MTCorePlugin.Log.LogWarning((object)("RedVfx (recibir): " + (ex.InnerException ?? ex).Message));
			}
		}

		internal static void RegistrarRpc()
		{
			if (ZRoutedRpc.instance != null)
			{
				ZRoutedRpc.instance.Register<ZPackage>("MT_RedVfx", (Action<long, ZPackage>)Recibir);
			}
		}
	}
	[HarmonyPatch(typeof(ZNet), "Awake")]
	public static class RedVfxRegistroPatch
	{
		private static void Postfix()
		{
			RedVfx.RegistrarRpc();
		}
	}
	public static class Ritmo
	{
		public const int Min = 1;

		public const int Max = 5;

		private const string Key = "MT.Ritmo";

		private const string DiaKey = "MT.Ritmo.Dia";

		private const string ElegidoKey = "MT.Ritmo.Elegido";

		private const string PreguntadoKey = "MT.Ritmo.Preguntado";

		public static int Permitido => Mathf.Clamp(CoreConfig.RitmoMaximo?.Value ?? 5, 1, 5);

		public static bool Preguntado(Player p)
		{
			if ((Object)(object)p != (Object)null)
			{
				return p.m_customData.ContainsKey("MT.Ritmo.Preguntado");
			}
			return false;
		}

		public static void MarcarPreguntado(Player p)
		{
			if ((Object)(object)p != (Object)null)
			{
				p.m_customData["MT.Ritmo.Preguntado"] = "1";
			}
		}

		public static int Guardado(Player p)
		{
			if (!((Object)(object)p != (Object)null) || !p.m_customData.TryGetValue("MT.Ritmo", out var value) || !int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return 1;
			}
			return Mathf.Clamp(result, 1, 5);
		}

		public static int Nivel(Player p)
		{
			return Mathf.Min(Guardado(p), Permitido);
		}

		public static float Crecimiento(Player p)
		{
			return RitmoRules.Crecimiento(Nivel(p));
		}

		public static float Comodidad(Player p)
		{
			return RitmoRules.Comodidad(Nivel(p));
		}

		public static float Poder(Player p)
		{
			return RitmoRules.Poder(Nivel(p));
		}

		public static bool HaElegido(Player p)
		{
			if ((Object)(object)p != (Object)null)
			{
				return p.m_customData.ContainsKey("MT.Ritmo.Elegido");
			}
			return false;
		}

		public static void MarcarElegido(Player p)
		{
			if ((Object)(object)p != (Object)null)
			{
				p.m_customData["MT.Ritmo.Elegido"] = "1";
			}
		}

		public static bool PuedeCambiar(Player p)
		{
			if (HaElegido(p) && p.m_customData.TryGetValue("MT.Ritmo.Dia", out var value))
			{
				return value != Mundo.Dia(Cronica.Dia());
			}
			return true;
		}

		public static bool Elegir(Player p, int nivel)
		{
			if ((Object)(object)p == (Object)null || nivel < 1 || nivel > Permitido || !PuedeCambiar(p))
			{
				return false;
			}
			bool num = !HaElegido(p);
			p.m_customData["MT.Ritmo"] = nivel.ToString(CultureInfo.InvariantCulture);
			if (!num)
			{
				p.m_customData["MT.Ritmo.Dia"] = Mundo.Dia(Cronica.Dia());
			}
			MarcarElegido(p);
			return true;
		}
	}
	[HarmonyPatch(typeof(Player), "RaiseSkill")]
	public static class RitmoExperienciaPatch
	{
		[HarmonyPriority(800)]
		private static void Prefix(Player __instance, ref float value)
		{
			if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && value > 0f)
			{
				value *= Ritmo.Crecimiento(__instance);
			}
		}
	}
	public static class RitmoRules
	{
		public static float Crecimiento(int m)
		{
			return m;
		}

		public static float Comodidad(int m)
		{
			return 1f + (float)(m - 1) * 0.5f;
		}

		public static float Poder(int m)
		{
			return 1f + (float)(m - 1) * 0.2f;
		}
	}
	public static class Topes
	{
		private const string Key = "MT.Core.DiosDragon";

		public static Func<Player, bool> DiosDragonCheck;

		public static bool IsDiosDragon(Player p)
		{
			if ((Object)(object)p != (Object)null)
			{
				if (!p.m_customData.ContainsKey("MT.Core.DiosDragon"))
				{
					return DiosDragonCheck?.Invoke(p) ?? false;
				}
				return true;
			}
	

plugins/MT.Espada/MT.Espada.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using MT.Core;
using MT.Core.Commands;
using MT.Core.Diario;
using MT.Core.Especialidades;
using MT.Core.I18n;
using MT.Core.Rueda;
using MT.Core.Touki;
using MT.Core.Vfx;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("MT.Espada")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ffb23be1655489b43ebd87164178fc39ecbb9f14")]
[assembly: AssemblyProduct("MT.Espada")]
[assembly: AssemblyTitle("MT.Espada")]
[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 MT.Espada
{
	public enum Arte
	{
		Corriente = 1,
		EspejoDelAgua,
		Contracorriente,
		Remolino,
		AguasQuietas
	}
	public static class Artes
	{
		private const string Key = "MT.Espada.Artes";

		public static string Name(Arte a)
		{
			return a switch
			{
				Arte.Corriente => "I · " + Tr.Get("espada_current_parry_arrows_projectiles"), 
				Arte.EspejoDelAgua => "II · " + Tr.Get("espada_water_mirror_block_from_behind"), 
				Arte.Contracorriente => "III · " + Tr.Get("espada_countercurrent_after_parry_hit_always"), 
				Arte.Remolino => "IV · " + Tr.Get("espada_whirlpool_perfect_parry_staggers_everyone"), 
				_ => "V · " + Tr.Get("espada_still_waters_stand_1_s"), 
			};
		}

		public static int Slots(Player p)
		{
			int num = Estilos.Rank(p, Estilo.Agua);
			if (num < 6)
			{
				if (num < 5)
				{
					return (num >= 4) ? 1 : 0;
				}
				return 2;
			}
			return 3;
		}

		public static List<Arte> Learned(Player p)
		{
			if (!p.m_customData.TryGetValue("MT.Espada.Artes", out var value) || string.IsNullOrEmpty(value))
			{
				return new List<Arte>();
			}
			return (from s in value.Split(new char[1] { ',' })
				select (Arte)int.Parse(s)).ToList();
		}

		public static bool Has(Player p, Arte a)
		{
			return Learned(p).Contains(a);
		}

		public static string Learn(Player p, Arte a)
		{
			List<Arte> list = Learned(p);
			if (list.Contains(a))
			{
				return Tr.Get("espada_already_master_that_art");
			}
			if (list.Count >= Slots(p))
			{
				return Tr.Get("espada_can_t_learn_more_arts", new object[1] { Slots(p) });
			}
			list.Add(a);
			p.m_customData["MT.Espada.Artes"] = string.Join(",", list.Select(delegate(Arte x)
			{
				int num = (int)x;
				return num.ToString();
			}));
			return Tr.Get("espada_learned_secret_art", new object[1] { Name(a) });
		}

		public static bool HasPrivacion(Player p)
		{
			if (Estilos.Rank(p, Estilo.Agua) >= 6 && Has(p, Arte.Corriente))
			{
				return Has(p, Arte.EspejoDelAgua);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Character), "Damage")]
	public static class OutgoingStylePatch
	{
		private static bool _extraHit;

		public static bool EnTecnica;

		private static readonly PropertyInfo PasoLastDash = AccessTools.TypeByName("MT.Paso.PasoController")?.GetProperty("LastDashTime", BindingFlags.Static | BindingFlags.Public);

		private static void Prefix(Character __instance, HitData hit)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Invalid comparison between Unknown and I4
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Invalid comparison between Unknown and I4
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Invalid comparison between Unknown and I4
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Invalid comparison between Unknown and I4
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (!_extraHit && !EnTecnica && !((Object)(object)localPlayer == (Object)null) && hit != null && !((Object)(object)__instance == (Object)(object)localPlayer) && !((Object)(object)hit.GetAttacker() != (Object)(object)localPlayer) && Array.IndexOf(BodyLevel.MeleeWeapons, hit.m_skill) >= 0 && Maestria.Hostile(localPlayer, __instance) && !(hit.GetTotalDamage() <= 0f))
			{
				Maestria.Reset(localPlayer);
				bool flag = Campos.AtaqueSecundario.Invoke((Humanoid)(object)localPlayer);
				float num = 0f;
				if ((int)hit.m_skill == 1)
				{
					num += SwordGod(localPlayer, __instance, hit, flag);
				}
				if ((int)hit.m_skill != 11)
				{
					num += WaterGod(localPlayer, __instance, hit);
				}
				num += NorthGod(localPlayer, __instance, hit, flag);
				if ((int)hit.m_skill == 11)
				{
					Logros.Add(localPlayer, Logro.Desarmado);
				}
				num = Mathf.Min(num, 3f);
				if (num > 0f)
				{
					((DamageTypes)(ref hit.m_damage)).Modify(1f + num);
				}
				MultiGolpe(localPlayer, __instance, hit);
				CombatState.LastHitTime = Time.time;
				if ((int)hit.m_skill == 1)
				{
					EntrenamientoEspada.Contact(localPlayer, combat: true);
					EstiloVfx.Burst(localPlayer, Estilo.Espada, hit.m_point);
					SEMan sEMan = ((Character)localPlayer).GetSEMan();
					(((sEMan != null) ? sEMan.GetStatusEffect(SE_PosturaLuna.Hash) : null) as SE_PosturaLuna)?.RegistrarGolpe();
					TajoPasivo.DispararTajoBasico(localPlayer, ((Humanoid)localPlayer).GetCurrentWeapon());
				}
				if (flag || __instance.IsStaggering() || Time.time - CombatState.LastDodgeStart < 2f)
				{
					Maestria.Train(localPlayer, Estilo.Norte, 3);
				}
			}
		}

		private static float SwordGod(Player p, Character target, HitData hit, bool secondary)
		{
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			int rank = Estilos.BonusRank(p, Estilo.Espada);
			int num = Estilos.Rank(p, Estilo.Espada);
			float num2 = 0.025f * (float)num;
			int num3 = (EntrenamientoEspada.ComboHit = EntrenamientoEspada.Session.CombatHit(Time.time, CombatState.LastDamagedTime));
			float num4 = ((PasoLastDash != null) ? ((float)PasoLastDash.GetValue(null)) : (-999f));
			if (target.GetHealth() >= target.GetMaxHealth() * 0.999f || Time.time - num4 < 1f)
			{
				num2 += Estilos.Scale(rank, 0.05f, 0.2f, 0.35f);
				Logros.Add(p, Logro.PrimerGolpe);
			}
			CombatState.NoteFirstHit(target);
			if (((Character)p).IsRunning())
			{
				num2 += Estilos.Scale(rank, 0f, 0.1f, 0.2f);
				Logros.Add(p, Logro.GolpeCorriendo);
			}
			Attack val = Campos.AtaqueActual.Invoke((Humanoid)(object)p);
			if (val != null && val.m_attackChainLevels > 1 && Campos.AtaqueCadena.Invoke(val) >= val.m_attackChainLevels - 1)
			{
				Logros.Add(p, Logro.CadenaCompleta);
				EstocadaEco.Intentar(p, num);
			}
			if (num >= 4)
			{
				bool flag = Time.time - CombatState.LastHitTime < 3f && CombatState.LastDamagedTime < CombatState.LastHitTime;
				if (num3 > 0)
				{
					CombatState.ComboStacks = (flag ? Mathf.Min(CombatState.ComboStacks + 1, 5) : 0);
				}
				num2 += 0.05f * (float)CombatState.ComboStacks;
			}
			if (num3 != 0 && num >= 5)
			{
				Vector3 velocity = target.GetVelocity();
				if (((Vector3)(ref velocity)).magnitude < 0.5f && CombatState.LagoReady(target) && PayToki(p, 25f))
				{
					CombatState.UseLago(target);
					num2 += 0.4f;
					hit.m_staggerMultiplier *= 3f;
					TajoPasivo.VisualHazaña(p, target, Estilo.Espada);
				}
			}
			return num2;
		}

		private static void MultiGolpe(Player p, Character target, HitData hit)
		{
			int num = Mathf.Max(Estilos.Rank(p, Estilo.Espada), Mathf.Max(Estilos.Rank(p, Estilo.Agua), Estilos.Rank(p, Estilo.Norte)));
			if (num >= 5)
			{
				bool flag = num >= 6;
				if (!(Random.value > (flag ? MTEspadaPlugin.ProbTripleGolpe.Value : MTEspadaPlugin.ProbDobleGolpe.Value)))
				{
					int count = ((!flag) ? 1 : 2);
					float share = (flag ? 0.85f : 0.7f);
					((Character)p).Message((MessageType)1, flag ? Tr.Get("espada_triple_strike") : Tr.Get("espada_double_strike"), 0, (Sprite)null, false);
					((MonoBehaviour)p).StartCoroutine(ExtraHits(p, target, hit, count, share));
				}
			}
		}

		private static IEnumerator ExtraHits(Player p, Character target, HitData hit, int count, float share)
		{
			DamageTypes dmg = ((DamageTypes)(ref hit.m_damage)).Clone();
			for (int i = 0; i < count; i++)
			{
				yield return (object)new WaitForSeconds(0.12f);
				if ((Object)(object)p == (Object)null || (Object)(object)p != (Object)(object)Player.m_localPlayer || ((Character)p).IsDead() || (Object)(object)target == (Object)null || target.IsDead() || Vector3.Distance(((Component)p).transform.position, ((Component)target).transform.position) > 5f)
				{
					break;
				}
				HitData val = new HitData
				{
					m_damage = ((DamageTypes)(ref dmg)).Clone(),
					m_point = target.GetCenterPoint()
				};
				Vector3 val2 = ((Component)target).transform.position - ((Component)p).transform.position;
				val.m_dir = ((Vector3)(ref val2)).normalized;
				val.m_skill = hit.m_skill;
				val.m_pushForce = hit.m_pushForce * 0.3f;
				val.m_toolTier = hit.m_toolTier;
				HitData val3 = val;
				((DamageTypes)(ref val3.m_damage)).Modify(share);
				val3.SetAttacker((Character)(object)p);
				_extraHit = true;
				try
				{
					target.Damage(val3);
					TajoPasivo.VisualMultiGolpe(p, target, i);
				}
				finally
				{
					_extraHit = false;
				}
			}
		}

		private static float WaterGod(Player p, Character target, HitData hit)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time - CombatState.LastParryTime > 1.5f)
			{
				return 0f;
			}
			float num = Estilos.Scale(Estilos.BonusRank(p, Estilo.Agua), 0.1f, 0.4f, 0.7f);
			Logros.Add(p, Logro.Contraataque);
			Maestria.Train(p, Estilo.Agua, 6);
			EstiloVfx.Burst(p, Estilo.Agua, hit.m_point);
			TajoPasivo.VisualHazaña(p, target, Estilo.Agua);
			if (Artes.Has(p, Arte.Contracorriente))
			{
				target.Stagger(hit.m_dir);
			}
			if (CombatState.LastParryPerfect && Artes.HasPrivacion(p) && Time.time >= CombatState.PrivacionReadyAt)
			{
				CombatState.PrivacionReadyAt = Time.time + 30f;
				num += 2f;
				((Character)p).Message((MessageType)1, Tr.Get("espada_sword_deprivation"), 0, (Sprite)null, false);
				TajoPasivo.VisualHazaña(p, target, Estilo.Agua);
			}
			CombatState.LastParryTime = -999f;
			return num;
		}

		private static float NorthGod(Player p, Character target, HitData hit, bool secondary)
		{
			//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_014f: Unknown result type (might be due to invalid IL or missing references)
			int rank = Estilos.BonusRank(p, Estilo.Norte);
			int num = Estilos.Rank(p, Estilo.Norte);
			float num2 = 0f;
			hit.m_backstabBonus += Estilos.Scale(rank, 0.1f, 0.5f, 1f);
			bool flag = Vector3.Dot(((Component)target).transform.forward, hit.m_dir) > 0.5f;
			if (flag)
			{
				Logros.Add(p, Logro.Espalda);
			}
			if (target.IsStaggering())
			{
				num2 += Estilos.Scale(rank, 0.05f, 0.2f, 0.35f);
				if (num >= 6)
				{
					num2 += 0.3f;
				}
				if (num >= 5 && flag)
				{
					hit.m_backstabBonus += 1f;
				}
				Logros.Add(p, Logro.Tambaleado);
			}
			if (secondary)
			{
				num2 += Estilos.Scale(rank, 0.03f, 0.12f, 0.2f);
				Logros.Add(p, Logro.Secundario);
			}
			if (num >= 3 && Time.time - CombatState.LastDodgeStart < 2f)
			{
				hit.m_staggerMultiplier *= 1f + Estilos.Scale(num, 0f, 0.3f, 0.6f);
			}
			if (num >= 4 && Time.time - CombatState.LastWeaponSwitch < 5f && Time.time >= CombatState.GuardReadyAt)
			{
				CombatState.GuardReadyAt = Time.time + 10f;
				num2 += 0.15f;
			}
			int num3 = CombatState.DistinctWeapons(hit.m_skill);
			if (num >= 5)
			{
				num2 += 0.05f * (float)Mathf.Min(num3, 4);
			}
			return num2;
		}

		private static bool PayToki(Player p, float cost)
		{
			if (!Manto.Active || Manto.Charge < cost * Manto.CostMultiplier(p))
			{
				return false;
			}
			Manto.Spend(p, cost, true);
			return true;
		}
	}
	[HarmonyPatch(typeof(Humanoid), "BlockAttack")]
	public static class BlockPatch
	{
		public struct State
		{
			public bool Active;

			public bool Perfect;

			public bool DirFlipped;

			public float Interval;

			public float Damage;

			public Vector3 Dir;
		}

		private static readonly FieldInfo PerfectInterval = AccessTools.Field(typeof(Humanoid), "m_perfectBlockInterval");

		private static float _lastCounterTime;

		private static float BaseInterval()
		{
			if (PerfectInterval == null)
			{
				return 0.25f;
			}
			return Convert.ToSingle(PerfectInterval.IsLiteral ? PerfectInterval.GetRawConstantValue() : PerfectInterval.GetValue(null));
		}

		private static void Prefix(Humanoid __instance, HitData hit, Character attacker, out State __state)
		{
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			__state = default(State);
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)__instance != (Object)(object)localPlayer) && hit != null && Maestria.Armed(localPlayer) && Maestria.Hostile(localPlayer, attacker))
			{
				int rank = Estilos.BonusRank(localPlayer, Estilo.Agua);
				__state.Active = true;
				__state.Interval = BaseInterval();
				__state.Damage = hit.GetTotalDamage();
				float num = Estilos.Scale(rank, 0.05f, 0.25f, 0.5f);
				if ((Object)(object)attacker != (Object)null && attacker.IsBoss() && Artes.Has(localPlayer, Arte.EspejoDelAgua))
				{
					num += 0.25f;
				}
				float num2 = __state.Interval * (1f + num);
				Traverse val = Traverse.Create((object)localPlayer).Field("m_blockTimer");
				if (Artes.Has(localPlayer, Arte.AguasQuietas) && Time.time - CombatState.StillSince >= 1f)
				{
					val.SetValue((object)0f);
				}
				float value = val.GetValue<float>();
				__state.Perfect = value >= 0f && value < num2;
				if (__state.Perfect && value >= __state.Interval)
				{
					val.SetValue((object)(__state.Interval * 0.5f));
				}
				if (Artes.Has(localPlayer, Arte.EspejoDelAgua) && Vector3.Dot(hit.m_dir, ((Component)localPlayer).transform.forward) > 0f)
				{
					__state.Dir = hit.m_dir;
					__state.DirFlipped = true;
					hit.m_dir = -((Component)localPlayer).transform.forward;
				}
				((DamageTypes)(ref hit.m_damage)).Modify(1f - Estilos.Scale(rank, 0.03f, 0.12f, 0.2f));
			}
		}

		private static void Postfix(Humanoid __instance, HitData hit, Character attacker, bool __result, State __state)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			if (!__state.Active)
			{
				return;
			}
			if (__state.DirFlipped)
			{
				hit.m_dir = __state.Dir;
			}
			if (!__result)
			{
				return;
			}
			Player val = (Player)__instance;
			int rank = Estilos.BonusRank(val, Estilo.Agua);
			int num = Estilos.Rank(val, Estilo.Agua);
			if (MTEspadaPlugin.ContraataqueAgua.Value && Time.time - _lastCounterTime > 0.22f)
			{
				_lastCounterTime = Time.time;
				EjecutarContraataqueAgua(val, attacker, hit, __state.Damage, __state.Perfect, num);
			}
			if (!__state.Perfect)
			{
				Maestria.Train(val, Estilo.Agua, 3);
				return;
			}
			CombatState.LastParryTime = Time.time;
			CombatState.LastParryPerfect = true;
			if (num >= 4)
			{
				VoluntadAcero.Limpiar(val);
			}
			if (num >= 5 && hit.m_ranged && (Object)(object)attacker != (Object)null && !attacker.IsDead())
			{
				HitData val2 = new HitData
				{
					m_damage = new DamageTypes
					{
						m_slash = __state.Damage * 0.5f
					},
					m_point = attacker.GetCenterPoint()
				};
				Vector3 val3 = ((Component)attacker).transform.position - ((Component)val).transform.position;
				val2.m_dir = ((Vector3)(ref val3)).normalized;
				val2.m_skill = (SkillType)6;
				HitData val4 = val2;
				val4.SetAttacker((Character)(object)val);
				attacker.Damage(val4);
				Tajo.SpawnAt(((Character)val).GetCenterPoint() + ((Component)val).transform.forward, ((Component)val).transform.forward, Tecnicas.Agua, 2.5f, 0.25f);
				((Character)val).Message((MessageType)1, Tr.Get("espada_water_reflect"), 0, (Sprite)null, false);
			}
			Logros.Add(val, Logro.ParryPerfecto);
			Maestria.Train(val, Estilo.Agua, 8);
			EstiloVfx.Burst(val, Estilo.Agua, ((Character)val).GetCenterPoint() + ((Component)val).transform.forward);
			((Character)val).AddStamina(10f * Estilos.Scale(rank, 0.05f, 0.2f, 0.35f) * 5f);
			if (!Artes.Has(val, Arte.Remolino))
			{
				return;
			}
			foreach (Character allCharacter in Character.GetAllCharacters())
			{
				if (Maestria.Hostile(val, allCharacter) && Vector3.Distance(((Component)allCharacter).transform.position, ((Component)val).transform.position) < 4f)
				{
					allCharacter.Stagger(((Component)allCharacter).transform.position - ((Component)val).transform.position);
				}
			}
		}

		private static void EjecutarContraataqueAgua(Player p, Character attacker, HitData hit, float blockedDamage, bool perfect, int rank)
		{
			//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_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_0032: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: 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_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Expected O, but got Unknown
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			ItemData currentWeapon = ((Humanoid)p).GetCurrentWeapon();
			Vector3 val = ((Component)p).transform.forward;
			if ((Object)(object)attacker != (Object)null)
			{
				Vector3 val2 = ((Component)attacker).transform.position - ((Component)p).transform.position;
				val2.y = 0f;
				if (((Vector3)(ref val2)).sqrMagnitude > 0.01f)
				{
					val = ((Vector3)(ref val2)).normalized;
				}
			}
			float skillLevel = ((Character)p).GetSkillLevel((SkillType)6);
			float num = ((currentWeapon != null) ? ((Character)p).GetSkillLevel(currentWeapon.m_shared.m_skillType) : 0f);
			float num2 = Mathf.Clamp01(Mathf.Max(skillLevel, num) / 100f);
			float num3 = (float)rank / 6f;
			float num4 = Mathf.Clamp01(MTEspadaPlugin.ProbFlujoTotal.Value + num2 * 0.35f + num3 * 0.35f);
			bool flag = perfect && Random.value < num4;
			float size = 3.2f + 0.25f * (float)rank + (flag ? 1.2f : 0f);
			float roll = Random.Range(-25f, 25f);
			Tajo.SpawnAt(((Character)p).GetCenterPoint() + val * 1.2f, val, Tecnicas.Agua, size, 0.28f, roll);
			EstiloVfx.Burst(p, Estilo.Agua, ((Character)p).GetCenterPoint() + val * 1f);
			float num5;
			DamageTypes val3;
			if (currentWeapon == null)
			{
				num5 = 25f;
			}
			else
			{
				val3 = currentWeapon.GetDamage();
				num5 = ((DamageTypes)(ref val3)).GetTotalPhysicalDamage();
			}
			float num6 = num5;
			if (num6 < 15f)
			{
				num6 = 25f;
			}
			float num7;
			if (flag)
			{
				num7 = num6 * (0.9f + 0.18f * (float)rank) + blockedDamage * Estilos.Scale(rank, 0.25f, 0.5f, 0.9f);
				Logros.Add(p, Logro.Contraataque);
			}
			else
			{
				float num8 = (perfect ? (0.55f + 0.1f * (float)rank) : (0.35f + 0.08f * (float)rank));
				num7 = num6 * num8 + blockedDamage * (perfect ? 0.25f : 0.15f);
			}
			HitData val4 = new HitData();
			val3 = (val4.m_damage = new DamageTypes
			{
				m_slash = num7 * 0.75f,
				m_blunt = num7 * 0.25f
			});
			val4.m_point = (((Object)(object)attacker != (Object)null) ? attacker.GetCenterPoint() : (((Character)p).GetCenterPoint() + val * 1.5f));
			val4.m_dir = val;
			val4.m_pushForce = (flag ? (14f + 2f * (float)rank) : (perfect ? 8f : 5f));
			val4.m_skill = (SkillType)((currentWeapon == null) ? 1 : ((int)currentWeapon.m_shared.m_skillType));
			HitData val5 = val4;
			val5.SetAttacker((Character)(object)p);
			if ((Object)(object)attacker != (Object)null && !attacker.IsDead() && Vector3.Distance(((Component)p).transform.position, ((Component)attacker).transform.position) <= 4.8f)
			{
				attacker.Damage(val5);
				if (flag || (perfect && Artes.Has(p, Arte.Contracorriente)))
				{
					attacker.Stagger(val);
				}
			}
			foreach (Character allCharacter in Character.GetAllCharacters())
			{
				if (!((Object)(object)allCharacter == (Object)(object)p) && !((Object)(object)allCharacter == (Object)(object)attacker) && Maestria.Hostile(p, allCharacter))
				{
					Vector3 val6 = ((Component)allCharacter).transform.position - ((Component)p).transform.position;
					val6.y = 0f;
					if (((Vector3)(ref val6)).magnitude <= 3.8f && Vector3.Dot(((Component)p).transform.forward, ((Vector3)(ref val6)).normalized) > 0.35f)
					{
						HitData val7 = val5.Clone();
						((DamageTypes)(ref val7.m_damage)).Modify(0.6f);
						val7.m_point = allCharacter.GetCenterPoint();
						val7.m_dir = ((Vector3)(ref val6)).normalized;
						allCharacter.Damage(val7);
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(Character), "RPC_Damage")]
	public static class IncomingStylePatch
	{
		private static void Prefix(Character __instance, HitData hit)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)__instance != (Object)(object)localPlayer) && hit != null)
			{
				if (hit.GetTotalDamage() > 0f && (int)hit.m_hitType != 3 && !((Character)localPlayer).IsDodgeInvincible())
				{
					CombatState.LastDamagedTime = Time.time;
				}
				if (hit.m_ranged && Artes.Has(localPlayer, Arte.Corriente))
				{
					hit.m_blockable = true;
				}
				if (((Character)localPlayer).IsDodgeInvincible() && hit.m_dodgeable && Maestria.Hostile(localPlayer, hit.GetAttacker()) && Maestria.Armed(localPlayer) && Time.time - Maestria.UltimaEvasion > 2f)
				{
					Logros.Add(localPlayer, Logro.EsquivaLimite);
					Maestria.Train(localPlayer, Estilo.Norte, 6);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Humanoid), "EquipItem")]
	public static class WeaponSwitchPatch
	{
		private static void Postfix(Humanoid __instance, ItemData item, bool __result)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (__result && !((Object)(object)localPlayer == (Object)null) && !((Object)(object)__instance != (Object)(object)localPlayer) && item != null && Array.IndexOf(BodyLevel.MeleeWeapons, item.m_shared.m_skillType) >= 0 && !(Time.time - Mathf.Max(CombatState.LastHitTime, CombatState.LastDamagedTime) > 10f))
			{
				CombatState.LastWeaponSwitch = Time.time;
				Logros.Add(localPlayer, Logro.CambioArma);
			}
		}
	}
	public static class CombatState
	{
		public static float LastParryTime = -999f;

		public static bool LastParryPerfect;

		public static float LastDodgeStart = -999f;

		public static float LastHitTime = -999f;

		public static float LastDamagedTime = -999f;

		public static int ComboStacks;

		public static float LastWeaponSwitch = -999f;

		public static float GuardReadyAt;

		public static SkillType LastKillWeapon = (SkillType)0;

		public static float StillSince;

		public static float PrivacionReadyAt;

		private static readonly Dictionary<Character, float> FirstHit = new Dictionary<Character, float>();

		private static readonly Dictionary<Character, float> LagoReadyAt = new Dictionary<Character, float>();

		private static readonly Dictionary<SkillType, float> WeaponHits = new Dictionary<SkillType, float>();

		public static void Reset()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			LastParryTime = (LastDodgeStart = (LastHitTime = (LastDamagedTime = (LastWeaponSwitch = -999f))));
			LastParryPerfect = false;
			ComboStacks = 0;
			GuardReadyAt = (PrivacionReadyAt = 0f);
			LastKillWeapon = (SkillType)0;
			StillSince = Time.time;
			FirstHit.Clear();
			LagoReadyAt.Clear();
			WeaponHits.Clear();
		}

		public static void NoteFirstHit(Character target)
		{
			if (!FirstHit.ContainsKey(target))
			{
				FirstHit[target] = Time.time;
			}
		}

		public static bool KilledQuickly(Character target)
		{
			if (FirstHit.TryGetValue(target, out var value))
			{
				return Time.time - value < 5f;
			}
			return false;
		}

		public static bool LagoReady(Character target)
		{
			if (LagoReadyAt.TryGetValue(target, out var value))
			{
				return Time.time >= value;
			}
			return true;
		}

		public static void UseLago(Character target)
		{
			LagoReadyAt[target] = Time.time + 15f;
		}

		public static int DistinctWeapons(SkillType current)
		{
			//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_0013: Unknown result type (might be due to invalid IL or missing references)
			WeaponHits[current] = Time.time;
			return WeaponHits.Count((KeyValuePair<SkillType, float> kv) => kv.Key != current && Time.time - kv.Value < 10f);
		}

		public static void Cleanup()
		{
			foreach (Character item in FirstHit.Keys.Where((Character c) => (Object)(object)c == (Object)null || Time.time - FirstHit[c] > 60f).ToList())
			{
				FirstHit.Remove(item);
			}
			foreach (Character item2 in LagoReadyAt.Keys.Where((Character c) => (Object)(object)c == (Object)null).ToList())
			{
				LagoReadyAt.Remove(item2);
			}
		}
	}
	public class CorteSupersonico : MonoBehaviour
	{
		private const int Puntos = 72;

		private const float Velocidad = 85f;

		private const float Desvanecer = 0.35f;

		private const float RadioGolpe = 1.4f;

		private static readonly AnimationCurve AnchoGrueso = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
		{
			new Keyframe(0f, 0.02f),
			new Keyframe(0.75f, 0.32f),
			new Keyframe(1f, 0.12f)
		});

		private static readonly AnimationCurve AnchoFino = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
		{
			new Keyframe(0f, 0.01f),
			new Keyframe(0.7f, 0.08f),
			new Keyframe(1f, 0.03f)
		});

		private static float _listo;

		private Vector3[] _camino;

		private float[] _acum;

		private float _largo;

		private float _t;

		private float _fin;

		private LineRenderer[] _lineas;

		private Vector3[][] _offsets;

		private Color _color;

		private Golpe _golpe;

		private int _hecho;

		private readonly HashSet<Character> _tocados = new HashSet<Character>();

		private readonly List<Vector3> _tmp = new List<Vector3>(72);

		private static int _forma = 0;

		private static int _combo;

		private static float _ultimoCorte = -10f;

		private static float _secundarioHasta;

		public static float Alcance(Player p, DefTecnica d, bool conToki)
		{
			float skillFactor = ((Character)p).GetSkillFactor((SkillType)1);
			return (d.Alcance + 2f * (float)Mathf.Max(0, Estilos.Rank(p, d.Estilo) - d.Rango) + 8f * skillFactor) * (conToki ? 1.3f : 1f) * MTEspadaPlugin.SupersonicaAlcance.Value;
		}

		public static bool DesdeAtaque(Player p, Attack atk)
		{
			if ((Object)(object)p == (Object)null || Time.time < _listo || Time.time < _secundarioHasta)
			{
				return false;
			}
			if (Time.time - Tecnicas.UltimoUso < 0.7f)
			{
				return true;
			}
			DefTecnica defTecnica = Tecnicas.Def(Tecnica.Supersonica);
			if (defTecnica == null || !Tecnicas.ArmaValida(p, defTecnica))
			{
				return false;
			}
			_listo = Time.time + 0.25f;
			_forma = SiguienteLateral();
			try
			{
				Tecnicas.Ejecutar(p, defTecnica, Manto.Active, 0.45f, eco: true);
			}
			finally
			{
				_forma = 0;
			}
			return true;
		}

		private static int SiguienteLateral()
		{
			if (Time.time - _ultimoCorte > 1.6f)
			{
				_combo = 0;
			}
			int result = _combo % 3;
			_combo++;
			_ultimoCorte = Time.time;
			return result;
		}

		public static void DesdeSecundario(Player p)
		{
			if (!((Object)(object)p == (Object)null))
			{
				DefTecnica defTecnica = Tecnicas.Def(Tecnica.Supersonica);
				if (defTecnica != null && Tecnicas.ArmaValida(p, defTecnica))
				{
					_secundarioHasta = Time.time + 0.9f;
					_combo = 0;
					((MonoBehaviour)p).StartCoroutine(Secundario(p, defTecnica));
				}
			}
		}

		private static IEnumerator Secundario(Player p, DefTecnica d)
		{
			yield return (object)new WaitForSeconds(0.2f);
			if ((Object)(object)p == (Object)null || ((Character)p).IsDead())
			{
				yield break;
			}
			_forma = 3;
			try
			{
				Tecnicas.Ejecutar(p, d, Manto.Active, 0.45f, eco: true);
			}
			finally
			{
				_forma = 0;
			}
		}

		public static void Lanzar(Player p, Golpe golpe, float alcance, Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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)
			Vector3 lookDir = ((Character)p).GetLookDir();
			Vector3 val = new Vector3(lookDir.x, Mathf.Clamp(lookDir.y, -0.6f, 0.9f), lookDir.z);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			int num = _forma;
			if (Time.time - Tecnicas.UltimoUso < 0.05f && num == 0 && _combo == 0)
			{
				num = SiguienteLateral();
			}
			LanzarDesde(((Component)p).transform.position + Vector3.up * 1f + normalized * 0.5f, normalized, alcance, color, golpe, num);
		}

		public static void LanzarDesde(Vector3 origen, Vector3 dir, float alcance, Color color, Golpe golpe, int forma)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_00dd: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = ((forma == 2) ? CaminoRecto(origen, dir, alcance) : CaminoCurvo(origen, dir, alcance, forma));
			GameObject val = new GameObject("MT_CorteSupersonico");
			CorteSupersonico corteSupersonico = val.AddComponent<CorteSupersonico>();
			corteSupersonico._camino = array;
			corteSupersonico._color = color;
			corteSupersonico._golpe = golpe;
			corteSupersonico._acum = new float[72];
			for (int i = 1; i < 72; i++)
			{
				corteSupersonico._acum[i] = corteSupersonico._acum[i - 1] + Vector3.Distance(array[i - 1], array[i]);
			}
			corteSupersonico._largo = corteSupersonico._acum[71];
			corteSupersonico._fin = corteSupersonico._largo / 85f;
			Vector3 val2 = Vector3.Cross(dir, Vector3.Cross(Vector3.up, dir));
			Vector3 up = ((Vector3)(ref val2)).normalized;
			if (((Vector3)(ref up)).sqrMagnitude < 0.01f)
			{
				up = Vector3.up;
			}
			corteSupersonico.Preparar(dir, up);
			Object.Destroy((Object)(object)val, corteSupersonico._fin + 0.35f + 0.2f);
		}

		private static Vector3[] CaminoRecto(Vector3 origen, Vector3 dir, float alcance)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			float num = alcance * 0.8f;
			int mask = LayerMask.GetMask(new string[4] { "Default", "static_solid", "terrain", "piece" });
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(origen, dir, ref val, num, mask, (QueryTriggerInteraction)1))
			{
				num = Mathf.Max(1.5f, ((RaycastHit)(ref val)).distance - 0.3f);
			}
			float num2 = Mathf.Clamp(alcance * 0.11f, 1.2f, 4.5f);
			Vector3 val2 = Vector3.Cross(dir, Vector3.Cross(Vector3.up, dir));
			Vector3 val3 = ((Vector3)(ref val2)).normalized;
			if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
			{
				val3 = Vector3.up;
			}
			int num3 = 48;
			int num4 = 72 - num3;
			Vector3[] array = (Vector3[])(object)new Vector3[72];
			for (int i = 0; i < num3; i++)
			{
				float num5 = (float)i / (float)num3;
				array[i] = origen + dir * (num * num5) - val3 * (0.45f * Mathf.SmoothStep(0f, 1f, num5));
			}
			Vector3 val4 = origen + dir * num - val3 * 0.45f + val3 * num2;
			for (int j = 0; j < num4; j++)
			{
				float num6 = Mathf.Lerp(0f, 3.5185838f, (float)(j + 1) / (float)num4);
				array[num3 + j] = val4 + dir * (num2 * Mathf.Sin(num6)) - val3 * (num2 * Mathf.Cos(num6));
			}
			return array;
		}

		private static Vector3[] CaminoCurvo(Vector3 origen, Vector3 dir, float alcance, int forma)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.ProjectOnPlane(dir, Vector3.up);
			if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
			{
				val = Vector3.forward;
			}
			((Vector3)(ref val)).Normalize();
			Vector3 val2 = Vector3.Cross(Vector3.up, val);
			float num = dir.y * alcance * 0.5f;
			Vector3[] array = (Vector3[])(object)new Vector3[72];
			float num2;
			switch (forma)
			{
			case 3:
			{
				float num3 = alcance * 0.42f;
				Vector3 val3 = origen + val * num3;
				for (int i = 0; i < 72; i++)
				{
					float num4 = Mathf.Lerp(0f, 4.363323f, (float)i / 71f);
					array[i] = val3 - val * (num3 * Mathf.Cos(num4)) - val2 * (num3 * Mathf.Sin(num4)) + Vector3.up * (num * (float)i / 71f);
				}
				return array;
			}
			default:
				num2 = -1f;
				break;
			case 0:
				num2 = 1f;
				break;
			}
			float num5 = num2;
			Vector3 val4 = origen + val * (alcance * 0.6f) + val2 * (num5 * alcance * 0.35f);
			Vector3 val5 = origen + val * (alcance * 0.75f) - val2 * (num5 * alcance * 0.45f);
			for (int j = 0; j < 72; j++)
			{
				float num6 = (float)j / 71f;
				float num7 = 1f - num6;
				array[j] = num7 * num7 * origen + 2f * num7 * num6 * val4 + num6 * num6 * val5 + Vector3.up * (num * num6);
			}
			return array;
		}

		private void Preparar(Vector3 dir, Vector3 up)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			if (!MTEspadaPlugin.EfectosTajo.Value || (Object)(object)TajoRecursos.Linea == (Object)null)
			{
				_lineas = (LineRenderer[])(object)new LineRenderer[0];
				return;
			}
			Vector3 val = Vector3.Cross(up, dir);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			_lineas = (LineRenderer[])(object)new LineRenderer[3]
			{
				TajoRecursos.NuevaLinea(((Component)this).transform, mundo: true, AnchoGrueso),
				TajoRecursos.NuevaLinea(((Component)this).transform, mundo: true, AnchoFino),
				TajoRecursos.NuevaLinea(((Component)this).transform, mundo: true, AnchoFino)
			};
			_offsets = new Vector3[3][]
			{
				(Vector3[])(object)new Vector3[1] { Vector3.zero },
				(Vector3[])(object)new Vector3[1] { up * 0.35f + normalized * 0.15f },
				(Vector3[])(object)new Vector3[1] { -up * 0.3f - normalized * 0.2f }
			};
		}

		private void Update()
		{
			_t += Time.deltaTime;
			float num = Mathf.Min(_largo, _t * 85f);
			int cabeza = Indice(num);
			Danar(cabeza);
			Dibujar(cabeza, num);
		}

		private int Indice(float d)
		{
			int i;
			for (i = 0; i < 71 && _acum[i + 1] <= d; i++)
			{
			}
			return i;
		}

		private void Danar(int cabeza)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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)
			//IL_00b1: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: 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)
			if (_golpe == null || (Object)(object)_golpe.Atacante == (Object)null || cabeza < _hecho)
			{
				return;
			}
			Player atacante = _golpe.Atacante;
			foreach (Character allCharacter in Character.GetAllCharacters())
			{
				if ((Object)(object)allCharacter == (Object)null || _tocados.Contains(allCharacter) || !Maestria.Hostile(atacante, allCharacter))
				{
					continue;
				}
				Vector3 centerPoint = allCharacter.GetCenterPoint();
				float num = 1.4f + allCharacter.GetRadius();
				for (int i = Mathf.Max(0, _hecho - 1); i < cabeza; i++)
				{
					if (!(DistSeg(centerPoint, _camino[i], _camino[i + 1]) > num))
					{
						_tocados.Add(allCharacter);
						Golpe golpe = _golpe;
						Vector3 val = _camino[i + 1] - _camino[i];
						golpe.Aplicar(allCharacter, centerPoint, ((Vector3)(ref val)).normalized);
						break;
					}
				}
			}
			_hecho = cabeza + 1;
		}

		private static float DistSeg(Vector3 p, Vector3 a, Vector3 b)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001d: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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)
			Vector3 val = b - a;
			float num = ((((Vector3)(ref val)).sqrMagnitude > 1E-06f) ? Mathf.Clamp01(Vector3.Dot(p - a, val) / ((Vector3)(ref val)).sqrMagnitude) : 0f);
			return Vector3.Distance(p, a + val * num);
		}

		private void Dibujar(int cabeza, float recorrido)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			if (_lineas.Length == 0)
			{
				return;
			}
			float num = ((_t <= _fin) ? 1f : Mathf.Clamp01(1f - (_t - _fin) / 0.35f));
			for (int i = 0; i < _lineas.Length; i++)
			{
				LineRenderer val = _lineas[i];
				if (!((Object)(object)val == (Object)null))
				{
					int num2 = Mathf.Max(0, cabeza - i * 3);
					_tmp.Clear();
					for (int j = 0; j <= num2; j++)
					{
						_tmp.Add(_camino[j] + _offsets[i][0]);
					}
					if (num2 < 71 && i == 0 && recorrido < _largo)
					{
						float num3 = Mathf.InverseLerp(_acum[num2], _acum[num2 + 1], recorrido);
						_tmp.Add(Vector3.Lerp(_camino[num2], _camino[num2 + 1], num3));
					}
					val.positionCount = _tmp.Count;
					for (int k = 0; k < _tmp.Count; k++)
					{
						val.SetPosition(k, _tmp[k]);
					}
					Color val2 = Color.Lerp(_color, Color.white, (i == 0) ? 0.55f : 0.75f);
					float num4 = num * ((i == 0) ? 0.85f : 0.6f);
					val.startColor = new Color(val2.r, val2.g, val2.b, num4 * 0.35f);
					val.endColor = new Color(val2.r, val2.g, val2.b, num4);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Humanoid), "StartAttack")]
	public static class SupersonicaSecundarioPatch
	{
		private static void Postfix(Humanoid __instance, bool secondaryAttack, bool __result)
		{
			if (!__result || !secondaryAttack)
			{
				return;
			}
			Player val = (Player)(object)((__instance is Player) ? __instance : null);
			if (val != null && !((Object)(object)val != (Object)(object)Player.m_localPlayer))
			{
				SEMan sEMan = ((Character)val).GetSEMan();
				if (sEMan != null && sEMan.HaveStatusEffect(SE_PosturaSupersonica.Hash))
				{
					CorteSupersonico.DesdeSecundario(val);
				}
			}
		}
	}
	public static class DiarioEspada
	{
		public static void Registrar()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			Paginas.Registrar(new DiarioPagina
			{
				Id = "espada",
				TituloKey = "diario_tab_sword",
				Orden = 30,
				Dibujar = Dibujar
			});
		}

		private static string NameKey(Estilo e)
		{
			return e switch
			{
				Estilo.Agua => "espada_water_god", 
				Estilo.Espada => "espada_sword_god", 
				_ => "espada_north_god", 
			};
		}

		public static void RangoSubido(Player p, Estilo e, int rango)
		{
			Cronica.Anotar(p, "cronica_sword_rank", new string[2]
			{
				"@" + NameKey(e),
				"@core_rank_" + rango.ToString(CultureInfo.InvariantCulture)
			});
		}

		private static void Dibujar(Player p, DiarioEscritor e)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			e.Titulo(Tr.Get("diario_tab_sword"));
			e.Parrafo(Tr.Get("diario_sword_intro"), (Color?)DiarioEscritor.TintaSuave, 15, 0f);
			List<Estilo> list = (from x in Estilos.All
				where Estilos.Rank(p, x) < 6
				orderby Maestria.XP(p, x) descending
				select x).ToList();
			if (list.Count > 0)
			{
				Estilo e2 = list[0];
				int num = Estilos.Rank(p, e2);
				e.Meta((Estilos.RequirementCap(p) <= num) ? Tr.Get("diario_goal_sword_req", new object[3]
				{
					Estilos.Name(e2),
					Rangos.Name(num + 1),
					Requisito(p)
				}) : Tr.Get("diario_goal_sword_xp", new object[4]
				{
					Estilos.Name(e2),
					Rangos.Name(num + 1),
					Maestria.XP(p, e2),
					Maestria.Umbrales[num + 1]
				}));
			}
			Estilo[] all = Estilos.All;
			foreach (Estilo estilo in all)
			{
				int num3 = Estilos.Rank(p, estilo);
				e.Subtitulo(Estilos.Name(estilo), (Color?)null);
				e.Parrafo(Tr.Get(ComoKey(estilo)), (Color?)DiarioEscritor.TintaAzul, 14, 0f);
				e.Dato(Tr.Get("diario_current_rank"), Rangos.Name(num3), (Color?)null);
				if (num3 >= 6)
				{
					e.Parrafo(Tr.Get("diario_rank_max"), (Color?)DiarioEscritor.TintaOro, 14, 0f);
					continue;
				}
				int num4 = num3 + 1;
				e.Dato(Tr.Get("diario_target_rank"), Rangos.Name(num4), (Color?)null);
				if (Estilos.RequirementCap(p) <= num3)
				{
					e.Parrafo(Requisito(p), (Color?)DiarioEscritor.TintaRoja, 15, 0f);
				}
				int num5 = Maestria.XP(p, estilo);
				e.Progreso(Tr.Get("diario_sword_training"), Mathf.InverseLerp((float)Maestria.Umbrales[num3], (float)Maestria.Umbrales[num4], (float)num5), $"{num5} / {Maestria.Umbrales[num4]}", (Color?)DiarioEscritor.TintaOro);
				e.Parrafo(Tr.Get("diario_sword_or_feats", new object[1] { Rangos.Name(num4) }), (Color?)DiarioEscritor.TintaSuave, 14, 0f);
				Logro[] array = Logros.Required[(int)estilo];
				foreach (Logro l in array)
				{
					int num7 = Logros.Count(p, l);
					int num8 = Logros.Needed[num4];
					e.Requisito(Logros.Name(l), (float)num7, (float)num8);
				}
			}
			List<Arte> list2 = Artes.Learned(p);
			e.Subtitulo(Tr.Get("diario_sword_arts"), (Color?)null);
			e.Parrafo(Tr.Get("diario_arts_slots", new object[2]
			{
				list2.Count,
				Artes.Slots(p)
			}), (Color?)DiarioEscritor.TintaSuave, 15, 0f);
			e.Parrafo(Tr.Get("diario_sword_arts_how"), (Color?)DiarioEscritor.TintaAzul, 14, 0f);
			if (list2.Count == 0)
			{
				e.Parrafo(Tr.Get("diario_sword_arts_none"), (Color?)DiarioEscritor.TintaSuave, 14, 0f);
			}
			foreach (Arte item in list2)
			{
				e.Parrafo("• " + Artes.Name(item), (Color?)DiarioEscritor.Tinta, 15, 0f);
			}
			if (list2.Count >= Artes.Slots(p))
			{
				return;
			}
			foreach (Arte value in Enum.GetValues(typeof(Arte)))
			{
				if (!list2.Contains(value))
				{
					float y = e.Y;
					e.Parrafo("☐ " + Artes.Name(value) + " · " + Tr.Get("diario_sword_arts_click"), (Color?)DiarioEscritor.TintaOro, 15, 0f);
					if (e.Pulsado(new Rect(e.X, y, e.Ancho, e.Y - y)))
					{
						((Character)p).Message((MessageType)2, Artes.Learn(p, value), 0, (Sprite)null, false);
						break;
					}
				}
			}
		}

		private static string ComoKey(Estilo e)
		{
			return e switch
			{
				Estilo.Agua => "diario_sword_how_water", 
				Estilo.Espada => "diario_sword_how_sword", 
				_ => "diario_sword_how_north", 
			};
		}

		private static string Requisito(Player p)
		{
			int num = ToukiRules.Level(p);
			if (!ToukiState.IsAwakened(p))
			{
				return Tr.Get("diario_sword_need_toki");
			}
			if (num < 4)
			{
				return Tr.Get("diario_sword_need_toki_level", new object[1] { 4 });
			}
			if (!Estilos.Defeated(p, "defeated_dragon"))
			{
				return Tr.Get("diario_need_boss", new object[1] { Tr.Localize(EventosCore.NombreJefe("defeated_dragon")) });
			}
			if (num < 6)
			{
				return Tr.Get("diario_sword_need_toki_level", new object[1] { 6 });
			}
			return Tr.Get("diario_sword_need_toki_level", new object[1] { 8 });
		}
	}
	public static class DiarioTecnicas
	{
		private static readonly Color Lacre = new Color(0.62f, 0.1f, 0.08f);

		public static void Registrar()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			Paginas.Registrar(new DiarioPagina
			{
				Id = "tecnicas",
				TituloKey = "diario_tab_techniques",
				Orden = 31,
				Dibujar = Dibujar
			});
		}

		private static void Dibujar(Player p, DiarioEscritor e)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			e.Titulo(Tr.Get("diario_tab_techniques"));
			e.Parrafo(Tr.Get("diario_tech_intro"), (Color?)DiarioEscritor.TintaSuave, 15, 0f);
			int num = 0;
			DefTecnica[] todas = Tecnicas.Todas;
			foreach (DefTecnica defTecnica in todas)
			{
				bool conoce = Tecnicas.Conoce(p, defTecnica);
				e.Subtitulo(conoce ? defTecnica.Nombre : (defTecnica.Nombre + " · " + Tr.Get("diario_tech_unknown")), (Color?)(conoce ? DiarioEscritor.TintaOro : DiarioEscritor.TintaSuave));
				DefTecnica def = defTecnica;
				Sprite val = (conoce ? defTecnica.Icono : null);
				if ((Object)(object)val == (Object)null)
				{
					e.Boceto(92f, (Action<Rect>)delegate(Rect r)
					{
						//IL_0000: Unknown result type (might be due to invalid IL or missing references)
						Boceto(r, def, conoce ? 0.9f : 0.22f, DiarioEscritor.EscalaActual);
					});
				}
				if (!conoce)
				{
					string text = ((num % 4 == 0) ? "diario_tech_rumor" : ("diario_tech_rumor_" + (num % 4 + 1)));
					num++;
					string text2 = ((Estilos.StoredRank(p, defTecnica.Estilo) >= defTecnica.Rango) ? Estilos.Falta(p, defTecnica.Rango) : "");
					if (text2.Length > 0)
					{
						e.Parrafo(Tr.Get("diario_tech_capped", new object[2]
						{
							Estilos.RankNames[defTecnica.Rango],
							text2
						}), (Color?)DiarioEscritor.TintaRoja, 14, 0f);
					}
					else
					{
						e.Parrafo(Tr.Get(text, new object[2]
						{
							Estilos.RankNames[defTecnica.Rango],
							Estilos.Name(defTecnica.Estilo)
						}), (Color?)DiarioEscritor.TintaSuave, 14, 0f);
					}
					e.Espacio(6f);
					continue;
				}
				if ((Object)(object)val != (Object)null)
				{
					ConIcono(e, val, defTecnica.Descripcion);
				}
				else
				{
					e.Parrafo(defTecnica.Descripcion, (Color?)DiarioEscritor.Tinta, 15, 0f);
				}
				string text3 = (defTecnica.TokiObligatorio ? Tr.Get("diario_tech_toki_needed", new object[1] { defTecnica.Toki }) : Tr.Get("diario_tech_toki_bonus", new object[1] { defTecnica.Toki }));
				e.Dato(Tr.Get("diario_tech_cost"), Tr.Get("diario_tech_cost_value", new object[2] { defTecnica.Stamina, defTecnica.Enfriamiento }), (Color?)null);
				e.Parrafo(text3, (Color?)DiarioEscritor.TintaSuave, 14, 0f);
				if (defTecnica.SoloEspada)
				{
					e.Parrafo(Tr.Get("diario_tech_sword_only"), (Color?)DiarioEscritor.TintaSuave, 14, 0f);
				}
				Atajos(p, e, defTecnica);
				e.Espacio(8f);
			}
		}

		private static void ConIcono(DiarioEscritor e, Sprite icono, string texto)
		{
			//IL_009b: 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)
			float escalaActual = DiarioEscritor.EscalaActual;
			float num = 76f * escalaActual;
			float y = e.Y;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(e.X + 2f * escalaActual, e.Y + 2f * escalaActual, num, num);
			if (DiarioEscritor.Visible(((Rect)(ref val)).y, ((Rect)(ref val)).height))
			{
				RecortesDiario.Dibujar(val, icono, 1f, -1.4f);
			}
			float x = e.X;
			float ancho = e.Ancho;
			float num2 = num + 16f * escalaActual;
			e.X += num2;
			e.Ancho -= num2;
			e.Parrafo(texto, (Color?)DiarioEscritor.Tinta, 15, 0f);
			e.X = x;
			e.Ancho = ancho;
			e.Y = Mathf.Max(e.Y, y + num + 10f * escalaActual);
		}

		private static void Atajos(Player p, DiarioEscritor e, DefTecnica d)
		{
			//IL_0021: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Invalid comparison between Unknown and I4
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			float escalaActual = DiarioEscritor.EscalaActual;
			float num = 30f * escalaActual;
			float num2 = 8f * escalaActual;
			e.Parrafo(Tr.Get("diario_tech_shortcut"), (Color?)DiarioEscritor.TintaSuave, 14, 0f);
			Tecnica[] array = Tecnicas.Atajo(p);
			float y = e.Y;
			Rect val = default(Rect);
			Color val2 = default(Color);
			for (int i = 0; i < 9; i++)
			{
				((Rect)(ref val))..ctor(e.X + (float)i * (num + num2), y, num, num);
				if (e.Pulsado(val))
				{
					Tecnicas.Asignar(p, i, d.Id);
					array = Tecnicas.Atajo(p);
				}
				if (!DiarioEscritor.Visible(((Rect)(ref val)).y, ((Rect)(ref val)).height))
				{
					continue;
				}
				bool flag = array[i] == d.Id;
				bool flag2 = array[i] != 0 && !flag;
				((Color)(ref val2))..ctor(DiarioEscritor.Tinta.r, DiarioEscritor.Tinta.g, DiarioEscritor.Tinta.b, DiarioEscritor.Encima(val) ? 0.9f : 0.45f);
				if (flag)
				{
					DiarioEscritor.Sello(new Rect(((Rect)(ref val)).x + 2f * escalaActual, ((Rect)(ref val)).y + 2f * escalaActual, num - 4f * escalaActual, num - 4f * escalaActual), (i + 1).ToString(), Lacre, escalaActual);
					continue;
				}
				DiarioEscritor.Trazo(new Vector2(((Rect)(ref val)).x, ((Rect)(ref val)).y), new Vector2(((Rect)(ref val)).xMax, ((Rect)(ref val)).y + escalaActual), val2, 1.4f * escalaActual);
				DiarioEscritor.Trazo(new Vector2(((Rect)(ref val)).xMax, ((Rect)(ref val)).y + escalaActual), new Vector2(((Rect)(ref val)).xMax - escalaActual, ((Rect)(ref val)).yMax), val2, 1.4f * escalaActual);
				DiarioEscritor.Trazo(new Vector2(((Rect)(ref val)).xMax - escalaActual, ((Rect)(ref val)).yMax), new Vector2(((Rect)(ref val)).x + escalaActual, ((Rect)(ref val)).yMax - escalaActual), val2, 1.4f * escalaActual);
				DiarioEscritor.Trazo(new Vector2(((Rect)(ref val)).x + escalaActual, ((Rect)(ref val)).yMax - escalaActual), new Vector2(((Rect)(ref val)).x, ((Rect)(ref val)).y), val2, 1.4f * escalaActual);
				if ((int)Event.current.type == 7)
				{
					GUI.Label(val, (i + 1).ToString(), DiarioEscritor.Estilo(14, flag2 ? DiarioEscritor.TintaSuave : DiarioEscritor.Tinta, (TextAnchor)4, false, false));
				}
				if (flag2)
				{
					DiarioEscritor.Trazo(new Vector2(((Rect)(ref val)).x + 5f * escalaActual, ((Rect)(ref val)).yMax - 5f * escalaActual), new Vector2(((Rect)(ref val)).xMax - 5f * escalaActual, ((Rect)(ref val)).y + 5f * escalaActual), val2, 1.2f * escalaActual);
				}
			}
			e.Y = y + num + 6f * escalaActual;
		}

		private static void Boceto(Rect r, DefTecnica d, float alpha, float s)
		{
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: 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_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_051c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Unknown result type (might be due to invalid IL or missing references)
			//IL_0553: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0570: Unknown result type (might be due to invalid IL or missing references)
			//IL_0575: Unknown result type (might be due to invalid IL or missing references)
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0581: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05db: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
			Color val = default(Color);
			((Color)(ref val))..ctor(DiarioEscritor.Tinta.r, DiarioEscritor.Tinta.g, DiarioEscritor.Tinta.b, alpha);
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(Mathf.Lerp(DiarioEscritor.Tinta.r, d.Color.r * 0.55f, 0.6f), Mathf.Lerp(DiarioEscritor.Tinta.g, d.Color.g * 0.55f, 0.6f), Mathf.Lerp(DiarioEscritor.Tinta.b, d.Color.b * 0.55f, 0.6f), alpha);
			DiarioEscritor.Trazo(new Vector2(((Rect)(ref r)).x + 8f * s, ((Rect)(ref r)).yMax - 8f * s), new Vector2(((Rect)(ref r)).x + ((Rect)(ref r)).width * 0.9f, ((Rect)(ref r)).yMax - 9f * s), new Color(val.r, val.g, val.b, alpha * 0.35f), 1f * s);
			if (d.Forma == Forma.Anillo)
			{
				Vector2 val3 = default(Vector2);
				((Vector2)(ref val3))..ctor(((Rect)(ref r)).x + ((Rect)(ref r)).width * 0.3f, ((Rect)(ref r)).yMax - 30f * s);
				Figura(val3 + new Vector2(0f, 8f * s), val, s);
				Vector2 val4 = default(Vector2);
				((Vector2)(ref val4))..ctor(62f * s, 22f * s);
				DiarioEscritor.Arco(val3 + new Vector2(0f, 8f * s), val4, 200f, 500f, val2, 3.2f * s, 36);
				DiarioEscritor.Flecha(val3 + new Vector2(val4.x * 0.2f, 8f * s + val4.y), val3 + new Vector2(val4.x * 0.62f, 8f * s + val4.y * 0.8f), val2, 1.6f * s, 7f * s);
				if (d.Id == Tecnica.CorteRio)
				{
					for (int i = 0; i < 7; i++)
					{
						float num = (float)i * 0.9f;
						DiarioEscritor.Arco(val3 + new Vector2(Mathf.Cos(num) * (val4.x + 12f * s), 8f * s + Mathf.Sin(num) * (val4.y + 8f * s)), new Vector2(2.2f * s, 3f * s), 0f, 360f, val2, 1.4f * s, 8);
					}
				}
				return;
			}
			Vector2 val5 = new Vector2(((Rect)(ref r)).x + 40f * s, ((Rect)(ref r)).yMax - 22f * s);
			Figura(val5, val, s);
			Vector2 val6 = val5 + new Vector2(6f * s, -30f * s);
			float num2 = Mathf.Min(((Rect)(ref r)).width * 0.72f, ((d.Id == Tecnica.LuzLarga) ? 420f : ((d.Id == Tecnica.Supersonica) ? 330f : 250f)) * s);
			float num3 = Mathf.Clamp(d.Ancho * 14f, 16f, 48f) * s;
			Vector2 val7 = val6 + new Vector2(num2, 0f);
			if (d.Id == Tecnica.LuzLarga)
			{
				DiarioEscritor.Trazo(val6 + new Vector2(20f * s, 0f), val7, val2, 3.4f * s);
				for (int j = 0; j < 9; j++)
				{
					float num4 = val6.x + 40f * s + (float)j * (num2 - 40f * s) / 9f;
					DiarioEscritor.Trazo(new Vector2(num4, val6.y - 6f * s), new Vector2(num4 + 10f * s, val6.y - 14f * s), val2, 1f * s);
					DiarioEscritor.Trazo(new Vector2(num4, val6.y + 6f * s), new Vector2(num4 + 10f * s, val6.y + 14f * s), val2, 1f * s);
				}
				return;
			}
			Color val9 = default(Color);
			for (int k = 0; k < 3; k++)
			{
				float num5 = (float)(k + 1) / 3f;
				Vector2 val8 = Vector2.Lerp(val6 + new Vector2(24f * s, 0f), val7, num5);
				((Color)(ref val9))..ctor(val2.r, val2.g, val2.b, alpha * (0.3f + 0.7f * num5));
				DiarioEscritor.Arco(val8 - new Vector2(num3 * 0.55f, 0f), new Vector2(num3 * 0.6f, num3), (0f - d.Arco) * 0.35f, d.Arco * 0.35f, val9, (1.2f + 2.4f * num5) * s, 18);
			}
			for (int l = -2; l <= 2; l++)
			{
				float num6 = val6.y + (float)l * num3 * 0.32f;
				float num7 = val6.x + 30f * s + (float)(Mathf.Abs(l) * 12) * s;
				DiarioEscritor.Trazo(new Vector2(num7, num6), new Vector2(Mathf.Lerp(num7, val7.x - num3, 0.8f), num6), new Color(val2.r, val2.g, val2.b, alpha * 0.35f), 1f * s);
			}
			if (d.Id == Tecnica.Supersonica)
			{
				DiarioEscritor.Arco(val6 + new Vector2(30f * s, 0f), new Vector2(6f * s, 18f * s), 0f, 360f, val2, 1.3f * s, 20);
			}
		}

		private static void Figura(Vector2 pies, Color c, float s)
		{
			//IL_0000: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0045: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d3: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = pies + new Vector2(0f, -14f * s);
			Vector2 val2 = val + new Vector2(2f * s, -22f * s);
			DiarioEscritor.Arco(val2 + new Vector2(1f * s, -7f * s), new Vector2(5f * s, 5f * s), 0f, 360f, c, 1.6f * s, 14);
			DiarioEscritor.Trazo(val2, val, c, 2f * s);
			DiarioEscritor.Trazo(val, pies + new Vector2(-9f * s, 14f * s), c, 1.8f * s);
			DiarioEscritor.Trazo(val, pies + new Vector2(10f * s, 14f * s), c, 1.8f * s);
			Vector2 val3 = val2 + new Vector2(16f * s, 6f * s);
			DiarioEscritor.Trazo(val2 + new Vector2(0f, 3f * s), val3, c, 1.8f * s);
			DiarioEscritor.Trazo(val3, val3 + new Vector2(22f * s, -10f * s), c, 2.4f * s);
		}
	}
	[HarmonyPatch]
	public static class DurabilidadPatch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return AccessTools.Method(typeof(Attack), "Start", (Type[])null, (Type[])null);
			yield return AccessTools.Method(typeof(Attack), "OnAttackTrigger", (Type[])null, (Type[])null);
		}

		private static void Prefix(Attack __instance, out float __state)
		{
			__state = -1f;
			ItemData val = Weapon(__instance);
			if (val != null && (Object)(object)Owner(__instance) == (Object)(object)Player.m_localPlayer)
			{
				__state = val.m_durability;
			}
		}

		private static void Postfix(Attack __instance, float __state)
		{
			if (!(__state < 0f))
			{
				ItemData val = Weapon(__instance);
				Player localPlayer = Player.m_localPlayer;
				if (val != null && !((Object)(object)localPlayer == (Object)null) && !(val.m_durability >= __state))
				{
					float num = __state - val.m_durability;
					val.m_durability = Mathf.Min(val.GetMaxDurability(), val.m_durability + num * Ahorro(localPlayer, val));
				}
			}
		}

		public static float Ahorro(Player p, ItemData w)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			float num = ((Character)p).GetSkillLevel(w.m_shared.m_skillType) / 100f;
			int num2 = Mathf.Max(Estilos.Rank(p, Estilo.Espada), Mathf.Max(Estilos.Rank(p, Estilo.Agua), Estilos.Rank(p, Estilo.Norte)));
			return Mathf.Clamp(num * 0.4f + (float)num2 / 6f * 0.35f, 0f, MTEspadaPlugin.DurabilidadMaxAhorro.Value);
		}

		private static ItemData Weapon(Attack a)
		{
			return Campos.AtaqueArma.Invoke(a);
		}

		private static Humanoid Owner(Attack a)
		{
			return Campos.AtaquePersonaje.Invoke(a);
		}
	}
	public static class EcoTajo
	{
		private const float Espera = 1.2f;

		private static float _listo;

		public static void Intentar(Player p)
		{
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: 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_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)p == (Object)null || !MTEspadaPlugin.EfectosTajo.Value || !Maestria.Armed(p) || Time.time < _listo)
			{
				return;
			}
			ItemData currentWeapon = ((Humanoid)p).GetCurrentWeapon();
			if (currentWeapon == null)
			{
				return;
			}
			int num = Estilos.Rank(p, Estilo.Espada);
			int num2 = Estilos.Rank(p, Estilo.Agua);
			int num3 = Estilos.Rank(p, Estilo.Norte);
			int num4 = Mathf.Max(num, Mathf.Max(num2, num3));
			if (num4 >= 1)
			{
				SEMan sEMan = ((Character)p).GetSEMan();
				bool flag = sEMan != null && sEMan.HaveStatusEffect(SE_PosturaLuz.Hash);
				bool flag2 = sEMan != null && sEMan.HaveStatusEffect(SE_PosturaLuna.Hash);
				bool flag3 = flag || flag2 || (sEMan != null && (sEMan.HaveStatusEffect(SE_PosturaViento.Hash) || sEMan.HaveStatusEffect(SE_PosturaNorte.Hash) || sEMan.HaveStatusEffect(SE_PosturaAgua.Hash) || sEMan.HaveStatusEffect(SE_PosturaSupersonica.Hash)));
				if (!(Random.value > 0.04f + 0.04f * (float)num4 + (flag3 ? 0.15f : 0f)))
				{
					_listo = Time.time + 1.2f;
					Color color = (flag ? Tecnicas.Oro : (flag2 ? Tecnicas.LunaAzul : ((num2 > num && num2 >= num3) ? Tecnicas.Agua : ((num3 > num && num3 > num2) ? Tecnicas.Norte : Tecnicas.Celeste))));
					DamageTypes damage = currentWeapon.GetDamage();
					((DamageTypes)(ref damage)).Modify((0.3f + 0.03f * (float)num4) * (0.6f + 0.4f * ((Character)p).GetSkillFactor(currentWeapon.m_shared.m_skillType)));
					Golpe golpe = new Golpe
					{
						Atacante = p,
						Dano = damage,
						Skill = currentWeapon.m_shared.m_skillType,
						Empuje = 4f,
						Tambaleo = 0.6f,
						Herramienta = currentWeapon.m_shared.m_toolTier
					};
					DefTecnica d = new DefTecnica
					{
						Id = Tecnica.TajoAire,
						Estilo = Estilo.Espada,
						Forma = Forma.Vuelo,
						Clave = "air_slash",
						Ancho = 1f + 0.08f * (float)num4,
						Velocidad = 26f,
						Arco = 115f,
						Color = color
					};
					Vector3 lookDir = ((Character)p).GetLookDir();
					Vector3 val = new Vector3(lookDir.x, Mathf.Clamp(lookDir.y, -0.3f, 0.3f), lookDir.z);
					Vector3 normalized = ((Vector3)(ref val)).normalized;
					Vector3 origen = ((Component)p).transform.position + Vector3.up * 1.1f + ((Component)p).transform.forward * 0.7f;
					TajoVolador.Lanzar(golpe, d, origen, normalized, 4.5f + 0.5f * (float)num4, Manto.Active);
				}
			}
		}
	}
	public static class EcoTecnica
	{
		private static readonly Dictionary<Tecnica, float> Listos = new Dictionary<Tecnica, float>();

		private static float _escudoListo;

		public static Tecnica UltimaTecnica;

		private static int PosturaDe(Tecnica t)
		{
			return t switch
			{
				Tecnica.TajoAire => SE_PosturaViento.Hash, 
				Tecnica.EstocadaViento => SE_PosturaEstocada.Hash, 
				Tecnica.CorteHechizo => SE_PosturaCorteHechizo.Hash, 
				Tecnica.RemolinoNorte => SE_PosturaNorte.Hash, 
				Tecnica.TormentaAcero => SE_PosturaTormenta.Hash, 
				Tecnica.CorteRio => SE_PosturaAgua.Hash, 
				Tecnica.DanzaCorriente => SE_PosturaCorriente.Hash, 
				Tecnica.Supersonica => SE_PosturaSupersonica.Hash, 
				Tecnica.LunaCreciente => SE_PosturaLuna.Hash, 
				Tecnica.LuzLarga => SE_PosturaLuz.Hash, 
				_ => 0, 
			};
		}

		public static bool EnPostura(Player p)
		{
			return PosturaActiva(p) != (Tecnica)0;
		}

		private static Tecnica PosturaActiva(Player p)
		{
			SEMan sEMan = ((Character)p).GetSEMan();
			if (sEMan == null)
			{
				return (Tecnica)0;
			}
			if (UltimaTecnica != 0 && sEMan.HaveStatusEffect(PosturaDe(UltimaTecnica)))
			{
				return UltimaTecnica;
			}
			if (sEMan.HaveStatusEffect(SE_PosturaLuz.Hash))
			{
				return Tecnica.LuzLarga;
			}
			if (sEMan.HaveStatusEffect(SE_PosturaLuna.Hash))
			{
				return Tecnica.LunaCreciente;
			}
			if (sEMan.HaveStatusEffect(SE_PosturaSupersonica.Hash))
			{
				return Tecnica.Supersonica;
			}
			if (sEMan.HaveStatusEffect(SE_PosturaViento.Hash))
			{
				return Tecnica.TajoAire;
			}
			if (sEMan.HaveStatusEffect(SE_PosturaAgua.Hash))
			{
				return Tecnica.CorteRio;
			}
			if (sEMan.HaveStatusEffect(SE_PosturaNorte.Hash))
			{
				return Tecnica.RemolinoNorte;
			}
			if (sEMan.HaveStatusEffect(SE_PosturaEstocada.Hash))
			{
				return Tecnica.EstocadaViento;
			}
			if (sEMan.HaveStatusEffect(SE_PosturaCorteHechizo.Hash))
			{
				return Tecnica.CorteHechizo;
			}
			if (sEMan.HaveStatusEffect(SE_PosturaCorriente.Hash))
			{
				return Tecnica.DanzaCorriente;
			}
			if (sEMan.HaveStatusEffect(SE_PosturaTormenta.Hash))
			{
				return Tecnica.TormentaAcero;
			}
			return (Tecnica)0;
		}

		public static float BonusVelocidad(Player p)
		{
			if ((Object)(object)p == (Object)null || !Maestria.Armed(p))
			{
				return 0f;
			}
			Tecnica tecnica = PosturaActiva(p);
			if (tecnica == (Tecnica)0)
			{
				return 0f;
			}
			DefTecnica defTecnica = Tecnicas.Def(tecnica);
			if (defTecnica == null)
			{
				return 0f;
			}
			float num = Mathf.Min(0.2f, 0.1f + 0.02f * (float)Estilos.Rank(p, defTecnica.Estilo));
			if (!Manto.Active)
			{
				return num;
			}
			return num * 1.5f;
		}

		private static bool Listo(Tecnica t)
		{
			if (Listos.TryGetValue(t, out var value))
			{
				return Time.time >= value;
			}
			return true;
		}

		public static bool Intentar(Player p)
		{
			//IL_0084: Unknown result type (migh

plugins/MT.Magia/MT.Magia.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using MT.Core;
using MT.Core.Commands;
using MT.Core.Diario;
using MT.Core.Especialidades;
using MT.Core.I18n;
using MT.Core.Mana;
using MT.Core.Rueda;
using MT.Core.Touki;
using MT.Core.Vfx;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Playables;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("MT.Magia")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ffb23be1655489b43ebd87164178fc39ecbb9f14")]
[assembly: AssemblyProduct("MT.Magia")]
[assembly: AssemblyTitle("MT.Magia")]
[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 MT.Magia
{
	public static class Afinidad
	{
		private const string Key = "MT.Magia.Afinidad";

		public static bool Get(Player p, out Escuela fav, out Escuela weak)
		{
			fav = (weak = Escuela.Fuego);
			if ((Object)(object)p == (Object)null || !p.m_customData.TryGetValue("MT.Magia.Afinidad", out var value))
			{
				return false;
			}
			string[] array = value.Split(new char[1] { ',' });
			if (array.Length == 2 && Enum.TryParse<Escuela>(array[0], out fav))
			{
				return Enum.TryParse<Escuela>(array[1], out weak);
			}
			return false;
		}

		public static void Roll(Player p)
		{
			if (!((Object)(object)p == (Object)null) && !p.m_customData.ContainsKey("MT.Magia.Afinidad"))
			{
				Escuela[] all = Escuelas.All;
				Escuela escuela = all[Random.Range(0, all.Length)];
				Escuela escuela2;
				do
				{
					escuela2 = all[Random.Range(0, all.Length)];
				}
				while (escuela2 == escuela);
				p.m_customData["MT.Magia.Afinidad"] = escuela.ToString() + "," + escuela2;
				((Character)p).Message((MessageType)2, Tr.Get("magia_magic_affinity_favorite_weak", new object[2]
				{
					Escuelas.Name(escuela),
					Escuelas.Name(escuela2)
				}), 0, (Sprite)null, false);
			}
		}

		public static float CostMult(Player p, Escuela e)
		{
			if (!Get(p, out var fav, out var weak))
			{
				return 1f;
			}
			if (e != fav)
			{
				if (e != weak)
				{
					return 1f;
				}
				return 1.1f;
			}
			return 0.9f;
		}

		public static bool IsFavorite(Player p, Escuela e)
		{
			if (Get(p, out var fav, out var _))
			{
				return fav == e;
			}
			return false;
		}

		public static string Describe(Player p)
		{
			if (!Get(p, out var fav, out var weak))
			{
				return Tr.Get("magia_not_rolled");
			}
			return Tr.Get("magia_favorite_weak", new object[2]
			{
				Escuelas.Name(fav),
				Escuelas.Name(weak)
			});
		}
	}
	public static class Agarre
	{
		private static ConfigFile _cfg;

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

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

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

		public static readonly Vector3 GiroPorDefecto = new Vector3(90f, 0f, 0f);

		public const float EscalaPorDefecto = 0.7f;

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

		public static void Init(ConfigFile cfg)
		{
			_cfg = cfg;
		}

		public static Vector3 Rotation(string prefab)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			return Entry(Rot, prefab, "Giro", GiroPorDefecto).Value;
		}

		public static Vector3 Offset(string prefab)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			return Entry(Pos, prefab, "Posicion", Vector3.zero).Value;
		}

		public static float Scale(string prefab)
		{
			if (!Size.TryGetValue(prefab, out var value))
			{
				value = _cfg.Bind<float>("Agarre", prefab + ".Escala", 0.7f, "Tamaño del modelo (1 = original). Ajústalo en el juego con «mt_grab scale 0.7».");
				Size[prefab] = value;
			}
			return Mathf.Clamp(value.Value, 0.2f, 3f);
		}

		public static void SetScale(string prefab, float value)
		{
			Scale(prefab);
			Size[prefab].Value = value;
			_cfg.Save();
			if (Prefabs.TryGetValue(prefab, out var value2))
			{
				Apply(value2.transform.Find("attach"), prefab);
			}
		}

		public static void Track(string prefab, GameObject go)
		{
			Prefabs[prefab] = go;
		}

		private static ConfigEntry<Vector3> Entry(Dictionary<string, ConfigEntry<Vector3>> map, string prefab, string kind, Vector3 def)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (map.TryGetValue(prefab, out var value))
			{
				return value;
			}
			return map[prefab] = _cfg.Bind<Vector3>("Agarre", prefab + "." + kind, def, (kind == "Giro") ? "Giro del modelo en la mano (grados X, Y, Z). Ajústalo en el juego con mt_grab." : "Desplazamiento del modelo en la mano (metros X, Y, Z). Ajústalo en el juego con mt_grab.");
		}

		public static void Set(string prefab, Vector3? rot, Vector3? pos)
		{
			//IL_0014: 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_003e: 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)
			if (rot.HasValue)
			{
				Entry(Rot, prefab, "Giro", Vector3.zero).Value = rot.Value;
			}
			if (pos.HasValue)
			{
				Entry(Pos, prefab, "Posicion", Vector3.zero).Value = pos.Value;
			}
			_cfg.Save();
			if (Prefabs.TryGetValue(prefab, out var value))
			{
				Apply(value.transform.Find("attach"));
			}
		}

		public static void Apply(Transform attach, string prefab = null)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)attach == (Object)null)
			{
				return;
			}
			Transform val = attach.Find("MT_Modelo");
			if (!((Object)(object)val == (Object)null))
			{
				if (prefab == null)
				{
					prefab = ((Object)attach.root).name.Replace("(Clone)", "").Trim();
				}
				val.localRotation = Quaternion.Euler(Rotation(prefab));
				val.localPosition = Offset(prefab);
				val.localScale = Vector3.one * Scale(prefab);
				Transform val2 = attach.root.Find("MT_ModeloSuelo");
				if ((Object)(object)val2 != (Object)null)
				{
					val2.localScale = Vector3.one * Scale(prefab);
				}
			}
		}

		public static void Setup(string prefab, GameObject go)
		{
			Track(prefab, go);
			Apply(go.transform.Find("attach"), prefab);
		}

		public static Transform HeldModel(Player p, out string prefab)
		{
			prefab = null;
			ItemData currentWeapon = ((Humanoid)p).GetCurrentWeapon();
			if ((Object)(object)currentWeapon?.m_dropPrefab == (Object)null)
			{
				return null;
			}
			prefab = ((Object)currentWeapon.m_dropPrefab).name;
			VisEquipment val = Campos.VisEquipo.Invoke((Humanoid)(object)p);
			GameObject val2 = (((Object)(object)val != (Object)null) ? Campos.InstanciaDerecha.Invoke(val) : null);
			if (!((Object)(object)val2 != (Object)null))
			{
				return null;
			}
			return Find(val2.transform, "MT_Modelo");
		}

		private static Transform Find(Transform t, string name)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if (((Object)t).name == name)
			{
				return t;
			}
			foreach (Transform item in t)
			{
				Transform val = Find(item, name);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}
	}
	public class AgarreCommand : ConsoleCommand
	{
		public override string Name => "mt_grab";

		public override string Help => "mt_grab [rotX rotY rotZ] [posX posY posZ] — adjust how you hold the wand or staff in your hand (saved per item). mt_grab scale 0.7: size. No numbers: show values. mt_grab reset: rotation and position to 0.";

		public override void Run(string[] args)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			string prefab;
			Transform val = Agarre.HeldModel(localPlayer, out prefab);
			if ((Object)(object)val == (Object)null)
			{
				Console.instance.Print("Equip a mod wand or staff (with its own model).");
				return;
			}
			if (args.Length == 0)
			{
				Console.instance.Print($"{prefab}: rotation {Fmt(Agarre.Rotation(prefab))} · position {Fmt(Agarre.Offset(prefab))} · scale {Agarre.Scale(prefab):0.##}\n{((ConsoleCommand)this).Help}");
				return;
			}
			if (args[0].ToLowerInvariant() == "scale")
			{
				if (args.Length < 2 || !float.TryParse(args[1].Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
				{
					Console.instance.Print($"{prefab}: scale {Agarre.Scale(prefab):0.##}. Usage: mt_grab scale 0.7");
					return;
				}
				Agarre.SetScale(prefab, result);
				val.localScale = Vector3.one * Agarre.Scale(prefab);
				Console.instance.Print($"{prefab}: scale {Agarre.Scale(prefab):0.##} (saved)");
				return;
			}
			Vector3? rot = null;
			Vector3? pos = null;
			if (args[0].ToLowerInvariant() == "reset")
			{
				rot = Vector3.zero;
				pos = Vector3.zero;
			}
			else
			{
				if (args.Length >= 3 && TryVec(args, 0, out var v))
				{
					rot = v;
				}
				if (args.Length >= 6 && TryVec(args, 3, out var v2))
				{
					pos = v2;
				}
				if (!rot.HasValue)
				{
					Console.instance.Print(((ConsoleCommand)this).Help);
					return;
				}
			}
			Agarre.Set(prefab, rot, pos);
			val.localRotation = Quaternion.Euler(Agarre.Rotation(prefab));
			val.localPosition = Agarre.Offset(prefab);
			Console.instance.Print(prefab + ": rotation " + Fmt(Agarre.Rotation(prefab)) + " · position " + Fmt(Agarre.Offset(prefab)) + " (saved)");
		}

		private static bool TryVec(string[] a, int i, out Vector3 v)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			v = Vector3.zero;
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			if (!float.TryParse(a[i].Replace(',', '.'), NumberStyles.Float, invariantCulture, out var result) || !float.TryParse(a[i + 1].Replace(',', '.'), NumberStyles.Float, invariantCulture, out var result2) || !float.TryParse(a[i + 2].Replace(',', '.'), NumberStyles.Float, invariantCulture, out var result3))
			{
				return false;
			}
			v = new Vector3(result, result2, result3);
			return true;
		}

		private static string Fmt(Vector3 v)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return string.Format(CultureInfo.InvariantCulture, "{0:0.##} {1:0.##} {2:0.##}", v.x, v.y, v.z);
		}
	}
	public static class AguaVfx
	{
		private static readonly Color Agua = new Color(0.45f, 0.7f, 1f);

		private static readonly Color AguaClara = new Color(0.8f, 0.92f, 1f);

		public static void Diluvio(Vector3 pos)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			FuegoVfx.Destello(pos + Vector3.up, 14f, 2.5f, 0.6f, Agua);
			Particulas.Spawn(pos, new Particulas.Config
			{
				ColorA = new Color(Agua.r, Agua.g, Agua.b, 0.9f),
				ColorB = new Color(AguaClara.r, AguaClara.g, AguaClara.b, 0.8f),
				LifeMin = 0.8f,
				LifeMax = 1.3f,
				SpeedMin = 12f,
				SpeedMax = 20f,
				SizeMin = 0.1f,
				SizeMax = 0.25f,
				Gravity = 0.4f,
				Radius = 0.6f,
				Hemisphere = true,
				Rate = 250f,
				Duration = 1f,
				FadeIn = 0.05f,
				Grow = 0.6f,
				Max = 3000
			});
			Chaparron(pos, 10f, 4f, 700f);
			Salpicadura(pos, 3f, 70);
		}

		public static void Ventisca(Vector3 pos)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			FuegoVfx.Destello(pos + Vector3.up, 12f, 2f, 0.6f, AguaClara);
			Particulas.Spawn(pos, new Particulas.Config
			{
				ColorA = new Color(1f, 1f, 1f, 0.9f),
				ColorB = new Color(0.75f, 0.88f, 1f, 0.7f),
				LifeMin = 1.2f,
				LifeMax = 2f,
				SpeedMin = 3f,
				SpeedMax = 8f,
				SizeMin = 0.06f,
				SizeMax = 0.16f,
				Gravity = -0.1f,
				Radius = 3f,
				Hemisphere = true,
				Rate = 300f,
				Duration = 2.5f,
				FadeIn = 0.1f,
				Max = 3000
			});
			Particulas.Spawn(pos, new Particulas.Config
			{
				ColorA = new Color(0.9f, 0.95f, 1f, 0.4f),
				ColorB = new Color(0.8f, 0.88f, 1f, 0.25f),
				LifeMin = 1.5f,
				LifeMax = 2.5f,
				SpeedMin = 1f,
				SpeedMax = 3f,
				SizeMin = 1.2f,
				SizeMax = 2.4f,
				Radius = 2f,
				Hemisphere = true,
				Burst = 25,
				Additive = false,
				FadeIn = 0.15f,
				Grow = 2.5f
			});
			Particulas.Spawn(pos + Vector3.up * 8f, new Particulas.Config
			{
				ColorA = Color.white,
				ColorB = new Color(0.8f, 0.9f, 1f, 0.8f),
				LifeMin = 2.5f,
				LifeMax = 3.5f,
				SpeedMin = 0f,
				SpeedMax = 0.5f,
				SizeMin = 0.06f,
				SizeMax = 0.14f,
				Gravity = 0.25f,
				Radius = 10f,
				Rate = 400f,
				Duration = 4f,
				FadeIn = 0.1f,
				Max = 3000
			});
		}

		public static void Lavar(Player p)
		{
			//IL_0006: 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_000c: 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)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Vector3 position = ((Component)p).transform.position;
			Particulas.Spawn(position + Vector3.up * 2.6f, new Particulas.Config
			{
				ColorA = new Color(Agua.r, Agua.g, Agua.b, 0.9f),
				ColorB = new Color(AguaClara.r, AguaClara.g, AguaClara.b, 0.8f),
				LifeMin = 0.45f,
				LifeMax = 0.7f,
				SpeedMin = 0.5f,
				SpeedMax = 1.5f,
				SizeMin = 0.08f,
				SizeMax = 0.2f,
				Gravity = 2f,
				Radius = 0.45f,
				Rate = 300f,
				Duration = 0.5f,
				FadeIn = 0.05f,
				Max = 1000
			});
			Salpicadura(position, 0.6f, 50);
		}

		private static void Chaparron(Vector3 pos, float radio, float segundos, float porSegundo)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			Particulas.Spawn(pos + Vector3.up * 10f, new Particulas.Config
			{
				ColorA = new Color(Agua.r, Agua.g, Agua.b, 0.75f),
				ColorB = new Color(AguaClara.r, AguaClara.g, AguaClara.b, 0.6f),
				LifeMin = 0.8f,
				LifeMax = 1.1f,
				SpeedMin = 0f,
				SpeedMax = 1f,
				SizeMin = 0.06f,
				SizeMax = 0.14f,
				Gravity = 2.2f,
				Radius = radio,
				Rate = porSegundo,
				Duration = segundos,
				FadeIn = 0.05f,
				Max = 4000
			});
		}

		private static void Salpicadura(Vector3 pos, float radio, int cantidad)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			Particulas.Spawn(pos + Vector3.up * 0.1f, new Particulas.Config
			{
				ColorA = new Color(AguaClara.r, AguaClara.g, AguaClara.b, 0.9f),
				ColorB = new Color(Agua.r, Agua.g, Agua.b, 0.7f),
				LifeMin = 0.4f,
				LifeMax = 0.8f,
				SpeedMin = 2f,
				SpeedMax = 4.5f,
				SizeMin = 0.06f,
				SizeMax = 0.16f,
				Gravity = 1.5f,
				Radius = radio,
				Hemisphere = true,
				Burst = cantidad,
				FadeIn = 0.02f,
				Max = 1000
			});
		}
	}
	public static class Aprendizaje
	{
		private const string DespiertaKey = "MT.Magia.Despierta";

		public static Spell Random(Player p, int minRank, int maxRank, Escuela? school = null)
		{
			HashSet<string> known = Pergaminos.Known(p);
			List<Spell> list = SpellBook.All.Where((Spell s) => !known.Contains(s.Id) && s.School != Escuela.Gravedad && s.Rank >= minRank && s.Rank <= maxRank && (!school.HasValue || s.School == school.Value)).ToList();
			if (list.Count != 0)
			{
				return list[Random.Range(0, list.Count)];
			}
			return null;
		}

		public static Spell Nuevo(Player p, Escuela? school, int minRank, int maxRank)
		{
			return Random(p, minRank, maxRank, school) ?? Random(p, 0, maxRank, school) ?? Random(p, 0, maxRank) ?? Random(p, 0, 6);
		}

		public static void Teach(Player p, Spell s, string como)
		{
			Pergaminos.Learn(p, s.Id);
			DiarioMagia.HechizoAprendido(p, s);
			string text = como + "\n«" + s.Name + "»";
			if (!Pergaminos.CanCast(p, s))
			{
				text = text + "\n" + Tr.Get("magia_learned_cannot_cast_yet");
			}
			((Character)p).Message((MessageType)2, text, 0, (Sprite)null, false);
		}

		public static bool MagiaDespierta(Player p)
		{
			if ((Object)(object)p != (Object)null)
			{
				if (!p.m_customData.ContainsKey("MT.Magia.Despierta"))
				{
					return Pergaminos.Known(p).Count > 0;
				}
				return true;
			}
			return false;
		}

		public static void Despertar(Player p)
		{
			if (!((Object)(object)p == (Object)null) && !p.m_customData.ContainsKey("MT.Magia.Despierta"))
			{
				p.m_customData["MT.Magia.Despierta"] = "1";
				Laminas.Desbloquear(p, "pagina_mana");
				if (Pergaminos.Known(p).Count <= 0)
				{
					((Character)p).Message((MessageType)2, Tr.Get("magia_mana_awakened_no_spell"), 0, (Sprite)null, false);
					Cronica.AnotarUnaVez(p, "magia_despierta", "cronica_magic_awakened", Array.Empty<string>());
				}
			}
		}

		public static void AlFabricarVarita(Player p)
		{
			Despertar(p);
		}

		public static void AlSubirRango(Player p, Escuela e, int rank)
		{
			if (MTMagiaPlugin.AprenderRango.Value)
			{
				Spell spell = Nuevo(p, e, 0, rank);
				if (spell != null)
				{
					Teach(p, spell, Tr.Get("magia_practice_pays_off_discover_new"));
				}
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
	public static class VaritaCraftPatch
	{
		private static int _antes;

		private static void Prefix(InventoryGui __instance, out bool __state)
		{
			Traverse obj = Traverse.Create((object)__instance);
			Recipe value = obj.Field("m_craftRecipe").GetValue<Recipe>();
			ItemData value2 = obj.Field("m_craftUpgradeItem").GetValue<ItemData>();
			__state = value2 == null && (Object)(object)value != (Object)null && (Object)(object)value.m_item != (Object)null && ((Object)value.m_item).name == "MT_VaritaAprendiz";
			if (__state)
			{
				_antes = Contar(Player.m_localPlayer);
			}
		}

		private static int Contar(Player p)
		{
			if (!((Object)(object)p == (Object)null))
			{
				return ((Humanoid)p).GetInventory().GetAllItems().Count((ItemData i) => (Object)(object)i.m_dropPrefab != (Object)null && ((Object)i.m_dropPrefab).name == "MT_VaritaAprendiz");
			}
			return 0;
		}

		private static void Postfix(bool __state)
		{
			Player localPlayer = Player.m_localPlayer;
			if (__state && (Object)(object)localPlayer != (Object)null && Contar(localPlayer) > _antes)
			{
				Aprendizaje.AlFabricarVarita(localPlayer);
			}
		}
	}
	public class Arco : MonoBehaviour
	{
		private LineRenderer _core;

		private LineRenderer _glow;

		private Light _light;

		private Vector3 _from;

		private Vector3 _to;

		private float _width;

		private float _grow;

		private float _born;

		public static Arco Spawn(Vector3 from, Vector3 to, Color color, float width = 0.3f, float duration = 0.3f, float grow = 0f)
		{
			//IL_000c: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//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_003d: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			if (MTMagiaPlugin.EfectosPropios.Value)
			{
				Vector3 val = to - from;
				if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f))
				{
					GameObject val2 = new GameObject("MT_ArcoElectrico");
					Arco arco = val2.AddComponent<Arco>();
					arco._from = from;
					arco._to = to;
					arco._width = width;
					arco._grow = grow;
					arco._born = Time.time;
					arco._glow = Line(val2.transform, "Halo", color, width);
					arco._core = Line(val2.transform, "Nucleo", Color.Lerp(color, Color.white, 0.8f), width * 0.3f);
					arco._light = LucesMagicas.Registrar(new GameObject("Luz").AddComponent<Light>());
					((Component)arco._light).transform.SetParent(val2.transform, false);
					((Component)arco._light).transform.position = to;
					arco._light.color = color;
					arco._light.range = 6f;
					arco._light.intensity = 2.5f;
					arco.Shape();
					Object.Destroy((Object)(object)val2, duration);
					return arco;
				}
			}
			return null;
		}

		public void Retarget(Vector3 from, Vector3 to)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			_from = from;
			_to = to;
			if ((Object)(object)_light != (Object)null)
			{
				((Component)_light).transform.position = to;
			}
		}

		private static LineRenderer Line(Transform parent, string name, Color color, float width)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_003d: 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)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			LineRenderer obj = val.AddComponent<LineRenderer>();
			obj.useWorldSpace = true;
			((Renderer)obj).material = Vfx.NewMaterial(Vfx.Tex("heal_streak"), color);
			Color startColor = (obj.endColor = color);
			obj.startColor = startColor;
			obj.startWidth = width;
			obj.endWidth = width * 0.6f;
			obj.textureMode = (LineTextureMode)0;
			obj.numCapVertices = 2;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj).receiveShadows = false;
			return obj;
		}

		private void Update()
		{
			Shape();
		}

		private void Shape()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((_grow > 0f) ? Vector3.Lerp(_from, _to, Mathf.Clamp01((Time.time - _born) / _grow)) : _to);
			if ((Object)(object)_light != (Object)null)
			{
				((Component)_light).transform.position = val;
			}
			float num = Vector3.Distance(_from, val);
			int num2 = Mathf.Clamp(Mathf.CeilToInt(num / 0.5f), 4, 60);
			Vector3 val2 = val - _from;
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			Vector3 val3 = Vector3.Cross(normalized, Vector3.up);
			if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
			{
				val3 = Vector3.Cross(normalized, Vector3.right);
			}
			((Vector3)(ref val3)).Normalize();
			Vector3 val4 = Vector3.Cross(val3, normalized);
			float num3 = Mathf.Clamp(num * 0.03f, 0.08f, 0.5f);
			Vector3[] array = (Vector3[])(object)new Vector3[num2 + 1];
			for (int i = 0; i <= num2; i++)
			{
				float num4 = (float)i / (float)num2;
				float num5 = Mathf.Sin(num4 * (float)Math.PI);
				Vector3 val5 = (val3 * Random.Range(-1f, 1f) + val4 * Random.Range(-1f, 1f)) * num3 * num5;
				array[i] = Vector3.Lerp(_from, val, num4) + val5;
			}
			LineRenderer[] array2 = (LineRenderer[])(object)new LineRenderer[2] { _glow, _core };
			foreach (LineRenderer obj in array2)
			{
				obj.positionCount = array.Length;
				obj.SetPositions(array);
			}
			float num6 = Random.Range(0.7f, 1.2f);
			_glow.widthMultiplier = num6;
			if ((Object)(object)_light != (Object)null)
			{
				_light.intensity = 2.5f * num6;
			}
		}
	}
	public static class ArmaduraMk1
	{
		public class Modelo
		{
			public Mesh Mesh;

			public Material[] Mats;
		}

		public const string Prefab = "MT_ArmaduraMk1";

		public const string Escudo = "MT_EscudoMk1";

		public const string Canon = "MT_CanonMk1";

		public const string Casco = "MT_CascoMk1";

		public const string Grebas = "MT_GrebasMk1";

		public const string Coraza = "MT_CorazaMk1";

		public static readonly KeyValuePair<string, HumanBodyBones>[] Piezas = new KeyValuePair<string, HumanBodyBones>[15]
		{
			P("cabeza", (HumanBodyBones)10),
			P("pecho", (HumanBodyBones)8),
			P("cadera", (HumanBodyBones)0),
			P("brazo_der", (HumanBodyBones)14),
			P("brazo_izq", (HumanBodyBones)13),
			P("antebrazo_der", (HumanBodyBones)16),
			P("antebrazo_izq", (HumanBodyBones)15),
			P("mano_der", (HumanBodyBones)18),
			P("mano_izq", (HumanBodyBones)17),
			P("muslo_der", (HumanBodyBones)2),
			P("muslo_izq", (HumanBodyBones)1),
			P("pierna_der", (HumanBodyBones)4),
			P("pierna_izq", (HumanBodyBones)3),
			P("pie_der", (HumanBodyBones)6),
			P("pie_izq", (HumanBodyBones)5)
		};

		public static readonly KeyValuePair<string, HumanBodyBones>[] PiezaEscudo = new KeyValuePair<string, HumanBodyBones>[1] { P("escudo", (HumanBodyBones)15) };

		public static readonly KeyValuePair<string, HumanBodyBones>[] PiezaCanon = new KeyValuePair<string, HumanBodyBones>[1] { P("canon", (HumanBodyBones)16) };

		public static bool Powered;

		private static Dictionary<string, Modelo> _cache;

		private static KeyValuePair<string, HumanBodyBones> P(string pieza, HumanBodyBones hueso)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return new KeyValuePair<string, HumanBodyBones>(pieza, hueso);
		}

		public static void Register()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			PrefabManager.OnVanillaPrefabsAvailable -= Register;
			RegistrarPieza("MT_CascoMk1", Tr.Token("magia_casco_mk1"), Tr.Token("magia_casco_mk1_d"), "casco_mk1", 8f, (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("BlackMetal", 10, 0, true),
				new RequirementConfig("Iron", 10, 0, true),
				new RequirementConfig("Crystal", 3, 0, true)
			});
			RegistrarPieza("MT_CorazaMk1", Tr.Token("magia_coraza_mk1"), Tr.Token("magia_coraza_mk1_d"), "coraza_mk1", 30f, (RequirementConfig[])(object)new RequirementConfig[4]
			{
				new RequirementConfig("BlackMetal", 30, 0, true),
				new RequirementConfig("Iron", 30, 0, true),
				new RequirementConfig("Crystal", 10, 0, true),
				new RequirementConfig("SurtlingCore", 10, 0, true)
			});
			RegistrarPieza("MT_GrebasMk1", Tr.Token("magia_grebas_mk1"), Tr.Token("magia_grebas_mk1_d"), "grebas_mk1", 18f, (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("BlackMetal", 20, 0, true),
				new RequirementConfig("Iron", 20, 0, true),
				new RequirementConfig("SurtlingCore", 4, 0, true)
			});
			RegistrarArmadura();
			RegistrarEscudo();
			RegistrarCanon();
		}

		private static void RegistrarArmadura()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)PrefabManager.Instance.GetPrefab("ArmorBronzeChest") == (Object)null))
			{
				ItemConfig val = new ItemConfig();
				val.Name = Tr.Token("magia_armadura_mk1");
				val.Description = Tr.Token("magia_armadura_mk1_d");
				val.Icon = MTMagiaPlugin.Icon("armadura_mk1");
				val.CraftingStation = CraftingStations.Forge;
				val.MinStationLevel = 3;
				val.Requirements = (RequirementConfig[])(object)new RequirementConfig[5]
				{
					new RequirementConfig("MT_CascoMk1", 1, 1, true),
					new RequirementConfig("MT_CorazaMk1", 1, 1, true),
					new RequirementConfig("MT_GrebasMk1", 1, 1, true),
					new RequirementConfig("BlackMetal", 0, 10, true),
					new RequirementConfig("Crystal", 0, 5, true)
				};
				CustomItem val2 = new CustomItem("MT_ArmaduraMk1", "ArmorBronzeChest", val);
				SharedData shared = val2.ItemDrop.m_itemData.m_shared;
				shared.m_armor = MTMagiaPlugin.Mk1Armadura.Value + 28f;
				shared.m_damageModifiers = new List<DamageModPair>(shared.m_damageModifiers ?? new List<DamageModPair>())
				{
					new DamageModPair
					{
						m_type = (DamageType)64,
						m_modifier = (DamageModifier)5
					}
				};
				shared.m_armorPerLevel = 4f;
				shared.m_weight = 60f;
				shared.m_movementModifier = 0f;
				shared.m_maxQuality = 3;
				shared.m_useDurability = true;
				shared.m_canBeReparied = true;
				shared.m_maxDurability = MTMagiaPlugin.Mk1Durabilidad.Value;
				shared.m_durabilityPerLevel = MTMagiaPlugin.Mk1Durabilidad.Value * 0.25f;
				HideVisual(val2.ItemPrefab);
				EnElSuelo(val2.ItemPrefab, new string[3] { "casco", "torso", "piernas" }, 2.3f);
				ItemManager.Instance.AddItem(val2);
			}
		}

		private static void RegistrarPieza(string prefab, string name, string desc, string icon, float weight, RequirementConfig[] req)
		{
			//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_002a: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)PrefabManager.Instance.GetPrefab("BlackMetal") == (Object)null))
			{
				CustomItem val = new CustomItem(prefab, "BlackMetal", new ItemConfig
				{
					Name = name,
					Description = desc,
					Icon = MTMagiaPlugin.Icon(icon),
					CraftingStation = CraftingStations.Forge,
					MinStationLevel = 3,
					Requirements = req
				});
				SharedData shared = val.ItemDrop.m_itemData.m_shared;
				shared.m_itemType = (ItemType)1;
				shared.m_maxStackSize = 1;
				shared.m_weight = weight;
				shared.m_maxQuality = 1;
				shared.m_teleportable = true;
				string text = ((prefab == "MT_CascoMk1") ? "casco" : ((prefab == "MT_CorazaMk1") ? "torso" : "piernas"));
				HideVisual(val.ItemPrefab);
				EnElSuelo(val.ItemPrefab, new string[1] { text }, 1.6f);
				ItemManager.Instance.AddItem(val);
			}
		}

		public static bool WornPart(Player p, string field, string prefab)
		{
			if ((Object)(object)p != (Object)null)
			{
				return Is(Slot(p, field), prefab);
			}
			return false;
		}

		public static int Piezas_(Player p)
		{
			if (!Worn(p))
			{
				return 0;
			}
			return 3;
		}

		private static void RegistrarEscudo()
		{
			//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_009e: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			string text = (((Object)(object)PrefabManager.Instance.GetPrefab("ShieldIronTower") != (Object)null) ? "ShieldIronTower" : "ShieldBanded");
			if (!((Object)(object)PrefabManager.Instance.GetPrefab(text) == (Object)null))
			{
				ItemConfig val = new ItemConfig();
				val.Name = Tr.Token("magia_escudo_mk1");
				val.Description = Tr.Token("magia_escudo_mk1_d");
				val.Icon = MTMagiaPlugin.Icon("escudo_mk1");
				val.CraftingStation = CraftingStations.Forge;
				val.MinStationLevel = 3;
				val.Requirements = (RequirementConfig[])(object)new RequirementConfig[4]
				{
					new RequirementConfig("BlackMetal", 15, 5, true),
					new RequirementConfig("Iron", 15, 5, true),
					new RequirementConfig("Crystal", 0, 3, true),
					new RequirementConfig("SurtlingCore", 0, 1, true)
				};
				CustomItem val2 = new CustomItem("MT_EscudoMk1", text, val);
				SharedData shared = val2.ItemDrop.m_itemData.m_shared;
				shared.m_blockPower = MTMagiaPlugin.Mk1BloqueoEscudo.Value;
				shared.m_blockPowerPerLevel = 6f;
				shared.m_deflectionForce = 60f;
				shared.m_weight = 18f;
				shared.m_movementModifier = -0.05f;
				shared.m_maxDurability *= 1.5f;
				shared.m_durabilityPerLevel *= 1.5f;
				shared.m_maxQuality = 3;
				ShieldInHand(val2.ItemPrefab);
				ItemManager.Instance.AddItem(val2);
			}
		}

		private static void EnElSuelo(GameObject prefab, string[] piezas, float escala)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0023: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("MT_Mk1_suelo");
			val.transform.SetParent(prefab.transform, false);
			val.transform.localScale = Vector3.one * escala;
			Material val2 = Mk1Material.Body();
			Bounds? val3 = null;
			foreach (string text in piezas)
			{
				Mesh val4 = Mk1Skin.StaticMesh(text);
				if (!((Object)(object)val4 == (Object)null))
				{
					GameObject val5 = new GameObject(text);
					val5.transform.SetParent(val.transform, false);
					val5.AddComponent<MeshFilter>().sharedMesh = val4;
					MeshRenderer val6 = val5.AddComponent<MeshRenderer>();
					if ((Object)(object)val2 != (Object)null)
					{
						((Renderer)val6).sharedMaterial = val2;
					}
					if (!val3.HasValue)
					{
						val3 = val4.bounds;
						continue;
					}
					Bounds value = val3.Value;
					((Bounds)(ref value)).Encapsulate(val4.bounds);
					val3 = value;
				}
			}
			if (val3.HasValue)
			{
				Bounds value2 = val3.Value;
				val.transform.localPosition = -new Vector3(((Bounds)(ref value2)).center.x, ((Bounds)(ref value2)).min.y, ((Bounds)(ref value2)).center.z) * escala;
			}
		}

		private static void CanonEnSuelo(GameObject prefab)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			Modelo modelo = Piece("canon");
			if (!((Object)(object)modelo.Mesh == (Object)null))
			{
				GameObject val = new GameObject("MT_Mk1_canon_suelo");
				val.transform.SetParent(prefab.transform, false);
				val.transform.localRotation = Quaternion.Euler(90f, 0f, 0f);
				val.AddComponent<MeshFilter>().sharedMesh = modelo.Mesh;
				((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterials = modelo.Mats;
			}
		}

		private static void ShieldInHand(GameObject prefab)
		{
			bool num = ColocarEscudo(prefab, soloVisibles: true);
			HideVisual(prefab);
			if (!num)
			{
				MTMagiaPlugin.Log.LogWarning((object)"Mk-I: no se pudo poner el escudo en la mano");
			}
		}

		public static bool ColocarEscudo(GameObject root, bool soloVisibles, float extra = 1f)
		{
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: 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_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: 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_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: 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_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			MeshFilter val = null;
			Transform val2 = root.transform.Find("attach");
			MeshFilter[] componentsInChildren = (((Object)(object)val2 != (Object)null) ? ((Component)val2).gameObject : root).GetComponentsInChildren<MeshFilter>(true);
			Bounds bounds;
			foreach (MeshFilter val3 in componentsInChildren)
			{
				MeshRenderer component = ((Component)val3).GetComponent<MeshRenderer>();
				if ((Object)(object)val3.sharedMesh == (Object)null || (Object)(object)component == (Object)null || (soloVisibles && !((Renderer)component).enabled) || ((Object)val3).name.StartsWith("MT_Mk1"))
				{
					continue;
				}
				if (!((Object)(object)val == (Object)null))
				{
					bounds = val3.sharedMesh.bounds;
					Vector3 size = ((Bounds)(ref bounds)).size;
					float sqrMagnitude = ((Vector3)(ref size)).sqrMagnitude;
					bounds = val.sharedMesh.bounds;
					size = ((Bounds)(ref bounds)).size;
					if (!(sqrMagnitude > ((Vector3)(ref size)).sqrMagnitude))
					{
						continue;
					}
				}
				val = val3;
			}
			Modelo modelo = Piece("escudo");
			if ((Object)(object)val == (Object)null || (Object)(object)modelo.Mesh == (Object)null)
			{
				return false;
			}
			Ejes(val.sharedMesh, out var c, out var ax, out var len);
			Ejes(modelo.Mesh, out var c2, out var ax2, out var len2);
			if (Vector3.Dot(Vector3.Cross(ax2[0], ax2[1]), ax2[2]) < 0f)
			{
				ax2[2] = -ax2[2];
			}
			if (Vector3.Dot(Vector3.Cross(ax[0], ax[1]), ax[2]) < 0f)
			{
				ax[2] = -ax[2];
			}
			if (MTMagiaPlugin.Mk1EscudoManoVoltear.Value)
			{
				ax2[1] = -ax2[1];
				ax2[2] = -ax2[2];
			}
			Quaternion val4 = Quaternion.LookRotation(ax2[2], ax2[0]);
			Quaternion val5 = Quaternion.LookRotation(ax[2], ax[0]) * Quaternion.Inverse(val4) * Quaternion.Euler(MTMagiaPlugin.Mk1EscudoManoGiro.Value);
			float num = len[0] / Mathf.Max(0.01f, len2[0]) * MTMagiaPlugin.Mk1EscudoManoEscala.Value * extra;
			if (float.IsNaN(num) || float.IsInfinity(num) || num <= 0f || float.IsNaN(val5.x))
			{
				MTMagiaPlugin.Log.LogWarning((object)$"Mk-I: ajuste del escudo inválido (escala {num}); se usa tamaño 1");
				num = MTMagiaPlugin.Mk1EscudoManoEscala.Value;
				val5 = Quaternion.Euler(MTMagiaPlugin.Mk1EscudoManoGiro.Value);
				bounds = val.sharedMesh.bounds;
				c = ((Bounds)(ref bounds)).center;
				bounds = modelo.Mesh.bounds;
				c2 = ((Bounds)(ref bounds)).center;
			}
			GameObject val6 = new GameObject("MT_Mk1_escudo_mano");
			val6.transform.SetParent(((Component)val).transform, false);
			val6.transform.localRotation = val5;
			val6.transform.localScale = Vector3.one * num;
			Vector3 val7 = ((Vector3.Dot(c, ax[2]) < 0f) ? (-ax[2]) : ax[2]);
			float num2 = MTMagiaPlugin.Mk1EscudoManoSeparacion.Value / Mathf.Max(0.01f, ((Component)val).transform.lossyScale.x);
			val6.transform.localPosition = c - val5 * (c2 * num) + val7 * num2;
			val6.layer = ((Component)val).gameObject.layer;
			val6.AddComponent<MeshFilter>().sharedMesh = modelo.Mesh;
			((Renderer)val6.AddComponent<MeshRenderer>()).sharedMaterials = modelo.Mats;
			return true;
		}

		private static void Ejes(Mesh mesh, out Vector3 c, out Vector3[] ax, out float[] len)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(mesh.isReadable ? ((Array)mesh.vertices) : ((Array)new Vector3[0]));
			if (array.Length >= 3)
			{
				Ejes(array, out c, out ax, out len);
				if (!float.IsNaN(len[0]) && len[0] > 0f)
				{
					return;
				}
			}
			Bounds bounds = mesh.bounds;
			c = ((Bounds)(ref bounds)).center;
			Vector3[] array2 = (Vector3[])(object)new Vector3[3]
			{
				Vector3.right,
				Vector3.up,
				Vector3.forward
			};
			float[] sizes = new float[3]
			{
				((Bounds)(ref bounds)).size.x,
				((Bounds)(ref bounds)).size.y,
				((Bounds)(ref bounds)).size.z
			};
			int[] array3 = new int[3] { 0, 1, 2 };
			Array.Sort(array3, (int i, int j) => sizes[j].CompareTo(sizes[i]));
			ax = (Vector3[])(object)new Vector3[3]
			{
				array2[array3[0]],
				array2[array3[1]],
				array2[array3[2]]
			};
			len = new float[3]
			{
				sizes[array3[0]],
				sizes[array3[1]],
				sizes[array3[2]]
			};
		}

		public static bool ReaplicarEscudo(Player p)
		{
			if ((Object)(object)p == (Object)null || !Is(Slot(p, "m_leftItem"), "MT_EscudoMk1"))
			{
				return false;
			}
			VisEquipment component = ((Component)p).GetComponent<VisEquipment>();
			GameObject val = (((Object)(object)component != (Object)null) ? Campos.InstanciaIzquierda.Invoke(component) : null);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			MeshRenderer[] componentsInChildren = val.GetComponentsInChildren<MeshRenderer>(true);
			foreach (MeshRenderer val2 in componentsInChildren)
			{
				if (((Object)val2).name == "MT_Mk1_escudo_mano")
				{
					Object.Destroy((Object)(object)((Component)val2).gameObject);
				}
			}
			return ColocarEscudo(val, soloVisibles: false, ConArmadura(p));
		}

		private static void Ejes(Vector3[] v, out Vector3 c, out Vector3[] ax, out float[] len)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: 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_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: 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_0293: Unknown result type (might be due to invalid IL or missing references)
			c = Vector3.zero;
			Vector3[] array = v;
			foreach (Vector3 val in array)
			{
				c += val;
			}
			c /= (float)Mathf.Max(1, v.Length);
			float xx = 0f;
			float xy = 0f;
			float xz = 0f;
			float yy = 0f;
			float yz = 0f;
			float zz = 0f;
			array = v;
			for (int i = 0; i < array.Length; i++)
			{
				Vector3 val2 = array[i] - c;
				xx += val2.x * val2.x;
				xy += val2.x * val2.y;
				xz += val2.x * val2.z;
				yy += val2.y * val2.y;
				yz += val2.y * val2.z;
				zz += val2.z * val2.z;
			}
			Func<Vector3, Vector3> func = (Vector3 a) => new Vector3(xx * a.x + xy * a.y + xz * a.z, xy * a.x + yy * a.y + yz * a.z, xz * a.x + yz * a.y + zz * a.z);
			Vector3 normalized = default(Vector3);
			((Vector3)(ref normalized))..ctor(0.3f, 0.9f, 0.2f);
			Vector3 val3;
			for (int num = 0; num < 60; num++)
			{
				val3 = func(normalized);
				normalized = ((Vector3)(ref val3)).normalized;
			}
			val3 = Vector3.Cross(normalized, (Mathf.Abs(normalized.x) < 0.9f) ? Vector3.right : Vector3.up);
			Vector3 normalized2 = ((Vector3)(ref val3)).normalized;
			for (int num2 = 0; num2 < 60; num2++)
			{
				normalized2 = func(normalized2);
				val3 = normalized2 - Vector3.Dot(normalized2, normalized) * normalized;
				normalized2 = ((Vector3)(ref val3)).normalized;
			}
			val3 = Vector3.Cross(normalized, normalized2);
			Vector3 normalized3 = ((Vector3)(ref val3)).normalized;
			ax = (Vector3[])(object)new Vector3[3] { normalized, normalized2, normalized3 };
			len = new float[3];
			for (int num3 = 0; num3 < 3; num3++)
			{
				float num4 = float.MaxValue;
				float num5 = float.MinValue;
				array = v;
				for (int i = 0; i < array.Length; i++)
				{
					float num6 = Vector3.Dot(array[i] - c, ax[num3]);
					num4 = Mathf.Min(num4, num6);
					num5 = Mathf.Max(num5, num6);
				}
				len[num3] = num5 - num4;
			}
		}

		private static int[] Axes(Vector3 s)
		{
			//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)
			int[] obj = new int[3] { 0, 1, 2 };
			Array.Sort(obj, (int x, int y) => ((Vector3)(ref s))[y].CompareTo(((Vector3)(ref s))[x]));
			return obj;
		}

		private static Vector3 Axis(int i)
		{
			//IL_0013: 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_0007: Unknown result type (might be due to invalid IL or missing references)
			return (Vector3)(i switch
			{
				1 => Vector3.up, 
				0 => Vector3.right, 
				_ => Vector3.forward, 
			});
		}

		private static void RegistrarCanon()
		{
			//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_009e: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			string text = (((Object)(object)PrefabManager.Instance.GetPrefab("StaffIceShards") != (Object)null) ? "StaffIceShards" : "StaffFireball");
			if (!((Object)(object)PrefabManager.Instance.GetPrefab(text) == (Object)null))
			{
				ItemConfig val = new ItemConfig();
				val.Name = Tr.Token("magia_canon_mk1");
				val.Description = Tr.Token("magia_canon_mk1_d");
				val.Icon = MTMagiaPlugin.Icon("canon_mk1");
				val.CraftingStation = CraftingStations.Forge;
				val.MinStationLevel = 3;
				val.Requirements = (RequirementConfig[])(object)new RequirementConfig[4]
				{
					new RequirementConfig("BlackMetal", 20, 5, true),
					new RequirementConfig("Iron", 10, 5, true),
					new RequirementConfig("SurtlingCore", 5, 2, true),
					new RequirementConfig("Crystal", 0, 3, true)
				};
				CustomItem val2 = new CustomItem("MT_CanonMk1", text, val);
				SharedData shared = val2.ItemDrop.m_itemData.m_shared;
				shared.m_itemType = (ItemType)3;
				shared.m_skillType = (SkillType)9;
				shared.m_damages = new DamageTypes
				{
					m_blunt = MTMagiaPlugin.Mk1DanoBala.Value
				};
				shared.m_damagesPerLevel = new DamageTypes
				{
					m_blunt = 5f
				};
				shared.m_attack.m_attackEitr = 0f;
				shared.m_attackStatusEffect = null;
				shared.m_secondaryAttack.m_attackEitr = 0f;
				shared.m_weight = 12f;
				shared.m_maxQuality = 3;
				shared.m_useDurability = true;
				shared.m_canBeReparied = true;
				shared.m_maxDurability = MTMagiaPlugin.Mk1CanonDurabilidad.Value;
				shared.m_durabilityPerLevel = MTMagiaPlugin.Mk1CanonDurabilidad.Value * 0.25f;
				HideVisual(val2.ItemPrefab);
				CanonEnSuelo(val2.ItemPrefab);
				ItemManager.Instance.AddItem(val2);
			}
		}

		private static void HideVisual(GameObject prefab)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
			Light[] componentsInChildren2 = prefab.GetComponentsInChildren<Light>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				((Behaviour)componentsInChildren2[i]).enabled = false;
			}
			ParticleSystem[] componentsInChildren3 = prefab.GetComponentsInChildren<ParticleSystem>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				EmissionModule emission = componentsInChildren3[i].emission;
				((EmissionModule)(ref emission)).enabled = false;
			}
		}

		public static bool Is(ItemData it, string prefab)
		{
			if (it != null && (Object)(object)it.m_dropPrefab != (Object)null)
			{
				return ((Object)it.m_dropPrefab).name == prefab;
			}
			return false;
		}

		public static ItemData Slot(Player p, string field)
		{
			if ((Object)(object)p == (Object)null)
			{
				return null;
			}
			return (ItemData)(field switch
			{
				"m_chestItem" => Campos.Pecho.Invoke((Humanoid)(object)p), 
				"m_rightItem" => Campos.ManoDerecha.Invoke((Humanoid)(object)p), 
				"m_leftItem" => Campos.ManoIzquierda.Invoke((Humanoid)(object)p), 
				_ => Traverse.Create((object)p).Field(field).GetValue<ItemData>(), 
			});
		}

		public static bool Worn(Player p)
		{
			if ((Object)(object)p != (Object)null)
			{
				return Is(Slot(p, "m_chestItem"), "MT_ArmaduraMk1");
			}
			return false;
		}

		public static float ConArmadura(Player p)
		{
			if (!Worn(p))
			{
				return 1f;
			}
			return MTMagiaPlugin.Mk1ConArmaduraEscala.Value;
		}

		public static bool HoldsCanon(Player p)
		{
			if ((Object)(object)p != (Object)null)
			{
				return Is(Slot(p, "m_rightItem"), "MT_CanonMk1");
			}
			return false;
		}

		public static void Recargar()
		{
			_cache = null;
			Mk1Skin.ClearCache();
			Mk1Material.ClearCache();
			ArmaduraMk1Ctrl.Rebuild = true;
		}

		public static Modelo Piece(string name)
		{
			if (_cache == null)
			{
				_cache = new Dictionary<string, Modelo>();
			}
			if (_cache.TryGetValue(name, out var value))
			{
				return value;
			}
			string text = Path.Combine(MTMagiaPlugin.ModelDir, "mk1_" + name + ".obj");
			List<string> materialNames;
			Mesh val = ObjModel.Load(text, out materialNames);
			if ((Object)(object)val == (Object)null)
			{
				MTMagiaPlugin.Log.LogWarning((object)("Mk-I: falta la pieza " + text));
				return _cache[name] = new Modelo();
			}
			val.RecalculateTangents();
			Material val2 = Mk1Material.Armas();
			if ((Object)(object)val2 == (Object)null)
			{
				return _cache[name] = new Modelo();
			}
			Material[] array = (Material[])(object)new Material[val.subMeshCount];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = (materialNames[i].Contains("UnderArmor") ? Mk1Material.Joint() : val2);
			}
			return _cache[name] = new Modelo
			{
				Mesh = val,
				Mats = array
			};
		}
	}
	public class ArmaduraMk1Ctrl : MonoBehaviour
	{
		private class Conjunto
		{
			public readonly List<GameObject> Pieces = new List<GameObject>();

			public float Since;

			public bool Built => Pieces.Count > 0;
		}

		public static bool Rebuild;

		private readonly Conjunto _armadura = new Conjunto();

		private readonly Conjunto _escudo = new Conjunto();

		private readonly Conjunto _canon = new Conjunto();

		private readonly Conjunto _casco = new Conjunto();

		private readonly Conjunto _grebas = new Conjunto();

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

		private readonly List<SkinnedMeshRenderer> _piezasCuerpo = new List<SkinnedMeshRenderer>();

		private Player _for;

		private float _hideCheck;

		private Animator _animator;

		private AnimatorCullingMode _originalCulling;

		private float _nextBuildWarning;

		public static Transform CanonPiece;

		private bool _apuntando;

		private float _nextShot;

		private float _nadoPuesto = -1f;

		private bool _camara;

		public static float CamaraAplicada = 1f;

		public static bool CamaraReaplicar;

		public static bool CanonReaplicar;

		private Vector3 _off3;

		private Vector3 _offCombate;

		private float _minD;

		private float _maxD;

		private static readonly HumanBodyBones[][] BrazoApuntar = new HumanBodyBones[2][]
		{
			(HumanBodyBones[])(object)new HumanBodyBones[2]
			{
				(HumanBodyBones)14,
				(HumanBodyBones)16
			},
			(HumanBodyBones[])(object)new HumanBodyBones[2]
			{
				(HumanBodyBones)16,
				(HumanBodyBones)18
			}
		};

		internal static bool Saltando;

		private float _stepDist;

		private float _airTime;

		private float _peakY;

		private Vector3 _lastPos;

		private static GameObject _sfxPaso;

		private static bool _sfxBuscado;

		private GameObject _escudoRevisado;

		private bool _escudoConArmadura;

		private bool _canonConArmadura;

		private Transform _grown;

		private Vector3 _grownScale;

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

		private float _partsCheck;

		private void OnDisable()
		{
			Clear(_armadura, restore: true);
			Clear(_escudo, restore: false);
			Clear(_canon, restore: false);
			Clear(_casco, restore: false);
			Clear(_grebas, restore: false);
			RestoreAnimator();
			CanonPiece = null;
			ArmaduraMk1.Powered = false;
		}

		private void RestoreAnimator()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_animator != (Object)null)
			{
				_animator.cullingMode = _originalCulling;
			}
			_animator = null;
		}

		private void Canon(Player p)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			_apuntando = false;
			if ((Object)(object)p == (Object)null || ((Character)p).IsDead() || !ArmaduraMk1.HoldsCanon(p) || ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) || Console.IsVisible() || Menu.IsVisible() || InventoryGui.IsVisible() || Minimap.IsOpen() || !ZInput.GetButton("Attack"))
			{
				return;
			}
			_apuntando = true;
			p.FaceLookDirection();
			if (Time.time < _nextShot)
			{
				return;
			}
			_nextShot = Time.time + MTMagiaPlugin.Mk1Cadencia.Value;
			if (Mk1Canon.Calor(p))
			{
				Vector3 val = Fx.AimPoint(p, 60f);
				MeshRenderer val2 = (((Object)(object)CanonPiece != (Object)null) ? ((Component)CanonPiece).GetComponent<MeshRenderer>() : null);
				Vector3 val3;
				Bounds bounds;
				if (!((Object)(object)val2 != (Object)null))
				{
					val3 = Fx.HandOrigin(p);
				}
				else
				{
					bounds = ((Renderer)val2).bounds;
					val3 = ((Bounds)(ref bounds)).center;
				}
				Vector3 val4 = val3;
				Vector3 val5 = val - val4;
				val5 = ((((Vector3)(ref val5)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val5)).normalized : ((Component)p).transform.forward);
				Vector3 val6 = val5;
				float num;
				if (!((Object)(object)val2 != (Object)null))
				{
					num = 0f;
				}
				else
				{
					bounds = ((Renderer)val2).bounds;
					Vector3 extents = ((Bounds)(ref bounds)).extents;
					num = ((Vector3)(ref extents)).magnitude * 0.7f;
				}
				Vector3 muzzle = val4 + val6 * (num + 0.3f);
				Mk1Canon.Disparar(p, muzzle, val5);
			}
		}

		private void Camara(bool puesta)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			GameCamera instance = GameCamera.instance;
			if (!((Object)(object)instance == (Object)null) && puesta != _camara)
			{
				Traverse val = Traverse.Create((object)instance);
				if (puesta && !_camara)
				{
					_off3 = val.Field("m_3rdOffset").GetValue<Vector3>();
					_offCombate = val.Field("m_3rdCombatOffset").GetValue<Vector3>();
					_minD = val.Field("m_minDistance").GetValue<float>();
					_maxD = val.Field("m_maxDistance").GetValue<float>();
					float num = (CamaraAplicada = MTMagiaPlugin.Mk1Camara.Value);
					val.Field("m_3rdOffset").SetValue((object)new Vector3(_off3.x * num, _off3.y * num, _off3.z));
					val.Field("m_3rdCombatOffset").SetValue((object)new Vector3(_offCombate.x * num, _offCombate.y * num, _offCombate.z));
					val.Field("m_minDistance").SetValue((object)(_minD * num));
					val.Field("m_maxDistance").SetValue((object)(_maxD * num));
					float value = val.Field("m_distance").GetValue<float>();
					val.Field("m_distance").SetValue((object)Mathf.Max(value * num, _minD * num));
					_camara = true;
				}
				else if (!puesta && _camara)
				{
					val.Field("m_3rdOffset").SetValue((object)_off3);
					val.Field("m_3rdCombatOffset").SetValue((object)_offCombate);
					val.Field("m_minDistance").SetValue((object)_minD);
					val.Field("m_maxDistance").SetValue((object)_maxD);
					float value2 = val.Field("m_distance").GetValue<float>();
					val.Field("m_distance").SetValue((object)Mathf.Clamp(value2 / CamaraAplicada, _minD, _maxD));
					_camara = false;
				}
			}
		}

		private void LateUpdate()
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (CamaraReaplicar)
			{
				CamaraReaplicar = false;
				Camara(puesta: false);
			}
			Camara((Object)(object)localPlayer != (Object)null && !((Character)localPlayer).IsDead() && _armadura.Built);
			if ((Object)(object)localPlayer != (Object)null && ArmaduraMk1.Powered && ((Character)localPlayer).m_swimSpeed != _nadoPuesto)
			{
				((Character)localPlayer).m_swimSpeed = ((Character)localPlayer).m_swimSpeed * MTMagiaPlugin.Mk1Nado.Value;
				_nadoPuesto = ((Character)localPlayer).m_swimSpeed;
			}
			if (!_apuntando)
			{
				return;
			}
			Player localPlayer2 = Player.m_localPlayer;
			Animator val = (((Object)(object)localPlayer2 != (Object)null) ? ((Component)localPlayer2).GetComponentInChildren<Animator>() : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Vector3 val2 = Fx.AimPoint(localPlayer2, 60f);
			HumanBodyBones[][] brazoApuntar = BrazoApuntar;
			foreach (HumanBodyBones[] array in brazoApuntar)
			{
				Transform boneTransform = val.GetBoneTransform(array[0]);
				Transform boneTransform2 = val.GetBoneTransform(array[1]);
				if (!((Object)(object)boneTransform == (Object)null) && !((Object)(object)boneTransform2 == (Object)null))
				{
					Vector3 val3 = boneTransform2.position - boneTransform.position;
					Vector3 val4 = val2 - boneTransform.position;
					if (!(((Vector3)(ref val3)).sqrMagnitude < 1E-06f) && !(((Vector3)(ref val4)).sqrMagnitude < 1E-06f))
					{
						boneTransform.rotation = Quaternion.FromToRotation(val3, val4) * boneTransform.rotation;
					}
				}
			}
		}

		private void Update()
		{
			Player localPlayer = Player.m_localPlayer;
			if (Rebuild)
			{
				Rebuild = false;
				_for = null;
			}
			if ((Object)(object)localPlayer != (Object)(object)_for)
			{
				Clear(_armadura, restore: true);
				Clear(_escudo, restore: false);
				Clear(_canon, restore: false);
				Clear(_casco, restore: false);
				Clear(_grebas, restore: false);
				RestoreAnimator();
				_for = localPlayer;
			}
			bool flag = (Object)(object)localPlayer != (Object)null && !((Character)localPlayer).IsDead();
			bool flag2 = flag && ArmaduraMk1.Worn(localPlayer);
			if (flag2 && Escuelas.Rank(localPlayer, Escuela.Tierra) < 3)
			{
				((Humanoid)localPlayer).UnequipItem(ArmaduraMk1.Slot(localPlayer, "m_chestItem"), true);
				((Character)localPlayer).Message((MessageType)2, Tr.Get("magia_need_earth_saint_rank_move"), 0, (Sprite)null, false);
				flag2 = false;
			}
			if (flag2 && !Mk1Diaria.PuedeEncender(localPlayer))
			{
				((Humanoid)localPlayer).UnequipItem(ArmaduraMk1.Slot(localPlayer, "m_chestItem"), true);
				((Character)localPlayer).Message((MessageType)2, Tr.Get("magia_mk1_cooldown"), 0, (Sprite)null, false);
				flag2 = false;
			}
			if ((Object)(object)localPlayer != (Object)null && !flag2)
			{
				Mk1Diaria.Terminar(localPlayer);
			}
			Keep(localPlayer, _armadura, flag2, ArmaduraMk1.Piezas);
			if (ArmaduraMk1.Worn(localPlayer) != _canonConArmadura)
			{
				_canonConArmadura = ArmaduraMk1.Worn(localPlayer);
				CanonReaplicar = true;
			}
			if (CanonReaplicar)
			{
				CanonReaplicar = false;
				Clear(_canon, restore: false);
			}
			Keep(localPlayer, _canon, flag && ArmaduraMk1.HoldsCanon(localPlayer), ArmaduraMk1.PiezaCanon);
			Keep(localPlayer, _casco, flag2, null);
			Keep(localPlayer, _grebas, flag2, null);
			HideForParts(localPlayer);
			EscudoVisible(localPlayer);
			CanonPiece = (_canon.Built ? _canon.Pieces[0].transform : null);
			Canon(localPlayer);
			if (!_armadura.Built && !_escudo.Built && !_canon.Built && !_casco.Built && !_grebas.Built)
			{
				RestoreAnimator();
			}
			if (flag)
			{
				Pisadas(localPlayer, flag2);
			}
			if (!flag2 || !_armadura.Built)
			{
				ArmaduraMk1.Powered = false;
				return;
			}
			float num = MTMagiaPlugin.Mk1ManaSegundo.Value * Time.deltaTime;
			bool powered = ArmaduraMk1.Powered;
			ArmaduraMk1.Powered = localPlayer.GetEitr() > num + 0.5f;
			ItemData val = ArmaduraMk1.Slot(localPlayer, "m_chestItem");
			if (ArmaduraMk1.Powered && val != null)
			{
				val.m_durability = Mathf.Max(0f, val.m_durability - MTMagiaPlugin.Mk1DesgasteSegundo.Value * Time.deltaTime);
				if (val.m_durability <= 0f)
				{
					ArmaduraMk1.Powered = false;
					Clear(_armadura, restore: true);
					Clear(_casco, restore: false);
					Clear(_grebas, restore: false);
					HideForParts(localPlayer);
					RestoreAnimator();
					((Humanoid)localPlayer).UnequipItem(val, true);
					((Character)localPlayer).Message((MessageType)2, Tr.Get("magia_mk_i_broken_repair_forge"), 0, (Sprite)null, false);
					Cronica.AnotarUnaVez(localPlayer, "mk1_rota", "cronica_mk1_broken", Array.Empty<string>());
					return;
				}
			}
			if (ArmaduraMk1.Powered)
			{
				if (!powered)
				{
					Cronica.AnotarUnaVez(localPlayer, "mk1_encendida", "cronica_mk1_powered", Array.Empty<string>());
				}
				((Character)localPlayer).UseEitr(num);
				if (((Character)localPlayer).GetHealth() < ((Character)localPlayer).GetMaxHealth())
				{
					((Character)localPlayer).Heal(MTMagiaPlugin.Mk1RegenVida.Value * Time.deltaTime, false);
				}
				_hideCheck -= Time.deltaTime;
				if (!(_hideCheck <= 0f) || (!_grebas.Built && Mk1Skin.PartAvailable("piernas")))
				{
					return;
				}
				_hideCheck = 0.5f;
				((Component)localPlayer).GetComponentsInChildren<SkinnedMeshRenderer>(_piezasCuerpo);
				{
					foreach (SkinnedMeshRenderer item in _piezasCuerpo)
					{
						if (((Renderer)item).enabled && !((Object)item).name.StartsWith("MT_Mk1_"))
						{
							((Renderer)item).enabled = false;
							_hidden.Add((Renderer)(object)item);
						}
					}
					return;
				}
			}
			ArmaduraMk1.Powered = false;
			Clear(_armadura, restore: true);
			Clear(_casco, restore: false);
			Clear(_grebas, restore: false);
			HideForParts(localPlayer);
			RestoreAnimator();
			((Humanoid)localPlayer).UnequipItem(ArmaduraMk1.Slot(localPlayer, "m_chestItem"), true);
			((Character)localPlayer).Message((MessageType)2, Tr.Get("magia_mk_i_runs_out_mana"), 0, (Sprite)null, false);
		}

		private void Pisadas(Player p, bool worn)
		{
			//IL_0006: 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_0074: 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_0057: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)p).transform.position;
			if (!((Character)p).IsOnGround())
			{
				if (_airTime <= 0f)
				{
					_peakY = position.y;
				}
				_peakY = Mathf.Max(_peakY, position.y);
				_airTime += Time.deltaTime;
				_lastPos = position;
				return;
			}
			if (_airTime > 0f)
			{
				float num = _peakY - position.y;
				float value = MTMagiaPlugin.Mk1CaidaMinima.Value;
				if (num >= value)
				{
					float num2 = Mathf.Clamp01((num - value) / (value * 2f));
					if (MTMagiaPlugin.Mk1TemblorCaida.Value > 0f)
					{
						GameCamera instance = GameCamera.instance;
						if (instance != null)
						{
							instance.AddShake(position, 12f, MTMagiaPlugin.Mk1TemblorCaida.Value * (1f + num2 * 2f), false);
						}
					}
					Tierra(position, 0.25f + num2 * 0.35f);
					if (worn)
					{
						SonidoPesado(position, fuerte: true);
					}
					if (worn && ArmaduraMk1.Powered && Saltando)
					{
						Aterrizaje(p, position, 0.5f + num2 * 2.5f);
					}
				}
				else if (worn && num > 0.3f)
				{
					if (MTMagiaPlugin.Mk1TemblorPaso.Value > 0f)
					{
						GameCamera instance2 = GameCamera.instance;
						if (instance2 != null)
						{
							instance2.AddShake(position, 12f, MTMagiaPlugin.Mk1TemblorPaso.Value * 0.8f, false);
						}
					}
					SonidoPesado(position, fuerte: false);
				}
			}
			_airTime = 0f;
			Saltando = false;
			if (!worn || !MTMagiaPlugin.Mk1Temblor.Value)
			{
				_lastPos = position;
				return;
			}
			Vector3 val = position - _lastPos;
			val.y = 0f;
			_lastPos = position;
			if (!(((Vector3)(ref val)).magnitude > 2f))
			{
				_stepDist += ((Vector3)(ref val)).magnitude;
				float num3 = (((Character)p).IsRunning() ? 2.1f : 1.4f);
				if (_stepDist >= num3)
				{
					_stepDist = 0f;
					Paso(p, position, ((Character)p).IsRunning() ? 1f : 0.6f);
				}
			}
		}

		private static void Aterrizaje(Player p, Vector3 pos, float aire)
		{
			//IL_0021: 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_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_006c: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Clamp(aire, 0.5f, 3f);
			float radius = 1.8f + num * 0.8f;
			DamageTypes damage = new DamageTypes
			{
				m_blunt = MTMagiaPlugin.Mk1DanoCaida.Value * num
			};
			foreach (Character item in Fx.EnemiesInRadius(p, pos, radius))
			{
				if ((Object)(object)item != (Object)null && !item.IsDead())
				{
					Fx.Damage(p, item, damage, (SkillType)9, 25f * num, 2f);
				}
			}
		}

		private static void Tierra(Vector3 pos, float fuerza)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			Particulas.Spawn(pos + Vector3.up * 0.1f, new Particulas.Config
			{
				ColorA = new Color(0.55f, 0.47f, 0.36f, 0.7f),
				ColorB = new Color(0.45f, 0.4f, 0.32f, 0.5f),
				LifeMin = 0.6f,
				LifeMax = 1.2f,
				SpeedMin = 0.5f,
				SpeedMax = 2f * fuerza,
				SizeMin = 0.3f,
				SizeMax = 0.8f * fuerza,
				Radius = 0.5f,
				Hemisphere = true,
				Additive = false,
				Burst = (int)(18f * fuerza),
				Grow = 1.8f
			});
		}

		private static void SonidoPesado(Vector3 pos, bool fuerte)
		{
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			List<string> nombres;
			if (!_sfxBuscado && (Object)(object)ZNetScene.instance != (Object)null)
			{
				_sfxBuscado = true;
				nombres = new List<string>();
				foreach (GameObject prefab in ZNetScene.instance.m_prefabs)
				{
					if ((Object)(object)prefab != (Object)null && ((Object)prefab).name.StartsWith("sfx_"))
					{
						nombres.Add(((Object)prefab).name);
					}
				}
				string text = Buscar(new string[6][]
				{
					new string[1] { "footstep" },
					new string[2] { "foot", "grass" },
					new string[2] { "foot", "dirt" },
					new string[2] { "troll", "foot" },
					new string[2] { "troll", "step" },
					new string[2] { "golem", "step" }
				});
				_sfxPaso = ((text != null) ? ZNetScene.instance.GetPrefab(text) : null);
				MTMagiaPlugin.Log.LogInfo((object)("Mk-I: sonido de pisada reutilizado «" + (text ?? "ninguno") + "»"));
			}
			if (fuerte && (Object)(object)_sfxPaso != (Object)null)
			{
				Object.Instantiate<GameObject>(_sfxPaso, pos, Quaternion.identity);
			}
			string Buscar(params string[][] reglas)
			{
				foreach (string[] array in reglas)
				{
					foreach (string item in nombres)
					{
						string text2 = item.ToLowerInva

plugins/MT.Ojos/MT.Ojos.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using MT.Core;
using MT.Core.Diario;
using MT.Core.I18n;
using MT.Core.Vfx;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("MT.Ojos")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ffb23be1655489b43ebd87164178fc39ecbb9f14")]
[assembly: AssemblyProduct("MT.Ojos")]
[assembly: AssemblyTitle("MT.Ojos")]
[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 MT.Ojos
{
	public class BrilloOjo : MonoBehaviour
	{
		private static BrilloOjo _inst;

		private Player _jugador;

		private Transform _cabeza;

		private readonly ParticleSystem[] _llamas = (ParticleSystem[])(object)new ParticleSystem[2];

		private readonly string[] _tipos = new string[2];

		private readonly Color[] _colores = (Color[])(object)new Color[2];

		private float _tamano;

		public static Color ColorDe(string ojo)
		{
			//IL_0021: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			if (!(ojo == "MT_OjoPrevision"))
			{
				if (ojo == "MT_OjoVistaLejana")
				{
					return MTOjosPlugin.ColorVistaLejana.Value;
				}
				return MTOjosPlugin.ColorIdentificacion.Value;
			}
			return MTOjosPlugin.ColorPrevision.Value;
		}

		public static void Recalibrar()
		{
			if ((Object)(object)_inst != (Object)null)
			{
				_inst.Limpiar();
			}
		}

		private void Awake()
		{
			_inst = this;
		}

		private void LateUpdate()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)(object)_jugador)
			{
				Limpiar();
				_jugador = localPlayer;
			}
			if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || !MTOjosPlugin.BrilloOjos.Value || !Cabeza(localPlayer))
			{
				Mostrar(0, null);
				Mostrar(1, null);
				return;
			}
			if ((Object)(object)_llamas[0] != (Object)null && !Mathf.Approximately(_tamano, MTOjosPlugin.DiametroOjo.Value))
			{
				Limpiar();
				if (!Cabeza(localPlayer))
				{
					return;
				}
			}
			List<string> puestos = Ojos.Puestos;
			Mostrar(0, (puestos.Count > 0) ? puestos[0] : null);
			Mostrar(1, (puestos.Count > 1) ? puestos[1] : null);
		}

		private void Mostrar(int i, string tipo)
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystem val = _llamas[i];
			if (tipo == null)
			{
				if ((Object)(object)val != (Object)null)
				{
					EmissionModule emission = val.emission;
					((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
				}
				_tipos[i] = null;
				return;
			}
			if ((Object)(object)val == (Object)null)
			{
				float num = MTOjosPlugin.DiametroOjo.Value / 0.04f;
				val = (_llamas[i] = ToukiManos.Flame(_cabeza, 0.07f, 0.06f * num, 0.14f * num));
				((Object)((Component)val).gameObject).name = "MT_OjoTouki_" + i;
				_tamano = MTOjosPlugin.DiametroOjo.Value;
				_tipos[i] = null;
			}
			Color val2 = ColorDe(tipo);
			if (_tipos[i] != tipo || _colores[i] != val2)
			{
				Teñir(val, val2);
				_tipos[i] = tipo;
				_colores[i] = val2;
			}
			EmissionModule emission2 = val.emission;
			((EmissionModule)(ref emission2)).rateOverTime = MinMaxCurve.op_Implicit(22f);
		}

		private static void Teñir(ParticleSystem ps, Color col)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			MainModule main = ps.main;
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(col.r, col.g, col.b, 0.9f), Color.Lerp(col, Color.white, 0.4f) * new Color(1f, 1f, 1f, 0.8f));
			ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime;
			Gradient val = new Gradient();
			val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Color.Lerp(col, Color.white, 0.4f), 0f),
				new GradientColorKey(col * 0.6f, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(0f, 0f),
				new GradientAlphaKey(0.9f, 0.15f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val);
		}

		private bool Cabeza(Player p)
		{
			if (Object.op_Implicit((Object)(object)_cabeza))
			{
				return true;
			}
			SkinnedMeshRenderer val = ((Component)p).GetComponent<VisEquipment>()?.m_bodyModel;
			if ((Object)(object)val == (Object)null || val.bones == null)
			{
				return false;
			}
			Transform[] bones = val.bones;
			foreach (Transform val2 in bones)
			{
				if ((Object)(object)val2 != (Object)null && (((Object)val2).name == "Head" || ((Object)val2).name.EndsWith(":Head") || ((Object)val2).name.EndsWith("_Head")))
				{
					_cabeza = val2;
					return true;
				}
			}
			return false;
		}

		public static string Diagnostico()
		{
			//IL_0052: 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)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)_inst == (Object)null || (Object)(object)localPlayer == (Object)null || (Object)(object)_inst._cabeza == (Object)null)
			{
				return "no head bone yet (equip an eye)";
			}
			return $"on head bone '{((Object)_inst._cabeza).name}' at {_inst._cabeza.position.y - ((Component)localPlayer).transform.position.y:0.00} m above the feet";
		}

		private void Limpiar()
		{
			_cabeza = null;
			for (int i = 0; i < 2; i++)
			{
				if ((Object)(object)_llamas[i] != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)_llamas[i]).gameObject);
				}
				_llamas[i] = null;
				_tipos[i] = null;
			}
		}

		private void OnDisable()
		{
			Limpiar();
		}

		private void OnDestroy()
		{
			Limpiar();
		}
	}
	public static class Circulo
	{
		private static GameObject _ext;

		private static GameObject _int;

		private static Material _mExt;

		private static Material _mInt;

		public static void Actualizar(Component objetivo, float alfa)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)objetivo == (Object)null || alfa <= 0f)
			{
				if (Object.op_Implicit((Object)(object)_ext))
				{
					_ext.SetActive(false);
				}
			}
			else if (Object.op_Implicit((Object)(object)_ext) || Crear())
			{
				Collider component = objetivo.GetComponent<Collider>();
				float num;
				Bounds bounds;
				if (!((Object)(object)component != (Object)null))
				{
					num = 0.5f;
				}
				else
				{
					bounds = component.bounds;
					float x = ((Bounds)(ref bounds)).extents.x;
					bounds = component.bounds;
					num = Mathf.Max(x, ((Bounds)(ref bounds)).extents.z);
				}
				float num2 = Mathf.Clamp(num * 2.6f, 1f, 8f) * (0.85f + 0.15f * alfa);
				Vector3 position = objetivo.transform.position;
				if ((Object)(object)component != (Object)null)
				{
					bounds = component.bounds;
					position.y = ((Bounds)(ref bounds)).min.y;
				}
				_ext.transform.position = position + Vector3.up * 0.06f;
				_ext.transform.localScale = Vector3.one * num2;
				_ext.transform.rotation = Quaternion.Euler(90f, Time.time * 25f, 0f);
				_int.transform.localRotation = Quaternion.Euler(0f, 0f, (0f - Time.time) * 70f);
				float num3 = 0.75f + 0.25f * Mathf.Sin(Time.time * 3f);
				Pintar(_mExt, new Color(0.65f, 0.35f, 1f, 0.8f * alfa * num3));
				Pintar(_mInt, new Color(0.85f, 0.6f, 1f, 0.7f * alfa));
				if (!_ext.activeSelf)
				{
					_ext.SetActive(true);
				}
			}
		}

		private static void Pintar(Material m, Color c)
		{
			//IL_0001: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			m.color = c;
			if (m.HasProperty("_TintColor"))
			{
				m.SetColor("_TintColor", c * 0.5f);
			}
		}

		private static bool Crear()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("Legacy Shaders/Particles/Additive") ?? Shader.Find("Sprites/Default");
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			_ext = Quad("MT_CirculoIdent", val, Textura(exterior: true), out _mExt);
			Object.DontDestroyOnLoad((Object)(object)_ext);
			_int = Quad("Interior", val, Textura(exterior: false), out _mInt);
			_int.transform.SetParent(_ext.transform, false);
			_int.transform.localScale = Vector3.one * 0.62f;
			_int.transform.localPosition = new Vector3(0f, 0f, -0.001f);
			return true;
		}

		private static GameObject Quad(string nombre, Shader shader, Texture2D tex, out Material mat)
		{
			//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_002d: Expected O, but got Unknown
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5);
			Object.Destroy((Object)(object)obj.GetComponent<Collider>());
			((Object)obj).name = nombre;
			Renderer component = obj.GetComponent<Renderer>();
			mat = new Material(shader)
			{
				mainTexture = (Texture)(object)tex
			};
			component.sharedMaterial = mat;
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
			return obj;
		}

		private static Texture2D Textura(bool exterior)
		{
			//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_0019: Expected O, but got Unknown
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(256, 256, (TextureFormat)4, true)
			{
				wrapMode = (TextureWrapMode)1
			};
			Color[] array = (Color[])(object)new Color[65536];
			for (int i = 0; i < 256; i++)
			{
				for (int j = 0; j < 256; j++)
				{
					float num = ((float)j + 0.5f) / 256f * 2f - 1f;
					float num2 = ((float)i + 0.5f) / 256f * 2f - 1f;
					float num3 = Mathf.Sqrt(num * num + num2 * num2);
					float num4 = Mathf.Atan2(num2, num);
					float num5;
					if (exterior)
					{
						num5 = Mathf.Max(Anillo(num3, 0.96f, 0.015f), Anillo(num3, 0.84f, 0.01f));
						float num6 = Mathf.Abs(Mathf.Repeat(num4 / ((float)Math.PI * 2f) * 12f, 1f) - 0.5f);
						if (num3 > 0.86f && num3 < 0.94f && num6 < 0.06f)
						{
							num5 = 1f;
						}
						if (num3 > 0.87f && num3 < 0.93f && num6 > 0.2f && num6 < 0.24f)
						{
							num5 = Mathf.Max(num5, 0.6f);
						}
					}
					else
					{
						num5 = Anillo(num3, 0.95f, 0.02f);
						for (int k = 0; k < 2; k++)
						{
							for (int l = 0; l < 3; l++)
							{
								float num7 = (float)k * (float)Math.PI / 3f + (float)l * (float)Math.PI * 2f / 3f + (float)Math.PI / 2f;
								float num8 = num7 + (float)Math.PI * 2f / 3f;
								Vector2 a = new Vector2(Mathf.Cos(num7), Mathf.Sin(num7)) * 0.95f;
								Vector2 b = new Vector2(Mathf.Cos(num8), Mathf.Sin(num8)) * 0.95f;
								num5 = Mathf.Max(num5, Segmento(new Vector2(num, num2), a, b, 0.015f));
							}
						}
					}
					array[i * 256 + j] = new Color(1f, 1f, 1f, num5);
				}
			}
			val.SetPixels(array);
			val.Apply(true);
			return val;
		}

		private static float Anillo(float r, float centro, float grosor)
		{
			return Mathf.Clamp01(1f - Mathf.Abs(r - centro) / grosor);
		}

		private static float Segmento(Vector2 p, Vector2 a, Vector2 b, float grosor)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = b - a;
			float num = Mathf.Clamp01(Vector2.Dot(p - a, val) / ((Vector2)(ref val)).sqrMagnitude);
			return Mathf.Clamp01(1f - Vector2.Distance(p, a + val * num) / grosor);
		}
	}
	public static class Desgaste
	{
		private static readonly Dictionary<string, string> NombreDe = new Dictionary<string, string>();

		private static float _avisoHasta;

		private static List<ItemData> _equipados;

		private static int _fotograma = -1;

		private static Player _de;

		public static void Init()
		{
			ItemManager.OnItemsRegistered += Configurar;
		}

		private static void Configurar()
		{
			string[] array = new string[3] { "MT_OjoIdentificacion", "MT_OjoVistaLejana", "MT_OjoPrevision" };
			foreach (string text in array)
			{
				ObjectDB instance = ObjectDB.instance;
				object obj;
				if (instance == null)
				{
					obj = null;
				}
				else
				{
					GameObject itemPrefab = instance.GetItemPrefab(text);
					obj = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
				}
				ItemDrop val = (ItemDrop)obj;
				if (!((Object)(object)val == (Object)null))
				{
					SharedData shared = val.m_itemData.m_shared;
					shared.m_useDurability = true;
					shared.m_maxDurability = MTOjosPlugin.DurabilidadMax.Value;
					shared.m_canBeReparied = true;
					shared.m_destroyBroken = false;
					shared.m_durabilityDrain = 0f;
					shared.m_durabilityPerLevel = MTOjosPlugin.DurabilidadMax.Value * 0.5f;
					val.m_itemData.m_durability = shared.m_maxDurability;
					NombreDe[text] = shared.m_name;
				}
			}
		}

		public static ItemData Item(string ojo)
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || !NombreDe.TryGetValue(ojo, out var value))
			{
				return null;
			}
			if (_fotograma != Time.frameCount || (Object)(object)_de != (Object)(object)localPlayer)
			{
				_equipados = ((Humanoid)localPlayer).GetInventory().GetEquippedItems();
				_fotograma = Time.frameCount;
				_de = localPlayer;
			}
			foreach (ItemData equipado in _equipados)
			{
				if (equipado.m_shared.m_name == value)
				{
					return equipado;
				}
			}
			return null;
		}

		public static bool Funciona(string ojo)
		{
			if (!Ojos.Equipado(ojo))
			{
				return false;
			}
			ItemData val = Item(ojo);
			if (val == null)
			{
				return false;
			}
			if (!val.m_shared.m_useDurability || val.m_durability > 0f)
			{
				return true;
			}
			Avisar(ojo);
			return false;
		}

		public static void Gastar(string ojo, float cantidad)
		{
			ItemData val = Item(ojo);
			if (val != null && val.m_shared.m_useDurability && !(cantidad <= 0f))
			{
				bool num = val.m_durability > 0f;
				val.m_durability = Mathf.Max(0f, val.m_durability - cantidad);
				if (num && val.m_durability <= 0f)
				{
					Avisar(ojo);
				}
			}
		}

		private static void Avisar(string ojo)
		{
			if (!(Time.time < _avisoHasta))
			{
				_avisoHasta = Time.time + 10f;
				ObjectDB instance = ObjectDB.instance;
				object obj;
				if (instance == null)
				{
					obj = null;
				}
				else
				{
					GameObject itemPrefab = instance.GetItemPrefab(ojo);
					obj = ((itemPrefab == null) ? null : itemPrefab.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_name);
				}
				if (obj == null)
				{
					obj = ojo;
				}
				string text = Tr.Localize((string)obj);
				Player localPlayer = Player.m_localPlayer;
				if (localPlayer != null)
				{
					((Character)localPlayer).Message((MessageType)2, Tr.Get("ojos_worn_out_repair_its_station", new object[1] { text }), 0, (Sprite)null, false);
				}
			}
		}
	}
	public class DesgasteEquipado : MonoBehaviour
	{
		private void Update()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || !MTOjosPlugin.PuedeUsarTeclas())
			{
				return;
			}
			float num = MTOjosPlugin.DesgasteEquipadoPorSegundo.Value * Time.deltaTime;
			if (num <= 0f)
			{
				return;
			}
			foreach (string puesto in Ojos.Puestos)
			{
				Desgaste.Gastar(puesto, num);
			}
		}
	}
	public class Fantasma : MonoBehaviour
	{
		private const float FadeIn = 0.1f;

		private const float FadeOut = 0.2f;

		private const float MaxVida = 2.5f;

		private const float MinVida = 0.3f;

		private static readonly Dictionary<string, Stack<Fantasma>> Pool = new Dictionary<string, Stack<Fantasma>>();

		private static readonly List<Fantasma> Activos = new List<Fantasma>();

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

		private static GameObject _almacen;

		private static readonly Type[] Conservar = new Type[6]
		{
			typeof(Transform),
			typeof(Animator),
			typeof(SkinnedMeshRenderer),
			typeof(MeshRenderer),
			typeof(MeshFilter),
			typeof(LODGroup)
		};

		private string _key;

		private Character _objetivo;

		private Transform _visualObjetivo;

		private Transform _copia;

		private Animator _anim;

		private Material _mat;

		private float _edad;

		private float _alfaFin = -1f;

		private float _distancia;

		public static bool Mostrar(Character c, string trigger, float distancia)
		{
			string prefabName = Utils.GetPrefabName(((Component)c).gameObject);
			if (NoCopiable.Contains(prefabName))
			{
				return false;
			}
			foreach (Fantasma activo in Activos)
			{
				if ((Object)(object)activo._objetivo == (Object)(object)c)
				{
					activo.Iniciar(c, trigger, distancia);
					return true;
				}
			}
			if (Activos.Count >= MTOjosPlugin.PrevMaxSiluetas.Value)
			{
				Fantasma fantasma = null;
				foreach (Fantasma activo2 in Activos)
				{
					if ((Object)(object)fantasma == (Object)null || activo2._distancia > fantasma._distancia)
					{
						fantasma = activo2;
					}
				}
				if ((Object)(object)fantasma == (Object)null || fantasma._distancia <= distancia)
				{
					return false;
				}
				fantasma.Devolver();
			}
			Fantasma fantasma2 = Sacar(prefabName, c);
			if ((Object)(object)fantasma2 == (Object)null)
			{
				NoCopiable.Add(prefabName);
				MTOjosPlugin.Log.LogInfo((object)("Previsión: '" + prefabName + "' no se puede copiar; se usa la marca de suelo."));
				return false;
			}
			fantasma2.Iniciar(c, trigger, distancia);
			return true;
		}

		public static void TerminarTodos()
		{
			for (int num = Activos.Count - 1; num >= 0; num--)
			{
				Activos[num].Devolver();
			}
		}

		public static void VaciarPool()
		{
			TerminarTodos();
			foreach (Stack<Fantasma> value in Pool.Values)
			{
				foreach (Fantasma item in value)
				{
					if (Object.op_Implicit((Object)(object)item))
					{
						Object.Destroy((Object)(object)((Component)item).gameObject);
					}
				}
			}
			Pool.Clear();
			if (Object.op_Implicit((Object)(object)_almacen))
			{
				Object.Destroy((Object)(object)_almacen);
			}
			_almacen = null;
		}

		private static Fantasma Sacar(string key, Character c)
		{
			if (Pool.TryGetValue(key, out var value))
			{
				while (value.Count > 0)
				{
					Fantasma fantasma = value.Pop();
					if (Object.op_Implicit((Object)(object)fantasma))
					{
						return fantasma;
					}
				}
			}
			try
			{
				return Construir(key, c);
			}
			catch (Exception ex)
			{
				MTOjosPlugin.Log.LogWarning((object)("Previsión: error copiando '" + key + "': " + ex.Message));
				return null;
			}
		}

		private static Fantasma Construir(string key, Character c)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Expected O, but got Unknown
			Animator componentInChildren = ((Component)c).GetComponentInChildren<Animator>();
			if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.runtimeAnimatorController == (Object)null)
			{
				return null;
			}
			if (!Object.op_Implicit((Object)(object)_almacen))
			{
				_almacen = new GameObject("MT_Ojos_Almacen");
				_almacen.SetActive(false);
			}
			GameObject val = Object.Instantiate<GameObject>(((Component)componentInChildren).gameObject, _almacen.transform);
			((Object)val).name = "copia";
			Component[] componentsInChildren;
			for (int i = 0; i < 3; i++)
			{
				componentsInChildren = val.GetComponentsInChildren<Component>(true);
				foreach (Component val2 in componentsInChildren)
				{
					if ((Object)(object)val2 == (Object)null || EsConservado(val2))
					{
						continue;
					}
					if (val2 is ParticleSystem || val2 is ParticleSystemRenderer)
					{
						if ((Object)(object)val2.gameObject != (Object)(object)val)
						{
							Object.DestroyImmediate((Object)(object)val2.gameObject);
						}
					}
					else
					{
						try
						{
							Object.DestroyImmediate((Object)(object)val2);
						}
						catch
						{
						}
					}
				}
			}
			componentsInChildren = val.GetComponentsInChildren<Component>(true);
			foreach (Component val3 in componentsInChildren)
			{
				if ((Object)(object)val3 == (Object)null || EsConservado(val3))
				{
					continue;
				}
				Collider val4 = (Collider)(object)((val3 is Collider) ? val3 : null);
				if (val4 != null)
				{
					val4.enabled = false;
					val4.isTrigger = true;
					continue;
				}
				Rigidbody val5 = (Rigidbody)(object)((val3 is Rigidbody) ? val3 : null);
				if (val5 != null)
				{
					val5.isKinematic = true;
					val5.detectCollisions = false;
					continue;
				}
				AudioSource val6 = (AudioSource)(object)((val3 is AudioSource) ? val3 : null);
				if (val6 != null)
				{
					val6.mute = true;
					((Behaviour)val6).enabled = false;
					continue;
				}
				Light val7 = (Light)(object)((val3 is Light) ? val3 : null);
				if (val7 != null)
				{
					((Behaviour)val7).enabled = false;
					continue;
				}
				Behaviour val8 = (Behaviour)(object)((val3 is Behaviour) ? val3 : null);
				if (val8 != null)
				{
					val8.enabled = false;
				}
			}
			Material val9 = Transparente.Nuevo(Color.clear);
			if ((Object)(object)val9 == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			int num = 0;
			Renderer[] componentsInChildren2 = val.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val10 in componentsInChildren2)
			{
				if (!(val10 is ParticleSystemRenderer))
				{
					val10.shadowCastingMode = (ShadowCastingMode)0;
					val10.receiveShadows = false;
					Material[] array = (Material[])(object)new Material[val10.sharedMaterials.Length];
					for (int k = 0; k < array.Length; k++)
					{
						array[k] = val9;
					}
					val10.sharedMaterials = array;
					SkinnedMeshRenderer val11 = (SkinnedMeshRenderer)(object)((val10 is SkinnedMeshRenderer) ? val10 : null);
					if (val11 != null)
					{
						val11.updateWhenOffscreen = true;
					}
					num++;
				}
			}
			if (num == 0)
			{
				Object.Destroy((Object)(object)val);
				Object.Destroy((Object)(object)val9);
				return null;
			}
			Animator component = val.GetComponent<Animator>();
			component.applyRootMotion = false;
			component.fireEvents = false;
			component.cullingMode = (AnimatorCullingMode)0;
			GameObject val12 = new GameObject("MT_Fantasma_" + key);
			val12.SetActive(false);
			Fantasma fantasma = val12.AddComponent<Fantasma>();
			fantasma._key = key;
			fantasma._mat = val9;
			fantasma._anim = component;
			fantasma._copia = val.transform;
			val.transform.SetParent(val12.transform, false);
			return fantasma;
		}

		private static bool EsConservado(Component comp)
		{
			Type type = ((object)comp).GetType();
			Type[] conservar = Conservar;
			for (int i = 0; i < conservar.Length; i++)
			{
				if (conservar[i].IsAssignableFrom(type))
				{
					return true;
				}
			}
			return false;
		}

		private void Iniciar(Character c, string trigger, float distancia)
		{
			_objetivo = c;
			_visualObjetivo = ((Component)((Component)c).GetComponentInChildren<Animator>()).transform;
			_distancia = distancia;
			_edad = 0f;
			_alfaFin = -1f;
			if (!Activos.Contains(this))
			{
				Activos.Add(this);
			}
			Seguir();
			((Component)this).gameObject.SetActive(true);
			_anim.Rebind();
			_anim.speed = MTOjosPlugin.PrevVelocidad.Value;
			_anim.Update(0f);
			_anim.SetTrigger(trigger);
			_anim.Update(MTOjosPlugin.PrevAdelanto.Value);
			PonerAlfa(0f);
		}

		private void LateUpdate()
		{
			if ((Object)(object)_objetivo == (Object)null || (Object)(object)_visualObjetivo == (Object)null || _objetivo.IsDead() || !((Component)_objetivo).gameObject.activeInHierarchy)
			{
				Devolver();
				return;
			}
			_edad += Time.deltaTime;
			Seguir();
			if (_alfaFin < 0f && ((_edad > 0.3f && !_objetivo.InAttack()) || _edad > 2.5f))
			{
				_alfaFin = _edad;
			}
			float num;
			if (_alfaFin >= 0f)
			{
				num = 1f - (_edad - _alfaFin) / 0.2f;
				if (num <= 0f)
				{
					Devolver();
					return;
				}
			}
			else
			{
				num = Mathf.Clamp01(_edad / 0.1f);
			}
			PonerAlfa(num);
		}

		private void Seguir()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.SetPositionAndRotation(_visualObjetivo.position, _visualObjetivo.rotation);
			_copia.localPosition = Vector3.zero;
			_copia.localRotation = Quaternion.identity;
			_copia.localScale = _visualObjetivo.lossyScale;
		}

		private void PonerAlfa(float a)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Color value = MTOjosPlugin.PrevColor.Value;
			value.a = a * MTOjosPlugin.PrevOpacidad.Value;
			_mat.color = value;
			Transparente.Tinte(_mat, value);
		}

		private void Devolver()
		{
			Activos.Remove(this);
			_objetivo = null;
			_visualObjetivo = null;
			if (Object.op_Implicit((Object)(object)this))
			{
				((Component)this).gameObject.SetActive(false);
				if (!Pool.TryGetValue(_key, out var value))
				{
					value = (Pool[_key] = new Stack<Fantasma>());
				}
				if (!value.Contains(this))
				{
					value.Push(this);
				}
			}
		}

		private void OnDestroy()
		{
			Activos.Remove(this);
			if (Object.op_Implicit((Object)(object)_mat))
			{
				Object.Destroy((Object)(object)_mat);
			}
		}
	}
	public class Marca : MonoBehaviour
	{
		private const float Vida = 1.2f;

		private Material _mat;

		private float _edad;

		public static void Mostrar(Character c, Attack atk, bool area)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)c).transform;
			float num = Mathf.Max(atk.m_attackRange, 1f);
			Vector3 val;
			float num2;
			if (area)
			{
				val = transform.position + transform.forward * num;
				num2 = Mathf.Max(atk.m_attackRayWidth, 1.5f);
			}
			else
			{
				val = transform.position + transform.forward * num * 0.6f;
				num2 = num * 0.6f;
			}
			Material val2 = Transparente.Nuevo(Color.clear);
			if (!((Object)(object)val2 == (Object)null))
			{
				GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2);
				Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>());
				((Object)obj).name = "MT_Marca";
				float y = default(float);
				if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetSolidHeight(val, ref y, 1000))
				{
					val.y = y;
				}
				obj.transform.position = val + Vector3.up * 0.05f;
				obj.transform.localScale = new Vector3(num2 * 2f, 0.01f, num2 * 2f);
				Renderer component = obj.GetComponent<Renderer>();
				component.sharedMaterial = val2;
				component.shadowCastingMode = (ShadowCastingMode)0;
				component.receiveShadows = false;
				obj.AddComponent<Marca>()._mat = val2;
			}
		}

		private void Update()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			_edad += Time.deltaTime;
			float num = ((_edad < 0.1f) ? (_edad / 0.1f) : (1f - (_edad - 0.1f) / 1.1f));
			if (num <= 0f || !Prevision.Activo)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Color value = MTOjosPlugin.PrevColor.Value;
			value.a = num * 0.4f;
			_mat.color = value;
			Transparente.Tinte(_mat, value);
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)_mat))
			{
				Object.Destroy((Object)(object)_mat);
			}
		}
	}
	public class Identificacion : MonoBehaviour
	{
		private static int _mask;

		private Component _objetivo;

		private float _siguienteBusqueda;

		private GUIStyle _estilo;

		private GUIStyle _sombra;

		private const float Retardo = 0.3f;

		private const float Fundido = 0.2f;

		private Component _candidato;

		private float _desde;

		private float _alfa;

		private float _siguienteDatos;

		private string[] _lecturas = new string[0];

		private static readonly Regex Etiquetas = new Regex("<.*?>");

		private static readonly RaycastHit[] _golpes = (RaycastHit[])(object)new RaycastHit[64];

		private static readonly Color Violeta = new Color(0.72f, 0.45f, 1f);

		private GUIStyle _halo;

		private static Font _norse;

		private static bool _buscada;

		private static readonly string[] SinNorse = new string[6] { "Russian", "Ukrainian", "Chinese", "Chinese_Trad", "Japanese", "Korean" };

		private float _desdeObjetivo;

		private Component _ultimo;

		private readonly List<string> _lineas = new List<string>();

		private string _nombre;

		private static Vector3 APantalla(Camera cam, Vector3 mundo)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = cam.WorldToViewportPoint(mundo);
			return new Vector3(val.x * (float)Screen.width, val.y * (float)Screen.height, val.z);
		}

		private void Update()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || !MTOjosPlugin.PuedeUsarTeclas() || !Desgaste.Funciona("MT_OjoIdentificacion"))
			{
				_objetivo = (_candidato = null);
				_alfa = 0f;
				return;
			}
			if (Valido(_objetivo))
			{
				Desgaste.Gastar("MT_OjoIdentificacion", MTOjosPlugin.DesgasteIdentificacion.Value * Time.deltaTime);
				_alfa = Mathf.MoveTowards(_alfa, 1f, Time.deltaTime / 0.2f);
			}
			if (Time.time < _siguienteBusqueda)
			{
				return;
			}
			_siguienteBusqueda = Time.time + 0.1f;
			Component val = Apuntada(localPlayer);
			if ((Object)(object)val != (Object)(object)_candidato)
			{
				_candidato = val;
				_desde = Time.time;
			}
			if ((Object)(object)val != (Object)null && Time.time - _desde >= 0.3f)
			{
				if ((Object)(object)_objetivo != (Object)(object)val)
				{
					_objetivo = val;
					_alfa = 0f;
					_siguienteDatos = 0f;
				}
			}
			else if ((Object)(object)val != (Object)(object)_objetivo)
			{
				_objetivo = null;
			}
		}

		private static bool Valido(Component c)
		{
			if ((Object)(object)c != (Object)null)
			{
				Character val = (Character)(object)((c is Character) ? c : null);
				if (val == null || !val.IsDead())
				{
					Pickable val2 = (Pickable)(object)((c is Pickable) ? c : null);
					if (val2 != null)
					{
						return val2.CanBePicked();
					}
					return true;
				}
			}
			return false;
		}

		private static Component Apuntada(Player p)
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			Transform val = (Object.op_Implicit((Object)(object)GameCamera.instance) ? ((Component)GameCamera.instance).transform : null);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			if (_mask == 0)
			{
				_mask = LayerMask.GetMask(new string[11]
				{
					"character", "character_net", "character_ghost", "character_noenv", "hitbox", "Default", "static_solid", "terrain", "piece", "item",
					"Default_small"
				});
			}
			int num = Physics.SphereCastNonAlloc(val.position, 0.25f, val.forward, _golpes, MTOjosPlugin.IdentDistancia.Value * (VistaLejana.Mirando ? 3f : 1f), _mask);
			Component result = null;
			float num2 = float.MaxValue;
			float num3 = float.MaxValue;
			for (int i = 0; i < num; i++)
			{
				RaycastHit val2 = _golpes[i];
				Component componentInParent = (Component)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Character>();
				if ((Object)(object)componentInParent == (Object)(object)p)
				{
					continue;
				}
				if ((Object)(object)componentInParent == (Object)null)
				{
					componentInParent = (Component)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<ItemDrop>();
				}
				if ((Object)(object)componentInParent == (Object)null)
				{
					componentInParent = (Component)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Pickable>();
				}
				if ((Object)(object)componentInParent == (Object)null)
				{
					componentInParent = (Component)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<MineRock>();
				}
				if ((Object)(object)componentInParent == (Object)null)
				{
					componentInParent = (Component)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<MineRock5>();
				}
				if ((Object)(object)componentInParent == (Object)null)
				{
					if (!((RaycastHit)(ref val2)).collider.isTrigger)
					{
						num3 = Mathf.Min(num3, ((RaycastHit)(ref val2)).distance);
					}
				}
				else if (Valido(componentInParent) && ((RaycastHit)(ref val2)).distance < num2)
				{
					num2 = ((RaycastHit)(ref val2)).distance;
					result = componentInParent;
				}
			}
			if (!(num2 < num3))
			{
				return null;
			}
			return result;
		}

		private static Font Norse()
		{
			if (Array.IndexOf(SinNorse, Tr.Current) >= 0)
			{
				return null;
			}
			if (!_buscada)
			{
				_buscada = true;
				Font[] array = Resources.FindObjectsOfTypeAll<Font>();
				string[] array2 = new string[3] { "Norsebold", "Norse", "AveriaSerifLibre-Bold" };
				foreach (string value in array2)
				{
					Font[] array3 = array;
					foreach (Font val in array3)
					{
						if ((Object)(object)_norse == (Object)null && ((Object)val).name.StartsWith(value))
						{
							_norse = val;
						}
					}
				}
			}
			return _norse;
		}

		private void LateUpdate()
		{
			Circulo.Actualizar(null, 0f);
		}

		private void OnGUI()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_005d: 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_0069: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Event.current.type != 7 || !Valido(_objetivo) || (Object)(object)Player.m_localPlayer == (Object)null || ((Character)Player.m_localPlayer).IsDead() || !MTOjosPlugin.PuedeUsarTeclas() || !Desgaste.Funciona("MT_OjoIdentificacion"))
			{
				return;
			}
			if (_estilo == null)
			{
				_estilo = new GUIStyle(GUI.skin.label)
				{
					richText = true,
					alignment = (TextAnchor)3,
					wordWrap = false,
					fontStyle = (FontStyle)1
				};
				_sombra = new GUIStyle(_estilo);
				_sombra.normal.textColor = new Color(0.05f, 0f, 0.1f);
				_halo = new GUIStyle(_estilo);
				_halo.normal.textColor = Violeta;
				_estilo.normal.textColor = new Color(0.93f, 0.87f, 1f);
			}
			GUIStyle estilo = _estilo;
			GUIStyle sombra = _sombra;
			Font val = (_halo.font = Norse());
			Font font = (sombra.font = val);
			estilo.font = font;
			if ((Object)(object)_objetivo != (Object)(object)_ultimo)
			{
				_ultimo = _objetivo;
				_desdeObjetivo = Time.time;
				_nombre = Nombre(_objetivo);
				_siguienteDatos = 0f;
			}
			bool num = Time.time >= _siguienteDatos;
			if (num)
			{
				_siguienteDatos = Time.time + 0.25f;
				_lecturas = Lecturas(_objetivo).ToArray();
			}
			float num2 = Mathf.Clamp((float)Screen.height / 900f, 0.8f, 1.6f);
			GUIStyle estilo2 = _estilo;
			GUIStyle sombra2 = _sombra;
			int num3 = (_halo.fontSize = Mathf.RoundToInt((((Object)(object)Norse() != (Object)null) ? 19f : 16f) * num2 / 2f) * 2);
			int fontSize = (sombra2.fontSize = num3);
			estilo2.fontSize = fontSize;
			List<string> lineas = _lineas;
			if (num || lineas.Count == 0)
			{
				float num6 = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, _objetivo.transform.position);
				lineas.Clear();
				if (!string.IsNullOrEmpty(_nombre))
				{
					lineas.Add("<color=#FFC857>" + _nombre + "</color>");
				}
				lineas.Add("<color=#FFE49B>" + Principal(_objetivo) + "</color>");
				lineas.Add($"<color=#9CE8F1>{num6:0} m</color>");
				lineas.AddRange(_lecturas);
			}
			float num7 = 22f * num2;
			float num8 = 40f * num2;
			float num9 = (float)Screen.height * 0.2f;
			float num10 = Time.time - _desdeObjetivo;
			for (int i = 0; i < lineas.Count; i++)
			{
				float num11 = Mathf.Clamp01((num10 - (float)i * 0.06f) / 0.2f) * _alfa;
				if (!(num11 <= 0f))
				{
					float num12 = (1f - num11) * -12f * num2;
					Linea(lineas[i], num8 + num12, num9 + (float)i * num7, num7, num11, i, num2);
				}
			}
		}

		private void Linea(string texto, float x, float y, float alto, float a, int i, float ui)
		{
			//IL_0000: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			Color color = GUI.color;
			GUI.color = new Color(0.8f, 0.6f, 1f, a * (0.75f + 0.25f * Mathf.Sin(Time.time * 4f + (float)i)));
			float num = 12f * ui;
			GUI.DrawTexture(new Rect(x + 5f * ui, y + (alto - num) / 2f, num, num), (Texture)(object)ToukiManos.Dot());
			GUI.color = color;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(x + 26f * ui, y, 420f, alto);
			string text = Etiquetas.Replace(texto, "");
			Color color2 = GUI.color;
			float num2 = 0.25f + 0.1f * Mathf.Sin(Time.time * 3f + (float)i);
			GUI.color = new Color(1f, 1f, 1f, a * num2);
			for (int j = 0; j < 4; j++)
			{
				float num3 = ((j < 2) ? ((j == 0) ? (-1.5f) : 1.5f) : 0f);
				float num4 = ((j >= 2) ? ((j == 2) ? (-1.5f) : 1.5f) : 0f);
				GUI.Label(new Rect(((Rect)(ref val)).x + num3, ((Rect)(ref val)).y + num4, ((Rect)(ref val)).width, ((Rect)(ref val)).height), text, _halo);
			}
			GUI.color = new Color(1f, 1f, 1f, a * 0.9f);
			GUI.Label(new Rect(((Rect)(ref val)).x + 1f, ((Rect)(ref val)).y + 1f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), text, _sombra);
			GUI.color = new Color(1f, 1f, 1f, a);
			GUI.Label(val, texto, _estilo);
			GUI.color = color2;
		}

		private static string Nombre(Component objetivo)
		{
			string text = null;
			try
			{
				Component obj = ((objetivo is Hoverable) ? objetivo : null);
				text = ((obj != null) ? ((Hoverable)obj).GetHoverName() : null);
			}
			catch
			{
				text = null;
			}
			if (string.IsNullOrEmpty(text))
			{
				ItemDrop val = (ItemDrop)(object)((objetivo is ItemDrop) ? objetivo : null);
				if (val != null)
				{
					text = val.m_itemData.m_shared.m_name;
				}
			}
			if (string.IsNullOrEmpty(text))
			{
				return null;
			}
			text = Etiquetas.Replace(Tr.Localize(text), "").Trim();
			Character val2 = (Character)(object)((objetivo is Character) ? objetivo : null);
			if (val2 != null && val2.GetLevel() > 1)
			{
				text = text + " " + new string('★', val2.GetLevel() - 1);
			}
			return text;
		}

		private static string Principal(Component objetivo)
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			Character val = (Character)(object)((objetivo is Character) ? objetivo : null);
			if (val != null)
			{
				return Tr.Get("ojos_health") + $" {Mathf.CeilToInt(val.GetHealth())} / {Mathf.CeilToInt(val.GetMaxHealth())}";
			}
			ItemDrop val2 = (ItemDrop)(object)((objetivo is ItemDrop) ? objetivo : null);
			if (val2 != null)
			{
				return Tr.Get("ojos_quantity") + $" ×{val2.m_itemData.m_stack}";
			}
			Pickable val3 = (Pickable)(object)((objetivo is Pickable) ? objetivo : null);
			if (val3 != null)
			{
				return Tr.Get("ojos_base_yield") + $" ×{val3.m_amount}";
			}
			int num = ((MineRock)(((objetivo is MineRock) ? objetivo : null)?)).m_minToolTier ?? ((MineRock5)objetivo).m_minToolTier;
			return Tr.Get("ojos_tool_tier") + $" {num}";
		}

		private static List<string> Lecturas(Component objetivo)
		{
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: 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_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: 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_0160: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			ItemDrop val = (ItemDrop)(object)((objetivo is ItemDrop) ? objetivo : null);
			if (val != null)
			{
				ItemData itemData = val.m_itemData;
				list.Add("<color=#9CE8F1>" + Tr.Get("ojos_weight") + $" {itemData.GetWeight(-1):0.0}</color>");
				list.Add("<color=#DFC5FF>" + Tr.Get("ojos_quality") + $" {itemData.m_quality}</color>");
				if (itemData.m_shared.m_useDurability)
				{
					list.Add("<color=#FFE49B>" + Tr.Get("ojos_durability") + $" {Mathf.CeilToInt(itemData.m_durability)} / {Mathf.CeilToInt(itemData.GetMaxDurability())}</color>");
				}
				return list;
			}
			Pickable val2 = (Pickable)(object)((objetivo is Pickable) ? objetivo : null);
			if (val2 != null)
			{
				ItemData val3 = ((!((Object)(object)val2.m_itemPrefab != (Object)null)) ? null : val2.m_itemPrefab.GetComponent<ItemDrop>()?.m_itemData);
				if (val3 != null)
				{
					list.Add("<color=#9CE8F1>" + Tr.Get("ojos_weight") + $" {val3.GetWeight(val2.m_amount):0.0}</color>");
				}
				return list;
			}
			Character val4 = (Character)(object)((objetivo is Character) ? objetivo : null);
			DamageModifiers val5 = ((val4 != null) ? val4.GetDamageModifiers((WeakSpot)null) : (((MineRock)(((objetivo is MineRock) ? objetivo : null)?)).m_damageModifiers ?? ((MineRock5)objetivo).m_damageModifiers));
			Add(list, Tr.Get("ojos_slash"), val5.m_slash);
			Add(list, Tr.Get("ojos_blunt"), val5.m_blunt);
			Add(list, Tr.Get("ojos_pierce"), val5.m_pierce);
			Add(list, Tr.Get("ojos_fire"), val5.m_fire);
			Add(list, Tr.Get("ojos_frost"), val5.m_frost);
			Add(list, Tr.Get("ojos_lightning"), val5.m_lightning);
			Add(list, Tr.Get("ojos_poison"), val5.m_poison);
			Add(list, Tr.Get("ojos_spirit"), val5.m_spirit);
			Add(list, Tr.Get("ojos_chop"), val5.m_chop);
			Add(list, Tr.Get("ojos_pickaxe"), val5.m_pickaxe);
			if (list.Count == 0)
			{
				list.Add("<color=#DDCCEE>" + Tr.Get("ojos_no_weaknesses_or_resistances") + "</color>");
			}
			return list;
		}

		private static void Add(List<string> partes, string tipo, DamageModifier mod)
		{
			//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_0028: Expected I4, but got Unknown
			switch (mod - 1)
			{
			case 5:
				partes.Add("<color=#FF3030>" + tipo + " ×2</color>");
				break;
			case 1:
				partes.Add("<color=#FF9933>" + tipo + " ×1,5</color>");
				break;
			case 7:
				partes.Add("<color=#FFCC66>" + tipo + " ×1,25</color>");
				break;
			case 6:
				partes.Add("<color=#A8E6A1>" + tipo + " ×0,75</color>");
				break;
			case 0:
				partes.Add("<color=#66CC66>" + tipo + " ×0,5</color>");
				break;
			case 4:
				partes.Add("<color=#2E8B57>" + tipo + " ×0,25</color>");
				break;
			case 2:
			case 3:
				partes.Add("<color=#999999>" + tipo + ": " + Tr.Get("ojos_immune") + "</color>");
				break;
			}
		}
	}
	[BepInPlugin("mushokutensei.ojos", "MT Ojos", "2.1.9")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class MTOjosPlugin : BaseUnityPlugin
	{
		public const string Guid = "mushokutensei.ojos";

		public const string Version = "2.1.9";

		public static ConfigEntry<KeyCode> TeclaZoom;

		public static ManualLogSource Log;

		public static string Dir;

		public static ConfigEntry<float> PrevAdelanto;

		public static ConfigEntry<float> PrevVelocidad;

		public static ConfigEntry<float> PrevOpacidad;

		public static ConfigEntry<float> PrevManaPorGolpe;

		public static ConfigEntry<float> PrevDistObjetivo;

		public static ConfigEntry<float> PrevDistCerca;

		public static ConfigEntry<int> PrevMaxSiluetas;

		public static ConfigEntry<Color> PrevColor;

		public static ConfigEntry<bool> PrevMarcaSuelo;

		public static ConfigEntry<float> ZoomMin;

		public static ConfigEntry<float> ZoomMax;

		public static ConfigEntry<float> ZoomManaPorSegundo;

		public static ConfigEntry<float> ZoomVelocidadMover;

		public static ConfigEntry<float> ZoomArco;

		public static ConfigEntry<bool> ZoomTelemetro;

		public static ConfigEntry<Color> ColorPrevision;

		public static ConfigEntry<Color> ColorVistaLejana;

		public static ConfigEntry<Color> ColorIdentificacion;

		public static ConfigEntry<float> IdentDistancia;

		public static ConfigEntry<float> IdentAltura;

		public static ConfigEntry<bool> BrilloOjos;

		public static ConfigEntry<float> DurabilidadMax;

		public static ConfigEntry<float> DesgasteIdentificacion;

		public static ConfigEntry<float> DesgasteVistaLejana;

		public static ConfigEntry<float> DesgastePrevision;

		public static ConfigEntry<float> PrevRalentizar;

		public static ConfigEntry<float> PrevRalentizarJefe;

		public static ConfigEntry<float> PrevManaRalentizar;

		public static ConfigEntry<float> DesgasteEquipadoPorSegundo;

		public static ConfigEntry<float> BotinMultiplicador;

		public static ConfigEntry<float> DiametroOjo;

		private void Awake()
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Expected O, but got Unknown
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Expected O, but got Unknown
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Expected O, but got Unknown
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: Expected O, but got Unknown
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			//IL_057c: Expected O, but got Unknown
			//IL_05af: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b9: Expected O, but got Unknown
			//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Invalid comparison between Unknown and I4
			//IL_0619: Unknown result type (might be due to invalid IL or missing references)
			//IL_061e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_0631: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0647: Unknown result type (might be due to invalid IL or missing references)
			//IL_0671: Expected O, but got Unknown
			Tr.Load(typeof(MTOjosPlugin).Assembly, Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location));
			Log = ((BaseUnityPlugin)this).Logger;
			Dir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			PrevAdelanto = ((BaseUnityPlugin)this).Config.Bind<float>("Prevision", "Adelanto", 0.3f, new ConfigDescription("Segundos que la silueta empieza por delante del enemigo.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.8f), Array.Empty<object>()));
			PrevVelocidad = ((BaseUnityPlugin)this).Config.Bind<float>("Prevision", "VelocidadSilueta", 1.6f, new ConfigDescription("La animación de la silueta va acelerada: termina el golpe antes que el enemigo real.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 3f), Array.Empty<object>()));
			PrevOpacidad = ((BaseUnityPlugin)this).Config.Bind<float>("Prevision", "OpacidadFantasmaTenue", 0.14f, new ConfigDescription("Opacidad de la silueta (clave nueva: las antiguas OpacidadSilueta=0,55 y OpacidadFantasma=0,28 tapaban demasiado).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.03f, 0.9f), Array.Empty<object>()));
			PrevColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Prevision", "ColorSilueta", new Color(1f, 0.78f, 0.15f), "Color de la silueta (dorado, como el ojo; cámbialo si eres daltónico).");
			PrevMaxSiluetas = ((BaseUnityPlugin)this).Config.Bind<int>("Prevision", "MaxSiluetas", 3, new ConfigDescription("Siluetas a la vez (las más cercanas).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 6), Array.Empty<object>()));
			PrevMarcaSuelo = ((BaseUnityPlugin)this).Config.Bind<bool>("Prevision", "MarcaSueloArea", false, "Además de la silueta, marca en el suelo para golpes de área y criaturas que no se pueden copiar.");
			PrevManaPorGolpe = ((BaseUnityPlugin)this).Config.Bind<float>("Prevision", "ManaPorGolpe", 1f, "Maná por cada golpe previsto (es automático mientras llevas el ojo).");
			PrevDistObjetivo = ((BaseUnityPlugin)this).Config.Bind<float>("Prevision", "DistanciaObjetivo", 20f, "Distancia máx. de enemigos que te apuntan a ti.");
			PrevDistCerca = ((BaseUnityPlugin)this).Config.Bind<float>("Prevision", "DistanciaCerca", 8f, "Distancia máx. de enemigos que te miran (aunque no sepamos su objetivo).");
			ZoomMin = ((BaseUnityPlugin)this).Config.Bind<float>("VistaLejana", "Aumento", 4f, "Aumento al pulsar la tecla.");
			ZoomMax = ((BaseUnityPlugin)this).Config.Bind<float>("VistaLejana", "AumentoMaximo", 12f, "Aumento máximo con la rueda del ratón.");
			ZoomManaPorSegundo = ((BaseUnityPlugin)this).Config.Bind<float>("VistaLejana", "ManaPorSegundo", 0.25f, "Maná por segundo mientras haces zoom.");
			ZoomVelocidadMover = ((BaseUnityPlugin)this).Config.Bind<float>("VistaLejana", "VelocidadAlMirar", 0.75f, "Multiplicador de velocidad de movimiento mientras haces zoom.");
			ZoomArco = ((BaseUnityPlugin)this).Config.Bind<float>("VistaLejana", "AumentoArco", 2.5f, new ConfigDescription("Aumento automático al tensar el arco con el ojo puesto (1 = sin zoom). Con la tecla, el zoom completo.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 6f), Array.Empty<object>()));
			ZoomTelemetro = ((BaseUnityPlugin)this).Config.Bind<bool>("VistaLejana", "Telemetro", true, "Mientras miras: distancia en metros y nombre de lo que apuntas, bajo la mira.");
			ColorPrevision = ((BaseUnityPlugin)this).Config.Bind<Color>("Visual", "ColorPrevision", new Color(1f, 0.72f, 0.08f), "Color del brillo del ojo con Previsión (mt_eye color foresight r g b).");
			ColorVistaLejana = ((BaseUnityPlugin)this).Config.Bind<Color>("Visual", "ColorVistaLejana", new Color(1f, 0.12f, 0.4f), "Color del brillo del ojo con Vista Lejana.");
			ColorIdentificacion = ((BaseUnityPlugin)this).Config.Bind<Color>("Visual", "ColorIdentificacion", new Color(0.65f, 0.3f, 1f), "Color del brillo del ojo con Identificación.");
			BrilloOjos = ((BaseUnityPlugin)this).Config.Bind<bool>("Visual", "LlamasOjos", false, "Tu ojo se enciende del color del ojo mágico puesto, con llamitas como el tōki.");
			DiametroOjo = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "TamanoBrillo", 0.04f, new ConfigDescription("Tamaño de las llamas de los ojos en la cabeza (0,04 = normal; mt_eye size).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.005f, 0.3f), Array.Empty<object>()));
			IdentAltura = ((BaseUnityPlugin)this).Config.Bind<float>("Identificacion", "Altura", 0.35f, "Metros sobre la cabeza de la criatura donde empieza el texto (justo bajo su barra de vida del juego).");
			IdentDistancia = ((BaseUnityPlugin)this).Config.Bind<float>("Identificacion", "Distancia", 60f, "Distancia máx. de identificación de criaturas, botín, recursos recolectables y vetas visibles.");
			PrevRalentizar = ((BaseUnityPlugin)this).Config.Bind<float>("Prevision", "VelocidadEnemigoAtacando", 0.5f, new ConfigDescription("Velocidad de la animación del enemigo mientras ataca (1 = normal, 0,5 = 50 % más lento). Solo en el enemigo que previste. Sustituye a RalentizarEnemigo (0,8).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 1f), Array.Empty<object>()));
			PrevRalentizarJefe = ((BaseUnityPlugin)this).Config.Bind<float>("Prevision", "VelocidadJefeAtacando", 0.8f, new ConfigDescription("Igual, pero para jefes (0,8 = 20 % más lento).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 1f), Array.Empty<object>()));
			PrevManaRalentizar = ((BaseUnityPlugin)this).Config.Bind<float>("Prevision", "ManaPorRalentizar", 3f, "Maná extra cada vez que la Previsión ralentiza a un enemigo (sin maná: solo el fantasma).");
			DurabilidadMax = ((BaseUnityPlugin)this).Config.Bind<float>("Desgaste", "Durabilidad", 100f, "Durabilidad de los ojos (+50 % por nivel de mejora). Se reparan en su estación.");
			DesgasteIdentificacion = ((BaseUnityPlugin)this).Config.Bind<float>("Desgaste", "IdentificacionPorSegundoV2", 0.2f, "Desgaste por segundo identificando una criatura (100 → ~8 min apuntando).");
			DesgasteVistaLejana = ((BaseUnityPlugin)this).Config.Bind<float>("Desgaste", "VistaLejanaPorSegundoV2", 0.6f, "Desgaste por segundo de zoom (100 → ~3 min mirando).");
			DesgastePrevision = ((BaseUnityPlugin)this).Config.Bind<float>("Desgaste", "PrevisionPorGolpeV2", 1f, "Desgaste por golpe previsto (100 → 100 golpes).");
			DesgasteEquipadoPorSegundo = ((BaseUnityPlugin)this).Config.Bind<float>("Desgaste", "SoloLlevarloPorSegundoV2", 0.004f, new ConfigDescription("Desgaste por solo llevar el ojo puesto (0,004 → 100 en ~7 h de juego).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			BotinMultiplicador = ((BaseUnityPlugin)this).Config.Bind<float>("Botin", "Multiplicador", 1f, new ConfigDescription("Multiplica la probabilidad de que los ojos caigan de criaturas y jefes (0 = solo fabricarlos).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			TeclaZoom = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Teclas", "VistaLejana", (KeyCode)121, "Mantener para usar el Ojo de la Vista Lejana (solo con el ojo equipado).");
			if ((int)TeclaZoom.Value == 122)
			{
				TeclaZoom.Value = (KeyCode)121;
			}
			PrefabManager.OnVanillaPrefabsAvailable += Ojos.Registrar;
			try
			{
				GuiaInicio.Registrar(new PasoGuia
				{
					Orden = 40,
					TituloKey = "guia_eye",
					TextoKey = "guia_eye_d",
					Receta = "MT_OjoIdentificacion",
					Hecho = (Player p) => GuiaInicio.Fabricado(p, "MT_OjoIdentificacion")
				});
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("MT Ojos: guía: " + ex));
			}
			Desgaste.Init();
			((Component)this).gameObject.AddComponent<DesgasteEquipado>();
			((Component)this).gameObject.AddComponent<VistaLejana>();
			AtaqueSeguro.OcupadoAProposito.Add((Player p) => VistaLejana.Mirando && !VistaLejana.EsArco(p));
			((Component)this).gameObject.AddComponent<Prevision>();
			((Component)this).gameObject.AddComponent<Identificacion>();
			((Component)this).gameObject.AddComponent<BrilloOjo>();
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new OjoCommand());
			Parches.Aplicar("mushokutensei.ojos", ((object)this).GetType().Assembly, ((BaseUnityPlugin)this).Logger);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"MT Ojos 2.1.9 cargado");
		}

		public static bool PuedeUsarTeclas()
		{
			if (((Object)(object)Chat.instance == (Object)null || !Chat.instance.HasFocus()) && !Console.IsVisible() && !Menu.IsVisible() && !InventoryGui.IsVisible() && !Minimap.IsOpen() && !TextInput.IsVisible())
			{
				return !StoreGui.IsVisible();
			}
			return false;
		}
	}
	public static class ObjModel
	{
		public static Mesh Load(string path, out List<string> materialNames)
		{
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: 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)
			materialNames = new List<string>();
			if (!File.Exists(path))
			{
				return null;
			}
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			List<Vector2> list3 = new List<Vector2>();
			List<Vector3> list4 = new List<Vector3>();
			List<Vector3> list5 = new List<Vector3>();
			List<Vector2> list6 = new List<Vector2>();
			List<List<int>> list7 = new List<List<int>>();
			List<int> list8 = null;
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			string[] array = File.ReadAllLines(path);
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim();
				if (text.Length == 0 || text[0] == '#')
				{
					continue;
				}
				string[] array2 = text.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
				switch (array2[0])
				{
				case "v":
					list.Add(new Vector3(0f - float.Parse(array2[1], invariantCulture), float.Parse(array2[2], invariantCulture), float.Parse(array2[3], invariantCulture)));
					break;
				case "vn":
					list2.Add(new Vector3(0f - float.Parse(array2[1], invariantCulture), float.Parse(array2[2], invariantCulture), float.Parse(array2[3], invariantCulture)));
					break;
				case "vt":
					list3.Add(new Vector2(float.Parse(array2[1], invariantCulture), float.Parse(array2[2], invariantCulture)));
					break;
				case "usemtl":
				{
					string item = ((array2.Length > 1) ? array2[1] : "default");
					int num = materialNames.IndexOf(item);
					if (num < 0)
					{
						materialNames.Add(item);
						list8 = new List<int>();
						list7.Add(list8);
					}
					else
					{
						list8 = list7[num];
					}
					break;
				}
				case "f":
				{
					if (list8 == null)
					{
						materialNames.Add("default");
						list8 = new List<int>();
						list7.Add(list8);
					}
					List<int> list9 = new List<int>();
					for (int j = 1; j < array2.Length; j++)
					{
						string[] array3 = array2[j].Split(new char[1] { '/' });
						list4.Add(list[Index(array3[0], list.Count)]);
						list6.Add((array3.Length > 1 && array3[1].Length > 0) ? list3[Index(array3[1], list3.Count)] : Vector2.zero);
						list5.Add((array3.Length > 2 && array3[2].Length > 0) ? list2[Index(array3[2], list2.Count)] : Vector3.up);
						list9.Add(list4.Count - 1);
					}
					for (int k = 1; k + 1 < list9.Count; k++)
					{
						list8.Add(list9[0]);
						list8.Add(list9[k + 1]);
						list8.Add(list9[k]);
					}
					break;
				}
				}
			}
			Mesh val = new Mesh
			{
				name = Path.GetFileNameWithoutExtension(path)
			};
			val.SetVertices(list4);
			val.SetNormals(list5);
			val.SetUVs(0, list6);
			val.subMeshCount = list7.Count;
			for (int l = 0; l < list7.Count; l++)
			{
				val.SetTriangles(list7[l], l);
			}
			val.RecalculateBounds();
			return val;
		}

		private static int Index(string s, int count)
		{
			int num = int.Parse(s, CultureInfo.InvariantCulture);
			if (num <= 0)
			{
				return count + num;
			}
			return num - 1;
		}

		public static Material[] Materials(List<string> names, Material template, string mtlPath)
		{
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: 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)
			Dictionary<string, Color> dictionary = new Dictionary<string, Color>();
			Dictionary<string, Color> dictionary2 = new Dictionary<string, Color>();
			string text = null;
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			if (File.Exists(mtlPath))
			{
				string[] array = File.ReadAllLines(mtlPath);
				Color value = default(Color);
				for (int i = 0; i < array.Length; i++)
				{
					string[] array2 = array[i].Trim().Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
					if (array2.Length != 0)
					{
						if (array2[0] == "newmtl" && array2.Length > 1)
						{
							text = array2[1];
						}
						else if (text != null && array2.Length >= 4 && (array2[0] == "Kd" || array2[0] == "Ke"))
						{
							((Color)(ref value))..ctor(Mathf.LinearToGammaSpace(float.Parse(array2[1], invariantCulture)), Mathf.LinearToGammaSpace(float.Parse(array2[2], invariantCulture)), Mathf.LinearToGammaSpace(float.Parse(array2[3], invariantCulture)));
							((array2[0] == "Kd") ? dictionary : dictionary2)[text] = value;
						}
					}
				}
			}
			Material[] array3 = (Material[])(object)new Material[names.Count];
			for (int j = 0; j < names.Count; j++)
			{
				Material val = (((Object)(object)template != (Object)null) ? new Material(template) : new Material(Shader.Find("Standard")));
				((Object)val).name = "MT_" + names[j];
				string text2 = names[j];
				if (!dictionary.ContainsKey(text2))
				{
					int num = text2.LastIndexOf('.');
					if (num > 0)
					{
						text2 = text2.Substring(0, num);
					}
				}
				if (val.HasProperty("_MainTex"))
				{
					val.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture);
				}
				if (val.HasProperty("_BumpMap"))
				{
					val.SetTexture("_BumpMap", (Texture)null);
				}
				if (val.HasProperty("_Color"))
				{
					val.SetColor("_Color", dictionary.TryGetValue(text2, out var value2) ? value2 : Color.gray);
				}
				if (dictionary2.TryGetValue(text2, out var value3) && ((Color)(ref value3)).maxColorComponent > 0.01f && val.HasProperty("_EmissionColor"))
				{
					val.EnableKeyword("_EMISSION");
					val.SetColor("_EmissionColor", value3 * 1.5f);
				}
				array3[j] = val;
			}
			return array3;
		}

		public static void ReplaceVisual(GameObject itemPrefab, Mesh mesh, Material[] mats)
		{
			//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_003b: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = itemPrefab.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
			GameObject val = new GameObject("MT_ModeloOjo");
			val.transform.SetParent(itemPrefab.transform, false);
			val.transform.localPosition = new Vector3(0f, 0.09f, 0f);
			val.AddComponent<MeshFilter>().sharedMesh = mesh;
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterials = mats;
			val.layer = itemPrefab.layer;
		}
	}
	public class OjoCommand : ConsoleCommand
	{
		public override string Name => "mt_eye";

		public override string Help => "mt_eye — show values · size s (flame size, default 0.04) · color <foresight|farsight|identification> r g b (0-1, 0-255 or #hex) · on/off · reset · scan (log the face: renderers, materials, eye bones)";

		public override List<string> CommandOptionList()
		{
			return new List<string> { "scan", "size", "color", "on", "off", "reset" };
		}

		public override void Run(string[] args)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			if (args.Length == 0)
			{
				Mostrar();
				return;
			}
			switch (args[0].ToLowerInvariant())
			{
			case "size":
			{
				if (args.Length >= 2 && F(args[1], out var v))
				{
					MTOjosPlugin.DiametroOjo.Value = v;
					Mostrar();
					return;
				}
				break;
			}
			case "color":
			{
				ConfigEntry<Color> val = ((args.Length > 1) ? Entrada(args[1]) : null);
				if (val != null && Leer(args, out var c))
				{
					val.Value = c;
					Mostrar();
					return;
				}
				break;
			}
			case "scan":
				Escanear();
				return;
			case "on":
				MTOjosPlugin.BrilloOjos.Value = true;
				Mostrar();
				return;
			case "off":
				MTOjosPlugin.BrilloOjos.Value = false;
				Mostrar();
				return;
			case "reset":
			{
				ConfigEntryBase[] array = (ConfigEntryBase[])(object)new ConfigEntryBase[4]
				{
					(ConfigEntryBase)MTOjosPlugin.DiametroOjo,
					(ConfigEntryBase)MTOjosPlugin.ColorPrevision,
					(ConfigEntryBase)MTOjosPlugin.ColorVistaLejana,
					(ConfigEntryBase)MTOjosPlugin.ColorIdentificacion
				};
				foreach (ConfigEntryBase obj in array)
				{
					obj.BoxedValue = obj.DefaultValue;
				}
				BrilloOjo.Recalibrar();
				Mostrar();
				return;
			}
			}
			Console.instance.Print(((ConsoleCommand)this).Help);
		}

		private static void Escanear()
		{
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				Console.instance.Print("No player.");
				return;
			}
			ManualLogSource log = MTOjosPlugin.Log;
			log.LogInfo((object)"=== mt_eye scan ===");
			int num = 0;
			Renderer[] componentsInChildren = ((Component)localPlayer).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((val is SkinnedMeshRenderer) ? val : null);
				MeshFilter component = ((Component)val).GetComponent<MeshFilter>();
				Mesh val3 = (((Object)(object)val2 != (Object)null) ? val2.sharedMesh : (((Object)(object)component != (Object)null) ? component.sharedMesh : null));
				log.LogInfo((object)string.Format("[R] {0} · {1} · on={2} · mesh={3}", Ruta(((Component)val).transform, ((Component)localPlayer).transform), ((object)val).GetType().Name, val.enabled && ((Component)val).gameObject.activeInHierarchy, Object.op_Implicit((Object)(object)val3) ? (((Object)val3).name + " sub=" + val3.subMeshCount + " blend=" + val3.blendShapeCount) : "-"));
				if ((Object)(object)val3 != (Object)null)
				{
					for (int j = 0; j < val3.blendShapeCount; j++)
					{
						log.LogInfo((object)("      blendshape " + val3.GetBlendShapeName(j)));
					}
				}
				Material[] sharedMaterials = val.sharedMaterials;
				foreach (Material val4 in sharedMaterials)
				{
					if ((Object)(object)val4 == (Object)null)
					{
						continue;
					}
					List<string> list = new List<string>();
					string[] array = new string[10] { "_MainTex", "_EmissionMap", "_EmissionColor", "_SkinColor", "_ChestTex", "_LegsTex", "_EyeColor", "_EyeTex", "_Glow", "_GlowColor" };
					foreach (string text in array)
					{
						if (val4.HasProperty(text))
						{
							list.Add(text + "=" + ((!text.EndsWith("Tex") && !text.EndsWith("Map")) ? ((object)val4.GetColor(text)) : (Object.op_Implicit((Object)(object)val4.GetTexture(text)) ? ((Object)val4.GetTexture(text)).name : "null")));
						}
					}
					log.LogInfo((object)("      mat " + ((Object)val4).name + " · shader " + ((Object)val4.shader).name + " · kw [" + string.Join(",", val4.shaderKeywords) + "] · " + string.Join(" · ", list)));
				}
				num++;
			}
			Transform[] componentsInChildren2 = ((Component)localPlayer).GetComponentsInChildren<Transform>(true);
			foreach (Transform val5 in componentsInChildren2)
			{
				string text2 = ((Object)val5).name.ToLowerInvariant();
				if (text2.Contains("eye") || text2.Contains("head") || text2.Contains("face") || text2.Contains("beard") || text2.Contains("hair"))
				{
					log.LogInfo((object)$"[T] {Ruta(val5, ((Component)localPlayer).transform)} · y={val5.position.y - ((Component)localPlayer).transform.position.y:0.00} · scale={val5.lossyScale.x:0.###}");
				}
			}
			Console.instance.Print($"Scan done: {num} renderers written to BepInEx/LogOutput.log (search for 'mt_eye scan').");
		}

		private static string Ruta(Transform t, Transform raiz)
		{
			string text = ((Object)t).name;
			Transform parent = t.parent;
			while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)raiz)
			{
				text = ((Object)parent).name + "/" + text;
				parent = parent.parent;
			}
			return text;
		}

		private static ConfigEntry<Color> Entrada(string nombre)
		{
			return (ConfigEntry<Color>)(nombre.ToLowerInvariant() switch
			{
				"foresight" => MTOjosPlugin.ColorPrevision, 
				"farsight" => MTOjosPlugin.ColorVistaLejana, 
				"identification" => MTOjosPlugin.ColorIdentificacion, 
				_ => null, 
			});
		}

		private static bool Leer(string[] a, out Color c)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			c = Color.white;
			if (a.Length == 3 && a[2].StartsWith("#"))
			{
				return ColorUtility.TryParseHtmlString(a[2], ref c);
			}
			if (a.Length < 5 || !F(a[2], out var v) || !F(a[3], out var v2) || !F(a[4], out var v3))
			{
				return false;
			}
			float num = ((v > 1f || v2 > 1f || v3 > 1f) ? 255f : 1f);
			c = new Color(v / num, v2 / num, v3 / num);
			return true;
		}

		private static bool F(string s, out float v)
		{
			return float.TryParse(s.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out v);
		}

		private static void Mostrar()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			Console.instance.Print(string.Format(CultureInfo.InvariantCulture, "Eye flames: {0} · size {1:0.###} · foresight #{2} · farsight #{3} · identification #{4}", MTOjosPlugin.BrilloOjos.Value ? "on" : "off", MTOjosPlugin.DiametroOjo.Value, ColorUtility.ToHtmlStringRGB(MTOjosPlugin.ColorPrevision.Value), ColorUtility.ToHtmlStringRGB(MTOjosPlugin.ColorVistaLejana.Value), ColorUtility.ToHtmlStringRGB(MTOjosPlugin.ColorIdentificacion.Value)));
			Console.instance.Print("Eye flames " + BrilloOjo.Diagnostico());
		}
	}
	public static class Ojos
	{
		public const string Prevision = "MT_OjoPrevision";

		public const string VistaLejana = "MT_OjoVistaLejana";

		public const string Identificacion = "MT_OjoIdentificacion";

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

		private static float _cacheHasta;

		private static Player _cacheJugador;

		private static readonly List<string> Orden = new List<string>();

		public const int MaxOjos = 2;

		public static List<string> Puestos
		{
			get
			{
				Refrescar();
				return Orden;
			}
		}

		private static void Refrescar()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)(object)_cacheJugador)
			{
				Orden.Clear();
				_cacheHasta = 0f;
				_cacheJugador = localPlayer;
			}
			if ((Object)(object)localPlayer == (Object)null)
			{
				Orden.Clear();
			}
			else if (!(Time.time < _cacheHasta))
			{
				_cacheHasta = Time.time + 0.1f;
				Actualizar(localPlayer);
			}
		}

		public static void Registrar()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			try
			{
				Crear("MT_OjoIdentificacion", Tr.Token("ojos_ojo_identificacion"), Tr.Token("ojos_ojo_identificacion_d") + "\n\n" + Tr.Token("ojos_ojo_identificacion_fuente"), "ojo_identificacion", "GreydwarfEye", CraftingStations.Workbench, 2, new RequirementConfig("GreydwarfEye", 5, 0, true), new RequirementConfig("LeatherScraps", 3, 0, true), new RequirementConfig("Resin", 5, 0, true));
				Crear("MT_OjoVistaLejana", Tr.Token("ojos_ojo_vista_lejana"), Tr.Token("ojos_ojo_vista_lejana_d") + "\n\n" + Tr.Token("ojos_ojo_vista_lejana_fuente"), "ojo_vista_lejana", "Crystal", CraftingStations.Forge, 2, new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("GreydwarfEye", 5, 0, true), new RequirementConfig("TrollHide", 2, 0, true));
				Crear("MT_OjoPrevision", Tr.Token("ojos_ojo_prevision"), Tr.Token("ojos_ojo_prevision_d") + "\n\n" + Tr.Token("ojos_ojo_prevision_fuente"), "ojo_prevision", "Ruby", CraftingStations.Forge, 3, new RequirementConfig("Silver", 4, 0, true), new RequirementConfig("Crystal", 3, 0, true), new RequirementConfig("TrophyHatchling", 1, 0, true));
			}
			finally
			{
				PrefabManager.OnVanillaPrefabsAvailable -= Registrar;
			}
		}

		private static void Crear(string prefab, string nombre, string desc, string modelo, string iconoDe, string estacion, int nivel, params RequirementConfig[] reqs)
		{
			//IL_0006: 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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0036: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			CustomItem val = new CustomItem(prefab, "BeltStrength", new ItemConfig
			{
				Name = nombre,
				Description = desc,
				CraftingStation = estacion,
				MinStationLevel = nivel,
				Requirements = reqs
			});
			SharedData shared = val.ItemDrop.m_itemData.m_shared;
			Nombres[shared.m_name] = prefab;
			shared.m_equipStatusEffect = null;
			shared.m_setStatusEffect = null;
			shared.m_setName = "";
			shared.m_setSize = 0;
			string dir = MTOjosPlugin.Dir;
			string text = Path.Combine(Path.Combine(dir, "Icons"), modelo + ".png");
			Sprite val2 = (File.Exists(text) ? AssetUtils.LoadSpriteFromFile(text) : null);
			if ((Object)(object)val2 == (Object)null)
			{
				ItemDrop prefab2 = Cache.GetPrefab<ItemDrop>(iconoDe);
				if ((Object)(object)prefab2 != (Object)null && prefab2.m_itemData.m_shared.m_icons.Length != 0)
				{
					val2 = prefab2.m_itemData.m_shared.m_icons[0];
				}
			}
			if ((Object)(object)val2 != (Object)null)
			{
				shared.m_icons = (Sprite[])(object)new Sprite[1] { val2 };
			}
			shared.m_equipStatusEffect = SE_Ojo.Crear(prefab, shared);
			string text2 = Path.Combine(Path.Combine(dir, "Models"), modelo + ".obj");
			List<string> materialNames;
			Mesh val3 = ObjModel.Load(text2, out materialNames);
			if ((Object)(object)val3 != (Object)null)
			{
				GameObject prefab3 = PrefabManager.Instance.GetPrefab("Club");
				object obj;
				if (prefab3 == null)
				{
					obj = null;
				}
				else
				{
					MeshRenderer componentInChildren = prefab3.GetComponentInChildren<MeshRenderer>(true);
					obj = ((componentInChildren != null) ? ((Renderer)componentInChildren).sharedMaterial : null);
				}
				Material template = (Material)obj;
				ObjModel.ReplaceVisual(val.ItemPrefab, val3, ObjModel.Materials(materialNames, template, Path.ChangeExtension(text2, ".mtl")));
			}
			else
			{
				MTOjosPlugin.Log.LogWarning((object)("Modelo no encontrado: " + text2));
			}
			ItemManager.Instance.AddItem(val);
		}

		public static bool EnInventario(string prefab)
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return false;
			}
			foreach (ItemData allItem in ((Humanoid)localPlayer).GetInventory().GetAllItems())
			{
				if (Nombres.TryGetValue(allItem.m_shared.m_name, out var value) && value == prefab)
				{
					return true;
				}
			}
			return false;
		}

		public static bool Equipado(string prefab)
		{
			Refrescar();
			return Orden.Contains(prefab);
		}

		private static void Actualizar(Player p)
		{
			Dictionary<string, ItemData> ahora = new Dictionary<string, ItemData>();
			foreach (ItemData equippedItem in ((Humanoid)p).GetInventory().GetEquippedItems())
			{
				if (Nombres.TryGetValue(equippedItem.m_shared.m_name, out var value) && !ahora.ContainsKey(value))
				{
					ahora[value] = equippedItem;
				}
			}
			string text = string.Join(",", Orden.ToArray());
			Orden.RemoveAll((string o) => !ahora.ContainsKey(o));
			foreach (string key2 in ahora.Keys)
			{
				if (!Orden.Contains(key2))
				{
					Orden.Add(key2);
				}
			}
			while (Orden.Count > 2)
			{
				string key = Orden[0];
				Orden.RemoveAt(0);
				((Humanoid)p).UnequipItem(ahora[key], true);
				((Character)p).Message((MessageType)2, Tr.Get("ojos_can_only_wear_2_eyes"), 0, (Sprite)null, false);
			}
			string text2 = string.Join(",", Orden.ToArray());
			if (text != text2)
			{
				MTOjosPlugin.Log.LogInfo((object)("Ojos puestos: " + ((text2.Length > 0) ? text2 : "ninguno")));
			}
		}
	}
	[HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")]
	public static class OjosDropPatch
	{
		private const string I = "MT_OjoIdentificacion";

		private const string V = "MT_OjoVistaLejana";

		private const string P = "MT_OjoPrevision";

		internal static readonly Dictionary<string, KeyValuePair<string, float>[]> Table = new Dictionary<string, KeyValuePair<string, float>[]>
		{
			{
				"Greydwarf_Elite",
				new KeyValuePair<string, float>[1] { D("MT_OjoIdentificacion", 0.01f) }
			},
			{
				"Greydwarf_Shaman",
				new KeyValuePair<string, float>[1] { D("MT_OjoIdentificacion", 0.02f) }
			},
			{
				"gd_king",
				new KeyValuePair<string, float>[1] { D("MT_OjoIdentificacion", 0.3f) }
			},
			{
				"Draugr_Elite",
				new KeyValuePair<string, float>[1] { D("MT_OjoVistaLejana", 0.015f) }
			},
			{
				"Wraith",
				new KeyValuePair<string, float>[1] { D("MT_OjoVistaLejana", 0.03f) }
			},
			{
				"Bonemass",
				new KeyValuePair<string, float>[1] { D("MT_OjoVistaLejana", 0.3f) }
			},
			{
				"Fenring",
				new KeyValuePair<string, float>[1] { D("MT_OjoVistaLejana", 0.01f) }
			},
			{
				"Fenring_Cultist",
				new KeyValuePair<string, float>[1] { D("MT_OjoPrevision", 0.02f) }
			},
			{
				"GoblinShaman",
				new KeyValuePair<string, float>[1] { D("MT_OjoPrevision", 0.02f) }
			},
			{
				"Dragon",
				new KeyValuePair<string, float>[1] { D("MT_OjoPrevision", 0.3f) }
			},
			{
				"GoblinKing",
				new KeyValuePair<string, float>[1] { D("MT_OjoPrevision", 0.3f) }
			}
		};

		private static KeyValuePair<string, float> D(string item, float chance)
		{
			return new KeyValuePair<string, float>(item, chance);
		}

		private static void Postfix(CharacterDrop __instance, List<KeyValuePair<GameObject, int>> __result)
		{
			if (__result == null || (Object)(object)ObjectDB.instance == (Object)null || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			string key = ((Object)((Component)__instance).gameObject).name.Replace("(Clone)", "").Trim();
			if (!Table.TryGetValue(key, out var value))
			{
				return;
			}
			float value2 = MTOjosPlugin.BotinMultiplicador.Value;
			KeyValuePair<string, float>[] array = value;
			for (int i = 0; i < array.Length; i++)
			{
				KeyValuePair<string, float> keyValuePair = array[i];
				if (!(Random.value > keyValuePair.Value * value2))
				{
					GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(keyValuePair.Key);
					if ((Object)(object)itemPrefab != (Object)null)
					{
						__result.Add(new KeyValuePair<GameObject, int>(itemPrefab, 1));
					}
				}
			}
		}
	}
	public class Prevision : MonoBehaviour
	{
		public const string SEName = "SE_MT_Prevision";

		public static StatusEffect SE;

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

		private static readonly Dictionary<int, float> UltimoAviso = new Dictionary<int, float>();

		private static readonly Dictionary<string, Dictionary<string, Attack>> Ataques = new Dictionary<string, Dictionary<string, Attack>>();

		public static bool Activo { get; private set; }

		private void Awake()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			SE = ScriptableObject.CreateInstance<StatusEffect>();
			((Object)SE).name = "SE_MT_Prevision";
			SE.m_name = Tr.Token("ojos_se_prevision");
			SE.m_tooltip = Tr.Token("ojos_se_prevision_tt");
			SE.m_ttl = 0f;
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(SE, false));
		}

		private void Update()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				if (Activo)
				{
					Apagar(null, null);
				}
				Fantasma.VaciarPool();
				return;
			}
			bool flag = Desgaste.Funciona("MT_OjoPrevision") && !((Character)localPlayer).IsDead();
			if (flag && !Activo)
			{
				Encender(localPlayer);
			}
			else if (!flag && Activo)
			{
				Apagar(localPlayer, null);
			}
		}

		private static void Encender(Player p)
		{
			Activo = true;
			((Character)p).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("SE_MT_Prevision"), false, 0, 0f, (short)0);
		}

		private static void Apagar(Player p, string msg)
		{
			Activo = false;
			Fantasma.TerminarTodos();
			UltimoAviso.Clear();
			if (!((Object)(object)p == (Object)null))
			{
				((Character)p).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_MT_Prevision"), true);
				if (msg != null)
				{
					((Character)p).Message((MessageType)1, msg, 0, (Sprite)null, false);
				}
			}
		}

		private void OnDestroy()
		{
			Fantasma.VaciarPool();
		}

		public static void OnTrigger(ZSyncAnimation z, string trigger)
		{
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Invalid comparison between Unknown and I4
			if (!Activo || string.IsNullOrEmpty(trigger) || !Desgaste.Funciona("MT_OjoPrevision"))
			{
				return;
			}
			try
			{
				Player localPlayer = Player.m_localPlayer;
				Character component = ((Component)z).GetComponent<Character>();
				if ((Object)(object)localPlayer == (Object)null || (Object)(object)component == (Object)null || component.IsPlayer() || component.IsDead() || component.IsTamed())
				{
					return;
				}
				BaseAI baseAI = component.GetBaseAI();
				if ((Object)(object)baseAI == (Object)null || !BaseAI.IsEnemy(component, (Character)(object)localPlayer))
				{
					return;
				}
				Attack val = BuscarAtaque(component, trigger);
				string text = Utils.GetPrefabName(((Component)component).gameObject) + "/" + trigger;
				if (Registrados.Add(text))
				{
					MTOjosPlugin.Log.LogInfo((object)("Previsión: '" + text + "' → " + ((val != null) ? "ataque" : "no es ataque")));
				}
				if (val == null)
				{
					return;
				}
				Vector3 val2 = ((Component)localPlayer).transform.position - ((Component)component).transform.position;
				float magnitude = ((Vector3)(ref val2)).magnitude;
				bool num = (Object)(object)baseAI.GetTargetCreature() == (Object)(object)localPlayer && magnitude <= MTOjosPlugin.PrevDistObjetivo.Value;
				bool flag = magnitude <= MTOjosPlugin.PrevDistCerca.Value && Vector3.Angle(((Component)component).transform.forward, val2) < 60f;
				if (!num && !flag)
				{
					return;
				}
				int instanceID = ((Object)component).GetInstanceID();
				if (UltimoAviso.TryGetValue(instanceID, out var value) && Time.time - value < 0.15f)
				{
					return;
				}
				UltimoAviso[instanceID] = Time.time;
				if (UltimoAviso.Count > 64)
				{
					UltimoAviso.Clear();
				}
				float value2 = MTOjosPlugin.PrevManaPorGolpe.Value;
				if (!(localPlayer.GetEitr() < value2))
				{
					bool flag2 = (int)val.m_attackType == 4;
					bool flag3 = Fantasma.Mostrar(component, trigger, magnitude);
					if (flag3)
					{
						((Character)localPlayer).UseEitr(v

plugins/MT.Paso/MT.Paso.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Managers;
using Jotunn.Utils;
using MT.Core;
using MT.Core.I18n;
using MT.Core.Touki;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("MT.Paso")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ffb23be1655489b43ebd87164178fc39ecbb9f14")]
[assembly: AssemblyProduct("MT.Paso")]
[assembly: AssemblyTitle("MT.Paso")]
[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 MT
{
	public static class Magia_FxBridge
	{
		public static void Dust(Vector3 pos)
		{
			//IL_002a: 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)
			GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("fx_land") : null);
			if ((Object)(object)val != (Object)null)
			{
				Object.Instantiate<GameObject>(val, pos, Quaternion.identity);
			}
		}
	}
}
namespace MT.Paso
{
	public class Afterimage : MonoBehaviour
	{
		private const float FadeSeconds = 0.35f;

		private const int Copies = 5;

		private static readonly string[] ShaderCandidates = new string[4] { "Legacy Shaders/Particles/Alpha Blended", "Sprites/Default", "Particles/Standard Unlit", "Unlit/Transparent" };

		private static Shader _shader;

		private static bool _searched;

		private Material[] _materials;

		private float _age;

		private Color _color;

		public static void SpawnTrail(Player p, Vector3 start, Vector3 end, Color color)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (FindShader())
			{
				SkinnedMeshRenderer[] componentsInChildren = ((Component)p).GetComponentsInChildren<SkinnedMeshRenderer>();
				Vector3 val = ((Component)p).transform.position - start;
				for (int i = 0; i < 5; i++)
				{
					Vector3 rootPos = Vector3.Lerp(start, end, (float)i / 5f) + val;
					Spawn(componentsInChildren, ((Component)p).transform, rootPos, color * new Color(1f, 1f, 1f, 1f - (float)i / 5f));
				}
			}
		}

		private static bool FindShader()
		{
			if (_searched)
			{
				return (Object)(object)_shader != (Object)null;
			}
			_searched = true;
			string[] shaderCandidates = ShaderCandidates;
			for (int i = 0; i < shaderCandidates.Length; i++)
			{
				_shader = Shader.Find(shaderCandidates[i]);
				if ((Object)(object)_shader != (Object)null)
				{
					break;
				}
			}
			if ((Object)(object)_shader == (Object)null)
			{
				Logger.CreateLogSource("MT Paso").LogWarning((object)"No hay shader transparente para las siluetas (asset A-P1 pendiente).");
			}
			return (Object)(object)_shader != (Object)null;
		}

		private static void Spawn(SkinnedMeshRenderer[] renderers, Transform root, Vector3 rootPos, Color color)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0011: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			GameObject val = new GameObject("MT_Afterimage");
			val.transform.SetPositionAndRotation(rootPos, root.rotation);
			Afterimage afterimage = val.AddComponent<Afterimage>();
			afterimage._color = color;
			List<Material> list = new List<Material>();
			foreach (SkinnedMeshRenderer val2 in renderers)
			{
				if (((Renderer)val2).enabled && ((Component)val2).gameObject.activeInHierarchy && !((Object)(object)val2.sharedMesh == (Object)null))
				{
					Mesh val3 = new Mesh();
					val2.BakeMesh(val3);
					GameObject val4 = new GameObject("part");
					val4.transform.SetParent(val.transform, false);
					val4.transform.localPosition = root.InverseTransformPoint(((Component)val2).transform.position);
					val4.transform.localRotation = Quaternion.Inverse(root.rotation) * ((Component)val2).transform.rotation;
					val4.AddComponent<MeshFilter>().sharedMesh = val3;
					Material val5 = new Material(_shader)
					{
						color = color
					};
					((Renderer)val4.AddComponent<MeshRenderer>()).sharedMaterial = val5;
					list.Add(val5);
				}
			}
			afterimage._materials = list.ToArray();
		}

		private void Update()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			_age += Time.deltaTime;
			float num = Mathf.Clamp01(1f - _age / 0.35f);
			Material[] materials = _materials;
			for (int i = 0; i < materials.Length; i++)
			{
				materials[i].color = new Color(_color.r, _color.g, _color.b, _color.a * num);
			}
			if (_age >= 0.35f)
			{
				MeshFilter[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshFilter>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Object.Destroy((Object)(object)componentsInChildren[i].sharedMesh);
				}
				materials = _materials;
				for (int i = 0; i < materials.Length; i++)
				{
					Object.Destroy((Object)(object)materials[i]);
				}
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	public static class Aire
	{
		private static bool _usedAirJump;

		private static bool _usedAirDash;

		private static float _lastImpulse = -999f;

		public const int NivelDobleSalto = 5;

		public const int NivelImpulso = 4;

		public const int NivelImpulsoAire = 8;

		private static Rigidbody Body(Player p)
		{
			return Campos.Cuerpo.Invoke((Character)(object)p);
		}

		public static void Tick(Player p)
		{
			if (((Character)p).IsOnGround() || ((Character)p).IsSwimming())
			{
				_usedAirJump = false;
				_usedAirDash = false;
			}
		}

		private static bool Pay(Player p, float cost)
		{
			if (!Manto.Active || Manto.Charge < cost * Manto.CostMultiplier(p))
			{
				return false;
			}
			Manto.Spend(p, cost, true);
			return true;
		}

		private static void ResetFall(Player p)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Campos.AlturaMaxAire.Invoke((Character)(object)p) = ((Component)p).transform.position.y;
		}

		public static bool TryAirJump(Player p)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			if (Estado.Levitando)
			{
				return false;
			}
			if (_usedAirJump || ((Character)p).IsOnGround() || ((Character)p).IsSwimming() || ((Character)p).IsAttached() || ToukiRules.Level(p) < 5)
			{
				return false;
			}
			if (!Pay(p, 8f))
			{
				return false;
			}
			Rigidbody val = Body(p);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			_usedAirJump = true;
			Vector3 linearVelocity = val.linearVelocity;
			float num = ((Character)p).m_jumpForce * (1f + (float)ToukiRules.Level(p) * CoreConfig.SaltoPorNivel.Value);
			val.linearVelocity = new Vector3(linearVelocity.x, Mathf.Max(linearVelocity.y, 0f) + num, linearVelocity.z);
			ResetFall(p);
			Magia_FxBridge.Dust(((Component)p).transform.position);
			Manto.TrainDominio(p, 0.3f);
			return true;
		}

		public static bool TryDodgeImpulse(Player p, Vector3 dir)
		{
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			if (Estado.Levitando)
			{
				return false;
			}
			if (!Manto.Active || ((Character)p).IsAttached() || Time.time - _lastImpulse < 0.6f)
			{
				return false;
			}
			int num = ToukiRules.Level(p);
			Rigidbody val = Body(p);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			if (!((Character)p).IsOnGround() && !((Character)p).IsSwimming())
			{
				if (_usedAirDash || num < 8 || !Pay(p, 12f))
				{
					return false;
				}
				_usedAirDash = true;
				Vector3 val2 = (((Object)(object)GameCamera.instance != (Object)null) ? ((Component)GameCamera.instance).transform.forward : ((Component)p).transform.forward);
				val.linearVelocity = ((Vector3)(ref val2)).normalized * (12f + (float)num) + Vector3.up * 2f;
			}
			else
			{
				if (num < 4 || !((Character)p).IsRunning() || !Pay(p, 6f))
				{
					return false;
				}
				dir.y = 0f;
				if (((Vector3)(ref dir)).sqrMagnitude < 0.01f)
				{
					dir = ((Component)p).transform.forward;
				}
				val.linearVelocity = ((Vector3)(ref dir)).normalized * (14f + (float)num * 0.8f) + Vector3.up * 1.5f;
			}
			_lastImpulse = Time.time;
			ResetFall(p);
			Magia_FxBridge.Dust(((Component)p).transform.position);
			if (MTPasoPlugin.Afterimages.Value)
			{
				Vector3 position = ((Component)p).transform.position;
				Vector3 position2 = ((Component)p).transform.position;
				Vector3 linearVelocity = val.linearVelocity;
				Afterimage.SpawnTrail(p, position, position2 + ((Vector3)(ref linearVelocity)).normalized * 3f, MTPasoPlugin.AfterimageColor.Value);
			}
			PasoController.MarkDash();
			Manto.TrainDominio(p, 0.5f);
			return true;
		}
	}
	[HarmonyPatch(typeof(Character), "Jump")]
	public static class AirJumpPatch
	{
		private static bool Prefix(Character __instance)
		{
			Player val = (Player)(object)((__instance is Player) ? __instance : null);
			if (val == null || (Object)(object)val != (Object)(object)Player.m_localPlayer || ((Character)val).IsOnGround())
			{
				return true;
			}
			return !Aire.TryAirJump(val);
		}
	}
	[HarmonyPatch(typeof(Player), "Dodge")]
	public static class DodgeImpulsePatch
	{
		private static bool Prefix(Player __instance, Vector3 dodgeDir)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			return !Aire.TryDodgeImpulse(__instance, dodgeDir);
		}
	}
	[BepInPlugin("mushokutensei.paso", "MT Paso", "2.1.13")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class MTPasoPlugin : BaseUnityPlugin
	{
		public const string Guid = "mushokutensei.paso";

		public const string Version = "2.1.13";

		public const string ButtonName = "MT_Paso";

		public static ConfigEntry<bool> Afterimages;

		public static ConfigEntry<Color> AfterimageColor;

		public static ConfigEntry<bool> LineasVelocidad;

		private void Awake()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00b6: 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_00ca: Expected O, but got Unknown
			Tr.Load(typeof(MTPasoPlugin).Assembly, Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location));
			Afterimages = ((BaseUnityPlugin)this).Config.Bind<bool>("Visual", "ImagenesResiduales", true, "Dibujar siluetas residuales durante el Paso de Tōki.");
			AfterimageColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Visual", "ColorSiluetas", new Color(1f, 0.6f, 0.2f, 0.45f), "Color de las siluetas (el alfa es la transparencia).");
			LineasVelocidad = ((BaseUnityPlugin)this).Config.Bind<bool>("Visual", "LineasVelocidad", true, "Líneas de velocidad en el personaje al correr con el manto de tōki y en el Paso.");
			InputManager.Instance.AddButton("mushokutensei.paso", new ButtonConfig
			{
				Name = "MT_Paso",
				Key = (KeyCode)122,
				ActiveInCustomGUI = false
			});
			((Component)this).gameObject.AddComponent<PasoController>();
			((Component)this).gameObject.AddComponent<VelocidadLineas>();
			Parches.Aplicar("mushokutensei.paso", ((object)this).GetType().Assembly, ((BaseUnityPlugin)this).Logger);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"MT Paso 2.1.13 cargado");
		}
	}
	public class PasoController : MonoBehaviour
	{
		private const float InvulnerableSeconds = 0.15f;

		private float _cooldownUntil;

		private float _cooldownTotal;

		private int _decimas = -1;

		private string _textoEspera;

		public static float LastDashTime { get; private set; } = -9999f;

		public static bool Invulnerable => Time.time - LastDashTime < 0.15f;

		private static float Distance(int l)
		{
			return Mathf.Lerp(5f, 15f, (float)(l - 4) / 6f);
		}

		private static float Cost(int l)
		{
			return Mathf.Lerp(12f, 15f, (float)(l - 4) / 6f);
		}

		private static float Cooldown(int l)
		{
			return Mathf.Lerp(6f, 3f, (float)(l - 4) / 6f);
		}

		public static void MarkDash()
		{
			LastDashTime = Time.time;
		}

		private void Update()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				Aire.Tick(localPlayer);
			}
			if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || !MTKeys.Down(MTKeys.Paso) || !CanTakeInput())
			{
				return;
			}
			int num = ToukiRules.Level(localPlayer);
			if (num < 4)
			{
				((Character)localPlayer).Message((MessageType)1, Tr.Get("paso_need_toki_level_4"), 0, (Sprite)null, false);
			}
			else if (!Manto.Active)
			{
				((Character)localPlayer).Message((MessageType)1, Tr.Get("paso_activate_toki_mantle_f1"), 0, (Sprite)null, false);
			}
			else if (!((Character)localPlayer).IsAttached() && !((Character)localPlayer).IsTeleporting())
			{
				if (Time.time < _cooldownUntil)
				{
					((Character)localPlayer).Message((MessageType)1, string.Format(Tr.Get("paso_cooldown"), (_cooldownUntil - Time.time).ToString("0.0")), 0, (Sprite)null, false);
				}
				else if (!((Character)localPlayer).IsOnGround())
				{
					((Character)localPlayer).Message((MessageType)1, Tr.Get("paso_need_ground"), 0, (Sprite)null, false);
				}
				else if (Manto.Charge < Cost(num) * Manto.CostMultiplier(localPlayer))
				{
					((Character)localPlayer).Message((MessageType)1, Tr.Get("paso_not_enough_toki"), 0, (Sprite)null, false);
				}
				else
				{
					Dash(localPlayer, num);
				}
			}
		}

		private void OnGUI()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Event.current.type != 7 || (Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)Hud.instance == (Object)null || Menu.IsVisible() || _cooldownTotal <= 0f)
			{
				return;
			}
			float num = _cooldownUntil - Time.time;
			if (num < -1.2f)
			{
				return;
			}
			float scale = MTGui.Scale;
			float num2 = 300f * scale;
			float num3 = 6f * scale;
			float num4 = (float)Screen.width * CoreConfig.BarraX.Value - num2 / 2f;
			float num5 = (float)Screen.height * CoreConfig.BarraY.Value + 18f * scale;
			if (num > 0f)
			{
				MTGui.Bar(new Rect(num4, num5, num2, num3), 1f - num / _cooldownTotal, MTGui.Texto);
				int num6 = Mathf.CeilToInt(num * 10f);
				if (num6 != _decimas || _textoEspera == null)
				{
					_decimas = num6;
					_textoEspera = string.Format(Tr.Get("paso_cooldown"), ((float)num6 / 10f).ToString("0.0"));
				}
				MTGui.Label(new Rect(num4, num5 + num3, num2, 18f * scale), _textoEspera, 13, MTGui.Texto, (TextAnchor)1, false);
			}
			else
			{
				MTGui.Label(new Rect(num4, num5, num2, 18f * scale), Tr.Get("paso_ready"), 14, MTGui.Oro, (TextAnchor)1, true);
			}
		}

		private static bool EnemigoDelante(Player p, Vector3 desde, Vector3 dir)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			foreach (Character allCharacter in Character.GetAllCharacters())
			{
				if (!((Object)(object)allCharacter == (Object)null) && !((Object)(object)allCharacter == (Object)(object)p) && !allCharacter.IsDead() && BaseAI.IsEnemy((Character)(object)p, allCharacter))
				{
					Vector3 val = ((Component)allCharacter).transform.position - desde;
					val.y = 0f;
					if (((Vector3)(ref val)).sqrMagnitude < 225f && Vector3.Dot(((Vector3)(ref val)).normalized, dir) > 0.7f)
					{
						return true;
					}
				}
			}
			return false;
		}

		private static bool CanTakeInput()
		{
			if (((Object)(object)Chat.instance == (Object)null || !Chat.instance.HasFocus()) && !Console.IsVisible() && !Menu.IsVisible() && !InventoryGui.IsVisible() && !TextInput.IsVisible())
			{
				return !Minimap.IsOpen();
			}
			return false;
		}

		private void Dash(Player p, int level)
		{
			//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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: 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)
			Rigidbody val = Campos.Cuerpo.Invoke((Character)(object)p);
			CapsuleCollider val2 = Campos.Colision.Invoke((Character)(object)p);
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				return;
			}
			Vector3 val3 = Campos.DirMovimiento.Invoke((Character)(object)p);
			if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
			{
				val3 = ((Component)p).transform.forward;
			}
			val3.y = 0f;
			((Vector3)(ref val3)).Normalize();
			float num = Distance(level);
			Vector3 position = val.position;
			float num2 = val2.radius * 0.9f;
			Vector3 val4 = position + Vector3.up * num2;
			Vector3 val5 = position + Vector3.up * (val2.height - num2);
			int mask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" });
			RaycastHit val6 = default(RaycastHit);
			if (Physics.CapsuleCast(val4, val5, num2, val3, ref val6, num, mask, (QueryTriggerInteraction)1))
			{
				num = Mathf.Max(0f, ((RaycastHit)(ref val6)).distance - 0.2f);
			}
			if (!(num < 1f))
			{
				Vector3 val7 = position + val3 * num;
				RaycastHit val8 = default(RaycastHit);
				if (Physics.Raycast(val7 + Vector3.up * 2f, Vector3.down, ref val8, 6f, mask, (QueryTriggerInteraction)1))
				{
					val7.y = ((RaycastHit)(ref val8)).point.y;
				}
				Manto.Spend(p, Cost(level), true);
				if (MTPasoPlugin.Afterimages.Value)
				{
					Afterimage.SpawnTrail(p, position, val7, MTPasoPlugin.AfterimageColor.Value);
				}
				val.position = val7;
				((Component)p).transform.position = val7;
				val.linearVelocity = val3 * 2f;
				LastDashTime = Time.time;
				_cooldownUntil = Time.time + Cooldown(level);
				if (level >= 7 && EnemigoDelante(p, position, val3))
				{
					_cooldownUntil = Time.time + Cooldown(level) * 0.5f;
				}
				_cooldownTotal = _cooldownUntil - Time.time;
				Manto.TrainDominio(p, 1f);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "RPC_Damage")]
	public static class DashInvulnerablePatch
	{
		private static bool Prefix(Character __instance)
		{
			if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				return !PasoController.Invulnerable;
			}
			return true;
		}
	}
	public class VelocidadLineas : MonoBehaviour
	{
		private class Trazo
		{
			public LineRenderer Lr;

			public Vector3 Inicio;

			public Vector3 Dir;

			public float Edad = -1f;

			public float Largo;

			public float Ancho;
		}

		private const int Max = 28;

		private const float Vida = 0.28f;

		private readonly Trazo[] _trazos = new Trazo[28];

		private Material _mat;

		private float _proximo;

		private float _rafagaHasta;

		private float _ultimoPaso = -1f;

		private Vector3 _lastPos;

		private Vector3 _vel;

		private bool _hasLast;

		private static readonly Color Blanco = new Color(1f, 0.97f, 0.92f, 1f);

		private void Crear()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			_mat = new Material(Shader.Find("Sprites/Default"));
			AnimationCurve widthCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
			{
				new Keyframe(0f, 0.022f),
				new Keyframe(1f, 0.002f)
			});
			for (int i = 0; i < 28; i++)
			{
				GameObject val = new GameObject("MT_LineaVelocidad");
				val.transform.SetParent(((Component)this).transform, false);
				LineRenderer val2 = val.AddComponent<LineRenderer>();
				((Renderer)val2).sharedMaterial = _mat;
				val2.useWorldSpace = true;
				((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)val2).receiveShadows = false;
				val2.numCapVertices = 1;
				val2.widthCurve = widthCurve;
				val2.positionCount = 2;
				((Renderer)val2).enabled = false;
				_trazos[i] = new Trazo
				{
					Lr = val2
				};
			}
		}

		private void Update()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || !MTPasoPlugin.LineasVelocidad.Value)
			{
				Apagar();
				_hasLast = false;
				return;
			}
			if ((Object)(object)_mat == (Object)null)
			{
				Crear();
			}
			float deltaTime = Time.deltaTime;
			Vector3 position = ((Component)localPlayer).transform.position;
			Vector3 val = ((_hasLast && deltaTime > 0f) ? ((position - _lastPos) / deltaTime) : Vector3.zero);
			_lastPos = position;
			_hasLast = true;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 2500f)
			{
				_vel = Vector3.Lerp(_vel, val, Mathf.Clamp01(deltaTime * 10f));
			}
			if (PasoController.LastDashTime != _ultimoPaso && Time.time - PasoController.LastDashTime < 0.1f)
			{
				_ultimoPaso = PasoController.LastDashTime;
				_rafagaHasta = Time.time + 0.35f;
				for (int i = 0; i < 12; i++)
				{
					Lanzar(localPlayer, ((Component)localPlayer).transform.forward, 1.6f, 2.6f);
				}
			}
			float magnitude = ((Vector3)(ref _vel)).magnitude;
			bool num = Manto.Active && ((Character)localPlayer).IsRunning() && magnitude > 4f && ((Character)localPlayer).IsOnGround();
			bool flag = Time.time < _rafagaHasta;
			if (num || flag)
			{
				_proximo -= deltaTime;
				if (_proximo <= 0f)
				{
					_proximo = (flag ? 0.015f : Random.Range(0.04f, 0.07f));
					Vector3 adelante = ((magnitude > 0.5f) ? (_vel / magnitude) : ((Component)localPlayer).transform.forward);
					Lanzar(localPlayer, adelante, flag ? 1.2f : 0.6f, flag ? 2f : 1.2f);
				}
			}
			for (int j = 0; j < 28; j++)
			{
				Animar(_trazos[j], deltaTime);
			}
		}

		private void Lanzar(Player p, Vector3 adelante, float largoMin, float largoMax)
		{
			//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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			Trazo trazo = null;
			for (int i = 0; i < 28; i++)
			{
				if (_trazos[i].Edad < 0f)
				{
					trazo = _trazos[i];
					break;
				}
			}
			if (trazo != null)
			{
				Vector3 val = Vector3.Cross(Vector3.up, adelante);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				float num = Random.Range(0f, (float)Math.PI * 2f);
				float num2 = Random.Range(0.35f, 0.7f);
				trazo.Inicio = ((Component)p).transform.position + Vector3.up * Random.Range(0.25f, 1.75f) + normalized * Mathf.Cos(num) * num2 + Vector3.up * Mathf.Sin(num) * num2 * 0.25f + adelante * Random.Range(-0.2f, 0.4f);
				trazo.Dir = -adelante;
				trazo.Largo = Random.Range(largoMin, largoMax);
				trazo.Ancho = Random.Range(0.6f, 1.2f);
				trazo.Edad = 0f;
				trazo.Lr.widthMultiplier = trazo.Ancho;
				((Renderer)trazo.Lr).enabled = true;
			}
		}

		private static void Animar(Trazo tr, float dt)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			if (!(tr.Edad < 0f))
			{
				tr.Edad += dt;
				float num = tr.Edad / 0.28f;
				if (num >= 1f)
				{
					tr.Edad = -1f;
					((Renderer)tr.Lr).enabled = false;
					return;
				}
				float num2 = tr.Largo * Mathf.Min(1f, num * 3f);
				Vector3 val = tr.Inicio + tr.Dir * (tr.Largo * 0.6f * num);
				tr.Lr.SetPosition(0, val);
				tr.Lr.SetPosition(1, val + tr.Dir * num2);
				float a = Mathf.Clamp01((1f - num) / 0.5f) * 0.8f;
				Color blanco = Blanco;
				blanco.a = a;
				Color endColor = blanco;
				endColor.a = 0f;
				tr.Lr.startColor = blanco;
				tr.Lr.endColor = endColor;
			}
		}

		private void Apagar()
		{
			if ((Object)(object)_mat == (Object)null)
			{
				return;
			}
			for (int i = 0; i < 28; i++)
			{
				if (_trazos[i].Edad >= 0f)
				{
					_trazos[i].Edad = -1f;
					((Renderer)_trazos[i].Lr).enabled = false;
				}
			}
		}
	}
}