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 Bondi v1.0.0
Bondi.dll
Decompiled a day 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 System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("Bondi")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9d7e3a1e0097f12212a6aef9e559ef609d51da6f")] [assembly: AssemblyProduct("Bondi")] [assembly: AssemblyTitle("Bondi")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 Bondi { internal static class Catalogo { [HarmonyPatch(typeof(ZNetScene), "Awake")] private static class AoCarregarCena { private static void Postfix(ZNetScene __instance) { Montar(__instance); } } internal static readonly HashSet<string> Cultivos = new HashSet<string>(); internal static readonly HashSet<string> Mel = new HashSet<string>(); internal static readonly Dictionary<string, Piece> MudaPorColheita = new Dictionary<string, Piece>(); internal static bool PadraoPermite(string item) { if (!Cultivos.Contains(item)) { return Mel.Contains(item); } return true; } internal static bool Permitido(string item) { if (string.IsNullOrEmpty(item)) { return false; } return Plugin.RegraDe(item) switch { RegraItem.Allow => true, RegraItem.Block => false, _ => PadraoPermite(item), }; } internal static void Montar(ZNetScene __instance) { Cultivos.Clear(); Mel.Clear(); MudaPorColheita.Clear(); List<string> list = new List<string>(); foreach (GameObject prefab in __instance.m_prefabs) { if ((Object)(object)prefab == (Object)null) { continue; } Plant component = prefab.GetComponent<Plant>(); if ((Object)(object)component != (Object)null && component.m_grownPrefabs != null) { Piece component2 = prefab.GetComponent<Piece>(); GameObject[] grownPrefabs = component.m_grownPrefabs; foreach (GameObject val in grownPrefabs) { Pickable val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Pickable>() : null); if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.m_itemPrefab == (Object)null)) { Cultivos.Add(((Object)val2.m_itemPrefab).name); if ((Object)(object)component2 != (Object)null && val2.m_respawnTimeMinutes <= 0f && !MudaPorColheita.ContainsKey(((Object)val).name)) { MudaPorColheita[((Object)val).name] = component2; } } } } Pickable component3 = prefab.GetComponent<Pickable>(); if ((Object)(object)component3 != (Object)null && (Object)(object)component3.m_itemPrefab != (Object)null) { list.Add(((Object)component3.m_itemPrefab).name); } Beehive component4 = prefab.GetComponent<Beehive>(); if ((Object)(object)component4 != (Object)null && (Object)(object)component4.m_honeyItem != (Object)null) { Mel.Add(((Object)((Component)component4.m_honeyItem).gameObject).name); } } Plugin.CriarRegrasDeItens(list.Concat(Cultivos).Concat(Mel)); } } internal static class Registro { [HarmonyPatch(typeof(Pickable), "Awake")] private static class NovoColhivel { private static void Postfix(Pickable __instance) { Colhiveis.Add(__instance); } } [HarmonyPatch(typeof(Beehive), "Awake")] private static class NovaColmeia { private static void Postfix(Beehive __instance) { Colmeias.Add(__instance); } } internal static readonly HashSet<Pickable> Colhiveis = new HashSet<Pickable>(); internal static readonly HashSet<Beehive> Colmeias = new HashSet<Beehive>(); internal static void Preencher() { Pickable[] array = Object.FindObjectsByType<Pickable>((FindObjectsSortMode)0); foreach (Pickable item in array) { Colhiveis.Add(item); } Beehive[] array2 = Object.FindObjectsByType<Beehive>((FindObjectsSortMode)0); foreach (Beehive item2 in array2) { Colmeias.Add(item2); } } } internal static class Colheita { [HarmonyPatch(typeof(Pickable), "Interact")] private static class AoColher { private static void Postfix(Pickable __instance, Humanoid character, bool repeat, bool __result) { //IL_0036: 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_004e: Expected O, but got Unknown try { if (__result && !emAndamento && !((Object)(object)character != (Object)(object)Player.m_localPlayer)) { string text = ItemDe(__instance); if (Disparou(character, repeat) && Catalogo.Permitido(text)) { Plugin.Rodar(ColherArea((Player)character, ((Component)__instance).transform.position, text, __instance, null)); } } } catch (Exception ex) { Plugin.Log.LogError((object)("colheita: " + ex)); } } } [HarmonyPatch(typeof(Beehive), "Interact")] private static class AoTirarMel { private static void Postfix(Beehive __instance, Humanoid character, bool repeat, bool __result) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if (__result && Disparou(character, repeat)) { string text = MelDe(__instance); if (Catalogo.Permitido(text)) { Plugin.Rodar(ColherArea((Player)character, ((Component)__instance).transform.position, text, null, __instance)); } } } } [HarmonyPatch(typeof(Pickable), "GetHoverText")] private static class Dica { private static void Postfix(Pickable __instance, ref string __result) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(__result) && Sincronia.ColheitaAtiva && __instance.CanBePicked() && Catalogo.Permitido(ItemDe(__instance))) { __result += Localization.instance.Localize("\n[<color=yellow><b>" + NomeTecla(Plugin.TeclaColheita.Value) + " + $KEY_Use</b></color>] " + Texto.ColherEmArea); } } } private static bool emAndamento; private const int PorQuadro = 12; private static string ItemDe(Pickable pk) { if (!((Object)(object)pk != (Object)null) || !((Object)(object)pk.m_itemPrefab != (Object)null)) { return null; } return ((Object)pk.m_itemPrefab).name; } private static string MelDe(Beehive b) { if (!((Object)(object)b != (Object)null) || !((Object)(object)b.m_honeyItem != (Object)null)) { return null; } return ((Object)((Component)b.m_honeyItem).gameObject).name; } private static bool Valido(ZNetView v) { if ((Object)(object)v != (Object)null) { return v.IsValid(); } return false; } private static bool Disparou(Humanoid quem, bool repeat) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!repeat && (Object)(object)quem != (Object)null && (Object)(object)quem == (Object)(object)Player.m_localPlayer && !emAndamento && Sincronia.ColheitaAtiva) { return ZInput.GetKey(Plugin.TeclaColheita.Value, false); } return false; } private unsafe static string NomeTecla(KeyCode k) { string text = ((object)(*(KeyCode*)(&k))/*cast due to .constrained prefix*/).ToString(); if (text.EndsWith("Shift")) { return "Shift"; } if (text.EndsWith("Control")) { return "Ctrl"; } if (text.EndsWith("Alt")) { return "Alt"; } return text; } private static IEnumerator ColherArea(Player quem, Vector3 centro, string itemBase, Pickable jaColhido, Beehive jaTirada) { //IL_000e: 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) emAndamento = true; try { float raio = Sincronia.Raio; float num = raio * raio; bool flag = Sincronia.Valor<EstiloColheita>(Plugin.Estilo) == EstiloColheita.SameType; Registro.Colhiveis.RemoveWhere((Pickable p) => (Object)(object)p == (Object)null); Registro.Colmeias.RemoveWhere((Beehive b) => (Object)(object)b == (Object)null); List<Pickable> list = new List<Pickable>(); Vector3 val; foreach (Pickable colhivei in Registro.Colhiveis) { if ((Object)(object)colhivei == (Object)(object)jaColhido || !Valido(colhivei.m_nview)) { continue; } Vector3 position = ((Component)colhivei).transform.position; val = position - centro; if (!(((Vector3)(ref val)).sqrMagnitude > num) && colhivei.CanBePicked()) { string text = ItemDe(colhivei); if (!(flag ? (text != itemBase) : (!Catalogo.Permitido(text))) && PrivateArea.CheckAccess(position, 0f, false, false)) { list.Add(colhivei); } } } list.Sort(delegate(Pickable a, Pickable b) { //IL_0006: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) Vector3 val2 = ((Component)a).transform.position - centro; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; val2 = ((Component)b).transform.position - centro; return sqrMagnitude.CompareTo(((Vector3)(ref val2)).sqrMagnitude); }); List<Beehive> colmeias = new List<Beehive>(); foreach (Beehive colmeia in Registro.Colmeias) { if ((Object)(object)colmeia == (Object)(object)jaTirada || !Valido(colmeia.m_nview)) { continue; } val = ((Component)colmeia).transform.position - centro; if (!(((Vector3)(ref val)).sqrMagnitude > num)) { string text2 = MelDe(colmeia); if (!(flag ? (text2 != itemBase) : (!Catalogo.Permitido(text2))) && colmeia.GetHoneyLevel() > 0 && PrivateArea.CheckAccess(((Component)colmeia).transform.position, 0f, false, false)) { colmeias.Add(colmeia); } } } int i = 0; foreach (Pickable item in list) { if (!((Object)(object)quem == (Object)null)) { if ((Object)(object)item != (Object)null && Valido(item.m_nview) && item.CanBePicked()) { item.Interact((Humanoid)(object)quem, false, false); } int num2 = i + 1; i = num2; if (num2 % 12 == 0) { yield return null; } continue; } yield break; } foreach (Beehive item2 in colmeias) { if (!((Object)(object)quem == (Object)null)) { if ((Object)(object)item2 != (Object)null && Valido(item2.m_nview) && item2.GetHoneyLevel() > 0) { item2.Interact((Humanoid)(object)quem, false, false); } int num2 = i + 1; i = num2; if (num2 % 12 == 0) { yield return null; } continue; } yield break; } } finally { emAndamento = false; } } } [HarmonyPatch(typeof(Plant), "GetHoverText")] internal static class Crescimento { private static void Postfix(Plant __instance, ref string __result) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (Sincronia.Valor<bool>(Plugin.MostrarCrescimento) && !string.IsNullOrEmpty(__result) && !((Object)(object)__instance.m_nview == (Object)null) && __instance.m_nview.IsValid() && !((Object)(object)ZNet.instance == (Object)null) && (int)__instance.GetStatus() == 0) { double num = __instance.TimeSincePlanted(); float growTime = __instance.GetGrowTime(); if (!(growTime <= 0f)) { float num2 = Mathf.Clamp01((float)(num / (double)growTime)); double s = Math.Max(0.0, (double)growTime - num); string text = ((num2 >= 1f) ? Texto.Pronta : Texto.Crescendo(Mathf.FloorToInt(num2 * 100f), Tempo(s))); __result = __result + "\n<color=#9CE37A>" + text + "</color>"; } } } private static string Tempo(double s) { if (s >= 3600.0) { return $"{(int)(s / 3600.0)} h {(int)(s % 3600.0 / 60.0)} min"; } if (s >= 60.0) { return $"{(int)Math.Ceiling(s / 60.0)} min"; } return $"{(int)Math.Ceiling(s)} s"; } } internal static class Grade { private struct Vaga { public Vector3 pos; public Quaternion rot; public bool ok; } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] private static class AtualizarFantasmas { private static void Postfix(Player __instance) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Invalid comparison between Unknown and I4 //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Invalid comparison between Unknown and I4 //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0346: 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_0316: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } if (!EmPlantio(__instance, out var peca, out var planta)) { if (copias.Count > 0) { Limpar(); } Marcas.Ocultar(); return; } GameObject placementGhost = __instance.m_placementGhost; Eixos(__instance, out var frente, out var direita); float num = Passo(planta); if (Plugin.Encaixe.Value && placementGhost.activeSelf) { Encaixar(__instance, placementGhost, peca, planta, frente, direita, num); } bool flag = (int)__instance.m_placementStatus == 0; if (!placementGhost.activeSelf) { Marcas.Ocultar(); } if (LinhasUso * ColunasUso <= 1) { if (copias.Count > 0) { Limpar(); } if (placementGhost.activeSelf) { Marcas.Contorno(placementGhost.transform.position, frente, direita, num, 1, 1, flag ? Plugin.CorValida.Value : Plugin.CorInvalida.Value); } return; } if ((Object)(object)fantasmaBase != (Object)(object)placementGhost) { Limpar(); fantasmaBase = placementGhost; nossos.Add(placementGhost); } int num2 = LinhasUso * ColunasUso - 1; while (copias.Count < num2) { copias.Add(Copiar(placementGhost)); } while (copias.Count > num2) { GameObject val = copias[copias.Count - 1]; copias.RemoveAt(copias.Count - 1); nossos.Remove(val); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } bool activeSelf = placementGhost.activeSelf; bool flag2 = (int)__instance.m_placementStatus == 0; Vector3 position = placementGhost.transform.position; Quaternion rotation = placementGhost.transform.rotation; vagas.Clear(); int num3 = 0; int num4 = 0; for (int i = 0; i < LinhasUso; i++) { for (int j = 0; j < ColunasUso; j++) { if (i != 0 || j != 0) { Vector3 pos = position + frente * ((float)i * num) + direita * ((float)j * num); bool flag3 = activeSelf && flag2 && VagaBoa(ref pos, peca, planta); GameObject val2 = copias[num3++]; val2.transform.SetPositionAndRotation(pos, rotation); bool flag4 = activeSelf && (flag3 || !Plugin.EsconderInvalidas.Value); if (val2.activeSelf != flag4) { val2.SetActive(flag4); } Piece component = val2.GetComponent<Piece>(); if ((Object)(object)component != (Object)null && flag4) { component.SetInvalidPlacementHeightlight(!flag3); } vagas.Add(new Vaga { pos = pos, rot = rotation, ok = flag3 }); if (flag3) { num4++; } } } } if (!activeSelf) { Marcas.Ocultar(); return; } Color cor = ((!flag2) ? Plugin.CorInvalida.Value : ((num4 == vagas.Count) ? Plugin.CorValida.Value : Plugin.CorParcial.Value)); Marcas.Contorno(position, frente, direita, num, LinhasUso, ColunasUso, cor); } } [HarmonyPatch(typeof(Player), "TryPlacePiece")] private static class GuardarPlantio { private static void Postfix(Player __instance, Piece piece, bool __result) { if (__result && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && vagas.Count != 0 && Ativa(__instance, out var peca, out var _) && !((Object)(object)peca != (Object)(object)piece)) { pendente = true; pecaPendente = piece; filaPendente.Clear(); filaPendente.AddRange(vagas); } } } [HarmonyPatch(typeof(Player), "UpdatePlacement")] private static class PlantarExtras { private static void Postfix(Player __instance) { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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) if (!pendente || (Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } pendente = false; Piece pecaPendente = Grade.pecaPendente; Grade.pecaPendente = null; if ((Object)(object)pecaPendente == (Object)null) { return; } Plant component = ((Component)pecaPendente).GetComponent<Plant>(); ItemData rightItem = ((Humanoid)__instance).GetRightItem(); bool noPlacementCost = __instance.m_noPlacementCost; int num = 0; int num2 = 0; string text = null; foreach (Vaga item in filaPendente) { if (!item.ok) { continue; } num2++; if (text != null) { continue; } if (!noPlacementCost && !__instance.HaveRequirements(pecaPendente, (RequirementMode)0)) { text = Texto.Sementes; continue; } float buildStamina = __instance.GetBuildStamina(); if (!noPlacementCost && !((Character)__instance).HaveStamina(buildStamina)) { text = Texto.Estamina; continue; } if (!noPlacementCost && rightItem != null && rightItem.m_shared.m_useDurability && rightItem.m_durability <= 0f) { text = Texto.Durabilidade; continue; } Vector3 pos = item.pos; if ((Object)(object)component != (Object)null && !VagaBoa(ref pos, pecaPendente, component)) { continue; } __instance.PlacePiece(pecaPendente, pos, item.rot, false, false); num++; if (!noPlacementCost) { __instance.ConsumeResources(pecaPendente.m_resources, 0, -1, 1); ((Character)__instance).UseStamina(buildStamina); if (rightItem != null && rightItem.m_shared.m_useDurability) { rightItem.m_durability -= __instance.GetPlaceDurability(rightItem) * Game.m_durabilityRate; } PieceTable buildPieces = __instance.m_buildPieces; if ((Object)(object)buildPieces != (Object)null && (int)buildPieces.m_skill != 0) { ((Character)__instance).RaiseSkill(buildPieces.m_skill, 1f); } } } filaPendente.Clear(); if (text != null) { Plugin.Mensagem(Texto.Plantadas(num + 1, num2 + 1, text)); } } } [HarmonyPatch(typeof(Player), "OnDestroy")] private static class AoSair { private static void Postfix(Player __instance) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer || (Object)(object)Player.m_localPlayer == (Object)null) { Limpar(); } } } private static readonly List<GameObject> copias = new List<GameObject>(); private static readonly List<Vaga> vagas = new List<Vaga>(); private static readonly HashSet<GameObject> nossos = new HashSet<GameObject>(); private static readonly Collider[] buffer = (Collider[])(object)new Collider[256]; private static GameObject fantasmaBase; private static GameObject berco; private static int mascara = -1; private static bool pendente; private static Piece pecaPendente; private static readonly List<Vaga> filaPendente = new List<Vaga>(); private static readonly Collider[] vizinhosBuf = (Collider[])(object)new Collider[128]; private static readonly List<Vector3> vizinhos = new List<Vector3>(); private static bool presoA; private static bool presoB; internal static int LinhasUso => Mathf.Clamp(Plugin.Linhas.Value, 1, Sincronia.Valor<int>(Plugin.MaximoPorLado)); internal static int ColunasUso => Mathf.Clamp(Plugin.Colunas.Value, 1, Sincronia.Valor<int>(Plugin.MaximoPorLado)); private static int Mascara() { if (mascara == -1) { mascara = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid" }); } return mascara; } internal static bool EhPlanta(Piece p) { if ((Object)(object)p != (Object)null) { return (Object)(object)((Component)p).GetComponent<Plant>() != (Object)null; } return false; } private static bool EmPlantio(Player p, out Piece peca, out Plant planta) { peca = null; planta = null; if ((Object)(object)p == (Object)null || (Object)(object)p != (Object)(object)Player.m_localPlayer || !((Character)p).InPlaceMode() || (Object)(object)p.m_placementGhost == (Object)null) { return false; } peca = p.GetSelectedPiece(); if (!EhPlanta(peca)) { return false; } planta = ((Component)peca).GetComponent<Plant>(); return true; } private static void Encaixar(Player p, GameObject fantasma, Piece peca, Plant planta, Vector3 frente, Vector3 direita, float passo) { //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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Invalid comparison between Unknown and I4 //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Invalid comparison between Unknown and I4 //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) Vector3 position = fantasma.transform.position; vizinhos.Clear(); int num = Physics.OverlapSphereNonAlloc(position, passo * 1.6f, vizinhosBuf, Mascara()); for (int i = 0; i < num; i++) { Collider val = vizinhosBuf[i]; if ((Object)(object)val == (Object)null || nossos.Contains(((Component)((Component)val).transform.root).gameObject)) { continue; } Plant componentInParent = ((Component)val).GetComponentInParent<Plant>(); Vector3 position2; float growRadius; if ((Object)(object)componentInParent != (Object)null) { position2 = ((Component)componentInParent).transform.position; growRadius = componentInParent.m_growRadius; } else { Pickable componentInParent2 = ((Component)val).GetComponentInParent<Pickable>(); if ((Object)(object)componentInParent2 == (Object)null || !Catalogo.MudaPorColheita.TryGetValue(Utils.GetPrefabName(((Component)componentInParent2).gameObject), out var value)) { continue; } Plant component = ((Component)value).GetComponent<Plant>(); if ((Object)(object)component == (Object)null) { continue; } position2 = ((Component)componentInParent2).transform.position; growRadius = component.m_growRadius; } if (Mathf.Abs(growRadius - planta.m_growRadius) > 0.01f) { continue; } bool flag = false; foreach (Vector3 vizinho in vizinhos) { Vector3 val2 = vizinho - position2; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { flag = true; break; } } if (!flag) { vizinhos.Add(position2); } } if (vizinhos.Count == 0) { return; } Vector3 pos = default(Vector3); float num2 = passo * 0.75f; bool flag2 = false; foreach (Vector3 vizinho2 in vizinhos) { for (int j = -1; j <= 1; j++) { for (int k = -1; k <= 1; k++) { if (j == 0 && k == 0) { continue; } Vector3 val3 = vizinho2 + frente * ((float)j * passo) + direita * ((float)k * passo); float num3 = Plano(val3 - position); if (num3 >= num2) { continue; } bool flag3 = false; foreach (Vector3 vizinho3 in vizinhos) { if (Plano(val3 - vizinho3) < passo * 0.5f) { flag3 = true; break; } } if (!flag3) { pos = val3; num2 = num3; flag2 = true; } } } } if (flag2) { bool flag4 = VagaBoa(ref pos, peca, planta); fantasma.transform.position = pos; PlacementStatus placementStatus = p.m_placementStatus; if ((int)placementStatus == 0 || (int)placementStatus == 5 || (int)placementStatus == 9) { p.m_placementStatus = (PlacementStatus)((!flag4) ? 5 : 0); p.SetPlacementGhostValid(flag4); } } } private static float Plano(Vector3 v) { v.y = 0f; return ((Vector3)(ref v)).magnitude; } private static bool Ativa(Player p, out Piece peca, out Plant planta) { peca = null; planta = null; if ((Object)(object)p == (Object)null || (Object)(object)p != (Object)(object)Player.m_localPlayer || !((Character)p).InPlaceMode()) { return false; } peca = p.GetSelectedPiece(); if (!EhPlanta(peca)) { return false; } planta = ((Component)peca).GetComponent<Plant>(); if ((Object)(object)p.m_placementGhost != (Object)null) { return LinhasUso * ColunasUso > 1; } return false; } private static KeyCode Par(KeyCode k) { //IL_0000: 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_0024: Expected I4, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) return (KeyCode)((k - 303) switch { 2 => 306, 3 => 305, 0 => 304, 1 => 303, 4 => 308, 5 => 307, _ => k, }); } internal static void LerTeclas(Player p) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) KeyCode value = Plugin.Modificador.Value; KeyCode val = Par(value); if (ZInput.GetKeyDown(value, false)) { presoA = true; } if (ZInput.GetKeyUp(value, false)) { presoA = false; } if (ZInput.GetKeyDown(val, false)) { presoB = true; } if (ZInput.GetKeyUp(val, false)) { presoB = false; } if (EhPlanta(p.GetSelectedPiece()) && (presoA || presoB)) { int num = Sincronia.Valor<int>(Plugin.MaximoPorLado); int num2 = LinhasUso; int num3 = ColunasUso; if (ZInput.GetKeyDown(Plugin.MaisLinhas.Value, false)) { num2++; } if (ZInput.GetKeyDown(Plugin.MenosLinhas.Value, false)) { num2--; } if (ZInput.GetKeyDown(Plugin.MaisColunas.Value, false)) { num3++; } if (ZInput.GetKeyDown(Plugin.MenosColunas.Value, false)) { num3--; } num2 = Mathf.Clamp(num2, 1, num); num3 = Mathf.Clamp(num3, 1, num); if (num2 != Plugin.Linhas.Value || num3 != Plugin.Colunas.Value) { Plugin.Linhas.Value = num2; Plugin.Colunas.Value = num3; Plugin.Mensagem(Texto.Grade(num2, num3)); } } } internal static float Passo(Plant planta) { bool flag = false; if (planta.m_grownPrefabs != null) { GameObject[] grownPrefabs = planta.m_grownPrefabs; foreach (GameObject val in grownPrefabs) { if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponent<TreeBase>() != (Object)null) { flag = true; break; } } } float num = planta.m_growRadius * (flag ? 2.2f : 2f); return Mathf.Max(new float[3] { num, planta.m_growRadiusVines + 0.2f, 0.3f }) + Sincronia.Valor<float>(Plugin.EspacamentoExtra); } private static float Grossura(Piece peca) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) float num = 0.2f; CapsuleCollider component = ((Component)peca).GetComponent<CapsuleCollider>(); if ((Object)(object)component != (Object)null) { num = component.radius * Mathf.Max(((Component)peca).transform.localScale.x, ((Component)peca).transform.localScale.z); } else { SphereCollider component2 = ((Component)peca).GetComponent<SphereCollider>(); if ((Object)(object)component2 != (Object)null) { num = component2.radius; } } return num + 0.05f; } private static void Eixos(Player p, out Vector3 frente, out Vector3 direita) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)GameCamera.instance != (Object)null) ? ((Component)GameCamera.instance).transform.forward : ((Component)p).transform.forward); val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.forward; } float num = Mathf.Atan2(val.x, val.z) * 57.29578f; float num2 = Sincronia.Valor<float>(Plugin.AnguloDaGrade); if (num2 > 0.01f) { num = Mathf.Round(num / num2) * num2; } frente = Quaternion.Euler(0f, num, 0f) * Vector3.forward; direita = Quaternion.Euler(0f, num + 90f, 0f) * Vector3.forward; } internal static bool VagaBoa(ref Vector3 pos, Piece peca, Plant planta) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) float num = default(float); if ((Object)(object)ZoneSystem.instance == (Object)null || !ZoneSystem.instance.GetGroundHeight(pos, ref num)) { return false; } pos.y = num; if (num < ZoneSystem.instance.m_waterLevel) { return false; } if (peca.m_cultivatedGroundOnly) { Heightmap val = Heightmap.FindHeightmap(pos); if ((Object)(object)val == (Object)null || !val.IsCultivated(pos)) { return false; } } if ((int)planta.m_biome != 0 && WorldGenerator.instance != null && (WorldGenerator.instance.GetBiome(pos) & planta.m_biome) == 0) { return false; } if (!PrivateArea.CheckAccess(pos, 0f, false, false)) { return false; } int num2 = Physics.OverlapSphereNonAlloc(pos + Vector3.up * 0.1f, planta.m_growRadius, buffer, Mascara()); for (int i = 0; i < num2; i++) { Collider val2 = buffer[i]; if (!((Object)(object)val2 == (Object)null)) { GameObject gameObject = ((Component)((Component)val2).transform.root).gameObject; if (!nossos.Contains(gameObject)) { return false; } } } float num3 = Grossura(peca); num2 = Physics.OverlapSphereNonAlloc(pos, 3f + num3, buffer, Mascara()); for (int j = 0; j < num2; j++) { Collider val3 = buffer[j]; if (!((Object)(object)val3 == (Object)null) && !nossos.Contains(((Component)((Component)val3).transform.root).gameObject)) { Plant component = ((Component)val3).GetComponent<Plant>(); if (!((Object)(object)component == (Object)null) && Plano(((Component)component).transform.position - pos) < component.m_growRadius + num3) { return false; } } } if (planta.m_growRadiusVines > 0f) { num2 = Physics.OverlapSphereNonAlloc(pos, planta.m_growRadiusVines, buffer, Mascara()); for (int k = 0; k < num2; k++) { if ((Object)(object)buffer[k] != (Object)null && (Object)(object)((Component)buffer[k]).GetComponentInParent<Vine>() != (Object)null) { return false; } } } return true; } private static GameObject Copiar(GameObject fantasma) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)berco == (Object)null) { berco = new GameObject("Bondi berco"); berco.SetActive(false); Object.DontDestroyOnLoad((Object)(object)berco); } bool forceDisableInit = ZNetView.m_forceDisableInit; ZNetView.m_forceDisableInit = true; GameObject val; try { val = Object.Instantiate<GameObject>(fantasma, berco.transform); } finally { ZNetView.m_forceDisableInit = forceDisableInit; } ((Object)val).name = ((Object)fantasma).name + " (grade)"; Plant[] componentsInChildren = val.GetComponentsInChildren<Plant>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } ZNetView[] componentsInChildren2 = val.GetComponentsInChildren<ZNetView>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } MaterialManNotifier[] componentsInChildren3 = val.GetComponentsInChildren<MaterialManNotifier>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } Collider[] componentsInChildren4 = val.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { componentsInChildren4[i].enabled = false; } val.transform.SetParent((Transform)null, false); nossos.Add(val); return val; } internal static void Descarregar() { Limpar(); Marcas.Destruir(); if ((Object)(object)berco != (Object)null) { Object.Destroy((Object)(object)berco); } berco = null; } internal static void Limpar() { foreach (GameObject copia in copias) { if ((Object)(object)copia != (Object)null) { Object.Destroy((Object)(object)copia); } } copias.Clear(); vagas.Clear(); nossos.Clear(); fantasmaBase = null; } } internal static class Marcas { private const float Passo = 0.25f; private static LineRenderer linha; private static Material material; private static bool procurou; private static readonly List<Vector3> pontos = new List<Vector3>(); private static Material Material() { if ((Object)(object)material != (Object)null || procurou) { return material; } procurou = true; try { Material[] array = Resources.FindObjectsOfTypeAll<Material>(); foreach (Material val in array) { if ((Object)(object)val != (Object)null && ((Object)val).name == "Default-Line") { material = val; break; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("contorno sem material: " + ex.Message)); } return material; } private static LineRenderer Linha() { //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_0023: Expected O, but got Unknown if ((Object)(object)linha != (Object)null) { return linha; } GameObject val = new GameObject("Bondi contorno"); Object.DontDestroyOnLoad((Object)val); linha = val.AddComponent<LineRenderer>(); linha.useWorldSpace = true; linha.loop = true; linha.widthMultiplier = 0.09f; linha.numCornerVertices = 3; ((Renderer)linha).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)linha).receiveShadows = false; ((Renderer)linha).sharedMaterial = Material(); return linha; } internal static void Contorno(Vector3 origem, Vector3 frente, Vector3 direita, float passo, int linhas, int colunas, Color cor) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Contorno.Value || (Object)(object)Material() == (Object)null) { Ocultar(); return; } float num = passo * 0.5f; Vector3 val = origem - frente * num - direita * num; Vector3 val2 = origem + frente * ((float)(linhas - 1) * passo + num) - direita * num; Vector3 val3 = origem + frente * ((float)(linhas - 1) * passo + num) + direita * ((float)(colunas - 1) * passo + num); Vector3 val4 = origem - frente * num + direita * ((float)(colunas - 1) * passo + num); pontos.Clear(); Lado(val, val2); Lado(val2, val3); Lado(val3, val4); Lado(val4, val); LineRenderer val5 = Linha(); val5.startColor = cor; val5.endColor = cor; val5.positionCount = pontos.Count; val5.SetPositions(pontos.ToArray()); if (!((Component)val5).gameObject.activeSelf) { ((Component)val5).gameObject.SetActive(true); } } private static void Lado(Vector3 de, Vector3 ate) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) ZoneSystem instance = ZoneSystem.instance; int num = Mathf.Max(1, Mathf.CeilToInt(Vector3.Distance(de, ate) / 0.25f)); float y = default(float); for (int i = 0; i < num; i++) { Vector3 val = Vector3.Lerp(de, ate, (float)i / (float)num); if ((Object)(object)instance != (Object)null && instance.GetGroundHeight(val, ref y)) { val.y = y; } val.y += 0.12f; pontos.Add(val); } } internal static void Ocultar() { if ((Object)(object)linha != (Object)null && ((Component)linha).gameObject.activeSelf) { ((Component)linha).gameObject.SetActive(false); } } internal static void Destruir() { if ((Object)(object)linha != (Object)null) { Object.Destroy((Object)(object)((Component)linha).gameObject); } linha = null; } } public enum RegraItem { Default, Allow, Block } public enum EstiloColheita { SameType, AllAllowed } [BepInPlugin("razaotium.Bondi", "Bóndi", "1.0.0")] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(Player), "UpdateBuildGuiInput")] private static class TeclasNoModoConstrucao { private static void Prefix(Player __instance) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { Grade.LerTeclas(__instance); } } } public const string Guid = "razaotium.Bondi"; public const string Nome = "Bóndi"; public const string Versao = "1.0.0"; internal static Plugin Instancia; private static Harmony harmony; internal static ConfigEntry<int> Linhas; internal static ConfigEntry<int> Colunas; internal static ConfigEntry<int> MaximoPorLado; internal static ConfigEntry<float> EspacamentoExtra; internal static ConfigEntry<float> AnguloDaGrade; internal static ConfigEntry<bool> Encaixe; internal static ConfigEntry<bool> Contorno; internal static ConfigEntry<bool> EsconderInvalidas; internal static ConfigEntry<Color> CorValida; internal static ConfigEntry<Color> CorParcial; internal static ConfigEntry<Color> CorInvalida; internal static ConfigEntry<KeyCode> Modificador; internal static ConfigEntry<KeyCode> MaisLinhas; internal static ConfigEntry<KeyCode> MenosLinhas; internal static ConfigEntry<KeyCode> MaisColunas; internal static ConfigEntry<KeyCode> MenosColunas; internal static ConfigEntry<KeyCode> TeclaColheita; internal static ConfigEntry<bool> ColheitaAtiva; internal static ConfigEntry<bool> MostrarCrescimento; internal static ConfigEntry<float> Raio; internal static ConfigEntry<EstiloColheita> Estilo; private static ConfigFile arquivo; private static readonly Dictionary<string, ConfigEntry<RegraItem>> regras = new Dictionary<string, ConfigEntry<RegraItem>>(); internal static readonly ManualLogSource Log = Logger.CreateLogSource("Bondi"); private void Awake() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Expected O, but got Unknown //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Expected O, but got Unknown Instancia = this; ConfigFile val = (arquivo = ((BaseUnityPlugin)this).Config); Linhas = val.Bind<int>("1 - Grid", "Rows", 2, new ConfigDescription("Grid rows (change in game with Ctrl + up/down).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); Colunas = val.Bind<int>("1 - Grid", "Columns", 2, new ConfigDescription("Grid columns (change in game with Ctrl + right/left).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); MaximoPorLado = val.Bind<int>("1 - Grid", "MaxPerSide", 10, new ConfigDescription("Largest number of rows or columns allowed in game.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); EspacamentoExtra = val.Bind<float>("1 - Grid", "ExtraSpacing", 0f, new ConfigDescription("Metres added to the safe growing space between plants.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>())); AnguloDaGrade = val.Bind<float>("1 - Grid", "GridAngle", 90f, new ConfigDescription("The grid follows the camera, rounded to multiples of this angle. 0 = free.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 90f), Array.Empty<object>())); Encaixe = val.Bind<bool>("1 - Grid", "Snap", true, "The seedling you aim at snaps next to plants already in the ground, with the same spacing."); Contorno = val.Bind<bool>("1 - Grid", "Outline", true, "Line around the grid: green plants everything, yellow plants part of it, red can't plant."); EsconderInvalidas = val.Bind<bool>("1 - Grid", "HideInvalid", true, "Hide the spots that can't be planted: what you see is what gets planted."); CorValida = val.Bind<Color>("1 - Grid", "ColorValid", new Color(0.2f, 1f, 0.25f, 1f), "Outline colour when everything will be planted."); CorParcial = val.Bind<Color>("1 - Grid", "ColorPartial", new Color(1f, 0.85f, 0.1f, 1f), "Outline colour when only part of the grid will be planted."); CorInvalida = val.Bind<Color>("1 - Grid", "ColorInvalid", new Color(1f, 0.15f, 0.1f, 1f), "Outline colour when the seedling you aim at can't be planted."); Modificador = val.Bind<KeyCode>("2 - Keys", "Modifier", (KeyCode)305, "Hold to resize the grid (either side of the keyboard works)."); MaisLinhas = val.Bind<KeyCode>("2 - Keys", "MoreRows", (KeyCode)273, ""); MenosLinhas = val.Bind<KeyCode>("2 - Keys", "FewerRows", (KeyCode)274, ""); MaisColunas = val.Bind<KeyCode>("2 - Keys", "MoreColumns", (KeyCode)275, ""); MenosColunas = val.Bind<KeyCode>("2 - Keys", "FewerColumns", (KeyCode)276, ""); TeclaColheita = val.Bind<KeyCode>("2 - Keys", "AreaHarvest", (KeyCode)304, "Hold while interacting to harvest the whole area."); MostrarCrescimento = val.Bind<bool>("3 - Harvest", "ShowGrowth", true, "Show on the seedling how much it has grown and how long is left."); ColheitaAtiva = val.Bind<bool>("3 - Harvest", "Enabled", true, "Enable area harvest."); Raio = val.Bind<float>("3 - Harvest", "Radius", 50f, new ConfigDescription("Area harvest radius in metres (the game keeps about 60 m loaded around you).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>())); Estilo = val.Bind<EstiloColheita>("3 - Harvest", "Style", EstiloColheita.SameType, "SameType: only the item you clicked. AllAllowed: every allowed item in the radius."); ConfigEntryBase[] array = (ConfigEntryBase[])(object)new ConfigEntryBase[7] { (ConfigEntryBase)MaximoPorLado, (ConfigEntryBase)EspacamentoExtra, (ConfigEntryBase)AnguloDaGrade, (ConfigEntryBase)MostrarCrescimento, (ConfigEntryBase)ColheitaAtiva, (ConfigEntryBase)Raio, (ConfigEntryBase)Estilo }; for (int i = 0; i < array.Length; i++) { Sincronia.Sincronizar(array[i]); } Sincronia.Escutar(val); harmony = new Harmony("razaotium.Bondi"); harmony.PatchAll(); if ((Object)(object)ZNetScene.instance != (Object)null) { Catalogo.Montar(ZNetScene.instance); Registro.Preencher(); } } internal static void Rodar(IEnumerator rotina) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { ((MonoBehaviour)localPlayer).StartCoroutine(rotina); } } private void OnDestroy() { Grade.Descarregar(); Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } internal static void CriarRegrasDeItens(IEnumerable<string> itens) { if (arquivo == null) { return; } foreach (string item in itens.Distinct().OrderBy<string, string>((string n) => n, StringComparer.Ordinal)) { if (!regras.ContainsKey(item)) { regras[item] = arquivo.Bind<RegraItem>("4 - Items", item, RegraItem.Default, "Default: area harvest if it is a crop or honey. Allow / Block: your choice."); Sincronia.Sincronizar((ConfigEntryBase)(object)regras[item]); } } } internal static RegraItem RegraDe(string item) { if (item == null || !regras.TryGetValue(item, out var value)) { return RegraItem.Default; } return Sincronia.Valor<RegraItem>(value); } internal static void Mensagem(string texto) { if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)1, texto, 0, (Sprite)null, false, false); } } } internal static class Sincronia { [HarmonyPatch(typeof(ZNet), "Awake")] private static class Registrar { private static void Postfix() { recebido = false; doServidor.Clear(); convertidos.Clear(); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.Register<ZPackage>("Bondi_Config", (Action<long, ZPackage>)Receber); } } } [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] private static class AoEntrarJogador { private static void Postfix(ZNet __instance, ZRpc rpc) { if (__instance.IsServer()) { ZNetPeer peer = __instance.GetPeer(rpc); if (peer != null && ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "Bondi_Config", new object[1] { Pacote() }); } } } } [HarmonyPatch(typeof(ZNet), "OnDestroy")] private static class AoSair { private static void Postfix() { recebido = false; doServidor.Clear(); convertidos.Clear(); } } private const string Rpc = "Bondi_Config"; private static readonly List<ConfigEntryBase> sincronizadas = new List<ConfigEntryBase>(); private static readonly Dictionary<string, string> doServidor = new Dictionary<string, string>(); private static readonly Dictionary<string, object> convertidos = new Dictionary<string, object>(); private static bool recebido; private static bool UsaServidor { get { if (recebido && (Object)(object)ZNet.instance != (Object)null) { return !ZNet.instance.IsServer(); } return false; } } internal static bool DoServidor => UsaServidor; internal static bool ColheitaAtiva => Valor<bool>(Plugin.ColheitaAtiva); internal static float Raio => Mathf.Clamp(Valor<float>(Plugin.Raio), 1f, 100f); private static string Chave(ConfigEntryBase e) { return e.Definition.Section + "/" + e.Definition.Key; } internal static void Sincronizar(ConfigEntryBase e) { sincronizadas.Add(e); } internal static void Escutar(ConfigFile arquivo) { arquivo.SettingChanged += delegate(object _, SettingChangedEventArgs ev) { if (sincronizadas.Contains(ev.ChangedSetting)) { EnviarParaTodos(); } }; } internal static T Valor<T>(ConfigEntry<T> e) { if (!UsaServidor) { return e.Value; } string key = Chave((ConfigEntryBase)(object)e); if (!doServidor.TryGetValue(key, out var value)) { return e.Value; } if (!convertidos.TryGetValue(key, out var value2)) { try { value2 = TomlTypeConverter.ConvertToValue(value, typeof(T)); } catch { value2 = e.Value; } convertidos[key] = value2; } return (T)value2; } private static ZPackage Pacote() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(sincronizadas.Count); foreach (ConfigEntryBase sincronizada in sincronizadas) { val.Write(Chave(sincronizada)); val.Write(sincronizada.GetSerializedValue()); } return val; } private static void Receber(long remetente, ZPackage p) { if (!((Object)(object)ZNet.instance == (Object)null) && !ZNet.instance.IsServer() && (ZRoutedRpc.instance == null || remetente == ZRoutedRpc.instance.GetServerPeerID())) { doServidor.Clear(); convertidos.Clear(); int num = p.ReadInt(); for (int i = 0; i < num; i++) { doServidor[p.ReadString()] = p.ReadString(); } recebido = true; Plugin.Log.LogInfo((object)$"regras do servidor recebidas ({num})"); } } internal static void EnviarParaTodos() { if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer() && ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(0L, "Bondi_Config", new object[1] { Pacote() }); } } } internal static class Texto { private static bool Portugues { get { if (Localization.instance != null) { return Localization.instance.GetSelectedLanguage().StartsWith("Portuguese", StringComparison.OrdinalIgnoreCase); } return false; } } internal static string ColherEmArea => T("Harvest area", "Colher em área"); internal static string Pronta => T("Ready to grow", "Pronta para crescer"); internal static string Sementes => T("seeds", "sementes"); internal static string Estamina => T("stamina", "estamina"); internal static string Durabilidade => T("durability", "durabilidade"); private static string T(string en, string pt) { if (!Portugues) { return en; } return pt; } internal static string Grade(int l, int c) { return T($"Grid: {l} × {c}", $"Grade: {l} × {c}"); } internal static string Crescendo(int pct, string falta) { return T($"Growing: {pct}% ({falta} left)", $"Crescendo: {pct}% (faltam {falta})"); } internal static string Plantadas(int feitas, int total, string falta) { return T($"Planted {feitas} of {total}: not enough {falta}", $"Plantadas {feitas} de {total}: faltou {falta}"); } } }