using 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 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.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.1")]
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.1";
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<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 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_02a1: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
//IL_0379: Unknown result type (might be due to invalid IL or missing references)
//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
//IL_040d: Unknown result type (might be due to invalid IL or missing references)
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, 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.");
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, 350f), "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();
};
}
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 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);
pinsList.Add(this);
}
public void Destroy()
{
RectTransform obj = rect;
Object.Destroy((Object)(object)((obj != null) ? ((Component)obj).gameObject : null));
}
}
[HarmonyPatch(typeof(GuiScaler), "UpdateScale")]
public static class GuiScaler_UpdateScale_GetCurrentScale
{
public static void Postfix(GuiScaler __instance)
{
if (((Object)__instance).name == "LoadingGUI" && scaleFactor != (scaleFactor = __instance.m_canvasScaler.scaleFactor))
{
UpdateParentObject();
}
}
}
[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();
}
}
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 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 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 float scaleFactor = 1f;
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>();
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_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
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 / scaleFactor;
Texture2D texture = ImageFileInfo.GetImageInfo("compass").texture;
if (Object.op_Implicit((Object)(object)texture))
{
component.anchoredPosition = new Vector2(0f, ((float)Screen.height / scaleFactor - (float)((Texture)texture).height * Compass.scale.Value / scaleFactor) / 2f) - 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_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Expected O, but got Unknown
//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
//IL_02e4: Expected O, but got Unknown
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_032a: Unknown result type (might be due to invalid IL or missing references)
//IL_0370: Unknown result type (might be due to invalid IL or missing references)
//IL_0375: 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("Mask", new Type[1] { typeof(RectTransform) })
{
layer = layerUI
};
val3.transform.SetParent(parentObject.transform, false);
imageInfo3.SetGameObject(val3);
UpdateMaskObject();
val3.AddComponent<Mask>().showMaskGraphic = false;
compassObject = new GameObject("Compass", new Type[1] { typeof(RectTransform) })
{
layer = layerUI
};
compassObject.transform.SetParent(val3.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(val3.transform, false);
imageInfo2.SetGameObject(centerObject).UpdateGameObject();
pinsRootObject = new GameObject("Pins", new Type[1] { typeof(RectTransform) })
{
layer = layerUI
}.GetComponent<RectTransform>();
((Component)pinsRootObject).transform.SetParent(val3.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 val4 = Object.Instantiate<GameObject>(((Component)Minimap.instance.m_pinPrefab.transform.Find("Checked")).gameObject, (Transform)(object)pinElement);
((Object)val4).name = "Checked";
val4.SetActive(false);
UpdateParentObject();
UpdateCenterObject();
UpdateCompassObject();
UpdatePinsObject();
}
public static void UpdateCompass()
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: 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 = ((Compass.orientation.Value == Compass.OrientationType.Camera) ? ((Component)GameCamera.instance).transform.eulerAngles.y : ((Component)Player.m_localPlayer).transform.eulerAngles.y);
if (num > 180f)
{
num -= 360f;
}
num *= -(float)Math.PI / 180f;
((Transform)compassObject.GetComponent<RectTransform>()).localPosition = Vector3.right * (compassWidth / 2f) * num / ((float)Math.PI * 2f) - new Vector3(compassWidth * 0.125f, 0f, 0f);
UpdatePins();
}
}
private static void UpdatePinList()
{
tempPins.Clear();
if (Compass.showOnlyLastDeath.Value)
{
AddPin(Minimap.instance.m_deathPin);
}
AddPinRange(Minimap.instance.m_pins);
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_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_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(((Component)Player.m_localPlayer).transform.position, y.m_pos).CompareTo(Utils.DistanceXZ(((Component)Player.m_localPlayer).transform.position, x.m_pos));
}
}
private static void AddPinRange(IEnumerable<PinData> pinList)
{
CollectionExtensions.Do<PinData>(pinList, (Action<PinData>)AddPin);
}
private static void AddPin(PinData pin)
{
//IL_0074: 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_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: 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))
{
float num = Utils.DistanceXZ(((Component)Player.m_localPlayer).transform.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)))
{
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_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: 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_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: 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_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_033f: Unknown result type (might be due to invalid IL or missing references)
//IL_0360: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)pinsRootObject) || !((Component)pinsRootObject).gameObject.activeInHierarchy)
{
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;
float width = ((Rect)(ref rect)).width;
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;
}
Vector3 val2 = ((Compass.orientation.Value == Compass.OrientationType.Camera) ? ((Component)GameCamera.instance).transform.InverseTransformPoint(val.m_pos) : ((Component)Player.m_localPlayer).transform.InverseTransformPoint(val.m_pos));
float num = Mathf.Atan2(val2.x, val2.z);
float num2 = Utils.DistanceXZ(((Component)Player.m_localPlayer).transform.position, val.m_pos);
float num3 = Mathf.Lerp(Compass.pinsScale.Value.x, Compass.pinsScale.Value.y, (num2 - Compass.pinsStyleConditions.Value.y) / (Compass.pinsStyleConditions.Value.z - Compass.pinsStyleConditions.Value.y));
float num4 = Mathf.Lerp(Compass.pinsAlpha.Value.x, Compass.pinsAlpha.Value.y, (num2 - Compass.pinsStyleConditions.Value.z) / (Compass.pinsStyleConditions.Value.w - Compass.pinsStyleConditions.Value.z));
((Transform)pinElement.rect).localScale = Vector3.one * num3;
((Transform)pinElement.rect).localPosition = Vector3.right * (width / 2f) * num / ((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 : num4);
((Transform)pinElement.rect).SetSiblingIndex(j);
GameObject checkedIcon = pinElement.checkedIcon;
if (checkedIcon != null)
{
checkedIcon.SetActive(val.m_checked);
}
if (val.m_animate)
{
RectTransform rect2 = pinElement.rect;
((Transform)rect2).localScale = ((Transform)rect2).localScale * (0.9f + Mathf.Sin(Time.time * 5f) * 0.2f);
}
}
}
}
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);
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();
}
}
}
}