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 MapBuildings v0.2.0
plugins/MapBuildings/MapBuildings.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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 Blackforge.Hot; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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 Blackforge { public static class Built { private class Zone { public byte[] data; public int hash; public float at; public ZDOID groundId; public uint groundRevision; public byte[] ground; } private class Tile { public int hash; public byte[] data; public int pieces; public int photoOnServer; public byte[] photo; public int photoHere; public float photoAskedAt = -1000f; public int shot; public Texture2D texture; public RawImage image; public bool stale; public bool hidden; } private const string Ask = "bf_built_ask"; private const string Answer = "bf_built"; private const string Shot = "bf_built_shot"; private const string PhotoAsk = "bf_built_photo_ask"; private const string Photos = "bf_built_photo"; private static readonly string[] RpcNames = new string[5] { "bf_built_ask", "bf_built", "bf_built_shot", "bf_built_photo_ask", "bf_built_photo" }; private const byte Wood = 0; private const byte Stone = 1; private const byte Iron = 2; private const byte Marble = 3; private const byte Lowered = 1; private const byte WithRoofs = 0; private const byte NoRoofs = 1; private const int ZoneSize = 64; private const int Cells = 64; private const int Spots = 128; private const int PhotoSize = 256; private const int Edge = 170; private const float InsideFrom = 3000f; private static HotHost host; private static ManualLogSource log; private static readonly string[] Shown = new string[2] { "wall", "roof" }; private static readonly string[] Hidden = new string[4] { "log", "pole", "beam", "torch" }; private const string Block = "blackmarble_"; private static readonly string[] Furnaces = new string[3] { "smelter", "blastfurnace", "charcoal_kiln" }; private const string Rail = "bf_"; private static readonly int RailBuilt = StringExtensionMethods.GetStableHashCode("bf_built"); private const string Pole = "pole"; private static readonly int Ground = StringExtensionMethods.GetStableHashCode("_TerrainCompiler"); private static Dictionary<int, byte> kinds; private static HashSet<int> placed; private static readonly List<ZDO> objects = new List<ZDO>(); private static readonly HashSet<SectorIndex> seen = new HashSet<SectorIndex>(); private static Dictionary<int, (Vector3 offset, float radius)> bases; private static int reach = 1; private const int Look = 59; private const float ZoneAge = 20f; private const float Deep = 2f; private const int AnswerBytes = 200000; private const int PhotoAnswerBytes = 400000; private const int MostPhotoBytes = 400000; private const float ShotWithin = 300f; private static readonly Dictionary<Vector2s, Zone> zones = new Dictionary<Vector2s, Zone>(); private const float SpawnOver = 0.5f; private static readonly Dictionary<Vector2s, (float at, List<(float x, float z, float radius)> list)> covers = new Dictionary<Vector2s, (float, List<(float, float, float)>)>(); private static readonly List<(float x, float z, float radius)> circles = new List<(float, float, float)>(); private static Dictionary<Vector2s, int> stored; private static string folder; private static readonly byte[] spots = new byte[16384]; private static bool said; private const string ShowKey = "bf_map_built"; private const string RoofsKey = "bf_map_roofs"; private const string SafeKey = "bf_map_safe"; private const float AskEvery = 30f; private const float AskSoon = 1f; private const int BakesAFrame = 6; private const int MostTiles = 800; private const float ClosestZoom = 0.0025f; private const float PhotoFrom = 40f; private const float PhotoAskEvery = 5f; private const int PhotosAnAsk = 24; private const float ShotCheckEvery = 10f; private static readonly Color32[] Materials = (Color32[])(object)new Color32[4] { new Color32((byte)150, (byte)95, (byte)40, byte.MaxValue), new Color32((byte)200, (byte)200, (byte)200, byte.MaxValue), new Color32((byte)80, (byte)120, (byte)170, byte.MaxValue), new Color32((byte)30, (byte)25, (byte)40, byte.MaxValue) }; private static readonly Color32 Trench = new Color32((byte)60, (byte)38, (byte)20, (byte)220); private static readonly Color32 DefaultTint = new Color32((byte)170, (byte)120, byte.MaxValue, (byte)70); private static readonly Color32 DefaultLine = new Color32((byte)200, (byte)160, byte.MaxValue, (byte)230); private const float SafeLineWide = 1f; private static readonly Dictionary<Vector2s, Tile> tiles = new Dictionary<Vector2s, Tile>(); private static readonly Color32[] pixels = (Color32[])(object)new Color32[16384]; private static readonly float[] depth = new float[16384]; private static readonly List<Vector2s> wanted = new List<Vector2s>(); private static RectTransform root; private static MapMode mode = (MapMode)0; private static float askedAt = -1000f; private static float photosAskedAt = -1000f; private static float shotCheckedAt; private static (int, int, int, int) asked; private static bool more; private static float zoomOfGame; private static ConfigEntry<bool> showEntry; private static ConfigEntry<bool> roofsEntry; private static ConfigEntry<bool> safeEntry; private static ConfigEntry<bool> smallMap; private static ConfigEntry<bool> closerZoom; private static ConfigEntry<Color> tintEntry; private static ConfigEntry<Color> lineEntry; private static ConfigEntry<bool> showRow; private static ConfigEntry<bool> roofsRow; private static ConfigEntry<bool> safeRow; private static ConfigEntry<float> rowsRight; private static ConfigEntry<float> rowsUp; private const float LensHeight = 1500f; private static readonly Color Ambient = new Color(0.9f, 0.9f, 0.9f); private const float SunStrength = 1.6f; private static readonly int SunDir = Shader.PropertyToID("_SunDir"); private static readonly int SunColor = Shader.PropertyToID("_SunColor"); private static readonly int AmbientColor = Shader.PropertyToID("_AmbientColor"); private static readonly int Wet = Shader.PropertyToID("_Wet"); private static Camera lens; private static Texture2D film; internal static bool Show { get; private set; } = true; internal static bool Roofs { get; private set; } = true; internal static bool Safe { get; private set; } = true; private static Color32 SafeTint => Color32.op_Implicit(tintEntry.Value); private static Color32 SafeLine => Color32.op_Implicit(lineEntry.Value); private static bool SmallMap => smallMap.Value; private static bool CloserZoom => closerZoom.Value; public static void Load(HotHost from) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Expected O, but got Unknown host = from; log = from.Log; host.Harmony.Patch((MethodBase)AccessTools.Method(typeof(Game), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Built), "Register", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); if (!host.IsDedicatedServer) { Show = showEntry.Value; Roofs = roofsEntry.Value; Safe = safeEntry.Value; Func<Vector2> offset = () => new Vector2(rowsRight.Value, rowsUp.Value); MapSwitches.Add(3, "Buildings", "Hammer", () => Show, SetShow, () => showRow.Value, offset); MapSwitches.Add(4, "Roofs", "Wood", () => Roofs, SetRoofs, () => roofsRow.Value, offset); MapSwitches.Add(5, "No spawns", "ShieldWood", () => Safe, SetSafe, () => safeRow.Value, offset); host.Harmony.Patch((MethodBase)AccessTools.Method(typeof(Minimap), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Built), "MapTick", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (ZRoutedRpc.instance != null) { Register(); } } public static void Unload() { MapSwitches.Clear(); DropTiles(); if ((Object)(object)Minimap.instance != (Object)null && zoomOfGame > 0f) { Minimap.instance.m_minZoom = zoomOfGame; } zoomOfGame = 0f; if ((Object)(object)root != (Object)null) { Object.Destroy((Object)(object)((Component)root).gameObject); } root = null; if ((Object)(object)lens != (Object)null) { Object.Destroy((Object)(object)((Component)lens).gameObject); } lens = null; if ((Object)(object)film != (Object)null) { Object.Destroy((Object)(object)film); } film = null; host?.UnregisterRpc(RpcNames); zones.Clear(); covers.Clear(); stored = null; kinds = null; placed = null; bases = null; host = null; } private static void Register() { if (host != null && ZRoutedRpc.instance != null && !((Object)(object)ZNet.instance == (Object)null)) { host.UnregisterRpc(RpcNames); if (ZNet.instance.IsServer()) { ZRoutedRpc.instance.Register<ZPackage>("bf_built_ask", (Action<long, ZPackage>)OnAsk); ZRoutedRpc.instance.Register<ZPackage>("bf_built_shot", (Action<long, ZPackage>)OnShot); ZRoutedRpc.instance.Register<ZPackage>("bf_built_photo_ask", (Action<long, ZPackage>)OnPhotoAsk); } if (!host.IsDedicatedServer) { ZRoutedRpc.instance.Register<ZPackage>("bf_built", (Action<long, ZPackage>)OnAnswer); ZRoutedRpc.instance.Register<ZPackage>("bf_built_photo", (Action<long, ZPackage>)OnPhotos); } zones.Clear(); covers.Clear(); stored = null; DropTiles(); askedAt = -1000f; said = false; } } private static void Kinds() { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected I4, but got Unknown kinds = new Dictionary<int, byte>(); placed = new HashSet<int>(); foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if ((Object)(object)prefab == (Object)null || (Object)(object)prefab.GetComponent<Piece>() == (Object)null) { continue; } int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)prefab).name); if ((Object)(object)prefab.GetComponentInChildren<Ship>(true) == (Object)null && (Object)(object)prefab.GetComponentInChildren<Vagon>(true) == (Object)null && (Object)(object)prefab.GetComponentInChildren<Plant>(true) == (Object)null && !((Object)prefab).name.StartsWith("bf_") && !((Object)prefab).name.ToLowerInvariant().Contains("pole")) { placed.Add(stableHashCode); } if (!Marked(((Object)prefab).name.ToLowerInvariant())) { continue; } WearNTear component = prefab.GetComponent<WearNTear>(); byte value = 0; if ((Object)(object)component != (Object)null) { MaterialType materialType = component.m_materialType; switch (materialType - 1) { case 0: case 4: case 6: value = 1; break; case 1: value = 2; break; case 3: value = 3; break; } } kinds[stableHashCode] = value; } if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { log.LogInfo((object)string.Format("built: {0} kinds of pieces count for a photo, {1} get a mark: {2}", placed.Count, kinds.Count, string.Join(", ", from hash in kinds.Keys select ((Object)ZNetScene.instance.GetPrefab(hash)).name into name orderby name select name))); } } private static void Bases() { //IL_0062: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) bases = new Dictionary<int, (Vector3, float)>(); List<string> list = new List<string>(); List<string> list2 = new List<string>(); float num = 0f; foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if ((Object)(object)prefab == (Object)null) { continue; } EffectArea[] componentsInChildren = prefab.GetComponentsInChildren<EffectArea>(true); foreach (EffectArea val in componentsInChildren) { if ((val.m_type & 4) == 0) { continue; } Collider component = ((Component)val).GetComponent<Collider>(); Vector3 lossyScale = ((Component)val).transform.lossyScale; float num2 = Mathf.Max(new float[3] { Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.y), Mathf.Abs(lossyScale.z) }); SphereCollider val2 = (SphereCollider)(object)((component is SphereCollider) ? component : null); float num3; Vector3 center; if (val2 != null) { num3 = val2.radius * num2; center = val2.center; } else { CapsuleCollider val3 = (CapsuleCollider)(object)((component is CapsuleCollider) ? component : null); if (val3 == null) { list2.Add(((Object)prefab).name + " with no sphere"); continue; } num3 = val3.radius * num2; center = val3.center; } bool flag = false; Transform val4 = ((Component)val).transform; while ((Object)(object)val4 != (Object)(object)prefab.transform) { flag |= !((Component)val4).gameObject.activeSelf; val4 = val4.parent; } if (flag) { list2.Add(((Object)prefab).name + " with its area off"); continue; } int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)prefab).name); if (!bases.TryGetValue(stableHashCode, out (Vector3, float) value) || !(value.Item2 >= num3)) { bases[stableHashCode] = (prefab.transform.InverseTransformPoint(((Component)val).transform.TransformPoint(center)), num3); num = Mathf.Max(num, num3); list.Add($"{((Object)prefab).name} {num3:0.#} m"); } } } reach = Mathf.Clamp(Mathf.CeilToInt(num / 64f), 1, 2); if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { list.Sort(); log.LogInfo((object)string.Format("built: no mob spawns round {0} kinds of pieces: {1}. Left out: {2}", bases.Count, string.Join(", ", list), (list2.Count == 0) ? "none" : string.Join(", ", list2))); } } private static bool Marked(string name) { if (Furnaces.Contains(name)) { return true; } if (Hidden.Any(name.Contains)) { return false; } if (!Shown.Any(name.Contains)) { if (name.StartsWith("blackmarble_") && name.Length > "blackmarble_".Length) { return char.IsDigit(name["blackmarble_".Length]); } return false; } return true; } private static bool Placed(ZDO zdo) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (placed.Contains(zdo.GetPrefab()) && zdo.GetLong(ZDOVars.s_creator, 0L) != 0L && zdo.GetPosition().y < 3000f) { return !zdo.GetBool(RailBuilt, false); } return false; } private static int Mix(int sum, ZDOID id) { long userID = ((ZDOID)(ref id)).UserID; return sum + (int)(userID ^ (userID >> 32)) * 59 + (int)((ZDOID)(ref id)).ID; } private static void Stored() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) stored = new Dictionary<Vector2s, int>(); string path = string.Concat(from letter in ZNet.instance.GetWorldName() select (!char.IsLetterOrDigit(letter)) ? '_' : letter); folder = Path.Combine(Paths.BepInExRootPath, "blackforge-built", path); Directory.CreateDirectory(folder); string[] files = Directory.GetFiles(folder, "*.bin"); Vector2s key = default(Vector2s); foreach (string text in files) { try { string[] array = Path.GetFileNameWithoutExtension(text).Split('_'); ((Vector2s)(ref key))..ctor(int.Parse(array[0]), int.Parse(array[1])); ZPackage val = new ZPackage(File.ReadAllBytes(text)); if (val.ReadInt() != 59) { File.Delete(text); } else { stored[key] = val.ReadInt(); } } catch (Exception ex) { log.LogWarning((object)("built: the photo file " + text + " could not be read: " + ex.Message)); } } log.LogInfo((object)$"built: {stored.Count} zones have a photo in {folder}"); } private static string FileOf(Vector2s at) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) return Path.Combine(folder, $"{at.x}_{at.y}.bin"); } private static bool Ready() { if (host == null || ZDOMan.instance == null || (Object)(object)ZNetScene.instance == (Object)null || (Object)(object)ZNet.instance == (Object)null) { return false; } if (kinds == null) { Kinds(); } if (bases == null) { Bases(); } if (stored == null) { Stored(); } return true; } private static void OnAsk(long sender, ZPackage package) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: 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_025b: 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_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0272: 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: Expected O, but got Unknown try { if (!Ready()) { return; } int num = Mathf.Max(package.ReadInt(), -170); int num2 = Mathf.Max(package.ReadInt(), -170); int num3 = Mathf.Min(package.ReadInt(), 170); int num4 = Mathf.Min(package.ReadInt(), 170); Dictionary<Vector2s, int> dictionary = new Dictionary<Vector2s, int>(); int num5 = package.ReadInt(); for (int i = 0; i < num5; i++) { int num6 = package.ReadInt(); int num7 = package.ReadInt(); dictionary[new Vector2s(num6, num7)] = package.ReadInt(); } float num8 = (float)(num + num3) / 2f; float num9 = (float)(num2 + num4) / 2f; List<(float, Vector2s, Zone)> list = new List<(float, Vector2s, Zone)>(); List<Vector2s> list2 = new List<Vector2s>(); Vector2s val = default(Vector2s); for (int j = num2; j <= num4; j++) { for (int k = num; k <= num3; k++) { ((Vector2s)(ref val))..ctor(k, j); Zone zone = Read(val); int value; bool flag = dictionary.TryGetValue(val, out value); if (zone.data == null) { if (flag) { list2.Add(val); } } else if (!flag || value != zone.hash) { list.Add((((float)k - num8) * ((float)k - num8) + ((float)j - num9) * ((float)j - num9), val, zone)); } } } list.Sort(((float far, Vector2s at, Zone zone) a, (float far, Vector2s at, Zone zone) b) => a.far.CompareTo(b.far)); ZPackage val2 = new ZPackage(); int num10 = 0; int num11 = 0; for (; num10 < list.Count; num10++) { if (num11 >= 200000) { break; } num11 += list[num10].Item3.data.Length; } val2.Write(num10); for (int num12 = 0; num12 < num10; num12++) { val2.Write((int)list[num12].Item2.x); val2.Write((int)list[num12].Item2.y); val2.Write(list[num12].Item3.hash); val2.Write(list[num12].Item3.data); } val2.Write(list2.Count); foreach (Vector2s item in list2) { val2.Write((int)item.x); val2.Write((int)item.y); } val2.Write(num10 < list.Count); ZPackage val3 = new ZPackage(); val3.Write(Utils.Compress(val2.GetArray())); ZRoutedRpc.instance.InvokeRoutedRPC(sender, "bf_built", new object[1] { val3 }); if (!said && num10 > 0) { said = true; log.LogInfo((object)$"built: the first answer has {num10} of {list.Count} zones with something built, {num11} bytes"); } } catch (Exception arg) { log.LogError((object)$"built: the answer failed: {arg}"); } } private static List<(float x, float z, float radius)> BasesOf(Vector2s at) { //IL_000b: 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_0089: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_00c2: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) float realtimeSinceStartup = Time.realtimeSinceStartup; if (covers.TryGetValue(at, out (float, List<(float, float, float)>) value) && realtimeSinceStartup - value.Item1 < 20f) { return value.Item2; } objects.Clear(); seen.Clear(); ZDOMan.instance.FindObjects(at, objects, seen); List<(float, float, float)> list = null; foreach (ZDO @object in objects) { if (!bases.TryGetValue(@object.GetPrefab(), out (Vector3, float) value2)) { continue; } Vector3 val = @object.GetPosition() + @object.GetRotation() * value2.Item1; if (val.y >= 3000f) { continue; } float num = val.y - (WorldGenerator.instance.GetHeight(val.x, val.z) + 0.5f); float num2 = value2.Item2 * value2.Item2 - num * num; if (!(num2 <= 0f)) { if (list == null) { list = new List<(float, float, float)>(); } list.Add((val.x, val.z, Mathf.Sqrt(num2))); } } covers[at] = (realtimeSinceStartup, list); return list; } private static Zone Read(Vector2s at) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0360: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Expected O, but got Unknown //IL_0171: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: 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) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) float realtimeSinceStartup = Time.realtimeSinceStartup; if (zones.TryGetValue(at, out var value)) { if (realtimeSinceStartup - value.at < 20f) { return value; } } else { value = new Zone(); zones[at] = value; } value.at = realtimeSinceStartup; Vector3 zonePos = ZoneSystem.GetZonePos(at); float num = zonePos.x - 32f; float num2 = zonePos.z - 32f; circles.Clear(); for (int i = -reach; i <= reach; i++) { for (int j = -reach; j <= reach; j++) { List<(float, float, float)> list = BasesOf(new Vector2s(at.x + j, at.y + i)); if (list == null) { continue; } foreach (var item in list) { if (item.Item1 + item.Item3 > num && item.Item1 - item.Item3 < num + 64f && item.Item2 + item.Item3 > num2 && item.Item2 - item.Item3 < num2 + 64f) { circles.Add(item); } } } } objects.Clear(); seen.Clear(); ZDOMan.instance.FindObjects(at, objects, seen); int num3 = 0; int num4 = 0; int num5 = 0; ZDO val = null; foreach (ZDO @object in objects) { int prefab = @object.GetPrefab(); if (prefab == Ground) { val = @object; } else { if (!Placed(@object)) { continue; } num4++; num5 = Mix(num5, @object.m_uid); if (kinds.TryGetValue(prefab, out var value2)) { if (num3 == 0) { Array.Clear(spots, 0, spots.Length); } Vector3 position = @object.GetPosition(); int num6 = Mathf.Clamp((int)((position.x - num) * 2f), 0, 127); int num7 = Mathf.Clamp((int)((position.z - num2) * 2f), 0, 127); if (spots[num7 * 128 + num6] == 0) { num3++; } spots[num7 * 128 + num6] = (byte)Mathf.Max((int)spots[num7 * 128 + num6], value2 + 1); } } } if (val == null) { value.ground = null; value.groundId = ZDOID.None; } else if (value.groundId != val.m_uid || value.groundRevision != val.DataRevision) { value.groundId = val.m_uid; value.groundRevision = val.DataRevision; value.ground = GroundOf(val); } int num8 = ((num4 != 0) ? ((num5 == 0) ? 1 : num5) : 0); if (stored.TryGetValue(at, out var value3) && num4 == 0) { stored.Remove(at); value3 = 0; try { File.Delete(FileOf(at)); } catch (Exception ex) { log.LogWarning((object)$"built: the photo of the zone {at.x} {at.y} could not be deleted: {ex.Message}"); } } if (num4 == 0 && value.ground == null && circles.Count == 0) { value.data = null; value.hash = 0; return value; } ZPackage val2 = new ZPackage(); val2.Write(num8); val2.Write(value3); val2.Write(num3); int num9 = 0; while (num3 > 0 && num9 < spots.Length) { if (spots[num9] != 0) { val2.Write((byte)(num9 % 128)); val2.Write((byte)(num9 / 128)); val2.Write((byte)(spots[num9] - 1)); } num9++; } val2.Write(value.ground != null); if (value.ground != null) { val2.Write(value.ground); } val2.Write(circles.Count); foreach (var circle in circles) { val2.Write(circle.x - num); val2.Write(circle.z - num2); val2.Write(circle.radius); } value.data = val2.GetArray(); value.hash = Hash(value.data); return value; } private static byte[] GroundOf(ZDO zdo) { //IL_011d: 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_0028: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) try { byte[] byteArray = zdo.GetByteArray(ZDOVars.s_TCData, (byte[])null); if (byteArray == null || byteArray.Length == 0) { return null; } ZPackage val = new ZPackage(Utils.Decompress(byteArray)); val.ReadInt(); val.ReadInt(); val.ReadVector3(); val.ReadSingle(); int num = 65; int num2 = val.ReadInt(); if (num2 != num * num) { return null; } byte[] array = new byte[4096]; bool flag = false; for (int i = 0; i < num2; i++) { if (val.ReadBool()) { float num3 = val.ReadSingle() + val.ReadSingle(); int num4 = i % num; int num5 = i / num; if (num4 < 64 && num5 < 64 && num3 < -2f) { array[num5 * 64 + num4] = 1; flag = true; } } } if (!flag) { return null; } byte[] array2 = new byte[1024]; for (int j = 0; j < array.Length; j++) { array2[j / 4] |= (byte)(array[j] << j % 4 * 2); } return array2; } catch (Exception ex) { log.LogWarning((object)$"built: the ground at {zdo.GetPosition()} could not be read: {ex.Message}"); return null; } } private static int Hash(byte[] data) { uint num = 2166136261u; foreach (byte b in data) { num = (num ^ b) * 16777619; } if (num != 0) { return (int)num; } return 1; } private static void OnShot(long sender, ZPackage package) { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_008e: Unknown result type (might be due to invalid IL or missing references) try { if (!Ready()) { return; } int num = package.ReadInt(); int num2 = package.ReadInt(); int num3 = package.ReadInt(); byte[] array = package.ReadByteArray(); byte[] array2 = package.ReadByteArray(); Vector2s val = default(Vector2s); ((Vector2s)(ref val))..ctor(num, num2); ZNetPeer peer = ZNet.instance.GetPeer(sender); if (Mathf.Abs(num) > 170 || Mathf.Abs(num2) > 170 || num3 == 0 || array.Length == 0 || array2.Length == 0 || array.Length > 400000 || array2.Length > 400000 || (peer != null && Utils.DistanceXZ(peer.m_refPos, ZoneSystem.GetZonePos(val)) > 300f)) { log.LogWarning((object)$"built: a photo of the zone {num} {num2} from {peer?.m_playerName} is refused"); return; } ZPackage val2 = new ZPackage(); val2.Write(59); val2.Write(num3); val2.Write(array); val2.Write(array2); File.WriteAllBytes(FileOf(val), val2.GetArray()); stored[val] = num3; if (zones.TryGetValue(val, out var value)) { value.at = -1000f; } log.LogInfo((object)$"built: a photo of the zone {num} {num2} came from {peer?.m_playerName}, {array.Length} and {array2.Length} bytes"); } catch (Exception arg) { log.LogError((object)$"built: a photo could not be kept: {arg}"); } } private static void OnPhotoAsk(long sender, ZPackage package) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) try { if (!Ready()) { return; } byte b = package.ReadByte(); int num = Mathf.Min(package.ReadInt(), 64); ZPackage val = new ZPackage(); List<(Vector2s, int, byte[])> list = new List<(Vector2s, int, byte[])>(); int num2 = 0; Vector2s val2 = default(Vector2s); for (int i = 0; i < num; i++) { if (num2 >= 400000) { break; } int num3 = package.ReadInt(); int num4 = package.ReadInt(); ((Vector2s)(ref val2))..ctor(num3, num4); if (stored.ContainsKey(val2)) { ZPackage val3 = new ZPackage(File.ReadAllBytes(FileOf(val2))); val3.ReadInt(); int item = val3.ReadInt(); byte[] array = val3.ReadByteArray(); byte[] array2 = val3.ReadByteArray(); byte[] array3 = ((b == 1) ? array2 : array); num2 += array3.Length; list.Add((val2, item, array3)); } } val.Write(b); val.Write(list.Count); foreach (var (val4, num5, array4) in list) { val.Write((int)val4.x); val.Write((int)val4.y); val.Write(num5); val.Write(array4); } ZRoutedRpc.instance.InvokeRoutedRPC(sender, "bf_built_photo", new object[1] { val }); } catch (Exception arg) { log.LogError((object)$"built: the photos could not be sent: {arg}"); } } public static void Bind(ConfigFile config) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown showEntry = config.Bind<bool>("Map", "Buildings", true, "The buildings show on the map. The switch Buildings on the big map changes it too."); roofsEntry = config.Bind<bool>("Map", "Roofs", true, "The photos show the roofs. Off, you see the inside of a house. The switch Roofs on the big map changes it too."); safeEntry = config.Bind<bool>("Map", "NoSpawns", true, "The ground where no mob spawns, round workbenches, fires and other pieces, shows in color. The switch No spawns on the big map changes it too."); smallMap = config.Bind<bool>("Map", "SmallMap", true, "The buildings show on the small map in the corner too. Off, they show only on the big map."); closerZoom = config.Bind<bool>("Map", "CloserZoom", true, "The map zooms 4 times closer than the game allows. Off, the zoom of the game counts, or the one of another mod."); tintEntry = config.Bind<Color>("Map", "NoSpawnsColor", Color32.op_Implicit(DefaultTint), "The color of the ground where no mob spawns. The last 2 digits are its strength, 00 is clear and FF hides the map under it."); lineEntry = config.Bind<Color>("Map", "NoSpawnsLineColor", Color32.op_Implicit(DefaultLine), "The color of the line round the ground where no mob spawns. The last 2 digits are its strength, 00 is clear and FF hides the map under it."); showRow = config.Bind<bool>("Switches", "ShowBuildings", true, "The switch Buildings shows on the big map. Hidden, the map keeps the value of Buildings."); roofsRow = config.Bind<bool>("Switches", "ShowRoofs", true, "The switch Roofs shows on the big map. Hidden, the map keeps the value of Roofs."); safeRow = config.Bind<bool>("Switches", "ShowNoSpawns", true, "The switch No spawns shows on the big map. Hidden, the map keeps the value of NoSpawns."); rowsRight = config.Bind<float>("Switches", "MoveRight", 0f, new ConfigDescription("Moves the switches of this mod on the big map to the right, under 0 to the left. 1 row of switches is 51 high.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2000f, 2000f), Array.Empty<object>())); rowsUp = config.Bind<float>("Switches", "MoveUp", 0f, new ConfigDescription("Moves the switches of this mod on the big map up, under 0 down. 1 row of switches is 51 high.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2000f, 2000f), Array.Empty<object>())); config.SettingChanged += OnSetting; } private static void OnSetting(object sender, SettingChangedEventArgs change) { if (Show != showEntry.Value) { SetShow(showEntry.Value); } if (Roofs != roofsEntry.Value) { SetRoofs(roofsEntry.Value); } if (Safe != safeEntry.Value) { SetSafe(safeEntry.Value); } if ((object)change.ChangedSetting != tintEntry && (object)change.ChangedSetting != lineEntry) { return; } foreach (Tile value in tiles.Values) { value.stale = true; } } internal static void SetShow(bool on) { Show = on; showEntry.Value = on; } internal static void SetRoofs(bool on) { Roofs = on; roofsEntry.Value = on; foreach (Tile value in tiles.Values) { value.photo = null; value.photoHere = 0; value.photoAskedAt = -1000f; value.stale = true; } } internal static void SetSafe(bool on) { Safe = on; safeEntry.Value = on; foreach (Tile value in tiles.Values) { value.stale = true; } } private static void OnAnswer(long sender, ZPackage packed) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) try { ZPackage val = new ZPackage(Utils.Decompress(packed.ReadByteArray())); int num = val.ReadInt(); Vector2s key = default(Vector2s); for (int i = 0; i < num; i++) { int num2 = val.ReadInt(); int num3 = val.ReadInt(); ((Vector2s)(ref key))..ctor(num2, num3); if (!tiles.TryGetValue(key, out var value)) { value = new Tile(); tiles[key] = value; } value.hash = val.ReadInt(); value.data = val.ReadByteArray(); ZPackage val2 = new ZPackage(value.data); value.pieces = val2.ReadInt(); value.photoOnServer = val2.ReadInt(); if (value.photoOnServer == 0) { value.photo = null; value.photoHere = 0; } value.stale = true; } num = val.ReadInt(); Vector2s key2 = default(Vector2s); for (int j = 0; j < num; j++) { int num4 = val.ReadInt(); int num5 = val.ReadInt(); ((Vector2s)(ref key2))..ctor(num4, num5); if (tiles.TryGetValue(key2, out var value2)) { Drop(value2); tiles.Remove(key2); } } more = val.ReadBool(); } catch (Exception ex) { log.LogWarning((object)("built: the answer of the server could not be read: " + ex.Message)); } } private static void OnPhotos(long sender, ZPackage package) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) try { byte b = package.ReadByte(); int num = package.ReadInt(); for (int i = 0; i < num; i++) { int num2 = package.ReadInt(); int num3 = package.ReadInt(); int photoHere = package.ReadInt(); byte[] photo = package.ReadByteArray(); if ((uint)b == ((!Roofs) ? 1u : 0u) && tiles.TryGetValue(new Vector2s(num2, num3), out var value)) { value.photo = photo; value.photoHere = photoHere; value.stale = true; } } } catch (Exception ex) { log.LogWarning((object)("built: the photos of the server could not be read: " + ex.Message)); } } private static void Drop(Tile tile) { if ((Object)(object)tile.image != (Object)null) { Object.Destroy((Object)(object)((Component)tile.image).gameObject); } if ((Object)(object)tile.texture != (Object)null) { Object.Destroy((Object)(object)tile.texture); } } private static void DropTiles() { foreach (Tile value in tiles.Values) { Drop(value); } tiles.Clear(); } private static void MapTick(Minimap __instance) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_006e: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Invalid comparison between Unknown and I4 //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Invalid comparison between Unknown and I4 //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Expected O, but got Unknown //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_05db: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) if (host == null) { return; } if ((int)__instance.m_mode == 2) { MapSwitches.Draw(__instance); } if (CloserZoom && __instance.m_minZoom > 0.0025f) { zoomOfGame = __instance.m_minZoom; __instance.m_minZoom = 0.0025f; } else if (!CloserZoom && zoomOfGame > 0f) { __instance.m_minZoom = zoomOfGame; zoomOfGame = 0f; } if ((int)__instance.m_mode == 0 || !Show || (Object)(object)Player.m_localPlayer == (Object)null || ((int)__instance.m_mode == 1 && !SmallMap)) { if ((Object)(object)root != (Object)null && ((Component)root).gameObject.activeSelf) { ((Component)root).gameObject.SetActive(false); } mode = (MapMode)0; return; } bool num = (int)__instance.m_mode == 2; RawImage val = (num ? __instance.m_mapImageLarge : __instance.m_mapImageSmall); RectTransform val2 = (num ? __instance.m_pinRootLarge : __instance.m_pinRootSmall); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { return; } if ((Object)(object)root == (Object)null) { root = new GameObject("bf_built", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); mode = (MapMode)0; } if (mode != __instance.m_mode) { mode = __instance.m_mode; ((Transform)root).SetParent((Transform)(object)val2, false); root.anchorMin = Vector2.zero; root.anchorMax = Vector2.one; root.offsetMin = Vector2.zero; root.offsetMax = Vector2.zero; ((Transform)root).SetAsFirstSibling(); ((Component)root).gameObject.SetActive(true); Stale(); } Rect uvRect = val.uvRect; Rect rect = ((Graphic)val).rectTransform.rect; float num2 = (float)__instance.m_textureSize * __instance.m_pixelSize; float num3 = (((Rect)(ref uvRect)).xMin - 0.5f) * num2; float num4 = (((Rect)(ref uvRect)).yMin - 0.5f) * num2; float num5 = ((Rect)(ref uvRect)).width * num2; float num6 = ((Rect)(ref uvRect)).height * num2; if (num5 <= 0f || num6 <= 0f || ((Rect)(ref rect)).width <= 0f || ((Rect)(ref rect)).height <= 0f) { return; } (int, int, int, int) view = (Mathf.Max(Mathf.FloorToInt((num3 + 32f) / 64f), -170), Mathf.Max(Mathf.FloorToInt((num4 + 32f) / 64f), -170), Mathf.Min(Mathf.FloorToInt((num3 + num5 + 32f) / 64f), 170), Mathf.Min(Mathf.FloorToInt((num4 + num6 + 32f) / 64f), 170)); float realtimeSinceStartup = Time.realtimeSinceStartup; float num7 = realtimeSinceStartup - askedAt; if (ZRoutedRpc.instance != null && (num7 > 30f || (num7 > 1f && (more || !view.Equals(asked))))) { if (num7 > 30f) { Stale(); } Request(view); } float num8 = ((Rect)(ref rect)).width / num5; float num9 = ((Rect)(ref rect)).height / num6; int num10 = 0; wanted.Clear(); foreach (KeyValuePair<Vector2s, Tile> tile in tiles) { Tile value = tile.Value; float num11 = ((float)(tile.Key.x * 64) - 32f - num3) * num8; float num12 = ((float)(tile.Key.y * 64) - 32f - num4) * num9; float num13 = num11 + 64f * num8; float num14 = num12 + 64f * num9; float num15 = Mathf.Max(num11, 0f); float num16 = Mathf.Max(num12, 0f); float num17 = Mathf.Min(num13, ((Rect)(ref rect)).width); float num18 = Mathf.Min(num14, ((Rect)(ref rect)).height); if (num15 >= num17 || num16 >= num18) { if ((Object)(object)value.image != (Object)null && ((Behaviour)value.image).enabled) { ((Behaviour)value.image).enabled = false; } continue; } if (value.photoOnServer != 0 && value.photoHere != value.photoOnServer && num14 - num12 >= 40f && realtimeSinceStartup - value.photoAskedAt > 5f && wanted.Count < 24) { wanted.Add(tile.Key); } if (value.stale || (Object)(object)value.image == (Object)null) { if (num10 >= 6) { continue; } num10++; Bake(__instance, tile.Key, value); } ((Behaviour)value.image).enabled = true; RectTransform rectTransform = ((Graphic)value.image).rectTransform; rectTransform.anchoredPosition = new Vector2(num15, num16); rectTransform.sizeDelta = new Vector2(num17 - num15, num18 - num16); value.image.uvRect = new Rect((num15 - num11) / (num13 - num11), (num16 - num12) / (num14 - num12), (num17 - num15) / (num13 - num11), (num18 - num16) / (num14 - num12)); } if (wanted.Count > 0 && ZRoutedRpc.instance != null && realtimeSinceStartup - photosAskedAt > 1f) { photosAskedAt = realtimeSinceStartup; ZPackage val3 = new ZPackage(); val3.Write((!Roofs) ? ((byte)1) : ((byte)0)); val3.Write(wanted.Count); foreach (Vector2s item in wanted) { tiles[item].photoAskedAt = realtimeSinceStartup; val3.Write((int)item.x); val3.Write((int)item.y); } ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "bf_built_photo_ask", new object[1] { val3 }); } if (realtimeSinceStartup - shotCheckedAt > 10f) { shotCheckedAt = realtimeSinceStartup; Shoot(); } } private static void Stale() { foreach (Tile value in tiles.Values) { if (value.photo == null || value.hidden) { value.stale = true; } } } private static void Request((int minX, int minY, int maxX, int maxY) view) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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) askedAt = Time.realtimeSinceStartup; asked = view; more = false; if (tiles.Count > 800) { foreach (Vector2s item in tiles.Keys.Where((Vector2s at) => at.x < view.minX || at.x > view.maxX || at.y < view.minY || at.y > view.maxY).ToList()) { Drop(tiles[item]); tiles.Remove(item); } } ZPackage val = new ZPackage(); val.Write(view.minX); val.Write(view.minY); val.Write(view.maxX); val.Write(view.maxY); List<KeyValuePair<Vector2s, Tile>> list = tiles.Where((KeyValuePair<Vector2s, Tile> entry) => entry.Key.x >= view.minX && entry.Key.x <= view.maxX && entry.Key.y >= view.minY && entry.Key.y <= view.maxY).ToList(); val.Write(list.Count); foreach (KeyValuePair<Vector2s, Tile> item2 in list) { val.Write((int)item2.Key.x); val.Write((int)item2.Key.y); val.Write(item2.Value.hash); } ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "bf_built_ask", new object[1] { val }); } private static void Bake(Minimap map, Vector2s at, Tile tile) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) tile.stale = false; tile.hidden = false; float left = (float)(at.x * 64) - 32f; float low = (float)(at.y * 64) - 32f; byte[] array = Array.Empty<byte>(); byte[] ground = null; float[] array2 = Array.Empty<float>(); try { ZPackage val = new ZPackage(tile.data); val.ReadInt(); val.ReadInt(); array = new byte[val.ReadInt() * 3]; for (int i = 0; i < array.Length; i++) { array[i] = val.ReadByte(); } if (val.ReadBool()) { ground = val.ReadByteArray(); } if (val.GetPos() < val.Size()) { array2 = new float[val.ReadInt() * 3]; for (int j = 0; j < array2.Length; j++) { array2[j] = val.ReadSingle(); } } } catch (Exception ex) { log.LogWarning((object)$"built: the zone {at.x} {at.y} could not be read: {ex.Message}"); } bool safe = Cover(array2); if (tile.photo == null || !Photo(map, tile, left, low, ground, safe)) { Marks(map, tile, left, low, array, ground, safe); } if ((Object)(object)tile.image == (Object)null) { GameObject val2 = new GameObject($"bf_built_{at.x}_{at.y}", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent((Transform)(object)root, false); tile.image = val2.AddComponent<RawImage>(); ((Graphic)tile.image).raycastTarget = false; RectTransform val3 = (RectTransform)map.m_pinPrefab.transform; RectTransform rectTransform = ((Graphic)tile.image).rectTransform; rectTransform.anchorMin = val3.anchorMin; rectTransform.anchorMax = val3.anchorMin; rectTransform.pivot = Vector2.zero; } tile.image.texture = (Texture)(object)tile.texture; } private static bool Dug(byte[] ground, int cell) { if (ground != null) { return ((ground[cell / 4] >> cell % 4 * 2) & 3) == 1; } return false; } private static bool Cover(float[] circles) { if (!Safe || circles.Length == 0) { return false; } for (int i = 0; i < depth.Length; i++) { depth[i] = -1f; } float num = 2f; for (int j = 0; j < circles.Length; j += 3) { float num2 = circles[j]; float num3 = circles[j + 1]; float num4 = circles[j + 2]; int num5 = Mathf.Max(Mathf.FloorToInt((num2 - num4) * num), 0); int num6 = Mathf.Min(Mathf.CeilToInt((num2 + num4) * num), 127); int num7 = Mathf.Max(Mathf.FloorToInt((num3 - num4) * num), 0); int num8 = Mathf.Min(Mathf.CeilToInt((num3 + num4) * num), 127); for (int k = num7; k <= num8; k++) { float num9 = ((float)k + 0.5f) / num - num3; for (int l = num5; l <= num6; l++) { float num10 = ((float)l + 0.5f) / num - num2; float num11 = num4 - Mathf.Sqrt(num10 * num10 + num9 * num9); if (num11 > depth[k * 128 + l]) { depth[k * 128 + l] = num11; } } } } return true; } private static void Marks(Minimap map, Tile tile, float left, float low, byte[] marks, byte[] ground, bool safe) { //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) Array.Clear(pixels, 0, pixels.Length); int num = 2; int num2 = 0; while (safe && num2 < 4096) { int num3 = num2 % 64 * num; int num4 = num2 / 64 * num; bool flag = false; for (int i = 0; i < num * num; i++) { int num5 = (num4 + i / num) * 128 + num3 + i % num; if (depth[num5] < 0f) { continue; } if (!flag) { if (!map.IsExplored(new Vector3(left + (float)(num2 % 64) + 0.5f, 0f, low + (float)(num2 / 64) + 0.5f))) { break; } flag = true; } pixels[num5] = ((depth[num5] < 1f) ? SafeLine : SafeTint); } num2++; } for (int j = 0; j < 4096; j++) { int num6 = j % 64; int num7 = j / 64; if (Dug(ground, j) && map.IsExplored(new Vector3(left + (float)num6, 0f, low + (float)num7))) { Fill(pixels, 128, num6 * 2 - 1, num7 * 2 - 1, 2, Trench); } } for (int k = 0; k < marks.Length; k += 3) { int num8 = marks[k]; int num9 = marks[k + 1]; int num10 = marks[k + 2]; if (num10 < Materials.Length && map.IsExplored(new Vector3(left + (float)num8 / 2f, 0f, low + (float)num9 / 2f))) { Fill(pixels, 128, num8 - 2, num9 - 2, 4, Materials[num10]); } } if ((Object)(object)tile.texture != (Object)null && ((Texture)tile.texture).width != 128) { Object.Destroy((Object)(object)tile.texture); tile.texture = null; } if ((Object)(object)tile.texture == (Object)null) { tile.texture = new Texture2D(128, 128, (TextureFormat)4, false) { filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)1 }; } tile.texture.SetPixels32(pixels); tile.texture.Apply(); } private static bool Photo(Minimap map, Tile tile, float left, float low, byte[] ground, bool safe) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: 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_01c0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)tile.texture != (Object)null) { Object.Destroy((Object)(object)tile.texture); } tile.texture = new Texture2D(2, 2, (TextureFormat)4, true) { filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; if (!ImageConversion.LoadImage(tile.texture, tile.photo) || ((Texture)tile.texture).width != 256 || ((Texture)tile.texture).height != 256) { log.LogWarning((object)$"built: a photo of the server is no picture of {256} pixels"); tile.photo = null; tile.photoHere = 0; return false; } Color32[] pixels = tile.texture.GetPixels32(); int num = 4; for (int i = 0; i < 4096; i++) { int num2 = i % 64; int num3 = i / 64; if (!map.IsExplored(new Vector3(left + (float)num2 + 0.5f, 0f, low + (float)num3 + 0.5f))) { Fill(pixels, 256, num2 * num, num3 * num, num, default(Color32)); tile.hidden = true; } else { if (!safe && !Dug(ground, i)) { continue; } bool flag = Dug(ground, i); int num4 = 2; for (int j = num3 * num; j < (num3 + 1) * num; j++) { for (int k = num2 * num; k < (num2 + 1) * num; k++) { if (pixels[j * 256 + k].a == 0) { float num5 = (safe ? depth[j / num4 * 128 + k / num4] : (-1f)); if (flag) { pixels[j * 256 + k] = Trench; } else if (num5 >= 0f) { pixels[j * 256 + k] = ((num5 < 1f) ? SafeLine : SafeTint); } } } } } } tile.texture.SetPixels32(pixels); tile.texture.Apply(true); return true; } private static void Fill(Color32[] into, int wide, int fromX, int fromY, int span, Color32 color) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) for (int i = Mathf.Max(fromY, 0); i < Mathf.Min(fromY + span, wide); i++) { for (int j = Mathf.Max(fromX, 0); j < Mathf.Min(fromX + span, wide); j++) { into[i * wide + j] = color; } } } private static void Shoot() { //IL_0117: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!EnvMan.IsDay() || (Object)(object)EnvMan.instance == (Object)null || (Object)(object)ZoneSystem.instance == (Object)null || (Object)(object)ZNetScene.instance == (Object)null || ZDOMan.instance == null || ZRoutedRpc.instance == null || ((Component)localPlayer).transform.position.y >= 3000f) { return; } Vector2s zone = ZoneSystem.GetZone(((Component)localPlayer).transform.position); Vector2s val = default(Vector2s); for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { ((Vector2s)(ref val))..ctor(zone.x + j, zone.y + i); if (tiles.TryGetValue(val, out var value) && value.pieces != 0 && value.pieces != value.photoOnServer && value.pieces != value.shot && ZoneSystem.instance.IsZoneLoaded(val) && Stands(val, value.pieces)) { value.shot = value.pieces; try { Take(val, value.pieces); return; } catch (Exception arg) { log.LogWarning((object)$"built: no photo of the zone {val.x} {val.y}: {arg}"); return; } } } } } private static bool Stands(Vector2s at, int pieces) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (placed == null) { Kinds(); } objects.Clear(); seen.Clear(); ZDOMan.instance.FindObjects(at, objects, seen); int num = 0; int num2 = 0; foreach (ZDO @object in objects) { if (Placed(@object)) { if ((Object)(object)ZNetScene.instance.FindInstance(@object) == (Object)null) { return false; } num2++; num = Mix(num, @object.m_uid); } } if (num2 > 0) { return ((num == 0) ? 1 : num) == pieces; } return false; } private static void Take(Vector2s at, int pieces) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_01b5: 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_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022f: 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_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Expected O, but got Unknown //IL_0525: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Unknown result type (might be due to invalid IL or missing references) float realtimeSinceStartup = Time.realtimeSinceStartup; if ((Object)(object)lens == (Object)null) { lens = new GameObject("bf_built_lens").AddComponent<Camera>(); ((Behaviour)lens).enabled = false; lens.orthographic = true; lens.orthographicSize = 32f; lens.aspect = 1f; lens.nearClipPlane = 1f; lens.farClipPlane = 2000f; lens.clearFlags = (CameraClearFlags)2; lens.allowHDR = false; lens.allowMSAA = false; lens.useOcclusionCulling = false; lens.renderingPath = (RenderingPath)1; } if ((Object)(object)film == (Object)null) { film = new Texture2D(256, 256, (TextureFormat)4, false); } Vector3 zonePos = ZoneSystem.GetZonePos(at); ((Component)lens).transform.SetPositionAndRotation(new Vector3(zonePos.x, 1500f, zonePos.z), Quaternion.Euler(90f, 0f, 0f)); Light dirLight = EnvMan.instance.m_dirLight; AmbientMode ambientMode = RenderSettings.ambientMode; Color ambientLight = RenderSettings.ambientLight; bool fog = RenderSettings.fog; Quaternion rotation = ((Component)dirLight).transform.rotation; Color color = dirLight.color; float intensity = dirLight.intensity; LightShadows shadows = dirLight.shadows; Vector4 globalVector = Shader.GetGlobalVector(SunDir); Color globalColor = Shader.GetGlobalColor(SunColor); Color globalColor2 = Shader.GetGlobalColor(AmbientColor); float globalFloat = Shader.GetGlobalFloat(Wet); float lodBias = QualitySettings.lodBias; RenderTexture temporary = RenderTexture.GetTemporary(256, 256, 24, (RenderTextureFormat)0); List<Renderer> list = new List<Renderer>(); int num = 0; byte[] array; byte[] array2; try { RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = Ambient; RenderSettings.fog = false; ((Component)dirLight).transform.rotation = Quaternion.Euler(65f, 30f, 0f); dirLight.color = Color.white; dirLight.intensity = 1.6f; dirLight.shadows = (LightShadows)0; Shader.SetGlobalVector(SunDir, Vector4.op_Implicit(-((Component)dirLight).transform.forward)); Shader.SetGlobalColor(SunColor, Color.white * 1.6f); Shader.SetGlobalColor(AmbientColor, Ambient); Shader.SetGlobalFloat(Wet, 0f); QualitySettings.lodBias = 1000f; lens.targetTexture = temporary; lens.cullingMask = LayerMask.GetMask(new string[2] { "piece", "piece_nonsolid" }); float num2 = 72f; List<Renderer> list2 = new List<Renderer>(); foreach (KeyValuePair<ZDO, ZNetView> instance in ZNetScene.instance.m_instances) { ZNetView value = instance.Value; if ((Object)(object)value == (Object)null || Mathf.Abs(((Component)value).transform.position.x - zonePos.x) > num2 || Mathf.Abs(((Component)value).transform.position.z - zonePos.z) > num2) { continue; } string prefabName = Utils.GetPrefabName(((Component)value).gameObject); bool flag = prefabName.StartsWith("bf_") || instance.Key.GetBool(RailBuilt, false); prefabName = prefabName.ToLowerInvariant(); flag |= prefabName.Contains("pole"); bool flag2 = prefabName.Contains("roof") && !prefabName.Contains("wall"); if (!flag && !flag2) { continue; } Renderer[] componentsInChildren = ((Component)value).GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { if (!val.forceRenderingOff) { if (flag) { val.forceRenderingOff = true; list.Add(val); } else { list2.Add(val); } } } } array = Develop(temporary); foreach (Renderer item in list2) { item.forceRenderingOff = true; list.Add(item); } num = list2.Count; array2 = Develop(temporary); } finally { foreach (Renderer item2 in list) { if ((Object)(object)item2 != (Object)null) { item2.forceRenderingOff = false; } } lens.targetTexture = null; RenderTexture.ReleaseTemporary(temporary); QualitySettings.lodBias = lodBias; Shader.SetGlobalFloat(Wet, globalFloat); Shader.SetGlobalColor(AmbientColor, globalColor2); Shader.SetGlobalColor(SunColor, globalColor); Shader.SetGlobalVector(SunDir, globalVector); dirLight.shadows = shadows; dirLight.intensity = intensity; dirLight.color = color; ((Component)dirLight).transform.rotation = rotation; RenderSettings.fog = fog; RenderSettings.ambientLight = ambientLight; RenderSettings.ambientMode = ambientMode; } ZPackage val2 = new ZPackage(); val2.Write((int)at.x); val2.Write((int)at.y); val2.Write(pieces); val2.Write(array); val2.Write(array2); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "bf_built_shot", new object[1] { val2 }); log.LogInfo((object)$"built: took the photos of the zone {at.x} {at.y}, {array.Length} and {array2.Length} bytes, {num} roof parts hidden for the second, in {(Time.realtimeSinceStartup - realtimeSinceStartup) * 1000f:0} ms"); } private static byte[] Develop(RenderTexture target) { //IL_0001: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) Color32[] array = Snap(target, Color.black); Color32[] array2 = Snap(target, Color.white); for (int i = 0; i < array.Length; i++) { int num = Mathf.Max(array2[i].r - array[i].r, Mathf.Max(array2[i].g - array[i].g, array2[i].b - array[i].b)); int num2 = 255 - Mathf.Clamp(num, 0, 255); array[i] = ((num2 == 0) ? default(Color32) : new Color32((byte)Mathf.Min(array[i].r * 255 / num2, 255), (byte)Mathf.Min(array[i].g * 255 / num2, 255), (byte)Mathf.Min(array[i].b * 255 / num2, 255), (byte)num2)); } film.SetPixels32(array); film.Apply(); return ImageConversion.EncodeToPNG(film); } private static Color32[] Snap(RenderTexture target, Color behind) { //IL_000b: 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) RenderTexture active = RenderTexture.active; try { lens.backgroundColor = behind; lens.Render(); RenderTexture.active = target; film.ReadPixels(new Rect(0f, 0f, 256f, 256f), 0, 0); return film.GetPixels32(); } finally { RenderTexture.active = active; } } } [BepInPlugin("vladasz.mapbuildings", "Buildings on the Map", "0.2.0")] public class MapBuildingsPlugin : BaseUnityPlugin { public const string Id = "vladasz.mapbuildings"; public const string Number = "0.2.0"; private void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown Built.Bind(((BaseUnityPlugin)this).Config); Built.Load(new HotHost(((BaseUnityPlugin)this).Logger, new Harmony("vladasz.mapbuildings"), "0.2.0")); } } internal static class MapSwitches { private sealed class Row { public int index; public string text; public string item; public Func<bool> on; public UnityAction<bool> changed; public Func<bool> shown; public Func<Vector2> offset; public GameObject made; public Toggle toggle; public Vector2 home; } private const float RowStep = 51f; private static readonly List<Row> rows = new List<Row>(); internal static void Add(int index, string text, string item, Func<bool> on, UnityAction<bool> changed, Func<bool> shown = null, Func<Vector2> offset = null) { rows.Add(new Row { index = index, text = text, item = item, on = on, changed = changed, shown = shown, offset = offset }); } internal static void Draw(Minimap map) { //IL_00d6: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_010f: Unknown result type (might be due to invalid IL or missing references) Toggle publicPosition = map.m_publicPosition; if ((Object)(object)publicPosition == (Object)null) { return; } foreach (Row row in rows) { if ((Object)(object)row.made == (Object)null) { row.made = Make(publicPosition, row); } bool flag = Shown(row); if (row.made.activeSelf != flag) { row.made.SetActive(flag); } if (!flag) { continue; } int num = row.index; foreach (Row row2 in rows) { if (row2.index < row.index && !Shown(row2)) { num--; } } Vector2 val = ((row.offset != null) ? row.offset() : Vector2.zero); ((RectTransform)row.made.transform).anchoredPosition = row.home + val + new Vector2(0f, (float)(num + 1) * 51f); bool flag2 = row.on(); if ((Object)(object)row.toggle != (Object)null && row.toggle.isOn != flag2) { row.toggle.SetIsOnWithoutNotify(flag2); } } } private static bool Shown(Row row) { if (row.shown != null) { return row.shown(); } return true; } internal static void Clear() { foreach (Row row in rows) { if ((Object)(object)row.made != (Object)null) { Object.Destroy((Object)(object)row.made); } } rows.Clear(); } private static GameObject Make(Toggle source, Row row) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_011e: 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) RectTransform val = (RectTransform)((Component)source).transform.parent; GameObject obj = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Transform)val).parent); ((Object)obj).name = $"bf_map_switch_{row.index}"; obj.transform.SetSiblingIndex(((Transform)val).GetSiblingIndex() + 1); Toggle val2 = (row.toggle = obj.GetComponentInChildren<Toggle>(true)); val2.onValueChanged = new ToggleEvent(); val2.SetIsOnWithoutNotify(row.on()); ((UnityEvent<bool>)(object)val2.onValueChanged).AddListener(row.changed); TMP_Text componentInChildren = obj.GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = row.text; } object obj2; if (!((Object)(object)ObjectDB.instance != (Object)null)) { obj2 = null; } else { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(row.item); obj2 = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null); } ItemDrop val3 = (ItemDrop)obj2; Graphic graphic = val2.graphic; Image val4 = (Image)(object)((graphic is Image) ? graphic : null); if (val4 != null && (Object)(object)val3 != (Object)null && val3.m_itemData.m_shared.m_icons.Length != 0) { val4.sprite = val3.m_itemData.m_shared.m_icons[0]; } row.home = val.anchoredPosition; return obj; } } } namespace Blackforge.Hot { public sealed class HotHost { public ManualLogSource Log { get; } public Harmony Harmony { get; } public string Version { get; } public bool IsDedicatedServer => (int)SystemInfo.graphicsDeviceType == 4; internal HotHost(ManualLogSource log, Harmony harmony, string version) { Log = log; Harmony = harmony; Version = version; } public byte[] ReadAsset(string relative) { return File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(typeof(HotHost).Assembly.Location), relative)); } public void UnregisterRpc(IEnumerable<string> names) { if (ZRoutedRpc.instance == null) { return; } foreach (string name in names) { ZRoutedRpc.instance.m_functions.Remove(StringExtensionMethods.GetStableHashCode(name)); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }