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 RunestoneSigns v0.1.5
BepInEx/plugins/RunestoneSigns/RunestoneSigns.dll
Decompiled 16 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("RunestoneSigns")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.5.0")] [assembly: AssemblyInformationalVersion("0.1.5")] [assembly: AssemblyProduct("RunestoneSigns")] [assembly: AssemblyTitle("RunestoneSigns")] [assembly: AssemblyVersion("0.1.5.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 RunestoneSigns { public sealed class Catalog { public sealed class Entry { public string Id; public string Style; public string Label; public string Title; } public static readonly string[] Styles = new string[8] { "oak", "ironbound-oak", "dvergr-workshop", "druid-grove", "royal-longhouse", "frosthold", "ashen-forge", "harvest-hearth" }; public static readonly string[] StyleNames = new string[8] { "Oak", "Ironbound Oak", "Dvergr Workshop", "Druid Grove", "Royal Longhouse", "Frosthold", "Ashen Forge", "Harvest Hearth" }; public readonly Dictionary<string, Entry> Entries = new Dictionary<string, Entry>(StringComparer.Ordinal); public readonly string Root; public Catalog(string root) { Root = root; string path = Path.Combine(root, "catalog.tsv"); if (!File.Exists(path)) { return; } string[] array = File.ReadAllLines(path); foreach (string text in array) { if (!text.StartsWith("#") && !string.IsNullOrWhiteSpace(text)) { string[] array2 = text.Split('\t'); if (array2.Length != 3 || !Styles.Contains(array2[0]) || !SafeId(array2[1]) || array2[2].Length > 80) { throw new InvalidDataException("Invalid catalog entry"); } string text2 = array2[0] + "/" + array2[1]; if (Entries.ContainsKey(text2)) { throw new InvalidDataException("Duplicate catalog ID"); } Entries.Add(text2, new Entry { Id = text2, Style = array2[0], Label = array2[1], Title = array2[2] }); } } } public static bool SafeId(string id) { if (id != null) { return Regex.IsMatch(id, "\\A[a-z0-9][a-z0-9-]{0,79}\\z"); } return false; } public bool Valid(string id) { if (id != null && id.Length <= 120) { return Entries.ContainsKey(id); } return false; } public string PathFor(string id, bool thumb) { if (!Valid(id)) { return null; } return Path.Combine(Root, thumb ? "thumbs" : "signs", id.Replace('/', Path.DirectorySeparatorChar) + ".jpg"); } public IEnumerable<Entry> Search(string style, string query) { return Entries.Values.Where((Entry e) => e.Style == style && e.Title.IndexOf(query ?? "", StringComparison.OrdinalIgnoreCase) >= 0).OrderBy<Entry, string>((Entry e) => e.Title, StringComparer.Ordinal); } } public sealed class TextureCache : IDisposable { private sealed class Item { public Texture2D Texture; public int Pins; public long Tick; } private readonly Dictionary<string, Item> items = new Dictionary<string, Item>(); private readonly Catalog catalog; private readonly int capacity; private readonly bool thumbs; private long clock; public int Count => items.Count; public TextureCache(Catalog catalog, int capacity, bool thumbs) { this.catalog = catalog; this.capacity = capacity; this.thumbs = thumbs; } public Texture2D Get(string id, bool pin = false) { //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown if (!catalog.Valid(id)) { return null; } if (items.TryGetValue(id, out var value)) { value.Tick = ++clock; if (pin) { value.Pins++; } return value.Texture; } string path = catalog.PathFor(id, thumbs); if (!File.Exists(path)) { return null; } if (items.Count >= capacity) { KeyValuePair<string, Item> keyValuePair = (from p in items where p.Value.Pins == 0 orderby p.Value.Tick select p).FirstOrDefault(); if (keyValuePair.Key == null) { return null; } Object.Destroy((Object)(object)keyValuePair.Value.Texture); items.Remove(keyValuePair.Key); } Texture2D val = null; try { byte[] array = File.ReadAllBytes(path); if (array.Length > 1048576) { return null; } val = new Texture2D(2, 2, (TextureFormat)3, false); if (!ImageConversion.LoadImage(val, array, true) || ((Texture)val).width != (thumbs ? 160 : 512) || ((Texture)val).height != (thumbs ? 88 : 282)) { Object.Destroy((Object)(object)val); return null; } ((Texture)val).wrapMode = (TextureWrapMode)1; items.Add(id, new Item { Texture = val, Pins = (pin ? 1 : 0), Tick = ++clock }); return val; } catch (Exception) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } return null; } } public void Release(string id) { if (id != null && items.TryGetValue(id, out var value)) { value.Pins = Math.Max(0, value.Pins - 1); } } public void Dispose() { foreach (Item value in items.Values) { if (Object.op_Implicit((Object)(object)value.Texture)) { Object.Destroy((Object)(object)value.Texture); } } items.Clear(); } } public sealed class Picker { private readonly Plugin plugin; private readonly PickerArt art; private Sign target; private SignSkin skin; private string selected = ""; private string expected = ""; private string query = ""; private string status = ""; private int style; private int page; private int token; private float deadline; private bool pending; private string previewId; private Texture2D preview; private Texture2D background; private bool focusSearch; public static int SuppressMenuThrough; public bool Open => Object.op_Implicit((Object)(object)target); public Picker(Plugin plugin) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown this.plugin = plugin; art = new PickerArt(plugin.Catalog.Root); string path = Path.Combine(plugin.Catalog.Root, "ui", "picker-background.png"); if (File.Exists(path)) { background = new Texture2D(2, 2); if (!ImageConversion.LoadImage(background, File.ReadAllBytes(path), true)) { Object.Destroy((Object)(object)background); background = null; } } } public void Show(Sign s) { Close(); target = s; skin = ((Component)s).GetComponent<SignSkin>(); expected = skin.Current; selected = (plugin.Catalog.Valid(expected) ? expected : ""); if (selected != "") { style = Array.IndexOf(Catalog.Styles, plugin.Catalog.Entries[selected].Style); } query = ""; page = 0; status = "Choose a style and label. Native sign text stays saved."; focusSearch = true; } public void Close() { target = null; skin = null; pending = false; ReleasePreview(); GUIUtility.keyboardControl = 0; GUIUtility.hotControl = 0; SuppressMenuThrough = Time.frameCount + 1; GameCamera instance = GameCamera.instance; if (instance != null) { instance.UpdateMouseCapture(); } } public void Dispose() { Close(); art.Dispose(); if (Object.op_Implicit((Object)(object)background)) { Object.Destroy((Object)(object)background); } } public void Tick() { if (Open) { if (!Object.op_Implicit((Object)(object)skin) || !SignSkin.CanEdit(target, Player.m_localPlayer)) { Close(); } else if (ZInput.GetKeyDown((KeyCode)27, true)) { Close(); } else if (pending && Time.unscaledTime > deadline) { pending = false; status = "No confirmation. Owner may lack the mod; reopen before retrying."; } } } public void Acknowledge(SignSkin source, int request, string message) { if (Open && !((Object)(object)source != (Object)(object)skin) && request == token && pending) { pending = false; status = message; if (message == "Applied") { expected = skin.Current; Close(); } } } private void ReleasePreview() { if (previewId != null) { plugin.Full.Release(previewId); } previewId = null; preview = null; } private void Submit(string id) { if (!pending) { pending = true; deadline = Time.unscaledTime + 6f; token++; status = "Waiting for sign owner."; if (!skin.Apply(id, expected, token)) { pending = false; status = "Could not apply. Check range and access."; } } } public void Draw() { //IL_0a2b: Unknown result type (might be due to invalid IL or missing references) //IL_0a31: Unknown result type (might be due to invalid IL or missing references) //IL_0a37: 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_0014: Invalid comparison between Unknown and I4 //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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) //IL_0022: Invalid comparison between Unknown and I4 //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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_018f: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: 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_01a7: Expected O, but got Unknown //IL_01bd: 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_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0219: 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_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_030c: 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_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Invalid comparison between Unknown and I4 //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_05db: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_063d: 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_055d: Unknown result type (might be due to invalid IL or missing references) //IL_067c: Unknown result type (might be due to invalid IL or missing references) //IL_06ad: 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_077f: Unknown result type (might be due to invalid IL or missing references) //IL_07a8: Unknown result type (might be due to invalid IL or missing references) //IL_0834: Unknown result type (might be due to invalid IL or missing references) //IL_0884: Unknown result type (might be due to invalid IL or missing references) //IL_085f: 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_08c9: 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_08dd: Expected O, but got Unknown //IL_08f1: Unknown result type (might be due to invalid IL or missing references) //IL_0916: Unknown result type (might be due to invalid IL or missing references) //IL_0950: Unknown result type (might be due to invalid IL or missing references) //IL_0997: Unknown result type (might be due to invalid IL or missing references) //IL_0a00: Unknown result type (might be due to invalid IL or missing references) if (!Open) { return; } if ((int)Event.current.type == 4 && (int)Event.current.keyCode == 27) { Event.current.Use(); Close(); return; } Matrix4x4 matrix = GUI.matrix; Color color = GUI.color; Color backgroundColor = GUI.backgroundColor; bool enabled = GUI.enabled; float num = Mathf.Min((float)Screen.width / 1140f, (float)Screen.height / 740f); GUI.matrix = Matrix4x4.TRS(Vector2.op_Implicit(new Vector2(((float)Screen.width - 1100f * num) / 2f, ((float)Screen.height - 700f * num) / 2f)), Quaternion.identity, new Vector3(num, num, 1f)); try { GUI.color = new Color(0.09f, 0.12f, 0.13f, 0.98f); GUI.DrawTexture(new Rect(0f, 0f, 1100f, 700f), (Texture)(object)Texture2D.whiteTexture); GUI.color = Color.white; GUI.backgroundColor = Color.white; if (Object.op_Implicit((Object)(object)background)) { GUI.DrawTexture(new Rect(0f, 0f, 1100f, 700f), (Texture)(object)background, (ScaleMode)0); } art.Ensure(); GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 28, fontStyle = (FontStyle)1 }; GUIStyle val2 = new GUIStyle(GUI.skin.label) { fontSize = 16, wordWrap = true }; GUIStyle val3 = new GUIStyle(val2) { fontSize = 14, alignment = (TextAnchor)4 }; val.normal.textColor = new Color(0.98f, 0.88f, 0.64f); val2.normal.textColor = new Color(0.92f, 0.91f, 0.85f); val3.normal.textColor = val2.normal.textColor; art.Glyph(new Rect(30f, 20f, 48f, 48f), "icon"); art.Glyph(new Rect(200f, 26f, 700f, 46f), "title"); GUI.Label(new Rect(32f, 78f, 1000f, 24f), "A place for everything | Choose the mark for your stores", val2); if (art.Button(new Rect(1028f, 32f, 36f, 36f), "", chosen: false, "Close picker")) { Close(); return; } art.Glyph(new Rect(1034f, 38f, 24f, 24f), "close"); GUI.enabled = !pending; for (int i = 0; i < Catalog.Styles.Length; i++) { if (art.Button(new Rect(28f, (float)(104 + i * 60), 190f, 52f), Catalog.StyleNames[i], i == style)) { style = i; page = 0; selected = ""; ReleasePreview(); } } GUI.SetNextControlName("runestone-search"); string text = art.Search(new Rect(238f, 104f, 510f, 30f), query); if (text != query) { query = text; page = 0; } art.Glyph(new Rect(245f, 108f, 22f, 22f), "search"); if (focusSearch && (int)Event.current.type == 7) { GUI.FocusControl("runestone-search"); focusSearch = false; } if (query.Length == 0 && GUI.GetNameOfFocusedControl() != "runestone-search") { GUI.Label(new Rect(274f, 106f, 450f, 26f), "Search labels...", val2); } Catalog.Entry[] array = plugin.Catalog.Search(Catalog.Styles[style], query).ToArray(); int num2 = Math.Max(1, (array.Length + 8) / 9); page = Mathf.Clamp(page, 0, num2 - 1); Rect rect = default(Rect); for (int j = 0; j < 9 && page * 9 + j < array.Length; j++) { Catalog.Entry entry = array[page * 9 + j]; ((Rect)(ref rect))..ctor((float)(238 + j % 3 * 170), (float)(140 + j / 3 * 136), 162f, 128f); if (art.Card(rect, selected == entry.Id)) { selected = entry.Id; ReleasePreview(); } Texture2D val4 = plugin.Thumbs.Get(entry.Id); if (Object.op_Implicit((Object)(object)val4)) { GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + 6f, ((Rect)(ref rect)).y + 6f, 150f, 83f), (Texture)(object)val4, (ScaleMode)2); } GUI.Label(new Rect(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y + 90f, 146f, 33f), entry.Title, val3); } if (array.Length == 0) { GUI.Label(new Rect(248f, 180f, 480f, 100f), (plugin.Catalog.Entries.Count == 0) ? "Artwork is not installed. This development build cannot apply skins." : "No labels match your search.", val2); } GUI.enabled = !pending && page > 0; if (art.Button(new Rect(238f, 554f, 80f, 32f), "", chosen: false, "Previous page")) { page--; } art.Glyph(new Rect(264f, 558f, 28f, 24f), "left"); GUI.enabled = !pending; GUI.Label(new Rect(328f, 556f, 330f, 30f), page + 1 + " / " + num2 + " | " + array.Length + " labels", val2); GUI.enabled = !pending && page < num2 - 1; if (art.Button(new Rect(668f, 554f, 80f, 32f), "", chosen: false, "Next page")) { page++; } art.Glyph(new Rect(694f, 558f, 28f, 24f), "right"); GUI.enabled = true; GUI.Label(new Rect(774f, 104f, 286f, 30f), "SELECTED SIGN", val2); if (selected != "" && previewId != selected) { ReleasePreview(); preview = plugin.Full.Get(selected, pin: true); if (Object.op_Implicit((Object)(object)preview)) { previewId = selected; } } art.PreviewFrame(new Rect(768f, 134f, 298f, 176f)); if (Object.op_Implicit((Object)(object)preview)) { GUI.DrawTexture(new Rect(774f, 140f, 286f, 164f), (Texture)(object)preview, (ScaleMode)2); } GUI.Label(new Rect(774f, 324f, 286f, 78f), (selected != "") ? plugin.Catalog.Entries[selected].Title : "Select a label to preview", new GUIStyle(val) { fontSize = 22, wordWrap = true }); GUI.Label(new Rect(774f, 410f, 286f, 150f), "Apply changes the artwork only.\n\nRestore vanilla reveals your original sign text.\n\nEscape or Cancel discards this selection.", val2); GUI.Label(new Rect(28f, 596f, 1044f, 36f), status, val2); GUI.enabled = !pending; if (art.Button(new Rect(36f, 628f, 190f, 38f), "Restore vanilla")) { Submit(""); return; } GUI.enabled = true; if (art.Button(new Rect(774f, 628f, 140f, 38f), "Cancel")) { Close(); return; } GUI.enabled = !pending && selected != "" && Object.op_Implicit((Object)(object)preview); if (art.Button(new Rect(924f, 628f, 140f, 38f), "Apply", chosen: true)) { Submit(selected); } } finally { GUI.enabled = enabled; GUI.backgroundColor = backgroundColor; GUI.color = color; GUI.matrix = matrix; } } } [HarmonyPatch(typeof(Menu), "Update")] internal static class MenuPatch { private static bool Prefix() { Plugin instance = Plugin.Instance; if (instance == null || instance.Picker?.Open != true) { return Time.frameCount > Picker.SuppressMenuThrough; } return false; } } internal sealed class PickerArt : IDisposable { private readonly Dictionary<string, Texture2D> textures = new Dictionary<string, Texture2D>(); private GUIStyle button; private GUIStyle disabled; private GUIStyle selected; private GUIStyle card; private GUIStyle selectedCard; private GUIStyle field; private GUIStyle frame; public PickerArt(string root) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown string[] array = new string[15] { "button-normal", "button-hover", "button-pressed", "button-disabled", "button-selected", "frame-normal", "frame-selected", "frame-preview", "frame-focus", "glyph-left", "glyph-right", "glyph-close", "glyph-search", "icon", "title" }; foreach (string text in array) { string path = Path.Combine(root, "ui", "controls", text + ".png"); if (File.Exists(path)) { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; if (ImageConversion.LoadImage(val, File.ReadAllBytes(path), true)) { textures[text] = val; } else { Object.Destroy((Object)(object)val); } } } } private Texture2D Get(string name) { if (!textures.TryGetValue(name, out var value)) { return null; } return value; } public void Ensure() { //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_0037: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: 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_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Expected O, but got Unknown //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Expected O, but got Unknown //IL_021e: Expected O, but got Unknown //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Expected O, but got Unknown //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: 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_02e1: Expected O, but got Unknown //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Expected O, but got Unknown //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Expected O, but got Unknown //IL_03b0: 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_03d1: Expected O, but got Unknown if (button == null) { Color textColor = default(Color); ((Color)(ref textColor))..ctor(0.96f, 0.93f, 0.84f); button = new GUIStyle(GUI.skin.button) { fontSize = 16, fontStyle = (FontStyle)1, border = new RectOffset(20, 20, 10, 10), padding = new RectOffset(14, 14, 5, 5), alignment = (TextAnchor)4 }; button.normal.background = Get("button-normal"); button.hover.background = Get("button-hover"); button.active.background = Get("button-pressed"); button.focused.background = Get("button-hover"); GUIStyleState[] array = (GUIStyleState[])(object)new GUIStyleState[4] { button.normal, button.hover, button.active, button.focused }; for (int i = 0; i < array.Length; i++) { array[i].textColor = textColor; } selected = new GUIStyle(button); selected.normal.background = Get("button-selected"); selected.focused.background = Get("button-selected"); selected.normal.textColor = new Color(0.72f, 1f, 0.95f); disabled = new GUIStyle(button); disabled.normal.background = Get("button-disabled"); disabled.normal.textColor = new Color(0.68f, 0.68f, 0.65f); card = new GUIStyle(button) { border = new RectOffset(12, 12, 12, 12), padding = new RectOffset(5, 5, 5, 5) }; card.normal.background = Get("frame-normal"); card.hover.background = Get("frame-focus"); card.active.background = Get("frame-selected"); card.focused.background = Get("frame-focus"); selectedCard = new GUIStyle(card); selectedCard.normal.background = Get("frame-selected"); field = new GUIStyle(GUI.skin.textField) { fontSize = 16, border = new RectOffset(12, 12, 12, 12), padding = new RectOffset(34, 12, 5, 5), alignment = (TextAnchor)3 }; field.normal.background = Get("frame-normal"); field.focused.background = Get("frame-focus"); field.hover.background = Get("frame-focus"); field.active.background = Get("frame-focus"); array = (GUIStyleState[])(object)new GUIStyleState[4] { field.normal, field.focused, field.hover, field.active }; for (int i = 0; i < array.Length; i++) { array[i].textColor = textColor; } frame = new GUIStyle(card); frame.normal.background = Get("frame-preview"); } } public bool Button(Rect rect, string text, bool chosen = false, string tooltip = "") { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown Ensure(); return GUI.Button(rect, new GUIContent(text, tooltip), (!GUI.enabled) ? disabled : (chosen ? selected : button)); } public bool Card(Rect rect, bool chosen) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Ensure(); return GUI.Button(rect, GUIContent.none, chosen ? selectedCard : card); } public string Search(Rect rect, string text) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Ensure(); return GUI.TextField(rect, text, 80, field); } public void PreviewFrame(Rect rect) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Ensure(); GUI.Box(rect, GUIContent.none, frame); } public void Glyph(Rect rect, string name) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) Texture2D val = Get((name == "icon" || name == "title") ? name : ("glyph-" + name)); if (Object.op_Implicit((Object)(object)val)) { GUI.DrawTexture(rect, (Texture)(object)val, (ScaleMode)2); } } public void Dispose() { foreach (Texture2D value in textures.Values) { if (Object.op_Implicit((Object)(object)value)) { Object.Destroy((Object)(object)value); } } textures.Clear(); } } [BepInPlugin("local.runestonesigns", "Runestone Signs", "0.1.5")] public sealed class Plugin : BaseUnityPlugin { public static Plugin Instance; public Catalog Catalog; public TextureCache Full; public TextureCache Thumbs; public Picker Picker; public ConfigEntry<KeyboardShortcut> Hotkey; private Harmony harmony; private void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown Instance = this; Hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "Open picker", new KeyboardShortcut((KeyCode)107, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), "Target a vanilla sign, then press this shortcut. Change if another mod uses it."); Catalog = new Catalog(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "assets")); Full = new TextureCache(Catalog, 48, thumbs: false); Thumbs = new TextureCache(Catalog, 24, thumbs: true); Picker = new Picker(this); harmony = new Harmony("local.runestonesigns"); harmony.PatchAll(typeof(Plugin).Assembly); Sign[] array = Object.FindObjectsByType<Sign>((FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { Attach(array[i]); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Runestone Signs private candidate: " + Catalog.Entries.Count + " catalog entries")); } private void Update() { //IL_0020: 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_0043: 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) if (Picker == null) { return; } Picker.Tick(); Player localPlayer = Player.m_localPlayer; KeyboardShortcut value = Hotkey.Value; if (!Picker.Open && Object.op_Implicit((Object)(object)localPlayer) && (int)((KeyboardShortcut)(ref value)).MainKey != 0 && ZInput.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey, true) && ((KeyboardShortcut)(ref value)).Modifiers.All((KeyCode k) => ZInput.GetKey(k, true)) && CanInput(localPlayer)) { GameObject hoverObject = ((Humanoid)localPlayer).GetHoverObject(); Sign val = (Object.op_Implicit((Object)(object)hoverObject) ? hoverObject.GetComponentInParent<Sign>() : null); if (Object.op_Implicit((Object)(object)val) && Eligible(val) && SignSkin.CanEdit(val, localPlayer)) { Attach(val); Picker.Show(val); } } } internal static bool CanInput(Player p) { return (bool)AccessTools.Method(typeof(Player), "TakeInput", (Type[])null, (Type[])null).Invoke(p, null); } private void OnGUI() { //IL_0017: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 //IL_0060: 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) Event e = Event.current; KeyboardShortcut value = Hotkey.Value; Player localPlayer = Player.m_localPlayer; if (Picker != null && !Picker.Open && Object.op_Implicit((Object)(object)localPlayer) && (int)e.type == 4 && e.keyCode == ((KeyboardShortcut)(ref value)).MainKey && ((KeyboardShortcut)(ref value)).Modifiers.All((KeyCode k) => ModifierHeld(k, e)) && CanInput(localPlayer)) { GameObject hoverObject = ((Humanoid)localPlayer).GetHoverObject(); Sign val = (Object.op_Implicit((Object)(object)hoverObject) ? hoverObject.GetComponentInParent<Sign>() : null); if (Object.op_Implicit((Object)(object)val) && Eligible(val) && SignSkin.CanEdit(val, localPlayer)) { Attach(val); Picker.Show(val); e.Use(); } } Picker?.Draw(); } private static bool ModifierHeld(KeyCode key, Event e) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 //IL_0045: Unknown result type (might be due to invalid IL or missing references) if ((int)key == 306 || (int)key == 305) { return e.control; } if ((int)key == 308 || (int)key == 307) { return e.alt; } if ((int)key == 304 || (int)key == 303) { return e.shift; } return ZInput.GetKey(key, true); } internal static bool Eligible(Sign sign) { if (Object.op_Implicit((Object)(object)sign) && Object.op_Implicit((Object)(object)((Component)sign).GetComponent<Piece>()) && Utils.GetPrefabName(((Component)sign).gameObject) == "sign") { ZNetView component = ((Component)sign).GetComponent<ZNetView>(); if (component == null) { return false; } return component.IsValid(); } return false; } internal static void Attach(Sign sign) { if (Object.op_Implicit((Object)(object)Instance) && Eligible(sign) && !Object.op_Implicit((Object)(object)((Component)sign).GetComponent<SignSkin>())) { ((Component)sign).gameObject.AddComponent<SignSkin>(); } } private void OnDestroy() { Picker?.Dispose(); SignSkin[] array = Object.FindObjectsByType<SignSkin>((FindObjectsSortMode)0); foreach (SignSkin obj in array) { obj.Cleanup(); Object.Destroy((Object)(object)obj); } Harmony obj2 = harmony; if (obj2 != null) { obj2.UnpatchSelf(); } Full?.Dispose(); Thumbs?.Dispose(); Instance = null; } } [HarmonyPatch(typeof(Sign), "Awake")] internal static class AttachPatch { private static void Postfix(Sign __instance) { Plugin.Attach(__instance); } } [HarmonyPatch(typeof(Player), "TakeInput")] internal static class InputPatch { private static void Postfix(ref bool __result) { Plugin instance = Plugin.Instance; if (instance != null && instance.Picker?.Open == true) { __result = false; } } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] internal static class ControllerInputPatch { private static void Postfix(ref bool __result) { Plugin instance = Plugin.Instance; if ((instance != null && instance.Picker?.Open == true) || Time.frameCount <= Picker.SuppressMenuThrough) { __result = false; } } } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] internal static class CursorPatch { private static bool Prefix() { Plugin instance = Plugin.Instance; if (instance == null || instance.Picker?.Open != true) { return true; } ZCursor.LockState = (CursorLockMode)0; ZCursor.Show(); return false; } } [HarmonyPatch(typeof(Sign), "GetHoverText")] internal static class HoverPatch { private static void Postfix(Sign __instance, ref string __result) { //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 (Object.op_Implicit((Object)(object)Plugin.Instance) && Plugin.Eligible(__instance) && SignSkin.CanEdit(__instance, Player.m_localPlayer)) { __result = __result + "\n[" + ((object)Plugin.Instance.Hotkey.Value/*cast due to .constrained prefix*/).ToString() + "] Sign style"; } } } public sealed class SignSkin : MonoBehaviour { public const string Key = "runestonesigns.skin.v1"; private const string Request = "RunestoneSigns.Apply.v1"; private const string Reply = "RunestoneSigns.Reply.v1"; private Sign sign; private ZNetView view; private RawImage image; private string rendered; private bool changedText; private bool priorTextEnabled; private bool registered; private float nextRefresh; private float nextRequest; public string Current { get { if (!Object.op_Implicit((Object)(object)view) || !view.IsValid()) { return ""; } return view.GetZDO().GetString("runestonesigns.skin.v1", ""); } } public static bool SignLinkOwns(Sign s) { object obj; if (!Object.op_Implicit((Object)(object)s)) { obj = null; } else { ZNetView component = ((Component)s).GetComponent<ZNetView>(); obj = ((component != null) ? component.GetZDO() : null); } ZDO val = (ZDO)obj; if (val != null) { if (val.GetLong(StringExtensionMethods.GetStableHashCode("signlink_made"), 0L) == 0L && val.GetInt(StringExtensionMethods.GetStableHashCode("signlink_copy"), 0) == 0) { return !string.IsNullOrEmpty(val.GetString(StringExtensionMethods.GetStableHashCode("signlink_src"), "")); } return true; } return false; } public static bool CanEdit(Sign s, Player p) { //IL_0029: 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_004c: Unknown result type (might be due to invalid IL or missing references) if (Plugin.Eligible(s) && Object.op_Implicit((Object)(object)p) && !((Character)p).IsDead() && !((Character)p).IsTeleporting() && !((Character)p).InCutscene() && Vector3.Distance(((Character)p).GetEyePoint(), ((Component)s).transform.position) <= p.m_maxInteractDistance && PrivateArea.CheckAccess(((Component)s).transform.position, 0f, false, false)) { return !SignLinkOwns(s); } return false; } private void Awake() { sign = ((Component)this).GetComponent<Sign>(); view = ((Component)this).GetComponent<ZNetView>(); view.Register<string, string, int>("RunestoneSigns.Apply.v1", (Action<long, string, string, int>)Receive); view.Register<int, string>("RunestoneSigns.Reply.v1", (Action<long, int, string>)Acknowledge); registered = true; } public bool Apply(string id, string expected, int token) { if (!CanEdit(sign, Player.m_localPlayer) || (!(id == "") && !Plugin.Instance.Catalog.Valid(id))) { return false; } view.InvokeRPC("RunestoneSigns.Apply.v1", new object[3] { id, expected, token }); return true; } private void Acknowledge(long sender, int token, string status) { if (Object.op_Implicit((Object)(object)view) && view.IsValid() && sender == view.GetZDO().GetOwner()) { Plugin.Instance?.Picker?.Acknowledge(this, token, status); } } private void Receive(long sender, string id, string expected, int token) { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) if (!view.IsValid() || !view.IsOwner()) { return; } string text = "Access denied or sign unavailable"; Player val = ((IEnumerable<Player>)Player.GetAllPlayers()).FirstOrDefault((Func<Player, bool>)delegate(Player p) { if (Object.op_Implicit((Object)(object)p)) { ZNetView component = ((Component)p).GetComponent<ZNetView>(); if (component == null) { return false; } ZDO zDO = component.GetZDO(); return ((zDO != null) ? new long?(zDO.GetOwner()) : ((long?)null)) == sender; } return false; }); if (Time.unscaledTime < nextRequest) { text = "Please wait, then try again"; } else if (id == null || id.Length > 120 || expected == null || expected.Length > 120 || (!(id == "") && !Plugin.Instance.Catalog.Valid(id))) { text = "Unknown sign design"; } else if (Current != expected) { text = "Sign changed; close and reopen the picker"; } else if (Object.op_Implicit((Object)(object)val) && !((Character)val).IsDead() && !((Character)val).IsTeleporting() && !((Character)val).InCutscene() && Vector3.Distance(((Character)val).GetEyePoint(), ((Component)this).transform.position) <= Math.Min(val.m_maxInteractDistance, 5f) && WardAccess(val.GetPlayerID()) && !SignLinkOwns(sign)) { nextRequest = Time.unscaledTime + 0.25f; view.GetZDO().Set("runestonesigns.skin.v1", id); text = "Applied"; nextRefresh = 0f; } view.InvokeRPC(sender, "RunestoneSigns.Reply.v1", new object[2] { token, text }); } private bool WardAccess(long playerId) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) List<PrivateArea> obj = (List<PrivateArea>)AccessTools.Field(typeof(PrivateArea), "m_allAreas").GetValue(null); bool flag = false; bool flag2 = false; foreach (PrivateArea item in obj) { if (Object.op_Implicit((Object)(object)item) && (bool)AccessTools.Method(typeof(PrivateArea), "IsEnabled", (Type[])null, (Type[])null).Invoke(item, null) && (bool)AccessTools.Method(typeof(PrivateArea), "IsInside", (Type[])null, (Type[])null).Invoke(item, new object[2] { ((Component)this).transform.position, 0f })) { bool flag3 = ((Component)item).GetComponent<Piece>().GetCreator() == playerId || (bool)AccessTools.Method(typeof(PrivateArea), "IsPermitted", (Type[])null, (Type[])null).Invoke(item, new object[1] { playerId }); flag2 = flag2 || flag3; flag = flag || !flag3; } } if (!flag2) { return !flag; } return true; } private void Update() { if (!(Time.unscaledTime < nextRefresh)) { nextRefresh = Time.unscaledTime + 0.25f; Refresh(); } } public void Refresh() { //IL_008f: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_0185: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: 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_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) Plugin instance = Plugin.Instance; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)view) || !view.IsValid() || !Object.op_Implicit((Object)(object)sign) || !Object.op_Implicit((Object)(object)sign.m_textWidget)) { ClearVisual(); return; } string current = Current; bool num = (bool)AccessTools.Field(typeof(Sign), "m_isViewable").GetValue(sign); Player localPlayer = Player.m_localPlayer; if (!num || !Object.op_Implicit((Object)(object)localPlayer) || Vector3.Distance(((Component)localPlayer).transform.position, ((Component)this).transform.position) > 64f || !instance.Catalog.Valid(current) || SignLinkOwns(sign)) { ClearVisual(); } else if (!(current == rendered) || !Object.op_Implicit((Object)(object)image)) { ClearVisual(); Texture2D val = instance.Full.Get(current, pin: true); if (Object.op_Implicit((Object)(object)val)) { rendered = current; GameObject val2 = new GameObject("RunestoneSigns artwork", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(RawImage) }); image = val2.GetComponent<RawImage>(); RectTransform rectTransform = ((TMP_Text)sign.m_textWidget).rectTransform; RectTransform rectTransform2 = ((Graphic)image).rectTransform; ((Transform)rectTransform2).SetParent(((Transform)rectTransform).parent, false); ((Transform)rectTransform2).localPosition = ((Transform)rectTransform).localPosition; ((Transform)rectTransform2).localRotation = ((Transform)rectTransform).localRotation; ((Transform)rectTransform2).localScale = ((Transform)rectTransform).localScale; rectTransform2.anchorMin = rectTransform.anchorMin; rectTransform2.anchorMax = rectTransform.anchorMax; rectTransform2.pivot = rectTransform.pivot; rectTransform2.sizeDelta = rectTransform.sizeDelta; rectTransform2.anchoredPosition3D = rectTransform.anchoredPosition3D; Rect rect = rectTransform.rect; Vector2 size = ((Rect)(ref rect)).size; float num2 = Mathf.Min(size.x, size.y * 512f / 282f); rectTransform2.SetSizeWithCurrentAnchors((Axis)0, num2); rectTransform2.SetSizeWithCurrentAnchors((Axis)1, num2 * 282f / 512f); FitBoard(rectTransform2, rectTransform); image.texture = (Texture)(object)val; ((Graphic)image).raycastTarget = false; ((Transform)rectTransform2).SetAsLastSibling(); priorTextEnabled = ((Behaviour)sign.m_textWidget).enabled; ((Behaviour)sign.m_textWidget).enabled = false; changedText = true; } } } private void FitBoard(RectTransform rect, RectTransform original) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00e8: 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) Transform obj = ((Component)sign).transform.Find("New/wood_pole (1)"); MeshFilter val = ((obj != null) ? ((Component)obj).GetComponent<MeshFilter>() : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.sharedMesh) && Object.op_Implicit((Object)(object)((Transform)original).parent)) { Bounds bounds = val.sharedMesh.bounds; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(float.PositiveInfinity, float.PositiveInfinity, 0f); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(float.NegativeInfinity, float.NegativeInfinity, 0f); for (int i = 0; i < 8; i++) { Vector3 val4 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((i & 1) != 0) ? 1 : (-1)), (float)(((i & 2) != 0) ? 1 : (-1)), (float)(((i & 4) != 0) ? 1 : (-1)))); Vector3 val5 = ((Transform)original).parent.InverseTransformPoint(((Component)val).transform.TransformPoint(val4)); val2 = Vector3.Min(val2, val5); val3 = Vector3.Max(val3, val5); } Vector3 val6 = val3 - val2; if (!(val6.x <= 0f) && !(val6.y <= 0f)) { Vector2 val7 = default(Vector2); ((Vector2)(ref val7))..ctor(0.5f, 0.5f); rect.pivot = val7; Vector2 anchorMin = (rect.anchorMax = val7); rect.anchorMin = anchorMin; ((Transform)rect).localScale = Vector3.one; ((Transform)rect).localRotation = Quaternion.identity; ((Transform)rect).localPosition = new Vector3((val2.x + val3.x) * 0.5f, (val2.y + val3.y) * 0.5f, ((Transform)original).localPosition.z); rect.SetSizeWithCurrentAnchors((Axis)0, val6.x); rect.SetSizeWithCurrentAnchors((Axis)1, val6.y); } } } private void ClearVisual() { if (Object.op_Implicit((Object)(object)image)) { Object.Destroy((Object)(object)((Component)image).gameObject); image = null; } if (rendered != null) { Plugin.Instance?.Full?.Release(rendered); } rendered = null; if (changedText && Object.op_Implicit((Object)(object)sign) && Object.op_Implicit((Object)(object)sign.m_textWidget)) { ((Behaviour)sign.m_textWidget).enabled = priorTextEnabled; } changedText = false; } public void Cleanup() { ClearVisual(); if (registered && Object.op_Implicit((Object)(object)view)) { view.Unregister("RunestoneSigns.Apply.v1"); view.Unregister("RunestoneSigns.Reply.v1"); } registered = false; } private void OnDestroy() { Cleanup(); } } }