Decompiled source of RelicsOfAsgard v1.0.0

RelicsOfAsgard.dll

Decompiled 5 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using RelicsOfAsgard.Armas;
using RelicsOfAsgard.Comandos;
using RelicsOfAsgard.Configuracion;
using RelicsOfAsgard.Efectos;
using RelicsOfAsgard.Lugares;
using RelicsOfAsgard.Mecanicas;
using RelicsOfAsgard.Parches;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("RelicsOfAsgard")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RelicsOfAsgard")]
[assembly: AssemblyTitle("RelicsOfAsgard")]
[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 RelicsOfAsgard
{
	[BepInPlugin("relicsofasgard.valheim", "Relics of Asgard", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	internal class Plugin : BaseUnityPlugin
	{
		public const string PluginGUID = "relicsofasgard.valheim";

		public const string PluginName = "Relics of Asgard";

		public const string PluginVersion = "1.0.0";

		private readonly Harmony _harmony = new Harmony("relicsofasgard.valheim");

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			ConfigReliquias.Inicializar(((BaseUnityPlugin)this).Config);
			Fx.Inicializar(((BaseUnityPlugin)this).Config);
			Traducciones.Cargar();
			RegistroArmas.Inicializar();
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ComandoInfo());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ComandoEquilibrio());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ComandoMarca());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ComandoSangrado());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ComandoEfecto());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ComandoGram());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ComandoLugares());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ComandoEspalda());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ComandoFx());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ComandoDps());
			_harmony.PatchAll();
			TajoGram.Inicializar();
			Hrimnir.Inicializar();
			LugarReliquia.Inicializar();
			VegvisirReliquias.Inicializar();
			PrefabManager.OnVanillaPrefabsAvailable += InformarAnimaciones;
			((Component)this).gameObject.AddComponent<MarcaVisual>();
			((Component)this).gameObject.AddComponent<CongelacionVisual>();
			((Component)this).gameObject.AddComponent<GestoLlamada>();
			((Component)this).gameObject.AddComponent<SangradoVisual>();
			Registro.Info("Relics of Asgard 1.0.0 cargado correctamente.");
		}

		private static void InformarAnimaciones()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= InformarAnimaciones;
			if (!ConfigReliquias.ModoDepuracion.Value)
			{
				return;
			}
			try
			{
				Registro.Info("Animaciones (Gram): " + Gram.InformeAnimaciones());
			}
			catch (Exception arg)
			{
				Registro.Error($"Informe de animaciones: {arg}");
			}
		}

		private void OnDestroy()
		{
			_harmony.UnpatchSelf();
		}
	}
	internal static class Registro
	{
		public static void Info(string msg)
		{
			Logger.LogInfo((object)msg);
		}

		public static void Aviso(string msg)
		{
			Logger.LogWarning((object)msg);
		}

		public static void Error(string msg)
		{
			Logger.LogError((object)msg);
		}

		public static void Depurar(string msg)
		{
			if (ConfigReliquias.ModoDepuracion != null && ConfigReliquias.ModoDepuracion.Value)
			{
				Logger.LogInfo((object)("[Depuración] " + msg));
			}
		}
	}
	internal static class Traducciones
	{
		private const string Prefijo = "RelicsOfAsgard.Traducciones.";

		public static void Cargar()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
			foreach (string text in manifestResourceNames)
			{
				if (!text.StartsWith("RelicsOfAsgard.Traducciones.") || !text.EndsWith(".json"))
				{
					continue;
				}
				string text2 = text.Substring("RelicsOfAsgard.Traducciones.".Length, text.Length - "RelicsOfAsgard.Traducciones.".Length - ".json".Length);
				using (Stream stream = executingAssembly.GetManifestResourceStream(text))
				{
					using StreamReader streamReader = new StreamReader(stream);
					localization.AddJsonFile(text2, streamReader.ReadToEnd());
				}
				Registro.Depurar("Traducciones cargadas: " + text2);
			}
		}
	}
}
namespace RelicsOfAsgard.Cosmetics
{
	[DefaultExecutionOrder(1100)]
	public sealed class HrimnirPendant : MonoBehaviour
	{
		public Vector3 localTip;

		public Vector3 localOutward;

		[Range(1f, 15f)]
		public float damping = 5.2f;

		[Range(30f, 120f)]
		public float maximumAngle = 96f;

		private Quaternion restRotation;

		private Vector3 previousAnchor;

		private Vector3 tip;

		private Vector3 velocity;

		private bool initialized;

		private void Awake()
		{
			//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)
			restRotation = ((Component)this).transform.localRotation;
		}

		private void OnEnable()
		{
			initialized = false;
		}

		private void OnDisable()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (initialized)
			{
				((Component)this).transform.localRotation = restRotation;
			}
			initialized = false;
		}

		private void LateUpdate()
		{
			Step(Time.deltaTime);
		}

		private void Step(float dt)
		{
			//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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00c8: 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_00cf: 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_00e6: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: 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_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_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_0166: 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_0172: 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_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_0195: 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_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_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)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: 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_0280: 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_028b: 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_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: 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_01cc: 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_01e2: 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_01ee: 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_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: 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_0229: 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_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: 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_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_024d: 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_0200: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)this).transform.position;
			Quaternion val = (Object.op_Implicit((Object)(object)((Component)this).transform.parent) ? (((Component)this).transform.parent.rotation * restRotation) : restRotation);
			Vector3 val2 = val * Vector3.Scale(localTip, ((Component)this).transform.lossyScale);
			float magnitude = ((Vector3)(ref val2)).magnitude;
			if (magnitude < 0.0001f)
			{
				return;
			}
			Vector3 val3 = val2 / magnitude;
			Vector3 val4 = val * localOutward;
			Vector3 normalized = ((Vector3)(ref val4)).normalized;
			if (initialized && !(dt > 0.12f))
			{
				val4 = position - previousAnchor;
				if (!(((Vector3)(ref val4)).sqrMagnitude > magnitude * magnitude * 16f))
				{
					if (dt <= 0f)
					{
						return;
					}
					int num = Mathf.CeilToInt(dt * 120f);
					float num2 = dt / (float)num;
					float num3 = Mathf.Exp((0f - damping) * num2);
					Vector3 val5 = (position - previousAnchor) / (float)num;
					for (int i = 1; i <= num; i++)
					{
						Vector3 val6 = previousAnchor + (float)i * val5;
						Vector3 val7 = tip;
						velocity = velocity * num3 + Vector3.down * (9.81f * num2);
						Vector3 val8 = tip + velocity * num2 - val6;
						Vector3 val9 = ((((Vector3)(ref val8)).sqrMagnitude > 1E-10f) ? ((Vector3)(ref val8)).normalized : val3);
						float num4 = Vector3.Dot(val9, normalized);
						if (num4 < 0f)
						{
							val9 -= num4 * normalized;
						}
						if (((Vector3)(ref val9)).sqrMagnitude < 1E-08f)
						{
							val9 = val3;
						}
						val9 = Vector3.RotateTowards(val3, ((Vector3)(ref val9)).normalized, maximumAngle * ((float)Math.PI / 180f), 0f);
						tip = val6 + magnitude * val9;
						velocity = (tip - val7) / num2;
					}
					previousAnchor = position;
					Transform transform = ((Component)this).transform;
					val4 = tip - position;
					transform.rotation = Quaternion.FromToRotation(val3, ((Vector3)(ref val4)).normalized) * val;
					return;
				}
			}
			tip = position + val2;
			previousAnchor = position;
			velocity = Vector3.zero;
			((Component)this).transform.localRotation = restRotation;
			initialized = true;
		}
	}
}
namespace RelicsOfAsgard.Parches
{
	internal static class ParchesRecetas
	{
		private class InfoReceta
		{
			public DefinicionArma Arma;

			public int Etapa;
		}

		[HarmonyPatch(typeof(Player), "HaveRequirements", new Type[]
		{
			typeof(Recipe),
			typeof(bool),
			typeof(int),
			typeof(int)
		})]
		private static class Player_HaveRequirements
		{
			private static bool Prefix(Player __instance, Recipe recipe, bool discover, int qualityLevel, ref bool __result)
			{
				if (!EsNuestra(recipe, out var info))
				{
					return true;
				}
				if (discover)
				{
					__result = Tiene(__instance, info.Arma, info.Etapa, 1) || (info.Etapa > 1 && Tiene(__instance, info.Arma, info.Etapa - 1, 1));
					return false;
				}
				if (qualityLevel <= 1 && (info.Etapa == 1 || !Tiene(__instance, info.Arma, info.Etapa - 1, ConfigReliquias.NivelEvolucion.Value)))
				{
					__result = false;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Player), "HaveRequirementItems")]
		private static class Player_HaveRequirementItems
		{
			private static void Prefix(Recipe piece, bool discover, ref int qualityLevel, out List<KeyValuePair<Requirement, int>> __state)
			{
				__state = null;
				if (!discover && EsNuestra(piece, out var _))
				{
					__state = FijarNivel(piece.m_resources, qualityLevel);
					qualityLevel = 1;
				}
			}

			private static void Postfix(List<KeyValuePair<Requirement, int>> __state)
			{
				Restaurar(__state);
			}
		}

		[HarmonyPatch(typeof(Player), "ConsumeResources")]
		private static class Player_ConsumeResources
		{
			private static void Prefix(Requirement[] requirements, ref int qualityLevel, out List<KeyValuePair<Requirement, int>> __state)
			{
				__state = FijarNivel(requirements, qualityLevel);
				if (__state != null)
				{
					qualityLevel = 1;
				}
			}

			private static void Postfix(List<KeyValuePair<Requirement, int>> __state)
			{
				Restaurar(__state);
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "SetupRequirement")]
		private static class InventoryGui_SetupRequirement
		{
			private static void Prefix(Requirement req, ref int quality, out List<KeyValuePair<Requirement, int>> __state)
			{
				__state = FijarNivel((IEnumerable<Requirement>)(object)new Requirement[1] { req }, quality);
				if (__state != null)
				{
					quality = 1;
				}
			}

			private static void Postfix(List<KeyValuePair<Requirement, int>> __state)
			{
				Restaurar(__state);
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "AddRecipeToList")]
		private static class InventoryGui_AddRecipeToList
		{
			private static bool Prefix(Recipe recipe, ItemData item)
			{
				if (item == null && EsNuestra(recipe, out var info))
				{
					return info.Etapa > 1;
				}
				return true;
			}
		}

		private static readonly Dictionary<Recipe, InfoReceta> _recetas = new Dictionary<Recipe, InfoReceta>();

		private static readonly Dictionary<Requirement, int[]> _cantidades = new Dictionary<Requirement, int[]>();

		public static void Reconstruir()
		{
			_recetas.Clear();
			_cantidades.Clear();
			if ((Object)(object)ObjectDB.instance == (Object)null)
			{
				return;
			}
			foreach (Recipe recipe in ObjectDB.instance.m_recipes)
			{
				if ((Object)(object)recipe == (Object)null || (Object)(object)recipe.m_item == (Object)null || !RegistroArmas.Identificar(((Object)((Component)recipe.m_item).gameObject).name, out var arma, out var etapa))
				{
					continue;
				}
				_recetas[recipe] = new InfoReceta
				{
					Arma = arma,
					Etapa = etapa
				};
				Dictionary<string, int[]> dictionary = RegistroArmas.TablaCostes(arma, etapa);
				HashSet<string> hashSet = new HashSet<string>();
				Requirement[] resources = recipe.m_resources;
				foreach (Requirement val in resources)
				{
					if (!((Object)(object)val?.m_resItem == (Object)null))
					{
						string name = ((Object)((Component)val.m_resItem).gameObject).name;
						hashSet.Add(name);
						_cantidades[val] = (dictionary.TryGetValue(name, out var value) ? value : new int[5]);
						val.m_amount = _cantidades[val][1];
					}
				}
				foreach (string key in dictionary.Keys)
				{
					if (!hashSet.Contains(key))
					{
						Registro.Aviso(((Object)((Component)recipe.m_item).gameObject).name + ": el material '" + key + "' se añadió a la configuración pero no está en la receta. Reinicia el juego.");
					}
				}
			}
			Registro.Depurar($"Recetas de legendarias preparadas: {_recetas.Count}");
		}

		private static bool EsNuestra(Recipe receta, out InfoReceta info)
		{
			info = null;
			if ((Object)(object)receta != (Object)null)
			{
				return _recetas.TryGetValue(receta, out info);
			}
			return false;
		}

		private static bool Tiene(Player jugador, DefinicionArma arma, int etapa, int nivelMinimo)
		{
			string text = arma.TokenNombre(etapa);
			foreach (ItemData allItem in ((Humanoid)jugador).GetInventory().GetAllItems())
			{
				if (allItem.m_shared.m_name == text && allItem.m_quality >= nivelMinimo)
				{
					return true;
				}
			}
			return false;
		}

		private static List<KeyValuePair<Requirement, int>> FijarNivel(IEnumerable<Requirement> reqs, int nivel)
		{
			List<KeyValuePair<Requirement, int>> list = null;
			if (reqs == null)
			{
				return null;
			}
			int num = Mathf.Clamp(nivel, 1, 4);
			foreach (Requirement req in reqs)
			{
				if (req != null && _cantidades.TryGetValue(req, out var value))
				{
					if (list == null)
					{
						list = new List<KeyValuePair<Requirement, int>>();
					}
					list.Add(new KeyValuePair<Requirement, int>(req, req.m_amount));
					req.m_amount = value[num];
				}
			}
			return list;
		}

		private static void Restaurar(List<KeyValuePair<Requirement, int>> previo)
		{
			if (previo == null)
			{
				return;
			}
			foreach (KeyValuePair<Requirement, int> item in previo)
			{
				item.Key.m_amount = item.Value;
			}
		}
	}
	internal static class ReglasLegendarias
	{
		[HarmonyPatch(typeof(Inventory), "AddItem", new Type[] { typeof(ItemData) })]
		private static class Inventory_AddItem
		{
			private static bool Prefix(Inventory __instance, ItemData item, ref bool __result)
			{
				if (!Bloqueado(__instance, item))
				{
					return true;
				}
				Avisar();
				__result = false;
				return false;
			}
		}

		[HarmonyPatch(typeof(Inventory), "AddItem", new Type[]
		{
			typeof(ItemData),
			typeof(Vector2i)
		})]
		private static class Inventory_AddItemPosicion
		{
			private static bool Prefix(Inventory __instance, ItemData item, ref bool __result)
			{
				if (!Bloqueado(__instance, item))
				{
					return true;
				}
				Avisar();
				__result = false;
				return false;
			}
		}

		[HarmonyPatch(typeof(Inventory), "AddItem", new Type[]
		{
			typeof(ItemData),
			typeof(int),
			typeof(int),
			typeof(int),
			typeof(bool)
		})]
		private static class Inventory_AddItemCasilla
		{
			private static bool Prefix(Inventory __instance, ItemData item, ref bool __result)
			{
				if (!Bloqueado(__instance, item))
				{
					return true;
				}
				Avisar();
				__result = false;
				return false;
			}
		}

		[HarmonyPatch(typeof(Inventory), "CanAddItem", new Type[]
		{
			typeof(ItemData),
			typeof(int)
		})]
		private static class Inventory_CanAddItem
		{
			private static bool Prefix(Inventory __instance, ItemData item, ref bool __result)
			{
				if (!Bloqueado(__instance, item))
				{
					return true;
				}
				Avisar();
				__result = false;
				return false;
			}
		}

		[HarmonyPatch(typeof(Humanoid), "Pickup")]
		private static class Humanoid_Pickup
		{
			private static bool Prefix(Humanoid __instance, GameObject go, ref bool __result)
			{
				if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || (Object)(object)go == (Object)null)
				{
					return true;
				}
				ItemDrop component = go.GetComponent<ItemDrop>();
				if ((Object)(object)component == (Object)null)
				{
					return true;
				}
				component.Load();
				if (!Bloqueado(__instance.GetInventory(), component.m_itemData))
				{
					return true;
				}
				Avisar(forzar: true);
				__result = false;
				return false;
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
		private static class InventoryGui_DoCrafting
		{
			private static void Prefix()
			{
				_fabricando++;
			}

			private static Exception Finalizer(Exception __exception)
			{
				_fabricando--;
				return __exception;
			}
		}

		[HarmonyPatch(typeof(Inventory), "CanAddItem", new Type[]
		{
			typeof(GameObject),
			typeof(int)
		})]
		private static class Inventory_CanAddItemPrefab
		{
			private static void Prefix()
			{
				_fabricando++;
			}

			private static Exception Finalizer(Exception __exception)
			{
				_fabricando--;
				return __exception;
			}
		}

		[HarmonyPatch]
		private static class Inventory_Load
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				yield return AccessTools.Method(typeof(Inventory), "Load", new Type[1] { typeof(ZPackage) }, (Type[])null);
				yield return AccessTools.Method(typeof(Inventory), "Load", new Type[2]
				{
					typeof(ZPackage),
					typeof(bool)
				}, (Type[])null);
			}

			private static void Prefix()
			{
				_cargando++;
			}

			private static Exception Finalizer(Exception __exception)
			{
				_cargando--;
				return __exception;
			}
		}

		[HarmonyPatch(typeof(TombStone), "OnTakeAllSuccess")]
		private static class TombStone_OnTakeAllSuccess
		{
			private static void Postfix()
			{
				if (AvisadoHacePoco)
				{
					Avisar(forzar: true);
				}
			}
		}

		[HarmonyPatch(typeof(ZNetView), "Destroy")]
		private static class ZNetView_Destroy
		{
			private static bool Prefix(ZNetView __instance)
			{
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				ItemDrop val = (((Object)(object)__instance != (Object)null) ? ((Component)__instance).GetComponent<ItemDrop>() : null);
				if ((Object)(object)val == (Object)null || !EsLegendaria(val.m_itemData))
				{
					return true;
				}
				Registro.Depurar($"Se ha evitado destruir {val.m_itemData.m_shared.m_name} en {((Component)val).transform.position}.");
				return false;
			}
		}

		[HarmonyPatch(typeof(Incinerator), "OnIncinerate")]
		private static class Incinerator_OnIncinerate
		{
			private static bool Prefix(Incinerator __instance, Humanoid user, ref bool __result)
			{
				Container container = __instance.m_container;
				if ((Object)(object)container == (Object)null)
				{
					return true;
				}
				foreach (ItemData allItem in container.GetInventory().GetAllItems())
				{
					if (EsLegendaria(allItem))
					{
						if (user != null)
						{
							((Character)user).Message((MessageType)2, "$roa_msg_incinerador", 0, (Sprite)null, false);
						}
						__result = false;
						return false;
					}
				}
				return true;
			}
		}

		private static int _fabricando;

		private static int _cargando;

		private static float _ultimoAviso = -100f;

		private static ItemData _ultimoBloqueado;

		private static float _ultimoRegistro = -100f;

		private static bool AvisadoHacePoco => Time.time - _ultimoAviso < 1f;

		public static bool EsLegendaria(ItemData item)
		{
			if (item != null && item.m_shared?.m_name != null)
			{
				return item.m_shared.m_name.StartsWith("$roa_", StringComparison.Ordinal);
			}
			return false;
		}

		private static string Arma(ItemData item)
		{
			string name = item.m_shared.m_name;
			int num = name.LastIndexOf('_');
			if (num <= 0)
			{
				return name;
			}
			return name.Substring(0, num);
		}

		public static bool Bloqueado(Inventory inventario, ItemData item)
		{
			Player localPlayer = Player.m_localPlayer;
			if (_cargando > 0 || (Object)(object)localPlayer == (Object)null || inventario == null || inventario != ((Humanoid)localPlayer).GetInventory() || !EsLegendaria(item))
			{
				return false;
			}
			int num = 0;
			string text = null;
			foreach (ItemData allItem in inventario.GetAllItems())
			{
				if (allItem != item && EsLegendaria(allItem) && (_fabricando <= 0 || !(Arma(allItem) == Arma(item))))
				{
					num++;
					text = ((text == null) ? allItem.m_shared.m_name : (text + ", " + allItem.m_shared.m_name));
				}
			}
			bool flag = num >= ConfigReliquias.LegendariasPorInventario.Value;
			if (flag && (item != _ultimoBloqueado || Time.time - _ultimoRegistro > 5f))
			{
				_ultimoBloqueado = item;
				_ultimoRegistro = Time.time;
				Registro.Depurar("Bloqueado " + item.m_shared.m_name + ": ya llevas " + text + ".");
			}
			return flag;
		}

		public static void Avisar(bool forzar = false)
		{
			if (!((Object)(object)Player.m_localPlayer == (Object)null) && (forzar || !(Time.time - _ultimoAviso < 2f)))
			{
				_ultimoAviso = Time.time;
				((Character)Player.m_localPlayer).Message((MessageType)2, "$roa_msg_no_comparten", 0, (Sprite)null, false);
			}
		}
	}
}
namespace RelicsOfAsgard.Mecanicas
{
	internal class EfectosLegendaria : MonoBehaviour
	{
		public string Arma;

		public int Etapa;

		public Quaternion RotacionIzquierda = Quaternion.identity;

		public bool RotacionIzquierdaFija;

		public static float TensadoForzado = -1f;

		public static readonly int ZdoTensado = StringExtensionMethods.GetStableHashCode("roa_ydalir_tensado");

		public static readonly int ZdoGramCargado = StringExtensionMethods.GetStableHashCode("roa_gram_cargado");

		public static readonly int ZdoGramCarga = StringExtensionMethods.GetStableHashCode("roa_gram_carga");

		public static readonly int ZdoFerocidad = StringExtensionMethods.GetStableHashCode("roa_gerifreki_ferocidad");

		private static readonly int ParamCharged = Animator.StringToHash("Charged");

		private static readonly Regex PatronEstado = new Regex("^State(\\d)");

		private static readonly AnimationCurve CargaTensado = new AnimationCurve((Keyframe[])(object)new Keyframe[4]
		{
			new Keyframe(0f, 0f),
			new Keyframe(0.8f, 1.05f),
			new Keyframe(0.96f, 2.1f),
			new Keyframe(1f, 1.6f)
		});

		private static readonly AnimationCurve DestelloDisparo = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
		{
			new Keyframe(0f, 2.6f),
			new Keyframe(0.045f, 3.8f),
			new Keyframe(0.22f, 0f)
		});

		private const float CargaSeApaga = 0.14f;

		private const float CuerdaVuelve = 0.12f;

		private static readonly int PropCarga = Shader.PropertyToID("_ChargeGain");

		private static readonly int ParamFerocidad = Animator.StringToHash("Ferocity");

		private Animator _animador;

		private readonly List<Animator> _animadoresFerocidad = new List<Animator>();

		private readonly List<Material> _matCarga = new List<Material>();

		private readonly List<Material> _matDisparo = new List<Material>();

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

		private float _disparo = -100f;

		private float _cargaAlSoltar;

		private Player _jugador;

		private ZNetView _nview;

		private readonly List<(Renderer r, int nivel)> _estados = new List<(Renderer, int)>();

		private Transform _izquierda;

		private float _tensadoAnterior;

		private int _ferocidadAplicada = -1;

		private CuervosFantasma _cuervos;

		private readonly List<(Light luz, float intensidad, float fase)> _luces = new List<(Light, float, float)>();

		private readonly List<(Material m, float intensidad, bool destello)> _matGram = new List<(Material, float, bool)>();

		private readonly List<(Renderer r, bool destello)> _piezasGram = new List<(Renderer, bool)>();

		private static readonly int PropIntensidad = Shader.PropertyToID("_Intensity");

		private GameObject _tonoGram;

		private float _cargaGramAnterior;

		private float _llenoDesde = -100f;

		private const float DuracionDestello = 0.18f;

		private void Awake()
		{
			_animador = ((Component)this).GetComponentInChildren<Animator>(true);
			Animator[] componentsInChildren = ((Component)this).GetComponentsInChildren<Animator>(true);
			foreach (Animator val in componentsInChildren)
			{
				if ((Object)(object)val.runtimeAnimatorController != (Object)null && TieneParametro(val, "Ferocity"))
				{
					_animadoresFerocidad.Add(val);
				}
			}
			Renderer[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren2)
			{
				Match match = PatronEstado.Match(((Object)val2).name);
				if (match.Success)
				{
					_estados.Add((val2, match.Groups[1].Value[0] - 48));
				}
			}
		}

		private void Start()
		{
			_jugador = ((Component)this).GetComponentInParent<Player>();
			if ((Object)(object)_jugador != (Object)null)
			{
				_nview = ((Component)_jugador).GetComponent<ZNetView>();
			}
			AplicarFerocidad(0);
			if (Arma == "Ydalir" && (Object)(object)_jugador != (Object)null)
			{
				PrepararArco();
			}
			if (Arma == "Gram" && (Object)(object)_jugador != (Object)null)
			{
				PrepararGram();
			}
			Goteo();
			if (Arma == "Gungnir" && Etapa >= 5 && (Object)(object)_jugador != (Object)null && !EnLaEspalda())
			{
				_cuervos = CuervosFantasma.Crear(((Component)_jugador).transform);
			}
		}

		private bool EnLaEspalda()
		{
			Transform parent = ((Component)this).transform.parent;
			while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)((Component)_jugador).transform)
			{
				if (((Object)parent).name.StartsWith("attach_back"))
				{
					return true;
				}
				parent = parent.parent;
			}
			return false;
		}

		private void Goteo()
		{
			//IL_029d: 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_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: 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_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			Goteo goteo = RelicsOfAsgard.Efectos.Goteo.De(Arma);
			if (goteo == null)
			{
				return;
			}
			float num = ((Etapa >= 5) ? 1f : ((Arma == "Tyrfing") ? 0.55f : RelicsOfAsgard.Efectos.Goteo.FactorEtapaIV.Value));
			float num2 = ((Etapa >= goteo.EtapaMinima) ? (goteo.Tasa.Value * num) : 0f);
			float num3 = ((goteo.Luz != null) ? (goteo.Luz.Value * ConfigReliquias.PorEtapa(RelicsOfAsgard.Efectos.Goteo.LuzPorEtapa, Etapa)) : 0f);
			float num4 = ((Arma == "Ydalir" && Etapa >= 5) ? RelicsOfAsgard.Efectos.Goteo.YdalirEscarcha.Value : 0f);
			if (num2 <= 0f && num3 <= 0f && num4 <= 0f)
			{
				return;
			}
			List<Transform> list = new List<Transform>();
			Transform val = ((Component)this).transform.Find("modelo");
			Transform val2 = (((Object)(object)_izquierda != (Object)null) ? _izquierda : ((Component)this).transform.Find("modelo_izq"));
			if ((Object)(object)val != (Object)null)
			{
				list.Add(val);
			}
			if ((Object)(object)val2 != (Object)null)
			{
				list.Add(val2);
			}
			if (list.Count == 0)
			{
				list.Add(((Component)this).transform);
			}
			foreach (Transform item in list)
			{
				Renderer val3 = null;
				float num5 = 0f;
				Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren<Renderer>(true);
				Bounds bounds;
				foreach (Renderer val4 in componentsInChildren)
				{
					if ((val4 is MeshRenderer || val4 is SkinnedMeshRenderer) && !((Object)val4).name.StartsWith("FX_") && !((Object)val4).name.StartsWith("VFX_") && !((Object)val4).name.StartsWith("Charge_") && !((Object)val4).name.StartsWith("Release_") && !((Object)val4).name.StartsWith("State"))
					{
						bounds = val4.bounds;
						Vector3 size = ((Bounds)(ref bounds)).size;
						float num6 = ((Vector3)(ref size)).sqrMagnitude;
						if (Arma == "Ydalir" && (val4 is SkinnedMeshRenderer || ((Object)val4).name.StartsWith("Yew_Stave")))
						{
							num6 += 1000f;
						}
						if (num6 > num5)
						{
							num5 = num6;
							val3 = val4;
						}
					}
				}
				if (!((Object)(object)val3 == (Object)null))
				{
					if (num2 > 0f && (Object)(object)Fx.Superficie(val3, goteo.Color(), num2 / (float)list.Count, goteo.Gravedad, goteo.Tamano, goteo.Vida, "RoA_Goteo", goteo.Estilo, goteo.Estelas, (goteo.LuzParticulas != null) ? (goteo.LuzParticulas.Value * ((Etapa >= 5) ? 1f : 0.6f)) : 0f) != (Object)null)
					{
						Registro.Depurar($"{Arma} (etapa {Etapa}): goteo desde '{((Object)val3).name}'.");
					}
					if (num4 > 0f)
					{
						Fx.Superficie(val3, new Color(0.85f, 0.95f, 1f), num4, 0.02f, 0.035f, 1.2f, "RoA_Escarcha", Fx.Estilo.Chispa);
					}
					if (num3 > 0f)
					{
						Light val5 = new GameObject("RoA_GoteoLuz").AddComponent<Light>();
						((Component)val5).transform.SetParent(((Component)val3).transform, false);
						Transform transform = ((Component)val5).transform;
						bounds = val3.bounds;
						transform.position = ((Bounds)(ref bounds)).center;
						val5.type = (LightType)2;
						val5.color = goteo.ColorLuz;
						val5.range = 2.5f;
						val5.shadows = (LightShadows)0;
						_luces.Add((val5, num3, Random.value * 10f));
					}
				}
			}
		}

		private void ParpadearLuces()
		{
			float time = Time.time;
			foreach (var (val, num, num2) in _luces)
			{
				if ((Object)(object)val != (Object)null)
				{
					val.intensity = num * (0.8f + 0.12f * Mathf.Sin(time * 3.1f + num2) + 0.08f * Mathf.PerlinNoise(time * 4f, num2));
				}
			}
		}

		private void PrepararGram()
		{
			Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (!((Object)val).name.StartsWith("Charge_"))
				{
					continue;
				}
				bool flag = ((Object)val).name.StartsWith("Charge_ReadyFlash");
				_piezasGram.Add((val, flag));
				Material[] materials = val.materials;
				foreach (Material val2 in materials)
				{
					if ((Object)(object)val2 != (Object)null && val2.HasProperty(PropIntensidad))
					{
						_matGram.Add((val2, val2.GetFloat(PropIntensidad), flag));
					}
				}
			}
			if (_piezasGram.Count > 0)
			{
				Animator[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Animator>(true);
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					((Behaviour)componentsInChildren2[i]).enabled = false;
				}
			}
			Registro.Depurar($"Gram: {_piezasGram.Count} piezas de carga y {_matGram.Count} materiales.");
		}

		private void GramVisual(float carga)
		{
			if (carga >= 1f && _cargaGramAnterior < 1f)
			{
				_llenoDesde = Time.time;
			}
			bool flag = Time.time - _llenoDesde < 0.18f;
			foreach (var (val, flag2) in _piezasGram)
			{
				if ((Object)(object)val != (Object)null)
				{
					val.enabled = (flag2 ? flag : (carga > 0.02f));
				}
			}
			float num = Mathf.Lerp(0.15f, 1f, carga);
			foreach (var (val2, num2, flag3) in _matGram)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					val2.SetFloat(PropIntensidad, flag3 ? num2 : (num2 * num));
				}
			}
			bool flag4 = carga > 0.02f && carga < 1f;
			if (flag4 && (Object)(object)_tonoGram == (Object)null)
			{
				_tonoGram = Fx.Persistente("Gram_Cargando", ((Component)this).transform);
			}
			else if (!flag4 && (Object)(object)_tonoGram != (Object)null)
			{
				Object.Destroy((Object)(object)_tonoGram);
				_tonoGram = null;
			}
			if ((Object)(object)_tonoGram != (Object)null)
			{
				ZSFX[] componentsInChildren = _tonoGram.GetComponentsInChildren<ZSFX>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].SetPitchModifier(Mathf.Lerp(0.75f, 1.5f, carga));
				}
			}
			_cargaGramAnterior = carga;
		}

		private void PrepararArco()
		{
			Animator[] componentsInChildren = ((Component)this).GetComponentsInChildren<Animator>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Behaviour)componentsInChildren[i]).enabled = false;
			}
			Renderer[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren2)
			{
				SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((val is SkinnedMeshRenderer) ? val : null);
				if (val2 != null && (Object)(object)val2.sharedMesh != (Object)null && val2.sharedMesh.blendShapeCount > 0)
				{
					_cuerdas.Add(val2);
				}
				bool flag = ((Object)val).name.StartsWith("Charge_");
				bool flag2 = ((Object)val).name.StartsWith("Release_");
				if (!flag && !flag2)
				{
					continue;
				}
				Material[] materials = val.materials;
				foreach (Material val3 in materials)
				{
					if (!((Object)(object)val3 == (Object)null) && val3.HasProperty(PropCarga))
					{
						val3.SetFloat(PropCarga, 0f);
						(flag ? _matCarga : _matDisparo).Add(val3);
					}
				}
			}
			Registro.Depurar($"Ýdalir: {_matCarga.Count} materiales de carga, {_matDisparo.Count} de disparo y {_cuerdas.Count} cuerdas.");
		}

		private void ArcoVisual(float tensado)
		{
			float num = Time.time - _disparo;
			bool num2 = num < ((Keyframe)(ref DestelloDisparo.keys[DestelloDisparo.length - 1])).time;
			float num3 = CargaTensado.Evaluate(tensado);
			if (tensado <= 0.001f && num < 0.14f)
			{
				num3 = Mathf.Lerp(_cargaAlSoltar, 0f, num / 0.14f);
			}
			float num4 = (num2 ? DestelloDisparo.Evaluate(num) : 0f);
			float num5 = ((tensado > 0.001f) ? (tensado * 100f) : (Mathf.Lerp(100f, 0f, num / 0.12f) * ((_cargaAlSoltar > 0f) ? 1f : 0f)));
			foreach (Material item in _matCarga)
			{
				item.SetFloat(PropCarga, num3);
			}
			foreach (Material item2 in _matDisparo)
			{
				item2.SetFloat(PropCarga, num4);
			}
			foreach (SkinnedMeshRenderer cuerda in _cuerdas)
			{
				if ((Object)(object)cuerda != (Object)null)
				{
					cuerda.SetBlendShapeWeight(0, Mathf.Clamp(num5, 0f, 100f));
				}
			}
		}

		public void LlevarIzquierda(Transform mano, Transform manoGeri, SkinnedMeshRenderer cuerpo)
		{
			//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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_012e: 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_013d: 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_014c: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: 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_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_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_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_00ce: 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_00e4: 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)
			Transform val = ((Component)this).transform.Find("modelo_izq");
			Transform val2 = ((Component)this).transform.Find("modelo");
			if (!((Object)(object)val == (Object)null) && !((Object)(object)mano == (Object)null))
			{
				if (!RotacionIzquierdaFija && (Object)(object)val2 != (Object)null && (Object)(object)manoGeri != (Object)null && Espejo(mano, manoGeri, val2, cuerpo, out var local, out var como))
				{
					val.SetParent(mano, false);
					val.localPosition = Vector4.op_Implicit(((Matrix4x4)(ref local)).GetColumn(3));
					val.localRotation = Quaternion.LookRotation(Vector4.op_Implicit(((Matrix4x4)(ref local)).GetColumn(2)), Vector4.op_Implicit(((Matrix4x4)(ref local)).GetColumn(1)));
					Vector3 val3 = Vector4.op_Implicit(((Matrix4x4)(ref local)).GetColumn(0));
					float magnitude = ((Vector3)(ref val3)).magnitude;
					val3 = Vector4.op_Implicit(((Matrix4x4)(ref local)).GetColumn(1));
					float magnitude2 = ((Vector3)(ref val3)).magnitude;
					val3 = Vector4.op_Implicit(((Matrix4x4)(ref local)).GetColumn(2));
					val.localScale = new Vector3(magnitude, magnitude2, ((Vector3)(ref val3)).magnitude);
				}
				else
				{
					Vector3 lossyScale = (val2 ?? val).lossyScale;
					val.SetParent(mano, false);
					val.localPosition = Vector3.zero;
					val.localRotation = RotacionIzquierda;
					Vector3 lossyScale2 = mano.lossyScale;
					val.localScale = new Vector3(lossyScale.x / lossyScale2.x, lossyScale.y / lossyScale2.y, lossyScale.z / lossyScale2.z);
					como = "rotación de la configuración";
				}
				_izquierda = val;
				object[] obj = new object[6]
				{
					((Object)mano).name,
					como,
					val.localPosition,
					null,
					null,
					null
				};
				Quaternion localRotation = val.localRotation;
				obj[3] = ((Quaternion)(ref localRotation)).eulerAngles;
				obj[4] = val.lossyScale;
				obj[5] = (((Object)(object)val2 != (Object)null) ? val2.lossyScale : Vector3.zero);
				Registro.Depurar(string.Format("Geri y Freki: Freki pasa a '{0}' ({1}): posición {2}, rotación {3}, escala en el mundo {4} (Geri {5}).", obj));
			}
		}

		private static bool Espejo(Transform mano, Transform manoGeri, Transform geri, SkinnedMeshRenderer cuerpo, out Matrix4x4 local, out string como)
		{
			//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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_008c: 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_00df: 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_0114: 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_0124: 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_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			local = Matrix4x4.identity;
			if (MarcoBind(mano, cuerpo, out var marco) && MarcoBind(manoGeri, cuerpo, out var marco2))
			{
				como = "espejo de Geri en la pose del esqueleto";
			}
			else
			{
				Transform obj = (((Object)(object)cuerpo != (Object)null) ? ((Component)cuerpo).transform : mano.root);
				marco = obj.worldToLocalMatrix * mano.localToWorldMatrix;
				marco2 = obj.worldToLocalMatrix * manoGeri.localToWorldMatrix;
				como = "espejo de Geri en la pose actual";
			}
			Vector3 val = Vector4.op_Implicit(((Matrix4x4)(ref marco)).GetColumn(3));
			Vector3 val2 = Vector4.op_Implicit(((Matrix4x4)(ref marco2)).GetColumn(3));
			Vector3 val3 = val - val2;
			int num = 0;
			for (int i = 1; i < 3; i++)
			{
				if (Mathf.Abs(((Vector3)(ref val3))[i]) > Mathf.Abs(((Vector3)(ref val3))[num]))
				{
					num = i;
				}
			}
			if (Mathf.Abs(((Vector3)(ref val3))[num]) < 0.0001f)
			{
				return false;
			}
			Matrix4x4 identity = Matrix4x4.identity;
			((Matrix4x4)(ref identity))[num, num] = -1f;
			((Matrix4x4)(ref identity))[num, 3] = ((Vector3)(ref val))[num] + ((Vector3)(ref val2))[num];
			Matrix4x4 val4 = manoGeri.worldToLocalMatrix * geri.localToWorldMatrix;
			local = ((Matrix4x4)(ref marco)).inverse * identity * marco2 * val4 * Matrix4x4.Scale(new Vector3(1f, 1f, -1f));
			return ((Matrix4x4)(ref local)).determinant > 0f;
		}

		private static bool MarcoBind(Transform articulacion, SkinnedMeshRenderer cuerpo, out Matrix4x4 marco)
		{
			//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_0065: 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_0071: 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_007b: 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)
			marco = Matrix4x4.identity;
			if ((Object)(object)cuerpo == (Object)null || (Object)(object)cuerpo.sharedMesh == (Object)null)
			{
				return false;
			}
			try
			{
				Transform[] bones = cuerpo.bones;
				Matrix4x4[] bindposes = cuerpo.sharedMesh.bindposes;
				if (bones == null || bindposes == null || bindposes.Length != bones.Length)
				{
					return false;
				}
				Transform val = articulacion;
				while ((Object)(object)val != (Object)null)
				{
					int num = Array.IndexOf(bones, val);
					if (num >= 0)
					{
						marco = ((Matrix4x4)(ref bindposes[num])).inverse * (val.worldToLocalMatrix * articulacion.localToWorldMatrix);
						return true;
					}
					val = val.parent;
				}
			}
			catch (Exception ex)
			{
				Registro.Depurar("Geri y Freki: no se pudo leer la pose del esqueleto (" + ex.Message + ").");
			}
			return false;
		}

		private void OnDestroy()
		{
			if ((Object)(object)_izquierda != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_izquierda).gameObject);
			}
			foreach (Material item2 in _matCarga)
			{
				if ((Object)(object)item2 != (Object)null)
				{
					Object.Destroy((Object)(object)item2);
				}
			}
			foreach (Material item3 in _matDisparo)
			{
				if ((Object)(object)item3 != (Object)null)
				{
					Object.Destroy((Object)(object)item3);
				}
			}
			foreach (var item4 in _matGram)
			{
				Material item = item4.m;
				if ((Object)(object)item != (Object)null)
				{
					Object.Destroy((Object)(object)item);
				}
			}
			if ((Object)(object)_cuervos != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_cuervos).gameObject);
			}
		}

		private void Update()
		{
			if (_luces.Count > 0)
			{
				ParpadearLuces();
			}
			if ((Object)(object)_jugador == (Object)null || (Object)(object)_nview == (Object)null || !_nview.IsValid())
			{
				return;
			}
			ZDO zDO = _nview.GetZDO();
			bool flag = (Object)(object)_jugador == (Object)(object)Player.m_localPlayer;
			switch (Arma)
			{
			case "Ydalir":
			{
				float num2;
				if (flag)
				{
					num2 = ((TensadoForzado >= 0f) ? Mathf.Clamp01(TensadoForzado) : Mathf.Clamp01(((Humanoid)_jugador).GetAttackDrawPercentage()));
					float num3 = zDO.GetFloat(ZdoTensado, 0f);
					if (Mathf.Abs(num2 - num3) > 0.03f || (num2 == 0f && num3 != 0f))
					{
						zDO.Set(ZdoTensado, num2);
					}
				}
				else
				{
					num2 = zDO.GetFloat(ZdoTensado, 0f);
				}
				if (_tensadoAnterior >= 0.1f && num2 <= 0.001f)
				{
					_disparo = Time.time;
					_cargaAlSoltar = CargaTensado.Evaluate(_tensadoAnterior);
					Registro.Depurar($"Ýdalir: disparo (tensado {_tensadoAnterior:0.00}, carga {_cargaAlSoltar:0.00}).");
				}
				else if (num2 > 0.001f)
				{
					_cargaAlSoltar = 0f;
				}
				ArcoVisual(num2);
				_tensadoAnterior = num2;
				break;
			}
			case "Gram":
			{
				bool flag2 = zDO.GetBool(ZdoGramCargado, false);
				if (_piezasGram.Count == 0)
				{
					if ((Object)(object)_animador != (Object)null)
					{
						_animador.SetBool(ParamCharged, flag2);
					}
				}
				else
				{
					GramVisual(flag2 ? 1f : Mathf.Clamp01(zDO.GetFloat(ZdoGramCarga, 0f)));
				}
				break;
			}
			case "GeriFreki":
			{
				int num;
				if (flag)
				{
					num = GeriFreki.NivelFerocidad();
					if (zDO.GetInt(ZdoFerocidad, 0) != num)
					{
						zDO.Set(ZdoFerocidad, num, false);
					}
				}
				else
				{
					num = zDO.GetInt(ZdoFerocidad, 0);
				}
				AplicarFerocidad(num);
				break;
			}
			}
		}

		private static bool TieneParametro(Animator a, string nombre)
		{
			try
			{
				AnimatorControllerParameter[] parameters = a.parameters;
				for (int i = 0; i < parameters.Length; i++)
				{
					if (parameters[i].name == nombre)
					{
						return true;
					}
				}
			}
			catch
			{
			}
			return false;
		}

		private void AplicarFerocidad(int nivel)
		{
			if (_animadoresFerocidad.Count > 0)
			{
				foreach (Animator item in _animadoresFerocidad)
				{
					if ((Object)(object)item != (Object)null && ((Behaviour)item).isActiveAndEnabled && item.GetInteger(ParamFerocidad) != nivel)
					{
						item.SetInteger(ParamFerocidad, nivel);
					}
				}
				_ferocidadAplicada = nivel;
			}
			else
			{
				if (nivel == _ferocidadAplicada || _estados.Count == 0)
				{
					return;
				}
				_ferocidadAplicada = nivel;
				foreach (var (val, num) in _estados)
				{
					if ((Object)(object)val != (Object)null)
					{
						val.enabled = nivel >= num;
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(VisEquipment), "AttachItem")]
	internal static class VisEquipment_AttachItem
	{
		private static void Postfix(VisEquipment __instance, GameObject __result, Transform joint)
		{
			if ((Object)(object)__result == (Object)null || (Object)(object)joint == (Object)null)
			{
				return;
			}
			EfectosLegendaria componentInChildren = __result.GetComponentInChildren<EfectosLegendaria>(true);
			if (!((Object)(object)componentInChildren == (Object)null) && !(componentInChildren.Arma != "GeriFreki"))
			{
				Transform val = (((Object)(object)joint == (Object)(object)__instance.m_rightHand) ? __instance.m_leftHand : (((Object)(object)joint == (Object)(object)__instance.m_leftHand) ? __instance.m_rightHand : null));
				if ((Object)(object)val != (Object)null)
				{
					componentInChildren.LlevarIzquierda(val, joint, __instance.m_bodyModel);
				}
			}
		}
	}
	internal static class GeriFreki
	{
		[HarmonyPatch(typeof(Character), "RPC_Damage")]
		private static class Character_RPC_Damage
		{
			private static void Prefix(Character __instance, HitData hit)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Invalid comparison between Unknown and I4
				//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_00f7: 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)
				try
				{
					if ((Object)(object)__instance == (Object)null || __instance.IsPlayer() || hit == null || (int)hit.m_skill != 2)
					{
						return;
					}
					ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
					if ((Object)(object)component == (Object)null || !component.IsValid() || !component.IsOwner() || __instance.IsDead() || __instance.GetHealth() <= 0f)
					{
						return;
					}
					Character attacker = hit.GetAttacker();
					Player val = (Player)(object)((attacker is Player) ? attacker : null);
					if (val != null && EtapaEquipada(val) != 0)
					{
						DamageTypes damage = hit.m_damage;
						damage.m_chop = 0f;
						damage.m_pickaxe = 0f;
						float num = C.SangradoPorCarga.Value * (__instance.IsBoss() ? C.SangradoJefes.Value : 1f);
						if (!(num <= 0f))
						{
							((DamageTypes)(ref damage)).Modify(num);
							(((Component)__instance).GetComponent<Sangrado>() ?? ((Component)__instance).gameObject.AddComponent<Sangrado>()).Añadir(damage, hit.m_attacker);
						}
					}
				}
				catch (Exception arg)
				{
					Registro.Error($"Sangrado de Geri y Freki: {arg}");
				}
			}
		}

		internal class Sangrado : MonoBehaviour
		{
			private class Carga
			{
				public DamageTypes Total;
			}

			private const float Intervalo = 0.5f;

			internal static readonly int ZdoCargas = StringExtensionMethods.GetStableHashCode("roa_sangrado_cargas");

			private readonly List<Carga> _cargas = new List<Carga>();

			private float _fin;

			private float _siguiente;

			private ZDOID _atacante;

			private Character _personaje;

			private ZNetView _nview;

			public int Cargas => _cargas.Count;

			public float Restante => Mathf.Max(0f, _fin - Time.time);

			private void Awake()
			{
				_personaje = ((Component)this).GetComponent<Character>();
				_nview = ((Component)this).GetComponent<ZNetView>();
			}

			private void Publicar()
			{
				if ((Object)(object)_nview != (Object)null && _nview.IsValid() && _nview.IsOwner() && _nview.GetZDO().GetInt(ZdoCargas, 0) != _cargas.Count)
				{
					_nview.GetZDO().Set(ZdoCargas, _cargas.Count, false);
				}
			}

			public void Añadir(DamageTypes danio, ZDOID atacante)
			{
				//IL_006d: 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_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				if (_cargas.Count == 0)
				{
					_siguiente = Time.time + 0.5f;
				}
				if (_cargas.Count < C.SangradoCargasMax.Value)
				{
					_cargas.Add(new Carga
					{
						Total = danio
					});
				}
				_fin = Time.time + C.SangradoDuracion.Value;
				_atacante = atacante;
				Publicar();
				Registro.Depurar($"Geri y Freki: {_personaje.m_name} sangra con {_cargas.Count} cargas ({C.SangradoDuracion.Value} s).");
			}

			private void Update()
			{
				//IL_00a4: 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_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_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_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_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_0131: Unknown result type (might be due to invalid IL or missing references)
				//IL_0136: Unknown result type (might be due to invalid IL or missing references)
				//IL_013b: Unknown result type (might be due to invalid IL or missing references)
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0142: 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_014a: Expected O, but got Unknown
				if (_cargas.Count == 0)
				{
					return;
				}
				if ((Object)(object)_personaje == (Object)null || (Object)(object)_nview == (Object)null || !_nview.IsValid() || !_nview.IsOwner() || _personaje.IsDead())
				{
					_cargas.Clear();
					Publicar();
				}
				else if (Time.time > _fin)
				{
					_cargas.Clear();
					Publicar();
				}
				else
				{
					if (Time.time < _siguiente)
					{
						return;
					}
					_siguiente += 0.5f;
					DamageTypes damage = default(DamageTypes);
					foreach (Carga carga in _cargas)
					{
						((DamageTypes)(ref damage)).Add(carga.Total, 1);
					}
					((DamageTypes)(ref damage)).Modify(0.5f / C.SangradoDuracion.Value);
					if (!(((DamageTypes)(ref damage)).GetTotalDamage() <= 0f))
					{
						HitData val = new HitData
						{
							m_damage = damage,
							m_point = _personaje.GetCenterPoint(),
							m_attacker = _atacante,
							m_skill = (SkillType)0,
							m_hitType = (HitType)2
						};
						_personaje.Damage(val);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Character), "Damage")]
		private static class Character_Damage
		{
			private static void Prefix(Character __instance, HitData hit)
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: 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)
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null || hit == null || (Object)(object)__instance == (Object)null || __instance is Player || (int)hit.m_skill != 2 || (Object)(object)hit.GetAttacker() != (Object)(object)localPlayer || Legendaria.EtapaDe(((Humanoid)localPlayer).GetCurrentWeapon(), "GeriFreki") == 0)
				{
					return;
				}
				Attack val = AtaqueActual.Invoke((Humanoid)(object)localPlayer);
				if (val == null || val != _ultimoAtaqueContado)
				{
					_ultimoAtaqueContado = val;
					Bonificacion();
					bool num = Bonificacion() >= C.VelocidadMaxima.Value - 0.0001f;
					_golpes++;
					_ultimoGolpe = Time.time;
					if (!num && Bonificacion() >= C.VelocidadMaxima.Value - 0.0001f)
					{
						Fx.Todos("GeriFreki_Ferocidad", ((Character)localPlayer).GetCenterPoint(), Quaternion.identity, ((Component)localPlayer).GetComponent<ZNetView>(), 1f, "GeriFreki");
					}
					Registro.Depurar($"Geri y Freki: {_golpes} golpes encadenados (+{Bonificacion() * 100f:0} % de velocidad).");
				}
			}
		}

		[HarmonyPatch(typeof(CharacterAnimEvent))]
		private static class CharacterAnimEvent_Velocidad
		{
			private static readonly FieldRef<CharacterAnimEvent, Animator> Animador = AccessTools.FieldRefAccess<CharacterAnimEvent, Animator>("m_animator");

			private static readonly FieldRef<CharacterAnimEvent, Character> Personaje = AccessTools.FieldRefAccess<CharacterAnimEvent, Character>("m_character");

			private static readonly FieldRef<CharacterAnimEvent, float> Pausa = AccessTools.FieldRefAccess<CharacterAnimEvent, float>("m_pauseTimer");

			private static float _velocidadAnimacion = 1f;

			private static bool EsLocal(CharacterAnimEvent ev)
			{
				if ((Object)(object)Player.m_localPlayer != (Object)null)
				{
					return (Object)(object)Personaje.Invoke(ev) == (Object)(object)Player.m_localPlayer;
				}
				return false;
			}

			[HarmonyPatch("Speed")]
			[HarmonyPostfix]
			private static void Speed(CharacterAnimEvent __instance, float speedScale)
			{
				if (EsLocal(__instance))
				{
					_velocidadAnimacion = speedScale;
					Aplicar(__instance);
				}
			}

			[HarmonyPatch("CustomFixedUpdate")]
			[HarmonyPostfix]
			private static void FixedUpdate(CharacterAnimEvent __instance)
			{
				if (EsLocal(__instance))
				{
					if (!((Character)Player.m_localPlayer).InAttack())
					{
						_velocidadAnimacion = 1f;
					}
					else
					{
						Aplicar(__instance);
					}
				}
			}

			private static void Aplicar(CharacterAnimEvent ev)
			{
				if (Pausa.Invoke(ev) > 0f)
				{
					return;
				}
				float num = Bonificacion();
				if (!(num <= 0f))
				{
					Animator val = Animador.Invoke(ev);
					if ((Object)(object)val != (Object)null && val.speed >= 0.01f)
					{
						val.speed = _velocidadAnimacion * (1f + num);
					}
				}
			}
		}

		private const string Id = "GeriFreki";

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

		private static Attack _ultimoAtaqueContado;

		private static int _golpes;

		private static float _ultimoGolpe = -100f;

		public static int FerocidadForzada = -1;

		private static ConfigReliquias.ConfigArma C => ConfigReliquias.Armas["GeriFreki"];

		private static int EtapaEquipada(Player p)
		{
			int num = Legendaria.EtapaEquipada(p, "GeriFreki", ZDOVars.s_rightItem);
			if (num <= 0)
			{
				return Legendaria.EtapaEquipada(p, "GeriFreki", ZDOVars.s_leftItem);
			}
			return num;
		}

		public static float Bonificacion()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || _golpes == 0)
			{
				return 0f;
			}
			if (Time.time - _ultimoGolpe > C.VelocidadVentana.Value || Legendaria.EtapaDe(((Humanoid)localPlayer).GetCurrentWeapon(), "GeriFreki") == 0)
			{
				_golpes = 0;
				return 0f;
			}
			return Mathf.Min(C.VelocidadMaxima.Value, (float)_golpes * C.VelocidadPorGolpe.Value);
		}

		public static int NivelFerocidad()
		{
			if (FerocidadForzada >= 0)
			{
				return FerocidadForzada;
			}
			float num = Bonificacion();
			float value = C.VelocidadMaxima.Value;
			if (num <= 0f || value <= 0f)
			{
				return 0;
			}
			if (num >= value - 0.0001f)
			{
				return 4;
			}
			return Mathf.Clamp(Mathf.CeilToInt(num / value * 4f - 0.0001f), 1, 3);
		}

		public static bool SangradoDe(Character c, out int cargas, out float restante)
		{
			Sangrado sangrado = (((Object)(object)c != (Object)null) ? ((Component)c).GetComponent<Sangrado>() : null);
			cargas = (((Object)(object)sangrado != (Object)null) ? sangrado.Cargas : 0);
			restante = (((Object)(object)sangrado != (Object)null) ? sangrado.Restante : 0f);
			return cargas > 0;
		}
	}
	internal class GestoLlamada : MonoBehaviour
	{
		private class Brazo
		{
			public Transform Hombro;

			public Transform Codo;

			public Transform Mano;

			public float Peso;

			public float Soltar;

			public Vector3 Hacia;
		}

		private static readonly int ZdoLlamando = StringExtensionMethods.GetStableHashCode("roa_gesto_llamada");

		private static readonly int ZdoHacia = StringExtensionMethods.GetStableHashCode("roa_gesto_hacia");

		private const float Subida = 10f;

		private const float Bajada = 5f;

		private const float Elevacion = 0.45f;

		private readonly Dictionary<Player, Brazo> _brazos = new Dictionary<Player, Brazo>();

		private readonly List<Player> _quitar = new List<Player>();

		private static bool _informado;

		internal static void Empezar(Player jugador, Vector3 hacha)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			ZDO val = Zdo(jugador);
			if (val != null)
			{
				val.Set(ZdoLlamando, true);
				val.Set(ZdoHacia, hacha);
			}
		}

		internal static void Apuntar(Player jugador, Vector3 hacha)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			ZDO val = Zdo(jugador);
			if (val != null && val.GetBool(ZdoLlamando, false))
			{
				val.Set(ZdoHacia, hacha);
			}
		}

		internal static void Terminar(Player jugador)
		{
			ZDO val = Zdo(jugador);
			if (val != null && val.GetBool(ZdoLlamando, false))
			{
				val.Set(ZdoLlamando, false);
			}
		}

		private static ZDO Zdo(Player jugador)
		{
			ZNetView val = (((Object)(object)jugador != (Object)null) ? ((Component)jugador).GetComponent<ZNetView>() : null);
			if (!((Object)(object)val != (Object)null) || !val.IsValid() || !val.IsOwner())
			{
				return null;
			}
			return val.GetZDO();
		}

		private void LateUpdate()
		{
			//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_00b3: Unknown result type (might be due to invalid IL or missing references)
			float deltaTime = Time.deltaTime;
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if ((Object)(object)allPlayer == (Object)null)
				{
					continue;
				}
				ZNetView component = ((Component)allPlayer).GetComponent<ZNetView>();
				if ((Object)(object)component == (Object)null || !component.IsValid())
				{
					continue;
				}
				ZDO zDO = component.GetZDO();
				bool flag = zDO.GetBool(ZdoLlamando, false);
				_brazos.TryGetValue(allPlayer, out var value);
				if (!flag && value == null)
				{
					continue;
				}
				if (value == null)
				{
					value = Buscar(allPlayer);
					if (value == null)
					{
						continue;
					}
					_brazos[allPlayer] = value;
				}
				if (flag)
				{
					value.Hacia = zDO.GetVec3(ZdoHacia, value.Hacia);
					value.Soltar = Hrimnir.C.GestoDuracion.Value;
					value.Peso = Mathf.MoveTowards(value.Peso, 1f, 10f * deltaTime);
				}
				else if (value.Soltar > 0f)
				{
					value.Soltar -= deltaTime;
				}
				else
				{
					value.Peso = Mathf.MoveTowards(value.Peso, 0f, 5f * deltaTime);
				}
				if (value.Peso <= 0f && !flag)
				{
					_quitar.Add(allPlayer);
				}
				else
				{
					Girar(value);
				}
			}
			foreach (Player item in _quitar)
			{
				_brazos.Remove(item);
			}
			_quitar.Clear();
			foreach (KeyValuePair<Player, Brazo> brazo in _brazos)
			{
				if ((Object)(object)brazo.Key == (Object)null)
				{
					_quitar.Add(brazo.Key);
				}
			}
			foreach (Player item2 in _quitar)
			{
				_brazos.Remove(item2);
			}
			_quitar.Clear();
		}

		private static void Girar(Brazo b)
		{
			//IL_0042: 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_0057: 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_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_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)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b5: 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_00c6: 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_00db: 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_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_00f7: 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_00fd: 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_010a: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)b.Hombro == (Object)null) && !((Object)(object)b.Codo == (Object)null) && !((Object)(object)b.Mano == (Object)null))
			{
				float num = Mathf.SmoothStep(0f, 1f, b.Peso);
				Vector3 val = b.Hacia - b.Hombro.position;
				if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f))
				{
					Vector3 val2 = ((Vector3)(ref val)).normalized + Vector3.up * 0.45f;
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					Vector3 val3 = b.Codo.position - b.Hombro.position;
					b.Hombro.rotation = Quaternion.Slerp(Quaternion.identity, Quaternion.FromToRotation(val3, normalized), num) * b.Hombro.rotation;
					val3 = b.Mano.position - b.Codo.position;
					b.Codo.rotation = Quaternion.Slerp(Quaternion.identity, Quaternion.FromToRotation(val3, normalized), num * 0.9f) * b.Codo.rotation;
				}
			}
		}

		private static Brazo Buscar(Player jugador)
		{
			//IL_00e2: 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_00f7: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)jugador).GetComponent<VisEquipment>()?.m_rightHand;
			Transform val2 = (((Object)(object)val != (Object)null) ? val.parent : null);
			Transform val3 = (((Object)(object)val2 != (Object)null) ? val2.parent : null);
			Transform val4 = (((Object)(object)val3 != (Object)null) ? val3.parent : null);
			if ((Object)(object)val4 == (Object)null)
			{
				return null;
			}
			if (!_informado)
			{
				_informado = true;
				Registro.Depurar("Gesto de llamada: huesos " + ((Object)val4).name + " → " + ((Object)val3).name + " → " + ((Object)val2).name + " (agarre " + ((Object)val).name + ").");
			}
			return new Brazo
			{
				Hombro = val4,
				Codo = val3,
				Mano = val2,
				Hacia = ((Component)jugador).transform.position + ((Component)jugador).transform.forward * 5f
			};
		}
	}
	internal static class Gram
	{
		[HarmonyPatch(typeof(Humanoid), "StartAttack")]
		private static class Humanoid_StartAttack
		{
			private static bool Prefix(Humanoid __instance, bool secondaryAttack, ref bool __result)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Expected O, but got Unknown
				try
				{
					if (_lanzando || !secondaryAttack || (Object)(object)__instance != (Object)(object)Player.m_localPlayer)
					{
						return true;
					}
					Player val = (Player)__instance;
					if (Legendaria.EtapaDe(((Humanoid)val).GetCurrentWeapon(), "Gram") == 0)
					{
						return true;
					}
					if (SecundarioPulsado.Invoke((Character)(object)val) && !_esperarSoltar && !_cargando && _soltarHasta < 0f)
					{
						_cargando = true;
						_inicioCarga = Time.time;
						Registro.Depurar("Gram: empieza la carga.");
					}
					__result = false;
					return false;
				}
				catch (Exception arg)
				{
					Registro.Error($"Carga de Gram: {arg}");
					return true;
				}
			}

			private static void Postfix(Humanoid __instance, bool secondaryAttack, bool __result)
			{
				if (__result && !secondaryAttack && !_lanzando && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && (_cargando || _soltarHasta > 0f))
				{
					Cancelar("ataque normal", esperarSoltar: true);
				}
			}
		}

		[HarmonyPatch(typeof(Player), "PlayerAttackInput")]
		private static class Player_PlayerAttackInput
		{
			private static void Postfix(Player __instance)
			{
				try
				{
					if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
					{
						return;
					}
					bool flag = SecundarioPulsado.Invoke((Character)(object)__instance);
					if (!flag)
					{
						_esperarSoltar = false;
					}
					if (Legendaria.EtapaDe(((Humanoid)__instance).GetCurrentWeapon(), "Gram") == 0 || ((Character)__instance).IsDead())
					{
						Cancelar("sin Gram en la mano", esperarSoltar: false);
						_parryHasta = -1f;
						PonerVisual(__instance, cargado: false);
						SincronizarCarga(__instance);
						PonerAnimacion(__instance);
						return;
					}
					if ((_cargando || _soltarHasta > 0f) && (((Character)__instance).InDodge() || ((Character)__instance).IsStaggering()))
					{
						Cancelar("esquiva o aturdimiento", flag);
					}
					if (_cargando && !flag && _soltarHasta < 0f)
					{
						_soltarHasta = Time.time + 0.6f;
					}
					if (_soltarHasta > 0f)
					{
						if (Soltar(__instance))
						{
							_soltarHasta = -1f;
							_esperarSoltar = flag;
						}
						else if (Time.time > _soltarHasta)
						{
							Cancelar("no se pudo atacar al soltar", flag);
						}
					}
					PonerVisual(__instance, Carga >= 1f);
					SincronizarCarga(__instance);
					PonerAnimacion(__instance);
				}
				catch (Exception arg)
				{
					Registro.Error($"Carga de Gram: {arg}");
				}
			}
		}

		[HarmonyPatch(typeof(Humanoid), "GetAttackSpeedFactorMovement")]
		private static class Humanoid_GetAttackSpeedFactorMovement
		{
			private static void Postfix(Humanoid __instance, ref float __result)
			{
				if (_cargando && (Object)(object)__instance == (Object)(object)Player.m_localPlayer)
				{
					__result *= C.CargaVelocidad.Value;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "CheckRun")]
		private static class Player_CheckRun
		{
			private static void Postfix(Player __instance, ref bool __result)
			{
				if (_cargando && (Object)(object)__instance == (Object)(object)Player.m_localPlayer)
				{
					__result = false;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "AlwaysRotateCamera")]
		private static class Player_AlwaysRotateCamera
		{
			private static void Postfix(Player __instance, ref bool __result)
			{
				if (_cargando && (Object)(object)__instance == (Object)(object)Player.m_localPlayer)
				{
					__result = true;
				}
			}
		}

		[HarmonyPatch(typeof(Humanoid), "BlockAttack")]
		private static class Humanoid_BlockAttack
		{
			private static void Prefix(Humanoid __instance, out bool __state)
			{
				__state = false;
				try
				{
					if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
					{
						return;
					}
					ItemData val = Bloqueador(__instance);
					if (val != null && !(val.m_shared.m_timedBlockBonus <= 1f))
					{
						int num = Legendaria.EtapaDe(val, "Gram");
						if (num != 0 && num >= C.EtapaParry.Value)
						{
							float num2 = TiempoBloqueo.Invoke(__instance);
							__state = num2 >= 0f && num2 < 0.25f;
						}
					}
				}
				catch (Exception arg)
				{
					Registro.Error($"Parry de Gram: {arg}");
				}
			}

			private static void Postfix(Humanoid __instance, Character attacker, bool __result, bool __state)
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Expected O, but got Unknown
				//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)
				if (__state && __result && !((Object)(object)attacker == (Object)null) && !((Character)__instance).IsStaggering() && ((Character)__instance).HaveStamina(0f))
				{
					DarCargaParry();
					ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
					Fx.Todos("Gram_Parry", Mano((Player)__instance), Quaternion.identity, component, 1f, "Gram");
					Registro.Depurar($"Gram: parry perfecto contra {attacker.m_name}; carga completa durante {C.ParryDuracion.Value:0.#} s.");
				}
			}
		}

		[HarmonyPatch(typeof(Attack), "DoMeleeAttack")]
		private static class Attack_DoMeleeAttack
		{
			private static void Postfix(Attack __instance)
			{
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0063: 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_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_00a4: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					if (__instance != _ataqueCargado || _ondaHecha)
					{
						return;
					}
					_ondaHecha = true;
					Player localPlayer = Player.m_localPlayer;
					if (!((Object)(object)localPlayer == (Object)null))
					{
						TajoGram.Crear(localPlayer, __instance.m_attackAngle, __instance.m_attackRange, _cargaAtaque);
						Vector3 val = Vector3.ProjectOnPlane(((Component)localPlayer).transform.forward, Vector3.up);
						Vector3 normalized = ((Vector3)(ref val)).normalized;
						if (_cargaAtaque >= 0.25f)
						{
							Fx.Todos("Gram_Soltar", ((Component)localPlayer).transform.position + normalized * 1.5f + Vector3.up * 0.5f, Quaternion.identity, null, 1f, "Gram");
						}
						ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon();
						int num = Legendaria.EtapaDe(currentWeapon, "Gram");
						ConfigReliquias.ConfigArma c = C;
						if (num != 0 && num >= c.EtapaOnda.Value && !(_cargaAtaque < c.OndaCargaMinima.Value))
						{
							Onda(localPlayer, currentWeapon, c);
						}
					}
				}
				catch (Exception arg)
				{
					Registro.Error($"Onda de choque de Gram: {arg}");
				}
			}
		}

		private const string Id = "Gram";

		private static readonly FieldRef<Character, bool> SecundarioPulsado = AccessTools.FieldRefAccess<Character, bool>("m_secondaryAttackHold");

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

		private static readonly FieldRef<Humanoid, float> TiempoBloqueo = AccessTools.FieldRefAccess<Humanoid, float>("m_blockTimer");

		private static readonly Func<Humanoid, ItemData> Bloqueador = AccessTools.MethodDelegate<Func<Humanoid, ItemData>>(AccessTools.Method(typeof(Humanoid), "GetCurrentBlocker", (Type[])null, (Type[])null), (object)null, true);

		private const float VentanaParry = 0.25f;

		private const float MargenSoltar = 0.6f;

		private static bool _cargando;

		private static float _inicioCarga;

		private static bool _esperarSoltar;

		private static float _soltarHasta = -1f;

		private static float _parryHasta = -1f;

		private static bool _lanzando;

		private static Attack _ataqueCargado;

		private static float _cargaAtaque;

		private static bool _ondaHecha;

		private static bool _visualCargado;

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

		private static string _animActiva = "";

		internal static string AnimacionForzada;

		private static ConfigReliquias.ConfigArma C => ConfigReliquias.Armas["Gram"];

		internal static float Carga
		{
			get
			{
				if (Time.time < _parryHasta)
				{
					return 1f;
				}
				if (!_cargando)
				{
					return 0f;
				}
				return Mathf.Clamp01((Time.time - _inicioCarga) / Mathf.Max(0.01f, C.CargaTiempo.Value));
			}
		}

		private static string AnimacionDeseada => (AnimacionForzada ?? C.CargaAnimacion.Value ?? "").Trim();

		internal static void DarCargaParry()
		{
			_parryHasta = Time.time + C.ParryDuracion.Value;
		}

		private static void Cancelar(string motivo, bool esperarSoltar)
		{
			if (_cargando)
			{
				Registro.Depurar("Gram: carga cancelada (" + motivo + ").");
			}
			_cargando = false;
			_soltarHasta = -1f;
			_esperarSoltar = esperarSoltar;
		}

		private static bool Soltar(Player jugador)
		{
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			float carga = Carga;
			_lanzando = true;
			bool flag;
			try
			{
				flag = ((Character)jugador).StartAttack((Character)null, true);
			}
			finally
			{
				_lanzando = false;
			}
			if (!flag)
			{
				return false;
			}
			Attack val = AtaqueActual.Invoke((Humanoid)(object)jugador);
			if (val == null)
			{
				return false;
			}
			ConfigReliquias.ConfigArma c = C;
			float num = Mathf.Lerp(1f, c.CargaMultiplicador.Value, carga);
			float num2 = Mathf.Lerp(1f, c.CargaAturdimiento.Value, carga);
			float attackAngle = val.m_attackAngle;
			val.m_damageMultiplier *= num;
			val.m_staggerMultiplier *= num2;
			val.m_attackAngle = Mathf.Max(val.m_attackAngle, c.TajoAngulo.Value);
			_ataqueCargado = val;
			_cargaAtaque = carga;
			_ondaHecha = false;
			_cargando = false;
			_parryHasta = -1f;
			Registro.Depurar($"Gram: golpe cargado al {carga * 100f:0} % → daño ×{num:0.00}, aturdimiento ×{num2:0.00}, " + $"ángulo {attackAngle:0}° → {val.m_attackAngle:0}° (animación '{val.m_attackAnimation}', tipo {val.m_attackType}), alcance {val.m_attackRange:0.0} m.");
			return true;
		}

		private static void PonerAnimacion(Player jugador)
		{
			ZSyncAnimation val = Animacion.Invoke((Character)(object)jugador);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			string text = (_cargando ? AnimacionDeseada : "");
			if (text != _animActiva)
			{
				if (_animActiva.Length > 0)
				{
					val.SetBool(_animActiva, false);
				}
				if (text.Length > 0)
				{
					val.SetBool(text, true);
				}
				_animActiva = text;
			}
			if (_animActiva.Length > 0)
			{
				val.SetFloat("drawpercent", Carga);
			}
		}

		internal static string InformeAnimaciones()
		{
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			StringBuilder stringBuilder = new StringBuilder();
			GameObject prefab = PrefabManager.Instance.GetPrefab("Player");
			ZSyncAnimation val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<ZSyncAnimation>() : null);
			if ((Object)(object)val != (Object)null)
			{
				stringBuilder.AppendLine("Bools del jugador: " + string.Join(", ", val.m_syncBools));
				stringBuilder.AppendLine("Floats del jugador: " + string.Join(", ", val.m_syncFloats));
				stringBuilder.AppendLine("Ints del jugador: " + string.Join(", ", val.m_syncInts));
			}
			Animator val2 = (((Object)(object)prefab != (Object)null) ? prefab.GetComponentInChildren<Animator>(true) : null);
			if ((Object)(object)val2 != (Object)null && (Object)(object)val2.runtimeAnimatorController != (Object)null)
			{
				SortedSet<string> sortedSet = new SortedSet<string>();
				AnimationClip[] animationClips = val2.runtimeAnimatorController.animationClips;
				foreach (AnimationClip val3 in animationClips)
				{
					if ((Object)(object)val3 != (Object)null)
					{
						sortedSet.Add(((Object)val3).name);
					}
				}
				stringBuilder.AppendLine("Animaciones del jugador: " + string.Join(", ", sortedSet));
			}
			SortedSet<string> sortedSet2 = new SortedSet<string>();
			if ((Object)(object)ObjectDB.instance != (Object)null)
			{
				foreach (GameObject item in ObjectDB.instance.m_items)
				{
					ItemDrop val4 = (((Object)(object)item != (Object)null) ? item.GetComponent<ItemDrop>() : null);
					if ((Object)(object)val4 == (Object)null)
					{
						continue;
					}
					Attack[] array = (Attack[])(object)new Attack[2]
					{
						val4.m_itemData.m_shared.m_attack,
						val4.m_itemData.m_shared.m_secondaryAttack
					};
					foreach (Attack val5 in array)
					{
						if (val5 != null && !string.IsNullOrEmpty(val5.m_drawAnimationState))
						{
							sortedSet2.Add(((Object)item).name + ": " + val5.m_drawAnimationState);
						}
					}
					if (((Object)item).name.StartsWith("THSword"))
					{
						Attack secondaryAttack = val4.m_itemData.m_shared.m_secondaryAttack;
						stringBuilder.AppendLine($"{((Object)item).name} secundario: animación '{secondaryAttack.m_attackAnimation}', tipo {secondaryAttack.m_attackType}, ángulo {secondaryAttack.m_attackAngle}, alcance {secondaryAttack.m_attackRange}");
					}
				}
			}
			stringBuilder.Append("Tensados de las armas del juego: " + string.Join("; ", sortedSet2));
			return stringBuilder.ToString();
		}

		private static void PonerVisual(Player jugador, bool cargado)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if (cargado == _visualCargado)
			{
				return;
			}
			ZNetView component = ((Component)jugador).GetComponent<ZNetView>();
			if (!((Object)(object)component == (Object)null) && component.IsValid())
			{
				_visualCargado = cargado;
				component.GetZDO().Set(EfectosLegendaria.ZdoGramCargado, cargado);
				if (cargado)
				{
					Registro.Depurar("Gram: carga completa.");
					Fx.Todos("Gram_CargaMaxima", Mano(jugador), Quaternion.identity, component, 1f, "Gram");
				}
			}
		}

		private static void SincronizarCarga(Player jugador)
		{
			ZNetView component = ((Component)jugador).GetComponent<ZNetView>();
			if (!((Object)(object)component == (Object)null) && component.IsValid())
			{
				float num = ((Legendaria.EtapaDe(((Humanoid)jugador).GetCurrentWeapon(), "Gram") == 0 || ((Character)jugador).IsDead()) ? 0f : Carga);
				ZDO zDO = component.GetZDO();
				float num2 = zDO.GetFloat(EfectosLegendaria.ZdoGramCarga, 0f);
				if (Mathf.Abs(num - num2) > 0.04f || num == 0f != (num2 == 0f) || (num >= 1f && num2 < 1f))
				{
					zDO.Set(EfectosLegendaria.ZdoGramCarga, num);
				}
			}
		}

		private static Vector3 Mano(Player jugador)
		{
			//IL_001f: 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)
			VisEquipment component = ((Component)jugador).GetComponent<VisEquipment>();
			if (!((Object)(object)component != (Object)null) || !((Object)(object)component.m_rightHand != (Object)null))
			{
				return ((Character)jugador).GetCenterPoint();
			}
			return component.m_rightHand.position;
		}

		private static void Onda(Player jugador, ItemData arma, ConfigReliquias.ConfigArma c)
		{
			//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_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_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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//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_0043: 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_004d: 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_00b1: 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_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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//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_00f2: 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_0195: 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_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_01b0: 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)
			Vector3 position = ((Component)jugador).transform.position;
			float value = c.OndaRadio.Value;
			Vector3 val = Vector3.ProjectOnPlane(((Component)jugador).transform.forward, Vector3.up);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Fx.Todos("Gram_Onda", position + normalized * 1.2f, Quaternion.LookRotation(normalized), null, Fx.GramOndaEscala.Value, "Gram");
			int num = 0;
			foreach (Character allCharacter in Character.GetAllCharacters())
			{
				if (!((Object)(object)allCharacter == (Object)null) && !((Object)(object)allCharacter == (Object)(object)jugador) && !allCharacter.IsDead())
				{
					Vector3 val2 = ((Component)allCharacter).transform.position - position;
					val2.y = 0f;
					if (!(((Vector3)(ref val2)).magnitude > value) && BaseAI.IsEnemy((Character)(object)jugador, allCharacter) && (!(((Vector3)(ref val2)).sqrMagnitude > 0.01f) || !(Vector3.Angle(normalized, val2) > c.OndaAngulo.Value * 0.5f)))
					{
						HitData val3 = new HitData();
						val3.m_damage = arma.GetDamage();
						((DamageTypes)(ref val3.m_damage)).Modify(c.OndaDano.Value);
						val3.m_pushForce = c.OndaEmpuje.Value;
						val3.m_staggerMultiplier = ((allCharacter.IsBoss() && !c.OndaDerribaJefes.Value) ? 1f : 100f);
						val3.m_dir = ((((Vector3)(ref val2)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val2)).normalized : ((Component)jugador).transform.forward);
						val3.m_point = allCharacter.GetCenterPoint();
						val3.m_skill = (SkillType)1;
						val3.m_skillRaiseAmount = 0f;
						val3.m_blockable = false;
						val3.m_dodgeable = false;
						val3.m_hitType = (HitType)2;
						val3.SetAttacker((Character)(object)jugador);
						allCharacter.Damage(val3);
						num++;
					}
				}
			}
			Registro.Depurar($"Gram: onda de choque (radio {value:0.#} m, {c.OndaAngulo.Value:0}° delante) alcanza a {num} enemigo(s).");
		}
	}
	internal static class Gungnir
	{
		[HarmonyPatch(typeof(Humanoid), "StartAttack")]
		private static class Humanoid_StartAttack
		{
			private static bool Prefix(Humanoid __instance, bool secondaryAttack, ref bool __result)
			{
				try
				{
					if (!secondaryAttack || (Object)(object)__instance != (Object)(object)Player.m_localPlayer || Time.time >= _recargaHasta)
					{
						return true;
					}
					if (Legendaria.EtapaDe(__instance.GetCurrentWeapon(), "Gungnir") == 0)
					{
						return true;
					}
					if (Time.time - _ultimoAviso > 1f)
					{
						_ultimoAviso = Time.time;
						string format = Localization.instance.Localize("$roa_msg_gungnir_recarga");
						((Character)__instance).Message((MessageType)2, string.Format(format, Mathf.CeilToInt(_recargaHasta - Time.time)), 0, (Sprite)null, false);
					}
					__result = false;
					return false;
				}
				catch (Exception arg)
				{
					Registro.Error($"Gungnir: {arg}");
					return true;
				}
			}
		}

		[HarmonyPatch(typeof(Projectile), "Setup")]
		private static class Projectile_Setup
		{
			private static void Postfix(Projectile __instance, Character owner, ItemData item)
			{
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Expected O, but got Unknown
				try
				{
					if (!((Object)(object)owner == (Object)null) && !((Object)(object)owner != (Object)(object)Player.m_localPlayer))
					{
						int num = Legendaria.EtapaDe(item, "Gungnir");
						if (num != 0)
						{
							__instance.m_spawnItem = null;
							__instance.m_respawnItemOnHit = false;
							__instance.m_attachToClosestBone = false;
							__instance.m_attachToRigidBody = false;
							__in