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 QuickPing v1.0.6
plugins/QuickPing.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Managers; using Jotunn.Utils; using QuickPing.Patches; using QuickPing.Utilities; using Splatform; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; 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("QuickPing")] [assembly: AssemblyDescription("Ping what you see!")] [assembly: AssemblyCompany("Atopy")] [assembly: AssemblyProduct("QuickPing")] [assembly: ComVisible(false)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace QuickPing { internal enum HoverType { GameObject, Character, Hoverable, Piece, Location } internal sealed class HoverObject { public GameObject Hover; public IDestructible Destructible; public Vector3 pos; public Vector3 center; public HoverType type; public PinType ResolvedPinType = (PinType)8; public string Name { get; set; } } [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.atopy.plugins.quickping", "QuickPing", "1.0.6")] public sealed class QuickPingPlugin : BaseUnityPlugin { public static QuickPingPlugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Instance = this; Settings.Init(); Player_Patch.OnPlayerPing.AddListener((UnityAction<HoverObject>)Player_Patch.SendPing); Player_Patch.OnPlayerPing.AddListener((UnityAction<HoverObject>)Minimap_Patch.AddPin); Player_Patch.OnPlayerForcePing.AddListener((UnityAction<HoverObject>)Player_Patch.SendPing); Player_Patch.OnPlayerForcePing.AddListener((UnityAction<HoverObject>)Minimap_Patch.ForceAddPin); Player_Patch.OnPlayerRename.AddListener((UnityAction<HoverObject>)Player_Patch.SendRename); Player_Patch.OnPlayerRename.AddListener((UnityAction<HoverObject>)Minimap_Patch.RenamePin); SafePatch(typeof(Player_Patch)); SafePatch(typeof(Minimap_Patch)); SafePatch(typeof(MineRock5_Patch)); SafePatch(typeof(Destructible_Patch)); SafePatch(typeof(WearNTear_Patch)); SafePatch(typeof(Character_Patch)); SafePatch(typeof(Persistence_Patch)); SafePatch(typeof(ChatPing_Patch)); } private static void SafePatch(Type patchType) { try { Harmony.CreateAndPatchAll(patchType, "com.atopy.plugins.quickping"); } catch (Exception ex) { Log.LogError((object)("[QP] Failed to patch " + patchType.Name + ": " + ex.Message)); } } } internal static class Settings { public const string DefaultPingText = "PING !"; public static ConfigEntry<bool> PingWhereLooking { get; private set; } public static ConfigEntry<bool> AddPin { get; private set; } public static ConfigEntry<float> ClosestPinRange { get; private set; } public static ConfigEntry<float> PinExclusionRange { get; private set; } public static ConfigEntry<float> LocationProximityRange { get; private set; } public static ConfigEntry<PinType> DefaultPinType { get; internal set; } public static ConfigEntry<string> DefaultPinName { get; internal set; } public static ConfigEntry<float> BeamTextOffset { get; private set; } public static ConfigEntry<float> PingTextHeight { get; private set; } public static ConfigEntry<bool> ShowDistanceInText { get; private set; } public static ConfigEntry<bool> EnableBeam { get; private set; } public static ConfigEntry<bool> EnableWisp { get; private set; } public static ConfigEntry<bool> EnableWispSound { get; private set; } public static ConfigEntry<float> WispBrightness { get; private set; } public static ConfigEntry<bool> EnablePingSound { get; private set; } public static ConfigEntry<float> PingSoundVolume { get; private set; } public static ConfigEntry<float> PingSoundMinVolume { get; private set; } public static ConfigEntry<float> PingSoundMaxDistance { get; private set; } public static ConfigEntry<bool> ShowDebugLocationInfo { get; private set; } public static ConfigEntry<KeyCode> PingKey { get; private set; } public static ConfigEntry<KeyCode> PinEverythingKey { get; internal set; } public static ConfigEntry<KeyboardShortcut> RenameKey { get; internal set; } public static ButtonConfig PingBtn { get; private set; } public static ButtonConfig PingEverythingBtn { get; private set; } public static ButtonConfig RenameBtn { get; private set; } public static void Init() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Expected O, but got Unknown //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Expected O, but got Unknown //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Expected O, but got Unknown //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Expected O, but got Unknown //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Expected O, but got Unknown PingWhereLooking = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<bool>("General", "PingWhereLooking", true, "Show QuickPing world text, beam/wisp and whistle at the point you ping. This does not control whether a recognized target is added to the minimap."); AddPin = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<bool>("General", "AddPinOnMap", true, "Automatically add a minimap pin when the normal ping targets a recognized QuickPing resource, location, landmark or portal."); ClosestPinRange = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<float>("General", "ClosestPinRange", 2f, new ConfigDescription("Distance in meters used to find an existing pin at the target position for replacement/rename checks such as portals.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>())); PinExclusionRange = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<float>("General", "PinExclusionRange", 10f, new ConfigDescription("Suppress another automatic pin with the same resolved name when one already exists within this many meters. Portal replacement is handled separately.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); LocationProximityRange = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<float>("General", "LocationProximityRange", 10f, new ConfigDescription("Maximum distance in meters from the raycast hit point to a Valheim Location anchor when resolving loose scenery in camps, villages, ruins and similar locations.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); DefaultPinType = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<PinType>("General", "DefaultPinType", (PinType)11, "Fallback minimap icon used when force-pinning something that has no recognized QuickPing pin type."); DefaultPinName = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<string>("General", "DefaultPinName", "", "Fallback name used when force-pinning something with no natural/recognized name. The Pin Editor can set this with 'Use as default'."); BeamTextOffset = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<float>("Ping", "BeamTextOffset", 2f, new ConfigDescription("Horizontal offset in meters that pulls the complete ping text block toward the camera so it remains readable in front of the beam/wisp.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>())); PingTextHeight = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<float>("Ping", "PingTextHeight", 5f, new ConfigDescription("Vertical world-space offset in meters above the ping point for the complete text block (debug location, main label and distance).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>())); ShowDistanceInText = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<bool>("Ping", "ShowDistanceInText", false, "Show the player-to-ping distance in meters on a smaller line below the main ping text."); EnableBeam = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<bool>("Ping", "EnableBeam", true, "Draw the vertical QuickPing beam at the ping point. Beam and wisp may be enabled together."); EnableWisp = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<bool>("Ping", "EnableWisp", false, "Spawn a rising demister-ball wisp at the ping point. Beam and wisp may be enabled together."); EnableWispSound = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<bool>("Ping", "EnableWispSound", false, "Allow the cloned demister-ball wisp to keep its built-in Valheim AudioSource. False makes QuickPing wisps silent."); WispBrightness = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<float>("Ping", "WispBrightness", 2f, new ConfigDescription("Brightness multiplier for the cloned QuickPing wisp emission and light. 1.0 = vanilla brightness; 2.0 = approximately twice as bright.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); EnablePingSound = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<bool>("Ping", "EnablePingSound", true, "Play a random positional QuickPing whistle. WAV files are loaded from a 'sounds' folder next to QuickPing.dll."); PingSoundVolume = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<float>("Ping", "PingSoundVolume", 1f, new ConfigDescription("Normalized QuickPing whistle volume. 1.0 = 100% QuickPing volume (internally Unity volume 0.10); 0.5 = half of that; 0 = silent.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); PingSoundMinVolume = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<float>("Ping", "PingSoundMinVolume", 0.1f, new ConfigDescription("Fraction of PingSoundVolume used at and beyond PingSoundMaxDistance. 0.10 = 10% of the configured QuickPing volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); PingSoundMaxDistance = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<float>("Ping", "PingSoundMaxDistance", 500f, new ConfigDescription("Distance in meters where the whistle reaches PingSoundMinVolume. Beyond this distance it remains at that minimum percentage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1000f), Array.Empty<object>())); ShowDebugLocationInfo = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<bool>("Debug", "ShowDebugLocationInfo", false, "Show the raw internal Valheim Location prefab name as a small line above normal ping text, including nearby locations QuickPing does not yet recognize as pinable."); PingKey = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<KeyCode>("Bindings", "PingInputKey", (KeyCode)122, "Normal QuickPing key: ping where you are looking and automatically pin recognized targets."); PinEverythingKey = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<KeyCode>("Bindings", "PingEverythingInputKey", (KeyCode)121, "Force-pin the object or point you are looking at even when QuickPing does not normally consider it pinable."); RenameKey = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<KeyboardShortcut>("Bindings", "RenameInputKey", new KeyboardShortcut(PinEverythingKey.Value, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), new ConfigDescription("Open the QuickPing Pin Editor for the object or point you are looking at.", (AcceptableValueBase)null, Array.Empty<object>())); AddInputs(); } private static void AddInputs() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0030: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_005f: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown PingBtn = new ButtonConfig { Name = "Ping", Config = PingKey, Hint = "Ping where you are looking and pin recognized targets" }; PingEverythingBtn = new ButtonConfig { Name = "PinEverything", Config = PinEverythingKey, Hint = "Force-pin what you are looking at" }; RenameBtn = new ButtonConfig { Name = "Rename", ShortcutConfig = RenameKey }; InputManager.Instance.AddButton("com.atopy.plugins.quickping", RenameBtn); InputManager.Instance.AddButton("com.atopy.plugins.quickping", PingBtn); InputManager.Instance.AddButton("com.atopy.plugins.quickping", PingEverythingBtn); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.atopy.plugins.quickping"; public const string PLUGIN_NAME = "QuickPing"; public const string PLUGIN_VERSION = "1.0.6"; } } namespace QuickPing.Utilities { internal static class DataManager { public static readonly Dictionary<ZDOID, PinData> PinnedObjects = new Dictionary<ZDOID, PinData>(); public static readonly Dictionary<string, string> CustomNames = new Dictionary<string, string>(); public static bool Save(World world, PlayerProfile playerProfile) { bool flag = SavePinnedObjects(world, playerProfile); bool flag2 = SaveCustomNames(world, playerProfile); return flag && flag2; } public static void Load(World world, PlayerProfile playerProfile) { LoadPinnedObjects(world, playerProfile); LoadCustomNames(world, playerProfile); } private static string GetSafePath(World world, PlayerProfile playerProfile, string extension) { string text = Path.Combine(Paths.ConfigPath, "QuickPing"); Directory.CreateDirectory(text); return Path.Combine(text, world.m_name + "_" + playerProfile.m_playerName + "." + extension + ".dat"); } private static bool SavePinnedObjects(World world, PlayerProfile playerProfile) { try { File.WriteAllBytes(GetSafePath(world, playerProfile, "pinned"), PackPinnedObjects().GetArray()); return true; } catch (Exception ex) { QuickPingPlugin.Log.LogError((object)("[QP] Failed to save pinned objects: " + ex.Message)); return false; } } private static void LoadPinnedObjects(World world, PlayerProfile playerProfile) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown PinnedObjects.Clear(); string safePath = GetSafePath(world, playerProfile, "pinned"); if (!File.Exists(safePath)) { return; } try { UnpackPinnedObjects(new ZPackage(File.ReadAllBytes(safePath))); } catch (Exception ex) { QuickPingPlugin.Log.LogError((object)("[QP] Failed to load pinned objects: " + ex.Message)); } } private static bool SaveCustomNames(World world, PlayerProfile playerProfile) { try { File.WriteAllBytes(GetSafePath(world, playerProfile, "customNames"), PackCustomNames().GetArray()); return true; } catch (Exception ex) { QuickPingPlugin.Log.LogError((object)("[QP] Failed to save custom names: " + ex.Message)); return false; } } private static void LoadCustomNames(World world, PlayerProfile playerProfile) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown CustomNames.Clear(); string safePath = GetSafePath(world, playerProfile, "customNames"); if (!File.Exists(safePath)) { return; } try { UnpackCustomNames(new ZPackage(File.ReadAllBytes(safePath))); } catch (Exception ex) { QuickPingPlugin.Log.LogError((object)("[QP] Failed to load custom names: " + ex.Message)); } } private static ZPackage PackPinnedObjects() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) ZPackage val = new ZPackage(); foreach (KeyValuePair<ZDOID, PinData> pinnedObject in PinnedObjects) { val.Write(pinnedObject.Key); val.WritePinData(pinnedObject.Value); } return val; } private static ZPackage PackCustomNames() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ZPackage val = new ZPackage(); foreach (KeyValuePair<string, string> customName in CustomNames) { val.Write(customName.Key); val.Write(customName.Value); } return val; } private static void UnpackCustomNames(ZPackage package) { CustomNames.Clear(); while (package.GetPos() < package.Size()) { CustomNames[package.ReadString()] = package.ReadString(); } } private static void UnpackPinnedObjects(ZPackage package) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) PinnedObjects.Clear(); while (package.GetPos() < package.Size()) { PinnedObjects[package.ReadZDOID()] = package.ReadPinData(); } } private static void WritePinData(this ZPackage package, PinData pin) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) package.Write(pin.m_name); package.Write(((object)Unsafe.As<PinType, PinType>(ref pin.m_type)/*cast due to .constrained prefix*/).ToString()); package.Write(pin.m_pos); } private static PinData ReadPinData(this ZPackage package) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_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) PinData val = new PinData(); val.m_name = package.ReadString(); val.m_type = (PinType)Enum.Parse(typeof(PinType), package.ReadString()); val.m_pos = package.ReadVector3(); return val; } } internal static class GO_Ext { public static T GetRecursiveComponentInParents<T>(Transform root) { return ((Object)(object)root == (Object)null) ? default(T) : ((Component)root).GetComponentInParent<T>(); } public static GameObject GetRecursiveParentWithComponent<T>(Transform root) { Transform val = (((Object)(object)root != (Object)null) ? root.parent : null); T val2 = default(T); while ((Object)(object)val != (Object)null) { if (((Component)val).gameObject.TryGetComponent<T>(ref val2)) { return ((Component)val).gameObject; } val = val.parent; } return null; } } } namespace QuickPing.Patches { public class ChatPing_Patch { public class PingHost : MonoBehaviour { } private const float ScalePerMeter = 0.22f; private const float MinScale = 0.6f; private const float MaxScale = 120f; private const float Lifetime = 5f; private const float BeamLifetime = 2.5f; private const float BeamHeight = 150f; private const float BeamWidth = 0.3f; private const float WispRiseSpeed = 8f; private const float QuickPingUnityVolumeScale = 0.1f; private static MonoBehaviour _host; private static Vector3 _lastTextPos; private static string _lastText = ""; private static float _lastTextTime = -1f; internal static string RawLocationLabel; private const string RPC_NAME = "QuickPingNet"; private static ZRoutedRpc _registeredRpcInstance; private static Vector3 _lastLocalPinPos; private static float _lastLocalPinTime = -1f; private static TMP_FontAsset _cachedFont; private static List<AudioClip> _pingSounds; private static bool _soundsLoadAttempted; private static MonoBehaviour Host { get { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)_host == (Object)null) { GameObject val = new GameObject("QuickPingHost"); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); _host = (MonoBehaviour)(object)val.AddComponent<PingHost>(); } return _host; } } public static void ShowWorldText(Vector3 position, string text) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) string rawLocationLabel = RawLocationLabel; RawLocationLabel = null; if (!(Time.time - _lastTextTime < 0.3f) || !(_lastText == text) || !(Vector3.Distance(_lastTextPos, position) < 1f)) { _lastTextPos = position; _lastText = text; _lastTextTime = Time.time; string text2 = CleanDisplayName(text); if (Settings.ShowDebugLocationInfo != null && Settings.ShowDebugLocationInfo.Value && !string.IsNullOrEmpty(rawLocationLabel)) { text2 = "<size=60%><color=#A0A0A0>" + rawLocationLabel + "</color></size>\n" + text2; } if (Settings.ShowDistanceInText.Value && (Object)(object)Player.m_localPlayer != (Object)null) { float num = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, position); text2 = "<line-height=70%>" + text2 + "\n<size=60%>" + Mathf.RoundToInt(num) + "m</size>"; } Host.StartCoroutine(TextRoutine(position, text2)); if (Settings.EnableBeam.Value) { Host.StartCoroutine(BeamRoutine(position)); } PlayPingSound(position); if (Settings.EnableWisp.Value) { Host.StartCoroutine(WispRoutine(position)); } } } [HarmonyPatch(typeof(Minimap), "Awake")] [HarmonyPostfix] public static void MinimapAwakeRegisterRpc() { RegisterRpc(); } public static void RegisterRpc() { if (ZRoutedRpc.instance != null && _registeredRpcInstance != ZRoutedRpc.instance) { ZRoutedRpc.instance.Register<ZPackage>("QuickPingNet", (Action<long, ZPackage>)RpcReceived); _registeredRpcInstance = ZRoutedRpc.instance; } } public static void BroadcastPing(Vector3 textPos, Vector3 pinPos, string displayText, string pinId) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) RegisterRpc(); if (ZRoutedRpc.instance != null) { _lastLocalPinPos = pinPos; _lastLocalPinTime = Time.time; ZPackage val = new ZPackage(); val.Write(textPos); val.Write(pinPos); val.Write(displayText); val.Write(pinId); ZRoutedRpc.instance.InvokeRoutedRPC(0L, "QuickPingNet", new object[1] { val }); } } public static void RpcReceived(long sender, ZPackage pkg) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_002f: 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) //IL_0057: Unknown result type (might be due to invalid IL or missing references) Vector3 position = pkg.ReadVector3(); Vector3 val = pkg.ReadVector3(); string text = pkg.ReadString(); string strID = pkg.ReadString(); if (!(Time.time - _lastLocalPinTime < 0.5f) || !(Vector3.Distance(_lastLocalPinPos, val) < 1f)) { ShowWorldText(position, text); Minimap_Patch.AddPin(null, null, strID, val, force: false, rename: false, (PinType)8); } } private static string CleanDisplayName(string rawName) { if (string.IsNullOrEmpty(rawName)) { return rawName; } string text = rawName.Trim(); if (text.StartsWith("$")) { text = text.Substring(1); } text = text.Replace("(Clone)", ""); string[] array = new string[7] { "object_", "item_", "piece_", "Rock_", "Tree_", "Pickable_", "destructible_" }; string[] array2 = array; foreach (string text2 in array2) { if (text.StartsWith(text2, StringComparison.OrdinalIgnoreCase)) { text = text.Substring(text2.Length); break; } } text = text.Replace("_", " "); text = Regex.Replace(text, "([a-zA-Z])([0-9])", "$1 $2"); text = Regex.Replace(text, "[^a-zA-Z0-9\\s]", ""); text = Regex.Replace(text, "\\s+", " ").Trim(); if (text.Length > 0) { text = text.ToLower(); text = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(text); } if (string.IsNullOrEmpty(text)) { return rawName; } return text; } private static Camera GetCamera() { if ((Object)(object)GameCamera.instance != (Object)null) { return ((Component)GameCamera.instance).GetComponent<Camera>(); } return Camera.main; } private static TMP_FontAsset FindFontAsset() { if ((Object)(object)_cachedFont != (Object)null) { return _cachedFont; } try { if ((Object)(object)Chat.instance != (Object)null && (Object)(object)Chat.instance.m_worldTextBase != (Object)null) { TMP_Text componentInChildren = Chat.instance.m_worldTextBase.GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.font != (Object)null) { _cachedFont = componentInChildren.font; return _cachedFont; } } TMP_Text[] array = Resources.FindObjectsOfTypeAll<TMP_Text>(); foreach (TMP_Text val in array) { if ((Object)(object)val != (Object)null && (Object)(object)val.font != (Object)null) { _cachedFont = val.font; return _cachedFont; } } TMP_FontAsset[] array2 = Resources.FindObjectsOfTypeAll<TMP_FontAsset>(); if (array2 != null && array2.Length != 0) { _cachedFont = array2[0]; } } catch (Exception ex) { QuickPingPlugin.Log.LogDebug((object)("[QP] Font lookup deferred: " + ex.Message)); } return _cachedFont; } private static IEnumerator TextRoutine(Vector3 position, string text) { //IL_0007: 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) TMP_FontAsset font = FindFontAsset(); if ((Object)(object)font == (Object)null) { yield break; } GameObject go = new GameObject("QuickPingWorldText"); go.SetActive(false); Vector3 basePos = position + Vector3.up * Settings.PingTextHeight.Value; go.transform.position = basePos; Camera cam0 = GetCamera(); if ((Object)(object)cam0 != (Object)null && Settings.BeamTextOffset.Value > 0f) { Vector3 toPlayer = ((Component)cam0).transform.position - basePos; toPlayer.y = 0f; if (((Vector3)(ref toPlayer)).sqrMagnitude > 0.01f) { go.transform.position = basePos + ((Vector3)(ref toPlayer)).normalized * Settings.BeamTextOffset.Value; } } TextMeshPro tmp = go.AddComponent<TextMeshPro>(); Material textMaterial = null; ((TMP_Text)tmp).font = font; ((TMP_Text)tmp).text = text; ((TMP_Text)tmp).fontSize = 2f; ((TMP_Text)tmp).alignment = (TextAlignmentOptions)514; ((Graphic)tmp).color = new Color(1f, 0.9f, 0f, 1f); if ((Object)(object)((TMP_Text)tmp).fontSharedMaterial != (Object)null) { textMaterial = new Material(((TMP_Text)tmp).fontSharedMaterial); textMaterial.EnableKeyword("OUTLINE_ON"); textMaterial.SetColor(Shader.PropertyToID("_OutlineColor"), Color.black); textMaterial.SetFloat(Shader.PropertyToID("_OutlineWidth"), 0.05f); ((TMP_Text)tmp).fontSharedMaterial = textMaterial; } go.SetActive(true); float textLife = 5f; while (textLife > 0f && (Object)(object)go != (Object)null) { Camera cam1 = GetCamera(); if ((Object)(object)cam1 != (Object)null) { Vector3 camPos = ((Component)cam1).transform.position; go.transform.rotation = Quaternion.LookRotation(go.transform.position - camPos); float dist = Vector3.Distance(go.transform.position, camPos); float scale = Mathf.Clamp(dist * 0.22f, 0.6f, 120f); go.transform.localScale = Vector3.one * scale; } textLife -= Time.deltaTime; yield return null; } if ((Object)(object)go != (Object)null) { Object.Destroy((Object)(object)go); } if ((Object)(object)textMaterial != (Object)null) { Object.Destroy((Object)(object)textMaterial); } } private static IEnumerator BeamRoutine(Vector3 position) { //IL_0007: 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) Shader beamShader = Shader.Find("Sprites/Default"); if ((Object)(object)beamShader == (Object)null) { beamShader = Shader.Find("Unlit/Color"); } if ((Object)(object)beamShader == (Object)null) { beamShader = Shader.Find("UI/Default"); } if ((Object)(object)beamShader == (Object)null) { beamShader = Shader.Find("Particles/Standard Unlit"); } if ((Object)(object)beamShader == (Object)null) { yield break; } GameObject beamGo = new GameObject("QuickPingBeam"); beamGo.transform.position = position; LineRenderer lr = beamGo.AddComponent<LineRenderer>(); lr.useWorldSpace = true; lr.positionCount = 2; lr.SetPosition(0, position); lr.SetPosition(1, position + Vector3.up * 150f); lr.startWidth = 0.3f; lr.endWidth = 0.3f; Material beamMaterial = (((Renderer)lr).sharedMaterial = new Material(beamShader)); beamMaterial.color = new Color(1f, 1f, 1f, 1f); lr.startColor = new Color(1f, 1f, 1f, 0.9f); lr.endColor = new Color(1f, 1f, 1f, 0.1f); float beamLife = 2.5f; while (beamLife > 0f && (Object)(object)beamGo != (Object)null) { beamLife -= Time.deltaTime; float alpha = Mathf.Clamp01(beamLife / 2.5f); if ((Object)(object)lr != (Object)null && (Object)(object)beamMaterial != (Object)null) { beamMaterial.color = new Color(1f, 1f, 1f, alpha); } yield return null; } if ((Object)(object)beamGo != (Object)null) { Object.Destroy((Object)(object)beamGo); } if ((Object)(object)beamMaterial != (Object)null) { Object.Destroy((Object)(object)beamMaterial); } } private static void PlayPingSound(Vector3 position) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown if (!Settings.EnablePingSound.Value) { return; } EnsureSoundsLoaded(); if (_pingSounds != null && _pingSounds.Count != 0) { AudioClip val = _pingSounds[Random.Range(0, _pingSounds.Count)]; if (!((Object)(object)val == (Object)null)) { GameObject val2 = new GameObject("QuickPingPingSound"); val2.transform.position = position; AudioSource val3 = val2.AddComponent<AudioSource>(); val3.clip = val; val3.playOnAwake = false; val3.spatialBlend = 1f; val3.dopplerLevel = 0f; val3.volume = Mathf.Clamp01(Settings.PingSoundVolume.Value) * 0.1f; val3.rolloffMode = (AudioRolloffMode)2; val3.minDistance = 1f; val3.maxDistance = Mathf.Max(1f, Settings.PingSoundMaxDistance.Value); float num = Mathf.Clamp01(Settings.PingSoundMinVolume.Value); AnimationCurve val4 = new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 1f), new Keyframe(1f, num) }); val3.SetCustomCurve((AudioSourceCurveType)0, val4); val3.Play(); Object.Destroy((Object)(object)val2, val.length + 1f); } } } private static void EnsureSoundsLoaded() { if (_soundsLoadAttempted) { return; } _soundsLoadAttempted = true; _pingSounds = new List<AudioClip>(); try { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string text = Path.Combine(directoryName, "sounds"); if (!Directory.Exists(text)) { QuickPingPlugin.Log.LogInfo((object)("[QP] No ping sounds folder found at " + text)); return; } string[] files = Directory.GetFiles(text, "*.wav"); foreach (string path in files) { AudioClip val = LoadWavClip(path); if ((Object)(object)val != (Object)null) { _pingSounds.Add(val); } } QuickPingPlugin.Log.LogInfo((object)("[QP] Loaded " + _pingSounds.Count + " ping sound(s) from " + text)); } catch (Exception ex) { QuickPingPlugin.Log.LogWarning((object)("[QP] Sound load error: " + ex.Message)); } } private static AudioClip LoadWavClip(string path) { try { byte[] array = File.ReadAllBytes(path); if (array.Length < 44) { return null; } int num = array[22]; int num2 = BitConverter.ToInt32(array, 24); int num3 = array[34]; int i = 12; int num4 = 0; int num5; for (; i < array.Length - 8; i += 8 + num5) { string text = Encoding.ASCII.GetString(array, i, 4); num5 = BitConverter.ToInt32(array, i + 4); if (text == "data") { i += 8; num4 = num5; break; } } if (num4 == 0) { return null; } int num6 = num3 / 8; int num7 = num4 / num6; float[] array2 = new float[num7]; for (int j = 0; j < num7; j++) { int num8 = i + j * num6; switch (num3) { case 16: array2[j] = (float)BitConverter.ToInt16(array, num8) / 32768f; break; case 8: array2[j] = (float)(array[num8] - 128) / 128f; break; case 32: array2[j] = BitConverter.ToSingle(array, num8); break; } } AudioClip val = AudioClip.Create(Path.GetFileNameWithoutExtension(path), num7 / num, num, num2, false); MethodInfo method = typeof(AudioClip).GetMethod("SetData", new Type[2] { typeof(float[]), typeof(int) }); if (method != null) { method.Invoke(val, new object[2] { array2, 0 }); } return val; } catch (Exception ex) { QuickPingPlugin.Log.LogWarning((object)("[QP] WAV load error (" + path + "): " + ex.Message)); return null; } } private static GameObject TrySpawnWisp(Vector3 position) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)ZNetScene.instance == (Object)null) { return null; } GameObject prefab = ZNetScene.instance.GetPrefab("demister_ball"); if ((Object)(object)prefab == (Object)null) { QuickPingPlugin.Log.LogWarning((object)"[QP] Wisp: demister_ball prefab not found"); return null; } GameObject val = new GameObject("QP_WispTemp"); val.SetActive(false); GameObject val2 = Object.Instantiate<GameObject>(prefab, val.transform); ZNetView[] componentsInChildren = val2.GetComponentsInChildren<ZNetView>(true); foreach (ZNetView val3 in componentsInChildren) { Object.DestroyImmediate((Object)(object)val3); } ZSyncTransform[] componentsInChildren2 = val2.GetComponentsInChildren<ZSyncTransform>(true); foreach (ZSyncTransform val4 in componentsInChildren2) { Object.DestroyImmediate((Object)(object)val4); } if (Settings.EnableWispSound == null || !Settings.EnableWispSound.Value) { AudioSource[] componentsInChildren3 = val2.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val5 in componentsInChildren3) { Object.DestroyImmediate((Object)(object)val5); } } float num = ((Settings.WispBrightness != null) ? Mathf.Max(0f, Settings.WispBrightness.Value) : 2f); Renderer[] componentsInChildren4 = val2.GetComponentsInChildren<Renderer>(true); foreach (Renderer val6 in componentsInChildren4) { Material[] materials = val6.materials; Material[] array = materials; foreach (Material val7 in array) { if (!((Object)(object)val7 == (Object)null) && val7.HasProperty("_EmissionColor")) { val7.EnableKeyword("_EMISSION"); Color color = val7.GetColor("_EmissionColor"); val7.SetColor("_EmissionColor", color * num); } } val6.materials = materials; } Light[] componentsInChildren5 = val2.GetComponentsInChildren<Light>(true); foreach (Light val8 in componentsInChildren5) { if ((Object)(object)val8 != (Object)null) { val8.intensity *= num; } } val2.transform.SetParent((Transform)null); val2.transform.position = position + Vector3.up * 1f; val2.transform.rotation = Quaternion.identity; Object.Destroy((Object)(object)val); val2.SetActive(true); return val2; } catch (Exception ex) { QuickPingPlugin.Log.LogWarning((object)("[QP] Wisp spawn error: " + ex.Message)); return null; } } private static IEnumerator WispRoutine(Vector3 position) { //IL_0007: 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) GameObject wisp = TrySpawnWisp(position); if (!((Object)(object)wisp == (Object)null)) { float elapsed = 0f; Vector3 startPos = wisp.transform.position; float wispLifetime = 7.5f; while (elapsed < wispLifetime && (Object)(object)wisp != (Object)null) { float rise = elapsed * 8f; float waveX = Mathf.Sin(elapsed * 1.8f) * 0.6f; float waveZ = Mathf.Cos(elapsed * 1.3f) * 0.6f; wisp.transform.position = startPos + new Vector3(waveX, rise, waveZ); elapsed += Time.deltaTime; yield return null; } if ((Object)(object)wisp != (Object)null) { Object.Destroy((Object)(object)wisp); } } } } internal static class Localization_Patch { public static string Localize(Location location) { return ((Object)(object)location == (Object)null) ? string.Empty : LocalizeName(((Object)location).name); } public static string LocalizeName(string locationName) { if (string.IsNullOrEmpty(locationName)) { return locationName; } return FriendlyLocationName(locationName.Replace("(Clone)", "").Trim()); } private static string FriendlyLocationName(string name) { if (name.StartsWith("SunkenCrypt")) { return "Sunken Crypt"; } if (name.StartsWith("Crypt")) { return "Burial Chambers"; } if (name.StartsWith("TrollCave") || name.StartsWith("ForestCave")) { return "Troll Cave"; } if (name.StartsWith("MountainCave")) { return "Frost Cave"; } if (name.StartsWith("Mistlands_DvergrBossEntrance")) { return "Infested Mine"; } if (name.StartsWith("Mistlands_DvergrTownEntrance")) { return "Dvergr Town"; } if (name.StartsWith("MorkBorg") || name.StartsWith("Morkhalla")) { return "Morkhalla"; } if (name.StartsWith("MorgenHole")) { return "Putrid Hole"; } if (name.StartsWith("WindingTunnel")) { return "Winding Tunnels"; } if (name.StartsWith("Hildir_cave")) { return "Hildir's Cave"; } if (name.StartsWith("Hildir_crypt")) { return "Hildir's Crypt"; } if (name.StartsWith("Hildir_plainsfortress")) { return "Hildir's Fortress"; } if (name.StartsWith("Hildir_camp")) { return "Hildir's Camp"; } if (name.StartsWith("TarPit")) { return "Tar Pit"; } if (name.StartsWith("Eikthyrnir")) { return "Eikthyr's Den"; } if (name.StartsWith("Aspect_Elder")) { return "The Elder's Shrine"; } if (name.StartsWith("Bonemass")) { return "Bonemass Altar"; } if (name.StartsWith("Moder")) { return "Moder's Altar"; } if (name.StartsWith("Yagluth") || name.StartsWith("GoblinKing")) { return "Yagluth's Lair"; } if (name.StartsWith("Dragonqueen")) { return "The Queen's Lair"; } if (name.StartsWith("FaderLocation") || name.StartsWith("Ashlands_Altar")) { return "Fader's Coliseum"; } if (name.StartsWith("DN_Bossroom")) { return "Kall Fimbulbringer's Lair"; } if (name.StartsWith("CharredFortress") || name.StartsWith("AshlandRuins")) { return "Charred Fortress"; } if (name.StartsWith("BearCave")) { return "Bear Cave"; } if (name.StartsWith("Mistlands_GuardTower")) { return "Dvergr Guard Tower"; } if (name.StartsWith("Mistlands_Lighthouse")) { return "Dvergr Lighthouse"; } if (name.StartsWith("FulingTower")) { return "Fuling Tower"; } if (name.StartsWith("GoblinCamp") || name.StartsWith("FulingCamp")) { return "Fuling Camp"; } if (name.StartsWith("AbandonedHomestead")) { return "Abandoned Homestead"; } if (name.StartsWith("Grausten")) { return "Grausten Ruins"; } if (name.StartsWith("Dolmen")) { return "Stone Circle"; } if (name.StartsWith("StatueTower") || name.StartsWith("StoneTower")) { return "Stone Tower Ruins"; } if (name.StartsWith("Ruin")) { return "Ruins"; } if (name.StartsWith("WoodVillage")) { return "Abandoned Village"; } if (name.StartsWith("StoneHenge")) { return "Stone Henge"; } if (name.StartsWith("SwampHut")) { return "Swamp Hut"; } if (name.StartsWith("SwampWell")) { return "Swamp Well"; } if (name.StartsWith("ShipWreck")) { return "Shipwreck"; } if (name.StartsWith("Pickable_DvergrStein")) { return "Dvergr Component Crate"; } if (name.StartsWith("FlametalRockstand")) { return "Flametal Ore"; } if (name.StartsWith("InfestedTree")) { return "Guck Sac"; } if (name.StartsWith("AbandonedLogCabin")) { return "Abandoned Log Cabin"; } if (name.StartsWith("DrakeNest")) { return "Drake Nest"; } if (name.StartsWith("SealedTower") || name.StartsWith("Mistlands_SealedTower")) { return "Sealed Tower"; } if (name.StartsWith("FloatingIsland") || name.StartsWith("Mistlands_FloatingIsland") || name.StartsWith("SkyIsland")) { return "Floating Island"; } return name; } public static string GetBaseTranslation(string text) { if (string.IsNullOrEmpty(text)) { return "noStr"; } if (Localization.instance == null || Localization.instance.m_translations == null) { return "$"; } Dictionary<string, string> translations = Localization.instance.m_translations; string key = translations.FirstOrDefault((KeyValuePair<string, string> x) => x.Value == text).Key; return string.IsNullOrEmpty(key) ? "$" : ("$" + key); } } internal static class PinLifecycle { public static void RemoveTrackedPin(ZNetView netView) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)netView == (Object)null || (Object)(object)Minimap.instance == (Object)null) { return; } ZDO zDO = netView.GetZDO(); if (zDO != null) { ZDOID uid = zDO.m_uid; if (DataManager.PinnedObjects.TryGetValue(uid, out var value)) { Minimap.instance.RemovePin(value); DataManager.PinnedObjects.Remove(uid); } } } } [HarmonyPatch(typeof(MineRock5))] internal static class MineRock5_Patch { [HarmonyPatch(typeof(MineRock5), "AllDestroyed")] [HarmonyPostfix] private static void AllDestroyed(MineRock5 __instance, bool __result) { if (__result) { PinLifecycle.RemoveTrackedPin(__instance.m_nview); } } } [HarmonyPatch(typeof(WearNTear))] internal static class WearNTear_Patch { [HarmonyPatch(typeof(WearNTear), "Destroy")] [HarmonyPrefix] private static void Destroy(WearNTear __instance) { PinLifecycle.RemoveTrackedPin(__instance.m_nview); } } [HarmonyPatch(typeof(Destructible))] internal static class Destructible_Patch { [HarmonyPatch(typeof(Destructible), "Destroy")] [HarmonyPrefix] private static void DestroyPrefix(Destructible __instance) { PinLifecycle.RemoveTrackedPin(__instance.m_nview); } } [HarmonyPatch(typeof(Character))] internal static class Character_Patch { [HarmonyPatch(typeof(Character), "OnDeath")] [HarmonyPrefix] private static void OnDeath(Character __instance) { PinLifecycle.RemoveTrackedPin(__instance.m_nview); } } internal static class Minimap_Patch { private static FieldInfo _minimapPinsField; private static FieldInfo _minimapNamePinField; private static bool _minimapPinsErrorLogged; private static GameObject panel; private static GameObject nameInput; private static GameObject toggleDefault; private static string tempOriginalText; private static IDestructible tempDestructible; private static PinData tempPin; private static bool _releaseInputAfterEnter; private static bool _releaseInputCoroutineRunning; private static PinType selectedIcon = (PinType)3; private static FieldInfo _minimapIconsField; private static bool _iconsFieldSearched; private static readonly Dictionary<PinType, Outline> IconOutlines = new Dictionary<PinType, Outline>(); private static readonly Dictionary<string, PinType> PinableTypes = BuildPinableTypes(); private static readonly PinType[] EditorIcons; public static bool IsNaming { get; private set; } private static Dictionary<string, PinType> BuildPinableTypes() { Dictionary<string, PinType> dictionary = new Dictionary<string, PinType>(StringComparer.OrdinalIgnoreCase); AddPinables(dictionary, (PinType)0, "$piece_firepit", "$piece_bonfire", "$piece_fire", "$piece_goblincamp", "Goblin Camp", "Bonfire", "Campfire", "Hearth"); AddPinables(dictionary, (PinType)1, "$piece_portal", "Base", "Home", "Portal"); AddPinables(dictionary, (PinType)2, "$piece_deposit_copper", "Copper Deposit", "Copper", "$piece_deposit_silver", "$piece_deposit_silvervein", "Silver Deposit", "Silver", "Silvervein", "$piece_deposit_tin", "Tin Deposit", "Tin", "$piece_mudpile", "Muddy scrap pile", "Mud pile", "$piece_giant_brain", "Giant brain", "Giant Brain", "Tar Pit", "Dvergr Component Crate", "Flametal Ore", "Leviathan"); AddPinables(dictionary, (PinType)3, "$item_raspberries", "Raspberries", "$peRaspberryBushName", "$item_blueberries", "Blueberries", "$peBlueberryBushName", "$item_cloudberries", "Cloudberries", "$peCloudberryBushName", "$item_dragonegg", "Dragon egg", "$item_dandelion", "Dandelion", "$pePickableDandelionName", "$item_mushroomcommon", "Mushroom", "$pePickableMushroomName", "$pePickableYellowMushroomName", "$item_magecap", "Magecap", "$item_mushroomblue", "Blue mushroom", "$pePickableBlueMushroomName", "$item_thistle", "Thistle", "$pePickableThistleName", "$item_jotunpuffs", "Jotun puffs", "$pePickableJotunpuffsName", "$item_ancientroot", "Ancient root"); AddPinables(dictionary, (PinType)6, "$location_forestcave", "Troll Cave", "$location_forestcrypt", "Burial Chambers", "$location_sunkencrypt", "Sunken Crypt", "$location_mountaincave", "Frost Cave", "$location_dvergrtown", "Dvergr Town", "Infested Mine", "Morkhalla", "Putrid Hole", "Winding Tunnels", "Hildir's Cave", "Hildir's Crypt", "Hildir's Fortress", "Hildir's Camp", "Stone Henge", "Charred Fortress", "Bear Cave", "Fuling Camp", "Draugr Village", "Goblin Tower", "Fuling Tower", "Dvergr Guard Tower", "Dvergr Lighthouse", "Ruins", "Stone Tower Ruins", "Abandoned Village", "Dolmen", "Stone Circle", "Gibberish Statue", "Village Well", "Swamp Well", "Swamp Hut", "Shipwreck", "Rock Spire", "Road Post", "Mistlands Statue", "Ancient Altar", "Petrified Troll Remains", "Soft Tissue", "Winding Tunnels Entrance", "Abandoned Homestead", "Abandoned Log Cabin", "Deep North Bedchamber", "Deep North Combat Ring", "Deep North Dressing Room", "Deep North Forge", "Deep North Garden", "Deep North House", "Deep North Kitchen", "Deep North Mage's Room", "Grausten Ruins", "Ashland Ruins", "Infested Tree", "Guck Sac", "Runestone", "Sealed Chest", "Treasure Chest", "Sealed Tower", "Floating Island", "Drake Nest"); AddPinables(dictionary, (PinType)9, "Eikthyr's Den", "The Elder's Shrine", "Bonemass's Altar", "Bonemass Altar", "Moder's Altar", "Yagluth's Lair", "The Queen's Lair", "Fader's Coliseum", "Kall Fimbulbringer's Lair"); return dictionary; } private static void AddPinables(Dictionary<string, PinType> map, PinType type, params string[] names) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) foreach (string key in names) { map[key] = type; } } public static PinType IsPinable(string strID) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0085: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(strID)) { return (PinType)8; } string text = (strID.StartsWith("$", StringComparison.Ordinal) ? strID.Substring(1) : strID); if (PinableTypes.TryGetValue(strID, out var value)) { return value; } if (PinableTypes.TryGetValue(text, out value)) { return value; } try { string baseTranslation = Localization_Patch.GetBaseTranslation(text); if (!string.IsNullOrEmpty(baseTranslation) && PinableTypes.TryGetValue(baseTranslation, out value)) { return value; } } catch (Exception ex) { QuickPingPlugin.Log.LogWarning((object)("[QP] Reverse localization lookup failed for '" + strID + "': " + ex.Message)); } return (PinType)8; } private static IEnumerable<PinData> GetPinsSafe() { if ((Object)(object)Minimap.instance == (Object)null) { yield break; } if (_minimapPinsField == null) { _minimapPinsField = AccessTools.Field(typeof(Minimap), "m_pins"); } if (_minimapPinsField == null) { if (!_minimapPinsErrorLogged) { _minimapPinsErrorLogged = true; QuickPingPlugin.Log.LogError((object)"[QP] Could not resolve private Minimap.m_pins field."); } yield break; } object rawPins; try { rawPins = _minimapPinsField.GetValue(Minimap.instance); } catch (Exception ex) { Exception e = ex; if (!_minimapPinsErrorLogged) { _minimapPinsErrorLogged = true; QuickPingPlugin.Log.LogError((object)("[QP] Failed reading private Minimap.m_pins: " + e.GetType().Name + ": " + e.Message)); } yield break; } if (!(rawPins is IEnumerable pins)) { yield break; } foreach (object item in pins) { PinData pin = (PinData)((item is PinData) ? item : null); if (pin != null) { yield return pin; } } } private static bool PinsContainSafe(PinData target) { if (target == null) { return false; } foreach (PinData item in GetPinsSafe()) { if (item == target) { return true; } } return false; } private static void ClearNamePinSafe() { if ((Object)(object)Minimap.instance == (Object)null) { return; } try { if (_minimapNamePinField == null) { _minimapNamePinField = AccessTools.Field(typeof(Minimap), "m_namePin"); } if (_minimapNamePinField != null) { _minimapNamePinField.SetValue(Minimap.instance, null); } } catch { } } internal static void RenamePin(HoverObject obj) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (obj != null) { AddPin(obj.Hover, obj.Destructible, obj.Name, obj.center, force: true, rename: true, obj.ResolvedPinType); } } public static void AddPin(HoverObject obj) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (obj != null) { AddPin(obj.Hover, obj.Destructible, obj.Name, obj.center, force: false, rename: false, obj.ResolvedPinType); } } public static void ForceAddPin(HoverObject obj) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (obj != null) { AddPin(obj.Hover, obj.Destructible, obj.Name, obj.center, force: true, rename: false, obj.ResolvedPinType); } } public unsafe static void AddPin(GameObject hover, IDestructible idestructible, string strID, Vector3 pos, bool force = false, bool rename = false, PinType preferredType = (PinType)8) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Invalid comparison between Unknown and I4 //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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_0296: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Invalid comparison between Unknown and I4 //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0235: 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_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Invalid comparison between Unknown and I4 //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Invalid comparison between Unknown and I4 //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_0369: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0386: 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_03a9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance == (Object)null || (!Settings.AddPin.Value && !force) || (!force && !rename && !string.IsNullOrEmpty(strID) && strID.Contains("item_tar"))) { return; } if ((Object)(object)hover != (Object)null && !rename) { ZNetView componentInParent = hover.GetComponentInParent<ZNetView>(); if ((Object)(object)componentInParent != (Object)null && componentInParent.GetZDO() != null) { ZDOID uid = componentInParent.GetZDO().m_uid; if (DataManager.PinnedObjects.TryGetValue(uid, out var value)) { if (value != null && PinsContainSafe(value)) { return; } DataManager.PinnedObjects.Remove(uid); } } } bool flag = strID == "$piece_portal" || strID == "Portal"; if (!rename && !flag) { string text = ResolvePinName(strID); foreach (PinData item in GetPinsSafe()) { if (item != null && item.m_name == text && Vector3.Distance(item.m_pos, pos) <= Settings.PinExclusionRange.Value) { return; } } } PinType type = (((int)preferredType != 8) ? preferredType : IsPinable(strID)); PinData val = new PinData { m_type = type }; if ((Object)(object)hover != (Object)null && (Object)(object)hover.GetComponent<ItemDrop>() != (Object)null) { val.m_type = (PinType)8; } PinData closestPin = Minimap.instance.GetClosestPin(pos, Settings.ClosestPinRange.Value, true); if (flag) { Hoverable hoverable = default(Hoverable); if ((Object)(object)hover != (Object)null && hover.TryGetComponent<Hoverable>(ref hoverable)) { val.m_name = GetPortalTag(hoverable); if (closestPin != null) { Minimap.instance.RemovePin(closestPin); } val.m_pos = pos; val = Minimap.instance.AddPin(val.m_pos, val.m_type, val.m_name, true, false, 0L, default(PlatformUserID)); TrackPin(idestructible, val); } } else { if (closestPin != null && !rename) { return; } val.m_name = ResolvePinName(strID); val.m_pos = pos; if (rename && (int)val.m_type == 8) { val.m_type = Settings.DefaultPinType.Value; } if (force && val.m_name == "PING !" && !string.IsNullOrEmpty(Settings.DefaultPinName.Value)) { val.m_name = Settings.DefaultPinName.Value; } if (rename) { GUIManager.BlockInput(true); tempOriginalText = strID; tempPin = val; tempDestructible = idestructible; InitNameInput(); return; } if ((int)val.m_type == 8 && force) { val.m_type = Settings.DefaultPinType.Value; } if ((int)val.m_type != 8) { val = Minimap.instance.AddPin(val.m_pos, val.m_type, val.m_name, true, false, 0L, default(PlatformUserID)); ManualLogSource log = QuickPingPlugin.Log; string name = val.m_name; Vector3 pos2 = val.m_pos; log.LogInfo((object)("[QP] Pin added: " + name + " @ " + ((object)(*(Vector3*)(&pos2))/*cast due to .constrained prefix*/).ToString())); TrackPin(idestructible, val); } } } private static string ResolvePinName(string strID) { if (!string.IsNullOrEmpty(strID) && DataManager.CustomNames.TryGetValue(strID, out var value)) { return value; } string text = ((!string.IsNullOrEmpty(strID) && Localization.instance != null) ? Localization.instance.Localize(strID) : strID); return string.IsNullOrEmpty(text) ? "PING !" : text; } private static void TrackPin(IDestructible idestructible, PinData pin) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (idestructible == null || pin == null) { return; } Component val = (Component)(object)((idestructible is Component) ? idestructible : null); if (val != null) { ZNetView componentInParent = val.GetComponentInParent<ZNetView>(); if (!((Object)(object)componentInParent == (Object)null) && componentInParent.GetZDO() != null) { DataManager.PinnedObjects[componentInParent.GetZDO().m_uid] = pin; } } } public static void UpdateNameInput() { try { if ((Object)(object)Minimap.instance == (Object)null) { return; } if (Input.GetKeyDown((KeyCode)27)) { CancelNameInput(); return; } if ((Object)(object)nameInput != (Object)null && (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271))) { InputField component = nameInput.GetComponent<InputField>(); Toggle val = (((Object)(object)toggleDefault != (Object)null) ? toggleDefault.GetComponent<Toggle>() : null); _releaseInputAfterEnter = true; ValidateNameInput(component, (Object)(object)val != (Object)null && val.isOn); return; } if ((Object)(object)panel != (Object)null) { panel.SetActive(true); } if ((Object)(object)nameInput != (Object)null) { nameInput.SetActive(true); } if ((Object)(object)toggleDefault != (Object)null) { toggleDefault.SetActive(true); } InputField val2 = (((Object)(object)nameInput != (Object)null) ? nameInput.GetComponent<InputField>() : null); if ((Object)(object)val2 != (Object)null && !val2.isFocused && (Object)(object)EventSystem.current != (Object)null) { EventSystem.current.SetSelectedGameObject(nameInput); } } catch (Exception ex) { QuickPingPlugin.Log.LogError((object)("[QP] UpdateNameInput failed: " + ex.Message)); CancelNameInput(); } } private static void CancelNameInput() { IsNaming = false; tempOriginalText = null; tempPin = null; tempDestructible = null; try { GUIManager.BlockInput(false); } catch { } DestroyGUI(); } private static void DestroyGUI() { try { if ((Object)(object)nameInput != (Object)null) { Object.Destroy((Object)(object)nameInput); } if ((Object)(object)toggleDefault != (Object)null) { Object.Destroy((Object)(object)toggleDefault); } if ((Object)(object)panel != (Object)null) { Object.Destroy((Object)(object)panel); } } catch { } IconOutlines.Clear(); panel = null; nameInput = null; toggleDefault = null; } private static void ConfirmEditor() { try { InputField inputField = (((Object)(object)nameInput != (Object)null) ? nameInput.GetComponent<InputField>() : null); Toggle val = (((Object)(object)toggleDefault != (Object)null) ? toggleDefault.GetComponent<Toggle>() : null); ValidateNameInput(inputField, (Object)(object)val != (Object)null && val.isOn); } catch (Exception ex) { QuickPingPlugin.Log.LogError((object)("[QP] Confirm failed: " + ex.Message)); CancelNameInput(); } } private unsafe static void ValidateNameInput(InputField inputField, bool useAsDefault) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) try { string text = (((Object)(object)inputField != (Object)null) ? inputField.text.Replace('$', ' ').Replace('<', ' ').Replace('>', ' ') : ""); string text2 = tempOriginalText; PinData val = tempPin; if (val != null && (Object)(object)Minimap.instance != (Object)null) { val.m_name = text; val.m_type = selectedIcon; PinData val2 = Minimap.instance.AddPin(val.m_pos, val.m_type, val.m_name, true, false, 0L, default(PlatformUserID)); if (val2 != null) { val = val2; ManualLogSource log = QuickPingPlugin.Log; string name = val.m_name; Vector3 pos = val.m_pos; log.LogInfo((object)("[QP] Pin added (via editor): " + name + " @ " + ((object)(*(Vector3*)(&pos))/*cast due to .constrained prefix*/).ToString())); TrackPin(tempDestructible, val); } } if (string.IsNullOrEmpty(text)) { if (!string.IsNullOrEmpty(text2) && DataManager.CustomNames.ContainsKey(text2)) { DataManager.CustomNames.Remove(text2); } } else { SaveName(text, text2); } if (useAsDefault) { Settings.DefaultPinType.Value = selectedIcon; Settings.DefaultPinName.Value = text; } } catch (Exception ex) { QuickPingPlugin.Log.LogError((object)("[QP] ValidateNameInput failed: " + ex.Message)); } IsNaming = false; tempOriginalText = null; tempPin = null; tempDestructible = null; ReleaseEditorInput(); DestroyGUI(); } private static void ReleaseEditorInput() { if (!_releaseInputAfterEnter) { try { GUIManager.BlockInput(false); return; } catch { return; } } _releaseInputAfterEnter = false; if (_releaseInputCoroutineRunning) { return; } if ((Object)(object)QuickPingPlugin.Instance == (Object)null) { try { GUIManager.BlockInput(false); return; } catch { return; } } _releaseInputCoroutineRunning = true; ((MonoBehaviour)QuickPingPlugin.Instance).StartCoroutine(ReleaseInputAfterEnterRoutine()); } private static IEnumerator ReleaseInputAfterEnterRoutine() { while (Input.GetKey((KeyCode)13) || Input.GetKey((KeyCode)271)) { yield return null; } yield return null; try { GUIManager.BlockInput(false); } catch { } _releaseInputCoroutineRunning = false; } private static void SaveName(string m_name, string originalName) { if (!string.IsNullOrEmpty(originalName)) { if (DataManager.CustomNames.ContainsKey(originalName)) { DataManager.CustomNames[originalName] = m_name; } else { DataManager.CustomNames.Add(originalName, m_name); } } } private static Sprite GetPinSprite(PinType type) { //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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Invalid comparison between I4 and Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)Minimap.instance == (Object)null) { return null; } if (!_iconsFieldSearched) { _iconsFieldSearched = true; _minimapIconsField = typeof(Minimap).GetField("m_icons", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (!(_minimapIconsField?.GetValue(Minimap.instance) is IEnumerable enumerable)) { return null; } foreach (object item in enumerable) { if (item == null) { continue; } Type type2 = item.GetType(); FieldInfo field = type2.GetField("m_name", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo field2 = type2.GetField("m_icon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null || field2 == null) { continue; } object value = field.GetValue(item); bool num; if (!(value is PinType val)) { if (!TryConvertPinType(value, out var result)) { continue; } num = result == (int)type; } else { num = val == type; } if (num) { object? value2 = field2.GetValue(item); return (Sprite)((value2 is Sprite) ? value2 : null); } } } catch (Exception ex) { QuickPingPlugin.Log.LogDebug((object)("[QP] Pin icon lookup failed: " + ex.Message)); } return null; } private static bool TryConvertPinType(object value, out int result) { try { result = Convert.ToInt32(value); return true; } catch { result = 0; return false; } } private unsafe static string ShortLabel(PinType type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected I4, but got Unknown PinType val = type; PinType val2 = val; return (int)val2 switch { 0 => "Fire", 1 => "Home", 2 => "Hammer", 3 => "Berry", 6 => "Dungeon", 4 => "Death", 5 => "Bed", 9 => "Boss", 10 => "Player", 7 => "Shout", 12 => "Ping", 11 => "!", _ => ((object)(*(PinType*)(&type))/*cast due to .constrained prefix*/).ToString(), }; } private static void SelectIcon(PinType type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) selectedIcon = type; foreach (KeyValuePair<PinType, Outline> iconOutline in IconOutlines) { if ((Object)(object)iconOutline.Value != (Object)null) { ((Behaviour)iconOutline.Value).enabled = iconOutline.Key == selectedIcon; } } } private unsafe static GameObject CreateIconButton(PinType type, Transform parent, Vector2 anchoredPos) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0045: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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_00eb: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Expected O, but got Unknown try { GameObject val = new GameObject("PinIcon_" + ((object)(*(PinType*)(&type))/*cast due to .constrained prefix*/).ToString()); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.sizeDelta = new Vector2(48f, 48f); val2.anchoredPosition = anchoredPos; Image val3 = val.AddComponent<Image>(); ((Graphic)val3).color = new Color(0f, 0f, 0f, 0.4f); Outline val4 = val.AddComponent<Outline>(); ((Shadow)val4).effectColor = new Color(1f, 0.85f, 0f, 1f); ((Shadow)val4).effectDistance = new Vector2(3f, 3f); ((Behaviour)val4).enabled = false; Sprite pinSprite = GetPinSprite(type); if ((Object)(object)pinSprite != (Object)null) { GameObject val5 = new GameObject("Icon"); val5.transform.SetParent(val.transform, false); RectTransform val6 = val5.AddComponent<RectTransform>(); val6.sizeDelta = new Vector2(34f, 34f); val6.anchoredPosition = Vector2.zero; Image val7 = val5.AddComponent<Image>(); val7.sprite = pinSprite; ((Graphic)val7).color = Color.white; } else { GameObject val8 = new GameObject("Label"); val8.transform.SetParent(val.transform, false); RectTransform val9 = val8.AddComponent<RectTransform>(); val9.anchorMin = Vector2.zero; val9.anchorMax = Vector2.one; val9.offsetMin = Vector2.zero; val9.offsetMax = Vector2.zero; Text val10 = val8.AddComponent<Text>(); val10.text = ShortLabel(type); ((Graphic)val10).color = Color.white; val10.alignment = (TextAnchor)4; val10.fontSize = 12; val10.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); } Button val11 = val.AddComponent<Button>(); ((Selectable)val11).targetGraphic = (Graphic)(object)val3; PinType captured = type; ((UnityEvent)val11.onClick).AddListener((UnityAction)delegate { //IL_0002: Unknown result type (might be due to invalid IL or missing references) SelectIcon(captured); }); return val; } catch (Exception ex) { QuickPingPlugin.Log.LogError((object)("[QP] CreateIconButton failed for " + ((object)(*(PinType*)(&type))/*cast due to .constrained prefix*/).ToString() + ": " + ex.Message)); return null; } } private static GameObject CreateTextButton(string label, Transform parent, Vector2 anchoredPos, Vector2 size, Color bgColor, Action onClick) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0058: Expected O, but got Unknown //IL_0077: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown try { GameObject val = new GameObject(label); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.sizeDelta = size; val2.anchoredPosition = anchoredPos; Image val3 = val.AddComponent<Image>(); ((Graphic)val3).color = bgColor; GameObject val4 = new GameObject("Text"); val4.transform.SetParent(val.transform, false); RectTransform val5 = val4.AddComponent<RectTransform>(); val5.anchorMin = Vector2.zero; val5.anchorMax = Vector2.one; val5.offsetMin = Vector2.zero; val5.offsetMax = Vector2.zero; Text val6 = val4.AddComponent<Text>(); val6.text = label; ((Graphic)val6).color = Color.white; val6.alignment = (TextAnchor)4; val6.fontSize = 16; val6.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); Button val7 = val.AddComponent<Button>(); ((Selectable)val7).targetGraphic = (Graphic)(object)val3; ((UnityEvent)val7.onClick).AddListener((UnityAction)delegate { onClick(); }); return val; } catch (Exception ex) { QuickPingPlugin.Log.LogError((object)("[QP] CreateTextButton failed for " + label + ": " + ex.Message)); return null; } } private static void InitNameInput() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00bc: Expected O, but got Unknown //IL_00e5: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0227: 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_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Expected O, but got Unknown //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: 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_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) try { if (GUIManager.Instance == null || !Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { return; } DestroyGUI(); IsNaming = true; selectedIcon = ((tempPin != null && (int)tempPin.m_type != 8) ? tempPin.m_type : Settings.DefaultPinType.Value); panel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 380f, 320f, true); GameObject val = new GameObject("Title"); val.transform.SetParent(panel.transform, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.sizeDelta = new Vector2(320f, 24f); val2.anchoredPosition = new Vector2(0f, 132f); Text val3 = val.AddComponent<Text>(); val3.text = "Pin Editor"; ((Graphic)val3).color = Color.white; val3.alignment = (TextAnchor)4; val3.fontSize = 18; val3.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); IconOutlines.Clear(); Vector2 anchoredPos = default(Vector2); for (int i = 0; i < EditorIcons.Length; i++) { PinType val4 = EditorIcons[i]; ((Vector2)(ref anchoredPos))..ctor(-125f + (float)(i % 6) * 50f, 80f - (float)(i / 6) * 54f); GameObject val5 = CreateIconButton(val4, panel.transform, anchoredPos); if ((Object)(object)val5 != (Object)null) { Outline component = val5.GetComponent<Outline>(); if ((Object)(object)component != (Object)null) { IconOutlines[val4] = component; } } } SelectIcon(selectedIcon); nameInput = GUIManager.Instance.CreateInputField(panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, -20f), (ContentType)0, "Pin Name (blank = icon only)", 16, 280f, 32f); InputField val6 = (((Object)(object)nameInput != (Object)null) ? nameInput.GetComponent<InputField>() : null); if ((Object)(object)val6 != (Object)null) { val6.text = ((tempPin != null) ? (tempPin.m_name ?? "") : ""); } if ((Object)(object)nameInput != (Object)null) { nameInput.SetActive(true); } toggleDefault = GUIManager.Instance.CreateToggle(panel.transform, 20f, 20f); if ((Object)(object)toggleDefault != (Object)null) { RectTransform component2 = toggleDefault.GetComponent<RectTransform>(); if ((Object)(object)component2 != (Object)null) { component2.anchorMin = new Vector2(0.5f, 0.5f); component2.anchorMax = new Vector2(0.5f, 0.5f); component2.anchoredPosition = new Vector2(-135f, -62f); } toggleDefault.SetActive(true); } GameObject val7 = new GameObject("ToggleLabel"); val7.transform.SetParent(panel.transform, false); RectTransform val8 = val7.AddComponent<RectTransform>(); val8.anchorMin = new Vector2(0.5f, 0.5f); val8.anchorMax = new Vector2(0.5f, 0.5f); val8.sizeDelta = new Vector2(230f, 20f); val8.anchoredPosition = new Vector2(-10f, -62f); Text val9 = val7.AddComponent<Text>(); val9.text = "Use as default for future pins"; ((Graphic)val9).color = Color.white; val9.alignment = (TextAnchor)3; val9.fontSize = 13; val9.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); CreateTextButton("Confirm", panel.transform, new Vector2(-75f, -115f), new Vector2(140f, 34f), new Color(0.3f, 0.45f, 0.25f, 1f), ConfirmEditor); CreateTextButton("Cancel", panel.transform, new Vector2(75f, -115f), new Vector2(140f, 34f), new Color(0.45f, 0.3f, 0.25f, 1f), CancelNameInput); } catch (Exception ex) { QuickPingPlugin.Log.LogError((object)("[QP] InitNameInput failed: " + ex)); IsNaming = false; try { GUIManager.BlockInput(false); } catch { } try { if ((Object)(object)Minimap.instance != (Object)null) { ClearNamePinSafe(); } } catch { } DestroyGUI(); } } private static string GetPortalTag(Hoverable hoverable) { string text = ((hoverable != null) ? hoverable.GetHoverText() : null) ?? string.Empty; int num = text.IndexOf('"'); int num2 = ((num >= 0) ? text.IndexOf('"', num + 1) : (-1)); if (num >= 0 && num2 > num) { return text.Substring(num + 1, num2 - num - 1); } return ((hoverable != null) ? hoverable.GetHoverName() : null) ?? "Portal"; } [HarmonyPatch(typeof(Minimap), "RemovePin", new Type[] { typeof(PinData) })] [HarmonyPostfix] public static void RemovePin_Postfix(Minimap __instance, PinData pin) { //IL_0010: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (pin == null) { return; } ZDOID key = default(ZDOID); bool flag = false; foreach (KeyValuePair<ZDOID, PinData> pinnedObject in DataManager.PinnedObjects) { if (pinnedObject.Value.m_name == pin.m_name && pinnedObject.Value.m_pos == pin.m_pos) { key = pinnedObject.Key; flag = true; break; } } if (flag) { DataManager.PinnedObjects.Remove(key); } } static Minimap_Patch() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) PinType[] array = new PinType[12]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); EditorIcons = (PinType[])(object)array; } } internal static class Player_Patch { public static readonly UnityEvent<HoverObject> OnPlayerPing = new UnityEvent<HoverObject>(); public static readonly UnityEvent<HoverObject> OnPlayerForcePing = new UnityEvent<HoverObject>(); public static readonly UnityEvent<HoverObject> OnPlayerRename = new UnityEvent<HoverObject>(); private static float LastPingStamp = -1f; private static bool _pinTypeErrorLogged; [HarmonyPatch(typeof(Player), "Update")] [HarmonyPostfix] private static void Player_Update(Player __instance) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Invalid comparison between Unknown and I4 //IL_01b1: Unknown result type (might be due to invalid IL or missing references) if (ZInput.instance == null || (Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)Player.m_localPlayer != (Object)(object)__instance) { return; } if (Minimap_Patch.IsNaming) { Minimap_Patch.UpdateNameInput(); } MethodInfo method = typeof(Player).GetMethod("TakeInput", new Type[1] { typeof(float) }); bool flag; if (method != null) { flag = (bool)method.Invoke(Player.m_localPlayer, new object[1] { 0f }); } else { MethodInfo method2 = typeof(Player).GetMethod("TakeInput", Type.EmptyTypes); flag = ((method2 != null) ? ((bool)method2.Invoke(Player.m_localPlayer, null)) : (!((Character)Player.m_localPlayer).IsDead() && !((Character)Player.m_localPlayer).InBed() && !((Character)Player.m_localPlayer).InCutscene())); } if (flag && !(Time.time - LastPingStamp < 0.25f)) { int num; if (Settings.RenameBtn == null || !ZInput.GetButtonDown(Settings.RenameBtn.Name)) { KeyboardShortcut value = Settings.RenameKey.Value; num = (((KeyboardShortcut)(ref value)).IsDown() ? 1 : 0); } else { num = 1; } bool flag2 = (byte)num != 0; bool flag3 = Settings.PingBtn != null && ZInput.GetButtonDown(Settings.PingBtn.Name); bool flag4 = Settings.PingEverythingBtn != null && ZInput.GetButtonDown(Settings.PingEverythingBtn.Name); if (!flag4 && (int)Settings.PinEverythingKey.Value > 0) { flag4 = Input.GetKeyDown(Settings.PinEverythingKey.Value); } if (flag2) { HoverObject hoverObject = FindHoverObject(500f); hoverObject.Name = GetHoverName(hoverObject.Name, hoverObject.Hover, hoverObject.type); OnPlayerRename.Invoke(hoverObject); LastPingStamp = Time.time; } else if (flag3) { HoverObject hoverObject2 = FindHoverObject(500f); hoverObject2.Name = GetHoverName(hoverObject2.Name, hoverObject2.Hover, hoverObject2.type); OnPlayerPing.Invoke(hoverObject2); LastPingStamp = Time.time; } else if (flag4) { HoverObject hoverObject3 = FindHoverObject(500f); hoverObject3.Name = GetHoverName(hoverObject3.Name, hoverObject3.Hover, hoverObject3.type); OnPlayerForcePing.Invoke(hoverObject3); LastPingStamp = Time.time; } } } private static string GetHoverName(string pingText, GameObject hover, HoverType type) { switch (type) { case HoverType.Hoverable: { Hoverable val = default(Hoverable); hover.TryGetComponent<Hoverable>(ref val); pingText = ((!val.GetHoverName().StartsWith("$")) ? Localization_Patch.GetBaseTranslation(val.GetHoverName()) : val.GetHoverName()); if (pingText == "$") { pingText = val.GetHoverName(); } if (pingText == "noStr") { pingText = val.GetHoverName(); } if (((object)val).ToString().Contains("ReadMap") || ((object)val).ToString().Contains("WriteMap") || ((object)val).ToString().Contains("add_ore") || ((object)val).ToString().Contains("add_wood") || (((object)val).ToString().Contains("door") && Object.op_Implicit((Object)(object)hover.transform.parent) && Object.op_Implicit((Object)(object)((Component)hover.transform).GetComponentInParent<Piece>()))) { pingText = hover.GetComponentInParent<Piece>().m_name; } break; } case HoverType.Piece: { Piece component3 = hover.GetComponent<Piece>(); pingText = component3.m_name; break; } case HoverType.Location: try { if (!((Object)(object)hover == (Object)null)) { Location component2 = hover.GetComponent<Location>(); string text = (((Object)(object)component2 != (Object)null) ? Localization_Patch.Localize(component2) : Localization_Patch.LocalizeName(((Object)hover).name)); if (!string.IsNullOrEmpty(text)) { pingText = text; } } } catch (Exception ex) { QuickPingPlugin.Log.LogError((object)("[QP] Location name resolution failed; using normal ping: " + ex.Message)); } break; case HoverType.Character: { Character component = hover.GetComponent<Character>(); pingText = component.m_name; break; } } return pingText; } public static HoverObject FindHoverObject(float range) { //IL_0013: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0614: 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_01b8: 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_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: 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_0692: Unknown result type (might be due to invalid IL or missing references) //IL_0697: Unknown result type (might be due to invalid IL or missing references) //IL_0682: Unknown result type (might be due to invalid IL or missing references) //IL_0687: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_05c1: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_05d9: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) HoverObject hoverObj = new HoverObject { type = HoverType.GameObject, pos = ((Character)Player.m_localPlayer).GetHeadPoint(), center = ((Character)Player.m_localPlayer).GetHeadPoint(), Name = "PING !" }; ChatPing_Patch.RawLocationLabel = null; LayerMask val = LayerMask.op_Implicit(LayerMask.GetMask(new string[12] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "character_noenv", "vehicle", "item" })); RaycastHit[] array = Physics.RaycastAll(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, range + 10f, LayerMask.op_Implicit(val)); RaycastHit[] array2 = Physics.RaycastAll(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, range + 10f, LayerMask.GetMask(new string[1] { "Water" }), (QueryTriggerInteraction)2); if (array2.Length != 0) { RaycastHit[] array3 = (RaycastHit[])(object)new RaycastHit[array.Length + array2.Length]; array.CopyTo(array3, 0); array2.CopyTo(array3, array.Length); array = array3; } Array.Sort(array, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance)); RaycastHit[] array4 = array; if (array4.Length == 0) { Ray val2 = default(Ray); ((Ray)(ref val2))..ctor(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward); hoverObj.pos = ((Ray)(ref val2)).GetPoint(range); hoverObj.center = hoverObj.pos; return hoverObj; } for (int num = 0; num < array4.Length; num++) { hoverObj.pos = ((RaycastHit)(ref array4[num])).point; RaycastHit raycastHit = array4[num]; if (OverlappingPlayer(ref raycastHit)) { continue; } if (!(Vector3.Distance(((Character)Player.m_localPlayer).GetEyePoint(), ((RaycastHit)(ref raycastHit)).point) < range)) { break; } Character val3 = (Object.op_Implicit((Object)(object)((RaycastHit)(ref raycastHit)).collider.attachedRigidbody) ? ((Component)((RaycastHit)(ref raycastHit)).collider.attachedRigidbody).GetComponent<Character>() : ((Component)((RaycastHit)(ref raycastHit)).collider).Get