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 Compass v1.0.5
Compass.dll
Decompiled 4 days 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.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using Splatform; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Compass")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Compass")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("873ca971-9465-4427-a377-7523973b9138")] [assembly: AssemblyFileVersion("1.0.5")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.5.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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; } } } public class WildcardPattern { private readonly string _expression; private readonly Regex _regex; public WildcardPattern(string pattern) { if (string.IsNullOrEmpty(pattern)) { throw new ArgumentNullException("pattern"); } _expression = "^" + Regex.Escape(pattern).Replace("\\\\\\?", "??").Replace("\\?", ".") .Replace("??", "\\?") .Replace("\\\\\\*", "**") .Replace("\\*", ".*") .Replace("**", "\\*") + "$"; _regex = new Regex(_expression, RegexOptions.Compiled); } public bool IsMatch(string value) { return _regex.IsMatch(value); } } namespace Compass { [BepInPlugin("shudnal.Compass", "Compass", "1.0.5")] public class Compass : BaseUnityPlugin { public enum OrientationType { Camera, Player } [Flags] public enum CompassPinType { None = 0, Icon0 = 1, Icon1 = 2, Icon2 = 4, Icon3 = 8, Icon4 = 0x10, Death = 0x20, Bed = 0x40, Shout = 0x80, Boss = 0x100, Player = 0x200, RandomEvent = 0x400, Ping = 0x800, EventArea = 0x1000, HildirQuest = 0x2000, Static = 0x4000, Custom = 0x8000, All = 0xFFFF } public const string pluginID = "shudnal.Compass"; public const string pluginName = "Compass"; public const string pluginVersion = "1.0.5"; private readonly Harmony harmony = new Harmony("shudnal.Compass"); internal static Compass instance; public static ConfigEntry<bool> modEnabled; public static ConfigEntry<bool> loggingEnabled; public static ConfigEntry<OrientationType> orientation; public static ConfigEntry<float> scale; public static ConfigEntry<Vector2> offset; public static ConfigEntry<bool> showCenter; public static ConfigEntry<CompassPinType> showPins; public static ConfigEntry<string> pinNamesToIgnore; public static ConfigEntry<bool> showOnlyLastDeath; public static ConfigEntry<bool> hideChecked; public static ConfigEntry<bool> hideShared; public static ConfigEntry<bool> alwaysShowPinText; public static ConfigEntry<KeyboardShortcut> holdToAlwaysShowPings; public static ConfigEntry<KeyboardShortcut> holdToAlwaysShowShouts; public static ConfigEntry<KeyboardShortcut> holdToAlwaysShowPlayerPin; public static ConfigEntry<KeyboardShortcut> holdToShowText; public static ConfigEntry<Vector2> pinsAlpha; public static ConfigEntry<Vector2> pinsScale; public static ConfigEntry<Vector4> pinsStyleConditions; public static ConfigEntry<Color> compassColor; public static ConfigEntry<Color> centerColor; public static ConfigEntry<Color> pinsColor; public static ConfigEntry<float> pinTextSize; public static ConfigEntry<Color> pinTextColor; public static ConfigEntry<FontStyles> pinTextFormat; public static readonly string configDirectory = Path.Combine(Paths.ConfigPath, "shudnal.Compass"); private void Awake() { harmony.PatchAll(); instance = this; ConfigInit(); Game.isModded = true; CompassHUD.CheckImageFiles(); SetupFileWatcher(); } private void ConfigInit() { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Expected O, but got Unknown //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable the mod."); loggingEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Logging enabled", false, "Enable logging."); modEnabled.SettingChanged += delegate { CompassHUD.UpdateParentObject(); }; orientation = ((BaseUnityPlugin)this).Config.Bind<OrientationType>("Compass", "Orientation based on", OrientationType.Camera, "Orientation type. Camera direction or player eyes direction could be used as a center of a compass."); scale = ((BaseUnityPlugin)this).Config.Bind<float>("Compass", "Scale", 1f, "Scale of whole compass component"); offset = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Compass", "Position offset", Vector2.zero, "Offset from initial position in the middle top of the screen"); showCenter = ((BaseUnityPlugin)this).Config.Bind<bool>("Compass", "Show center", true, "Show center marker"); scale.SettingChanged += delegate { CompassHUD.UpdateParentObject(); }; offset.SettingChanged += delegate { CompassHUD.UpdateParentObject(); }; showCenter.SettingChanged += delegate { CompassHUD.UpdateCenterObject(); }; showPins = ((BaseUnityPlugin)this).Config.Bind<CompassPinType>("Pins", "Show pins", CompassPinType.All, "Pin types to show on the compass. Use Configuration Manager for more convenient editing.\nStatic - fixed locations like Haldor, Hildir, Bog Witch, Sacrificial Stones\nCustom - Any custom pin type added by other mods\nEventArea - red circle around an event\nRandomEvent - red exclamation mark of an event"); pinNamesToIgnore = ((BaseUnityPlugin)this).Config.Bind<string>("Pins", "Ignore pin names", "Silver&&Obsidian&&Copper&&Tin", new ConfigDescription("&& separated pin names to ignore. Wildcards * and ? supported. Use Configuration Manager for more convenient editing.", (AcceptableValueBase)null, new object[1] { new CustomConfigs.ConfigurationManagerAttributes { CustomDrawer = CustomConfigs.DrawSeparatedStrings("&&") } })); showOnlyLastDeath = ((BaseUnityPlugin)this).Config.Bind<bool>("Pins", "Show only last death", true, "Death pins except the last one will be hidden."); hideChecked = ((BaseUnityPlugin)this).Config.Bind<bool>("Pins", "Hide checked pins", false, "Hide pins checked by red cross."); hideShared = ((BaseUnityPlugin)this).Config.Bind<bool>("Pins", "Hide shared pins", false, "Hide pins shared via Cartography Table."); holdToAlwaysShowShouts = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Pins", "Hold to show shouts at any distance", new KeyboardShortcut((KeyCode)308, Array.Empty<KeyCode>()), "Hold to show player shouts without distance filter."); holdToAlwaysShowPlayerPin = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Pins", "Hold to show players at any distance", new KeyboardShortcut((KeyCode)308, Array.Empty<KeyCode>()), "Hold to show players with public positions without distance filter."); holdToAlwaysShowPings = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Pins", "Hold to show pings at any distance", new KeyboardShortcut((KeyCode)308, Array.Empty<KeyCode>()), "Hold to show player pings without distance filter."); holdToShowText = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Pins", "Hold to show pin text", new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Hold to show pin text if it is set."); alwaysShowPinText = ((BaseUnityPlugin)this).Config.Bind<bool>("Pins", "Always show pin text", false, "Always show pin text if it is set."); showPins.SettingChanged += delegate { CompassHUD.UpdatePinsObject(); }; pinNamesToIgnore.SettingChanged += delegate { UpdatePinFilterNames(); }; compassColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Style", "Compass color", Color.white - new Color(0f, 0f, 0f, 0.5f), "Compass color"); centerColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Style", "Center color", Color.yellow - new Color(0f, 0f, 0f, 0.5f), "Center marker color"); compassColor.SettingChanged += delegate { CompassHUD.UpdateCompassObject(); }; centerColor.SettingChanged += delegate { CompassHUD.UpdateCenterObject(); }; pinsColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Pin style", "Color", Color.clear, "Pins color. If not set - default is white"); pinsAlpha = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Pin style", "Alpha", new Vector2(1f, 0.33f), "Pins alpha. X for max alpha, Y for min alpha"); pinsScale = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Pin style", "Scale", new Vector2(1f, 0.33f), "Pins scale. X for max scale, Y for min scale"); pinsStyleConditions = ((BaseUnityPlugin)this).Config.Bind<Vector4>("Pin style", "Style conditions", new Vector4(1f, 20f, 250f, 550f), "Conditions for alpha and scale application\nX - Minimum distance to show pins\nY - Distance where pins will start to become smaller. Size is at maximum. Alpha is at maximum.\nZ - Distance where pins will start to become more transparent. Size is at minimum. Alpha is at maximum.\nW - Maximum distance to show pins. Size is at minimum. Alpha is at minimum."); pinsStyleConditions.SettingChanged += delegate { UpdatePinsStyleConditions(); }; pinTextSize = ((BaseUnityPlugin)this).Config.Bind<float>("Pin text style", "Size", 18f, "Pin text size"); pinTextColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Pin text style", "Color", Color.white, "Pin text color"); pinTextFormat = ((BaseUnityPlugin)this).Config.Bind<FontStyles>("Pin text style", "Format", (FontStyles)1, "Pin text format"); pinTextSize.SettingChanged += delegate { CompassHUD.UpdatePinTextStyle(); }; pinTextColor.SettingChanged += delegate { CompassHUD.UpdatePinTextStyle(); }; pinTextFormat.SettingChanged += delegate { CompassHUD.UpdatePinTextStyle(); }; } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); instance = null; Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } public static void LogInfo(object data) { if (loggingEnabled.Value) { ((BaseUnityPlugin)instance).Logger.LogInfo(data); } } public static void LogWarning(object data) { ((BaseUnityPlugin)instance).Logger.LogWarning(data); } private static void UpdatePinFilterNames() { CompassHUD.filteredWildcards.Clear(); CompassHUD.filteredNames = new HashSet<string>(from p in pinNamesToIgnore.Value.Split(new string[1] { "&&" }, StringSplitOptions.RemoveEmptyEntries) select p.Trim().ToLower() into p where !string.IsNullOrWhiteSpace(p) select p); CollectionExtensions.DoIf<string>((IEnumerable<string>)CompassHUD.filteredNames, (Func<string, bool>)((string str) => str.IndexOf('*') != -1 || str.IndexOf('?') != -1), (Action<string>)delegate(string str) { CompassHUD.filteredWildcards.Add(str); }); CompassHUD.filteredNames.RemoveWhere((string str) => CompassHUD.filteredWildcards.Contains(str)); } private static void UpdatePinsStyleConditions() { //IL_000b: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) pinsStyleConditions.Value = new Vector4((float)Mathf.FloorToInt(pinsStyleConditions.Value.x), (float)Mathf.FloorToInt(pinsStyleConditions.Value.y), (float)Mathf.FloorToInt(pinsStyleConditions.Value.z), (float)Mathf.FloorToInt(pinsStyleConditions.Value.w)); } public static void SetupFileWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(configDirectory, ImageFileInfo.filter); fileSystemWatcher.Changed += OnTextureFileChange; fileSystemWatcher.Created += OnTextureFileChange; fileSystemWatcher.Renamed += OnTextureFileChange; fileSystemWatcher.Deleted += OnTextureFileChange; fileSystemWatcher.IncludeSubdirectories = false; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private static void OnTextureFileChange(object sender, FileSystemEventArgs eargs) { ImageFileInfo.TryLoadFile(eargs.Name); if (eargs is RenamedEventArgs) { ImageFileInfo.TryClearFile((eargs as RenamedEventArgs).OldName); } } internal static bool LoadTextureFromConfigDirectory(string filename, ref Texture2D tex) { string path = Path.Combine(configDirectory, filename); if (!File.Exists(path)) { return false; } LogInfo("Loaded image from config folder: " + filename); return ImageConversion.LoadImage(tex, File.ReadAllBytes(path)); } internal static byte[] GetEmbeddedFileData(string filename) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename)); Stream manifestResourceStream = executingAssembly.GetManifestResourceStream(name); byte[] array = new byte[manifestResourceStream.Length]; manifestResourceStream.Read(array, 0, array.Length); return array; } } internal class CustomConfigs { internal class ConfigurationManagerAttributes { [UsedImplicitly] public Action<ConfigEntryBase>? CustomDrawer; } internal static object? configManager; internal static Type? configManagerStyles; internal static GUIStyle GetStyle(GUIStyle other) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if (configManagerStyles == null) { return other; } FieldInfo fieldInfo = AccessTools.Field(configManagerStyles, "fontSize"); if (fieldInfo == null) { return other; } return new GUIStyle(other) { fontSize = (int)fieldInfo.GetValue(configManagerStyles) }; } internal static void Awake() { Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "ConfigurationManager"); Type type = assembly?.GetType("ConfigurationManager.ConfigurationManager"); configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type)); configManagerStyles = assembly?.GetType("ConfigurationManager.ConfigurationManagerStyles"); } internal static Action<ConfigEntryBase> DrawSeparatedStrings(string splitString) { string splitString2 = splitString; return delegate(ConfigEntryBase cfg) { //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown bool valueOrDefault = cfg.Description.Tags.Select((object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault(); bool flag = false; GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); List<string> list = new List<string>(); List<string> list2 = ((string)cfg.BoxedValue).Split(new string[1] { splitString2 }, StringSplitOptions.None).ToList(); for (int i = 0; i < list2.Count; i++) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); string text = list2[i]; string text2 = GUILayout.TextField(text, GetStyle(GUI.skin.textArea), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (text2 != text && !valueOrDefault) { flag = true; } if (GUILayout.Button("x", new GUIStyle(GetStyle(GUI.skin.button)) { fixedWidth = 21f }, Array.Empty<GUILayoutOption>()) && !valueOrDefault) { flag = true; } else { list.Add(text2); } if (GUILayout.Button("+", new GUIStyle(GetStyle(GUI.skin.button)) { fixedWidth = 21f }, Array.Empty<GUILayoutOption>()) && !valueOrDefault) { flag = true; list.Add(""); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (flag) { cfg.BoxedValue = string.Join(splitString2, list); } }; } } internal static class CompassHUD { public class PinElement { public string name; public RectTransform rect; public Image image; public GameObject checkedIcon; public TMP_Text text; public PinElement() { rect = Object.Instantiate<RectTransform>(pinElement, (Transform)(object)pinsRootObject); ((Component)rect).gameObject.SetActive(true); image = ((Component)rect).GetComponent<Image>(); Transform obj = ((Transform)rect).Find("Checked"); checkedIcon = ((obj != null) ? ((Component)obj).gameObject : null); Transform obj2 = ((Transform)rect).Find("Name"); text = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null); pinsList.Add(this); } public void Destroy() { RectTransform obj = rect; Object.Destroy((Object)(object)((obj != null) ? ((Component)obj).gameObject : null)); } } [HarmonyPatch(typeof(Hud), "Awake")] private static class Hud_Awake_Initialize { private static void Postfix() { InitializeCompass(); } } [HarmonyPatch(typeof(Hud), "Update")] public static class Hud_Update_Compass { public static void Postfix() { UpdateCompass(); } } [HarmonyPatch(typeof(Hud), "OnDestroy")] public static class Hud_OnDestroy_Compass { public static void Postfix() { DestroyCompass(); } } [HarmonyPatch(typeof(Player), "SetCrouch")] public static class Player_SetCrouch_PreventCrouchingOnControlPress { private static bool IsCtrlDown(KeyboardShortcut shortcut) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return (ZInput.GetButton("Crouch") || ZInput.GetButton("JoyCrouch")) && IsShortcutDown(shortcut); } [HarmonyPriority(800)] public static bool Prefix() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) return !IsCtrlDown(Compass.holdToAlwaysShowPings.Value) && !IsCtrlDown(Compass.holdToAlwaysShowPlayerPin.Value) && !IsCtrlDown(Compass.holdToAlwaysShowShouts.Value) && !IsCtrlDown(Compass.holdToShowText.Value); } } public const string fileNameCompass = "compass"; public const string fileNameCenter = "center"; public const string fileNameMask = "mask"; public const string fileNameOverlay = "overlay"; public const string fileNameUnderlay = "underlay"; private const string objectRootName = "Compass_Parent"; private const string objectOverlayName = "Overlay"; private const string objectUnderlayName = "Underlay"; private const string objectGlobalMaskName = "GlobalMask"; private const string objectMaskName = "Mask"; private const string objectCompassName = "Compass"; private const string objectCenterName = "Center"; private const string objectPinsRootName = "Pins"; private const string objectPinElementName = "PinElement"; private const string objectPinElementCheckedName = "Checked"; private const string objectPinElementNameName = "Name"; private static readonly int layerUI = LayerMask.NameToLayer("UI"); public static GameObject parentObject; public static GameObject compassObject; public static GameObject centerObject; public static RectTransform pinsRootObject; public static RectTransform pinElement; public static RectTransform compassTransform; public static Mask maskComponent; public static Image maskImage; public static float compassWidth; public static readonly List<PinData> tempPins = new List<PinData>(); public static readonly List<PinElement> pinsList = new List<PinElement>(); public static HashSet<string> filteredNames = new HashSet<string>(); public static HashSet<string> filteredWildcards = new HashSet<string>(); private static Transform AnchorTransform { get { object result; if (Compass.orientation.Value != 0) { Player localPlayer = Player.m_localPlayer; result = ((localPlayer != null) ? ((Component)localPlayer).transform : null); } else { GameCamera instance = GameCamera.instance; result = ((instance != null) ? ((Component)instance).transform : null); } return (Transform)result; } } public static void CheckImageFiles() { Directory.CreateDirectory(Compass.configDirectory); CheckFile("compass"); CheckFile("center"); CheckFile("mask"); static void CheckFile(string id) { ImageFileInfo imageInfo = ImageFileInfo.GetImageInfo(id); if (!imageInfo.initialized) { File.WriteAllBytes(imageInfo.filePath, Compass.GetEmbeddedFileData(imageInfo.fileName)); imageInfo.Load(); } } } public static void UpdateParentObject() { //IL_0038: 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_005d: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)parentObject)) { parentObject.SetActive(Compass.modEnabled.Value); RectTransform component = parentObject.GetComponent<RectTransform>(); ((Transform)component).localScale = Vector3.one * Compass.scale.Value; component.anchorMin = new Vector2(0.5f, 1f); component.anchorMax = new Vector2(0.5f, 1f); Texture2D texture = ImageFileInfo.GetImageInfo("compass").texture; if (Object.op_Implicit((Object)(object)texture)) { component.anchoredPosition = new Vector2(0f, (float)(-((Texture)texture).height / 2)) - Compass.offset.Value; } } } public static void UpdateCenterObject() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)centerObject)) { ((Graphic)centerObject.GetComponent<Image>()).color = Compass.centerColor.Value; centerObject.SetActive(Compass.showCenter.Value); } } public static void UpdateMaskObject() { Texture2D texture = ImageFileInfo.GetImageInfo("compass").texture; if (Object.op_Implicit((Object)(object)texture)) { ImageFileInfo.GetImageInfo("mask").SetSpriteWidth(((Texture)texture).width / 2).UpdateGameObject(); } } public static void UpdateCompassObject() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)compassObject)) { Image component = compassObject.GetComponent<Image>(); ((Graphic)component).color = Compass.compassColor.Value; Rect rect = component.sprite.rect; compassWidth = ((Rect)(ref rect)).width; } } public static void UpdatePinsObject() { //IL_0064: 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_00a1: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)pinsRootObject)) { ((Component)pinsRootObject).gameObject.SetActive(Compass.showPins.Value != Compass.CompassPinType.None); Texture2D texture = ImageFileInfo.GetImageInfo("compass").texture; if ((Object)(object)texture != (Object)null) { pinsRootObject.sizeDelta = new Vector2((float)(((Texture)texture).width / 2), (float)((Texture)texture).height); } RectTransform obj = pinElement; if (obj != null) { obj.SetSizeWithCurrentAnchors((Axis)0, pinsRootObject.sizeDelta.y); } RectTransform obj2 = pinElement; if (obj2 != null) { obj2.SetSizeWithCurrentAnchors((Axis)1, pinsRootObject.sizeDelta.y); } } } public static void InitializeCompass() { //IL_00e0: 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_00f6: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown //IL_01d4: 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: Expected O, but got Unknown //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Expected O, but got Unknown //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Expected O, but got Unknown //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Expected O, but got Unknown //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: 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) pinsList.Clear(); tempPins.Clear(); ImageFileInfo imageInfo = ImageFileInfo.GetImageInfo("compass"); if (!imageInfo.initialized) { Compass.LogWarning("Mandatory file " + imageInfo.fileName + " is not found"); return; } ImageFileInfo imageInfo2 = ImageFileInfo.GetImageInfo("center"); if (!imageInfo2.initialized) { Compass.LogWarning("Mandatory file " + imageInfo2.fileName + " is not found"); return; } ImageFileInfo imageInfo3 = ImageFileInfo.GetImageInfo("mask"); if (!imageInfo3.initialized) { Compass.LogWarning("Mandatory file " + imageInfo3.fileName + " is not found"); return; } parentObject = new GameObject("Compass_Parent", new Type[1] { typeof(RectTransform) }) { layer = layerUI }; parentObject.transform.SetParent(Hud.instance.m_rootObject.transform); GameObject val = new GameObject("Overlay", new Type[1] { typeof(RectTransform) }) { layer = layerUI }; val.transform.SetParent(parentObject.transform, false); ImageFileInfo.SetGameObject("overlay", val).UpdateGameObject(); GameObject val2 = new GameObject("Underlay", new Type[1] { typeof(RectTransform) }) { layer = layerUI }; val2.transform.SetParent(parentObject.transform, false); ImageFileInfo.SetGameObject("underlay", val2).UpdateGameObject(); GameObject val3 = new GameObject("GlobalMask", new Type[1] { typeof(RectTransform) }) { layer = layerUI }; val3.transform.SetParent(parentObject.transform, false); val3.AddComponent<RectMask2D>(); val3.GetComponent<RectTransform>().sizeDelta = new Vector2(1600f, 100f); GameObject val4 = new GameObject("Mask", new Type[1] { typeof(RectTransform) }) { layer = layerUI }; val4.transform.SetParent(val3.transform, false); imageInfo3.SetGameObject(val4); UpdateMaskObject(); maskComponent = val4.AddComponent<Mask>(); maskComponent.showMaskGraphic = false; maskImage = val4.GetComponent<Image>(); compassObject = new GameObject("Compass", new Type[1] { typeof(RectTransform) }) { layer = layerUI }; compassObject.transform.SetParent(val4.transform, false); imageInfo.SetGameObject(compassObject).UpdateGameObject(); imageInfo.textureChanged = (Action)Delegate.Combine(new Action(UpdateParentObject), new Action(UpdateCompassObject), new Action(UpdateMaskObject)); centerObject = new GameObject("Center", new Type[1] { typeof(RectTransform) }) { layer = layerUI }; centerObject.transform.SetParent(val4.transform, false); imageInfo2.SetGameObject(centerObject).UpdateGameObject(); pinsRootObject = new GameObject("Pins", new Type[1] { typeof(RectTransform) }) { layer = layerUI }.GetComponent<RectTransform>(); ((Transform)pinsRootObject).SetParent(val4.transform, false); pinElement = new GameObject("PinElement", new Type[1] { typeof(RectTransform) }) { layer = layerUI }.GetComponent<RectTransform>(); ((Transform)pinElement).SetParent(parentObject.transform, false); ((Component)pinElement).gameObject.AddComponent<Image>(); ((Component)pinElement).gameObject.SetActive(false); GameObject val5 = Object.Instantiate<GameObject>(((Component)Minimap.instance.m_pinPrefab.transform.Find("Checked")).gameObject, (Transform)(object)pinElement); ((Object)val5).name = "Checked"; val5.SetActive(false); GameObject val6 = Object.Instantiate<GameObject>(((Component)Minimap.instance.m_pinNamePrefab.transform.Find("Name")).gameObject, (Transform)(object)pinElement); ((Object)val6).name = "Name"; val6.GetComponent<TMP_Text>().fontSizeMax = 24f; val6.SetActive(false); UpdateParentObject(); UpdateCenterObject(); UpdateCompassObject(); UpdatePinsObject(); } public static void UpdateCompass() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00b8: Unknown result type (might be due to invalid IL or missing references) if (Compass.modEnabled.Value && Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)compassObject)) { float num = AnchorTransform.eulerAngles.y; if (num > 180f) { num -= 360f; } num *= -(float)Math.PI / 180f; if (compassTransform == null) { compassTransform = compassObject.GetComponent<RectTransform>(); } ((Transform)compassTransform).localPosition = Vector3.right * (compassWidth / 2f) * num / ((float)Math.PI * 2f) - new Vector3(compassWidth * 0.125f, 0f, 0f); UpdatePins(); } } public static void UpdatePinTextStyle() { CollectionExtensions.Do<PinElement>((IEnumerable<PinElement>)pinsList, (Action<PinElement>)delegate(PinElement pin) { //IL_0041: 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) if (!((Object)(object)pin.text == (Object)null)) { pin.text.enableAutoSizing = false; pin.text.fontSize = Compass.pinTextSize.Value; ((Graphic)pin.text).color = Compass.pinTextColor.Value; pin.text.fontStyle = Compass.pinTextFormat.Value; } }); } public static void DestroyCompass() { parentObject = null; compassObject = null; centerObject = null; pinsRootObject = null; pinElement = null; compassTransform = null; maskComponent = null; maskImage = null; CollectionExtensions.Do<PinElement>((IEnumerable<PinElement>)pinsList, (Action<PinElement>)delegate(PinElement pin) { pin.Destroy(); }); pinsList.Clear(); tempPins.Clear(); } private static void UpdatePinList() { tempPins.Clear(); AddPinRange(Minimap.instance.m_pins); if (ShowAllPingPins()) { AddPinRange(Minimap.instance.m_pingPins); } if (ShowAllShoutPins()) { AddPinRange(Minimap.instance.m_shoutPins); } if (ShowAllPlayerPins()) { AddPinRange(Minimap.instance.m_playerPins); } tempPins.Sort((PinData x, PinData y) => ComparePins(x, y)); static int ComparePins(PinData x, PinData y) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (y.m_pos == x.m_pos) { if ((int)x.m_type == 13) { return -1; } if ((int)y.m_type == 13) { return 1; } return ((Enum)(PinType)(ref y.m_type)).CompareTo((object?)x.m_type); } return Utils.DistanceXZ(AnchorTransform.position, y.m_pos).CompareTo(Utils.DistanceXZ(AnchorTransform.position, x.m_pos)); } } public static bool IsShortcutDown(KeyboardShortcut shortcut) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) return (int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && ZInput.GetKey(((KeyboardShortcut)(ref shortcut)).MainKey, true) && ((KeyboardShortcut)(ref shortcut)).Modifiers.All((KeyCode key) => ZInput.GetKey(key, true)); } private static bool ShowAllPlayerPins() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) return Compass.alwaysShowPinText.Value || IsShortcutDown(Compass.holdToAlwaysShowPlayerPin.Value); } private static bool ShowAllShoutPins() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) return Compass.alwaysShowPinText.Value || IsShortcutDown(Compass.holdToAlwaysShowShouts.Value); } private static bool ShowAllPingPins() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) return Compass.alwaysShowPinText.Value || IsShortcutDown(Compass.holdToAlwaysShowPings.Value); } private static bool ShowPinText() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) return Compass.alwaysShowPinText.Value || IsShortcutDown(Compass.holdToShowText.Value); } private static void AddPinRange(List<PinData> pinList) { CollectionExtensions.Do<PinData>((IEnumerable<PinData>)pinList, (Action<PinData>)AddPin); } private static void AddPin(PinData pin) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) if (pin == null || (Compass.hideChecked.Value && pin.m_checked) || (Compass.hideShared.Value && pin.m_ownerID != 0)) { return; } Compass.CompassPinType pinType = GetPinType(pin.m_type); if (!Compass.showPins.Value.HasFlag(pinType) || (Compass.showOnlyLastDeath.Value && pinType == Compass.CompassPinType.Death && pin.m_pos != Game.instance.GetPlayerProfile().GetDeathPoint())) { return; } if (!IsDynamicPinToShow(pinType)) { float num = Utils.DistanceXZ(AnchorTransform.position, pin.m_pos); if (num < Compass.pinsStyleConditions.Value.x || num > Compass.pinsStyleConditions.Value.w || filteredNames.Contains(pin.m_name) || filteredWildcards.Any((string wildcard) => new WildcardPattern(wildcard).IsMatch(pin.m_name))) { return; } } if (!tempPins.Contains(pin)) { tempPins.Add(pin); } } private static Compass.CompassPinType GetPinType(PinType pinType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected I4, but got Unknown if (1 == 0) { } Compass.CompassPinType result = (int)pinType switch { 0 => Compass.CompassPinType.Icon0, 1 => Compass.CompassPinType.Icon1, 2 => Compass.CompassPinType.Icon2, 3 => Compass.CompassPinType.Icon3, 6 => Compass.CompassPinType.Icon4, 4 => Compass.CompassPinType.Death, 5 => Compass.CompassPinType.Bed, 7 => Compass.CompassPinType.Shout, 9 => Compass.CompassPinType.Boss, 10 => Compass.CompassPinType.Player, 11 => Compass.CompassPinType.RandomEvent, 12 => Compass.CompassPinType.Ping, 13 => Compass.CompassPinType.EventArea, 14 => Compass.CompassPinType.HildirQuest, 15 => Compass.CompassPinType.HildirQuest, 16 => Compass.CompassPinType.HildirQuest, 8 => Compass.CompassPinType.Static, _ => Compass.CompassPinType.Custom, }; if (1 == 0) { } return result; } public static void UpdatePins() { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: 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_01da: 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_0201: 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_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_047a: 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_03de: 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_03fc: 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) if (!Object.op_Implicit((Object)(object)pinsRootObject) || !((Component)pinsRootObject).gameObject.activeInHierarchy || (Object)(object)AnchorTransform == (Object)null) { return; } UpdatePinList(); if (pinsList.Count != tempPins.Count) { CollectionExtensions.Do<PinElement>((IEnumerable<PinElement>)pinsList, (Action<PinElement>)delegate(PinElement pin) { pin.Destroy(); }); pinsList.Clear(); for (int i = 0; i < tempPins.Count; i++) { new PinElement(); } } Rect rect = ImageFileInfo.GetImageInfo("compass").sprite.rect; bool flag = false; for (int j = 0; j < tempPins.Count; j++) { PinElement pinElement = pinsList[j]; PinData val = tempPins[j]; pinElement.name = val.m_name; pinElement.image.sprite = val.m_icon; if (Compass.pinsColor.Value != Color.clear) { ((Graphic)pinElement.image).color = Compass.pinsColor.Value; } bool flag2 = IsDynamicPinToShow(val.m_type); float num = Utils.DistanceXZ(AnchorTransform.position, val.m_pos); if (num > Compass.pinsStyleConditions.Value.y && flag2) { num = Compass.pinsStyleConditions.Value.y; } float num2 = Mathf.Lerp(Compass.pinsScale.Value.x, Compass.pinsScale.Value.y, (num - Compass.pinsStyleConditions.Value.y) / (Compass.pinsStyleConditions.Value.z - Compass.pinsStyleConditions.Value.y)); float num3 = Mathf.Lerp(Compass.pinsAlpha.Value.x, Compass.pinsAlpha.Value.y, (num - Compass.pinsStyleConditions.Value.z) / (Compass.pinsStyleConditions.Value.w - Compass.pinsStyleConditions.Value.z)); ((Transform)pinElement.rect).localScale = Vector3.one * num2; ((Transform)pinElement.rect).localPosition = Vector3.right * (((Rect)(ref rect)).width / 2f) * GetAngle(val.m_pos) / ((float)Math.PI * 2f); ((Graphic)pinElement.image).color = new Color(((Graphic)pinElement.image).color.r, ((Graphic)pinElement.image).color.g, ((Graphic)pinElement.image).color.b, val.m_animate ? Compass.pinsAlpha.Value.x : num3); ((Transform)pinElement.rect).SetSiblingIndex(j); GameObject checkedIcon = pinElement.checkedIcon; if (checkedIcon != null) { checkedIcon.SetActive(val.m_checked); } if ((Object)(object)pinElement.text != (Object)null) { ((Component)pinElement.text).gameObject.SetActive(!string.IsNullOrWhiteSpace(val.m_name) && (flag2 || ShowPinText())); if (((Behaviour)pinElement.text).isActiveAndEnabled) { pinElement.text.SetText(GetPinText(val)); pinElement.text.enableAutoSizing = false; pinElement.text.fontSize = Compass.pinTextSize.Value; ((Graphic)pinElement.text).color = Compass.pinTextColor.Value; pinElement.text.fontStyle = Compass.pinTextFormat.Value; pinElement.text.transform.localScale = Vector3.one / num2; pinElement.text.transform.localPosition = new Vector3(0f, (0f - ((Rect)(ref rect)).height) / 2f, 0f); flag = true; } } if (val.m_animate && !flag2) { RectTransform rect2 = pinElement.rect; ((Transform)rect2).localScale = ((Transform)rect2).localScale * (0.9f + Mathf.Sin(Time.time * 5f) * 0.2f); } } ((Behaviour)maskComponent).enabled = !flag; ((Behaviour)maskImage).enabled = !flag; } public static bool IsDynamicPinToShow(Compass.CompassPinType pinType) { return (pinType == Compass.CompassPinType.Shout && ShowAllShoutPins()) || (pinType == Compass.CompassPinType.Player && ShowAllPlayerPins()) || (pinType == Compass.CompassPinType.Ping && ShowAllPingPins()); } public static bool IsDynamicPinToShow(PinType pinType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return IsDynamicPinToShow(GetPinType(pinType)); } public static float GetAngle(Vector3 position) { //IL_0005: 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_001a: 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_0025: Unknown result type (might be due to invalid IL or missing references) return GetAtan2(AnchorTransform.InverseTransformPoint(new Vector3(position.x, AnchorTransform.position.y, position.z))); } public static float GetAtan2(Vector3 vector) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return Mathf.Atan2(vector.x, vector.z); } public static string GetPinText(PinData pin) { //IL_0014: 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_0041: Unknown result type (might be due to invalid IL or missing references) return (string.IsNullOrEmpty(pin.m_author.m_userID) || pin.m_author == ((IUser)PlatformManager.DistributionPlatform.LocalUser).PlatformUserID) ? Localization.instance.Localize(pin.m_name) : CensorShittyWords.FilterUGC(Localization.instance.Localize(pin.m_name), (UGCType)4, pin.m_author, 0L); } } public class ImageFileInfo { public static readonly Dictionary<string, ImageFileInfo> images = new Dictionary<string, ImageFileInfo>(); public const string ext = "png"; public static string filter = GetFilename("*"); public string fileID; public string fileName; public string filePath; public Texture2D texture; public bool initialized = false; public GameObject gameObject; public Sprite sprite; public int spriteWidthOverride; public Action textureChanged; public ImageFileInfo(string id) { fileID = id; fileName = GetFilename(id); filePath = Path.Combine(Compass.configDirectory, fileName); Load(); images[fileID] = this; } public void Load() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown Clear(); texture = new Texture2D(2, 2, (TextureFormat)4, true, true); initialized = Compass.LoadTextureFromConfigDirectory(fileName, ref texture); ((Texture)texture).wrapMode = (TextureWrapMode)1; InitSprite(); UpdateGameObject(); Update(); textureChanged?.Invoke(); } public void Clear() { if ((Object)(object)texture != (Object)null) { Object.Destroy((Object)(object)texture); texture = null; } if ((Object)(object)sprite != (Object)null) { Object.Destroy((Object)(object)sprite); sprite = null; } initialized = false; Update(); } public void Update() { GameObject obj = gameObject; if (obj != null) { obj.SetActive(initialized); } } public ImageFileInfo SetSpriteWidth(int width) { spriteWidthOverride = width; InitSprite(); return this; } public ImageFileInfo SetGameObject(GameObject gameObject) { this.gameObject = gameObject; return this; } public void UpdateGameObject() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)gameObject) && initialized) { RectTransform component = gameObject.GetComponent<RectTransform>(); component.sizeDelta = new Vector2((float)((spriteWidthOverride == 0) ? ((Texture)texture).width : spriteWidthOverride), (float)((Texture)texture).height); Image val = gameObject.GetComponent<Image>() ?? gameObject.AddComponent<Image>(); val.sprite = sprite; val.preserveAspect = true; } } private void InitSprite() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)sprite != (Object)null) { Object.Destroy((Object)(object)sprite); } sprite = ((!initialized) ? null : Sprite.Create(texture, new Rect(0f, 0f, (float)((spriteWidthOverride == 0) ? ((Texture)texture).width : spriteWidthOverride), (float)((Texture)texture).height), Vector2.zero)); } private static string GetFilename(string filename) { return Path.ChangeExtension(filename, "png"); } public static ImageFileInfo SetGameObject(string id, GameObject gameObject) { return GetImageInfo(id).SetGameObject(gameObject); } public static ImageFileInfo GetImageInfo(string id) { ImageFileInfo value; return images.TryGetValue(id, out value) ? value : new ImageFileInfo(id); } public static void TryClearFile(string filename) { if (images.TryGetValue(Path.GetFileNameWithoutExtension(filename), out var value)) { value.Clear(); } } public static void TryLoadFile(string filename) { if (images.TryGetValue(Path.GetFileNameWithoutExtension(filename), out var value)) { value.Load(); } } } }