Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of CofreFijo v1.1.5
BepInEx/plugins/CofreFijo/CofreFijo.dll
Decompiled a month agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("CofreFijo")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.5.0")] [assembly: AssemblyInformationalVersion("1.1.5")] [assembly: AssemblyProduct("CofreFijo")] [assembly: AssemblyTitle("CofreFijo")] [assembly: AssemblyVersion("1.1.5.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 CofreFijo { internal static class BuscadorCofres { private class Entrada { internal ItemData Muestra; internal string Nombre; internal string Interno; internal int Calidad; internal int Total; internal readonly HashSet<Container> Cofres = new HashSet<Container>(); internal readonly List<Fuente> Fuentes = new List<Fuente>(); } private class Fuente { internal CofreFijoPlugin.CofreCercano Cercano; internal ItemData Item; } [CompilerGenerated] private static class <>O { public static WindowFunction <0>__Contenido; } private const string NombreBuscador = "CofreFijo.Buscador"; private const float IntervaloRefresco = 1f; private const int MaximoFilas = 200; private const float AnchoVentana = 470f; private const float AltoMaximo = 560f; private const float TamIcono = 32f; private const float AnchoBotonMinimizar = 26f; private const float MargenIcono = 3f; private const float AltoMinimoVisible = 60f; private const float AnchoBotonUno = 34f; private const float AnchoBotonPila = 44f; private const float AnchoBotonTodo = 48f; private const float AnchoBarraVertical = 12f; private static readonly int IdVentana = "CofreFijo.Buscador".GetHashCode(); private static readonly MethodInfo MetodoAcceso = AccessTools.Method(typeof(Container), "CheckAccess", (Type[])null, (Type[])null); private static readonly List<Entrada> Entradas = new List<Entrada>(); private static Rect _rect; private static bool _rectIniciado; private static float _altoExpandido; private static bool _minimizada; private static bool _alternarMinimizada; private static string _filtroDelLayout = ""; private const int EstadoSinDecidir = -1; private const int EstadoCompacta = 0; private const int EstadoExpandida = 1; private static int _estadoAlto = -1; private static Vector2 _scroll; private static string _busqueda = ""; private static float _proximoRefresco; private static bool _visible; private static bool _soltarFoco; private static int _cofresVistos; private static Entrada _pendiente; private static int _cantidadPendiente; internal static bool BuscadorConFoco { get; private set; } internal static void Actualizar() { //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) if (!DebeVerse()) { if (_visible) { Ocultar(); } return; } if (!_visible) { _visible = true; _soltarFoco = true; _proximoRefresco = 0f; _busqueda = ""; _scroll = Vector2.zero; } EstiloValheim.Preparar(); if (_pendiente != null) { Entrada pendiente = _pendiente; int cantidadPendiente = _cantidadPendiente; _pendiente = null; Tomar(pendiente, cantidadPendiente); } if (Time.unscaledTime >= _proximoRefresco) { Reconstruir(); } } private static bool DebeVerse() { CofreFijoPlugin instancia = CofreFijoPlugin.Instancia; if ((Object)(object)instancia != (Object)null && instancia.BuscadorActivo && (Object)(object)Player.m_localPlayer != (Object)null && InventoryGui.IsVisible()) { return !Menu.IsVisible(); } return false; } private static void Ocultar() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) _visible = false; _pendiente = null; BuscadorConFoco = false; _soltarFoco = true; Entradas.Clear(); CofreFijoPlugin instancia = CofreFijoPlugin.Instancia; if ((Object)(object)instancia != (Object)null && _rectIniciado) { instancia.BuscadorPosicion = ((Rect)(ref _rect)).position; instancia.BuscadorMinimizado = _minimizada; } } private static void Reconstruir() { _proximoRefresco = Time.unscaledTime + 1f; Entradas.Clear(); _cofresVistos = 0; CofreFijoPlugin instancia = CofreFijoPlugin.Instancia; Player localPlayer = Player.m_localPlayer; if ((Object)(object)instancia == (Object)null || (Object)(object)localPlayer == (Object)null) { return; } long idJugador = IdJugador(); Dictionary<string, Entrada> dictionary = new Dictionary<string, Entrada>(); foreach (CofreFijoPlugin.CofreCercano item in instancia.CofresCercanos(localPlayer, instancia.BuscadorSoloVinculados)) { if (!Permitido(item.Cofre, idJugador)) { continue; } _cofresVistos++; foreach (ItemData allItem in item.Inventario.GetAllItems()) { if (allItem != null && allItem.m_shared != null && allItem.m_stack > 0) { string key = allItem.m_shared.m_name + "#" + allItem.m_quality; if (!dictionary.TryGetValue(key, out var value)) { value = (dictionary[key] = new Entrada { Muestra = allItem, Calidad = allItem.m_quality, Nombre = VentanaCategorias.Localizar(allItem.m_shared.m_name), Interno = (Categorias.NombreInterno(allItem) ?? "").ToLowerInvariant() }); Entradas.Add(value); } value.Total += allItem.m_stack; value.Cofres.Add(item.Cofre); value.Fuentes.Add(new Fuente { Cercano = item, Item = allItem }); } } } Entradas.Sort(delegate(Entrada a, Entrada b) { int num = string.Compare(a.Nombre, b.Nombre, StringComparison.CurrentCultureIgnoreCase); return (num == 0) ? a.Calidad.CompareTo(b.Calidad) : num; }); } private static bool Permitido(Container cofre, long idJugador) { if ((Object)(object)cofre == (Object)null || (Object)(object)((Component)cofre).GetComponent<TombStone>() != (Object)null) { return false; } if (MetodoAcceso == null) { return true; } return (bool)MetodoAcceso.Invoke(cofre, new object[1] { idJugador }); } private static long IdJugador() { Game instance = Game.instance; PlayerProfile val = (((Object)(object)instance != (Object)null) ? instance.GetPlayerProfile() : null); if (val == null) { return 0L; } return val.GetPlayerID(); } private static void Tomar(Entrada entrada, int pedida) { Player localPlayer = Player.m_localPlayer; Inventory val = (((Object)(object)localPlayer != (Object)null) ? ((Humanoid)localPlayer).GetInventory() : null); if (val == null || entrada == null || pedida <= 0) { return; } int num = 0; bool faltoEspacio = false; HashSet<Container> hashSet = new HashSet<Container>(); foreach (Fuente fuente in entrada.Fuentes) { int num2 = pedida - num; if (num2 <= 0) { break; } if (!SigueDisponible(fuente)) { continue; } int num3 = Math.Min(num2, fuente.Item.m_stack); int num4 = CuantoCabe(val, fuente.Item, num3); if (num4 <= 0) { faltoEspacio = true; break; } fuente.Cercano.Vista.ClaimOwnership(); if (Mover(fuente.Cercano.Inventario, val, fuente.Item, num4)) { hashSet.Add(fuente.Cercano.Cofre); num += num4; if (num4 < num3) { faltoEspacio = true; break; } } } foreach (Container item in hashSet) { CofreFijoPlugin.Guardar(item); } Reconstruir(); Mensaje(Resultado(entrada, pedida, num, faltoEspacio)); } private static bool SigueDisponible(Fuente fuente) { CofreFijoPlugin.CofreCercano cercano = fuente.Cercano; if ((Object)(object)cercano.Cofre != (Object)null && (Object)(object)cercano.Vista != (Object)null && cercano.Vista.IsValid() && !cercano.Cofre.IsInUse() && fuente.Item.m_stack > 0) { return cercano.Inventario.GetAllItems().Contains(fuente.Item); } return false; } private static int CuantoCabe(Inventory inventario, ItemData item, int maximo) { ItemData val = item.Clone(); int num = 0; int num2 = maximo; while (num < num2) { int num3 = (val.m_stack = (num + num2 + 1) / 2); if (inventario.CanAddItem(val, num3)) { num = num3; } else { num2 = num3 - 1; } } return num; } private static bool Mover(Inventory cofre, Inventory jugador, ItemData fuente, int cantidad) { ItemData val = fuente.Clone(); val.m_stack = cantidad; if (!cofre.RemoveItem(fuente, cantidad)) { return false; } if (jugador.AddItem(val)) { return true; } if (!cofre.AddItem(val)) { Debug.LogError((object)("[CofreFijo] No se pudo devolver al cofre " + val.m_stack + " x " + val.m_shared.m_name)); } return false; } private static string Resultado(Entrada entrada, int pedida, int tomadas, bool faltoEspacio) { if (tomadas == 0) { if (!faltoEspacio) { return "Ya no está: alguien lo sacó o abrió ese cofre"; } return "No te cabe en el inventario"; } string text = tomadas + " " + entrada.Nombre; if (faltoEspacio && tomadas < pedida) { return "Solo cabían " + text + " en tu inventario"; } return "Tomaste " + text; } internal static void Dibujar() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Invalid comparison between Unknown and I4 //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Invalid comparison between Unknown and I4 //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Expected O, but got Unknown if (_soltarFoco) { GUIUtility.keyboardControl = 0; _soltarFoco = false; } if (!_visible) { BuscadorConFoco = false; return; } if (!_rectIniciado) { _altoExpandido = Mathf.Min(560f, (float)Screen.height - 160f); _rect = new Rect(PosicionInicial(), new Vector2(470f, _altoExpandido)); _minimizada = (Object)(object)CofreFijoPlugin.Instancia != (Object)null && CofreFijoPlugin.Instancia.BuscadorMinimizado; _rectIniciado = true; } Event current = Event.current; if (BuscadorConFoco && (int)current.type == 0 && !((Rect)(ref _rect)).Contains(current.mousePosition)) { GUIUtility.keyboardControl = 0; BuscadorConFoco = false; } if (_alternarMinimizada && (int)current.type == 8) { _alternarMinimizada = false; _minimizada = !_minimizada; GUIUtility.keyboardControl = 0; } if ((int)current.type == 8) { _filtroDelLayout = (_busqueda ?? "").Trim().ToLowerInvariant(); int num = ((!_minimizada && _filtroDelLayout.Length != 0) ? 1 : 0); if (num != _estadoAlto) { _estadoAlto = num; ((Rect)(ref _rect)).height = ((num == 0) ? 0f : _altoExpandido); } } GUISkin skin = GUI.skin; if (EstiloValheim.Asegurar()) { GUI.skin = EstiloValheim.Skin; } try { int idVentana = IdVentana; Rect rect = _rect; object obj = <>O.<0>__Contenido; if (obj == null) { WindowFunction val = Contenido; <>O.<0>__Contenido = val; obj = (object)val; } _rect = GUILayout.Window(idVentana, rect, (WindowFunction)obj, "", Array.Empty<GUILayoutOption>()); } finally { GUI.skin = skin; } } private static Vector2 PosicionInicial() { //IL_0021: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_006b: 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_00b7: Unknown result type (might be due to invalid IL or missing references) CofreFijoPlugin instancia = CofreFijoPlugin.Instancia; Vector2 val = (Vector2)(((Object)(object)instancia != (Object)null) ? instancia.BuscadorPosicion : new Vector2(-1f, -1f)); if (val.x < 0f || val.y < 0f) { return new Vector2(((float)Screen.width - 470f) / 2f, ((float)Screen.height - _altoExpandido) / 2f); } return new Vector2(Mathf.Clamp(val.x, 0f, Mathf.Max(0f, (float)Screen.width - 470f)), Mathf.Clamp(val.y, 0f, Mathf.Max(0f, (float)Screen.height - 60f))); } private static GUIStyle Estilo(GUIStyle delCofre, GUIStyle deUnity) { if (!EstiloValheim.Listo || delCofre == null) { return deUnity; } return delCofre; } private static void Cabecera() { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Space(26f); GUILayout.Label("Cofres cercanos", Estilo(EstiloValheim.Titulo, GUI.skin.label), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button(_minimizada ? "+" : "–", Estilo(EstiloValheim.BotonMinimizar, GUI.skin.button), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(26f), GUILayout.Height(26f) })) { _alternarMinimizada = true; } GUILayout.EndHorizontal(); } private static void Contenido(int id) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; if (GUI.GetNameOfFocusedControl() == "CofreFijo.Buscador" && (int)current.type == 4 && ((int)current.keyCode == 27 || (int)current.keyCode == 13 || (int)current.keyCode == 271)) { GUIUtility.keyboardControl = 0; current.Use(); } Cabecera(); if (_minimizada) { BuscadorConFoco = false; GUI.DragWindow(); return; } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Buscar:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(56f) }); GUI.SetNextControlName("CofreFijo.Buscador"); _busqueda = GUILayout.TextField(_busqueda ?? "", Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Borrar", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) })) { _busqueda = ""; GUIUtility.keyboardControl = 0; } GUILayout.EndHorizontal(); GUILayout.Label(Resumen(), Estilo(EstiloValheim.TextoPequeno, GUI.skin.label), Array.Empty<GUILayoutOption>()); GUILayout.Space(2f); string filtroDelLayout = _filtroDelLayout; if (filtroDelLayout.Length == 0) { if (Entradas.Count > 0) { GUILayout.Label("Escribe arriba para buscar en los cofres.", Array.Empty<GUILayoutOption>()); } BuscadorConFoco = GUI.GetNameOfFocusedControl() == "CofreFijo.Buscador"; GUI.DragWindow(); return; } _scroll = GUILayout.BeginScrollView(_scroll, false, false, GUIStyle.none, GUI.skin.verticalScrollbar, GUI.skin.scrollView, Array.Empty<GUILayoutOption>()); float anchoFila = ((Rect)(ref _rect)).width - (float)GUI.skin.window.padding.horizontal - 12f - (float)GUI.skin.scrollView.padding.horizontal; int num = 0; foreach (Entrada entrada in Entradas) { if (entrada.Nombre.ToLowerInvariant().IndexOf(filtroDelLayout, StringComparison.Ordinal) >= 0 || entrada.Interno.IndexOf(filtroDelLayout, StringComparison.Ordinal) >= 0) { if (num >= 200) { GUILayout.Label("... hay más. Escribe en el buscador para acotar.", Array.Empty<GUILayoutOption>()); break; } num++; DibujarFila(entrada, anchoFila); } } if (num == 0 && Entradas.Count > 0) { GUILayout.Label("Nada coincide con \"" + _busqueda + "\"", Array.Empty<GUILayoutOption>()); } GUILayout.EndScrollView(); BuscadorConFoco = GUI.GetNameOfFocusedControl() == "CofreFijo.Buscador"; GUI.DragWindow(); } private static string Resumen() { CofreFijoPlugin instancia = CofreFijoPlugin.Instancia; string text = (((Object)(object)instancia != (Object)null) ? instancia.Rango : 0f).ToString("0") + " m"; if (_cofresVistos == 0) { return "No hay cofres a menos de " + text + " a los que tengas acceso"; } if (Entradas.Count == 0) { if (_cofresVistos != 1) { return "Los " + _cofresVistos + " cofres a menos de " + text + " están vacíos"; } return "El cofre a menos de " + text + " está vacío"; } return Entradas.Count + ((Entradas.Count == 1) ? " objeto distinto en " : " objetos distintos en ") + _cofresVistos + ((_cofresVistos == 1) ? " cofre" : " cofres") + " a menos de " + text; } private static float AnchoTexto(float anchoFila, GUIStyle fila) { int horizontal = GUI.skin.button.margin.horizontal; float num = 126f + (float)(3 * horizontal); return Mathf.Max(60f, anchoFila - (float)fila.padding.horizontal - 32f - num - (float)GUI.skin.label.margin.horizontal); } private static void DibujarFila(Entrada entrada, float anchoFila) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = Estilo(EstiloValheim.Fila, GUIStyle.none); GUILayoutOption val2 = GUILayout.Width(AnchoTexto(anchoFila, val)); GUILayout.BeginHorizontal(val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(anchoFila) }); DibujarIcono(GUILayoutUtility.GetRect(32f, 32f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(32f), GUILayout.Height(32f) }), entrada.Muestra); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { val2 }); GUILayout.Label((entrada.Calidad > 1) ? (entrada.Nombre + " (calidad " + entrada.Calidad + ")") : entrada.Nombre, (GUILayoutOption[])(object)new GUILayoutOption[1] { val2 }); GUILayout.Label(entrada.Total + " en " + entrada.Cofres.Count + ((entrada.Cofres.Count == 1) ? " cofre" : " cofres"), Estilo(EstiloValheim.TextoPequeno, GUI.skin.label), (GUILayoutOption[])(object)new GUILayoutOption[1] { val2 }); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); if (GUILayout.Button("1", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(34f), GUILayout.Height(32f) })) { Pedir(entrada, 1); } int maxStackSize = entrada.Muestra.m_shared.m_maxStackSize; if (maxStackSize > 1) { if (GUILayout.Button("Pila", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(44f), GUILayout.Height(32f) })) { Pedir(entrada, maxStackSize); } } else { GUILayout.Space(44f + (float)GUI.skin.button.margin.horizontal); } if (GUILayout.Button("Todo", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(48f), GUILayout.Height(32f) })) { Pedir(entrada, entrada.Total); } GUILayout.EndHorizontal(); } private static void Pedir(Entrada entrada, int cantidad) { _pendiente = entrada; _cantidadPendiente = cantidad; } private static void DibujarIcono(Rect zona, ItemData item) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_003d: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if ((int)Event.current.type == 7 && item.m_shared.m_icons != null && item.m_shared.m_icons.Length != 0) { if (EstiloValheim.Listo && (Object)(object)EstiloValheim.FondoCasilla != (Object)null) { GUI.DrawTexture(zona, (Texture)(object)EstiloValheim.FondoCasilla); ((Rect)(ref zona))..ctor(((Rect)(ref zona)).x + 3f, ((Rect)(ref zona)).y + 3f, ((Rect)(ref zona)).width - 6f, ((Rect)(ref zona)).height - 6f); } Sprite icon = item.GetIcon(); Texture2D val = (((Object)(object)icon != (Object)null) ? icon.texture : null); if (!((Object)(object)val == (Object)null)) { Rect textureRect = icon.textureRect; GUI.DrawTextureWithTexCoords(zona, (Texture)(object)val, new Rect(((Rect)(ref textureRect)).x / (float)((Texture)val).width, ((Rect)(ref textureRect)).y / (float)((Texture)val).height, ((Rect)(ref textureRect)).width / (float)((Texture)val).width, ((Rect)(ref textureRect)).height / (float)((Texture)val).height)); } } } private static void Mensaje(string texto) { MessageHud instance = MessageHud.instance; if ((Object)(object)instance != (Object)null && !string.IsNullOrEmpty(texto)) { instance.ShowMessage((MessageType)2, texto, 0, (Sprite)null, false, false); } } } [HarmonyPatch(typeof(Chat), "HasFocus")] internal static class ParcheBuscadorEscribiendo { private static void Postfix(ref bool __result) { if (BuscadorCofres.BuscadorConFoco) { __result = true; } } } internal struct Categoria : IEquatable<Categoria> { private readonly string _clave; internal static readonly Categoria Ninguna = new Categoria(null); internal static readonly Categoria Comida = new Categoria("Comida"); internal static readonly Categoria Municion = new Categoria("Municion"); internal static readonly Categoria Armas = new Categoria("Armas"); internal static readonly Categoria Armaduras = new Categoria("Armaduras"); internal static readonly Categoria Herramientas = new Categoria("Herramientas"); internal static readonly Categoria Trofeos = new Categoria("Trofeos"); internal static readonly Categoria Pieles = new Categoria("Pieles"); internal static readonly Categoria Minerales = new Categoria("Minerales"); internal static readonly Categoria Madera = new Categoria("Madera"); internal static readonly Categoria Semillas = new Categoria("Semillas"); internal static readonly Categoria Monstruos = new Categoria("Monstruos"); internal static readonly Categoria Materiales = new Categoria("Materiales"); internal static readonly Categoria Varios = new Categoria("Varios"); internal bool EsNinguna => string.IsNullOrEmpty(_clave); internal string Clave => _clave ?? string.Empty; internal string Nombre { get { if (EsNinguna) { return "Sin clasificar"; } if (!(_clave == "Municion")) { return _clave; } return "Munición"; } } private Categoria(string clave) { _clave = clave; } internal static Categoria Desde(string nombre) { if (string.IsNullOrEmpty(nombre)) { return Ninguna; } string text = nombre.Trim(); if (text.Length != 0) { return new Categoria(text); } return Ninguna; } public bool Equals(Categoria otra) { return string.Equals(Clave, otra.Clave, StringComparison.OrdinalIgnoreCase); } public override bool Equals(object obj) { if (obj is Categoria) { return Equals((Categoria)obj); } return false; } public override int GetHashCode() { return Clave.ToLowerInvariant().GetHashCode(); } public override string ToString() { return Clave; } public static bool operator ==(Categoria a, Categoria b) { return a.Equals(b); } public static bool operator !=(Categoria a, Categoria b) { return !a.Equals(b); } } internal static class Categorias { internal sealed class Propia { internal Categoria Categoria; internal string[] Palabras = new string[0]; } internal static readonly Categoria[] Integradas = new Categoria[13] { Categoria.Comida, Categoria.Municion, Categoria.Armas, Categoria.Armaduras, Categoria.Herramientas, Categoria.Trofeos, Categoria.Pieles, Categoria.Minerales, Categoria.Madera, Categoria.Semillas, Categoria.Monstruos, Categoria.Materiales, Categoria.Varios }; internal static string[] Pieles = new string[0]; internal static string[] Minerales = new string[0]; internal static string[] Madera = new string[0]; internal static string[] Semillas = new string[0]; internal static string[] Monstruos = new string[0]; internal static Propia[] Propias = new Propia[0]; internal static Categoria[] Todas { get { List<Categoria> list = new List<Categoria>(Integradas); Propia[] propias = Propias; foreach (Propia propia in propias) { if (!list.Contains(propia.Categoria)) { list.Add(propia.Categoria); } } return list.ToArray(); } } internal static string Nombre(Categoria categoria) { return categoria.Nombre; } internal static void CargarPropias(string valor) { List<Propia> list = new List<Propia>(); if (!string.IsNullOrEmpty(valor)) { string[] array = valor.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { '=' }, 2); Categoria categoria = Categoria.Desde(array2[0]); if (!categoria.EsNinguna && !YaEsta(list, categoria)) { list.Add(new Propia { Categoria = categoria, Palabras = ((array2.Length > 1) ? ParseLista(array2[1]) : new string[0]) }); } } } Propias = list.ToArray(); } private static bool YaEsta(List<Propia> lista, Categoria categoria) { foreach (Propia listum in lista) { if (listum.Categoria == categoria) { return true; } } return false; } internal static string[] ParseLista(string valor) { if (string.IsNullOrEmpty(valor)) { return new string[0]; } string[] array = valor.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); List<string> list = new List<string>(array.Length); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text = array2[i].Trim(); if (text.Length > 0) { list.Add(text.ToLowerInvariant()); } } return list.ToArray(); } internal static Categoria DeItem(ItemData item) { return DeItem(item, NombreInterno(item)); } internal static Categoria DeItem(ItemData item, string nombreInterno) { //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_005a: 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_00c3: Expected I4, but got Unknown SharedData val = item?.m_shared; if (val == null) { return Categoria.Ninguna; } if (ReglasItems.TryObtener(nombreInterno, out var categoria)) { return categoria; } Propia[] propias = Propias; foreach (Propia propia in propias) { if (Coincide(nombreInterno, propia.Palabras)) { return propia.Categoria; } } ItemType itemType = val.m_itemType; switch (itemType - 1) { case 8: case 22: return Categoria.Municion; case 1: case 20: return Categoria.Comida; case 2: case 3: case 4: case 13: case 14: case 19: case 21: return Categoria.Armas; case 5: case 6: case 9: case 10: case 11: case 16: case 17: case 23: return Categoria.Armaduras; case 18: return Categoria.Herramientas; case 12: return Categoria.Trofeos; case 0: return DeMaterial(nombreInterno); default: if (string.IsNullOrEmpty(val.m_ammoType)) { return Categoria.Varios; } return Categoria.Municion; } } private static Categoria DeMaterial(string nombre) { if (Coincide(nombre, Monstruos)) { return Categoria.Monstruos; } if (Coincide(nombre, Pieles)) { return Categoria.Pieles; } if (Coincide(nombre, Minerales)) { return Categoria.Minerales; } if (Coincide(nombre, Madera)) { return Categoria.Madera; } if (Coincide(nombre, Semillas)) { return Categoria.Semillas; } return Categoria.Materiales; } internal static string NombreInterno(ItemData item) { if ((Object)(object)item.m_dropPrefab != (Object)null && !string.IsNullOrEmpty(((Object)item.m_dropPrefab).name)) { return ((Object)item.m_dropPrefab).name.ToLowerInvariant(); } if (item.m_shared == null || item.m_shared.m_name == null) { return string.Empty; } return item.m_shared.m_name.ToLowerInvariant(); } private static bool Coincide(string nombre, string[] lista) { if (string.IsNullOrEmpty(nombre)) { return false; } foreach (string value in lista) { if (nombre.IndexOf(value, StringComparison.Ordinal) >= 0) { return true; } } return false; } internal static Categoria DeCofre(Inventory inventario) { if (inventario == null) { return Categoria.Ninguna; } Dictionary<Categoria, int> dictionary = new Dictionary<Categoria, int>(); foreach (ItemData allItem in inventario.GetAllItems()) { Categoria categoria = DeItem(allItem); if (!(categoria == Categoria.Ninguna)) { dictionary[categoria] = ((!dictionary.TryGetValue(categoria, out var value)) ? 1 : (value + 1)); } } Categoria result = Categoria.Ninguna; int num = 0; foreach (KeyValuePair<Categoria, int> item in dictionary) { if (item.Value > num) { num = item.Value; result = item.Key; } } return result; } } internal static class EstiloValheim { private static readonly Color Dorado = new Color(1f, 0.73f, 0.31f); private static readonly Color TextoClaro = new Color(0.93f, 0.89f, 0.8f); private static readonly Color TextoTenue = new Color(0.72f, 0.66f, 0.56f); private static readonly Color FondoDeReserva = new Color(0.17f, 0.11f, 0.06f, 0.94f); private const float FraccionMinimaFondo = 0.5f; private static readonly string[] PalabrasNoFondo = new string[7] { "darken", "shadow", "blob", "glow", "mask", "selected", "highlight" }; private static bool _intentado; private static bool _recursosListos; private static Font _fuenteTitulo; private static Font _fuenteTexto; private static Color _colorTitulo = Dorado; private static Texture2D _fondoVentana; private static RectOffset _bordeVentana; private static Texture2D _fondoBoton; private static RectOffset _bordeBoton; internal static bool Listo { get; private set; } internal static GUISkin Skin { get; private set; } internal static GUIStyle Ventana { get; private set; } internal static GUIStyle Titulo { get; private set; } internal static GUIStyle Texto { get; private set; } internal static GUIStyle TextoPequeno { get; private set; } internal static GUIStyle Boton { get; private set; } internal static GUIStyle BotonMinimizar { get; private set; } internal static GUIStyle CampoTexto { get; private set; } internal static GUIStyle Fila { get; private set; } internal static GUIStyle BarraVertical { get; private set; } internal static GUIStyle PulgarVertical { get; private set; } internal static Texture2D FondoCasilla { get; private set; } internal static void Preparar() { if (_intentado) { return; } InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_container == (Object)null) { return; } _intentado = true; try { SacarRecursos(instance); _recursosListos = true; } catch (Exception ex) { Debug.LogWarning((object)("[CofreFijo] No se pudo copiar el estilo del cofre; se usa el de por defecto. " + ex.Message)); } } internal static bool Asegurar() { if (!Listo && _recursosListos) { _recursosListos = false; try { ConstruirEstilos(); Listo = true; } catch (Exception ex) { Debug.LogWarning((object)("[CofreFijo] No se pudo armar el estilo del cofre; se usa el de por defecto. " + ex.Message)); } } return Listo; } private static void SacarRecursos(InventoryGui gui) { //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_00af: 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_00cc: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) _fuenteTitulo = FuenteDe(gui.m_containerName, "Norse"); _fuenteTexto = FuenteDe(((Object)(object)gui.m_takeAllButton != (Object)null) ? ((Component)gui.m_takeAllButton).GetComponentInChildren<TMP_Text>(true) : null, "Averia"); if ((Object)(object)gui.m_containerName != (Object)null) { _colorTitulo = ((Graphic)gui.m_containerName).color; } Image val = FondoDelPanel(gui.m_container) ?? FondoDelPanel(gui.m_player) ?? FondoDelPanel(gui.m_crafting); if ((Object)(object)val != (Object)null) { _fondoVentana = Copiar(val); _bordeVentana = Borde(val.sprite); } else { _fondoVentana = Plano(FondoDeReserva); _bordeVentana = new RectOffset(0, 0, 0, 0); } Image val2 = ImagenDe((Component)(object)gui.m_takeAllButton); if ((Object)(object)val2 != (Object)null) { _fondoBoton = Copiar(val2); _bordeBoton = Borde(val2.sprite); } Image val3 = (((Object)(object)gui.m_playerGrid != (Object)null && (Object)(object)gui.m_playerGrid.m_elementPrefab != (Object)null) ? ImagenDe((Component)(object)gui.m_playerGrid.m_elementPrefab.transform) : null); FondoCasilla = (((Object)(object)val3 != (Object)null) ? Copiar(val3) : Plano(new Color(0f, 0f, 0f, 0.4f))); Debug.Log((object)("[CofreFijo] Estilo del buscador: fondo " + Describir(val) + ", botón " + Describir(val2) + ", casilla " + Describir(val3) + ", fuentes " + (((Object)(object)_fuenteTitulo != (Object)null) ? ((Object)_fuenteTitulo).name : "-") + " / " + (((Object)(object)_fuenteTexto != (Object)null) ? ((Object)_fuenteTexto).name : "-"))); } private static void ConstruirEstilos() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0022: 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_0032: Expected O, but got Unknown //IL_00af: 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_00fa: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_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_01dd: Expected O, but got Unknown //IL_01e2: Expected O, but got Unknown //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0278: 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_0295: Expected O, but got Unknown //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Expected O, but got Unknown //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Expected O, but got Unknown //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Expected O, but got Unknown //IL_02f9: Expected O, but got Unknown //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0322: 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_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Expected O, but got Unknown //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Expected O, but got Unknown //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Expected O, but got Unknown //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Expected O, but got Unknown Ventana = new GUIStyle(GUI.skin.window) { padding = new RectOffset(16, 16, 12, 16), contentOffset = Vector2.zero }; if ((Object)(object)_fondoVentana != (Object)null) { Ventana.normal.background = _fondoVentana; Ventana.onNormal.background = _fondoVentana; Ventana.focused.background = _fondoVentana; Ventana.onFocused.background = _fondoVentana; Ventana.border = _bordeVentana; } Titulo = Estilo(GUI.skin.label, _fuenteTitulo, 26, _colorTitulo); Titulo.alignment = (TextAnchor)4; Texto = Estilo(GUI.skin.label, _fuenteTexto, 15, TextoClaro); TextoPequeno = Estilo(GUI.skin.label, _fuenteTexto, 13, TextoTenue); Boton = Estilo(GUI.skin.button, _fuenteTexto, 14, TextoClaro); Boton.hover.textColor = Dorado; Boton.active.textColor = Dorado; Boton.margin = new RectOffset(2, 2, 2, 2); if ((Object)(object)_fondoBoton != (Object)null) { Boton.normal.background = _fondoBoton; Boton.hover.background = _fondoBoton; Boton.active.background = _fondoBoton; Boton.border = _bordeBoton; } BotonMinimizar = new GUIStyle(Boton) { fontSize = 18, padding = new RectOffset(0, 0, 0, 2) }; CampoTexto = Estilo(GUI.skin.textField, _fuenteTexto, 15, TextoClaro); Texture2D background = Plano(new Color(0f, 0f, 0f, 0.45f)); CampoTexto.normal.background = background; CampoTexto.hover.background = background; CampoTexto.focused.background = Plano(new Color(0f, 0f, 0f, 0.6f)); CampoTexto.focused.textColor = Color.white; CampoTexto.border = new RectOffset(0, 0, 0, 0); CampoTexto.padding = new RectOffset(6, 6, 4, 4); GUIStyle val = new GUIStyle(); val.normal.background = Plano(new Color(0f, 0f, 0f, 0.18f)); val.padding = new RectOffset(4, 4, 3, 3); val.margin = new RectOffset(0, 0, 1, 1); Fila = val; GUIStyle val2 = new GUIStyle(GUI.skin.verticalScrollbar); val2.normal.background = Plano(new Color(0f, 0f, 0f, 0.35f)); val2.border = new RectOffset(0, 0, 0, 0); val2.fixedWidth = 8f; BarraVertical = val2; GUIStyle val3 = new GUIStyle(GUI.skin.verticalScrollbarThumb); val3.normal.background = Plano(new Color(0.6f, 0.45f, 0.25f, 0.9f)); val3.border = new RectOffset(0, 0, 0, 0); val3.fixedWidth = 8f; PulgarVertical = val3; Skin = Object.Instantiate<GUISkin>(GUI.skin); ((Object)Skin).hideFlags = (HideFlags)61; Skin.window = Ventana; Skin.label = Texto; Skin.button = Boton; Skin.textField = CampoTexto; Skin.verticalScrollbar = BarraVertical; Skin.verticalScrollbarThumb = PulgarVertical; } private static GUIStyle Estilo(GUIStyle baseStyle, Font fuente, int tamano, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(baseStyle) { fontSize = tamano, wordWrap = false, clipping = (TextClipping)1 }; if ((Object)(object)fuente != (Object)null) { val.font = fuente; } val.normal.textColor = color; val.hover.textColor = color; val.active.textColor = color; val.focused.textColor = color; return val; } private static Image FondoDelPanel(RectTransform panel) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)panel == (Object)null) { return null; } Rect rect = panel.rect; float width = ((Rect)(ref rect)).width; rect = panel.rect; float areaPanel = Mathf.Max(1f, width * ((Rect)(ref rect)).height); Image[] componentsInChildren = ((Component)panel).GetComponentsInChildren<Image>(true); foreach (Image item in componentsInChildren.Where(delegate(Image i) { //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_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) Rect rect2 = ((Graphic)i).rectTransform.rect; float width2 = ((Rect)(ref rect2)).width; rect2 = ((Graphic)i).rectTransform.rect; return width2 * ((Rect)(ref rect2)).height >= areaPanel * 0.1f; })) { string[] obj = new string[8] { "[CofreFijo] imagen en ", ((Object)panel).name, ": ", Describir(item), ", ", null, null, null }; rect = ((Graphic)item).rectTransform.rect; obj[5] = ((Rect)(ref rect)).width.ToString("0"); obj[6] = "x"; rect = ((Graphic)item).rectTransform.rect; obj[7] = ((Rect)(ref rect)).height.ToString("0"); Debug.Log((object)string.Concat(obj)); } return componentsInChildren.Where(delegate(Image i) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 //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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)i.sprite != (Object)null && ((Behaviour)i).enabled && ((Graphic)i).color.a >= 0.5f && ((int)i.type == 1 || (int)i.type == 2) && !PalabrasNoFondo.Any((string p) => ((Object)i.sprite).name.IndexOf(p, StringComparison.OrdinalIgnoreCase) >= 0)) { Rect rect2 = ((Graphic)i).rectTransform.rect; float width2 = ((Rect)(ref rect2)).width; rect2 = ((Graphic)i).rectTransform.rect; return width2 * ((Rect)(ref rect2)).height >= areaPanel * 0.5f; } return false; }).OrderByDescending(delegate(Image i) { //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_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) Rect rect2 = ((Graphic)i).rectTransform.rect; float width2 = ((Rect)(ref rect2)).width; rect2 = ((Graphic)i).rectTransform.rect; return width2 * ((Rect)(ref rect2)).height; }).FirstOrDefault(); } private static Image ImagenDe(Component componente) { Image val = (((Object)(object)componente != (Object)null) ? componente.GetComponent<Image>() : null); if (!((Object)(object)val != (Object)null) || !((Object)(object)val.sprite != (Object)null)) { return null; } return val; } private static string Describir(Image imagen) { //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_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) if (!((Object)(object)imagen == (Object)null)) { return ((Object)imagen).name + " [" + (((Object)(object)imagen.sprite != (Object)null) ? ((Object)imagen.sprite).name : "sin sprite") + ", color " + ((object)((Graphic)imagen).color/*cast due to .constrained prefix*/).ToString() + ", " + ((object)imagen.type/*cast due to .constrained prefix*/).ToString() + "]"; } return "(ninguno)"; } private static Font FuenteDe(TMP_Text texto, string parteDelNombre) { Font val = (((Object)(object)texto != (Object)null && (Object)(object)texto.font != (Object)null) ? texto.font.sourceFontFile : null); if ((Object)(object)val != (Object)null) { return val; } return ((IEnumerable<Font>)Resources.FindObjectsOfTypeAll<Font>()).FirstOrDefault((Func<Font, bool>)((Font f) => ((Object)f).name.IndexOf(parteDelNombre, StringComparison.OrdinalIgnoreCase) >= 0)); } private static RectOffset Borde(Sprite sprite) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0029: Expected O, but got Unknown Vector4 border = sprite.border; return new RectOffset((int)border.x, (int)border.z, (int)border.w, (int)border.y); } private static Texture2D Copiar(Image imagen) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) Texture2D val = Copiar(imagen.sprite); Color color = ((Graphic)imagen).color; if (color != Color.white) { Color[] pixels = val.GetPixels(); for (int i = 0; i < pixels.Length; i++) { ref Color reference = ref pixels[i]; reference *= color; } val.SetPixels(pixels); val.Apply(); } return val; } private static Texture2D Copiar(Sprite sprite) { //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_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_0054: 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_005d: 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_006d: Expected O, but got Unknown Texture2D texture = sprite.texture; Rect textureRect = sprite.textureRect; RenderTexture temporary = RenderTexture.GetTemporary(((Texture)texture).width, ((Texture)texture).height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2); RenderTexture active = RenderTexture.active; try { Graphics.Blit((Texture)(object)texture, temporary); RenderTexture.active = temporary; Texture2D val = new Texture2D((int)((Rect)(ref textureRect)).width, (int)((Rect)(ref textureRect)).height, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; val.ReadPixels(textureRect, 0, 0); val.Apply(); return val; } finally { RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); } } private static Texture2D Plano(Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1) { hideFlags = (HideFlags)61 }; val.SetPixel(0, 0, color); val.Apply(); return val; } } [HarmonyPatch(typeof(Piece), "SetCreator")] internal static class ParcheAutoVincular { private static void Postfix(Piece __instance) { try { CofreFijoPlugin instancia = CofreFijoPlugin.Instancia; if (!((Object)(object)instancia == (Object)null) && instancia.AutoVincularNuevos && !((Object)(object)__instance == (Object)null)) { Container component = ((Component)__instance).GetComponent<Container>(); if (!((Object)(object)component == (Object)null)) { Vinculo.Marcar(component, vinculado: true); } } } catch { } } } [HarmonyPatch(typeof(Player), "TakeInput")] internal static class ParcheBloquearInput { private static bool Prefix(ref bool __result) { if (!VentanaCategorias.Abierta) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] internal static class ParcheCursor { private static bool Prefix() { if (!VentanaCategorias.Abierta) { return true; } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; return false; } } [HarmonyPatch(typeof(Container), "GetHoverText")] internal static class ParcheTextoCofre { private class Entrada { internal float Momento; internal Categoria Categoria; } private const float DuracionCache = 1f; private const int MaximoEnCache = 64; private static readonly Dictionary<Container, Entrada> Cache = new Dictionary<Container, Entrada>(); private static void Postfix(Container __instance, ref string __result) { try { if (!((Object)(object)__instance == (Object)null) && !string.IsNullOrEmpty(__result) && Vinculo.EstaVinculado(__instance)) { Categoria categoria = CategoriaCacheada(__instance); string text = ((categoria == Categoria.Ninguna) ? "vinculado - libre" : ("vinculado - " + Categorias.Nombre(categoria))); __result = __result + "\n<color=#D6A24A>[CofreFijo] " + text + "</color>"; } } catch { } } private static Categoria CategoriaCacheada(Container cofre) { float time = Time.time; if (Cache.TryGetValue(cofre, out var value) && time - value.Momento < 1f) { return value.Categoria; } if (Cache.Count > 64) { Cache.Clear(); } Categoria categoria = Categorias.DeCofre(cofre.GetInventory()); Cache[cofre] = new Entrada { Momento = time, Categoria = categoria }; return categoria; } } [BepInPlugin("altairfernando.cofrefijo", "CofreFijo", "1.1.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class CofreFijoPlugin : BaseUnityPlugin { private class Destino { internal Container Cofre; internal Inventory Inventario; internal Categoria Categoria; internal float Distancia; } internal class CofreCercano { internal Container Cofre; internal ZNetView Vista; internal Inventory Inventario; internal float Distancia; } private class GrupoItems { internal string Clave; internal readonly List<ItemData> Items = new List<ItemData>(); } private class Faltante { internal string Nombre; internal int Calidad; internal int Falta; } public const string PluginGuid = "altairfernando.cofrefijo"; public const string PluginName = "CofreFijo"; public const string PluginVersion = "1.1.5"; private static readonly MethodInfo MetodoGuardarCofre = AccessTools.Method(typeof(Container), "Save", (Type[])null, (Type[])null); internal static CofreFijoPlugin Instancia; private ConfigEntry<KeyboardShortcut> _teclaVincular; private ConfigEntry<KeyboardShortcut> _teclaEnviar; private ConfigEntry<KeyboardShortcut> _teclaRellenar; private ConfigEntry<float> _rango; private ConfigEntry<bool> _incluirEquipado; private ConfigEntry<int> _dejarMinimoPorItem; private ConfigEntry<int> _dejarMinimoMunicion; private ConfigEntry<string> _listaPieles; private ConfigEntry<string> _listaMinerales; private ConfigEntry<string> _listaMadera; private ConfigEntry<string> _listaSemillas; private ConfigEntry<string> _listaMonstruos; private ConfigEntry<string> _categoriasPropias; private ConfigEntry<bool> _autoVincular; private ConfigEntry<KeyboardShortcut> _teclaCategorias; private ConfigEntry<string> _reglasPorItem; private ConfigEntry<bool> _buscadorActivo; private ConfigEntry<bool> _buscadorSoloVinculados; private ConfigEntry<Vector2> _buscadorPosicion; private ConfigEntry<bool> _buscadorMinimizado; internal Vector2 BuscadorPosicion { get { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (_buscadorPosicion == null) { return new Vector2(-1f, -1f); } return _buscadorPosicion.Value; } set { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (_buscadorPosicion != null && _buscadorPosicion.Value != value) { _buscadorPosicion.Value = value; } } } internal bool BuscadorMinimizado { get { if (_buscadorMinimizado != null) { return _buscadorMinimizado.Value; } return false; } set { if (_buscadorMinimizado != null && _buscadorMinimizado.Value != value) { _buscadorMinimizado.Value = value; } } } internal bool AutoVincularNuevos { get { if (_autoVincular != null) { return _autoVincular.Value; } return false; } } internal bool BuscadorActivo { get { if (_buscadorActivo != null) { return _buscadorActivo.Value; } return false; } } internal bool BuscadorSoloVinculados { get { if (_buscadorSoloVinculados != null) { return _buscadorSoloVinculados.Value; } return false; } } internal float Rango { get { if (_rango == null) { return 20f; } return _rango.Value; } } private void Awake() { //IL_001e: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) Instancia = this; _teclaVincular = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("1 - Teclas", "TeclaVincular", new KeyboardShortcut((KeyCode)107, Array.Empty<KeyCode>()), "Mirando un cofre, lo vincula. Si ya estaba vinculado, lo desvincula."); _teclaEnviar = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("1 - Teclas", "TeclaEnviar", new KeyboardShortcut((KeyCode)106, Array.Empty<KeyCode>()), "Reparte tu inventario entre los cofres vinculados que esten dentro del rango."); _teclaRellenar = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("1 - Teclas", "TeclaRellenar", new KeyboardShortcut((KeyCode)117, Array.Empty<KeyCode>()), "Rellena desde los cofres las pilas que ya traes, hasta su maximo. No trae items nuevos."); _rango = ((BaseUnityPlugin)this).Config.Bind<float>("2 - General", "Rango", 20f, new ConfigDescription("Distancia maxima en metros entre tu personaje y un cofre para poder enviarle cosas.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 200f), Array.Empty<object>())); _incluirEquipado = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - General", "IncluirEquipado", false, "Si esta activo, tambien envia lo que traes equipado. Recomendado dejarlo apagado."); _dejarMinimoPorItem = ((BaseUnityPlugin)this).Config.Bind<int>("3 - Reservas", "DejarMinimoPorItem", 0, new ConfigDescription("Unidades de cada item que siempre se quedan contigo. 0 = mandar todo.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); _dejarMinimoMunicion = ((BaseUnityPlugin)this).Config.Bind<int>("3 - Reservas", "DejarMinimoMunicion", 0, new ConfigDescription("Unidades de cada tipo de municion que siempre se quedan contigo (flechas, etc). 0 = mandar todo.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 500), Array.Empty<object>())); _listaPieles = ((BaseUnityPlugin)this).Config.Bind<string>("4 - Categorias", "Pieles", "hide,pelt,leather,scale", "Textos que, si aparecen en el nombre interno del item, lo marcan como piel. Separados por coma."); _listaMinerales = ((BaseUnityPlugin)this).Config.Bind<string>("4 - Categorias", "Minerales", "ore,ingot,scrap,metal,coal,copper,tin,bronze,iron,silver,flametal,obsidian,flint,stone", "Textos que marcan un material como mineral. Separados por coma."); _listaMadera = ((BaseUnityPlugin)this).Config.Bind<string>("4 - Categorias", "Madera", "wood,log,beech,fir,oak,birch,yggdrasil,resin", "Textos que marcan un material como madera. Separados por coma."); _listaSemillas = ((BaseUnityPlugin)this).Config.Bind<string>("4 - Categorias", "Semillas", "seed,sapling", "Textos que marcan un material como semilla. Separados por coma."); _listaMonstruos = ((BaseUnityPlugin)this).Config.Bind<string>("4 - Categorias", "Monstruos", "greydwarfeye,bonefragments,witheredbone,entrails,necktail,wolffang,freezegland,ticksack,chitin,carapace,guck,bloodbag,softtissue", "Textos que marcan un material como despojo de monstruo. Separados por coma."); _categoriasPropias = ((BaseUnityPlugin)this).Config.Bind<string>("5 - Categorias propias", "Propias", "", "Tus propias categorias, ademas de las que trae el mod. Formato: Nombre=palabra1,palabra2;Otro\nLas palabras son opcionales: con ellas se clasifican solos los items cuyo nombre interno las contenga, y sin ellas la categoria solo se usa al asignarla a mano desde la ventana. Ejemplo: Pociones=mead,potion;Gemas"); _autoVincular = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - General", "AutoVincularNuevos", true, "Vincula automaticamente cada cofre nuevo que construyas."); _teclaCategorias = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("1 - Teclas", "TeclaCategorias", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Abre la ventana para elegir a mano la categoria de cada item."); _reglasPorItem = ((BaseUnityPlugin)this).Config.Bind<string>("6 - Reglas por item", "CategoriasElegidas", "", "Categorias elegidas a mano desde la ventana. Formato: item=Categoria;item=Categoria"); _buscadorActivo = ((BaseUnityPlugin)this).Config.Bind<bool>("7 - Buscador de cofres", "VerAlAbrirInventario", true, "Al abrir el inventario muestra, a un lado, lo que hay en los cofres del area, con buscador y botones para traerlo."); _buscadorSoloVinculados = ((BaseUnityPlugin)this).Config.Bind<bool>("7 - Buscador de cofres", "SoloVinculados", false, "Si lo enciendes, el buscador solo mira los cofres vinculados. Apagado mira todos los del area a los que tengas acceso. El area es la misma distancia de '2 - General / Rango'."); _buscadorPosicion = ((BaseUnityPlugin)this).Config.Bind<Vector2>("7 - Buscador de cofres", "Posicion", new Vector2(-1f, -1f), "Donde dejaste la ventana, en pixeles desde la esquina de arriba a la izquierda. Se guarda sola al cerrar el inventario. Con -1 vuelve a salir en el centro de la pantalla."); _buscadorMinimizado = ((BaseUnityPlugin)this).Config.Bind<bool>("7 - Buscador de cofres", "Minimizado", false, "Si la ventana estaba minimizada. Se guarda sola al cerrar el inventario."); ReglasItems.Iniciar(_reglasPorItem); RecargarListas(); _listaPieles.SettingChanged += delegate { RecargarListas(); }; _listaMinerales.SettingChanged += delegate { RecargarListas(); }; _listaMadera.SettingChanged += delegate { RecargarListas(); }; _listaSemillas.SettingChanged += delegate { RecargarListas(); }; _listaMonstruos.SettingChanged += delegate { RecargarListas(); }; _categoriasPropias.SettingChanged += delegate { RecargarListas(); }; new Harmony("altairfernando.cofrefijo").PatchAll(Assembly.GetExecutingAssembly()); ((BaseUnityPlugin)this).Logger.LogInfo((object)"CofreFijo 1.1.5 cargado."); } private void RecargarListas() { Categorias.Pieles = Categorias.ParseLista(_listaPieles.Value); Categorias.Minerales = Categorias.ParseLista(_listaMinerales.Value); Categorias.Madera = Categorias.ParseLista(_listaMadera.Value); Categorias.Semillas = Categorias.ParseLista(_listaSemillas.Value); Categorias.Monstruos = Categorias.ParseLista(_listaMonstruos.Value); Categorias.CargarPropias(_categoriasPropias.Value); } private void OnGUI() { VentanaCategorias.Dibujar(); BuscadorCofres.Dibujar(); } private void Update() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //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_0079: 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_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) BuscadorCofres.Actualizar(); if (EscribiendoTexto()) { return; } KeyboardShortcut value = _teclaCategorias.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { VentanaCategorias.Alternar(); return; } if (VentanaCategorias.Abierta) { if (Input.GetKeyDown((KeyCode)27)) { VentanaCategorias.Cerrar(); } return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || InterfazBloquea()) { return; } value = _teclaVincular.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { AlternarCofreApuntado(localPlayer); return; } value = _teclaEnviar.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { Enviar(localPlayer); return; } value = _teclaRellenar.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { Rellenar(localPlayer); } } private static bool InterfazBloquea() { if (!Menu.IsVisible() && !InventoryGui.IsVisible()) { return EscribiendoTexto(); } return true; } private static bool EscribiendoTexto() { if (TextInput.IsVisible() || Console.IsVisible()) { return true; } Chat instance = Chat.instance; if ((Object)(object)instance != (Object)null) { return instance.HasFocus(); } return false; } private void AlternarCofreApuntado(Player jugador) { GameObject hoverObject = ((Humanoid)jugador).GetHoverObject(); Container val = (((Object)(object)hoverObject != (Object)null) ? hoverObject.GetComponentInParent<Container>() : null); if ((Object)(object)val == (Object)null) { Mensaje("Apunta a un cofre para vincularlo"); return; } bool flag = !Vinculo.EstaVinculado(val); if (!Vinculo.Marcar(val, flag)) { Mensaje("No pude cambiar ese cofre, inténtalo de nuevo"); return; } if (!flag) { Mensaje("Cofre desvinculado"); return; } Categoria categoria = Categorias.DeCofre(val.GetInventory()); Mensaje((categoria == Categoria.Ninguna) ? "Cofre vinculado y libre: se le asignará categoría sola" : ("Cofre vinculado: " + Categorias.Nombre(categoria))); } private void Enviar(Player jugador) { List<Destino> list = ReunirDestinos(jugador); if (list.Count == 0) { Mensaje("No hay cofres vinculados dentro de " + _rango.Value.ToString("0") + " m"); return; } Inventory inventory = ((Humanoid)jugador).GetInventory(); if (inventory == null) { return; } int num = 0; int num2 = 0; HashSet<Container> hashSet = new HashSet<Container>(); HashSet<Categoria> hashSet2 = new HashSet<Categoria>(); HashSet<ItemData> enSlotsEspeciales = SlotsExternos.ItemsEnSlots(); foreach (GrupoItems item in AgruparMovibles(inventory, enSlotsEspeciales)) { int num3 = ReservaPendiente(inventory, item, enSlotsEspeciales); foreach (ItemData item2 in item.Items) { int num4 = item2.m_stack - num3; if (num4 <= 0) { num3 -= item2.m_stack; continue; } num3 = 0; Destino destino = ElegirDestino(list, item2, num4); if (destino == null) { num2++; hashSet2.Add(Categorias.DeItem(item2)); } else if (Mover(inventory, destino.Inventario, item2, num4)) { num++; hashSet.Add(destino.Cofre); } else { num2++; hashSet2.Add(Categorias.DeItem(item2)); } } } foreach (Container item3 in hashSet) { if (MetodoGuardarCofre != null) { MetodoGuardarCofre.Invoke(item3, null); } } string text = DescribirPendientes(num2, hashSet2); if (num == 0) { Mensaje((num2 > 0) ? text : "No hay nada que enviar"); return; } string text2 = "Enviados " + num + ((num == 1) ? " objeto a " : " objetos a ") + hashSet.Count + ((hashSet.Count == 1) ? " cofre" : " cofres"); Mensaje((num2 > 0) ? (text2 + ". " + text) : text2); } private static string DescribirPendientes(int sinDestino, HashSet<Categoria> categorias) { string text = sinDestino + ((sinDestino == 1) ? " objeto se quedó" : " objetos se quedaron"); List<string> list = new List<string>(); foreach (Categoria categoria in categorias) { if (categoria != Categoria.Ninguna) { list.Add(Categorias.Nombre(categoria)); } } if (list.Count == 0) { return text + ": no hay cofre con espacio"; } list.Sort(StringComparer.Ordinal); return text + ": falta cofre de " + string.Join(", ", list.ToArray()); } private void Rellenar(Player jugador) { List<Destino> list = ReunirDestinos(jugador); if (list.Count == 0) { Mensaje("No hay cofres vinculados dentro de " + _rango.Value.ToString("0") + " m"); return; } Inventory inventory = ((Humanoid)jugador).GetInventory(); if (inventory == null) { return; } int num = 0; HashSet<Container> hashSet = new HashSet<Container>(); foreach (Faltante item in CalcularFaltantes(inventory)) { int num2 = item.Falta; foreach (Destino item2 in list) { if (num2 <= 0) { break; } foreach (ItemData item3 in new List<ItemData>(item2.Inventario.GetAllItems())) { if (num2 <= 0) { break; } if (item3.m_shared != null && string.Equals(item3.m_shared.m_name, item.Nombre, StringComparison.Ordinal) && item3.m_quality == item.Calidad) { int num3 = Math.Min(num2, item3.m_stack); ItemData val = item3.Clone(); val.m_stack = num3; if (inventory.CanAddItem(val, num3) && inventory.AddItem(val)) { item2.Inventario.RemoveItem(item3, num3); hashSet.Add(item2.Cofre); num2 -= num3; num += num3; } } } } } foreach (Container item4 in hashSet) { if (MetodoGuardarCofre != null) { MetodoGuardarCofre.Invoke(item4, null); } } if (num == 0) { Mensaje("No hay nada con qué rellenar"); return; } Mensaje("Rellenadas " + num + ((num == 1) ? " unidad desde " : " unidades desde ") + hashSet.Count + ((hashSet.Count == 1) ? " cofre" : " cofres")); } private static List<Faltante> CalcularFaltantes(Inventory inventario) { Dictionary<string, Faltante> dictionary = new Dictionary<string, Faltante>(); foreach (ItemData allItem in inventario.GetAllItems()) { SharedData shared = allItem.m_shared; if (shared == null || shared.m_maxStackSize <= 1 || string.IsNullOrEmpty(shared.m_name)) { continue; } int num = shared.m_maxStackSize - allItem.m_stack; if (num > 0) { string key = shared.m_name + "#" + allItem.m_quality; if (!dictionary.TryGetValue(key, out var value)) { value = (dictionary[key] = new Faltante { Nombre = shared.m_name, Calidad = allItem.m_quality }); } value.Falta += num; } } return new List<Faltante>(dictionary.Values); } private List<Destino> ReunirDestinos(Player jugador) { List<Destino> list = new List<Destino>(); foreach (CofreCercano item in CofresCercanos(jugador, soloVinculados: true)) { item.Vista.ClaimOwnership(); list.Add(new Destino { Cofre = item.Cofre, Inventario = item.Inventario, Categoria = Categorias.DeCofre(item.Inventario), Distancia = item.Distancia }); } return list; } internal List<CofreCercano> CofresCercanos(Player jugador, bool soloVinculados) { //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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) List<CofreCercano> list = new List<CofreCercano>(); Vector3 position = ((Component)jugador).transform.position; Container[] array = Object.FindObjectsByType<Container>((FindObjectsSortMode)0); foreach (Container val in array) { if ((Object)(object)val == (Object)null || (soloVinculados && !Vinculo.EstaVinculado(val))) { continue; } float num = Vector3.Distance(position, ((Component)val).transform.position); if (num > _rango.Value || val.IsInUse() || !PrivateArea.CheckAccess(((Component)val).transform.position, 0f, false, false)) { continue; } ZNetView component = ((Component)val).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { Inventory inventory = val.GetInventory(); if (inventory != null) { list.Add(new CofreCercano { Cofre = val, Vista = component, Inventario = inventory, Distancia = num }); } } } list.Sort((CofreCercano a, CofreCercano b) => a.Distancia.CompareTo(b.Distancia)); return list; } internal static void Guardar(Container cofre) { if ((Object)(object)cofre != (Object)null && MetodoGuardarCofre != null) { MetodoGuardarCofre.Invoke(cofre, null); } } private static Destino ElegirDestino(List<Destino> destinos, ItemData item, int cantidad) { Categoria categoria = Categorias.DeItem(item); string text = ((item.m_shared != null) ? item.m_shared.m_name : null); Destino destino = null; int num = 0; foreach (Destino destino2 in destinos) { int num2 = 0; if (!string.IsNullOrEmpty(text) && destino2.Inventario.ContainsItemByName(text)) { num2 = 2; } else if (categoria != Categoria.Ninguna && destino2.Categoria == categoria) { num2 = 1; } if (num2 != 0 && destino2.Inventario.CanAddItem(item, cantidad) && num2 > num) { destino = destino2; num = num2; } } if (destino != null || categoria == Categoria.Ninguna) { return destino; } foreach (Destino destino3 in destinos) { if (destino3.Categoria == Categoria.Ninguna && destino3.Inventario.CanAddItem(item, cantidad)) { destino3.Categoria = categoria; return destino3; } } return null; } private static bool Mover(Inventory origen, Inventory destino, ItemData item, int cantidad) { if (cantidad <= 0) { return false; } if (cantidad >= item.m_stack) { if (!destino.CanAddItem(item, item.m_stack) || !destino.AddItem(item)) { return false; } origen.RemoveItem(item); return true; } ItemData val = item.Clone(); val.m_stack = cantidad; if (!destino.CanAddItem(val, cantidad) || !destino.AddItem(val)) { return false; } origen.RemoveItem(item, cantidad); return true; } private List<GrupoItems> AgruparMovibles(Inventory inventario, HashSet<ItemData> enSlotsEspeciales) { List<GrupoItems> list = new List<GrupoItems>(); Dictionary<string, GrupoItems> dictionary = new Dictionary<string, GrupoItems>(); foreach (ItemData allItem in inventario.GetAllItems()) { if (!EsMovible(allItem, enSlotsEspeciales)) { continue; } string text = ((allItem.m_shared != null) ? allItem.m_shared.m_name : Categorias.NombreInterno(allItem)); if (!string.IsNullOrEmpty(text)) { if (!dictionary.TryGetValue(text, out var value)) { value = (dictionary[text] = new GrupoItems { Clave = text }); list.Add(value); } value.Items.Add(allItem); } } return list; } private bool EsMovible(ItemData item, HashSet<ItemData> enSlotsEspeciales) { if (item == null || item.m_shared == null) { return false; } if (item.m_gridPos.y == 0) { return false; } if (enSlotsEspeciales != null && enSlotsEspeciales.Contains(item)) { return false; } if (!_incluirEquipado.Value) { return !item.m_equipped; } return true; } private int ReservaPendiente(Inventory inventario, GrupoItems grupo, HashSet<ItemData> enSlotsEspeciales) { int num = ((Categorias.DeItem(grupo.Items[0]) == Categoria.Municion) ? _dejarMinimoMunicion.Value : _dejarMinimoPorItem.Value); if (num <= 0) { return 0; } int num2 = 0; foreach (ItemData allItem in inventario.GetAllItems()) { if (!EsMovible(allItem, enSlotsEspeciales) && allItem.m_shared != null && string.Equals(allItem.m_shared.m_name, grupo.Clave, StringComparison.Ordinal)) { num2 += allItem.m_stack; } } int num3 = num - num2; if (num3 <= 0) { return 0; } return num3; } private static void Mensaje(string texto) { MessageHud instance = MessageHud.instance; if ((Object)(object)instance != (Object)null) { instance.ShowMessage((MessageType)2, texto, 0, (Sprite)null, false, false); } } } internal static class ReglasItems { private const char SeparadorRegistro = ';'; private const char SeparadorCampo = '='; private static ConfigEntry<string> _almacen; private static Dictionary<string, Categoria> _reglas = new Dictionary<string, Categoria>(); internal static int Cantidad => _reglas.Count; internal static void Iniciar(ConfigEntry<string> almacen) { _almacen = almacen; Releer(); _almacen.SettingChanged += delegate { Releer(); }; } internal static bool TryObtener(string nombreInterno, out Categoria categoria) { return _reglas.TryGetValue(nombreInterno, out categoria); } internal static void Asignar(string nombreInterno, Categoria categoria) { if (!string.IsNullOrEmpty(nombreInterno)) { _reglas[nombreInterno.ToLowerInvariant()] = categoria; Guardar(); } } internal static void Quitar(string nombreInterno) { if (!string.IsNullOrEmpty(nombreInterno) && _reglas.Remove(nombreInterno.ToLowerInvariant())) { Guardar(); } } private static void Releer() { Dictionary<string, Categoria> dictionary = new Dictionary<string, Categoria>(); if (_almacen == null || string.IsNullOrEmpty(_almacen.Value)) { _reglas = dictionary; return; } string[] array = _almacen.Value.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { '=' }); if (array2.Length != 2) { continue; } string text = array2[0].Trim().ToLowerInvariant(); if (text.Length != 0) { Categoria value = Categoria.Desde(array2[1]); if (!value.EsNinguna) { dictionary[text] = value; } } } _reglas = dictionary; } private static void Guardar() { if (_almacen == null) { return; } List<string> list = new List<string>(_reglas.Count); foreach (KeyValuePair<string, Categoria> regla in _reglas) { list.Add(regla.Key + "=" + regla.Value.ToString()); } list.Sort(StringComparer.Ordinal); _almacen.Value = string.Join(';'.ToString(), list.ToArray()); } } internal static class SlotsExternos { private const string NombreEnsamblado = "ExtraSlots"; private const string NombreTipo = "ExtraSlots.API"; private const string NombreMetodo = "GetAllExtraSlotsItems"; private static bool _buscado; private static MethodInfo _metodo; internal static bool Disponible => Metodo != null; private static MethodInfo Metodo { get { if (!_buscado) { _buscado = true; _metodo = Localizar(); } return _metodo; } } private static MethodInfo Localizar() { try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (!(assembly.GetName().Name != "ExtraSlots")) { Type type = assembly.GetType("ExtraSlots.API"); if (!(type == null)) { return type.GetMethod("GetAllExtraSlotsItems", BindingFlags.Static | BindingFlags.Public); } } } } catch { } return null; } internal static HashSet<ItemData> ItemsEnSlots() { HashSet<ItemData> hashSet = new HashSet<ItemData>(); MethodInfo metodo = Metodo; if (metodo == null) { return hashSet; } try { if (!(metodo.Invoke(null, null) is IEnumerable enumerable)) { return hashSet; } foreach (object item in enumerable) { ItemData val = (ItemData)((item is ItemData) ? item : null); if (val != null) { hashSet.Add(val); } } } catch { } return hashSet; } } internal static class VentanaCategorias { private class Entrada { internal string Interno; internal string Visible; internal ItemData Datos; } [CompilerGenerated] private static class <>O { public static WindowFunction <0>__Contenido; } private const int MaximoFilas = 150; private static readonly int IdVentana = "CofreFijo.Categorias".GetHashCode(); private const int CategoriasPorFila = 6; private static readonly List<Entrada> Items = new List<Entrada>(); private static Rect _rect = new Rect(120f, 90f, 620f, 520f); private static Vector2 _scroll; private static string _busqueda = ""; private static string _editando; internal static bool Abierta { get; private set; } internal static void Alternar() { Abierta = !Abierta; if (Abierta && Items.Count == 0) { Construir(); } if (!Abierta) { _editando = null; } } internal static void Cerrar() { Abierta = false; _editando = null; } private static void Construir() { Items.Clear(); ObjectDB instance = ObjectDB.instance; if ((Object)(object)instance == (Object)null || instance.m_items == null) { return; } foreach (GameObject item in instance.m_items) { if (!((Object)(object)item == (Object)null)) { ItemDrop component = item.GetComponent<ItemDrop>(); if (!((Object)(object)component == (Object)null) && component.m_itemData != null && component.m_itemData.m_shared != null) { Items.Add(new Entrada { Interno = ((Object)item).name.ToLowerInvariant(), Visible = Localizar(component.m_itemData.m_shared.m_name), Datos = component.m_itemData }); } } } Items.Sort((Entrada a, Entrada b) => string.Compare(a.Visible, b.Visible, StringComparison.OrdinalIgnoreCase)); } internal static string Localizar(string token) { try { Localization instance = Localization.instance; if (instance != null) { string text = instance.Localize(token); if (!string.IsNullOrEmpty(text)) { return text; } } } catch { } return token; } internal static void Dibujar() { //IL_000d: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown if (Abierta) { int idVentana = IdVentana; Rect rect = _rect; object obj = <>O.<0>__Contenido; if (obj == null) { WindowFunction val = Contenido; <>O.<0>__Contenido = val; obj = (object)val; } _rect = GUILayout.Window(idVentana, rect, (WindowFunction)obj, "CofreFijo - Categorías de items", Array.Empty<GUILayoutOption>()); } } private static void Contenido(int id) { //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Buscar:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(55f) }); _busqueda = GUILayout.TextField(_busqueda ?? "", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(220f) }); if (GUILayout.Button("Limpiar", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) })) { _busqueda = ""; } GUILayout.FlexibleSpace(); GUILayout.Label(ReglasItems.Cantidad + " manuales", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(95f) }); if (GUILayout.Button("Cerrar", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(65f) })) { Cerrar(); } GUILayout.EndHorizontal(); if (Items.Count == 0) { GUILayout.Label("No pude leer la lista de items. Entra a un mundo y vuelve a abrir.", Array.Empty<GUILayoutOption>()); GUI.DragWindow(); return; } GUILayout.Label("La categoría en gris es la automática. Si eliges una, queda fija para ese item.", Array.Empty<GUILayoutOption>()); GUILayout.Space(4f); _scroll = GUILayout.BeginScrollView(_scroll, Array.Empty<GUILayoutOption>()); string text = (_busqueda ?? "").Trim().ToLowerInvariant(); int num = 0; foreach (Entrada item in Items) { if (text.Length <= 0 || item.Interno.IndexOf(text, StringComparison.Ordinal) >= 0 || item.Visible.ToLowerInvariant().IndexOf(text, StringComparison.Ordinal) >= 0) { if (num >= 150) { GUILayout.Label("... hay más. Escribe en el buscador para acotar.", Array.Empty<GUILayoutOption>()); break; } num++; DibujarFila(item); } } if (num == 0) { GUILayout.Label("Ningún item coincide con \"" + _busqueda + "\"", Array.Empty<GUILayoutOption>()); } GUILayout.EndScrollView(); GUI.DragWindow(); } private static void DibujarFila(Entrada entrada) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) Categoria categoria; bool flag = ReglasItems.TryObtener(entrada.Interno, out categoria); Categoria categoria2 = Categorias.DeItem(entrada.Datos, entrada.Interno); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(entrada.Visible, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) }); GUILayout.Label(entrada.Interno, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); Color color = GUI.color; GUI.color = (flag ? Color.white : Color.gray); GUILayout.Label(Categorias.Nombre(categoria2), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(95f) }); GUI.color = color; bool flag2 = _editando == entrada.Interno; if (GUILayout.Button(flag2 ? "Cancelar" : "Cambiar", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(75f) })) { _editando = (flag2 ? null : entrada.Interno); } if (flag && GUILayout.Button("Auto", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) })) { ReglasItems.Quitar(entrada.Interno); _editando = null; } GUILayout.EndHorizontal(); if (!flag2) { return; } Categoria[] todas = Categorias.Todas; for (int i = 0; i < todas.Length; i += 6) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Space(20f); for (int j = i; j < i + 6 && j < todas.Length; j++) { if (GUILayout.Button(Categorias.Nombre(todas[j]), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(88f) })) { ReglasItems.Asignar(entrada.Interno, todas[j]); _editando = null; } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } } } internal static class Vinculo { private const string Clave = "CofreFijo_vinculado"; internal static bool EstaVinculado(Container cofre) { ZNetView val = VistaDe(cofre); if ((Object)(object)val == (Object)null) { return false; } ZDO zDO = val.GetZDO(); if (zDO != null && zDO.IsValid()) { return zDO.GetBool("CofreFijo_vinculado", false); } return false; } internal static bool Marcar(Container cofre, bool vinculado) { ZNetView val = VistaDe(cofre); if ((Object)(object)val == (Object)null) { return false; } val.ClaimOwnership(); ZDO zDO = val.GetZDO(); if (zDO == null || !zDO.IsValid()) { return false; } zDO.Set("CofreFijo_vinculado", vinculado); return true; } private static ZNetView VistaDe(Container cofre) { if ((Object)(object)cofre == (Object)null) { return null; } ZNetView component = ((Component)cofre).GetComponent<ZNetView>(); if (!((Object)(object)component != (Object)null) || !component.IsValid()) { return null; } return component; } } }