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 Baurapido v1.4.2
RotaDoBau.dll
Decompiled 3 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace RotaDoBau; [BepInPlugin("yuri.RotaDoBau", "Rota do Bau", "1.4.2")] public class Plugin : BaseUnityPlugin { private const string GruposPadrao = "valiosos=coins,ruby,amber,amberpearl;minerio=copperore,tinore,ironore,silverore,ironscrap,blackmetalscrap,flametalore;pedra=stone,flint,obsidian;barras=copper,tin,bronze,iron,silver,blackmetal,flametal;madeira=wood,finewood,corewood,roundlog,yggdrasilwood;cogumelos=mushroom,mushroomblue,mushroomyellow;frutas=blueberries,cloudberry,cloudberries,raspberry,raspberries,honey;horta=carrot,turnip,onion;comida=cookedmeat,necktailgrilled,fishcooked,serpentmeatcooked,cookedloxmeat,carrotsoup,sausages,queensjam,serpentstew,turnipstew,bloodpudding,onionsoup"; public static Plugin Instancia; public static ConfigFile Arquivo; public static ConfigEntry<bool> Ligado; public static ConfigEntry<float> Distancia; public static ConfigEntry<bool> SoEmpilhavel; public static ConfigEntry<bool> Aviso; public static ConfigEntry<bool> Agrupar; public static ConfigEntry<bool> MesmoTipo; public static ConfigEntry<string> Grupos; public static ConfigEntry<string> Prefixos; public static ConfigEntry<string> Sufixos; public static ConfigEntry<string> Pular; private void Awake() { //IL_016a: Unknown result type (might be due to invalid IL or missing references) Instancia = this; Arquivo = ((BaseUnityPlugin)this).Config; Ligado = ((BaseUnityPlugin)this).Config.Bind<bool>("Geral", "Ligado", true, "Liga o mod."); Distancia = ((BaseUnityPlugin)this).Config.Bind<float>("Geral", "Distancia", 15f, "Distancia, em metros, para procurar baus."); SoEmpilhavel = ((BaseUnityPlugin)this).Config.Bind<bool>("Geral", "SoEmpilhavel", true, "Arma, ferramenta e armadura nao saem do inventario pelo botao Guardar."); Aviso = ((BaseUnityPlugin)this).Config.Bind<bool>("Geral", "Aviso", true, "Mostra um aviso quando o item muda de bau."); Agrupar = ((BaseUnityPlugin)this).Config.Bind<bool>("Geral", "Agrupar", true, "Usa grupos, prefixos e sufixos. Minerio vai para bau de minerio, semente vai para bau de semente."); MesmoTipo = ((BaseUnityPlugin)this).Config.Bind<bool>("Geral", "MesmoTipo", false, "Se nao achar grupo, aceita bau que tenha o mesmo tipo do jogo, como material ou comida."); Grupos = ((BaseUnityPlugin)this).Config.Bind<string>("Grupos", "Lista", "valiosos=coins,ruby,amber,amberpearl;minerio=copperore,tinore,ironore,silverore,ironscrap,blackmetalscrap,flametalore;pedra=stone,flint,obsidian;barras=copper,tin,bronze,iron,silver,blackmetal,flametal;madeira=wood,finewood,corewood,roundlog,yggdrasilwood;cogumelos=mushroom,mushroomblue,mushroomyellow;frutas=blueberries,cloudberry,cloudberries,raspberry,raspberries,honey;horta=carrot,turnip,onion;comida=cookedmeat,necktailgrilled,fishcooked,serpentmeatcooked,cookedloxmeat,carrotsoup,sausages,queensjam,serpentstew,turnipstew,bloodpudding,onionsoup", "Grupos separados por ponto e virgula. Exemplo: peixe=fishraw,fishcooked"); Prefixos = ((BaseUnityPlugin)this).Config.Bind<string>("Grupos", "Prefixos", "trophy,arrow,mead", "Itens que comecam igual ficam juntos. trophy junta os trofeus."); Sufixos = ((BaseUnityPlugin)this).Config.Bind<string>("Grupos", "Sufixos", "seeds,pelt,hide,cone", "Itens que terminam igual ficam juntos. seeds junta as sementes."); Pular = ((BaseUnityPlugin)this).Config.Bind<string>("Guardar", "Pular", "", "Itens que o botao Guardar nao mexe. Ctrl+clique no botao Grupo adiciona o bau nesta lista."); new Harmony("yuri.RotaDoBau").PatchAll(); } } public class GrupoInfo { public string Nome; public List<string> Itens; } [HarmonyPatch(typeof(InventoryGui), "UpdateContainer")] public static class BotaoPatch { private static void Postfix(InventoryGui __instance) { CliquePatch.GarantirBotao(__instance); } } [HarmonyPatch(typeof(InventoryGui), "OnSelectedItem")] public static class CliquePatch { private class Envio { public Container Bau; public string Nome; public int Quantidade; public int Qualidade; public int Nivel; public int Variante; } private static readonly FieldInfo CampoAberto = AccessTools.Field(typeof(InventoryGui), "m_currentContainer"); private static Button botao; private static Button botaoGrupo; private static Button botaoVoltar; private static bool armado; private static bool abertoJaTinha; private static InventoryGui guiAtual; private static List<Envio> ultimoEnvio = new List<Envio>(); private static int sessaoBau = int.MinValue; private static Dictionary<string, int> sessaoItens; private static readonly HashSet<int> TampaNossa = new HashSet<int>(); private static readonly Dictionary<int, float> UltimoSom = new Dictionary<int, float>(); public static void GarantirBotao(InventoryGui gui) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00db: 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_00f1: Expected O, but got Unknown guiAtual = gui; if (!((Object)(object)gui == (Object)null) && !((Object)(object)gui.m_stackAllButton == (Object)null)) { if ((Object)(object)botao == (Object)null) { botao = CriarBotao(gui, "RotaDoBauGuardar", "Guardar", 1, new Color(0.35f, 0.62f, 0.38f, 1f), new UnityAction(GuardarTudo)); } if ((Object)(object)botaoGrupo == (Object)null) { botaoGrupo = CriarBotao(gui, "RotaDoBauGrupo", "Grupo", 2, new Color(0.75f, 0.62f, 0.25f, 1f), new UnityAction(ClicarGrupo)); } if ((Object)(object)botaoVoltar == (Object)null) { botaoVoltar = CriarBotao(gui, "RotaDoBauVoltar", "Voltar", 3, new Color(0.72f, 0.32f, 0.24f, 1f), new UnityAction(Voltar)); } MarcarSessao(); } } private static Button CriarBotao(InventoryGui gui, string nome, string titulo, int linha, Color cor, UnityAction acao) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0050: 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_0068: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) Button val = Object.Instantiate<Button>(gui.m_stackAllButton, ((Component)gui.m_stackAllButton).transform.parent); ((Object)val).name = nome; val.onClick = new ButtonClickedEvent(); ((UnityEvent)val.onClick).AddListener(acao); RectTransform component = ((Component)gui.m_stackAllButton).GetComponent<RectTransform>(); RectTransform component2 = ((Component)val).GetComponent<RectTransform>(); component2.anchorMin = component.anchorMin; component2.anchorMax = component.anchorMax; component2.pivot = component.pivot; component2.sizeDelta = new Vector2(104f, 28f); component2.anchoredPosition = component.anchoredPosition + new Vector2(180f, -34f * (float)(linha - 1)); ((Component)val).transform.SetAsLastSibling(); Image component3 = ((Component)val).GetComponent<Image>(); if ((Object)(object)component3 != (Object)null) { ((Graphic)component3).color = cor; } TMP_Text componentInChildren = ((Component)val).GetComponentInChildren<TMP_Text>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = titulo; } return val; } private static bool Tecla(KeyCode tecla) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) Type type = Type.GetType("UnityEngine.Input, UnityEngine.InputLegacyModule"); if (type == null) { return false; } MethodInfo method = type.GetMethod("GetKey", new Type[1] { typeof(KeyCode) }); if (method == null) { return false; } return (bool)method.Invoke(null, new object[1] { tecla }); } private static Container BauAberto(InventoryGui gui) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown if ((Object)(object)gui == (Object)null || CampoAberto == null) { return null; } return (Container)CampoAberto.GetValue(gui); } private static void Prefix(InventoryGui __instance, InventoryGrid grid, ItemData item, Modifier mod) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 armado = false; guiAtual = __instance; if (Plugin.Ligado.Value && item != null && item.m_shared != null && (int)mod == 2 && !((Object)(object)grid != (Object)(object)__instance.m_playerGrid) && !item.m_equipped && PodeMexer(item)) { if (Tecla((KeyCode)108)) { AvisarSempre("Item: " + Chave(item)); } Container val = BauAberto(__instance); if (!((Object)(object)val == (Object)null) && val.GetInventory() != null) { armado = true; abertoJaTinha = val.GetInventory().ContainsItemByName(item.m_shared.m_name); } } } private static void Postfix(InventoryGui __instance, ItemData item) { if (!armado || item == null || item.m_shared == null) { return; } armado = false; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } Container val = BauAberto(__instance); Inventory inventory = ((Humanoid)localPlayer).GetInventory(); bool flag = inventory != null && inventory.ContainsItem(item); bool flag2 = (Object)(object)val != (Object)null && val.GetInventory() != null && val.GetInventory().ContainsItem(item); if (abertoJaTinha && !flag) { return; } Inventory origem; if (!abertoJaTinha && flag2) { origem = val.GetInventory(); } else { if (!flag) { return; } origem = inventory; } Container destino = Escolher(localPlayer, val, item, flag, pularAberto: true); if (Mover(origem, destino, item) && Plugin.Aviso.Value) { string text = (flag ? "Bau cheio, foi para outro" : "Foi para outro bau"); ((Character)localPlayer).Message((MessageType)2, text, 0, (Sprite)null, true); } } private static void ClicarGrupo() { Container val = BauAberto(guiAtual); if ((Object)(object)val == (Object)null || val.GetInventory() == null) { AvisarSempre("Abre um bau primeiro"); return; } List<string> list = ChavesDoInventario(val.GetInventory()); if (list.Count == 0) { AvisarSempre("Bau vazio"); } else if (Tecla((KeyCode)306) || Tecla((KeyCode)305)) { MudarPular(list, adicionar: true); AvisarSempre("Esses itens nao entram no Guardar"); } else if (Tecla((KeyCode)304) || Tecla((KeyCode)303)) { MudarPular(list, adicionar: false); AvisarSempre("Esses itens voltam a ser guardados"); } else { string text = JuntarGrupo(list); AvisarSempre("Grupo " + text); } } private static void GuardarTudo() { if (!Plugin.Ligado.Value) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Humanoid)localPlayer).GetInventory() == null) { return; } Container aberto = BauAberto(guiAtual); Inventory inventory = ((Humanoid)localPlayer).GetInventory(); int num = 0; MarcarSessao(); for (int i = 0; i < 4; i++) { bool flag = false; List<ItemData> list = new List<ItemData>(inventory.GetAllItems()); for (int j = 0; j < list.Count; j++) { ItemData val = list[j]; if (PodeMexer(val) && inventory.ContainsItem(val) && !ListaContem(Plugin.Pular.Value, Chave(val))) { Container destino = Escolher(localPlayer, aberto, val, aceitaQualquer: true, pularAberto: false); if (Mover(inventory, destino, val)) { flag = true; num++; } } } if (!flag) { break; } } if (num > 0 && Plugin.Aviso.Value) { ((Character)localPlayer).Message((MessageType)2, "Itens guardados", 0, (Sprite)null, true); } } private static void Voltar() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Humanoid)localPlayer).GetInventory() == null) { AvisarSempre("Nada para voltar"); return; } MarcarSessao(); int num = PuxarDiferenca(localPlayer); if (num == 0) { for (int num2 = ultimoEnvio.Count - 1; num2 >= 0; num2--) { if (Puxar(localPlayer, ultimoEnvio[num2])) { num++; } } } ultimoEnvio = new List<Envio>(); sessaoItens = Contar(((Humanoid)localPlayer).GetInventory()); AvisarSempre((num > 0) ? "Itens voltaram" : "Nada para voltar"); } private static void MarcarSessao() { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && ((Humanoid)localPlayer).GetInventory() != null) { Container val = BauAberto(guiAtual); int num = (((Object)(object)val != (Object)null) ? ((Object)val).GetInstanceID() : 0); if (sessaoItens == null || num != sessaoBau) { sessaoBau = num; sessaoItens = Contar(((Humanoid)localPlayer).GetInventory()); ultimoEnvio = new List<Envio>(); } } } private static Dictionary<string, int> Contar(Inventory inv) { Dictionary<string, int> dictionary = new Dictionary<string, int>(); if (inv == null) { return dictionary; } List<ItemData> allItems = inv.GetAllItems(); for (int i = 0; i < allItems.Count; i++) { ItemData val = allItems[i]; if (val != null && val.m_shared != null && !val.m_equipped) { string key = ChaveStack(val); int num = (dictionary.ContainsKey(key) ? dictionary[key] : 0); dictionary[key] = num + val.m_stack; } } return dictionary; } private static string ChaveStack(ItemData item) { return item.m_shared.m_name + "|" + item.m_quality + "|" + item.m_variant + "|" + item.m_worldLevel; } private static int PuxarDiferenca(Player player) { if (sessaoItens == null) { return 0; } Dictionary<string, int> dictionary = Contar(((Humanoid)player).GetInventory()); int num = 0; List<string> list = new List<string>(sessaoItens.Keys); for (int i = 0; i < list.Count; i++) { string text = list[i]; int num2 = sessaoItens[text]; int num3 = (dictionary.ContainsKey(text) ? dictionary[text] : 0); int num4 = num2 - num3; if (num4 > 0 && PuxarChave(player, text, num4)) { num++; } } return num; } private static bool PuxarChave(Player player, string chave, int quantidade) { string[] array = chave.Split(new char[1] { '|' }); if (array.Length < 4) { return false; } string text = array[0]; int qualidade = int.Parse(array[1]); int variante = int.Parse(array[2]); int nivel = int.Parse(array[3]); int num = quantidade; string marca = text + "|" + qualidade + "|" + variante + "|" + nivel; List<Container> list = BausPerto(player); for (int i = 0; i < list.Count; i++) { if (num <= 0) { break; } int num2 = Quantidade(((Humanoid)player).GetInventory(), marca); Envio envio = new Envio(); envio.Bau = list[i]; envio.Nome = text; envio.Quantidade = num; envio.Qualidade = qualidade; envio.Variante = variante; envio.Nivel = nivel; Puxar(player, envio); int num3 = Quantidade(((Humanoid)player).GetInventory(), marca); int num4 = num3 - num2; if (num4 > 0) { num -= num4; } } return num < quantidade; } private static int Quantidade(Inventory inv, string marca) { Dictionary<string, int> dictionary = Contar(inv); if (!dictionary.ContainsKey(marca)) { return 0; } return dictionary[marca]; } private static List<Container> BausPerto(Player player) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) List<Container> list = new List<Container>(); Container val = BauAberto(guiAtual); if ((Object)(object)val != (Object)null) { list.Add(val); } float num = Plugin.Distancia.Value; if (num < 30f) { num = 30f; } List<Piece> list2 = new List<Piece>(); Piece.GetAllPiecesInRadius(((Component)player).transform.position, num, list2); for (int i = 0; i < list2.Count; i++) { Piece val2 = list2[i]; if (!((Object)(object)val2 == (Object)null)) { Container val3 = ((Component)val2).GetComponent<Container>(); if ((Object)(object)val3 == (Object)null) { val3 = ((Component)val2).GetComponentInParent<Container>(); } if (!((Object)(object)val3 == (Object)null) && !list.Contains(val3) && !NomeInseguro(((Object)((Component)val3).gameObject).name)) { list.Add(val3); } } } return list; } private static bool Puxar(Player player, Envio envio) { if (envio == null || (Object)(object)envio.Bau == (Object)null || envio.Quantidade <= 0) { return false; } Inventory inventory = envio.Bau.GetInventory(); Inventory inventory2 = ((Humanoid)player).GetInventory(); if (inventory == null || inventory2 == null) { return false; } ZNetView component = ((Component)envio.Bau).GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null && component.IsValid() && !component.IsOwner()) { component.ClaimOwnership(); } int num = envio.Quantidade; List<ItemData> list = new List<ItemData>(inventory.GetAllItems()); for (int i = 0; i < list.Count; i++) { if (num <= 0) { break; } ItemData val = list[i]; if (val != null && val.m_shared != null && !(val.m_shared.m_name != envio.Nome) && val.m_quality == envio.Qualidade && val.m_variant == envio.Variante && val.m_worldLevel == envio.Nivel) { int num2 = ((val.m_stack < num) ? val.m_stack : num); ItemData val2 = val.Clone(); val2.m_stack = num2; val2.m_equipped = false; if (!inventory2.AddItem(val2)) { return num < envio.Quantidade; } inventory.RemoveItem(val, num2); num -= num2; } } return num < envio.Quantidade; } private static Container Escolher(Player player, Container aberto, ItemData item, bool aceitaQualquer, bool pularAberto) { Container val = Achar(player, aberto, item, 0, pularAberto); if ((Object)(object)val == (Object)null && Plugin.Agrupar.Value) { val = Achar(player, aberto, item, 1, pularAberto); } if ((Object)(object)val == (Object)null && Plugin.MesmoTipo.Value) { val = Achar(player, aberto, item, 2, pularAberto); } if ((Object)(object)val == (Object)null && aceitaQualquer) { val = Achar(player, aberto, item, 3, pularAberto); } return val; } private static Container Achar(Player player, Container aberto, ItemData item, int modo, bool pularAberto) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) List<Piece> list = new List<Piece>(); Piece.GetAllPiecesInRadius(((Component)player).transform.position, Plugin.Distancia.Value, list); Container result = null; float num = float.MaxValue; string name = item.m_shared.m_name; string chave = Chave(item); for (int i = 0; i < list.Count; i++) { Piece val = list[i]; if ((Object)(object)val == (Object)null) { continue; } Container val2 = ((Component)val).GetComponent<Container>(); if ((Object)(object)val2 == (Object)null) { val2 = ((Component)val).GetComponentInParent<Container>(); } if ((Object)(object)val2 == (Object)null || (pularAberto && (Object)(object)val2 == (Object)(object)aberto) || ((Object)(object)val2 != (Object)(object)aberto && val2.IsInUse() && !TampaNossa.Contains(((Object)val2).GetInstanceID())) || NomeInseguro(((Object)((Component)val2).gameObject).name)) { continue; } Inventory inventory = val2.GetInventory(); if (inventory != null && Cabe(inventory, item) && (modo != 0 || inventory.ContainsItemByName(name)) && (modo != 1 || CombinaGrupo(inventory, chave)) && (modo != 2 || TemMesmoTipo(inventory, item.m_shared.m_itemType))) { float num2 = Vector3.Distance(((Component)player).transform.position, ((Component)val2).transform.position); if (num2 < num) { num = num2; result = val2; } } } return result; } private static bool Mover(Inventory origem, Container destino, ItemData item) { if (origem == null || (Object)(object)destino == (Object)null || destino.GetInventory() == null || destino.GetInventory() == origem) { return false; } ZNetView component = ((Component)destino).GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null && component.IsValid() && !component.IsOwner()) { component.ClaimOwnership(); } int stack = item.m_stack; string name = item.m_shared.m_name; int quality = item.m_quality; int worldLevel = item.m_worldLevel; int variant = item.m_variant; destino.GetInventory().MoveItemToThis(origem, item); int num = (origem.ContainsItem(item) ? (stack - item.m_stack) : stack); if (num <= 0) { return false; } Envio envio = new Envio(); envio.Bau = destino; envio.Nome = name; envio.Quantidade = num; envio.Qualidade = quality; envio.Nivel = worldLevel; envio.Variante = variant; ultimoEnvio.Add(envio); TocarBau(destino); return true; } private static void TocarBau(Container bau) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bau == (Object)null) { return; } int instanceID = ((Object)bau).GetInstanceID(); float time = Time.time; if (!UltimoSom.ContainsKey(instanceID) || !(time - UltimoSom[instanceID] < 0.8f)) { UltimoSom[instanceID] = time; bool flag = (Object)(object)bau == (Object)(object)BauAberto(guiAtual); bool abertoLigado = (Object)(object)bau.m_open != (Object)null && bau.m_open.activeSelf; bool fechadoLigado = (Object)(object)bau.m_closed != (Object)null && bau.m_closed.activeSelf; if (!flag) { bau.SetInUse(true); TampaNossa.Add(instanceID); AbrirTampa(bau, abrir: true); } Vector3 posBau = ((Component)bau).transform.position + Vector3.up * 0.6f; TocarEfeito(bau.m_openEffects, posBau, abrir: true); if (!TemEfeito(bau.m_openEffects)) { TocarZsfx(bau); } if ((Object)(object)Plugin.Instancia != (Object)null) { ((MonoBehaviour)Plugin.Instancia).StartCoroutine(FecharDepois(bau, flag, abertoLigado, fechadoLigado)); } } } private static void AbrirTampa(Container bau, bool abrir) { if ((Object)(object)bau.m_open != (Object)null) { bau.m_open.SetActive(abrir); } if ((Object)(object)bau.m_closed != (Object)null) { bau.m_closed.SetActive(!abrir); } } private static IEnumerator FecharDepois(Container bau, bool jaAberto, bool abertoLigado, bool fechadoLigado) { yield return (object)new WaitForSeconds(0.85f); if ((Object)(object)bau == (Object)null) { yield break; } TocarEfeito(bau.m_closeEffects, ((Component)bau).transform.position + Vector3.up * 0.6f, abrir: false); TampaNossa.Remove(((Object)bau).GetInstanceID()); if (!jaAberto && !((Object)(object)bau == (Object)(object)BauAberto(guiAtual))) { bau.SetInUse(false); if ((Object)(object)bau.m_open != (Object)null) { bau.m_open.SetActive(abertoLigado); } if ((Object)(object)bau.m_closed != (Object)null) { bau.m_closed.SetActive(fechadoLigado); } } } private static bool TemEfeito(EffectList lista) { if (lista != null && lista.m_effectPrefabs != null) { return lista.m_effectPrefabs.Length > 0; } return false; } private static void TocarEfeito(EffectList lista, Vector3 posBau, bool abrir) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_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_0036: 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_0041: 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_0051: 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_006d: 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_007c: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) Quaternion identity = Quaternion.identity; Player localPlayer = Player.m_localPlayer; Vector3 val = posBau; if ((Object)(object)localPlayer != (Object)null) { val = ((Component)localPlayer).transform.position + Vector3.up * 1.2f; } if (TemEfeito(lista)) { lista.Create(posBau, identity, (Transform)null, 1f, -1, default(ZDOID)); if ((Object)(object)localPlayer != (Object)null && Vector3.Distance(((Component)localPlayer).transform.position, posBau) > 4f) { lista.Create(val, identity, (Transform)null, 1f, -1, default(ZDOID)); } return; } InventoryGui instance = InventoryGui.instance; if (!((Object)(object)instance == (Object)null)) { EffectList val2 = (abrir ? instance.m_openInventoryEffects : instance.m_closeInventoryEffects); if (TemEfeito(val2)) { val2.Create(val, identity, (Transform)null, 1f, -1, default(ZDOID)); } } } private static void TocarZsfx(Container bau) { ZSFX[] componentsInChildren = ((Component)bau).GetComponentsInChildren<ZSFX>(true); if (componentsInChildren == null) { return; } for (int i = 0; i < componentsInChildren.Length && i < 2; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { componentsInChildren[i].Play(); } } } private static bool PodeMexer(ItemData item) { if (item == null || item.m_shared == null || item.m_equipped) { return false; } if (Plugin.SoEmpilhavel.Value && item.m_shared.m_maxStackSize <= 1) { return false; } return true; } private static bool Cabe(Inventory inv, ItemData item) { if (inv.FindFreeStackSpace(item.m_shared.m_name, (float)item.m_worldLevel) > 0) { return true; } if (inv.GetEmptySlots() > 0) { return inv.CanAddItem(item, 1); } return false; } private static bool CombinaGrupo(Inventory inv, string chave) { if (chave.Length == 0) { return false; } List<ItemData> allItems = inv.GetAllItems(); for (int i = 0; i < allItems.Count; i++) { string text = Chave(allItems[i]); if (text.Length != 0 && !(text == chave) && (MesmoGrupo(chave, text) || MesmoAfixo(chave, text))) { return true; } } return false; } private static bool TemMesmoTipo(Inventory inv, ItemType tipo) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //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) if ((int)tipo == 0 || (int)tipo == 16) { return false; } List<ItemData> allItems = inv.GetAllItems(); for (int i = 0; i < allItems.Count; i++) { ItemData val = allItems[i]; if (val != null && val.m_shared != null && val.m_shared.m_itemType == tipo) { return true; } } return false; } private static List<string> ChavesDoInventario(Inventory inv) { List<string> list = new List<string>(); List<ItemData> allItems = inv.GetAllItems(); for (int i = 0; i < allItems.Count; i++) { string text = Chave(allItems[i]); if (text.Length > 0 && !list.Contains(text)) { list.Add(text); } } return list; } private static string JuntarGrupo(List<string> chaves) { List<GrupoInfo> list = LerGrupos(); List<GrupoInfo> list2 = new List<GrupoInfo>(); for (int i = 0; i < list.Count; i++) { if (Intersecta(list[i].Itens, chaves)) { list2.Add(list[i]); } } GrupoInfo grupoInfo; if (list2.Count == 0) { grupoInfo = new GrupoInfo(); grupoInfo.Nome = "grupo" + (list.Count + 1); grupoInfo.Itens = new List<string>(); list.Add(grupoInfo); } else { grupoInfo = list2[0]; for (int j = 1; j < list2.Count; j++) { if (list2[j].Itens.Count > grupoInfo.Itens.Count) { grupoInfo = list2[j]; } } } for (int k = 0; k < chaves.Count; k++) { if (!grupoInfo.Itens.Contains(chaves[k])) { grupoInfo.Itens.Add(chaves[k]); } } for (int l = 0; l < list2.Count; l++) { if (list2[l] == grupoInfo) { continue; } for (int m = 0; m < list2[l].Itens.Count; m++) { string item = list2[l].Itens[m]; if (!grupoInfo.Itens.Contains(item)) { grupoInfo.Itens.Add(item); } } list2[l].Itens.Clear(); } for (int num = list.Count - 1; num >= 0; num--) { if (list[num].Itens.Count == 0) { list.RemoveAt(num); } } SalvarGrupos(list); return grupoInfo.Nome; } private static bool MesmoGrupo(string a, string b) { string text = GrupoDaChave(a); string text2 = GrupoDaChave(b); if (text.Length > 0) { return text == text2; } return false; } private static bool MesmoAfixo(string a, string b) { string text = Afixo(Plugin.Prefixos.Value, a, prefixo: true); string text2 = Afixo(Plugin.Prefixos.Value, b, prefixo: true); if (text.Length > 0 && text == text2) { return true; } string text3 = Afixo(Plugin.Sufixos.Value, a, prefixo: false); string text4 = Afixo(Plugin.Sufixos.Value, b, prefixo: false); if (text3.Length > 0) { return text3 == text4; } return false; } private static string GrupoDaChave(string chave) { List<GrupoInfo> list = LerGrupos(); for (int i = 0; i < list.Count; i++) { if (list[i].Itens.Contains(chave)) { return list[i].Nome; } } return ""; } private static string Afixo(string lista, string chave, bool prefixo) { List<string> list = Separar(lista); string text = ""; for (int i = 0; i < list.Count; i++) { string text2 = list[i]; if ((prefixo ? chave.StartsWith(text2) : chave.EndsWith(text2)) && text2.Length > text.Length) { text = text2; } } return text; } private static List<GrupoInfo> LerGrupos() { List<GrupoInfo> list = new List<GrupoInfo>(); if (Plugin.Grupos == null || string.IsNullOrEmpty(Plugin.Grupos.Value)) { return list; } string[] array = Plugin.Grupos.Value.Split(new char[1] { ';' }); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); int num = text.IndexOf('='); if (num > 0) { GrupoInfo grupoInfo = new GrupoInfo(); grupoInfo.Nome = text.Substring(0, num).Trim().ToLowerInvariant(); grupoInfo.Itens = Separar(text.Substring(num + 1)); if (grupoInfo.Nome.Length > 0 && grupoInfo.Itens.Count > 0) { list.Add(grupoInfo); } } } return list; } private static void SalvarGrupos(List<GrupoInfo> grupos) { string text = ""; for (int i = 0; i < grupos.Count; i++) { if (grupos[i].Itens.Count != 0) { if (text.Length > 0) { text += ";"; } text = text + grupos[i].Nome + "=" + Juntar(grupos[i].Itens); } } Plugin.Grupos.Value = text; Plugin.Arquivo.Save(); } private static void MudarPular(List<string> chaves, bool adicionar) { List<string> list = Separar(Plugin.Pular.Value); for (int i = 0; i < chaves.Count; i++) { if (adicionar) { if (!list.Contains(chaves[i])) { list.Add(chaves[i]); } } else { list.Remove(chaves[i]); } } Plugin.Pular.Value = Juntar(list); Plugin.Arquivo.Save(); } private static bool ListaContem(string lista, string chave) { return Separar(lista).Contains(chave); } private static List<string> Separar(string texto) { List<string> list = new List<string>(); if (string.IsNullOrEmpty(texto)) { return list; } string[] array = texto.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim().ToLowerInvariant(); if (text.Length > 0 && !list.Contains(text)) { list.Add(text); } } return list; } private static string Juntar(List<string> lista) { string text = ""; for (int i = 0; i < lista.Count; i++) { if (text.Length > 0) { text += ","; } text += lista[i]; } return text; } private static bool Intersecta(List<string> a, List<string> b) { for (int i = 0; i < a.Count; i++) { if (b.Contains(a[i])) { return true; } } return false; } private static string Chave(ItemData item) { if (item == null) { return ""; } string text = ""; if ((Object)(object)item.m_dropPrefab != (Object)null) { text = ((Object)item.m_dropPrefab).name; } if (string.IsNullOrEmpty(text) && item.m_shared != null) { text = item.m_shared.m_name; } if (string.IsNullOrEmpty(text)) { return ""; } text = text.ToLowerInvariant(); if (text.StartsWith("$item_")) { text = text.Substring(6); } return text; } private static void AvisarSempre(string texto) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { ((Character)localPlayer).Message((MessageType)2, texto, 0, (Sprite)null, true); } } private static bool NomeInseguro(string nome) { if (string.IsNullOrEmpty(nome)) { return true; } string text = nome.ToLowerInvariant(); if (!text.Contains("ship") && !text.Contains("karve") && !text.Contains("cart") && !text.Contains("wagon") && !text.Contains("tombstone")) { return text.Contains("obliterator"); } return true; } }