Decompiled source of VDMThrowingHooks v1.0.0

GarfioMod.dll

Decompiled 31 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("GarfioMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GarfioMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("87173636-3b6b-4ffa-b1a7-f4bb50662ed5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GarfioMod;

public class Arma
{
	public string Clave;

	public string Nombre;

	public string Prefab;

	public string PrefabVuelo;

	public int Indice;

	public bool Gira;

	public float Hundir;

	public float Vel;

	public float Masa;

	public GameObject Objeto;

	public GameObject Vuelo;

	public Vector3 ArgollaLocal;

	public Vector3 FiloLocal;

	public Vector3 HojaDir = Vector3.right;

	public Vector3 MangoDir = Vector3.forward;

	public bool Registrado;

	public GameObject Puesto;

	public ConfigEntry<float> ManoDistancia;

	public ConfigEntry<float> ManoAltura;

	public ConfigEntry<float> ManoLado;

	public ConfigEntry<float> GiroX;

	public ConfigEntry<float> GiroY;

	public ConfigEntry<float> GiroZ;

	public ConfigEntry<string> TiendaEscena;

	public ConfigEntry<string> TiendaRaiz;

	public ConfigEntry<float> TiendaX;

	public ConfigEntry<float> TiendaY;

	public ConfigEntry<float> TiendaZ;

	public ConfigEntry<float> TiendaGiro;

	public ConfigEntry<float> TiendaInclinacion;

	public ConfigEntry<float> TiendaVuelta;

	public ConfigEntry<int> Precio;

	public ConfigEntry<float> ColgX;

	public ConfigEntry<float> ColgY;

	public ConfigEntry<float> ColgZ;

	public ConfigEntry<float> ColgRotX;

	public ConfigEntry<float> ColgRotY;

	public ConfigEntry<float> ColgRotZ;
}
[BepInPlugin("vikingdmike.grapplinghook", "VDM Throwing Hooks", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private enum Fase
	{
		Nada,
		Volando,
		Pescando,
		Clavada,
		Volviendo
	}

	[HarmonyPatch(typeof(PrefabsDirectory), "Start")]
	private static class ParcheDirectorio
	{
		private static void Prefix(PrefabsDirectory __instance)
		{
			Insertar(__instance);
		}
	}

	public const string ID = "vikingdmike.grapplinghook";

	public static Plugin Instancia;

	public static ManualLogSource Log;

	public static Arma Hacha;

	public static Arma Arpon;

	public static Arma Mikhtaf;

	public static Arma Kaginawa;

	public static Arma[] Armas;

	public static Type TipoAttachable;

	public static PropertyInfo PropPosColgado;

	public static PropertyInfo PropGiroColgado;

	private ConfigEntry<KeyCode> teclaLocalizar;

	public static ConfigEntry<float> Brillo;

	public static ConfigEntry<bool> SinReflejos;

	public static ConfigEntry<float> ProbPesca;

	private static readonly Dictionary<Material, Color> coloresOriginales = new Dictionary<Material, Color>();

	private const float Alcance = 35f;

	private const float Recoger = 2f;

	private const float CuerdaMin = 0.9f;

	private const float Rigidez = 15f;

	private const float TiroMax = 35f;

	private const float Freno = 2f;

	private const float TiempoMax = 40f;

	private Fase fase;

	private Arma arma;

	private GarfioItem lanzadora;

	private GameObject copia;

	private ShipItem objetivo;

	private Rigidbody cuerpo;

	private Vector3 desde;

	private Vector3 hasta;

	private Vector3 golpeLocal;

	private float vueltas;

	private float tVuelo;

	private float durVuelo;

	private float giro;

	private float largo;

	private float inicio;

	private float tLanzado;

	private LineRenderer cuerda;

	private bool pescar;

	private const float NivelMar = 0f;

	public bool Ocupada => fase != Fase.Nada;

	private void Awake()
	{
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_0350: Unknown result type (might be due to invalid IL or missing references)
		//IL_0369: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0397: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0429: Unknown result type (might be due to invalid IL or missing references)
		//IL_0433: Expected O, but got Unknown
		//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e2: Expected O, but got Unknown
		Instancia = this;
		Log = ((BaseUnityPlugin)this).Logger;
		Hacha = new Arma
		{
			Clave = "Hacha",
			Nombre = "grappling axe",
			Prefab = "hacha",
			PrefabVuelo = "hacha_vuelo",
			Indice = 24601,
			Gira = true,
			Hundir = 0.03f,
			Vel = 14f,
			Masa = 2f
		};
		Arpon = new Arma
		{
			Clave = "Arpon",
			Nombre = "harpoon",
			Prefab = "arpon_con_cuerda",
			PrefabVuelo = "arpon_vuelo",
			Indice = 24602,
			Gira = false,
			Hundir = 0.3f,
			Vel = 20f,
			Masa = 3f
		};
		Mikhtaf = new Arma
		{
			Clave = "Mikhtaf",
			Nombre = "mikhtaf",
			Prefab = "mikhtaf_con_cuerda",
			PrefabVuelo = "mikhtaf_vuelo",
			Indice = 24603,
			Gira = true,
			Hundir = 0.03f,
			Vel = 15f,
			Masa = 1.5f
		};
		Kaginawa = new Arma
		{
			Clave = "Kaginawa",
			Nombre = "kaginawa",
			Prefab = "kaginawa_con_cuerda",
			PrefabVuelo = "kaginawa_vuelo",
			Indice = 24604,
			Gira = true,
			Hundir = 0.03f,
			Vel = 15f,
			Masa = 1.5f
		};
		Armas = new Arma[4] { Hacha, Arpon, Mikhtaf, Kaginawa };
		Configurar(Hacha, "", "axe", 0.6f, -0.1f, 0f, new Vector3(90f, 0f, -70f), "island 17 M (Mount Malefic)", "island 17 M (mount malefic) scenery", -412.218f, 4.266f, 281.102f, new Vector3(25f, 90f, 0f), 300, new Vector3(0.1f, 0f, -0.1f), new Vector3(90f, 0f, 0f));
		Configurar(Mikhtaf, "Mikhtaf ", "mikhtaf", 0.5f, -0.2f, 0.2f, new Vector3(0f, 0f, 165f), "island 1 A Gold Rock", "island 1 A (gold rock) scenery", 1544.214f, 7.6f, -375.61f, new Vector3(90f, 0f, 0f), 250, new Vector3(0f, -0.17f, -0.1f), Vector3.zero);
		Configurar(Kaginawa, "Kaginawa ", "kaginawa", 0.5f, -0.2f, 0.2f, new Vector3(0f, 0f, 165f), "island 9 E Dragon Cliffs", "island 9 E (dragon cliffs) scenery", -66.2f, 4.45f, -547.221f, new Vector3(-25f, 0f, 0f), 250, new Vector3(0f, -0.17f, -0.12f), Vector3.zero);
		Configurar(Arpon, "Harpoon ", "harpoon", 0.7f, 0.1f, 0.25f, Vector3.zero, "island 15 M (Fort)", "island 15 M (Fort) scenery", -125.202f, 3.025f, 32.083f, new Vector3(99f, 0f, 36f), 450, new Vector3(0f, -0.2f, -0.1f), new Vector3(-90f, 0f, 0f));
		Brillo = ((BaseUnityPlugin)this).Config.Bind<float>("Colors", "Brightness", 1f, new ConfigDescription("Multiplies the colors (1 = as in Blender)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), Array.Empty<object>()));
		SinReflejos = ((BaseUnityPlugin)this).Config.Bind<bool>("Colors", "NoShine", true, "Removes the grey shine of the sky");
		Brillo.SettingChanged += delegate
		{
			AplicarColores();
		};
		SinReflejos.SettingChanged += delegate
		{
			AplicarColores();
		};
		ProbPesca = ((BaseUnityPlugin)this).Config.Bind<float>("Harpoon Fishing", "Chance", 3f, new ConfigDescription("Chance (%) of spearing a fish when the harpoon falls into the sea", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
		CargarPaquete();
		Harmony.CreateAndPatchAll(typeof(ParcheDirectorio), "vikingdmike.grapplinghook");
		if ((Object)(object)PrefabsDirectory.instance != (Object)null)
		{
			Insertar(PrefabsDirectory.instance);
			AccessTools.Method(typeof(PrefabsDirectory), "PopulateShipItems", (Type[])null, (Type[])null).Invoke(PrefabsDirectory.instance, null);
		}
		SceneManager.sceneLoaded += delegate(Scene e, LoadSceneMode m)
		{
			Arma[] armas = Armas;
			foreach (Arma arma in armas)
			{
				if ((Object)(object)arma.Objeto != (Object)null && ((Scene)(ref e)).name == arma.TiendaEscena.Value)
				{
					((MonoBehaviour)this).StartCoroutine(PonerEnTienda(arma));
				}
			}
		};
		((MonoBehaviour)this).StartCoroutine(RegistrarColgado());
		((BaseUnityPlugin)this).Logger.LogInfo((object)"VDM Throwing Hooks cargado");
	}

	private void Configurar(Arma a, string pre, string cosa, float dist, float alto, float lado, Vector3 giro, string escena, string raiz, float x, float y, float z, Vector3 tienda, int precio, Vector3 colg, Vector3 colgGiro)
	{
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0334: Unknown result type (might be due to invalid IL or missing references)
		//IL_0366: Unknown result type (might be due to invalid IL or missing references)
		//IL_0398: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_042e: Unknown result type (might be due to invalid IL or missing references)
		a.ManoDistancia = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Hand", "Distance", dist, "Distance from the camera when held");
		a.ManoAltura = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Hand", "Height", alto, "Height when held");
		a.ManoLado = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Hand", "Side", lado, "Moves it to the right (+) or left (-) when held");
		a.GiroX = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Hand", "RotX", giro.x, "Rotation X when held");
		a.GiroY = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Hand", "RotY", giro.y, "Rotation Y when held");
		a.GiroZ = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Hand", "RotZ", giro.z, "Rotation Z when held");
		a.TiendaEscena = ((BaseUnityPlugin)this).Config.Bind<string>(pre + "Shop", "Scene", escena, "Island scene of the " + cosa + " shop");
		a.TiendaRaiz = ((BaseUnityPlugin)this).Config.Bind<string>(pre + "Shop", "Root", raiz, "Island root object");
		a.TiendaX = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Shop", "PosX", x, "Shop position X");
		a.TiendaY = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Shop", "PosY", y, "Shop position Y");
		a.TiendaZ = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Shop", "PosZ", z, "Shop position Z");
		a.TiendaGiro = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Shop", "Rotation", tienda.x, "Shop rotation");
		a.TiendaInclinacion = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Shop", "Tilt", tienda.y, "Shop tilt (90 = lying)");
		a.TiendaVuelta = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Shop", "Roll", tienda.z, "Shop roll (turns it over its own length)");
		a.Precio = ((BaseUnityPlugin)this).Config.Bind<int>(pre + "Shop", "Price", precio, "Price");
		a.TiendaEscena.SettingChanged += delegate
		{
			CambiarTienda(a);
		};
		a.TiendaRaiz.SettingChanged += delegate
		{
			CambiarTienda(a);
		};
		a.ColgX = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Hook", "PosX", colg.x, "Offset X when hanging on a hook (HooksHangMore)");
		a.ColgY = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Hook", "PosY", colg.y, "Offset Y when hanging on a hook");
		a.ColgZ = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Hook", "PosZ", colg.z, "Offset Z when hanging on a hook");
		a.ColgRotX = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Hook", "RotX", colgGiro.x, "Rotation X when hanging on a hook");
		a.ColgRotY = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Hook", "RotY", colgGiro.y, "Rotation Y when hanging on a hook");
		a.ColgRotZ = ((BaseUnityPlugin)this).Config.Bind<float>(pre + "Hook", "RotZ", colgGiro.z, "Rotation Z when hanging on a hook");
	}

	private void CargarPaquete()
	{
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "garfio_bundle");
		if (!File.Exists(text))
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("No encuentro garfio_bundle en " + text));
			return;
		}
		AssetBundle val = AssetBundle.LoadFromFile(text);
		if ((Object)(object)val == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"No he podido abrir garfio_bundle");
			return;
		}
		Arma[] armas = Armas;
		foreach (Arma arma in armas)
		{
			GameObject val2 = val.LoadAsset<GameObject>(arma.Prefab);
			GameObject val3 = val.LoadAsset<GameObject>(arma.PrefabVuelo);
			if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Faltan prefabs de " + arma.Clave + " en garfio_bundle"));
				continue;
			}
			AjustarColores(val2);
			AjustarColores(val3);
			GarfioItem obj = ((arma == Hacha) ? val2.AddComponent<HachaItem>() : ((arma == Arpon) ? val2.AddComponent<ArponItem>() : ((arma == Mikhtaf) ? ((GarfioItem)val2.AddComponent<MikhtafItem>()) : ((GarfioItem)val2.AddComponent<KaginawaItem>()))));
			((PickupableItem)obj).holdDistance = arma.ManoDistancia.Value;
			((PickupableItem)obj).holdHeight = arma.ManoAltura.Value;
			((PickupableItem)obj).furniturePlaceHeight = 0.04f;
			((ShipItem)obj).mass = arma.Masa;
			((ShipItem)obj).value = arma.Precio.Value;
			((ShipItem)obj).name = arma.Nombre;
			((ShipItem)obj).category = (TransactionCategory)3;
			((ShipItem)obj).inventoryScale = 1f;
			((ShipItem)obj).floaterHeight = 1.6f;
			((GoPointerButton)obj).allowPlacingItems = true;
			val2.AddComponent<SaveablePrefab>().prefabIndex = arma.Indice;
			arma.Objeto = val2;
			arma.Vuelo = val3;
			BuscarGeometria(arma);
		}
	}

	private unsafe void AjustarColores(GameObject go)
	{
		//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_0062: 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_007a: 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_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			Material[] sharedMaterials = componentsInChildren[i].sharedMaterials;
			foreach (Material val in sharedMaterials)
			{
				if ((Object)(object)val != (Object)null && val.HasProperty("_Color") && !coloresOriginales.ContainsKey(val))
				{
					Color color = val.color;
					coloresOriginales[val] = new Color(Mathf.LinearToGammaSpace(color.r), Mathf.LinearToGammaSpace(color.g), Mathf.LinearToGammaSpace(color.b), color.a);
					ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
					string[] obj = new string[6]
					{
						"COLOR: ",
						((Object)val).name,
						" pasa de ",
						null,
						null,
						null
					};
					Color val2 = color;
					obj[3] = ((object)(*(Color*)(&val2))/*cast due to .constrained prefix*/).ToString();
					obj[4] = " a ";
					obj[5] = ((object)coloresOriginales[val]/*cast due to .constrained prefix*/).ToString();
					logger.LogDebug((object)string.Concat(obj));
				}
			}
		}
		AplicarColores();
	}

	public static void AplicarColores()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: 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_005d: 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)
		foreach (KeyValuePair<Material, Color> coloresOriginale in coloresOriginales)
		{
			Material key = coloresOriginale.Key;
			if (!((Object)(object)key == (Object)null))
			{
				Color value = coloresOriginale.Value;
				float value2 = Brillo.Value;
				key.color = new Color(Mathf.Clamp01(value.r * value2), Mathf.Clamp01(value.g * value2), Mathf.Clamp01(value.b * value2), value.a);
				bool value3 = SinReflejos.Value;
				if (value3 && key.HasProperty("_Metallic"))
				{
					key.SetFloat("_Metallic", 0f);
				}
				if (value3 && key.HasProperty("_Glossiness"))
				{
					key.SetFloat("_Glossiness", 0f);
				}
				if (key.HasProperty("_SpecularHighlights"))
				{
					key.SetFloat("_SpecularHighlights", value3 ? 0f : 1f);
				}
				if (key.HasProperty("_GlossyReflections"))
				{
					key.SetFloat("_GlossyReflections", value3 ? 0f : 1f);
				}
				if (value3)
				{
					key.EnableKeyword("_SPECULARHIGHLIGHTS_OFF");
					key.EnableKeyword("_GLOSSYREFLECTIONS_OFF");
				}
				else
				{
					key.DisableKeyword("_SPECULARHIGHLIGHTS_OFF");
					key.DisableKeyword("_GLOSSYREFLECTIONS_OFF");
				}
			}
		}
	}

	private void BuscarGeometria(Arma a)
	{
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_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_00a5: 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_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: 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_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0362: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_036a: Unknown result type (might be due to invalid IL or missing references)
		//IL_036d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		//IL_037b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0380: Unknown result type (might be due to invalid IL or missing references)
		//IL_038c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0391: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_03af: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0333: Unknown result type (might be due to invalid IL or missing references)
		//IL_040e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0410: Unknown result type (might be due to invalid IL or missing references)
		//IL_042b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0430: Unknown result type (might be due to invalid IL or missing references)
		//IL_0432: Unknown result type (might be due to invalid IL or missing references)
		//IL_0435: Unknown result type (might be due to invalid IL or missing references)
		//IL_043a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0440: Unknown result type (might be due to invalid IL or missing references)
		//IL_0457: Unknown result type (might be due to invalid IL or missing references)
		//IL_0459: Unknown result type (might be due to invalid IL or missing references)
		GameObject vuelo = a.Vuelo;
		List<Vector3> list = new List<Vector3>();
		MeshFilter[] componentsInChildren = vuelo.GetComponentsInChildren<MeshFilter>();
		foreach (MeshFilter val in componentsInChildren)
		{
			if ((Object)(object)val.sharedMesh == (Object)null)
			{
				continue;
			}
			if (!val.sharedMesh.isReadable)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("El modelo " + a.PrefabVuelo + " no tiene Read/Write activado en Unity"));
				continue;
			}
			Matrix4x4 val2 = vuelo.transform.worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix;
			Vector3[] vertices = val.sharedMesh.vertices;
			foreach (Vector3 val3 in vertices)
			{
				list.Add(((Matrix4x4)(ref val2)).MultiplyPoint3x4(val3));
			}
		}
		if (list.Count == 0)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("No puedo leer la forma de " + a.Clave + ": uso valores por defecto"));
			return;
		}
		Bounds val4 = default(Bounds);
		((Bounds)(ref val4))..ctor(list[0], Vector3.zero);
		foreach (Vector3 item in list)
		{
			((Bounds)(ref val4)).Encapsulate(item);
		}
		int num = ((!(((Bounds)(ref val4)).size.x >= ((Bounds)(ref val4)).size.y) || !(((Bounds)(ref val4)).size.x >= ((Bounds)(ref val4)).size.z)) ? ((((Bounds)(ref val4)).size.y >= ((Bounds)(ref val4)).size.z) ? 1 : 2) : 0);
		Vector3 val5 = ((Bounds)(ref val4)).min;
		float num2 = ((Vector3)(ref val5))[num];
		val5 = ((Bounds)(ref val4)).max;
		float num3 = ((Vector3)(ref val5))[num];
		float num4 = num3 - num2;
		List<Vector3> list2 = new List<Vector3>();
		List<Vector3> list3 = new List<Vector3>();
		List<Vector3> list4 = new List<Vector3>();
		List<Vector3> list5 = new List<Vector3>();
		foreach (Vector3 item2 in list)
		{
			Vector3 current2 = item2;
			if (((Vector3)(ref current2))[num] <= num2 + num4 * 0.06f)
			{
				list2.Add(current2);
			}
			if (((Vector3)(ref current2))[num] >= num3 - num4 * 0.25f)
			{
				list3.Add(current2);
			}
			if (((Vector3)(ref current2))[num] >= num3 - num4 * 0.06f)
			{
				list5.Add(current2);
			}
			if (((Vector3)(ref current2))[num] <= num2 + num4 * 0.25f)
			{
				list4.Add(current2);
			}
		}
		bool flag = (a.Gira ? (Ancho(list2) < Ancho(list5)) : (Ancho(list4) < Ancho(list3)));
		List<Vector3> ps = (flag ? list2 : list5);
		List<Vector3> list6 = (flag ? list3 : list4);
		if (a.Gira)
		{
			a.ArgollaLocal = Media(ps);
		}
		else
		{
			List<Vector3> list7 = new List<Vector3>();
			foreach (Vector3 item3 in list)
			{
				Vector3 current3 = item3;
				if (flag ? (((Vector3)(ref current3))[num] <= num2 + 0.04f) : (((Vector3)(ref current3))[num] >= num3 - 0.04f))
				{
					list7.Add(current3);
				}
			}
			a.ArgollaLocal = Media(list7);
		}
		Vector3 val6 = Media(list6);
		val5 = val6 - a.ArgollaLocal;
		a.MangoDir = ((Vector3)(ref val5)).normalized;
		float num5 = -1f;
		Vector3 filoLocal = Vector3.zero;
		foreach (Vector3 item4 in list6)
		{
			Vector3 val7 = item4 - a.ArgollaLocal;
			Vector3 val8 = val7 - Vector3.Project(val7, a.MangoDir);
			if (((Vector3)(ref val8)).sqrMagnitude > num5)
			{
				num5 = ((Vector3)(ref val8)).sqrMagnitude;
				filoLocal = item4;
				a.HojaDir = ((Vector3)(ref val8)).normalized;
			}
		}
		if (a.Gira)
		{
			a.FiloLocal = filoLocal;
		}
		else
		{
			float num6 = float.MinValue;
			foreach (Vector3 item5 in list6)
			{
				float num7 = Vector3.Dot(item5 - a.ArgollaLocal, a.MangoDir);
				if (num7 > num6)
				{
					num6 = num7;
					a.FiloLocal = item5;
				}
			}
		}
		((BaseUnityPlugin)this).Logger.LogDebug((object)(a.Clave + ": argolla " + ((Vector3)(ref a.ArgollaLocal)).ToString("F3") + ", filo/punta " + ((Vector3)(ref a.FiloLocal)).ToString("F3") + ", mango hacia " + ((Vector3)(ref a.MangoDir)).ToString("F2") + ", hoja/pua hacia " + ((Vector3)(ref a.HojaDir)).ToString("F2")));
	}

	private static float Ancho(List<Vector3> ps)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: 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)
		if (ps.Count == 0)
		{
			return float.MaxValue;
		}
		Bounds val = default(Bounds);
		((Bounds)(ref val))..ctor(ps[0], Vector3.zero);
		foreach (Vector3 p in ps)
		{
			((Bounds)(ref val)).Encapsulate(p);
		}
		Vector3 size = ((Bounds)(ref val)).size;
		return ((Vector3)(ref size)).sqrMagnitude;
	}

	private static Vector3 Media(List<Vector3> ps)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: 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_0047: 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_0041: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = Vector3.zero;
		foreach (Vector3 p in ps)
		{
			val += p;
		}
		if (ps.Count <= 0)
		{
			return Vector3.zero;
		}
		return val / (float)ps.Count;
	}

	private static Quaternion GiroClavada(Arma a, Vector3 dir)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: 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_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = Vector3.up;
		if (Mathf.Abs(Vector3.Dot(((Vector3)(ref dir)).normalized, val)) > 0.95f)
		{
			val = Vector3.forward;
		}
		if (a.Gira)
		{
			return Quaternion.LookRotation(dir, val) * Quaternion.Inverse(Quaternion.LookRotation(a.HojaDir, a.MangoDir));
		}
		Vector3 val2 = Vector3.Cross(a.MangoDir, a.HojaDir);
		if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f)
		{
			val2 = Vector3.up;
		}
		return Quaternion.LookRotation(dir, val) * Quaternion.Inverse(Quaternion.LookRotation(a.MangoDir, ((Vector3)(ref val2)).normalized));
	}

	private IEnumerator RegistrarColgado()
	{
		while ((Object)(object)PrefabsDirectory.instance == (Object)null || !Hacha.Registrado)
		{
			yield return (object)new WaitForSeconds(1f);
		}
		try
		{
			Type type = null;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				if (type == null)
				{
					type = assembly.GetType("HooksHangMore.HHM_Plugin");
				}
				if (TipoAttachable == null)
				{
					TipoAttachable = assembly.GetType("HooksHangMore.AttachableItem");
				}
			}
			if (type == null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"COLGAR: HooksHangMore no esta instalado");
				yield break;
			}
			if (TipoAttachable != null)
			{
				PropPosColgado = TipoAttachable.GetProperty("PositionOffset", BindingFlags.Instance | BindingFlags.Public);
				PropGiroColgado = TipoAttachable.GetProperty("RotationOffset", BindingFlags.Instance | BindingFlags.Public);
			}
			MethodInfo method = type.GetMethod("AddAttachedOffset", BindingFlags.Static | BindingFlags.Public);
			if (method == null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"COLGAR: esta version de HooksHangMore no tiene AddAttachedOffset");
				yield break;
			}
			Arma[] armas = Armas;
			foreach (Arma arma in armas)
			{
				if (arma.Registrado)
				{
					object obj = method.Invoke(null, new object[3]
					{
						arma.Nombre,
						(object)new Vector3(arma.ColgX.Value, arma.ColgY.Value, arma.ColgZ.Value),
						(object)new Vector3(arma.ColgRotX.Value, arma.ColgRotY.Value, arma.ColgRotZ.Value)
					});
					((BaseUnityPlugin)this).Logger.LogDebug((object)("COLGAR: AddAttachedOffset('" + arma.Nombre + "') -> " + obj));
				}
			}
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("COLGAR: no se pudo registrar: " + ex.Message));
		}
	}

	private static void Insertar(PrefabsDirectory dir)
	{
		Arma[] armas = Armas;
		foreach (Arma arma in armas)
		{
			if ((Object)(object)arma.Objeto == (Object)null || arma.Registrado)
			{
				continue;
			}
			if (arma.Indice < dir.directory.Length && (Object)(object)dir.directory[arma.Indice] != (Object)null && (Object)(object)dir.directory[arma.Indice] != (Object)(object)arma.Objeto)
			{
				Log.LogError((object)("La posicion " + arma.Indice + " ya esta ocupada por otro objeto: no registro " + arma.Clave));
				continue;
			}
			if (arma.Indice >= dir.directory.Length)
			{
				GameObject[] array = (GameObject[])(object)new GameObject[arma.Indice + 1];
				dir.directory.CopyTo(array, 0);
				dir.directory = array;
			}
			dir.directory[arma.Indice] = arma.Objeto;
			arma.Registrado = true;
			Log.LogDebug((object)(arma.Clave + " registrado en la posicion " + arma.Indice));
		}
	}

	private void CambiarTienda(Arma a)
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)a.Puesto != (Object)null)
		{
			((Object)a.Puesto).name = "viejo";
			a.Puesto.transform.SetParent((Transform)null);
			Object.Destroy((Object)(object)a.Puesto);
		}
		a.Puesto = null;
		if ((Object)(object)a.Objeto != (Object)null)
		{
			Scene sceneByName = SceneManager.GetSceneByName(a.TiendaEscena.Value);
			if (((Scene)(ref sceneByName)).isLoaded)
			{
				((MonoBehaviour)this).StartCoroutine(PonerEnTienda(a));
			}
		}
	}

	private IEnumerator PonerEnTienda(Arma a)
	{
		while (!a.Registrado)
		{
			yield return (object)new WaitForSeconds(1f);
		}
		GameObject raiz = null;
		for (int i = 0; i < 30; i++)
		{
			if (!((Object)(object)raiz == (Object)null))
			{
				break;
			}
			Scene sceneByName = SceneManager.GetSceneByName(a.TiendaEscena.Value);
			if (((Scene)(ref sceneByName)).isLoaded)
			{
				GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects();
				foreach (GameObject val in rootGameObjects)
				{
					if (((Object)val).name == a.TiendaRaiz.Value)
					{
						raiz = val;
						break;
					}
				}
			}
			if ((Object)(object)raiz == (Object)null)
			{
				yield return (object)new WaitForSeconds(1f);
			}
		}
		if ((Object)(object)raiz == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("TIENDA: no encuentro " + a.TiendaRaiz.Value));
			yield break;
		}
		string text = a.Prefab + " spawner";
		if (!((Object)(object)raiz.transform.Find(text) != (Object)null))
		{
			a.Puesto = new GameObject(text);
			a.Puesto.transform.parent = raiz.transform;
			a.Puesto.transform.localPosition = new Vector3(a.TiendaX.Value, a.TiendaY.Value, a.TiendaZ.Value);
			a.Puesto.transform.localRotation = Quaternion.Euler(a.TiendaInclinacion.Value, a.TiendaGiro.Value, a.TiendaVuelta.Value);
			a.Puesto.AddComponent<MeshFilter>().sharedMesh = a.Objeto.GetComponentInChildren<MeshFilter>().sharedMesh;
			a.Puesto.AddComponent<MeshRenderer>();
			a.Puesto.AddComponent<ShopItemSpawner>().itemPrefab = a.Objeto;
			((BaseUnityPlugin)this).Logger.LogDebug((object)("TIENDA: " + a.Clave + " a la venta en " + a.TiendaRaiz.Value));
		}
	}

	private void Update()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: 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)
		if (teclaLocalizar != null && (int)teclaLocalizar.Value != 0 && Input.GetKeyDown(teclaLocalizar.Value))
		{
			Localizar();
		}
		Arma[] armas = Armas;
		foreach (Arma arma in armas)
		{
			if (!((Object)(object)arma.Puesto == (Object)null))
			{
				arma.Puesto.transform.localPosition = new Vector3(arma.TiendaX.Value, arma.TiendaY.Value, arma.TiendaZ.Value);
				arma.Puesto.transform.localRotation = Quaternion.Euler(arma.TiendaInclinacion.Value, arma.TiendaGiro.Value, arma.TiendaVuelta.Value);
			}
		}
		if (fase != Fase.Nada)
		{
			ActualizarVuelo();
		}
	}

	private void Localizar()
	{
		//IL_0018: 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_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_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		Camera main = Camera.main;
		RaycastHit val = default(RaycastHit);
		if ((Object)(object)main != (Object)null && Physics.Raycast(((Component)main).transform.position, ((Component)main).transform.forward, ref val, 20f, -1, (QueryTriggerInteraction)1))
		{
			Transform root = ((RaycastHit)(ref val)).transform.root;
			Vector3 val2 = root.InverseTransformPoint(((RaycastHit)(ref val)).point);
			ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
			string[] obj = new string[13]
			{
				"LOCALIZAR: escena '", null, null, null, null, null, null, null, null, null,
				null, null, null
			};
			Scene scene = ((Component)root).gameObject.scene;
			obj[1] = ((Scene)(ref scene)).name;
			obj[2] = "', raiz '";
			obj[3] = ((Object)root).name;
			obj[4] = "', objeto '";
			obj[5] = ((Object)((RaycastHit)(ref val)).transform).name;
			obj[6] = "', punto respecto a la raiz (";
			obj[7] = val2.x.ToString("F3");
			obj[8] = ", ";
			obj[9] = val2.y.ToString("F3");
			obj[10] = ", ";
			obj[11] = val2.z.ToString("F3");
			obj[12] = ")";
			logger.LogDebug((object)string.Concat(obj));
		}
	}

	private static Vector3 Mano(Transform cam)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		return cam.position + cam.forward * 0.4f - cam.up * 0.3f + cam.right * 0.2f;
	}

	public void PulsarUsar(GarfioItem hacha)
	{
		if (fase == Fase.Nada)
		{
			Lanzar(hacha);
		}
		else
		{
			Soltar("soltado con R");
		}
	}

	private void Lanzar(GarfioItem hacha)
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_0325: Unknown result type (might be due to invalid IL or missing references)
		//IL_032a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0331: Unknown result type (might be due to invalid IL or missing references)
		//IL_0348: Unknown result type (might be due to invalid IL or missing references)
		//IL_034e: 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_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: 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_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: 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_0267: Unknown result type (might be due to invalid IL or missing references)
		Camera main = Camera.main;
		Arma datos = hacha.Datos;
		if ((Object)(object)main == (Object)null || datos == null || (Object)(object)datos.Vuelo == (Object)null)
		{
			return;
		}
		Transform transform = ((Component)main).transform;
		objetivo = null;
		cuerpo = null;
		Vector3 val = transform.position + transform.forward * 35f;
		pescar = false;
		float num = float.MaxValue;
		RaycastHit[] array = Physics.RaycastAll(transform.position, transform.forward, 35f, -1, (QueryTriggerInteraction)1);
		Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance));
		RaycastHit[] array2 = array;
		for (int num2 = 0; num2 < array2.Length; num2++)
		{
			RaycastHit val2 = array2[num2];
			if (((RaycastHit)(ref val2)).distance < 1.2f)
			{
				continue;
			}
			ShipItem val3 = Buscar(((RaycastHit)(ref val2)).collider);
			if (!((Object)(object)val3 == (Object)(object)hacha) && !((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(((Component)hacha).transform))
			{
				val = ((RaycastHit)(ref val2)).point;
				num = ((RaycastHit)(ref val2)).distance;
				string text = Valido(val3);
				((BaseUnityPlugin)this).Logger.LogDebug((object)("HACHA: toca '" + ((Object)((RaycastHit)(ref val2)).collider).name + "' a " + ((RaycastHit)(ref val2)).distance.ToString("F1") + " m" + ((text != null) ? (" (" + text + ")") : "")));
				if (text == null)
				{
					objetivo = val3;
					cuerpo = ((Component)val3.itemRigidbodyC).GetComponent<Rigidbody>();
					golpeLocal = ((Component)val3).transform.InverseTransformPoint(((RaycastHit)(ref val2)).point);
				}
				break;
			}
		}
		if (!datos.Gira && (Object)(object)objetivo == (Object)null && transform.forward.y < -0.02f)
		{
			float num3 = (0f - transform.position.y) / transform.forward.y;
			if (num3 > 1.5f && num3 <= 35f && num3 < num + 0.3f)
			{
				val = transform.position + transform.forward * num3;
				float num4 = Random.value * 100f;
				pescar = num4 < ProbPesca.Value;
				((BaseUnityPlugin)this).Logger.LogDebug((object)("ARPON: cae al mar a " + num3.ToString("F1") + " m" + (pescar ? " ... y hay pez!" : " (sin pez)")));
			}
		}
		arma = datos;
		lanzadora = hacha;
		lanzadora.Esconder(si: true);
		tLanzado = Time.time;
		copia = Object.Instantiate<GameObject>(datos.Vuelo);
		Collider[] componentsInChildren = copia.GetComponentsInChildren<Collider>();
		for (int num2 = 0; num2 < componentsInChildren.Length; num2++)
		{
			Object.Destroy((Object)(object)componentsInChildren[num2]);
		}
		desde = Mano(transform);
		hasta = val;
		tVuelo = 0f;
		durVuelo = Mathf.Max(0.2f, Vector3.Distance(desde, hasta) / datos.Vel);
		vueltas = Mathf.Max(1f, Mathf.Round(durVuelo * 2.5f));
		giro = 0f;
		fase = Fase.Volando;
	}

	private string Valido(ShipItem item)
	{
		//IL_0068: 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)
		if ((Object)(object)item == (Object)null)
		{
			return "no se puede traer";
		}
		if (!item.sold)
		{
			return "es de una tienda";
		}
		if ((Object)(object)((PickupableItem)item).held != (Object)null || (Object)(object)item.itemRigidbodyC == (Object)null)
		{
			return "no se puede mover ahora";
		}
		Rigidbody component = ((Component)item.itemRigidbodyC).GetComponent<Rigidbody>();
		if ((Object)(object)component == (Object)null || component.isKinematic)
		{
			return "esta fijo";
		}
		if (Vector3.Distance(((Component)item).transform.position, component.position) > 1f)
		{
			return "ya va dentro de un barco";
		}
		return null;
	}

	private ShipItem Buscar(Collider c)
	{
		ShipItem componentInParent = ((Component)c).GetComponentInParent<ShipItem>();
		if ((Object)(object)componentInParent != (Object)null)
		{
			return componentInParent;
		}
		ShipItem[] array = Object.FindObjectsOfType<ShipItem>();
		foreach (ShipItem val in array)
		{
			if (!((Object)(object)val.itemRigidbodyC == (Object)null))
			{
				Transform transform = ((Component)val.itemRigidbodyC).transform;
				if ((Object)(object)((Component)c).transform == (Object)(object)transform || ((Component)c).transform.IsChildOf(transform))
				{
					return val;
				}
			}
		}
		return null;
	}

	private void ActualizarVuelo()
	{
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: 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_01a7: 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_01b3: 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_01c7: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: 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_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: 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_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_031e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0434: Unknown result type (might be due to invalid IL or missing references)
		//IL_0439: Unknown result type (might be due to invalid IL or missing references)
		//IL_0450: Unknown result type (might be due to invalid IL or missing references)
		//IL_0456: Unknown result type (might be due to invalid IL or missing references)
		//IL_040e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0413: Unknown result type (might be due to invalid IL or missing references)
		//IL_0389: Unknown result type (might be due to invalid IL or missing references)
		//IL_0399: Unknown result type (might be due to invalid IL or missing references)
		Camera main = Camera.main;
		if ((Object)(object)main == (Object)null || ((Object)(object)copia == (Object)null && fase != Fase.Clavada))
		{
			Soltar("se ha perdido el hacha");
			return;
		}
		if ((Object)(object)lanzadora == (Object)null || (Object)(object)((PickupableItem)lanzadora).held == (Object)null)
		{
			GarfioItem garfioItem = lanzadora;
			ShipItem traido = ((fase == Fase.Clavada) ? objetivo : null);
			Soltar("has soltado el hacha (" + (Time.time - tLanzado).ToString("F2") + " s despues de lanzarla, fase " + fase.ToString() + ")");
			if ((Object)(object)garfioItem != (Object)null)
			{
				((MonoBehaviour)this).StartCoroutine(GuardarYCoger(garfioItem, traido));
			}
			return;
		}
		Transform transform = ((Component)main).transform;
		if (fase == Fase.Pescando)
		{
			DibujarCuerda(transform);
			return;
		}
		if (fase == Fase.Volando || fase == Fase.Volviendo)
		{
			if (fase == Fase.Volando && (Object)(object)objetivo != (Object)null)
			{
				hasta = ((Component)objetivo).transform.TransformPoint(golpeLocal);
			}
			if (fase == Fase.Volviendo)
			{
				hasta = Mano(transform);
			}
			tVuelo += Time.deltaTime;
			float num = Mathf.Clamp01(tVuelo / durVuelo);
			Vector3 val = Vector3.Lerp(desde, hasta, num);
			val += Vector3.up * Mathf.Sin(num * (float)Math.PI) * Vector3.Distance(desde, hasta) * 0.08f;
			Vector3 val2 = hasta - desde;
			if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f)
			{
				val2 = transform.forward;
			}
			Quaternion val4;
			if (arma.Gira)
			{
				Vector3 val3 = Vector3.Cross(arma.HojaDir, arma.MangoDir);
				Vector3 normalized = ((Vector3)(ref val3)).normalized;
				float num2 = ((fase == Fase.Volando) ? ((0f - (1f - num)) * vueltas * 360f) : (giro += Time.deltaTime * 720f));
				val4 = GiroClavada(arma, ((Vector3)(ref val2)).normalized) * Quaternion.AngleAxis(num2, normalized);
			}
			else
			{
				val4 = GiroClavada(arma, (fase == Fase.Volando) ? ((Vector3)(ref val2)).normalized : (-((Vector3)(ref val2)).normalized));
			}
			copia.transform.rotation = val4;
			copia.transform.position = val - val4 * arma.FiloLocal + ((Vector3)(ref val2)).normalized * ((fase == Fase.Volando) ? arma.Hundir : 0f);
			if (num >= 1f)
			{
				if (fase == Fase.Volviendo)
				{
					Soltar("ha vuelto");
					return;
				}
				if ((Object)(object)objetivo != (Object)null && (Object)(object)cuerpo != (Object)null)
				{
					copia.transform.SetParent(((Component)objetivo).transform, true);
					largo = Vector3.Distance(Mano(transform), ((Component)objetivo).transform.position);
					inicio = Time.time;
					fase = Fase.Clavada;
					((BaseUnityPlugin)this).Logger.LogDebug((object)(arma.Clave.ToUpper() + ": clavada en '" + objetivo.name + "'"));
				}
				else if (pescar && SacarPez(copia.transform.TransformPoint(arma.FiloLocal)))
				{
					fase = Fase.Pescando;
				}
				else
				{
					desde = copia.transform.position;
					tVuelo = 0f;
					durVuelo = Mathf.Max(0.3f, Vector3.Distance(desde, Mano(transform)) / arma.Vel * 1.5f);
					fase = Fase.Volviendo;
				}
			}
		}
		if (fase == Fase.Clavada && !arma.Gira && (Object)(object)copia != (Object)null && (Object)(object)objetivo != (Object)null)
		{
			ColocarArponClavado(transform);
		}
		DibujarCuerda(transform);
	}

	private void ColocarArponClavado(Transform c)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: 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_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = ((Component)objetivo).transform.TransformPoint(golpeLocal);
		Vector3 val2 = val - Mano(c);
		Vector3 val3 = arma.FiloLocal - arma.ArgollaLocal;
		float magnitude = ((Vector3)(ref val3)).magnitude;
		float num = Mathf.Clamp01((magnitude + 1f - ((Vector3)(ref val2)).magnitude) / magnitude);
		Vector3 val4 = Vector3.Slerp(((Vector3)(ref val2)).normalized, Vector3.down, num);
		Quaternion val5 = GiroClavada(arma, val4);
		copia.transform.rotation = val5;
		copia.transform.position = val - val5 * arma.FiloLocal + val4 * arma.Hundir;
	}

	private bool SacarPez(Vector3 donde)
	{
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			object value = AccessTools.Field(typeof(OceanFishes), "instance").GetValue(null);
			if (value == null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"ARPON: no encuentro los peces del mar");
				return false;
			}
			object? obj = AccessTools.Method(typeof(OceanFishes), "GetFish", (Type[])null, (Type[])null).Invoke(value, new object[1] { copia.transform });
			GameObject val = (GameObject)((obj is GameObject) ? obj : null);
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogDebug((object)"ARPON: aqui no hay peces");
				return false;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, donde, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f));
			ShipItem component = val2.GetComponent<ShipItem>();
			if ((Object)(object)component == (Object)null)
			{
				Object.Destroy((Object)(object)val2);
				((BaseUnityPlugin)this).Logger.LogWarning((object)("ARPON: el pez '" + ((Object)val).name + "' no es un objeto"));
				return false;
			}
			Traverse.Create((object)component).Field("sold").SetValue((object)true);
			SaveablePrefab component2 = val2.GetComponent<SaveablePrefab>();
			MethodInfo methodInfo = (((Object)(object)component2 != (Object)null) ? AccessTools.Method(typeof(SaveablePrefab), "RegisterToSave", (Type[])null, (Type[])null) : null);
			if (methodInfo != null && methodInfo.GetParameters().Length == 0)
			{
				methodInfo.Invoke(component2, null);
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"ARPON: no he podido apuntar el pez para guardarlo en la partida");
			}
			((BaseUnityPlugin)this).Logger.LogDebug((object)("ARPON: pez pescado: '" + ((Object)val).name + "'"));
			((MonoBehaviour)this).StartCoroutine(EngancharPez(component));
			return true;
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("ARPON: no he podido pescar: " + (ex.InnerException ?? ex).Message));
			return false;
		}
	}

	private IEnumerator EngancharPez(ShipItem pez)
	{
		yield return (object)new WaitForFixedUpdate();
		for (int i = 0; i < 150; i++)
		{
			if (!((Object)(object)pez != (Object)null))
			{
				break;
			}
			if (!((Object)(object)pez.itemRigidbodyC == (Object)null))
			{
				break;
			}
			yield return (object)new WaitForFixedUpdate();
		}
		if (fase == Fase.Pescando && !((Object)(object)copia == (Object)null))
		{
			Camera main = Camera.main;
			if ((Object)(object)pez == (Object)null || (Object)(object)pez.itemRigidbodyC == (Object)null || (Object)(object)main == (Object)null)
			{
				Soltar("el pez se ha escapado");
				yield break;
			}
			objetivo = pez;
			cuerpo = ((Component)pez.itemRigidbodyC).GetComponent<Rigidbody>();
			golpeLocal = ((Component)pez).transform.InverseTransformPoint(copia.transform.TransformPoint(arma.FiloLocal));
			copia.transform.SetParent(((Component)pez).transform, true);
			largo = Vector3.Distance(Mano(((Component)main).transform), ((Component)pez).transform.position);
			inicio = Time.time;
			fase = Fase.Clavada;
			((BaseUnityPlugin)this).Logger.LogDebug((object)"ARPON: pez clavado, tira de la cuerda");
		}
	}

	private void FixedUpdate()
	{
		//IL_006b: 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_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: 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_01c3: Unknown result type (might be due to invalid IL or missing references)
		if (fase != Fase.Clavada)
		{
			return;
		}
		Camera main = Camera.main;
		if ((Object)(object)main == (Object)null || (Object)(object)cuerpo == (Object)null || (Object)(object)objetivo == (Object)null)
		{
			Soltar("se ha perdido el objeto");
			return;
		}
		if ((Object)(object)((PickupableItem)objetivo).held != (Object)null)
		{
			Soltar("lo has cogido");
			return;
		}
		Matrix4x4 val = ((Component)cuerpo).transform.localToWorldMatrix * ((Component)objetivo).transform.worldToLocalMatrix;
		Vector3 val2 = ((Matrix4x4)(ref val)).MultiplyPoint3x4(Mano(((Component)main).transform)) - cuerpo.position;
		float magnitude = ((Vector3)(ref val2)).magnitude;
		largo = Mathf.Min(largo, magnitude + 0.5f);
		largo = Mathf.Max(0.9f, largo - 2f * Time.fixedDeltaTime);
		if (magnitude <= 1.5f)
		{
			inicio = Time.time;
		}
		else if (Time.time - inicio > 40f)
		{
			Soltar("ha tardado demasiado");
			return;
		}
		float num = magnitude - largo;
		if (!(num <= 0f))
		{
			Vector3 val3 = val2 / magnitude;
			float num2 = Mathf.Min(num * 15f, 35f) - Vector3.Dot(cuerpo.velocity, val3) * 2f;
			if (num2 > 0f)
			{
				cuerpo.AddForce(val3 * num2, (ForceMode)5);
			}
			if (num > 0.8f)
			{
				Rigidbody obj = cuerpo;
				Vector3 val4 = ((Matrix4x4)(ref val)).MultiplyVector(Vector3.up);
				obj.AddForce(((Vector3)(ref val4)).normalized * Mathf.Min((num - 0.8f) * 12f, 14f), (ForceMode)5);
			}
			cuerpo.WakeUp();
		}
	}

	private void DibujarCuerda(Transform c)
	{
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Expected O, but got Unknown
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: 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_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)cuerda == (Object)null)
		{
			GameObject val = new GameObject("HachaCuerda");
			Object.DontDestroyOnLoad((Object)(object)val);
			cuerda = val.AddComponent<LineRenderer>();
			cuerda.positionCount = 2;
			cuerda.startWidth = 0.015f;
			cuerda.endWidth = 0.015f;
			((Renderer)cuerda).material = new Material(Shader.Find("Sprites/Default"));
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.72f, 0.63f, 0.48f);
			cuerda.startColor = val2;
			cuerda.endColor = val2;
		}
		((Renderer)cuerda).enabled = true;
		cuerda.SetPosition(0, Mano(c));
		Vector3 val3 = (((Object)(object)copia != (Object)null) ? copia.transform.TransformPoint(arma.ArgollaLocal) : (((Object)(object)objetivo != (Object)null) ? ((Component)objetivo).transform.TransformPoint(golpeLocal) : Mano(c)));
		cuerda.SetPosition(1, val3);
	}

	private IEnumerator GuardarYCoger(GarfioItem h, ShipItem traido)
	{
		yield return (object)new WaitForFixedUpdate();
		if (!((Object)(object)h == (Object)null) && !((Object)(object)((PickupableItem)h).held != (Object)null))
		{
			if (!AlInventario(h))
			{
				PonerAPies(h);
			}
			yield return (object)new WaitForFixedUpdate();
			Camera main = Camera.main;
			if ((Object)(object)traido != (Object)null && (Object)(object)((PickupableItem)traido).held == (Object)null && (Object)(object)main != (Object)null && Vector3.Distance(((Component)main).transform.position, ((Component)traido).transform.position) < 3.5f)
			{
				AlasManos(traido);
			}
		}
	}

	private bool AlInventario(GarfioItem h)
	{
		SaveablePrefab component = ((Component)h).GetComponent<SaveablePrefab>();
		if ((Object)(object)component == (Object)null)
		{
			return false;
		}
		MethodInfo method = typeof(SaveablePrefab).GetMethod("PutInInventory", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (method == null)
		{
			return false;
		}
		Component[] array = (Component[])(object)Object.FindObjectsOfType<GPButtonInventorySlot>();
		array = array;
		foreach (Component val in array)
		{
			Type type = ((object)val).GetType();
			int num = -1;
			bool flag = false;
			bool flag2 = false;
			FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (fieldInfo.FieldType == typeof(int) && (fieldInfo.Name == "slotIndex" || fieldInfo.Name == "slotNumber" || fieldInfo.Name == "slot" || fieldInfo.Name == "index"))
				{
					num = (int)fieldInfo.GetValue(val);
				}
				if ((typeof(PickupableItem).IsAssignableFrom(fieldInfo.FieldType) || typeof(ShipItem).IsAssignableFrom(fieldInfo.FieldType) || fieldInfo.FieldType == typeof(GameObject)) && (fieldInfo.Name.ToLower().Contains("item") || fieldInfo.Name.ToLower().Contains("current")))
				{
					flag2 = true;
					object value = fieldInfo.GetValue(val);
					if (value != null && !value.Equals(null))
					{
						flag = true;
					}
				}
			}
			if (num < 0 || !flag2 || flag)
			{
				continue;
			}
			try
			{
				object obj = method.Invoke(component, new object[1] { num });
				if (obj is IEnumerator)
				{
					((MonoBehaviour)this).StartCoroutine((IEnumerator)obj);
				}
				((BaseUnityPlugin)this).Logger.LogDebug((object)("HACHA: guardada en el hueco " + num + " del inventario"));
				return true;
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("HACHA: no he podido guardarla: " + (ex.InnerException ?? ex).Message));
				return false;
			}
		}
		((BaseUnityPlugin)this).Logger.LogDebug((object)"HACHA: no hay hueco libre en el inventario (o no se como mirarlo)");
		return false;
	}

	private void PonerAPies(GarfioItem h)
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_006a: 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_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_008f: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		Camera main = Camera.main;
		if (!((Object)(object)h == (Object)null) && !((Object)(object)((PickupableItem)h).held != (Object)null) && !((Object)(object)((ShipItem)h).itemRigidbodyC == (Object)null) && !((Object)(object)main == (Object)null))
		{
			Rigidbody component = ((Component)((ShipItem)h).itemRigidbodyC).GetComponent<Rigidbody>();
			if (!((Object)(object)component == (Object)null))
			{
				Vector3 val = ((Component)main).transform.position - Vector3.up * 1.3f;
				Matrix4x4 val2 = ((Component)component).transform.localToWorldMatrix * ((Component)h).transform.worldToLocalMatrix;
				Vector3 position = ((Matrix4x4)(ref val2)).MultiplyPoint3x4(val);
				component.velocity = Vector3.zero;
				component.angularVelocity = Vector3.zero;
				component.position = position;
				((Component)component).transform.position = position;
				((BaseUnityPlugin)this).Logger.LogDebug((object)"HACHA: puesta a tus pies");
			}
		}
	}

	private void AlasManos(ShipItem item)
	{
		GoPointer val = Object.FindObjectOfType<GoPointer>();
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		MethodInfo[] methods = typeof(GoPointer).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		foreach (MethodInfo methodInfo in methods)
		{
			if (methodInfo.Name != "PickUpItem")
			{
				continue;
			}
			ParameterInfo[] parameters = methodInfo.GetParameters();
			if (parameters.Length == 1 && parameters[0].ParameterType.IsAssignableFrom(((object)item).GetType()))
			{
				try
				{
					methodInfo.Invoke(val, new object[1] { item });
					((BaseUnityPlugin)this).Logger.LogDebug((object)("HACHA: te doy '" + item.name + "'"));
					break;
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("HACHA: no he podido darte el objeto: " + (ex.InnerException ?? ex).Message));
				}
			}
		}
	}

	public void Soltar(string motivo)
	{
		if (fase != Fase.Nada)
		{
			((BaseUnityPlugin)this).Logger.LogDebug((object)("HACHA: " + motivo));
			fase = Fase.Nada;
			objetivo = null;
			cuerpo = null;
			if ((Object)(object)copia != (Object)null)
			{
				Object.Destroy((Object)(object)copia);
			}
			copia = null;
			if ((Object)(object)lanzadora != (Object)null)
			{
				lanzadora.Esconder(si: false);
			}
			lanzadora = null;
			arma = null;
			if ((Object)(object)cuerda != (Object)null)
			{
				((Renderer)cuerda).enabled = false;
			}
		}
	}
}
[DefaultExecutionOrder(1000)]
public abstract class GarfioItem : ShipItem
{
	private bool pulsadoEsteFotograma;

	private bool pulsadoAntes;

	private bool botonLiberado = true;

	private Renderer[] dibujos;

	private Component colgable;

	private Material[][] originales;

	private static Material invisible;

	public abstract Arma Datos { get; }

	public override void OnBuy()
	{
		botonLiberado = false;
	}

	public override void OnAltHeld()
	{
		pulsadoEsteFotograma = true;
	}

	public override void ExtraLateUpdate()
	{
		//IL_017c: 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_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		Arma datos = Datos;
		bool flag = pulsadoEsteFotograma;
		pulsadoEsteFotograma = false;
		bool flag2 = flag && !pulsadoAntes;
		pulsadoAntes = flag;
		if (!flag)
		{
			botonLiberado = true;
		}
		if (datos == null)
		{
			return;
		}
		if (Plugin.TipoAttachable != null && Plugin.PropPosColgado != null && Plugin.PropGiroColgado != null)
		{
			if ((Object)(object)colgable == (Object)null)
			{
				colgable = ((Component)this).GetComponent(Plugin.TipoAttachable);
			}
			if ((Object)(object)colgable != (Object)null)
			{
				Plugin.PropPosColgado.SetValue(colgable, (object)new Vector3(datos.ColgX.Value, datos.ColgY.Value, datos.ColgZ.Value), null);
				Plugin.PropGiroColgado.SetValue(colgable, (object)new Vector3(datos.ColgRotX.Value, datos.ColgRotY.Value, datos.ColgRotZ.Value), null);
			}
		}
		((PickupableItem)this).holdDistance = datos.ManoDistancia.Value;
		((PickupableItem)this).holdHeight = datos.ManoAltura.Value;
		if (!((Object)(object)((PickupableItem)this).held == (Object)null))
		{
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(datos.GiroX.Value, datos.GiroY.Value, datos.GiroZ.Value);
			if (((Vector3)(ref val)).sqrMagnitude > 0.0001f)
			{
				((Component)this).transform.Rotate(val, (Space)1);
			}
			Camera main = Camera.main;
			if ((Object)(object)main != (Object)null && Mathf.Abs(datos.ManoLado.Value) > 0.001f)
			{
				Transform transform = ((Component)this).transform;
				transform.position += ((Component)main).transform.right * datos.ManoLado.Value;
			}
			if (flag2 && base.sold && botonLiberado && (Object)(object)Plugin.Instancia != (Object)null)
			{
				Plugin.Instancia.PulsarUsar(this);
			}
		}
	}

	public void Esconder(bool si)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		if (dibujos == null)
		{
			dibujos = ((Component)this).GetComponentsInChildren<Renderer>();
		}
		if ((Object)(object)invisible == (Object)null)
		{
			invisible = new Material(Shader.Find("Sprites/Default"));
			invisible.color = new Color(0f, 0f, 0f, 0f);
		}
		if (si)
		{
			if (originales != null)
			{
				return;
			}
			originales = new Material[dibujos.Length][];
			for (int i = 0; i < dibujos.Length; i++)
			{
				if (!((Object)(object)dibujos[i] == (Object)null))
				{
					originales[i] = dibujos[i].sharedMaterials;
					Material[] array = (Material[])(object)new Material[originales[i].Length];
					for (int j = 0; j < array.Length; j++)
					{
						array[j] = invisible;
					}
					dibujos[i].sharedMaterials = array;
				}
			}
		}
		else
		{
			if (originales == null)
			{
				return;
			}
			for (int k = 0; k < dibujos.Length; k++)
			{
				if ((Object)(object)dibujos[k] != (Object)null && originales[k] != null)
				{
					dibujos[k].sharedMaterials = originales[k];
				}
			}
			originales = null;
		}
	}
}
public class HachaItem : GarfioItem
{
	public override Arma Datos => Plugin.Hacha;
}
public class ArponItem : GarfioItem
{
	public override Arma Datos => Plugin.Arpon;
}
public class MikhtafItem : GarfioItem
{
	public override Arma Datos => Plugin.Mikhtaf;
}
public class KaginawaItem : GarfioItem
{
	public override Arma Datos => Plugin.Kaginawa;
}