Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RepoRoomMarks v1.0.0
plugins/Matsu.RoomMarks.dll
Decompiled 5 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("RoomMarks.RuntimeProbe")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Matsu.RoomMarks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Matsu.RoomMarks")] [assembly: AssemblyTitle("Matsu.RoomMarks")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 Matsu.RoomMarks { internal static class Hud { private static Texture2D? _pixel; private static GUIStyle? _title; private static GUIStyle? _label; private static GUIStyle? _small; private static int _styledFor; private static Texture2D Pixel { get { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_pixel != (Object)null) { return _pixel; } _pixel = new Texture2D(1, 1) { hideFlags = (HideFlags)61 }; _pixel.SetPixel(0, 0, Color.white); _pixel.Apply(); return _pixel; } } private static void Styles(float unit) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0052: 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_0065: Expected O, but got Unknown //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_0080: 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_0093: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown int num = Mathf.RoundToInt(unit * 10f); if (_title == null || _styledFor != num) { _styledFor = num; _title = new GUIStyle(GUI.skin.label) { fontSize = Mathf.RoundToInt(unit * 1.25f), fontStyle = (FontStyle)1, alignment = (TextAnchor)3, richText = true, clipping = (TextClipping)1 }; _label = new GUIStyle(GUI.skin.label) { fontSize = Mathf.RoundToInt(unit), alignment = (TextAnchor)4, richText = true }; _small = new GUIStyle(GUI.skin.label) { fontSize = Mathf.RoundToInt(unit * 0.85f), alignment = (TextAnchor)3, richText = true }; } } internal static void Draw(MarkOverlay overlay) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: 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_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: 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_0312: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: 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_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Expected O, but got Unknown //IL_0565: Unknown result type (might be due to invalid IL or missing references) bool japanese = Text.Japanese; float num = Mathf.Max(12f, (float)Screen.height / 52f); Styles(num); float num2 = Mathf.Min((float)Screen.width - num * 2f, num * 38f); float num3 = num * 7.4f; Rect rect = default(Rect); ((Rect)(ref rect))..ctor(((float)Screen.width - num2) / 2f, (float)Screen.height * 0.86f - num3, num2, num3); Fill(rect, new Color(0.02f, 0.05f, 0.03f, 0.72f)); Fill(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 2f), new Color(0.3f, 1f, 0.45f, 0.8f)); float num4 = num * 0.7f; float num5 = ((Rect)(ref rect)).x + num4; float num6 = ((Rect)(ref rect)).y + num4 * 0.6f; float num7 = ((Rect)(ref rect)).width - num4 * 2f; MarkOverlay.Room hovered = overlay.Hovered; Entry entry = ((hovered != null) ? Marks.GetEntry(hovered.Key) : default(Entry)); string text = ((hovered == null) ? Paint(japanese ? "部屋の外" : "No room under the cursor", "#9aa") : hovered.Name); if (hovered != null && entry.Mark != Mark.None) { (string name, Color color) tuple = MarkNet.Author(entry.Author); string item = tuple.name; Color item2 = tuple.color; string hex = "#" + ColorUtility.ToHtmlStringRGB(Icons.Tint(entry.Mark)); text = text + " " + Paint(Text.Name(entry.Mark, japanese), hex); if (item.Length > 0) { text = text + " " + Paint((japanese ? "by " : "by ") + Escape(item), "#" + ColorUtility.ToHtmlStringRGB(item2)); } } Shadowed(new Rect(num5, num6, num7, num * 1.7f), text, _title); num6 += num * 1.9f; float num8 = num7 / 4f; float num9 = num * 1.6f; Rect val = default(Rect); for (int i = 1; i < 5; i++) { Mark mark = (Mark)i; bool flag = hovered != null && entry.Mark == mark; ((Rect)(ref val))..ctor(num5 + num8 * (float)(i - 1), num6, num8, num * 2.2f); if (flag) { Color val2 = Icons.Tint(mark); Fill(new Rect(((Rect)(ref val)).x + 2f, ((Rect)(ref val)).y, ((Rect)(ref val)).width - 4f, ((Rect)(ref val)).height), new Color(val2.r, val2.g, val2.b, 0.25f)); Fill(new Rect(((Rect)(ref val)).x + 2f, ((Rect)(ref val)).yMax - 2f, ((Rect)(ref val)).width - 4f, 2f), val2); } Texture2D texture = Icons.For(mark).texture; Color color = GUI.color; GUI.color = (Color)((flag || hovered == null) ? Color.white : new Color(1f, 1f, 1f, 0.55f)); GUI.DrawTexture(new Rect(((Rect)(ref val)).x + num * 0.4f, ((Rect)(ref val)).y + (((Rect)(ref val)).height - num9) / 2f, num9, num9), (Texture)(object)texture); GUI.color = color; Shadowed(new Rect(((Rect)(ref val)).x + num * 0.4f + num9 + num * 0.3f, ((Rect)(ref val)).y, ((Rect)(ref val)).width - num9 - num * 0.9f, ((Rect)(ref val)).height), flag ? ("<b>" + Text.Name(mark, japanese) + "</b>") : Paint(Text.Name(mark, japanese), "#c8d0c8"), _small); } num6 += num * 2.5f; string text2 = (japanese ? "Shift+" : "Shift+"); string text3 = (japanese ? $"<b>[{Plugin.MarkKey.Value}]</b> 次へ <b>[{text2}{Plugin.MarkKey.Value}]</b> 前へ <b>[{Plugin.ClearKey.Value}]</b> 消す <b>[ホイール]</b> カーソル {overlay.CursorDistance:0}m" : $"<b>[{Plugin.MarkKey.Value}]</b> next <b>[{text2}{Plugin.MarkKey.Value}]</b> back <b>[{Plugin.ClearKey.Value}]</b> clear <b>[Wheel]</b> cursor {overlay.CursorDistance:0} m"); Shadowed(new Rect(num5, num6, num7, num * 1.6f), text3, _small); string text4 = (japanese ? "チェック済み " : "Checked ") + $"{overlay.CheckedRooms}/{overlay.RoomCount}"; GUIStyle style = new GUIStyle(_small) { alignment = (TextAnchor)5 }; Shadowed(new Rect(num5, num6, num7, num * 1.6f), Paint(text4, "#7dff9a"), style); } private static string Paint(string text, string hex) { return "<color=" + hex + ">" + text + "</color>"; } private static string Escape(string text) { return text.Replace("<", "‹").Replace(">", "›"); } private static void Fill(Rect rect, Color color) { //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_000b: Unknown result type (might be due to invalid IL or missing references) Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(rect, (Texture)(object)Pixel); GUI.color = color2; } private static void Shadowed(Rect rect, string text, GUIStyle style) { //IL_0000: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.85f); GUI.Label(new Rect(((Rect)(ref rect)).x + 1.5f, ((Rect)(ref rect)).y + 1.5f, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), StripColor(text), style); GUI.color = color; GUI.Label(rect, text, style); } private static string StripColor(string text) { return Regex.Replace(text, "</?color[^>]*>", ""); } } internal static class Text { internal static bool Japanese { get { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 LocaleAsset val = (((Object)(object)LocalizationManager.instance != (Object)null) ? LocalizationManager.instance.ActiveLocale : null); if ((Object)(object)val != (Object)null) { if (!val.NativeName.Contains("日本")) { return ((Object)val).name.ToLowerInvariant().Contains("ja"); } return true; } return (int)Application.systemLanguage == 22; } } internal static string Name(Mark mark, bool ja) { return mark switch { Mark.Checked => ja ? "チェック済み" : "Checked", Mark.Valuables => ja ? "貴重品あり" : "Valuables left", Mark.Danger => ja ? "危険" : "Danger", Mark.Later => ja ? "あとで戻る" : "Come back later", _ => ja ? "マークなし" : "No mark", }; } } internal static class Icons { private const int Size = 64; private static Sprite?[]? _marks; private static Sprite? _ring; private static Sprite? _square; private static Sprite? _dash; private static Sprite?[]? _patterns; internal const float PatternTile = 0.16f; private static readonly Color Clear = new Color(0f, 0f, 0f, 0f); internal static Sprite Dash => _dash ?? (_dash = MakeTile("Dash", (float x, float y) => (!(y < 0.55f)) ? Clear : Color.white)); internal static Sprite Ring => _ring ?? (_ring = Make("Cursor", delegate(float x, float y) { //IL_002f: 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_0023: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Abs(Length(x, y) - 0.8f); return (!(num < 0.12f)) ? ((!(num < 0.2f)) ? Clear : Color.black) : Color.white; })); internal static Sprite Square => _square ?? (_square = Make("Fill", (float x, float y) => Color.white)); internal static Color Tint(Mark mark) { //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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) return (Color)(mark switch { Mark.Checked => new Color(0.25f, 0.85f, 0.35f), Mark.Valuables => new Color(1f, 0.82f, 0.2f), Mark.Danger => new Color(0.95f, 0.25f, 0.2f), Mark.Later => new Color(0.3f, 0.6f, 1f), _ => Color.white, }); } internal static Sprite For(Mark mark) { if (_marks == null) { _marks = (Sprite?[]?)(object)new Sprite[5]; } ref Sprite reference = ref _marks[(uint)mark]; return reference ?? (reference = Make(mark.ToString(), (float x, float y) => Pixel(mark, x, y))); } internal static Sprite Pattern(Mark mark) { if (_patterns == null) { _patterns = (Sprite?[]?)(object)new Sprite[5]; } ref Sprite reference = ref _patterns[(uint)mark]; return reference ?? (reference = MakeTile(mark.ToString() + " pattern", (float x, float y) => PatternPixel(mark, x, y))); } internal static Color PatternColor(Mark mark) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0022: Unknown result type (might be due to invalid IL or missing references) Color val = Tint(mark); if (mark != Mark.Checked) { return new Color(val.r, val.g, val.b, 0.55f); } return new Color(0f, 0f, 0f, 0.5f); } private static Color PatternPixel(Mark mark, float x, float y) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) switch (mark) { case Mark.Checked: return Color.white; case Mark.Danger: if (!(Mathf.Repeat(x + y, 0.5f) < 0.18f)) { return new Color(1f, 1f, 1f, 0.25f); } return Color.white; case Mark.Valuables: { float num = Mathf.Repeat(x, 0.5f) - 0.25f; float num2 = Mathf.Repeat(y, 0.5f) - 0.25f; if (!(num * num + num2 * num2 < 0.012f)) { return new Color(1f, 1f, 1f, 0.25f); } return Color.white; } case Mark.Later: if (!(Mathf.Repeat(y, 0.5f) < 0.12f)) { return new Color(1f, 1f, 1f, 0.25f); } return Color.white; default: return Clear; } } private static Sprite MakeTile(string name, Func<float, float, Color> paint) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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) Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false) { name = "Room Marks " + name, filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)0 }; Color[] array = (Color[])(object)new Color[1024]; for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { array[i * 32 + j] = paint(((float)j + 0.5f) / 32f, ((float)i + 0.5f) / 32f); } } val.SetPixels(array); val.Apply(false, true); Sprite obj = Sprite.Create(val, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f), 200f, 0u, (SpriteMeshType)0); ((Object)obj).name = ((Object)val).name; return obj; } private static Color Pixel(Mark mark, float x, float y) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) Color result = Tint(mark); Color white = Color.white; Color result2 = default(Color); ((Color)(ref result2))..ctor(0f, 0f, 0f, 0.9f); float num = Length(x, y); switch (mark) { case Mark.Checked: if (num > 0.95f) { return Clear; } if (num > 0.82f) { return result2; } if (!(Segment(x, y, -0.45f, 0f, -0.12f, -0.35f) < 0.13f) && !(Segment(x, y, -0.12f, -0.35f, 0.5f, 0.38f) < 0.13f)) { return result; } return white; case Mark.Valuables: { float num3 = Mathf.Abs(x) + Mathf.Abs(y); if (num3 > 0.95f) { return Clear; } if (num3 > 0.8f) { return result2; } if (!(num3 < 0.32f) || !(y > -0.05f)) { return result; } return new Color(1f, 0.97f, 0.75f); } case Mark.Danger: { float num2 = Mathf.Max(0f - y - 0.75f, (Mathf.Abs(x) * 1.73f + y) * 0.5f - 0.45f); if (num2 > 0.06f) { return Clear; } if (num2 > -0.08f) { return result2; } if (!(Mathf.Abs(x) < 0.09f) || ((!(y > -0.25f) || !(y < 0.38f)) && (!(y > -0.55f) || !(y < -0.38f)))) { return result; } return white; } case Mark.Later: if (num > 0.95f) { return Clear; } if (num > 0.82f) { return result2; } if (!(Segment(x, y, 0f, 0f, 0f, 0.5f) < 0.09f) && !(Segment(x, y, 0f, 0f, 0.38f, 0f) < 0.09f)) { return result; } return white; default: return Clear; } } private static float Length(float x, float y) { return Mathf.Sqrt(x * x + y * y); } private static float Segment(float px, float py, float ax, float ay, float bx, float by) { float num = bx - ax; float num2 = by - ay; float num3 = Mathf.Clamp01(((px - ax) * num + (py - ay) * num2) / (num * num + num2 * num2)); return Length(px - ax - num * num3, py - ay - num2 * num3); } private static Sprite Make(string name, Func<float, float, Color> paint) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false) { name = "Room Marks " + name, filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; Color[] array = (Color[])(object)new Color[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { array[i * 64 + j] = paint(((float)j + 0.5f) / 64f * 2f - 1f, ((float)i + 0.5f) / 64f * 2f - 1f); } } val.SetPixels(array); val.Apply(false, true); Sprite obj = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 64f); ((Object)obj).name = ((Object)val).name; return obj; } } internal sealed class MarkOverlay : MonoBehaviour { internal sealed class Room { internal Module Module; internal Vector3Int Key; internal readonly List<(Vector3 center, Vector3 size, float yaw)> Areas = new List<(Vector3, Vector3, float)>(); internal Vector3 Center; internal float Span; internal string Name = ""; } private Map? _map; private Transform? _root; private readonly Dictionary<Module, Room> _rooms = new Dictionary<Module, Room>(); private readonly Dictionary<Vector3Int, Room> _byKey = new Dictionary<Vector3Int, Room>(); private readonly List<SpriteRenderer> _icons = new List<SpriteRenderer>(); private readonly List<GameObject> _markParts = new List<GameObject>(); private readonly List<SpriteRenderer> _hoverParts = new List<SpriteRenderer>(); private SpriteRenderer? _cursor; private SpriteRenderer? _line; private int _drawnVersion = -1; private Room? _drawnHover; private float _nextScan; private bool _entered; private readonly Collider[] _hits = (Collider[])(object)new Collider[16]; internal static MarkOverlay? Instance { get; private set; } internal float CursorDistance { get; set; } = 6f; internal Room? Hovered { get; private set; } internal bool MapOpen { get; private set; } internal Mark HoveredMark { get { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (Hovered == null) { return Mark.None; } return Marks.Get(Hovered.Key); } } internal int RoomCount => _rooms.Count; internal Transform? Root => _root; internal IEnumerable<Room> Rooms => _rooms.Values; internal int Flickers { get; private set; } internal int CheckedRooms => _rooms.Values.Count((Room r) => Marks.Get(r.Key) == Mark.Checked); private void Awake() { Instance = this; Marks.Changed += OnChanged; } private void OnDestroy() { Marks.Changed -= OnChanged; } private void Update() { try { Tick(); } catch (Exception ex) { Plugin.Log.LogError((object)ex); ((Behaviour)this).enabled = false; } } private void Tick() { //IL_00ae: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_043a: 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) Map instance = Map.Instance; if (!((Object)(object)instance != (Object)null) || !((Object)(object)PlayerController.instance != (Object)null) || SemiFunc.MenuLevel() || SemiFunc.RunIsShop() || SemiFunc.RunIsArena() || SemiFunc.RunIsLobby() || !((Object)(object)LevelGenerator.Instance != (Object)null) || !LevelGenerator.Instance.Generated) { if ((Object)(object)_map != (Object)null || (Object)(object)_root != (Object)null) { Reset(); } Marks.Leave(); return; } if ((Object)(object)instance != (Object)(object)_map) { Reset(); _map = instance; } if ((Object)(object)_root == (Object)null) { _root = new GameObject("Room Marks").transform; _root.SetParent(instance.OverLayerParent, false); ((Component)_root).gameObject.layer = ((Component)instance.OverLayerParent).gameObject.layer; _cursor = Sprite("Cursor", Icons.Ring, Color.white, 0.2f); _line = Sprite("Cursor line", Icons.Dash, new Color(1f, 1f, 1f, 0.6f), 1f); _line.drawMode = (SpriteDrawMode)2; ((Renderer)_line).sortingOrder = 4; ((Renderer)_cursor).sortingOrder = 5; } if (Time.unscaledTime >= _nextScan) { Scan(); _nextScan = Time.unscaledTime + 2f; } if (!_entered) { _entered = true; int token = Marks.LevelToken(Object.FindObjectsByType<Module>((FindObjectsSortMode)0)); Marks.Enter(token); MarkNet.RequestSync(token); } MapOpen = instance.Active; Hovered = (MapOpen ? RoomAt(CursorWorld()) : null); if (MapOpen) { HandleInput(); } if (_drawnVersion != Marks.Version) { DrawMarks(); } if (_drawnHover != Hovered) { DrawHover(); } float y = ((Component)PlayerController.instance).transform.eulerAngles.y; Quaternion rotation = Quaternion.Euler(90f, y, 0f); foreach (SpriteRenderer icon in _icons) { if ((Object)(object)icon != (Object)null) { ((Component)icon).transform.rotation = rotation; } } float num = 0.12f + 0.1f * (0.5f + 0.5f * Mathf.Sin(Time.unscaledTime * 6f)); foreach (SpriteRenderer hoverPart in _hoverParts) { if ((Object)(object)hoverPart != (Object)null) { hoverPart.color = new Color(1f, 1f, 1f, num); } } if (!((Object)(object)_cursor != (Object)null) || !((Object)(object)_line != (Object)null)) { return; } ((Component)_cursor).gameObject.SetActive(MapOpen); float num2 = CursorDistance * _map.Scale - 0.12f; ((Component)_line).gameObject.SetActive(MapOpen && num2 > 0.05f); if (MapOpen) { Vector3 val = CursorWorld(); Place(((Component)_cursor).transform, val, 0.18f, rotation); _cursor.color = (Color)((Hovered != null) ? Color.white : new Color(1f, 1f, 1f, 0.45f)); if (num2 > 0.05f) { Vector3 val2 = ((Component)PlayerController.instance).transform.position + Vector3.up; Vector3 val3 = val - val2; Vector3 normalized = ((Vector3)(ref val3)).normalized; Place(((Component)_line).transform, val2 + normalized * (CursorDistance * 0.5f - 0.6f), 0.17f, rotation); _line.size = new Vector2(0.025f, num2); } } } private void HandleInput() { //IL_00b3: 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) if (!SemiFunc.NoTextInputsActive()) { return; } PhysGrabber val = (((Object)(object)PlayerAvatar.instance != (Object)null) ? PlayerAvatar.instance.physGrabber : null); if ((Object)(object)val == (Object)null || !val.grabbed) { float num = SemiFunc.InputScrollY(); if (Mathf.Abs(num) > 0.01f) { float num2 = Mathf.Clamp(CursorDistance + Mathf.Sign(num) * Plugin.CursorStep.Value, 0f, 60f); if (num2 != CursorDistance && Plugin.Sounds.Value) { Click((MenuClickEffectType)4, 1.4f, 0.35f); } CursorDistance = num2; } } Keyboard current = Keyboard.current; if (current != null && Hovered != null) { if (Pressed(current, Plugin.MarkKey.Value)) { bool flag = ((ButtonControl)current.leftShiftKey).isPressed || ((ButtonControl)current.rightShiftKey).isPressed; Step((!flag) ? 1 : (-1)); } else if (Pressed(current, Plugin.ClearKey.Value)) { ClearHovered(); } } } private static bool Pressed(Keyboard keyboard, Key key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) if ((int)key != 0) { return ((ButtonControl)keyboard[key]).wasPressedThisFrame; } return false; } internal void Step(int direction) { //IL_000f: 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) if (Hovered != null) { int num = ((int)Marks.Get(Hovered.Key) + direction + 5) % 5; Marks.Set(Hovered.Key, (Mark)num); } } internal void CycleHovered() { Step(1); } internal void ClearHovered() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (Hovered != null) { Marks.Set(Hovered.Key, Mark.None); } } private void OnChanged(Vector3Int key, Entry entry, bool remote) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Sounds.Value) { return; } if (!remote) { Click((MenuClickEffectType)((entry.Mark == Mark.None) ? 2 : 0), -1f, 0.6f); return; } if (entry.Mark != Mark.None && (Object)(object)MapToolController.instance != (Object)null) { MapToolController.instance.LedFlicker(Icons.Tint(entry.Mark), 0.6f); Flickers++; } if (MapOpen) { Click((MenuClickEffectType)4, 0.8f, 0.5f); } } private static void Click(MenuClickEffectType type, float pitch, float volume) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)MenuManager.instance != (Object)null) { MenuManager.instance.MenuEffectClick(type, (MenuPage)null, pitch, volume, true, false); } } catch (Exception ex) { Plugin.Log.LogDebug((object)ex); } } internal Vector3 CursorWorld() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)PlayerController.instance).transform; Vector3 val = Vector3.ProjectOnPlane(transform.forward, Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; return transform.position + Vector3.up + normalized * CursorDistance; } private Room? RoomAt(Vector3 point) { //IL_0000: 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_001b: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapBoxNonAlloc(point, new Vector3(0.2f, 1.2f, 0.2f), _hits, Quaternion.identity, LayerMask.GetMask(new string[1] { "RoomVolume" }), (QueryTriggerInteraction)2); Room room = null; for (int i = 0; i < num; i++) { RoomVolume componentInParent = ((Component)_hits[i]).GetComponentInParent<RoomVolume>(); if ((Object)(object)componentInParent?.Module != (Object)null && _rooms.TryGetValue(componentInParent.Module, out Room value) && (room == null || value.Span < room.Span)) { room = value; } } return room; } private void Scan() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0186: 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_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) RoomVolume[] array = Object.FindObjectsByType<RoomVolume>((FindObjectsSortMode)0); foreach (RoomVolume val in array) { if ((Object)(object)val == (Object)null || (Object)(object)val.Module == (Object)null || val.Truck || val.Extraction) { continue; } if (!_rooms.TryGetValue(val.Module, out Room value)) { value = new Room { Module = val.Module, Key = Marks.Key(val.Module), Name = RoomName(val.Module) }; _rooms[val.Module] = value; _byKey[value.Key] = value; } else if (value.Areas.Count > 0) { continue; } BoxCollider[] componentsInChildren = ((Component)val).GetComponentsInChildren<BoxCollider>(); foreach (BoxCollider val2 in componentsInChildren) { Vector3 val3 = Vector3.Scale(val2.size, ((Component)val2).transform.lossyScale); value.Areas.Add((((Component)val2).transform.TransformPoint(val2.center), new Vector3(Mathf.Abs(val3.x), 0f, Mathf.Abs(val3.z)), ((Component)val2).transform.eulerAngles.y)); } MeshCollider[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<MeshCollider>(); foreach (MeshCollider val4 in componentsInChildren2) { List<(Vector3 center, Vector3 size, float yaw)> areas = value.Areas; Bounds bounds = ((Collider)val4).bounds; Vector3 center = ((Bounds)(ref bounds)).center; bounds = ((Collider)val4).bounds; float x = ((Bounds)(ref bounds)).size.x; bounds = ((Collider)val4).bounds; areas.Add((center, new Vector3(x, 0f, ((Bounds)(ref bounds)).size.z), 0f)); } if (value.Areas.Count != 0) { (Vector3, Vector3, float) tuple = value.Areas.OrderByDescending(((Vector3 center, Vector3 size, float yaw) a) => a.size.x * a.size.z).First(); value.Center = tuple.Item1; value.Span = value.Areas.Sum(((Vector3 center, Vector3 size, float yaw) a) => a.size.x * a.size.z); _drawnVersion = -1; } } } internal static string RoomName(Module module) { string text = ((Object)module).name.Replace("(Clone)", "").Trim(); int num = text.LastIndexOf(" - ", StringComparison.Ordinal); if (num < 0) { return text; } return text.Substring(num + 3).Trim(); } private void DrawMarks() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) _drawnVersion = Marks.Version; foreach (GameObject markPart in _markParts) { if ((Object)(object)markPart != (Object)null) { Object.Destroy((Object)(object)markPart); } } _markParts.Clear(); _icons.Clear(); foreach (KeyValuePair<Vector3Int, Entry> item in Marks.All) { if (!_byKey.TryGetValue(item.Key, out Room value) || value.Areas.Count == 0) { continue; } foreach (var area in value.Areas) { SpriteRenderer val = Sprite("Mark fill", Icons.Pattern(item.Value.Mark), Icons.PatternColor(item.Value.Mark), 1f); Place(((Component)val).transform, area.center, 0.12f, Quaternion.Euler(90f, area.yaw, 0f)); val.drawMode = (SpriteDrawMode)2; val.size = new Vector2(area.size.x * _map.Scale, area.size.z * _map.Scale); ((Renderer)val).sortingOrder = 1; _markParts.Add(((Component)val).gameObject); } float size = Mathf.Clamp(Mathf.Sqrt(value.Span) * _map.Scale * 0.45f, 0.4f, 0.7f); SpriteRenderer val2 = Sprite("Mark icon", Icons.For(item.Value.Mark), Color.white, size); Place(((Component)val2).transform, value.Center, 0.16f, Quaternion.identity); ((Renderer)val2).sortingOrder = 3; _markParts.Add(((Component)val2).gameObject); _icons.Add(val2); } } private void DrawHover() { //IL_00a0: 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_00d4: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) _drawnHover = Hovered; foreach (SpriteRenderer hoverPart in _hoverParts) { if ((Object)(object)hoverPart != (Object)null) { Object.Destroy((Object)(object)((Component)hoverPart).gameObject); } } _hoverParts.Clear(); if (Hovered == null) { return; } foreach (var area in Hovered.Areas) { SpriteRenderer val = Sprite("Hover fill", Icons.Square, new Color(1f, 1f, 1f, 0.18f), 1f); Place(((Component)val).transform, area.center, 0.14f, Quaternion.Euler(90f, area.yaw, 0f)); ((Component)val).transform.localScale = new Vector3(area.size.x * _map.Scale, area.size.z * _map.Scale, 1f); ((Renderer)val).sortingOrder = 2; _hoverParts.Add(val); } } private void Place(Transform part, Vector3 world, float height, Quaternion rotation) { //IL_0014: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) Transform overLayerParent = _map.OverLayerParent; MapLayer component = ((Component)overLayerParent).GetComponent<MapLayer>(); part.position = world * _map.Scale + overLayerParent.position + (((Object)(object)component != (Object)null) ? _map.GetLayerPosition(component.layer) : Vector3.zero); part.localPosition = new Vector3(part.localPosition.x, height, part.localPosition.z); part.rotation = rotation; } private SpriteRenderer Sprite(string name, Sprite sprite, Color color, float size) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0034: 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_0052: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name) { layer = ((Component)_root).gameObject.layer }; val.transform.SetParent(_root, false); val.transform.localScale = Vector3.one * size; SpriteRenderer obj = val.AddComponent<SpriteRenderer>(); obj.sprite = sprite; obj.color = color; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; return obj; } private void Reset() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)((Component)_root).gameObject); } _root = null; _cursor = null; _line = null; _map = null; _rooms.Clear(); _byKey.Clear(); _icons.Clear(); _markParts.Clear(); _hoverParts.Clear(); _drawnVersion = -1; _drawnHover = null; Hovered = null; MapOpen = false; _nextScan = 0f; _entered = false; CursorDistance = 6f; } private void OnGUI() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 if (MapOpen && Plugin.ShowHint.Value && (int)Event.current.type == 7) { Hud.Draw(this); } } } internal enum Mark : byte { None, Checked, Valuables, Danger, Later } internal readonly struct Entry { internal readonly Mark Mark; internal readonly int Author; internal Entry(Mark mark, int author) { Mark = mark; Author = author; } } internal static class Marks { internal const int Count = 5; private static readonly Dictionary<int, Dictionary<Vector3Int, Entry>> Levels = new Dictionary<int, Dictionary<Vector3Int, Entry>>(); internal static int Current { get; private set; } internal static int Version { get; private set; } internal static IEnumerable<KeyValuePair<Vector3Int, Entry>> All { get { if (Current == 0 || !Levels.TryGetValue(Current, out Dictionary<Vector3Int, Entry> value)) { return Enumerable.Empty<KeyValuePair<Vector3Int, Entry>>(); } return value; } } internal static event Action<Vector3Int, Entry, bool>? Changed; internal static Vector3Int Key(Module module) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)module).transform.position; return new Vector3Int(Mathf.RoundToInt(position.x * 2f), Mathf.RoundToInt(position.y * 2f), Mathf.RoundToInt(position.z * 2f)); } internal static int LevelToken(IEnumerable<Module> modules) { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) int num = -2128831035; foreach (Vector3Int item in from k in modules.Where((Module m) => (Object)(object)m != (Object)null).Select(Key) orderby ((Vector3Int)(ref k)).x, ((Vector3Int)(ref k)).y, ((Vector3Int)(ref k)).z select k) { Vector3Int current = item; num = (((((num ^ ((Vector3Int)(ref current)).x) * 16777619) ^ ((Vector3Int)(ref current)).y) * 16777619) ^ ((Vector3Int)(ref current)).z) * 16777619; } if (num != 0) { return num; } return 1; } internal static void Enter(int token) { if (token == Current) { return; } Current = token; foreach (int item in Levels.Keys.Where((int k) => k != token).ToList()) { Levels.Remove(item); } Version++; } internal static void Leave() { if (Current != 0) { Levels.Remove(Current); Current = 0; Version++; } } private static Dictionary<Vector3Int, Entry> Level(int token) { if (!Levels.TryGetValue(token, out Dictionary<Vector3Int, Entry> value)) { value = (Levels[token] = new Dictionary<Vector3Int, Entry>()); } return value; } internal static Entry GetEntry(Vector3Int key) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (Current == 0 || !Levels.TryGetValue(Current, out Dictionary<Vector3Int, Entry> value) || !value.TryGetValue(key, out var value2)) { return default(Entry); } return value2; } internal static Mark Get(Vector3Int key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetEntry(key).Mark; } internal static bool Apply(int token, Vector3Int key, Mark mark, int author, bool remote) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (token == 0) { return false; } Dictionary<Vector3Int, Entry> dictionary = Level(token); bool num; if (!dictionary.TryGetValue(key, out var value)) { num = mark == Mark.None; } else { if (value.Mark != mark) { goto IL_0036; } num = value.Author == author; } if (num) { return false; } goto IL_0036; IL_0036: if (mark == Mark.None) { dictionary.Remove(key); } else { dictionary[key] = new Entry(mark, author); } if (token == Current) { Version++; try { Marks.Changed?.Invoke(key, new Entry(mark, author), remote); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } return true; } internal static void Set(Vector3Int key, Mark mark) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (Current != 0 && Apply(Current, key, mark, MarkNet.LocalActor, remote: false)) { MarkNet.SendSet(Current, key, mark); } } internal static IEnumerable<KeyValuePair<Vector3Int, Entry>> Snapshot(int token) { if (!Levels.TryGetValue(token, out Dictionary<Vector3Int, Entry> value)) { return new List<KeyValuePair<Vector3Int, Entry>>(); } return value.ToList(); } } internal static class MarkNet { internal const byte SetCode = 167; internal const byte RequestCode = 168; internal const byte BulkCode = 169; private static bool _registered; internal static int LocalActor { get { if (!PhotonNetwork.InRoom) { return 0; } return PhotonNetwork.LocalPlayer.ActorNumber; } } private static bool Online { get { if (PhotonNetwork.InRoom && SemiFunc.IsMultiplayer()) { return Plugin.Share.Value; } return false; } } internal static void Register() { if (!_registered) { PhotonNetwork.NetworkingClient.EventReceived += Receive; _registered = true; } } internal static void SendSet(int token, Vector3Int key, Mark mark) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown if (Online) { PhotonNetwork.RaiseEvent((byte)167, (object)new int[5] { token, ((Vector3Int)(ref key)).x, ((Vector3Int)(ref key)).y, ((Vector3Int)(ref key)).z, (int)mark }, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } } internal static void RequestSync(int token) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown if (Online && !PhotonNetwork.IsMasterClient) { PhotonNetwork.RaiseEvent((byte)168, (object)new int[1] { token }, new RaiseEventOptions { Receivers = (ReceiverGroup)2 }, SendOptions.SendReliable); } } private static void SendBulk(int token, int actor) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) List<KeyValuePair<Vector3Int, Entry>> list = Marks.Snapshot(token).ToList(); int[] array = new int[1 + list.Count * 5]; array[0] = token; for (int i = 0; i < list.Count; i++) { Vector3Int key = list[i].Key; Entry value = list[i].Value; Vector3Int val = key; int num = 1 + i * 5; array[num] = ((Vector3Int)(ref val)).x; array[num + 1] = ((Vector3Int)(ref val)).y; array[num + 2] = ((Vector3Int)(ref val)).z; array[num + 3] = (int)value.Mark; array[num + 4] = value.Author; } RaiseEventOptions val2 = new RaiseEventOptions(); val2.TargetActors = new int[1] { actor }; PhotonNetwork.RaiseEvent((byte)169, (object)array, val2, SendOptions.SendReliable); } internal static void Receive(EventData data) { //IL_0094: 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) if ((data.Code != 167 && data.Code != 168 && data.Code != 169) || !Plugin.Share.Value || !(data.CustomData is int[] array) || array.Length == 0 || array[0] == 0) { return; } try { switch (data.Code) { case 167: if (array.Length == 5 && Valid(array[4])) { Marks.Apply(array[0], new Vector3Int(array[1], array[2], array[3]), (Mark)array[4], data.Sender, remote: true); } break; case 168: if (PhotonNetwork.IsMasterClient && array.Length == 1 && data.Sender > 0) { SendBulk(array[0], data.Sender); } break; case 169: { if ((array.Length - 1) % 5 != 0) { break; } for (int i = 1; i < array.Length; i += 5) { if (Valid(array[i + 3])) { Marks.Apply(array[0], new Vector3Int(array[i], array[i + 1], array[i + 2]), (Mark)array[i + 3], array[i + 4], remote: true); } } break; } } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } private static bool Valid(int mark) { if (mark >= 0) { return mark < 5; } return false; } internal static (string name, Color color) Author(int actor) { //IL_0042: 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_008e: 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) if (actor == 0 || actor == LocalActor) { return (name: ((Object)(object)PlayerAvatar.instance != (Object)null) ? SemiFunc.PlayerGetName(PlayerAvatar.instance) : "", color: ((Object)(object)PlayerAvatar.instance != (Object)null) ? SemiFunc.PlayerGetColorMain(PlayerAvatar.instance) : Color.white); } foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if ((Object)(object)item != (Object)null && (Object)(object)item.photonView != (Object)null && item.photonView.OwnerActorNr == actor) { return (name: SemiFunc.PlayerGetName(item), color: SemiFunc.PlayerGetColorMain(item)); } } Room currentRoom = PhotonNetwork.CurrentRoom; Player obj = ((currentRoom != null) ? currentRoom.GetPlayer(actor, false) : null); return (name: ((obj != null) ? obj.NickName : null) ?? "?", color: Color.white); } } [BepInPlugin("matsu.RoomMarks", "Room Marks", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "matsu.RoomMarks"; public const string Name = "Room Marks"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<Key> MarkKey; internal static ConfigEntry<Key> ClearKey; internal static ConfigEntry<float> CursorStep; internal static ConfigEntry<bool> ShowHint; internal static ConfigEntry<bool> Share; internal static ConfigEntry<bool> Sounds; private void Awake() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; MarkKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Controls", "MarkKey", (Key)32, "While the map is open: cycle the mark on the room under the cursor (none, checked, valuables left, danger, come back later). Hold Shift to cycle backwards."); ClearKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Controls", "ClearKey", (Key)38, "While the map is open: remove the mark from the room under the cursor."); CursorStep = ((BaseUnityPlugin)this).Config.Bind<float>("Controls", "CursorStep", 2f, new ConfigDescription("Metres the map cursor moves per mouse-wheel notch.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>())); ShowHint = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "ShowHint", true, "Show the mark panel at the bottom of the screen while the map is open."); Share = ((BaseUnityPlugin)this).Config.Bind<bool>("Multiplayer", "ShareWithTeam", true, "Send your marks to teammates and show theirs. Teammates need this mod too; players without it are unaffected."); Sounds = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "Sounds", true, "Play a short click when a mark changes, and flash the map's light when a teammate sets one."); GameObject val = new GameObject("Room Marks"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent<MarkOverlay>(); MarkNet.Register(); Log.LogInfo((object)"Room Marks 1.0.0 loaded."); } } }