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 BaseOutlines v1.0.0
BaseOutlines.dll
Decompiled 4 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("BaseOutlines")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BaseOutlines")] [assembly: AssemblyTitle("BaseOutlines")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BaseOutlines { internal struct WorldRect { public float X0; public float Y0; public float X1; public float Y1; } internal class Room { public bool Generated; public readonly HashSet<long> Cells = new HashSet<long>(); public List<WorldRect> Runs; public Vector2 LabelPos; public Rect Bounds; public float Area; } internal static class BaseGeometry { public const float RoomCell = 0.5f; private const float RoomPad = 0.3f; private const int MaxComponentSpan = 600; private static int s_builtFor = int.MinValue; private static List<Room> s_rooms; private static readonly Dictionary<long, Room> s_cellToRoom = new Dictionary<long, Room>(); private static readonly Dictionary<float, List<WorldRect>> s_stamps = new Dictionary<float, List<WorldRect>>(); private static readonly int[] N4X = new int[4] { 1, -1, 0, 0 }; private static readonly int[] N4Y = new int[4] { 0, 0, 1, -1 }; public static int RoomsVersion { get; private set; } public static void Invalidate() { s_builtFor = int.MinValue; } private static void Refresh() { int num = (WallTracker.Version * 397) ^ Plugin.StyleVersion; if (num != s_builtFor) { s_builtFor = num; s_stamps.Clear(); s_rooms = null; } } public static List<Room> Rooms() { Refresh(); if (s_rooms == null) { s_cellToRoom.Clear(); s_rooms = new List<Room>(); BuildRooms(generated: false, s_rooms); BuildRooms(generated: true, s_rooms); foreach (Room s_room in s_rooms) { foreach (long cell in s_room.Cells) { if (!s_cellToRoom.ContainsKey(cell)) { s_cellToRoom[cell] = s_room; } } } RoomsVersion++; } return s_rooms; } public static Room RoomAt(Vector2 world) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) Rooms(); s_cellToRoom.TryGetValue(CellKey(world), out var value); return value; } public static long CellKey(Vector2 world) { //IL_0000: 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) return Key(Mathf.FloorToInt(world.x / 0.5f), Mathf.FloorToInt(world.y / 0.5f)); } public static List<WorldRect> Stamp(float cell) { Refresh(); if (!s_stamps.TryGetValue(cell, out var value)) { value = ToRuns(Rasterize(cell, cell * 0.45f, null), cell); s_stamps[cell] = value; } return value; } private static long Key(int x, int y) { return ((long)x << 32) | (uint)y; } private static int KX(long k) { return (int)(k >> 32); } private static int KY(long k) { return (int)k; } private static HashSet<long> Rasterize(float cell, float pad, Func<WallSeg, bool> filter) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //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_012c: 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_0138: Unknown result type (might be due to invalid IL or missing references) HashSet<long> hashSet = new HashSet<long>(); WallTracker instance = WallTracker.Instance; if ((Object)(object)instance == (Object)null) { return hashSet; } foreach (WallSeg value in instance.Walls.Values) { if (filter != null && !filter(value)) { continue; } float num = value.HalfWidth + pad; Vector2 val = value.B - value.A; if (((Vector2)(ref val)).sqrMagnitude > 10000f) { continue; } int num2 = Mathf.FloorToInt((Mathf.Min(value.A.x, value.B.x) - num) / cell); int num3 = Mathf.FloorToInt((Mathf.Max(value.A.x, value.B.x) + num) / cell); int num4 = Mathf.FloorToInt((Mathf.Min(value.A.y, value.B.y) - num) / cell); int num5 = Mathf.FloorToInt((Mathf.Max(value.A.y, value.B.y) + num) / cell); for (int i = num2; i <= num3; i++) { for (int j = num4; j <= num5; j++) { if (DistToSegment(new Vector2(((float)i + 0.5f) * cell, ((float)j + 0.5f) * cell), value.A, value.B) <= num) { hashSet.Add(Key(i, j)); } } } } return hashSet; } private static float DistToSegment(Vector2 p, Vector2 a, Vector2 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0035: 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_0038: 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) Vector2 val = b - a; float sqrMagnitude = ((Vector2)(ref val)).sqrMagnitude; float num = ((sqrMagnitude > 1E-06f) ? Mathf.Clamp01(Vector2.Dot(p - a, val) / sqrMagnitude) : 0f); return Vector2.Distance(p, a + val * num); } private static List<WorldRect> ToRuns(IEnumerable<long> cells, float cell) { List<long> list = new List<long>(cells); list.Sort(delegate(long p, long q) { int num5 = KY(p).CompareTo(KY(q)); return (num5 == 0) ? KX(p).CompareTo(KX(q)) : num5; }); List<WorldRect> list2 = new List<WorldRect>(); int num = 0; while (num < list.Count) { int num2 = KY(list[num]); int num3 = KX(list[num]); int num4 = num3; for (num++; num < list.Count && KY(list[num]) == num2 && KX(list[num]) == num4 + 1; num++) { num4++; } list2.Add(new WorldRect { X0 = (float)num3 * cell, X1 = (float)(num4 + 1) * cell, Y0 = (float)num2 * cell, Y1 = (float)(num2 + 1) * cell }); } return list2; } private static void BuildRooms(bool generated, List<Room> output) { HashSet<long> hashSet = Rasterize(0.5f, 0.3f, (WallSeg s) => s.Generated == generated); HashSet<long> hashSet2 = new HashSet<long>(); HashSet<long> hashSet3 = new HashSet<long>(); float num = 0.25f; int num2 = Mathf.CeilToInt(Plugin.MinRoomArea.Value / num); int num3 = Mathf.FloorToInt(Plugin.MaxRoomArea.Value / num); Stack<long> stack = new Stack<long>(); Queue<int> queue = new Queue<int>(); List<long> list = new List<long>(); foreach (long item3 in hashSet) { if (hashSet3.Contains(item3)) { continue; } int num4 = int.MaxValue; int num5 = int.MaxValue; int num6 = int.MinValue; int num7 = int.MinValue; stack.Push(item3); hashSet3.Add(item3); while (stack.Count > 0) { long k = stack.Pop(); int num8 = KX(k); int num9 = KY(k); if (num8 < num4) { num4 = num8; } if (num8 > num6) { num6 = num8; } if (num9 < num5) { num5 = num9; } if (num9 > num7) { num7 = num9; } for (int num10 = -1; num10 <= 1; num10++) { for (int num11 = -1; num11 <= 1; num11++) { long item = Key(num8 + num10, num9 + num11); if (hashSet.Contains(item) && hashSet3.Add(item)) { stack.Push(item); } } } } if (num6 - num4 > 600 || num7 - num5 > 600) { continue; } num4--; num5--; num6++; num7++; int num12 = num6 - num4 + 1; int num13 = num7 - num5 + 1; bool[] array = new bool[num12 * num13]; for (int num14 = 0; num14 < num12; num14++) { Seed(hashSet, array, queue, num12, num4, num5, num14, 0); Seed(hashSet, array, queue, num12, num4, num5, num14, num13 - 1); } for (int num15 = 0; num15 < num13; num15++) { Seed(hashSet, array, queue, num12, num4, num5, 0, num15); Seed(hashSet, array, queue, num12, num4, num5, num12 - 1, num15); } while (queue.Count > 0) { int num16 = queue.Dequeue(); int num17 = num16 % num12; int num18 = num16 / num12; for (int num19 = 0; num19 < 4; num19++) { int num20 = num17 + N4X[num19]; int num21 = num18 + N4Y[num19]; if (num20 >= 0 && num21 >= 0 && num20 < num12 && num21 < num13) { Seed(hashSet, array, queue, num12, num4, num5, num20, num21); } } } bool[] array2 = new bool[num12 * num13]; for (int num22 = 0; num22 < num12 * num13; num22++) { if (array[num22] || array2[num22]) { continue; } long item2 = Key(num22 % num12 + num4, num22 / num12 + num5); if (hashSet.Contains(item2)) { continue; } list.Clear(); queue.Enqueue(num22); array2[num22] = true; while (queue.Count > 0) { int num23 = queue.Dequeue(); int num24 = num23 % num12; int num25 = num23 / num12; list.Add(Key(num24 + num4, num25 + num5)); for (int num26 = 0; num26 < 4; num26++) { int num27 = num24 + N4X[num26]; int num28 = num25 + N4Y[num26]; if (num27 >= 0 && num28 >= 0 && num27 < num12 && num28 < num13) { int num29 = num28 * num12 + num27; if (!array2[num29] && !array[num29] && !hashSet.Contains(Key(num27 + num4, num28 + num5))) { array2[num29] = true; queue.Enqueue(num29); } } } } if (list.Count < num2 || list.Count > num3 || hashSet2.Contains(list[0])) { continue; } foreach (long item4 in list) { hashSet2.Add(item4); } output.Add(MakeRoom(list, hashSet, generated)); } } } private static void Seed(HashSet<long> walls, bool[] outside, Queue<int> queue, int w, int bx0, int by0, int x, int y) { int num = y * w + x; if (!outside[num] && !walls.Contains(Key(x + bx0, y + by0))) { outside[num] = true; queue.Enqueue(num); } } private static Room MakeRoom(List<long> interior, HashSet<long> walls, bool generated) { //IL_011d: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_020b: 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_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) Room room = new Room { Generated = generated, Area = (float)interior.Count * 0.5f * 0.5f }; double num = 0.0; double num2 = 0.0; foreach (long item2 in interior) { num += (double)KX(item2) + 0.5; num2 += (double)KY(item2) + 0.5; } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((float)(num / (double)interior.Count), (float)(num2 / (double)interior.Count)); long k = interior[0]; float num3 = float.MaxValue; float num4 = float.MaxValue; float num5 = float.MaxValue; float num6 = float.MinValue; float num7 = float.MinValue; foreach (long item3 in interior) { room.Cells.Add(item3); float num8 = (float)KX(item3) + 0.5f; float num9 = (float)KY(item3) + 0.5f; float num10 = (num8 - val.x) * (num8 - val.x) + (num9 - val.y) * (num9 - val.y); if (num10 < num3) { num3 = num10; k = item3; } num4 = Mathf.Min(num4, (float)KX(item3)); num6 = Mathf.Max(num6, (float)(KX(item3) + 1)); num5 = Mathf.Min(num5, (float)KY(item3)); num7 = Mathf.Max(num7, (float)(KY(item3) + 1)); for (int i = 0; i < 4; i++) { long item = Key(KX(item3) + N4X[i], KY(item3) + N4Y[i]); if (walls.Contains(item)) { room.Cells.Add(item); } } } bool flag = room.Cells.Contains(Key(Mathf.FloorToInt(val.x), Mathf.FloorToInt(val.y))); room.LabelPos = (Vector2)(flag ? (val * 0.5f) : new Vector2(((float)KX(k) + 0.5f) * 0.5f, ((float)KY(k) + 0.5f) * 0.5f)); room.Bounds = Rect.MinMaxRect(num4 * 0.5f, num5 * 0.5f, num6 * 0.5f, num7 * 0.5f); room.Runs = ToRuns(room.Cells, 0.5f); return room; } } internal struct Quad { public Vector2 P0; public Vector2 P1; public Vector2 P2; public Vector2 P3; public Color32 Color; } internal class MeshPage : MaskableGraphic { public const int QuadsPerPage = 15000; public List<Quad> Source; public int First; public int Count; protected override void OnPopulateMesh(VertexHelper vh) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_00bd: 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_00c7: Unknown result type (might be due to invalid IL or missing references) vh.Clear(); if (Source != null) { int num = Mathf.Min(First + Count, Source.Count); for (int i = First; i < num; i++) { Quad quad = Source[i]; int currentVertCount = vh.currentVertCount; vh.AddVert(Vector2.op_Implicit(quad.P0), quad.Color, Vector4.op_Implicit(Vector2.zero)); vh.AddVert(Vector2.op_Implicit(quad.P1), quad.Color, Vector4.op_Implicit(Vector2.zero)); vh.AddVert(Vector2.op_Implicit(quad.P2), quad.Color, Vector4.op_Implicit(Vector2.zero)); vh.AddVert(Vector2.op_Implicit(quad.P3), quad.Color, Vector4.op_Implicit(Vector2.zero)); vh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2); vh.AddTriangle(currentVertCount + 2, currentVertCount + 3, currentVertCount); } } } } internal class MapOverlay : MonoBehaviour { private const int MaxPages = 40; private Minimap _minimap; private RawImage _map; private RectTransform _mapRect; private RectTransform _rect; private bool _isLarge; private bool _shown; private bool _dirty = true; private int _builtWalls = -1; private int _builtStyle = -1; private bool _zonesShown; private int _builtZones = -1; private Vector2 _builtSize; private bool _warnedFull; private Rect _builtView; private Rect _visibleView; public static int LastQuads; public static int LastPages; public static int LastWallsDrawn; public static int LastRoomsDrawn; private readonly List<Quad> _quads = new List<Quad>(); private readonly List<MeshPage> _pages = new List<MeshPage>(); private float _worldSize; private Vector2 _size; private Room _hovered; private Room _drawnHover; private RoomNameReceiver _receiver; private TMP_Text _fontTemplate; private readonly List<TextMeshProUGUI> _labels = new List<TextMeshProUGUI>(); private string _labelKey; private readonly List<WallSeg> _visibleSegs = new List<WallSeg>(); private readonly List<SpawnZone> _zoneList = new List<SpawnZone>(); private readonly List<Vector2> _spans = new List<Vector2>(); private static readonly Comparison<Vector2> s_byStart = (Vector2 p, Vector2 q) => p.x.CompareTo(q.x); private readonly List<SpawnZone> _neighbors = new List<SpawnZone>(); public static void Attach(Minimap minimap, RawImage map, bool isLarge) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_004d: 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_0063: 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_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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)map == (Object)null)) { RectTransform val = (RectTransform)new GameObject("BaseOutlinesClip", new Type[2] { typeof(RectTransform), typeof(RectMask2D) }).transform; ((Transform)val).SetParent(((Component)map).transform, false); val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; val.offsetMin = Vector2.zero; val.offsetMax = Vector2.zero; GameObject val2 = new GameObject("BaseOutlines", new Type[1] { typeof(RectTransform) }); RectTransform val3 = (RectTransform)val2.transform; ((Transform)val3).SetParent((Transform)(object)val, false); val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.zero; val3.pivot = Vector2.zero; MapOverlay mapOverlay = val2.AddComponent<MapOverlay>(); mapOverlay._minimap = minimap; mapOverlay._map = map; mapOverlay._mapRect = ((Graphic)map).rectTransform; mapOverlay._rect = val3; mapOverlay._isLarge = isLarge; } } private void LateUpdate() { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_0225: 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_022f: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_014d: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0200: 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_0163: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_map == (Object)null) { return; } bool flag = Plugin.SpawnZonesVisible && (_isLarge || Plugin.SpawnZonesOnMinimap.Value); bool flag2 = Plugin.Enabled.Value && (_isLarge || Plugin.ShowOnMinimap.Value || flag); if (flag != _zonesShown || (flag && SpawnZones.Version != _builtZones)) { _zonesShown = flag; _builtZones = SpawnZones.Version; _dirty = true; } if (flag2 != _shown || WallTracker.Version != _builtWalls || Plugin.StyleVersion != _builtStyle) { _shown = flag2; _builtWalls = WallTracker.Version; _builtStyle = Plugin.StyleVersion; _dirty = true; } if (flag2) { Rect uvRect = _map.uvRect; Vector2 val2; if (((Rect)(ref uvRect)).width > 0f && ((Rect)(ref uvRect)).height > 0f) { Rect rect = _mapRect.rect; Vector2 size = ((Rect)(ref rect)).size; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(size.x / ((Rect)(ref uvRect)).width, size.y / ((Rect)(ref uvRect)).height); val2 = _rect.sizeDelta - val; if (((Vector2)(ref val2)).sqrMagnitude > 0.01f) { _rect.sizeDelta = val; } _rect.anchoredPosition = new Vector2((0f - ((Rect)(ref uvRect)).x) * val.x, (0f - ((Rect)(ref uvRect)).y) * val.y); float num = _minimap.m_pixelSize * (float)_minimap.m_textureSize; _visibleView = Rect.MinMaxRect((((Rect)(ref uvRect)).xMin - 0.5f) * num, (((Rect)(ref uvRect)).yMin - 0.5f) * num, (((Rect)(ref uvRect)).xMax - 0.5f) * num, (((Rect)(ref uvRect)).yMax - 0.5f) * num); if (!Contains(_builtView, _visibleView)) { _dirty = true; } } val2 = _rect.sizeDelta - _builtSize; if (((Vector2)(ref val2)).sqrMagnitude > 0.01f) { _dirty = true; } } if (_isLarge) { UpdateHoverAndClick(flag2); if (_hovered != _drawnHover) { _dirty = true; } } if (_dirty) { Rebuild(); } if (_isLarge) { UpdateLabels(flag2); } } private void Rebuild() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) _dirty = false; _builtSize = _rect.sizeDelta; _drawnHover = _hovered; _quads.Clear(); _builtView = Rect.MinMaxRect(((Rect)(ref _visibleView)).xMin - ((Rect)(ref _visibleView)).width, ((Rect)(ref _visibleView)).yMin - ((Rect)(ref _visibleView)).height, ((Rect)(ref _visibleView)).xMax + ((Rect)(ref _visibleView)).width, ((Rect)(ref _visibleView)).yMax + ((Rect)(ref _visibleView)).height); WallTracker instance = WallTracker.Instance; Rect rect = _rect.rect; _size = ((Rect)(ref rect)).size; _worldSize = _minimap.m_pixelSize * (float)_minimap.m_textureSize; if (_shown && (Object)(object)instance != (Object)null && _worldSize > 0f && _size.x > 0f) { float metersToUi = _size.x / _worldSize; if (_isLarge) { BuildLargeMap(instance, metersToUi); } else { BuildMinimap(metersToUi); } } if (_isLarge) { LastQuads = _quads.Count; LastPages = (_quads.Count + 15000 - 1) / 15000; } int num = Mathf.Min(40, (_quads.Count + 15000 - 1) / 15000); if (_quads.Count > 600000 && !_warnedFull) { _warnedFull = true; Plugin.Log.LogWarning((object)$"Too much to draw ({_quads.Count} shapes); some walls are left out."); } for (int i = 0; i < Mathf.Max(num, _pages.Count); i++) { MeshPage page = GetPage(i); page.Source = _quads; page.First = i * 15000; page.Count = ((i < num) ? 15000 : 0); ((Component)page).gameObject.SetActive(page.Count > 0); ((Graphic)page).SetVerticesDirty(); } } private MeshPage GetPage(int i) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0052: 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_006f: 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_007a: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) while (_pages.Count <= i) { GameObject val = new GameObject("BaseOutlinesMesh" + _pages.Count, new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent((Transform)(object)_rect, false); ((Transform)val2).SetSiblingIndex(_pages.Count); val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.pivot = Vector2.zero; val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; MeshPage meshPage = val.AddComponent<MeshPage>(); ((Graphic)meshPage).color = Color.white; ((Graphic)meshPage).raycastTarget = false; _pages.Add(meshPage); } return _pages[i]; } private void BuildLargeMap(WallTracker tracker, float metersToUi) { //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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015a: 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_0023: 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_002d: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0079: 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_00ae: 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_00a4: 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_0208: 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_0261: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) if (_zonesShown) { BuildSpawnZones(metersToUi); } if (Plugin.ShowRooms.Value) { Color32 val = Color32.op_Implicit(Plugin.RoomColor.Value); Color32 val2 = Color32.op_Implicit(Plugin.GeneratedRoomColor.Value); Color32 val3 = Color32.op_Implicit(Plugin.HoverColor.Value); LastRoomsDrawn = 0; foreach (Room item in BaseGeometry.Rooms()) { if (!((Rect)(ref item.Bounds)).Overlaps(_builtView)) { continue; } LastRoomsDrawn++; Color32 col = ((item == _hovered) ? val3 : (item.Generated ? val2 : val)); foreach (WorldRect run in item.Runs) { AddRect(run, col); } } } float num = Plugin.WallFillWidth.Value * 0.5f; float value = Plugin.WallOutlineWidth.Value; Color32 val4 = Color32.op_Implicit(Plugin.WallOutlineColor.Value); Color32 val5 = Color32.op_Implicit(Plugin.WallFillColor.Value); Color32 val6 = Color32.op_Implicit(Plugin.GeneratedOutlineColor.Value); Color32 val7 = Color32.op_Implicit(Plugin.GeneratedWallColor.Value); _visibleSegs.Clear(); foreach (WallSeg value2 in tracker.Walls.Values) { if (SegmentNear(value2, _builtView)) { _visibleSegs.Add(value2); } } LastWallsDrawn = _visibleSegs.Count; foreach (WallSeg visibleSeg in _visibleSegs) { AddSegment(visibleSeg, Mathf.Max(visibleSeg.HalfWidth * metersToUi, num) + value, visibleSeg.Generated ? val6 : val4); } foreach (WallSeg visibleSeg2 in _visibleSegs) { AddSegment(visibleSeg2, Mathf.Max(visibleSeg2.HalfWidth * metersToUi, num), visibleSeg2.Generated ? val7 : val5); } } private static bool SegmentNear(WallSeg seg, Rect view) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_005a: 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_0080: 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) float num = seg.HalfWidth + 1f; if (Mathf.Max(seg.A.x, seg.B.x) + num >= ((Rect)(ref view)).xMin && Mathf.Min(seg.A.x, seg.B.x) - num <= ((Rect)(ref view)).xMax && Mathf.Max(seg.A.y, seg.B.y) + num >= ((Rect)(ref view)).yMin) { return Mathf.Min(seg.A.y, seg.B.y) - num <= ((Rect)(ref view)).yMax; } return false; } private static bool Contains(Rect outer, Rect inner) { if (((Rect)(ref outer)).width > 0f && ((Rect)(ref inner)).xMin >= ((Rect)(ref outer)).xMin && ((Rect)(ref inner)).xMax <= ((Rect)(ref outer)).xMax && ((Rect)(ref inner)).yMin >= ((Rect)(ref outer)).yMin) { return ((Rect)(ref inner)).yMax <= ((Rect)(ref outer)).yMax; } return false; } private void BuildMinimap(float metersToUi) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) if (_zonesShown) { BuildSpawnZones(metersToUi); } if (!Plugin.ShowOnMinimap.Value) { return; } float num = Mathf.Max(0.25f, Plugin.StampSize.Value); float num2 = Mathf.Max(0f, Plugin.StampMinPixels.Value); while (num * metersToUi < num2 && num < 64f) { num *= 2f; } Color32 col = Color32.op_Implicit(Plugin.StampColor.Value); foreach (WorldRect item in BaseGeometry.Stamp(num)) { if (item.X1 >= ((Rect)(ref _builtView)).xMin && item.X0 <= ((Rect)(ref _builtView)).xMax && item.Y1 >= ((Rect)(ref _builtView)).yMin && item.Y0 <= ((Rect)(ref _builtView)).yMax) { AddRect(item, col); } } } private void BuildSpawnZones(float metersToUi) { //IL_0046: 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_0088: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_041e: 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_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_0552: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: 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_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_0575: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_0583: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) _zoneList.Clear(); bool value = Plugin.SpawnZonesShowUnlit.Value; foreach (SpawnZone value2 in SpawnZones.Zones.Values) { if ((value2.Active || value) && !(value2.Pos.x + value2.Radius < ((Rect)(ref _builtView)).xMin) && !(value2.Pos.x - value2.Radius > ((Rect)(ref _builtView)).xMax) && !(value2.Pos.y + value2.Radius < ((Rect)(ref _builtView)).yMin) && !(value2.Pos.y - value2.Radius > ((Rect)(ref _builtView)).yMax)) { _zoneList.Add(value2); } } if (_zoneList.Count == 0) { return; } float num = float.MaxValue; float num2 = float.MinValue; foreach (SpawnZone zone in _zoneList) { if (zone.Active) { num = Mathf.Min(num, zone.Pos.y - zone.Radius); num2 = Mathf.Max(num2, zone.Pos.y + zone.Radius); } } num = Mathf.Max(num, ((Rect)(ref _builtView)).yMin); num2 = Mathf.Min(num2, ((Rect)(ref _builtView)).yMax); if (num2 > num) { float num3 = Mathf.Max(0.05f, 2f / metersToUi); num3 = Mathf.Max(num3, (num2 - num) / 3000f); float num4 = Mathf.Floor(num / num3) * num3; int num5 = Mathf.CeilToInt((num2 - num4) / num3); Color32 col = Color32.op_Implicit(Plugin.SpawnZoneFill.Value); for (int i = 0; i < num5; i++) { float num6 = num4 + (float)i * num3; float num7 = num6 + num3 * 0.5f; _spans.Clear(); foreach (SpawnZone zone2 in _zoneList) { if (zone2.Active) { float num8 = num7 - zone2.Pos.y; if (!(num8 * num8 >= zone2.Radius * zone2.Radius)) { float num9 = Mathf.Sqrt(zone2.Radius * zone2.Radius - num8 * num8); _spans.Add(new Vector2(zone2.Pos.x - num9, zone2.Pos.x + num9)); } } } if (_spans.Count == 0) { continue; } _spans.Sort(s_byStart); Vector2 val = _spans[0]; for (int j = 1; j <= _spans.Count; j++) { if (j < _spans.Count && _spans[j].x <= val.y) { val.y = Mathf.Max(val.y, _spans[j].y); continue; } AddRect(new WorldRect { X0 = val.x, X1 = val.y, Y0 = num6, Y1 = num6 + num3 }, col); if (j < _spans.Count) { val = _spans[j]; } } } } float halfWidth = Mathf.Max(0.5f, Plugin.SpawnZoneRingWidth.Value * 0.5f); Color32 val2 = Color32.op_Implicit(Plugin.SpawnZoneRing.Value); Color32 val3 = Color32.op_Implicit(Plugin.SpawnZoneUnlitRing.Value); for (int k = 0; k < _zoneList.Count; k++) { SpawnZone spawnZone = _zoneList[k]; if (IsDuplicate(k)) { continue; } _neighbors.Clear(); for (int l = 0; l < _zoneList.Count; l++) { SpawnZone item = _zoneList[l]; if (l != k && item.Active) { float num10 = spawnZone.Radius + item.Radius; Vector2 val4 = item.Pos - spawnZone.Pos; if (((Vector2)(ref val4)).sqrMagnitude < num10 * num10) { _neighbors.Add(item); } } } int num11 = Mathf.Clamp(Mathf.CeilToInt((float)Math.PI * 2f * spawnZone.Radius * metersToUi / 3f), 24, 256); Vector2 val5 = spawnZone.Pos + new Vector2(spawnZone.Radius, 0f); for (int m = 1; m <= num11; m++) { float num12 = (float)m * 2f * (float)Math.PI / (float)num11; Vector2 val6 = spawnZone.Pos + new Vector2(Mathf.Cos(num12), Mathf.Sin(num12)) * spawnZone.Radius; if (!InsideAny((val5 + val6) * 0.5f)) { AddLine(val5, val6, halfWidth, spawnZone.Active ? val2 : val3, caps: false); } val5 = val6; } } } private bool InsideAny(Vector2 p) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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) foreach (SpawnZone neighbor in _neighbors) { float num = neighbor.Radius - 0.05f; Vector2 val = p - neighbor.Pos; if (((Vector2)(ref val)).sqrMagnitude < num * num) { return true; } } return false; } private bool IsDuplicate(int i) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) SpawnZone spawnZone = _zoneList[i]; for (int j = 0; j < i; j++) { SpawnZone spawnZone2 = _zoneList[j]; if (spawnZone2.Active == spawnZone.Active) { Vector2 val = spawnZone2.Pos - spawnZone.Pos; if (((Vector2)(ref val)).sqrMagnitude < 0.01f && Mathf.Abs(spawnZone2.Radius - spawnZone.Radius) < 0.05f) { return true; } } } return false; } private Vector2 ToLocal(Vector2 worldXZ) { //IL_0000: 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_003e: Unknown result type (might be due to invalid IL or missing references) return new Vector2((worldXZ.x / _worldSize + 0.5f) * _size.x, (worldXZ.y / _worldSize + 0.5f) * _size.y); } private void AddRect(WorldRect r, Color32 col) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0031: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_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_0055: Unknown result type (might be due to invalid IL or missing references) Vector2 val = ToLocal(new Vector2(r.X0, r.Y0)); Vector2 val2 = ToLocal(new Vector2(r.X1, r.Y1)); AddQuad(val, new Vector2(val.x, val2.y), val2, new Vector2(val2.x, val.y), col); } private void AddSegment(WallSeg seg, float halfWidth, Color32 col) { //IL_0002: 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_000e: Unknown result type (might be due to invalid IL or missing references) AddLine(seg.A, seg.B, halfWidth, col); } private void AddLine(Vector2 worldA, Vector2 worldB, float halfWidth, Color32 col, bool caps = true) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_000f: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0028: 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_0038: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) Vector2 val = ToLocal(worldA); Vector2 val2 = ToLocal(worldB); Vector2 val3 = val2 - val; float magnitude = ((Vector2)(ref val3)).magnitude; Vector2 val4 = ((magnitude > 0.0001f) ? (val3 / magnitude) : Vector2.right); Vector2 val5 = new Vector2(0f - val4.y, val4.x) * halfWidth; if (caps) { val -= val4 * halfWidth; val2 += val4 * halfWidth; } AddQuad(val - val5, val + val5, val2 + val5, val2 - val5, col); } private void AddQuad(Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, Color32 col) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) _quads.Add(new Quad { P0 = p0, P1 = p1, P2 = p2, P3 = p3, Color = col }); } private void UpdateHoverAndClick(bool show) { //IL_0028: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) Room hovered = null; if (show && Plugin.NamingEnabled.Value && !TextInput.IsVisible() && TryGetMouseWorld(out var world)) { hovered = BaseGeometry.RoomAt(world); } _hovered = hovered; if (_hovered == null || !ZInput.GetMouseButtonDown(0)) { return; } KeyCode value = Plugin.NameModifier.Value; if (((int)value == 0 || ZInput.GetKey(value, true)) && !((Object)(object)TextInput.instance == (Object)null)) { if ((Object)(object)_receiver == (Object)null) { _receiver = ((Component)this).gameObject.AddComponent<RoomNameReceiver>(); } _receiver.Target = _hovered; TextInput.instance.RequestText((TextReceiver)(object)_receiver, _hovered.Generated ? "Name this ruin" : "Name this building", 40); } } private bool TryGetMouseWorld(out Vector2 world) { //IL_0001: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0050: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) world = default(Vector2); Canvas componentInParent = ((Component)_rect).GetComponentInParent<Canvas>(); Camera val = (((Object)(object)componentInParent == (Object)null || (int)componentInParent.renderMode == 0) ? null : componentInParent.worldCamera); Vector2 val2 = Vector2.op_Implicit(ZInput.pointerPosition); if (!RectTransformUtility.RectangleContainsScreenPoint(_mapRect, val2, val)) { return false; } Vector2 val3 = default(Vector2); if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(_rect, val2, val, ref val3)) { return false; } Rect rect = _rect.rect; Vector2 size = ((Rect)(ref rect)).size; float num = _minimap.m_pixelSize * (float)_minimap.m_textureSize; if (size.x <= 0f || size.y <= 0f || num <= 0f) { return false; } world = new Vector2((val3.x / size.x - 0.5f) * num, (val3.y / size.y - 0.5f) * num); return true; } private void UpdateLabels(bool show) { //IL_0061: 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_00e2: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_019d: 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_0209: 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_022e: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) bool flag = show && Plugin.NamingEnabled.Value; List<Room> list = (flag ? BaseGeometry.Rooms() : null); string text = (flag ? $"{BaseGeometry.RoomsVersion}|{RoomNames.Version}|{Plugin.StyleVersion}|{_rect.sizeDelta.x:0}|{_hovered?.GetHashCode()}" : "off"); if (text == _labelKey) { return; } _labelKey = text; int num = 0; if (flag) { float num2 = _minimap.m_pixelSize * (float)_minimap.m_textureSize; Rect rect = _rect.rect; Vector2 size = ((Rect)(ref rect)).size; float num3 = ((num2 > 0f) ? (size.x / num2) : 0f); float value = Plugin.LabelMinRoomPixels.Value; foreach (Room item in list) { string text2 = RoomNames.Get(item); bool flag2 = item == _hovered; string text3; Color value2; if (!string.IsNullOrEmpty(text2)) { if (!flag2 && Mathf.Max(((Rect)(ref item.Bounds)).width, ((Rect)(ref item.Bounds)).height) * num3 < value) { continue; } text3 = text2; value2 = Plugin.LabelColor.Value; } else { if (!flag2) { continue; } KeyCode value3 = Plugin.NameModifier.Value; text3 = (((int)value3 == 0) ? "Click to name" : (KeyName(value3) + " + click to name")); value2 = Plugin.HintColor.Value; } TextMeshProUGUI label = GetLabel(num++); ((TMP_Text)label).text = text3; ((Graphic)label).color = value2; ((TMP_Text)label).fontSize = Plugin.LabelSize.Value; ((TMP_Text)label).rectTransform.anchoredPosition = new Vector2((item.LabelPos.x / num2 + 0.5f) * size.x, (item.LabelPos.y / num2 + 0.5f) * size.y); ((Component)label).gameObject.SetActive(true); } } for (int i = num; i < _labels.Count; i++) { if ((Object)(object)_labels[i] != (Object)null) { ((Component)_labels[i]).gameObject.SetActive(false); } } } private unsafe static string KeyName(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 switch (k - 303) { case 4: case 5: return "Alt"; case 2: case 3: return "Ctrl"; case 0: case 1: return "Shift"; default: return ((object)(*(KeyCode*)(&k))/*cast due to .constrained prefix*/).ToString(); } } private TextMeshProUGUI GetLabel(int i) { //IL_0024: 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_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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0068: 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) while (_labels.Count <= i) { TMP_Text val = FontTemplate(); GameObject val2 = new GameObject("BaseOutlinesLabel", new Type[1] { typeof(RectTransform) }); RectTransform val3 = (RectTransform)val2.transform; ((Transform)val3).SetParent((Transform)(object)_rect, false); ((Transform)val3).SetAsLastSibling(); val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.zero; val3.pivot = new Vector2(0.5f, 0.5f); val3.sizeDelta = new Vector2(400f, 40f); TextMeshProUGUI val4 = val2.AddComponent<TextMeshProUGUI>(); if ((Object)(object)val != (Object)null) { ((TMP_Text)val4).font = val.font; ((TMP_Text)val4).fontSharedMaterial = val.fontSharedMaterial; } ((TMP_Text)val4).alignment = (TextAlignmentOptions)514; ((TMP_Text)val4).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val4).overflowMode = (TextOverflowModes)0; ((Graphic)val4).raycastTarget = false; _labels.Add(val4); } return _labels[i]; } private TMP_Text FontTemplate() { if ((Object)(object)_fontTemplate != (Object)null) { return _fontTemplate; } object? obj = AccessTools.Field(typeof(Minimap), "m_pinNamePrefab")?.GetValue(_minimap); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if ((Object)(object)val != (Object)null) { _fontTemplate = val.GetComponentInChildren<TMP_Text>(true); } if ((Object)(object)_fontTemplate == (Object)null) { TMP_Text[] componentsInChildren = ((Component)_minimap).GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val2 in componentsInChildren) { TextMeshProUGUI val3 = (TextMeshProUGUI)(object)((val2 is TextMeshProUGUI) ? val2 : null); if (val3 == null || !_labels.Contains(val3)) { _fontTemplate = val2; break; } } } return _fontTemplate; } } [BepInPlugin("LDT.BaseOutlines", "BaseOutlines", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "LDT.BaseOutlines"; public const string ModName = "BaseOutlines"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<KeyboardShortcut> ToggleKey; internal static ConfigEntry<KeyboardShortcut> LogNearbyKey; internal static ConfigEntry<string> IncludeFilter; internal static ConfigEntry<string> ExcludeFilter; internal static ConfigEntry<Color> WallFillColor; internal static ConfigEntry<Color> WallOutlineColor; internal static ConfigEntry<float> WallFillWidth; internal static ConfigEntry<float> WallOutlineWidth; internal static ConfigEntry<bool> ShowRooms; internal static ConfigEntry<Color> RoomColor; internal static ConfigEntry<float> MinRoomArea; internal static ConfigEntry<float> MaxRoomArea; internal static ConfigEntry<bool> NamingEnabled; internal static ConfigEntry<KeyCode> NameModifier; internal static ConfigEntry<Color> HoverColor; internal static ConfigEntry<Color> LabelColor; internal static ConfigEntry<Color> HintColor; internal static ConfigEntry<float> LabelSize; internal static ConfigEntry<float> LabelMinRoomPixels; internal static ConfigEntry<bool> ShowGenerated; internal static ConfigEntry<bool> GeneratedOnlyExplored; internal static ConfigEntry<Color> GeneratedWallColor; internal static ConfigEntry<Color> GeneratedOutlineColor; internal static ConfigEntry<Color> GeneratedRoomColor; internal static ConfigEntry<bool> ShowOnMinimap; internal static ConfigEntry<Color> StampColor; internal static ConfigEntry<float> StampSize; internal static ConfigEntry<float> StampMinPixels; internal static ConfigEntry<bool> ShowSpawnZones; internal static ConfigEntry<KeyboardShortcut> SpawnZoneKey; internal static ConfigEntry<bool> SpawnZonesWhileBuilding; internal static ConfigEntry<bool> SpawnZonesOnMinimap; internal static ConfigEntry<Color> SpawnZoneFill; internal static ConfigEntry<Color> SpawnZoneRing; internal static ConfigEntry<Color> SpawnZoneUnlitRing; internal static ConfigEntry<float> SpawnZoneRingWidth; internal static ConfigEntry<bool> SpawnZonesShowUnlit; private static bool s_hiddenWhileBuilding; private Harmony _harmony; internal static int StyleVersion { get; private set; } internal static bool SpawnZonesVisible { get { if (Enabled.Value) { if (!ShowSpawnZones.Value) { if (SpawnZonesWhileBuilding.Value && InBuildMode) { return !s_hiddenWhileBuilding; } return false; } return true; } return false; } } private static bool InBuildMode { get { if ((Object)(object)Player.m_localPlayer != (Object)null) { return ((Character)Player.m_localPlayer).InPlaceMode(); } return false; } } private static Color Rgb(byte r, byte g, byte b, byte a) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) return Color32.op_Implicit(new Color32(r, g, b, a)); } private void Awake() { //IL_0045: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_027a: 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_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_06a7: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Draw build piece outlines on the map."); ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "ToggleKey", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), "Key to toggle the outlines on/off."); LogNearbyKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "LogNearbyKey", new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>()), "Writes the names of all structures within 30 m to BepInEx/LogOutput.log. Use it next to a ruin to find piece names for the Include filter."); IncludeFilter = ((BaseUnityPlugin)this).Config.Bind<string>("Pieces", "Include", "wall,door,gate", "Comma-separated, case-insensitive. A structure is drawn if its prefab name contains any of these."); ExcludeFilter = ((BaseUnityPlugin)this).Config.Bind<string>("Pieces", "Exclude", "", "Comma-separated, case-insensitive. Structures whose prefab name contains any of these are never drawn."); WallFillColor = ((BaseUnityPlugin)this).Config.Bind<Color>("LargeMap", "WallColor", Rgb(226, 210, 168, byte.MaxValue), "Fill color of walls on the large map (parchment)."); WallOutlineColor = ((BaseUnityPlugin)this).Config.Bind<Color>("LargeMap", "OutlineColor", Rgb(52, 38, 28, 240), "Outline color around walls on the large map."); WallFillWidth = ((BaseUnityPlugin)this).Config.Bind<float>("LargeMap", "WallWidth", 3f, "Minimum width of the wall fill, in UI pixels."); WallOutlineWidth = ((BaseUnityPlugin)this).Config.Bind<float>("LargeMap", "OutlineWidth", 1f, "Width of the dark outline on each side of a wall, in UI pixels."); ShowRooms = ((BaseUnityPlugin)this).Config.Bind<bool>("LargeMap", "ShowRooms", true, "Fill the inside of closed buildings with a warm wash."); RoomColor = ((BaseUnityPlugin)this).Config.Bind<Color>("LargeMap", "RoomColor", Rgb(150, 105, 60, 120), "Color of the fill inside closed buildings (alpha = strength)."); MinRoomArea = ((BaseUnityPlugin)this).Config.Bind<float>("LargeMap", "MinRoomArea", 2f, "Enclosed areas smaller than this (m²) are not filled, e.g. gaps between double walls."); MaxRoomArea = ((BaseUnityPlugin)this).Config.Bind<float>("LargeMap", "MaxRoomArea", 600f, "Enclosed areas larger than this (m²) are not filled, e.g. the palisade around your whole base."); NamingEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Names", "Enabled", true, "Allow naming closed buildings on the large map, and show their names."); NameModifier = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Names", "ClickModifier", (KeyCode)308, "Hold this key and left-click a building on the large map to name it. Set to None to name with a plain click (may conflict with adding pins)."); HoverColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Names", "HoverColor", Rgb(235, 190, 120, 150), "Fill color of the building under the mouse cursor."); LabelColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Names", "LabelColor", Rgb(byte.MaxValue, 250, 240, byte.MaxValue), "Color of building names."); HintColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Names", "HintColor", Rgb(byte.MaxValue, 250, 240, 150), "Color of the 'click to name' hint."); LabelSize = ((BaseUnityPlugin)this).Config.Bind<float>("Names", "LabelSize", 18f, "Font size of building names."); LabelMinRoomPixels = ((BaseUnityPlugin)this).Config.Bind<float>("Names", "HideBelowPixels", 12f, "Hide a building's name when the building is smaller than this on screen (zoomed far out)."); ShowGenerated = ((BaseUnityPlugin)this).Config.Bind<bool>("Generated", "Enabled", true, "Also draw structures that are part of the world: ruins, abandoned houses, Fuling villages."); GeneratedOnlyExplored = ((BaseUnityPlugin)this).Config.Bind<bool>("Generated", "OnlyExplored", true, "Only add world structures once their spot on the map is explored, so the mod doesn't spoil anything."); GeneratedWallColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Generated", "FillColor", Rgb(214, 214, 210, byte.MaxValue), "Fill color of world-generated walls on the large map (light grey)."); GeneratedOutlineColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Generated", "OutlineColor", Rgb(56, 54, 50, 240), "Outline color of world-generated walls on the large map."); GeneratedRoomColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Generated", "RoomColor", Rgb(110, 106, 98, 110), "Fill color inside closed world-generated buildings."); ShowOnMinimap = ((BaseUnityPlugin)this).Config.Bind<bool>("Minimap", "Enabled", true, "Draw walls on the small corner minimap."); StampColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Minimap", "Color", Rgb(44, 32, 24, 230), "Color of the pixel-style walls on the minimap."); StampSize = ((BaseUnityPlugin)this).Config.Bind<float>("Minimap", "PixelSize", 1f, "Size of one wall 'pixel' on the minimap, in meters."); StampMinPixels = ((BaseUnityPlugin)this).Config.Bind<float>("Minimap", "MinScreenPixels", 2f, "When zoomed out, pixels are doubled in size until they're at least this many UI pixels."); ShowSpawnZones = ((BaseUnityPlugin)this).Config.Bind<bool>("SpawnZones", "Show", false, "Show the areas where monsters can't spawn (around workbenches, lit fires, etc.) as blue circles."); SpawnZoneKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("SpawnZones", "ToggleKey", new KeyboardShortcut((KeyCode)290, Array.Empty<KeyCode>()), "Key to show/hide spawn-proof zones."); SpawnZonesWhileBuilding = ((BaseUnityPlugin)this).Config.Bind<bool>("SpawnZones", "ShowWhileBuilding", true, "Also show the zones whenever you have the hammer out, even if they're toggled off."); SpawnZonesOnMinimap = ((BaseUnityPlugin)this).Config.Bind<bool>("SpawnZones", "ShowOnMinimap", true, "Show the zones on the small corner minimap too."); SpawnZoneFill = ((BaseUnityPlugin)this).Config.Bind<Color>("SpawnZones", "FillColor", Rgb(70, 140, byte.MaxValue, 30), "Fill color of the covered area (alpha = transparency)."); SpawnZoneRing = ((BaseUnityPlugin)this).Config.Bind<Color>("SpawnZones", "RingColor", Rgb(120, 175, byte.MaxValue, 160), "Color of the edge of each zone."); SpawnZoneUnlitRing = ((BaseUnityPlugin)this).Config.Bind<Color>("SpawnZones", "UnlitRingColor", Rgb(120, 175, byte.MaxValue, 70), "Edge color for fires without fuel: they don't protect until lit, so they get no fill."); SpawnZoneRingWidth = ((BaseUnityPlugin)this).Config.Bind<float>("SpawnZones", "RingWidth", 1.5f, "Width of the zone edges, in UI pixels."); SpawnZonesShowUnlit = ((BaseUnityPlugin)this).Config.Bind<bool>("SpawnZones", "ShowUnlitFires", false, "Also show a faint ring for fires and torches that are out of fuel (they don't protect until lit)."); IncludeFilter.SettingChanged += delegate { WallTracker.ResetFilters(); }; ExcludeFilter.SettingChanged += delegate { WallTracker.ResetFilters(); }; ((BaseUnityPlugin)this).Config.SettingChanged += delegate { StyleVersion++; BaseGeometry.Invalidate(); }; _harmony = new Harmony("LDT.BaseOutlines"); _harmony.PatchAll(); } private void Update() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (TextInput.IsVisible()) { return; } if (Pressed(ToggleKey.Value)) { Enabled.Value = !Enabled.Value; } if (Pressed(LogNearbyKey.Value) && (Object)(object)WallTracker.Instance != (Object)null) { WallTracker.Instance.LogNearby(); } if (!InBuildMode) { s_hiddenWhileBuilding = false; } if (!Pressed(SpawnZoneKey.Value)) { return; } if (SpawnZonesVisible) { ShowSpawnZones.Value = false; if (InBuildMode) { s_hiddenWhileBuilding = true; } } else { ShowSpawnZones.Value = true; s_hiddenWhileBuilding = false; } if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)1, SpawnZonesVisible ? "Spawn-proof zones: shown" : "Spawn-proof zones: hidden", 0, (Sprite)null, false, true); } } private static bool Pressed(KeyboardShortcut shortcut) { //IL_0002: 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_002a: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref shortcut)).MainKey == 0 || !ZInput.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey, true)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref shortcut)).Modifiers) { if (!ZInput.GetKey(modifier, true)) { return false; } } return true; } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } [HarmonyPatch(typeof(Minimap), "Start")] internal static class MinimapStartPatch { private static void Postfix(Minimap __instance) { if ((Object)(object)((Component)__instance).GetComponent<WallTracker>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<WallTracker>(); } MapOverlay.Attach(__instance, __instance.m_mapImageLarge, isLarge: true); MapOverlay.Attach(__instance, __instance.m_mapImageSmall, isLarge: false); } } internal static class RoomNames { private struct Entry { public Vector2 Pos; public string Name; } private static readonly List<Entry> s_entries = new List<Entry>(); private static string s_path; public static int Version { get; private set; } public static void Load(string path) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) s_path = path; s_entries.Clear(); Version++; if (!File.Exists(path)) { return; } try { string[] array = File.ReadAllLines(path); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ' ' }, 3); if (array2.Length == 3) { s_entries.Add(new Entry { Pos = new Vector2(float.Parse(array2[0], CultureInfo.InvariantCulture), float.Parse(array2[1], CultureInfo.InvariantCulture)), Name = array2[2] }); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not read " + path + ": " + ex.Message)); } } public static string Get(Room room) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (room == null) { return null; } foreach (Entry s_entry in s_entries) { if (room.Cells.Contains(BaseGeometry.CellKey(s_entry.Pos))) { return s_entry.Name; } } return null; } public static void Set(Room room, string name) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (room != null) { s_entries.RemoveAll((Entry e) => room.Cells.Contains(BaseGeometry.CellKey(e.Pos))); name = Clean(name); if (name.Length > 0) { s_entries.Add(new Entry { Pos = room.LabelPos, Name = name }); } Version++; Save(); } } private static string Clean(string name) { return (name ?? "").Replace('\r', ' ').Replace('\n', ' ').Replace('\t', ' ') .Trim(); } private static void Save() { //IL_002e: 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) if (s_path == null) { return; } try { List<string> list = new List<string>(); foreach (Entry s_entry in s_entries) { string[] array = new string[5]; float x = s_entry.Pos.x; array[0] = x.ToString("0.##", CultureInfo.InvariantCulture); array[1] = " "; x = s_entry.Pos.y; array[2] = x.ToString("0.##", CultureInfo.InvariantCulture); array[3] = " "; array[4] = s_entry.Name; list.Add(string.Concat(array)); } File.WriteAllLines(s_path, list); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not save " + s_path + ": " + ex.Message)); } } } internal class RoomNameReceiver : MonoBehaviour, TextReceiver { public Room Target; public string GetText() { return RoomNames.Get(Target) ?? ""; } public void SetText(string text) { RoomNames.Set(Target, text); } } internal struct SpawnZone { public Vector2 Pos; public float Radius; public bool Active; } internal static class SpawnZones { private class ZoneInfo { public float Radius; public Vector3 Offset; public bool NeedsFuel; } public static readonly Dictionary<ZDOID, SpawnZone> Zones = new Dictionary<ZDOID, SpawnZone>(); private const float RemovalRadius = 32f; private const int MissedScansBeforeRemoval = 5; private const float MaxHeight = 2000f; private static readonly Dictionary<int, ZoneInfo> s_infos = new Dictionary<int, ZoneInfo>(); private static readonly int s_creatorHash = StringExtensionMethods.GetStableHashCode("creator"); private static readonly int s_fuelHash = StringExtensionMethods.GetStableHashCode("fuel"); private static readonly Dictionary<ZDOID, int> s_missing = new Dictionary<ZDOID, int>(); private static readonly List<ZDOID> s_toRemove = new List<ZDOID>(); private static string s_path; private static bool s_dirty; public static int Version { get; private set; } public static bool IsDirty => s_dirty; public static void Scan(Dictionary<ZDOID, ZDO> all, Vector2 playerPos) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0066: 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_0077: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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_00e3: 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_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_0213: 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_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) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) bool flag = false; Vector2 val2; foreach (KeyValuePair<ZDOID, ZDO> item in all) { ZDO value = item.Value; if (value == null) { continue; } ZoneInfo info = GetInfo(value.GetPrefab()); if (info == null || value.GetLong(s_creatorHash, 0L) == 0L) { continue; } Vector3 position = value.GetPosition(); if (position.y > 2000f) { continue; } Vector3 val = position + value.GetRotation() * info.Offset; SpawnZone value2 = new SpawnZone { Pos = new Vector2(val.x, val.z), Radius = info.Radius, Active = (!info.NeedsFuel || value.GetFloat(s_fuelHash, 0f) > 0f) }; if (Zones.TryGetValue(item.Key, out var value3) && value3.Active == value2.Active) { val2 = value3.Pos - value2.Pos; if (!(((Vector2)(ref val2)).sqrMagnitude > 0.0001f) && !(Mathf.Abs(value3.Radius - value2.Radius) > 0.01f)) { continue; } } Zones[item.Key] = value2; flag = true; } s_toRemove.Clear(); foreach (KeyValuePair<ZDOID, SpawnZone> zone in Zones) { if (all.ContainsKey(zone.Key)) { s_missing.Remove(zone.Key); continue; } val2 = zone.Value.Pos - playerPos; if (((Vector2)(ref val2)).sqrMagnitude > 1024f) { s_missing.Remove(zone.Key); continue; } s_missing.TryGetValue(zone.Key, out var value4); value4++; if (value4 >= 5) { s_toRemove.Add(zone.Key); } else { s_missing[zone.Key] = value4; } } foreach (ZDOID item2 in s_toRemove) { Zones.Remove(item2); s_missing.Remove(item2); flag = true; } if (flag) { s_dirty = true; Version++; } } private static ZoneInfo GetInfo(int prefabHash) { //IL_005a: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) if (s_infos.TryGetValue(prefabHash, out var value)) { return value; } value = null; GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(prefabHash) : null); if ((Object)(object)val != (Object)null) { Fireplace component = val.GetComponent<Fireplace>(); EffectArea[] componentsInChildren = val.GetComponentsInChildren<EffectArea>(true); foreach (EffectArea val2 in componentsInChildren) { if ((val2.m_type & 4) != 0 && TryGetFootprint(((Component)val2).GetComponent<Collider>(), out var worldCenter, out var radius) && (value == null || !(radius <= value.Radius))) { value = new ZoneInfo { Radius = radius, Offset = val.transform.InverseTransformPoint(worldCenter), NeedsFuel = ((Object)(object)component != (Object)null && !HasInfiniteFuel(component) && (StartsSwitchedOff(((Component)val2).transform, val.transform) || UnderBurningObject(component, ((Component)val2).transform))) }; } } } s_infos[prefabHash] = value; return value; } public static string Describe(GameObject prefab, ZDO zdo) { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) EffectArea[] componentsInChildren = prefab.GetComponentsInChildren<EffectArea>(true); if (componentsInChildren.Length == 0) { return null; } StringBuilder stringBuilder = new StringBuilder(); ZoneInfo info = GetInfo(zdo.GetPrefab()); stringBuilder.Append((info == null) ? "NOT drawn" : $"DRAWN r={info.Radius:0.#} m, needs fuel={info.NeedsFuel}, fuel={zdo.GetFloat(s_fuelHash, -1f):0.#}"); Fireplace component = prefab.GetComponent<Fireplace>(); EffectArea[] array = componentsInChildren; foreach (EffectArea val in array) { Collider component2 = ((Component)val).GetComponent<Collider>(); Vector3 worldCenter; float radius; string arg = (((Object)(object)component2 == (Object)null) ? "no collider" : (TryGetFootprint(component2, out worldCenter, out radius) ? $"{((object)component2).GetType().Name} r={radius:0.#}" : ((object)component2).GetType().Name)); stringBuilder.Append($"\n area '{((Object)val).name}': type={val.m_type}, {arg}, " + $"starts off={StartsSwitchedOff(((Component)val).transform, prefab.transform)}, " + $"fire piece={(Object)(object)component != (Object)null}" + (((Object)(object)component != (Object)null) ? $", under burning object={UnderBurningObject(component, ((Component)val).transform)}" : "")); } return stringBuilder.ToString(); } private static bool TryGetFootprint(Collider col, out Vector3 worldCenter, out float radius) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_002b: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) worldCenter = Vector3.zero; radius = 0f; if ((Object)(object)col == (Object)null) { return false; } Transform transform = ((Component)col).transform; Vector3 lossyScale = transform.lossyScale; float num = Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.z)); SphereCollider val = (SphereCollider)(object)((col is SphereCollider) ? col : null); if (val == null) { CapsuleCollider val2 = (CapsuleCollider)(object)((col is CapsuleCollider) ? col : null); if (val2 == null) { BoxCollider val3 = (BoxCollider)(object)((col is BoxCollider) ? col : null); if (val3 != null) { worldCenter = transform.TransformPoint(val3.center); radius = Mathf.Max(val3.size.x * Mathf.Abs(lossyScale.x), val3.size.z * Mathf.Abs(lossyScale.z)) * 0.5f; return radius > 0f; } return false; } worldCenter = transform.TransformPoint(val2.center); radius = ((val2.direction == 1) ? (val2.radius * num) : (Mathf.Max(val2.radius, val2.height * 0.5f) * num)); return radius > 0f; } worldCenter = transform.TransformPoint(val.center); radius = val.radius * num; return radius > 0f; } private static bool StartsSwitchedOff(Transform area, Transform root) { Transform val = area; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root) { if (!((Component)val).gameObject.activeSelf) { return true; } val = val.parent; } return false; } private static bool UnderBurningObject(Fireplace fire, Transform area) { string[] array = new string[3] { "m_enabledObject", "m_enabledObjectLow", "m_enabledObjectHigh" }; foreach (string text in array) { object? obj = AccessTools.Field(typeof(Fireplace), text)?.GetValue(fire); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if ((Object)(object)val != (Object)null && area.IsChildOf(val.transform)) { return true; } } return false; } private static bool HasInfiniteFuel(Fireplace fire) { FieldInfo fieldInfo = AccessTools.Field(typeof(Fireplace), "m_infiniteFuel"); bool flag = default(bool); int num; if (fieldInfo != null) { object value = fieldInfo.GetValue(fire); if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } public static void Load(string path) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) s_path = path; Zones.Clear(); s_missing.Clear(); Version++; if (!File.Exists(path)) { return; } try { string[] array = File.ReadAllLines(path); ZDOID key = default(ZDOID); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ' ' }); if (array2.Length == 6) { ((ZDOID)(ref key))..ctor(long.Parse(array2[0], CultureInfo.InvariantCulture), uint.Parse(array2[1], CultureInfo.InvariantCulture)); Zones[key] = new SpawnZone { Pos = new Vector2(F(array2[2]), F(array2[3])), Radius = F(array2[4]), Active = (array2[5] == "1") }; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not read " + path + ": " + ex.Message)); } } public static void Save() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0083: 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) if (s_path == null || !s_dirty) { return; } try { List<string> list = new List<string>(); foreach (KeyValuePair<ZDOID, SpawnZone> zone in Zones) { string[] array = new string[6]; ZDOID key = zone.Key; array[0] = ((ZDOID)(ref key)).UserID.ToString(CultureInfo.InvariantCulture); key = zone.Key; array[1] = ((ZDOID)(ref key)).ID.ToString(CultureInfo.InvariantCulture); array[2] = S(zone.Value.Pos.x); array[3] = S(zone.Value.Pos.y); array[4] = S(zone.Value.Radius); array[5] = (zone.Value.Active ? "1" : "0"); list.Add(string.Join(" ", array)); } File.WriteAllLines(s_path, list); s_dirty = false; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not save " + s_path + ": " + ex.Message)); } } private static float F(string s) { return float.Parse(s, CultureInfo.InvariantCulture); } private static string S(float v) { return v.ToString("0.###", CultureInfo.InvariantCulture); } } internal struct WallSeg { public int Prefab; public Vector2 A; public Vector2 B; public float HalfWidth; public bool Generated; } internal class Footprint { public Vector2 Center; public Vector2 Half; } internal class WallTracker : MonoBehaviour { private class AreaEntry { public int Count; public float Nearest; public string Details; } public readonly Dictionary<ZDOID, WallSeg> Walls = new Dictionary<ZDOID, WallSeg>(); private const float ScanInterval = 2f; private const float SaveInterval = 30f; private const float RemovalRadius = 32f; private const int MissedScansBeforeRemoval = 5; private const float DebugLogRadius = 30f; private const float MaxStructureHeight = 2000f; private static readonly FieldRef<ZDOMan, Dictionary<ZDOID, ZDO>> s_objectsById = AccessTools.FieldRefAccess<ZDOMan, Dictionary<ZDOID, ZDO>>("m_objectsByID"); private static readonly FieldInfo s_exploredField = AccessTools.Field(typeof(Minimap), "m_explored"); private static readonly FieldInfo s_exploredOthersField = AccessTools.Field(typeof(Minimap), "m_exploredOthers"); private static readonly Dictionary<int, Footprint> s_footprints = new Dictionary<int, Footprint>(); private static readonly int s_creatorHash = StringExtensionMethods.GetStableHashCode("creator"); private static string[] s_include; private static string[] s_exclude; private readonly Dictionary<ZDOID, int> _missing = new Dictionary<ZDOID, int>(); private readonly List<ZDOID> _toRemove = new List<ZDOID>(); private string _savePath; private float _scanTimer; private float _lastSave; private bool _dirty; private object _explored; private object _exploredOthers; public static WallTracker Instance { get; private set; } public static int Version { get; private set; } public string DataDir { get; private set; } public string WorldKey { get; private set; } public static void ResetFilters() { s_footprints.Clear(); s_include = null; s_exclude = null; } private void Awake() { Instance = this; } private void OnDestroy() { if (_dirty || SpawnZones.IsDirty) { Save(); } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void Update() { if ((Object)(object)ZNet.instance == (Object)null || ZDOMan.instance == null || (Object)(object)ZNetScene.instance == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null) { return; } if (_savePath == null) { Load(); } _scanTimer -= Time.deltaTime; if (!(_scanTimer > 0f)) { _scanTimer = 2f; Scan(); if ((_dirty || SpawnZones.IsDirty) && Time.time - _lastSave > 30f) { Save(); } } } private void Scan() { //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_01ad: 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_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: 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_01fb: Unknown result type (m