Decompiled source of MimesisMap v1.8.2
MimesisMap.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using DunGen; using HarmonyLib; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using MimesisMap; using Mimic.Actors; using Pathfinding; using Steamworks; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Utilities; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(Plugin), "MimesisMap", "1.8.2", "StimDesu", null)] [assembly: MelonGame("ReLUGames", "MIMESIS")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MimesisMap")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.8.2.0")] [assembly: AssemblyInformationalVersion("1.8.2+2fc110efa04c183809a9db0a77c676d07d7f5e77")] [assembly: AssemblyProduct("MimesisMap")] [assembly: AssemblyTitle("MimesisMap")] [assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was fully created with the assistance of Generative AI (code, documentation and icon), directed and tested by StimDesu.")] [assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic (Claude)")] [assembly: AssemblyVersion("1.8.2.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 MimesisMap { public enum RevealMode { Explored, Full } public enum MapStyle { Plain, Graphic } public enum Orientation { FollowView, NorthUp } public enum KeyMode { Hold, Toggle } public enum MiniShape { Circle, Square } public enum MiniAnchor { TopLeft, TopRight, BottomLeft, BottomRight, Custom } internal static class Cfg { private static MelonPreferences_Category _cat; public static MelonPreferences_Entry<Lang> Language; public static MelonPreferences_Entry<RevealMode> Reveal; public static MelonPreferences_Entry<MapStyle> Style; public static MelonPreferences_Entry<bool> NeighborHints; public static MelonPreferences_Entry<bool> ShowOutdoor; public static MelonPreferences_Entry<string> SettingsKey; public static MelonPreferences_Entry<string> BigMapKey; public static MelonPreferences_Entry<KeyMode> BigMapKeyMode; public static MelonPreferences_Entry<float> BigMapSize; public static MelonPreferences_Entry<float> BigMapZoom; public static MelonPreferences_Entry<float> BigMapOpacity; public static MelonPreferences_Entry<float> BigMapMarginTop; public static MelonPreferences_Entry<float> BigMapMarginBottom; public static MelonPreferences_Entry<float> BigMapMarginSide; public static MelonPreferences_Entry<Orientation> BigMapRotateE; public static MelonPreferences_Entry<bool> BigMapInteractive; public static MelonPreferences_Entry<bool> MiniEnabled; public static MelonPreferences_Entry<string> MiniKey; public static MelonPreferences_Entry<float> MiniRange; public static MelonPreferences_Entry<float> MiniSize; public static MelonPreferences_Entry<MiniShape> MiniShapeE; public static MelonPreferences_Entry<Orientation> MiniOrientation; public static MelonPreferences_Entry<MiniAnchor> MiniAnchorE; public static MelonPreferences_Entry<float> MiniOffsetX; public static MelonPreferences_Entry<float> MiniOffsetY; public static MelonPreferences_Entry<float> MiniOpacity; public static MelonPreferences_Entry<bool> ShowLoot; public static MelonPreferences_Entry<bool> LootOnlyRevealed; public static MelonPreferences_Entry<bool> ShowTeammates; public static MelonPreferences_Entry<bool> ShowNames; public static MelonPreferences_Entry<bool> ShowMonsters; public static MelonPreferences_Entry<bool> ShowExit; public static MelonPreferences_Entry<bool> ShowExitPath; public static MelonPreferences_Entry<bool> AnimatePath; public static MelonPreferences_Entry<float> MarkerScale; public static MelonPreferences_Entry<bool> RevealByTeammates; public static MelonPreferences_Entry<bool> ShareSteam; public static MelonPreferences_Entry<float> Resolution; public static Bind BSettings; public static Bind BBigMap; public static Bind BMini; public static Bind BZoomIn; public static Bind BZoomOut; public static Bind BRecenter; public static Bind[] Binds; public const string WheelUp = "WheelUp"; public const string WheelDown = "WheelDown"; public static void Init() { _cat = MelonPreferences.CreateCategory("MimesisMap", "Mimesis Map"); Language = _cat.CreateEntry<Lang>("Language", Lang.Auto, "UI language", "Auto = system language, Russian, English", false, false, (ValueValidator)null, (string)null); Reveal = _cat.CreateEntry<RevealMode>("RevealMode", RevealMode.Explored, "Reveal mode", "Explored = rooms open as you visit them, Full = whole map visible", false, false, (ValueValidator)null, (string)null); Style = _cat.CreateEntry<MapStyle>("Style", MapStyle.Plain, "Map style", "Plain = schematic floor plan, Graphic = real top-down view from a camera above you", false, false, (ValueValidator)null, (string)null); NeighborHints = _cat.CreateEntry<bool>("NeighborHints", true, "Hint unexplored neighbours", "Faintly draw unexplored rooms adjacent to explored ones", false, false, (ValueValidator)null, (string)null); ShowOutdoor = _cat.CreateEntry<bool>("ShowOutdoor", true, "Show outdoor area", (string)null, false, false, (ValueValidator)null, (string)null); SettingsKey = _cat.CreateEntry<string>("SettingsKey", "F8", "Settings window key", (string)null, false, false, (ValueValidator)null, (string)null); BigMapKey = _cat.CreateEntry<string>("BigMapKey", "Tab", "Big map key", (string)null, false, false, (ValueValidator)null, (string)null); BigMapKeyMode = _cat.CreateEntry<KeyMode>("BigMapKeyMode", KeyMode.Hold, "Big map key mode", "Hold = visible while held, Toggle = press to open/close", false, false, (ValueValidator)null, (string)null); BigMapSize = _cat.CreateEntry<float>("BigMapSize", 1f, "Big map size (fraction of the free screen area)", (string)null, false, false, (ValueValidator)null, (string)null); BigMapZoom = _cat.CreateEntry<float>("BigMapZoom", 1f, "Big map zoom (1 = fit whole map)", (string)null, false, false, (ValueValidator)null, (string)null); BigMapRotateE = _cat.CreateEntry<Orientation>("BigMapOrientation", Orientation.FollowView, "Big map orientation", "FollowView = rotates with your view, NorthUp = north always up", false, false, (ValueValidator)null, (string)null); BigMapInteractive = _cat.CreateEntry<bool>("BigMapInteractive", true, "Big map shows the cursor in Toggle mode (drag = pan)", (string)null, false, false, (ValueValidator)null, (string)null); BigMapMarginTop = _cat.CreateEntry<float>("BigMapMarginTop", 20f, "Big map top margin (px @1080p)", (string)null, false, false, (ValueValidator)null, (string)null); BigMapMarginBottom = _cat.CreateEntry<float>("BigMapMarginBottom", 165f, "Big map bottom margin, keeps the hotbar visible (px @1080p)", (string)null, false, false, (ValueValidator)null, (string)null); BigMapMarginSide = _cat.CreateEntry<float>("BigMapMarginSide", 510f, "Big map side margin, keeps health/radiation bars visible (px @1080p)", (string)null, false, false, (ValueValidator)null, (string)null); BigMapOpacity = _cat.CreateEntry<float>("BigMapOpacity", 0.85f, "Big map background opacity", (string)null, false, false, (ValueValidator)null, (string)null); MiniEnabled = _cat.CreateEntry<bool>("MinimapEnabled", true, "Minimap enabled", (string)null, false, false, (ValueValidator)null, (string)null); MiniKey = _cat.CreateEntry<string>("MinimapKey", "F6", "Minimap toggle key", (string)null, false, false, (ValueValidator)null, (string)null); MiniRange = _cat.CreateEntry<float>("MinimapRange", 25f, "Minimap range (metres from player to edge)", (string)null, false, false, (ValueValidator)null, (string)null); MiniSize = _cat.CreateEntry<float>("MinimapSize", 260f, "Minimap size (px @1080p)", (string)null, false, false, (ValueValidator)null, (string)null); MiniShapeE = _cat.CreateEntry<MiniShape>("MinimapShape", MiniShape.Circle, "Minimap shape", (string)null, false, false, (ValueValidator)null, (string)null); MiniOrientation = _cat.CreateEntry<Orientation>("MinimapOrientation", Orientation.FollowView, "Minimap orientation", "FollowView = rotates with your view, NorthUp = north always up", false, false, (ValueValidator)null, (string)null); MiniAnchorE = _cat.CreateEntry<MiniAnchor>("MinimapAnchor", MiniAnchor.TopRight, "Minimap screen corner", (string)null, false, false, (ValueValidator)null, (string)null); MiniOffsetX = _cat.CreateEntry<float>("MinimapOffsetX", 20f, "Minimap offset X", (string)null, false, false, (ValueValidator)null, (string)null); MiniOffsetY = _cat.CreateEntry<float>("MinimapOffsetY", 20f, "Minimap offset Y", (string)null, false, false, (ValueValidator)null, (string)null); MiniOpacity = _cat.CreateEntry<float>("MinimapOpacity", 0.6f, "Minimap background opacity", (string)null, false, false, (ValueValidator)null, (string)null); ShowLoot = _cat.CreateEntry<bool>("ShowLoot", true, "Show loot", (string)null, false, false, (ValueValidator)null, (string)null); LootOnlyRevealed = _cat.CreateEntry<bool>("LootOnlyRevealed", true, "Show loot only in explored rooms", (string)null, false, false, (ValueValidator)null, (string)null); ShowTeammates = _cat.CreateEntry<bool>("ShowTeammates", false, "Show teammates", (string)null, false, false, (ValueValidator)null, (string)null); ShowMonsters = _cat.CreateEntry<bool>("ShowMonsters", false, "Show monsters (mimics included)", (string)null, false, false, (ValueValidator)null, (string)null); ShowNames = _cat.CreateEntry<bool>("ShowNames", true, "Show teammate names on big map", (string)null, false, false, (ValueValidator)null, (string)null); ShowExit = _cat.CreateEntry<bool>("ShowExit", true, "Mark building exits and the entrance room", (string)null, false, false, (ValueValidator)null, (string)null); ShowExitPath = _cat.CreateEntry<bool>("ShowExitPath", true, "Shortest path to the nearest known exit", (string)null, false, false, (ValueValidator)null, (string)null); AnimatePath = _cat.CreateEntry<bool>("AnimatePathArrows", true, "Arrows on the exit path move towards the exit", (string)null, false, false, (ValueValidator)null, (string)null); MarkerScale = _cat.CreateEntry<float>("MarkerScale", 1f, "Marker scale", (string)null, false, false, (ValueValidator)null, (string)null); RevealByTeammates = _cat.CreateEntry<bool>("RevealByTeammates", true, "Reveal rooms where teammates have been", (string)null, false, false, (ValueValidator)null, (string)null); ShareSteam = _cat.CreateEntry<bool>("ShareViaSteam", true, "Exchange explored rooms with other players that have this mod", (string)null, false, false, (ValueValidator)null, (string)null); Resolution = _cat.CreateEntry<float>("MapResolution", 5f, "Map texels per metre (rebuild on next level)", (string)null, false, false, (ValueValidator)null, (string)null); BSettings = new Bind("Окно настроек", "Settings window", SettingsKey, _cat.CreateEntry<string>("SettingsKeyAlt", "", "Settings window key (alternative)", (string)null, false, false, (ValueValidator)null, (string)null)); BBigMap = new Bind("Большая карта", "Big map", BigMapKey, _cat.CreateEntry<string>("BigMapKeyAlt", "", "Big map key (alternative)", (string)null, false, false, (ValueValidator)null, (string)null)); BMini = new Bind("Миникарта вкл/выкл", "Minimap on/off", MiniKey, _cat.CreateEntry<string>("MinimapKeyAlt", "", "Minimap toggle key (alternative)", (string)null, false, false, (ValueValidator)null, (string)null)); BZoomIn = new Bind("Приблизить большую карту", "Big map zoom in", _cat.CreateEntry<string>("ZoomInKey", "Equals", "Big map zoom in", (string)null, false, false, (ValueValidator)null, (string)null), _cat.CreateEntry<string>("ZoomInKeyAlt", "WheelUp", "Big map zoom in (alternative)", (string)null, false, false, (ValueValidator)null, (string)null)); BZoomOut = new Bind("Отдалить большую карту", "Big map zoom out", _cat.CreateEntry<string>("ZoomOutKey", "Minus", "Big map zoom out", (string)null, false, false, (ValueValidator)null, (string)null), _cat.CreateEntry<string>("ZoomOutKeyAlt", "WheelDown", "Big map zoom out (alternative)", (string)null, false, false, (ValueValidator)null, (string)null)); BRecenter = new Bind("Большая карта: к себе", "Big map: recentre", _cat.CreateEntry<string>("RecenterKey", "R", "Big map recenter", (string)null, false, false, (ValueValidator)null, (string)null), _cat.CreateEntry<string>("RecenterKeyAlt", "Home", "Big map recenter (alternative)", (string)null, false, false, (ValueValidator)null, (string)null)); Binds = new Bind[6] { BBigMap, BZoomIn, BZoomOut, BRecenter, BMini, BSettings }; } public static void ResetAll() { foreach (MelonPreferences_Entry entry in _cat.Entries) { try { entry.ResetToDefault(); } catch (Exception ex) { MelonLogger.Warning("Reset " + entry.Identifier + " failed: " + ex.Message); } } Save(); MelonLogger.Msg("[MimesisMap] Settings reset to defaults"); } public static void Save() { try { MelonPreferences.Save(); } catch (Exception ex) { MelonLogger.Warning("Save failed: " + ex.Message); } } public static bool TryKey(string name, out Key key) { key = (Key)0; if (string.IsNullOrEmpty(name)) { return false; } if (Enum.TryParse<Key>(name, ignoreCase: true, out key)) { return (int)key != 0; } return false; } private static ButtonControl MouseButton(Mouse m, string name) { return (ButtonControl)(name switch { "MouseMiddle" => m.middleButton, "MouseRight" => m.rightButton, "MouseBack" => m.backButton, "MouseForward" => m.forwardButton, _ => null, }); } public static bool PressedName(string name) { //IL_0027: 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_009c: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(name)) { return false; } try { Mouse current = Mouse.current; if (name == "WheelUp") { return current != null && ((InputControl<Vector2>)(object)current.scroll).ReadValue().y > 0.01f; } if (name == "WheelDown") { return current != null && ((InputControl<Vector2>)(object)current.scroll).ReadValue().y < -0.01f; } ButtonControl val = ((current != null) ? MouseButton(current, name) : null); if (val != null) { return val.wasPressedThisFrame; } Keyboard current2 = Keyboard.current; Key key; return current2 != null && TryKey(name, out key) && ((ButtonControl)current2[key]).wasPressedThisFrame; } catch { return false; } } public static bool HeldName(string name) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(name) || name == "WheelUp" || name == "WheelDown") { return false; } try { Mouse current = Mouse.current; ButtonControl val = ((current != null) ? MouseButton(current, name) : null); if (val != null) { return val.isPressed; } Keyboard current2 = Keyboard.current; Key key; return current2 != null && TryKey(name, out key) && ((ButtonControl)current2[key]).isPressed; } catch { return false; } } public static string Pretty(string name) { switch (name) { case "": case null: return "—"; case "WheelUp": return Loc.T("Колесо вверх", "Wheel up"); case "WheelDown": return Loc.T("Колесо вниз", "Wheel down"); case "MouseMiddle": return Loc.T("Средняя кн. мыши", "Middle mouse"); case "MouseRight": return Loc.T("Правая кн. мыши", "Right mouse"); case "MouseBack": return Loc.T("Мышь: назад", "Mouse back"); case "MouseForward": return Loc.T("Мышь: вперёд", "Mouse forward"); case "Equals": return "="; case "Minus": return "-"; default: return name; } } } internal sealed class Bind { private readonly string _ru; private readonly string _en; public readonly MelonPreferences_Entry<string> Main; public readonly MelonPreferences_Entry<string> Alt; public string Label => Loc.T(_ru, _en); public bool Pressed { get { if (!Cfg.PressedName(Main.Value)) { return Cfg.PressedName(Alt.Value); } return true; } } public bool Held { get { if (!Cfg.HeldName(Main.Value)) { return Cfg.HeldName(Alt.Value); } return true; } } public string Text { get { bool flag = !string.IsNullOrEmpty(Main.Value); bool flag2 = !string.IsNullOrEmpty(Alt.Value); if (flag && flag2) { return Cfg.Pretty(Main.Value) + " / " + Cfg.Pretty(Alt.Value); } if (!flag) { if (!flag2) { return "—"; } return Cfg.Pretty(Alt.Value); } return Cfg.Pretty(Main.Value); } } public Bind(string ru, string en, MelonPreferences_Entry<string> main, MelonPreferences_Entry<string> alt) { _ru = ru; _en = en; Main = main; Alt = alt; } } internal static class ExitPath { public static readonly List<Vector3> Path = new List<Vector3>(); public static int TargetExit = -1; private static NavMeshPath _nav; private static readonly List<Vector3> Tmp = new List<Vector3>(); private static Seeker _seeker; private static bool _astarBroken; public static void Update(MapModel model, Vector3 from, int fromTile, bool full) { //IL_0026: 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_006a: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Path.Clear(); TargetExit = -1; if (model == null || model.Flat || fromTile < 0) { return; } float num = float.MaxValue; NavMeshHit val = default(NavMeshHit); bool flag = NavMesh.SamplePosition(from, ref val, 3f, -1); for (int i = 0; i < model.Exits.Count; i++) { ExitInfo exit = model.Exits[i]; if (!exit.ToIndoor && Known(model, exit.Tile, full)) { float num2 = AStar(model, from, exit.Pos, full); if (num2 < 0f && flag) { num2 = NavPath(model, ((NavMeshHit)(ref val)).position, exit.Pos, full); } if (num2 < 0f) { num2 = DoorPath(model, from, fromTile, exit, full); } if (!(num2 < 0f) && !(num2 >= num)) { num = num2; TargetExit = i; Path.Clear(); Path.AddRange(Tmp); } } } } private static float AStar(MapModel model, Vector3 from, Vector3 to, bool full) { //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_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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00fb: 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) Tmp.Clear(); if (_astarBroken || (Object)(object)AstarPath.active == (Object)null) { return -1f; } try { if ((Object)(object)_seeker == (Object)null) { GameObject val = new GameObject("MimesisMapSeeker"); Object.DontDestroyOnLoad((Object)val); _seeker = val.AddComponent<Seeker>(); val.AddComponent<FunnelModifier>(); } Vector3 position = AstarPath.active.GetNearest(from).position; Vector3 position2 = AstarPath.active.GetNearest(to).position; Path obj = _seeker.StartPath(position, position2); obj.BlockUntilCalculated(); List<Vector3> vectorPath = obj.vectorPath; if (obj.error || vectorPath == null || vectorPath.Count < 2 || Vector3.Distance(vectorPath[vectorPath.Count - 1], position2) > 1.5f) { return -1f; } float num = 0f; for (int i = 0; i < vectorPath.Count; i++) { if (i > 0) { num += Vector3.Distance(vectorPath[i - 1], vectorPath[i]); if (!full && !SegmentKnown(model, vectorPath[i - 1], vectorPath[i])) { Tmp.Clear(); return -1f; } } Tmp.Add(vectorPath[i]); } return num; } catch (Exception ex) { _astarBroken = true; MelonLogger.Warning("[MimesisMap] A* path failed, using fallbacks: " + ex.Message); Tmp.Clear(); return -1f; } } private static bool Known(MapModel m, int tile, bool full) { if (!full) { if (tile >= 0) { return m.Tiles[tile].Revealed; } return false; } return true; } private static float NavPath(MapModel model, Vector3 from, Vector3 to, bool full) { //IL_000a: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_004b: 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) //IL_0085: 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_00a0: 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) Tmp.Clear(); NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(to, ref val, 3f, -1)) { return -1f; } if (_nav == null) { _nav = new NavMeshPath(); } if (!NavMesh.CalculatePath(from, ((NavMeshHit)(ref val)).position, -1, _nav) || (int)_nav.status != 0) { return -1f; } Vector3[] corners = _nav.corners; if (corners == null || corners.Length < 2) { return -1f; } float num = 0f; for (int i = 0; i < corners.Length; i++) { if (i > 0) { num += Vector3.Distance(corners[i - 1], corners[i]); if (!full && !SegmentKnown(model, corners[i - 1], corners[i])) { return -1f; } } Tmp.Add(corners[i]); } return num; } private static bool SegmentKnown(MapModel model, Vector3 a, Vector3 b) { //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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //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_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) //IL_003f: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(1, Mathf.CeilToInt(Vector3.Distance(a, b) / 1.5f)); for (int i = 0; i <= num; i++) { Vector3 p = Vector3.Lerp(a, b, (float)i / (float)num) + Vector3.up * 0.3f; int num2 = model.FindTile(p); if (num2 >= 0 && !model.Tiles[num2].Revealed) { return false; } } return true; } private static float DoorPath(MapModel model, Vector3 from, int fromTile, ExitInfo exit, bool full) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0207: 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) //IL_0170: Unknown result type (might be due to invalid IL or missing references) Tmp.Clear(); List<(Vector3, int)> list = new List<(Vector3, int)> { (from, fromTile), (exit.Pos, exit.Tile) }; for (int i = 0; i < model.Tiles.Count; i++) { if (!full && !model.Tiles[i].Revealed) { continue; } foreach (Vector3 door in model.Tiles[i].Doors) { list.Add((door, i)); } } int count = list.Count; float[] array = new float[count]; int[] array2 = new int[count]; bool[] array3 = new bool[count]; for (int j = 0; j < count; j++) { array[j] = float.MaxValue; array2[j] = -1; } array[0] = 0f; for (int k = 0; k < count; k++) { int num = -1; float num2 = float.MaxValue; for (int l = 0; l < count; l++) { if (!array3[l] && array[l] < num2) { num2 = array[l]; num = l; } } if (num < 0 || num == 1) { break; } array3[num] = true; for (int m = 0; m < count; m++) { if (array3[m] || m == num) { continue; } float num3 = Vector3.Distance(list[num].Item1, list[m].Item1); float num4; if (list[num].Item2 == list[m].Item2) { num4 = num3; } else { if (!(num3 < 0.75f)) { continue; } num4 = num3; } if (array[num] + num4 < array[m]) { array[m] = array[num] + num4; array2[m] = num; } } } if (array[1] == float.MaxValue) { return -1f; } for (int num5 = 1; num5 >= 0; num5 = array2[num5]) { Tmp.Add(list[num5].Item1); } Tmp.Reverse(); return array[1]; } } internal static class GameAccess { private static readonly PropertyInfo CameraManProp = AccessTools.Property(typeof(Hub), "cameraman"); private static readonly PropertyInfo UiManProp = AccessTools.Property(typeof(Hub), "uiman"); private static readonly FieldInfo DispatcherField = AccessTools.Field(typeof(Hub), "steamInviteDispatcher"); public static readonly List<ProtoActor> Players = new List<ProtoActor>(); public static readonly List<ProtoActor> Monsters = new List<ProtoActor>(); public static ProtoActor LocalPlayer; public static readonly List<LootingLevelObject> Loot = new List<LootingLevelObject>(); private static float _nextActorScan; private static float _nextLootScan; public static GameMainBase CurrentMain() { try { GameMainBase val = default(GameMainBase); return ((Object)(object)Hub.s != (Object)null && Hub.TryGetMain(ref val)) ? val : null; } catch { return null; } } public static bool MenuOpen() { try { int result; if ((Object)(object)Hub.s != (Object)null) { object? obj = UiManProp?.GetValue(Hub.s); UIManager val = (UIManager)((obj is UIManager) ? obj : null); if (val != null && (Object)(object)val != (Object)null) { result = (val.isGameMenuOpen ? 1 : 0); goto IL_003e; } } result = 0; goto IL_003e; IL_003e: return (byte)result != 0; } catch { return false; } } public static List<Dungeon> FindDungeons() { List<Dungeon> list = new List<Dungeon>(); try { Dungeon[] array = Object.FindObjectsByType<Dungeon>((FindObjectsSortMode)0); foreach (Dungeon val in array) { if ((Object)(object)val != (Object)null && val.AllTiles != null && val.AllTiles.Count > 0 && (Object)(object)val.AllTiles[0] != (Object)null) { list.Add(val); } } } catch { } list.Sort(delegate(Dungeon a, Dungeon b) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)a.AllTiles[0]).transform.position; Vector3 position2 = ((Component)b.AllTiles[0]).transform.position; int num = position.x.CompareTo(position2.x); return (num == 0) ? position.z.CompareTo(position2.z) : num; }); return list; } public static int DungeonSeed() { try { GameMainBase obj = CurrentMain(); GamePlayScene val = (GamePlayScene)(object)((obj is GamePlayScene) ? obj : null); return (val != null) ? val.RandDungeonSeed : 0; } catch { return 0; } } public static RuntimeDungeon FindRuntimeDungeon() { try { RuntimeDungeon[] array = Object.FindObjectsByType<RuntimeDungeon>((FindObjectsSortMode)0); foreach (RuntimeDungeon val in array) { object obj; if (!((Object)(object)val != (Object)null)) { obj = null; } else { DungeonGenerator generator = val.Generator; obj = ((generator != null) ? generator.CurrentDungeon : null); } Dungeon val2 = (Dungeon)obj; if ((Object)(object)val2 != (Object)null && val2.AllTiles != null && val2.AllTiles.Count > 0) { return val; } } } catch { } return null; } public static void Scan(bool force = false) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Invalid comparison between Unknown and I4 //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Invalid comparison between Unknown and I4 float unscaledTime = Time.unscaledTime; if (force || unscaledTime >= _nextActorScan) { _nextActorScan = unscaledTime + 0.4f; Players.Clear(); Monsters.Clear(); LocalPlayer = null; try { ProtoActor[] array = Object.FindObjectsByType<ProtoActor>((FindObjectsSortMode)0); foreach (ProtoActor val in array) { if ((Object)(object)val == (Object)null) { continue; } if ((int)val.ActorType == 2) { if (!val.dead) { Monsters.Add(val); } } else if ((int)val.ActorType == 1) { if (val.AmIAvatar()) { LocalPlayer = val; } else { Players.Add(val); } } } } catch { } } if (!force && !(unscaledTime >= _nextLootScan)) { return; } _nextLootScan = unscaledTime + 0.5f; Loot.Clear(); try { LootingLevelObject[] array2 = Object.FindObjectsByType<LootingLevelObject>((FindObjectsSortMode)0); foreach (LootingLevelObject val2 in array2) { if (!((Object)(object)val2 == (Object)null) && ((Behaviour)val2).isActiveAndEnabled && !((Object)(object)((Component)val2).GetComponentInParent<ProtoActor>() != (Object)null)) { Loot.Add(val2); } } } catch { } } public static void Clear() { Players.Clear(); Monsters.Clear(); Loot.Clear(); LocalPlayer = null; } public static ProtoActor Focus() { ProtoActor localPlayer = LocalPlayer; if ((Object)(object)localPlayer != (Object)null && !localPlayer.dead) { return localPlayer; } try { object? obj = CameraManProp?.GetValue(Hub.s); object? obj2 = ((obj is CameraManager) ? obj : null); int? num = ((obj2 != null) ? ((CameraManager)obj2).SpectatorTargetActorID : ((int?)null)); if (num.HasValue) { foreach (ProtoActor player in Players) { if ((Object)(object)player != (Object)null && player.ActorID == num.Value) { return player; } } } } catch { } return localPlayer; } public static float Yaw(ProtoActor focus) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)focus == (Object)(object)LocalPlayer && (Object)(object)focus != (Object)null && !focus.dead) { Camera main = Camera.main; if ((Object)(object)main != (Object)null) { return ((Component)main).transform.eulerAngles.y; } } if (!((Object)(object)focus != (Object)null)) { return 0f; } return ((Component)focus).transform.eulerAngles.y; } public static CSteamID LobbyId() { //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_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_0062: 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_0049: 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) try { if ((Object)(object)Hub.s == (Object)null) { return CSteamID.Nil; } object? obj = DispatcherField?.GetValue(Hub.s); SteamInviteDispatcher val = (SteamInviteDispatcher)((obj is SteamInviteDispatcher) ? obj : null); if ((Object)(object)val == (Object)null) { val = Object.FindAnyObjectByType<SteamInviteDispatcher>(); } return ((Object)(object)val != (Object)null) ? val.joinedLobbyID : CSteamID.Nil; } catch { return CSteamID.Nil; } } } internal static class GraphicRenderer { public const float CameraAboveFeet = 2.2f; private static Camera _cam; private static Light _light; private static GameObject _root; private static readonly List<Renderer> Hide = new List<Renderer>(); private static readonly List<Renderer> Hidden = new List<Renderer>(); private static float _nextScan; public static bool Failed { get; private set; } public static bool Render(RenderTexture rt, Vector3 feet, float coverMeters, float farClip) { //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0059: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00e7: 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) if (Failed || (Object)(object)rt == (Object)null) { return false; } try { Ensure(); ScanHidden(); _cam.targetTexture = rt; _cam.orthographicSize = coverMeters * 0.5f; _cam.farClipPlane = farClip; ((Component)_cam).transform.SetPositionAndRotation(feet + Vector3.up * 2.2f, Quaternion.Euler(90f, 0f, 0f)); Hidden.Clear(); foreach (Renderer item in Hide) { if ((Object)(object)item != (Object)null && !item.forceRenderingOff) { item.forceRenderingOff = true; Hidden.Add(item); } } AmbientMode ambientMode = RenderSettings.ambientMode; Color ambientLight = RenderSettings.ambientLight; bool fog = RenderSettings.fog; RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = new Color(0.55f, 0.55f, 0.55f); RenderSettings.fog = false; ((Behaviour)_light).enabled = true; try { _cam.Render(); } finally { ((Behaviour)_light).enabled = false; RenderSettings.ambientMode = ambientMode; RenderSettings.ambientLight = ambientLight; RenderSettings.fog = fog; foreach (Renderer item2 in Hidden) { if ((Object)(object)item2 != (Object)null) { item2.forceRenderingOff = false; } } Hidden.Clear(); } return true; } catch (Exception ex) { Failed = true; MelonLogger.Error("[MimesisMap] Graphic style failed, falling back to Plain: " + ex); return false; } } private static void Ensure() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_002c: 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) //IL_00f1: 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) if (!((Object)(object)_cam != (Object)null)) { _root = new GameObject("MimesisMapGraphic"); Object.DontDestroyOnLoad((Object)(object)_root); _cam = new GameObject("MimesisMapCamera").AddComponent<Camera>(); ((Component)_cam).transform.SetParent(_root.transform, false); ((Behaviour)_cam).enabled = false; _cam.orthographic = true; _cam.nearClipPlane = 0.05f; _cam.clearFlags = (CameraClearFlags)2; _cam.backgroundColor = new Color(0f, 0f, 0f, 0f); int num = LayerMask.NameToLayer("UI"); if (num >= 0) { Camera cam = _cam; cam.cullingMask &= ~(1 << num); } try { UniversalAdditionalCameraData universalAdditionalCameraData = CameraExtensions.GetUniversalAdditionalCameraData(_cam); universalAdditionalCameraData.renderPostProcessing = false; universalAdditionalCameraData.renderShadows = false; } catch { } _light = new GameObject("MimesisMapLight").AddComponent<Light>(); ((Component)_light).transform.SetParent(_root.transform, false); ((Component)_light).transform.rotation = Quaternion.Euler(90f, 0f, 0f); _light.type = (LightType)1; _light.intensity = 1.1f; _light.shadows = (LightShadows)0; ((Behaviour)_light).enabled = false; } } private static void ScanHidden() { if (Time.unscaledTime < _nextScan) { return; } _nextScan = Time.unscaledTime + 1f; Hide.Clear(); try { if ((Object)(object)GameAccess.LocalPlayer != (Object)null) { Hide.AddRange(((Component)GameAccess.LocalPlayer).GetComponentsInChildren<Renderer>(true)); } if (!Cfg.ShowTeammates.Value) { foreach (ProtoActor player in GameAccess.Players) { if ((Object)(object)player != (Object)null) { Hide.AddRange(((Component)player).GetComponentsInChildren<Renderer>(true)); } } } if (!Cfg.ShowMonsters.Value) { foreach (ProtoActor monster in GameAccess.Monsters) { if ((Object)(object)monster != (Object)null) { Hide.AddRange(((Component)monster).GetComponentsInChildren<Renderer>(true)); } } } if (Cfg.ShowLoot.Value) { return; } foreach (LootingLevelObject item in GameAccess.Loot) { if ((Object)(object)item != (Object)null) { Hide.AddRange(((Component)item).GetComponentsInChildren<Renderer>(true)); } } } catch { } } } internal static class InputBlock { private static readonly HashSet<string> Holders = new HashSet<string>(); private static readonly List<PlayerInput> Suspended = new List<PlayerInput>(); private static CursorLockMode _prevLock; private static bool _prevVisible; public static bool Active => Holders.Count > 0; public static void Set(string holder, bool on) { if (on) { Acquire(holder); } else { Release(holder); } } public static void Acquire(string holder) { //IL_001b: 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) if (!Holders.Add(holder) || Holders.Count > 1) { return; } _prevLock = Cursor.lockState; _prevVisible = Cursor.visible; Suspended.Clear(); try { PlayerInput[] array = Object.FindObjectsByType<PlayerInput>((FindObjectsSortMode)0); foreach (PlayerInput val in array) { if (!((Object)(object)val == (Object)null) && val.inputIsActive) { val.DeactivateInput(); Suspended.Add(val); } } } catch { } } public static void Release(string holder) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (!Holders.Remove(holder) || Holders.Count > 0) { return; } Cursor.lockState = _prevLock; Cursor.visible = _prevVisible; foreach (PlayerInput item in Suspended) { try { if ((Object)(object)item != (Object)null) { item.ActivateInput(); } } catch { } } Suspended.Clear(); } public static void Tick() { if (Holders.Count != 0) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } } public enum Lang { Auto, Russian, English } internal static class Loc { public static bool Ru { get { //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 switch ((Cfg.Language != null) ? Cfg.Language.Value : Lang.Auto) { case Lang.Russian: return true; case Lang.English: return false; default: { SystemLanguage systemLanguage = Application.systemLanguage; if ((int)systemLanguage != 30 && (int)systemLanguage != 38) { return (int)systemLanguage == 3; } return true; } } } } public static string T(string ru, string en) { if (!Ru) { return en; } return ru; } } internal static class MapController { private static MapModel _model; private static Dungeon _seenDungeon; private static GameMainBase _seenMain; private static float _mainSeenAt; private static float _modelBuiltAt; private static float _seenAt; private static float _navBuiltAt = -1f; private static float _nextDungeonScan; private static float _nextReveal; private static GameObject _canvasGo; private static RectTransform _canvasRect; private static MapView _mini; private static MapView _big; private static bool _bigOpen; private static readonly Dictionary<string, HashSet<int>> Explored = new Dictionary<string, HashSet<int>>(); private static readonly FrameCtx Ctx = new FrameCtx(); public static Vector2 BigPan; public static int BigOpenStamp; private static float _nextNavCheck; private static float _nextExitScan; private static float _nextPath; private static int _seenTileCount; private static string _lastDiag; public static MapModel Model => _model; private static void Zoom(float k) { Cfg.BigMapZoom.Value = Mathf.Clamp(Cfg.BigMapZoom.Value * k, 0.5f, 12f); } public static void Init() { Sharing.Received += OnShared; } public static void OnNavMeshBuilt() { _navBuiltAt = Time.unscaledTime; _nextNavCheck = 0f; } public static void ResetExploration() { if (_model == null) { return; } foreach (TileInfo tile in _model.Tiles) { tile.Revealed = false; } _model.RevealedCount = 0; Explored.Remove(_model.Key); } public static void ForceRebuild() { Teardown(); _seenDungeon = null; } public static void Update() { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: 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_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: 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_0102: Unknown result type (might be due to invalid IL or missing references) if (!SettingsWindow.Capturing) { if (Cfg.BSettings.Pressed) { SettingsWindow.Toggle(); } if (Cfg.BMini.Pressed) { Cfg.MiniEnabled.Value = !Cfg.MiniEnabled.Value; Cfg.Save(); } bool bigOpen = _bigOpen; if (Cfg.BigMapKeyMode.Value == KeyMode.Hold) { _bigOpen = Cfg.BBigMap.Held; } else if (Cfg.BBigMap.Pressed) { _bigOpen = !_bigOpen; } if (_bigOpen && !bigOpen) { BigPan = Vector2.zero; BigOpenStamp++; } Keyboard current = Keyboard.current; if (_bigOpen && current != null) { if (((ButtonControl)current.escapeKey).wasPressedThisFrame) { _bigOpen = false; } if (Cfg.BZoomIn.Pressed) { Zoom(1.2f); } if (Cfg.BZoomOut.Pressed) { Zoom(5f / 6f); } if (Cfg.BRecenter.Pressed) { BigPan = Vector2.zero; BigOpenStamp++; } } } bool flag = _bigOpen && _model != null && Cfg.BigMapKeyMode.Value == KeyMode.Toggle && Cfg.BigMapInteractive.Value; InputBlock.Set("bigmap", flag); Mouse current2 = Mouse.current; if (flag && current2 != null && !SettingsWindow.Open && current2.leftButton.isPressed && _big != null && _big.LastPpm > 0.0001f) { Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current2).delta).ReadValue() * (1080f / (float)Mathf.Max(1, Screen.height)) / _big.LastPpm; BigPan -= Vector2.op_Implicit(Quaternion.Euler(0f, 0f, 0f - _big.LastRot) * Vector2.op_Implicit(val)); } GameMainBase val2 = GameAccess.CurrentMain(); if ((Object)(object)val2 == (Object)null) { Diagnose("no game scene"); if (_model != null) { Teardown(); } _seenDungeon = null; _seenMain = null; return; } if ((Object)(object)val2 != (Object)(object)_seenMain) { _seenMain = val2; _mainSeenAt = Time.unscaledTime; } if (_model != null && (_model.Owner != (Object)(object)val2 || (!_model.Flat && _model.DungeonGone) || (_model.Flat && _navBuiltAt > _modelBuiltAt))) { Teardown(); } if (_model == null && Time.unscaledTime >= _nextDungeonScan) { _nextDungeonScan = Time.unscaledTime + 0.5f; TryBuild(val2); } } private static void TryBuild(GameMainBase main) { //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: 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_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) List<Dungeon> list = GameAccess.FindDungeons(); if (list.Count == 0) { if (main is GamePlayScene && Time.unscaledTime - _mainSeenAt < 10f) { Diagnose("no generated dungeon in this scene yet"); return; } if ((Object)(object)GameAccess.LocalPlayer == (Object)null) { GameAccess.Scan(force: true); } if ((Object)(object)GameAccess.LocalPlayer == (Object)null || Time.unscaledTime - _mainSeenAt < 1f) { Diagnose("no local player yet"); return; } MapModel mapModel = null; try { mapModel = MapModel.BuildFlat("scene:" + ((object)main).GetType().Name + ":" + ((Object)main).GetInstanceID()); } catch (Exception ex) { MelonLogger.Error("[MimesisMap] Flat map build failed: " + ex); _nextDungeonScan = Time.unscaledTime + 10f; } if (mapModel == null) { Diagnose("no NavMesh or A* graph in " + ((object)main).GetType().Name + " yet"); _nextDungeonScan = Mathf.Max(_nextDungeonScan, Time.unscaledTime + 2f); } else { Install(mapModel, main); } return; } int num = 0; foreach (Dungeon item4 in list) { num += item4.AllTiles.Count; } if ((Object)(object)list[0] != (Object)(object)_seenDungeon || num != _seenTileCount) { _seenDungeon = list[0]; _seenTileCount = num; _seenAt = Time.unscaledTime; Diagnose("dungeon generating"); } else { if (Time.unscaledTime - _seenAt < 1f || Time.unscaledTime < _nextNavCheck) { return; } _nextNavCheck = Time.unscaledTime + 1f; Bounds val = MapModel.BoundsOf(list); (Vector3[] v, int[] ind, string source) tuple = MapModel.FloorTriangles(val); Vector3[] item = tuple.v; int[] item2 = tuple.ind; string item3 = tuple.source; int num2 = MapModel.CountInside(item, item2, val); if (num2 < 20) { Diagnose($"waiting for walkable floor inside the building ({item3}: {item2.Length / 3} triangles, {num2} inside {list.Count} building(s), bounds {((Bounds)(ref val)).center:0} size {((Bounds)(ref val)).size:0})"); return; } string key; try { Vector3 position = ((Component)list[0].AllTiles[0]).transform.position; key = $"{GameAccess.DungeonSeed()}:{num}:{Mathf.RoundToInt(position.x)}:{Mathf.RoundToInt(position.z)}"; } catch { key = "unknown:" + ((Object)list[0]).GetInstanceID(); } MapModel mapModel2; try { mapModel2 = MapModel.Build(list, key); } catch (Exception ex2) { MelonLogger.Error("[MimesisMap] Map build failed: " + ex2); _nextDungeonScan = Time.unscaledTime + 10f; return; } if (mapModel2 != null) { Install(mapModel2, main); } } } private static void Install(MapModel model, GameMainBase main) { _model = model; _model.Owner = (Object)(object)main; _modelBuiltAt = Time.unscaledTime; string key = model.Key; if (Explored.TryGetValue(key, out var value)) { foreach (int item in value) { _model.Reveal(item); } } EnsureCanvas(); _mini.Bind(_model); _big.Bind(_model); } private static void Teardown() { _mini?.Bind(null); _big?.Bind(null); _mini?.SetVisible(v: false); _big?.SetVisible(v: false); _model?.Destroy(); _model = null; _bigOpen = _bigOpen && Cfg.BigMapKeyMode.Value == KeyMode.Hold; InputBlock.Release("bigmap"); GameAccess.Clear(); } private static void EnsureCanvas() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_005b: 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_0083: Expected O, but got Unknown if (!((Object)(object)_canvasGo != (Object)null)) { _canvasGo = new GameObject("MimesisMapCanvas"); Object.DontDestroyOnLoad((Object)(object)_canvasGo); Canvas obj = _canvasGo.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 40; CanvasScaler obj2 = _canvasGo.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.matchWidthOrHeight = 1f; _canvasRect = (RectTransform)_canvasGo.transform; _mini = new MapView(mini: true); _mini.Create(_canvasGo.transform); _big = new MapView(mini: false); _big.Create(_canvasGo.transform); } } public static void LateUpdate() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Unknown result type (might be due to invalid IL or missing references) //IL_0596: Unknown result type (might be due to invalid IL or missing references) //IL_059d: Unknown result type (might be due to invalid IL or missing references) //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) if (_model == null || (Object)(object)_canvasGo == (Object)null) { return; } GameAccess.Scan(); ProtoActor val = GameAccess.Focus(); if ((Object)(object)val == (Object)null) { Diagnose("no local player yet"); _mini.SetVisible(v: false); _big.SetVisible(v: false); return; } FrameCtx ctx = Ctx; ctx.FocusPos = ((Component)val).transform.position; ctx.Yaw = GameAccess.Yaw(val); ctx.Indoor = _model.IsIndoor(ctx.FocusPos + Vector3.up * 0.3f, out ctx.CurTile); ctx.Mates.Clear(); int tile; foreach (ProtoActor player in GameAccess.Players) { if (!((Object)(object)player == (Object)null) && !player.dead && !((Object)(object)player == (Object)(object)val)) { Vector3 position = ((Component)player).transform.position; ctx.Mates.Add(new ActorDot { Pos = position, Yaw = ((Component)player).transform.eulerAngles.y, Name = SafeName(player), Indoor = _model.IsIndoor(position + Vector3.up * 0.3f, out tile) }); } } if ((Object)(object)val != (Object)(object)GameAccess.LocalPlayer && (Object)(object)GameAccess.LocalPlayer != (Object)null && !GameAccess.LocalPlayer.dead) { ProtoActor localPlayer = GameAccess.LocalPlayer; ctx.Mates.Add(new ActorDot { Pos = ((Component)localPlayer).transform.position, Yaw = ((Component)localPlayer).transform.eulerAngles.y, Name = SafeName(localPlayer), Indoor = _model.IsIndoor(((Component)localPlayer).transform.position, out tile) }); } ctx.Monsters.Clear(); if (Cfg.ShowMonsters.Value) { foreach (ProtoActor monster in GameAccess.Monsters) { if ((Object)(object)monster != (Object)null && !monster.dead) { Vector3 position2 = ((Component)monster).transform.position; ctx.Monsters.Add((position2, _model.IsIndoor(position2 + Vector3.up * 0.3f, out tile))); } } } ctx.Loot.Clear(); ctx.MaxPrice = 1; if (Cfg.ShowLoot.Value) { foreach (LootingLevelObject item2 in GameAccess.Loot) { if ((Object)(object)item2 == (Object)null) { continue; } Vector3 position3 = ((Component)item2).transform.position; if (!NearPlayer(position3, ctx)) { int tile2; bool item = _model.IsIndoor(position3 + Vector3.up * 0.2f, out tile2); int num = Mathf.Max(0, item2.marketPrice); if (num > ctx.MaxPrice) { ctx.MaxPrice = num; } ctx.Loot.Add((position3, num, item, tile2)); } } } if (Time.unscaledTime >= _nextReveal) { _nextReveal = Time.unscaledTime + 0.15f; bool flag = RevealAt(ctx.FocusPos); if ((Object)(object)GameAccess.LocalPlayer != (Object)null && (Object)(object)GameAccess.LocalPlayer != (Object)(object)val && !GameAccess.LocalPlayer.dead) { flag |= RevealAt(((Component)GameAccess.LocalPlayer).transform.position); } if (Cfg.RevealByTeammates.Value) { foreach (ProtoActor player2 in GameAccess.Players) { if ((Object)(object)player2 != (Object)null && !player2.dead) { flag |= RevealAt(((Component)player2).transform.position); } } } if (flag) { Sharing.MarkDirty(); } } Sharing.Tick(_model); if (Time.unscaledTime >= _nextExitScan) { _nextExitScan = Time.unscaledTime + 3f; _model.RefreshExits(); } if (Time.unscaledTime >= _nextPath) { _nextPath = Time.unscaledTime + 0.4f; if (Cfg.ShowExit.Value && Cfg.ShowExitPath.Value && ctx.Indoor) { ExitPath.Update(_model, ctx.FocusPos, ctx.CurTile, Cfg.Reveal.Value == RevealMode.Full); } else { ExitPath.Path.Clear(); ExitPath.TargetExit = -1; } } if (GameAccess.MenuOpen()) { _mini.SetVisible(v: false); _big.SetVisible(v: false); Diagnose("menu open"); return; } Diagnose(null); bool bigOpen = _bigOpen; _big.SetVisible(bigOpen); _mini.SetVisible(!bigOpen && Cfg.MiniEnabled.Value); ? val2; if (!((Object)(object)_canvasRect != (Object)null)) { val2 = new Vector2(1920f, 1080f); } else { Rect rect = _canvasRect.rect; val2 = ((Rect)(ref rect)).size; } Vector2 canvasSize = (Vector2)val2; _mini.Tick(ctx, canvasSize); _big.Tick(ctx, canvasSize); } private static bool NearPlayer(Vector3 p, FrameCtx ctx) { //IL_0000: 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_0026: 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) if (Near(p, ctx.FocusPos)) { return true; } foreach (ActorDot mate in ctx.Mates) { if (Near(p, mate.Pos)) { return true; } } return false; } private static bool Near(Vector3 a, Vector3 b) { //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_0019: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (Mathf.Abs(a.y - b.y) < 2.2f) { Vector2 val = new Vector2(a.x - b.x, a.z - b.z); return ((Vector2)(ref val)).sqrMagnitude < 1f; } return false; } private static void Diagnose(string why) { if (!(why == _lastDiag)) { _lastDiag = why; MelonLogger.Msg((why == null) ? "[MimesisMap] Map shown" : ("[MimesisMap] Map hidden: " + why)); } } private static bool RevealAt(Vector3 pos) { //IL_0005: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) int num = _model.FindTile(pos + Vector3.up * 0.3f); if (num < 0 || !_model.Reveal(num)) { return false; } Remember(_model.Key, num); return true; } private static void Remember(string key, int idx) { if (!Explored.TryGetValue(key, out var value)) { value = (Explored[key] = new HashSet<int>()); } value.Add(idx); } private static void OnShared(string key, List<int> ids) { foreach (int id in ids) { Remember(key, id); } if (_model == null || _model.Key != key) { return; } foreach (int id2 in ids) { _model.Reveal(id2); } } private static string SafeName(ProtoActor p) { try { return p.nickName; } catch { return null; } } } [HarmonyPatch(typeof(NavManager), "Build")] internal static class NavBuildPatch { public static bool Ok; private static bool Prepare() { Ok = true; return true; } private static void Postfix() { MapController.OnNavMeshBuilt(); } } internal sealed class TileInfo { public int Index; public Tile Tile; public Bounds Bounds; public Rect Rect; public Texture2D Tex; public Texture2D Fog; public float FloorY; public float MinY; public float MaxY; public bool IsStairs; public Vector3 StairsAt; public bool IsStart; public bool Revealed; public int[] Neighbors = Array.Empty<int>(); public string Name; public readonly List<Vector3> Doors = new List<Vector3>(); } internal struct ExitInfo { public Vector3 Pos; public bool ToIndoor; public int Tile; } internal sealed class MapModel { public string Key; public readonly List<Dungeon> Dungeons = new List<Dungeon>(); public readonly List<ExitInfo> Exits = new List<ExitInfo>(); public string Source; public Object Owner; public readonly List<TileInfo> Tiles = new List<TileInfo>(); public Bounds DungeonBounds; public Texture2D OutdoorTex; public Rect OutdoorRect; public int RevealedCount; public int StartTile = -1; private int _lastLookup = -1; private const float Pad = 1f; private const float AgentRadiusFill = 0.35f; public bool DungeonGone { get { foreach (Dungeon dungeon in Dungeons) { if ((Object)(object)dungeon == (Object)null) { return true; } } return false; } } public bool Flat => Tiles.Count == 0; public void Destroy() { foreach (TileInfo tile in Tiles) { if ((Object)(object)tile.Tex != (Object)null) { Object.Destroy((Object)(object)tile.Tex); } if ((Object)(object)tile.Fog != (Object)null) { Object.Destroy((Object)(object)tile.Fog); } } if ((Object)(object)OutdoorTex != (Object)null) { Object.Destroy((Object)(object)OutdoorTex); } Tiles.Clear(); } public int FindTile(Vector3 p) { //IL_004d: 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_003b: Unknown result type (might be due to invalid IL or missing references) if (_lastLookup >= 0 && _lastLookup < Tiles.Count && ((Bounds)(ref Tiles[_lastLookup].Bounds)).Contains(p)) { return _lastLookup = Smallest(p); } _lastLookup = Smallest(p); return _lastLookup; } private int Smallest(Vector3 p) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_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) int result = -1; float num = float.MaxValue; for (int i = 0; i < Tiles.Count; i++) { Bounds bounds = Tiles[i].Bounds; if (((Bounds)(ref bounds)).Contains(p)) { Vector3 size = ((Bounds)(ref bounds)).size; float num2 = size.x * size.y * size.z; if (num2 < num) { num = num2; result = i; } } } return result; } public int NearestTile(Vector3 p, float maxDist) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) int num = FindTile(p); if (num >= 0) { return num; } float num2 = maxDist * maxDist; for (int i = 0; i < Tiles.Count; i++) { float num3 = ((Bounds)(ref Tiles[i].Bounds)).SqrDistance(p); if (num3 < num2) { num2 = num3; num = i; } } return num; } public bool IsIndoor(Vector3 p, out int tile) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) tile = FindTile(p); if (tile >= 0) { return true; } Bounds dungeonBounds = DungeonBounds; ((Bounds)(ref dungeonBounds)).Expand(new Vector3(2f, 2f, 2f)); if (Tiles.Count > 0) { return ((Bounds)(ref dungeonBounds)).Contains(p); } return false; } public bool Reveal(int idx) { if (idx < 0 || idx >= Tiles.Count || Tiles[idx].Revealed) { return false; } Tiles[idx].Revealed = true; RevealedCount++; return true; } public bool IsHint(int idx) { TileInfo tileInfo = Tiles[idx]; if (tileInfo.Revealed) { return false; } int[] neighbors = tileInfo.Neighbors; foreach (int index in neighbors) { if (Tiles[index].Revealed) { return true; } } return false; } public static Bounds BoundsOf(List<Dungeon> dungeons) { //IL_0004: 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_003c: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) bool flag = true; Bounds result = default(Bounds); foreach (Dungeon dungeon in dungeons) { foreach (Tile allTile in dungeon.AllTiles) { if (!((Object)(object)allTile == (Object)null)) { Bounds bounds; try { bounds = allTile.Bounds; } catch { continue; } if (flag) { result = bounds; flag = false; } else { ((Bounds)(ref result)).Encapsulate(bounds); } } } } return result; } public static MapModel Build(List<Dungeon> dungeons, string key) { //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0552: Unknown result type (might be due to invalid IL or missing references) //IL_0566: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_07d5: Unknown result type (might be due to invalid IL or missing references) //IL_07da: Unknown result type (might be due to invalid IL or missing references) //IL_07e0: Unknown result type (might be due to invalid IL or missing references) //IL_07f2: Unknown result type (might be due to invalid IL or missing references) //IL_0804: Unknown result type (might be due to invalid IL or missing references) //IL_0816: Unknown result type (might be due to invalid IL or missing references) //IL_082d: Unknown result type (might be due to invalid IL or missing references) //IL_082f: Unknown result type (might be due to invalid IL or missing references) //IL_0836: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_05de: Unknown result type (might be due to invalid IL or missing references) //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_0600: Unknown result type (might be due to invalid IL or missing references) //IL_098d: Unknown result type (might be due to invalid IL or missing references) //IL_098f: Unknown result type (might be due to invalid IL or missing references) //IL_0995: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_08bf: Unknown result type (might be due to invalid IL or missing references) //IL_08c4: Unknown result type (might be due to invalid IL or missing references) //IL_08c6: Unknown result type (might be due to invalid IL or missing references) //IL_08da: Unknown result type (might be due to invalid IL or missing references) //IL_08d1: Unknown result type (might be due to invalid IL or missing references) //IL_0725: Unknown result type (might be due to invalid IL or missing references) //IL_072a: Unknown result type (might be due to invalid IL or missing references) //IL_072c: Unknown result type (might be due to invalid IL or missing references) //IL_08ee: Unknown result type (might be due to invalid IL or missing references) //IL_08e5: Unknown result type (might be due to invalid IL or missing references) //IL_0740: Unknown result type (might be due to invalid IL or missing references) //IL_0737: Unknown result type (might be due to invalid IL or missing references) //IL_0902: Unknown result type (might be due to invalid IL or missing references) //IL_08f9: Unknown result type (might be due to invalid IL or missing references) //IL_074b: Unknown result type (might be due to invalid IL or missing references) //IL_090d: Unknown result type (might be due to invalid IL or missing references) //IL_07c9: Unknown result type (might be due to invalid IL or missing references) //IL_07ce: Unknown result type (might be due to invalid IL or missing references) Stopwatch stopwatch = Stopwatch.StartNew(); MapModel mapModel = new MapModel { Key = key }; mapModel.Dungeons.AddRange(dungeons); List<Tile> list = new List<Tile>(); foreach (Dungeon dungeon in dungeons) { foreach (Tile allTile in dungeon.AllTiles) { if ((Object)(object)allTile != (Object)null) { list.Add(allTile); } } } if (list.Count == 0) { return null; } (Vector3[] v, int[] ind, string source) tuple = FloorTriangles(BoundsOf(dungeons)); Vector3[] item = tuple.v; int[] item2 = tuple.ind; string text = (mapModel.Source = tuple.source); int num = item2.Length / 3; float num2 = Mathf.Clamp(Cfg.Resolution.Value, 2f, 10f); Dictionary<Tile, int> dictionary = new Dictionary<Tile, int>(); bool flag = true; Bounds bounds = default(Bounds); for (int i = 0; i < list.Count; i++) { Tile val = list[i]; TileInfo tileInfo = new TileInfo { Index = i, Tile = val, Name = (((Object)(object)val != (Object)null) ? ((Object)val).name : "?") }; try { bounds = val.Bounds; } catch { ((Bounds)(ref bounds))..ctor(((Component)val).transform.position, Vector3.one * 4f); } if (flag) { mapModel.DungeonBounds = bounds; flag = false; } else { ((Bounds)(ref mapModel.DungeonBounds)).Encapsulate(bounds); } Bounds bounds2 = bounds; ((Bounds)(ref bounds2)).Expand(new Vector3(0.1f, 1.5f, 0.1f)); tileInfo.Bounds = bounds2; tileInfo.FloorY = ((Bounds)(ref bounds)).min.y; tileInfo.MinY = ((Bounds)(ref bounds)).min.y; tileInfo.MaxY = ((Bounds)(ref bounds)).min.y + 1f; mapModel.Tiles.Add(tileInfo); if ((Object)(object)val != (Object)null) { dictionary[val] = i; } } foreach (Dungeon dungeon2 in dungeons) { try { ReadOnlyCollection<Tile> mainPathTiles = dungeon2.MainPathTiles; if (mainPathTiles != null && mainPathTiles.Count > 0 && (Object)(object)mainPathTiles[0] != (Object)null && dictionary.TryGetValue(mainPathTiles[0], out var value)) { if (mapModel.StartTile < 0) { mapModel.StartTile = value; } mapModel.Tiles[value].IsStart = true; } } catch { } } for (int j = 0; j < mapModel.Tiles.Count; j++) { Tile tile = mapModel.Tiles[j].Tile; if ((Object)(object)tile == (Object)null || tile.UsedDoorways == null) { continue; } HashSet<int> hashSet = new HashSet<int>(); foreach (Doorway usedDoorway in tile.UsedDoorways) { try { if ((Object)(object)usedDoorway != (Object)null) { mapModel.Tiles[j].Doors.Add(((Component)usedDoorway).transform.position); } Doorway val2 = (((Object)(object)usedDoorway != (Object)null) ? usedDoorway.ConnectedDoorway : null); if ((Object)(object)val2 != (Object)null && (Object)(object)val2.Tile != (Object)null && dictionary.TryGetValue(val2.Tile, out var value2) && value2 != j) { hashSet.Add(value2); } } catch { } } mapModel.Tiles[j].Neighbors = new List<int>(hashSet).ToArray(); } int[] array = new int[num]; Vector3[] array2 = (Vector3[])(object)new Vector3[num]; List<int>[] array3 = new List<int>[mapModel.Tiles.Count]; List<int>[] array4 = new List<int>[mapModel.Tiles.Count]; for (int k = 0; k < mapModel.Tiles.Count; k++) { array3[k] = new List<int>(); array4[k] = new List<int>(); } List<int> list2 = new List<int>(); Bounds dungeonBounds = mapModel.DungeonBounds; ((Bounds)(ref dungeonBounds)).Expand(new Vector3(4f, 4f, 4f)); for (int l = 0; l < num; l++) { Vector3 val3 = (array2[l] = (item[item2[l * 3]] + item[item2[l * 3 + 1]] + item[item2[l * 3 + 2]]) / 3f); array[l] = mapModel.Smallest(val3); if (array[l] >= 0) { array3[array[l]].Add(l); } else if (!((Bounds)(ref dungeonBounds)).Contains(val3)) { list2.Add(l); } } for (int m = 0; m < mapModel.Tiles.Count; m++) { Bounds bounds3 = mapModel.Tiles[m].Bounds; float num3 = ((Bounds)(ref bounds3)).min.x - 1f; float num4 = ((Bounds)(ref bounds3)).max.x + 1f; float num5 = ((Bounds)(ref bounds3)).min.z - 1f; float num6 = ((Bounds)(ref bounds3)).max.z + 1f; float num7 = ((Bounds)(ref bounds3)).min.y - 1f; float num8 = ((Bounds)(ref bounds3)).max.y + 1f; for (int n = 0; n < num; n++) { if (array[n] != m) { Vector3 val4 = array2[n]; if (!(val4.x < num3 - 3f) && !(val4.x > num4 + 3f) && !(val4.z < num5 - 3f) && !(val4.z > num6 + 3f) && !(val4.y < num7) && !(val4.y > num8)) { array4[m].Add(n); } } } } Rect rect = default(Rect); for (int num9 = 0; num9 < mapModel.Tiles.Count; num9++) { TileInfo tileInfo2 = mapModel.Tiles[num9]; List<int> list3 = array3[num9]; if (list3.Count > 0) { float num10 = 0f; float num11 = float.MaxValue; float num12 = float.MinValue; foreach (int item3 in list3) { float y = array2[item3].y; num10 += y; if (y < num11) { num11 = y; } if (y > num12) { num12 = y; } } tileInfo2.FloorY = num10 / (float)list3.Count; tileInfo2.MinY = num11; tileInfo2.MaxY = num12; float num13 = float.MaxValue; float num14 = float.MinValue; foreach (Vector3 door in tileInfo2.Doors) { if (door.y < num13) { num13 = door.y; } if (door.y > num14) { num14 = door.y; } } tileInfo2.IsStairs = (tileInfo2.Doors.Count >= 2 && num14 - num13 > 1.8f) || (tileInfo2.Name != null && tileInfo2.Name.IndexOf("stair", StringComparison.OrdinalIgnoreCase) >= 0); if (tileInfo2.IsStairs) { tileInfo2.StairsAt = StairsCenter(list3, array2, num11, num12); } } Bounds bounds4 = tileInfo2.Bounds; ((Rect)(ref rect))..ctor(((Bounds)(ref bounds4)).min.x - 1f, ((Bounds)(ref bounds4)).min.z - 1f, ((Bounds)(ref bounds4)).size.x + 2f, ((Bounds)(ref bounds4)).size.z + 2f); tileInfo2.Rect = rect; tileInfo2.Tex = Rasterize(rect, num2, 1024, item, item2, list3, array4[num9], out tileInfo2.Fog); } if (list2.Count > 0) { float num15 = float.MaxValue; float num16 = float.MaxValue; float num17 = float.MinValue; float num18 = float.MinValue; foreach (int item4 in list2) { for (int num19 = 0; num19 < 3; num19++) { Vector3 val5 = item[item2[item4 * 3 + num19]]; if (val5.x < num15) { num15 = val5.x; } if (val5.x > num17) { num17 = val5.x; } if (val5.z < num16) { num16 = val5.z; } if (val5.z > num18) { num18 = val5.z; } } } Rect val6 = default(Rect); ((Rect)(ref val6))..ctor(num15 - 1f, num16 - 1f, num17 - num15 + 2f, num18 - num16 + 2f); float ppm = Mathf.Min(num2, 2048f / Mathf.Max(((Rect)(ref val6)).width, ((Rect)(ref val6)).height)); mapModel.OutdoorRect = val6; mapModel.OutdoorTex = Rasterize(val6, ppm, 2048, item, item2, list2, null, out var _); } mapModel.RefreshExits(); MelonLogger.Msg($"[MimesisMap] Map built: {dungeons.Count} building(s), {mapModel.Tiles.Count} rooms, {mapModel.Exits.Count} doors, {num} triangles from {text} ({list2.Count} outdoor) in {stopwatch.ElapsedMilliseconds} ms"); return mapModel; } public static MapModel BuildFlat(string key) { //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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) //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_0087: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) var (array, array2, text) = FloorTriangles(); if (array2.Length < 3) { return null; } MapModel mapModel = new MapModel { Key = key }; float num = float.MaxValue; float num2 = float.MaxValue; float num3 = float.MinValue; float num4 = float.MinValue; List<int> list = new List<int>(array2.Length / 3); for (int i = 0; i < array2.Length / 3; i++) { list.Add(i); for (int j = 0; j < 3; j++) { Vector3 val = array[array2[i * 3 + j]]; if (val.x < num) { num = val.x; } if (val.x > num3) { num3 = val.x; } if (val.z < num2) { num2 = val.z; } if (val.z > num4) { num4 = val.z; } } } Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(num - 1f, num2 - 1f, num3 - num + 2f, num4 - num2 + 2f); float ppm = Mathf.Min(Mathf.Clamp(Cfg.Resolution.Value, 2f, 10f), 2048f / Mathf.Max(((Rect)(ref val2)).width, ((Rect)(ref val2)).height)); mapModel.OutdoorRect = val2; mapModel.OutdoorTex = Rasterize(val2, ppm, 2048, array, array2, list, null, out var _); MelonLogger.Msg($"[MimesisMap] Flat map built from {text}: {list.Count} triangles, {((Rect)(ref val2)).width:0}x{((Rect)(ref val2)).height:0} m"); return mapModel; } public void RefreshExits() { //IL_0029: 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_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_005d: 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_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) Exits.Clear(); try { TeleporterLevelObject[] array = Object.FindObjectsByType<TeleporterLevelObject>((FindObjectsSortMode)0); foreach (TeleporterLevelObject val in array) { if (!((Object)(object)val == (Object)null)) { Vector3 position = ((Component)val).transform.position; bool destinationIsToInDoor = val.DestinationIsToInDoor; Exits.Add(new ExitInfo { Pos = position, ToIndoor = destinationIsToInDoor, Tile = (destinationIsToInDoor ? (-1) : NearestTile(position + Vector3.up * 0.3f, 3f)) }); } } } catch (Exception ex) { MelonLogger.Warning("[MimesisMap] door scan failed: " + ex.Message); } } public static int CountInside(Vector3[] v, int[] ind, Bounds b) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0051: Unknown result type (might be due to invalid IL or missing references) ((Bounds)(ref b)).Expand(new Vector3(1f, 3f, 1f)); int num = 0; for (int i = 0; i + 2 < ind.Length; i += 3) { if (((Bounds)(ref b)).Contains((v[ind[i]] + v[ind[i + 1]] + v[ind[i + 2]]) / 3f)) { num++; } } return num; } public static (Vector3[] v, int[] ind, string source) FloorTriangles(Bounds? cover = null) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_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) NavMeshTriangulation val = NavMesh.CalculateTriangulation(); bool flag = val.vertices != null && val.vertices.Length != 0 && val.indices != null && val.indices.Length >= 3; if (flag && !cover.HasValue) { return (v: val.vertices, ind: val.indices, source: "NavMesh"); } (Vector3[], int[], string) result = AStarTriangles(); if (!flag) { return result; } int num = CountInside(val.vertices, val.indices, cover.Value); if (CountInside(result.Item1, result.Item2, cover.Value) <= num * 2) { return (v: val.vertices, ind: val.indices, source: "NavMesh"); } return result; } private static (Vector3[] v, int[] ind, string source) AStarTriangles() { List<Vector3> verts = new List<Vector3>(); try { AstarData val = (((Object)(object)AstarPath.active != (Object)null) ? AstarPath.active.data : null); if (val?.graphs != null) { NavGraph[] graphs = val.graphs; foreach (NavGraph obj in graphs) { if (obj == null) { continue; } obj.GetNodes((Action<GraphNode>)delegate(GraphNode node) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) TriangleMeshNode val2 = (TriangleMeshNode)(object)((node is TriangleMeshNode) ? node : null); if (val2 != null && ((GraphNode)val2).Walkable) { for (int j = 0; j < 3; j++) { verts.Add((Vector3)((MeshNode)val2).GetVertex(j)); } } }); } } } catch (Exception ex) { MelonLogger.Warning("[MimesisMap] A* graph read failed: " + ex.Message); } int[] array = new int[verts.Count - verts.Count % 3]; for (int num = 0; num < array.Length; num++) { array[num] = num; } return (v: verts.ToArray(), ind: array, source: "A* graph"); } private static Texture2D Rasterize(Rect rect, float ppm, int maxSize, Vector3[] v, int[] ind, List<int> own, List<int> foreign, out Texture2D fog) { //IL_007d: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: 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_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) ppm = Mathf.Min(ppm, (float)maxSize / Mathf.Max(1f, Mathf.Max(((Rect)(ref rect)).width, ((Rect)(ref rect)).height))); int num = Mathf.Clamp(Mathf.CeilToInt(((Rect)(ref rect)).width * ppm), 2, maxSize); int num2 = Mathf.Clamp(Mathf.CeilToInt(((Rect)(ref rect)).height * ppm), 2, maxSize); bool[] m = new bool[num * num2]; bool[] array = new bool[num * num2]; foreach (int item in own) { Tri(m, num, num2, rect, ppm, v[ind[item * 3]], v[ind[item * 3 + 1]], v[ind[item * 3 + 2]]); } if (foreign != null) { foreach (int item2 in foreign) { Tri(array, num, num2, rect, ppm, v[ind[item2 * 3]], v[ind[item2 * 3 + 1]], v[ind[item2 * 3 + 2]]); } } int r = Mathf.Max(1, Mathf.RoundToInt(0.35f * ppm)); m = Dilate(m, num, num2, r); if (foreign != null) { array = Dilate(array, num, num2, r); } Color32[] array2 = (Color32[])(object)new Color32[num * num2]; Color32 val = default(Color32); ((Color32)(ref val))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)0); Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)105); Color32 val3 = default(Color32); ((Color32)(ref val3))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); for (int i = 0; i < num2; i++) { for (int j = 0; j < num; j++) { int num3 = i * num + j; if (!m[num3]) { array2[num3] = val; continue; } bool flag = false; for (int k = -1; k <= 1; k++) { if (flag) { break; } for (int l = -1; l <= 1; l++) { int num4 = j + l; int num5 = i + k; if (num4 >= 0 && num5 >= 0 && num4 < num && num5 < num2) { int num6 = num5 * num + num4; if (!m[num6] && !array[num6]) { flag = true; break; } } } } array2[num3] = (flag ? val3 : val2); } } Texture2D result = MakeTex(num, num2, array2); fog = null; if (foreign != null) { bool[] array3 = Dilate(m, num, num2, Mathf.Max(1, Mathf.RoundToInt(0.4f * ppm))); Color32[] array4 = (Color32[])(object)new Color32[num * num2]; for (int n = 0; n < array4.Length; n++) { array4[n] = (array3[n] ? val3 : val); } fog = MakeTex(num, num2, array4); } return result; } private static Vector3 StairsCenter(List<int> own, Vector3[] centroids, float lo, float hi) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_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_0054: 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_00b9: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) float num = lo + (hi - lo) * 0.25f; float num2 = lo + (hi - lo) * 0.75f; Vector3 val = Vector3.zero; int num3 = 0; foreach (int item in own) { Vector3 val2 = centroids[item]; if (val2.y >= num && val2.y <= num2) { val += val2; num3++; } } if (num3 == 0) { foreach (int item2 in own) { val += centroids[item2]; num3++; } } return val / (float)Mathf.Max(1, num3); } public static bool SameFloor(TileInfo t, float y) { if (y >= t.MinY - 2f) { return y <= t.MaxY + 2f; } return false; } private sta