using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LocationFinder.Core;
using LocationFinder.Patches;
using LocationFinder.UI;
using Splatform;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LocationFinder")]
[assembly: AssemblyDescription("Pins world locations on the minimap by category.")]
[assembly: AssemblyProduct("LocationFinder")]
[assembly: AssemblyCopyright("YouDied")]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LocationFinder
{
[BepInPlugin("YouDied.LocationFinder", "Location Finder", "1.0.14")]
[BepInProcess("valheim.exe")]
public class LocationFinderPlugin : BaseUnityPlugin
{
public const string PluginGUID = "YouDied.LocationFinder";
public const string PluginName = "Location Finder";
public const string PluginVersion = "1.0.14";
public static ManualLogSource Log;
public static ConfigEntry<KeyCode> PanelKey;
private readonly Harmony _harmony = new Harmony("YouDied.LocationFinder");
private void Awake()
{
//IL_0320: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
PanelKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "PanelKey", (KeyCode)39, "Key to open/close the Location Finder panel (default: ' key)");
Application.quitting += OnQuitting;
_harmony.CreateClassProcessor(typeof(Patch_HudAwake)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_ZoneSystemStart)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_ZoneSystemOnDestroy)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_GameCameraUpdateCamera)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_GameCameraMouseCapture)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_PlayerUpdate)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_PlayerFixedUpdate)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_PlayerTakeInput)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_HumanoidStartAttack)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_HumanoidUpdateEquipment)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_ChatUpdate)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_ChatHasFocus)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_MenuUpdate)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_TerminalUpdate)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_MinimapUpdate)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_MinimapSetMapMode)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_MinimapUpdateMap)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_MinimapOnMapLeftDown)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_MinimapOnMapLeftUp)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_MinimapOnMapDblClick)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_MinimapOnMapLeftClick)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_MinimapOnMapMiddleClick)).Patch();
_harmony.CreateClassProcessor(typeof(Patch_MinimapOnMapRightClick)).Patch();
SafePatch(typeof(Patch_ContainerAwake));
SafePatch(typeof(Patch_LeviathanAwake));
SafePatch(typeof(Patch_BeehiveAwake));
SafePatch(typeof(Patch_PickableAwake));
SafePatch(typeof(Patch_PickableInteract));
Assets.Load();
Log.LogInfo((object)string.Format("{0} {1} loaded. Press {2} to open.", "Location Finder", "1.0.14", PanelKey.Value));
}
private void SafePatch(Type patchType)
{
try
{
_harmony.CreateClassProcessor(patchType).Patch();
}
catch (Exception ex)
{
Log.LogWarning((object)("[LocationFinder] Optional patch " + patchType.Name + " failed: " + ex.Message));
}
}
private void OnQuitting()
{
WorldMapPinner.Shutdown();
}
private void OnDestroy()
{
WorldMapPinner.Shutdown();
_harmony.UnpatchSelf();
}
}
}
namespace LocationFinder.Patches
{
[HarmonyPatch(typeof(Hud), "Awake")]
public static class Patch_HudAwake
{
[HarmonyPostfix]
public static void Postfix(Hud __instance)
{
((Component)__instance).gameObject.AddComponent<LocationPanel>();
LocationFinderPlugin.Log.LogInfo((object)"Location Finder UI attached.");
}
}
[HarmonyPatch(typeof(ZoneSystem), "Start")]
public static class Patch_ZoneSystemStart
{
[HarmonyPostfix]
public static void Postfix(ZoneSystem __instance)
{
LocationConfig.LoadUserCategories();
WorldMapPinner.BeginInit((MonoBehaviour)(object)__instance);
}
}
[HarmonyPatch(typeof(ZoneSystem), "OnDestroy")]
public static class Patch_ZoneSystemOnDestroy
{
[HarmonyPostfix]
public static void Postfix()
{
WorldMapPinner.Shutdown();
}
}
[HarmonyPatch(typeof(Container), "Awake")]
public static class Patch_ContainerAwake
{
[CompilerGenerated]
private sealed class <IndexAfterLoad>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Container container;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <IndexAfterLoad>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if ((Object)(object)container != (Object)null)
{
WorldMapPinner.RegisterContainer(container);
}
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[HarmonyPostfix]
public static void Postfix(Container __instance)
{
if ((Object)(object)__instance != (Object)null)
{
((MonoBehaviour)__instance).StartCoroutine(IndexAfterLoad(__instance));
}
}
[IteratorStateMachine(typeof(<IndexAfterLoad>d__1))]
private static IEnumerator IndexAfterLoad(Container container)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <IndexAfterLoad>d__1(0)
{
container = container
};
}
}
[HarmonyPatch(typeof(Leviathan), "Awake")]
public static class Patch_LeviathanAwake
{
[HarmonyPostfix]
public static void Postfix(Leviathan __instance)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance != (Object)null)
{
WorldMapPinner.RegisterLeviathan(((Component)__instance).transform.position);
}
}
}
[HarmonyPatch(typeof(Beehive), "Awake")]
public static class Patch_BeehiveAwake
{
[HarmonyPostfix]
public static void Postfix(Beehive __instance)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance != (Object)null)
{
WorldMapPinner.RegisterBeehive(((Component)__instance).transform.position);
}
}
}
[HarmonyPatch(typeof(Pickable), "Awake")]
public static class Patch_PickableAwake
{
[HarmonyPostfix]
public static void Postfix(Pickable __instance)
{
if ((Object)(object)__instance != (Object)null)
{
WorldMapPinner.RegisterPickable(__instance);
}
}
}
[HarmonyPatch(typeof(Pickable), "Interact")]
public static class Patch_PickableInteract
{
[HarmonyPostfix]
public static void Postfix(Pickable __instance)
{
if ((Object)(object)__instance != (Object)null)
{
WorldMapPinner.UnregisterPickable(__instance);
}
}
}
[HarmonyPatch(typeof(Player), "Update")]
public static class Patch_PlayerUpdate
{
[HarmonyPrefix]
public static bool Prefix(Player __instance)
{
if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
{
return true;
}
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsBlockingInput)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Player), "FixedUpdate")]
public static class Patch_PlayerFixedUpdate
{
[HarmonyPrefix]
public static bool Prefix(Player __instance)
{
if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
{
return true;
}
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsBlockingInput)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Player), "TakeInput")]
public static class Patch_PlayerTakeInput
{
[HarmonyPrefix]
public static bool Prefix(Player __instance)
{
if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
{
return true;
}
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsBlockingInput)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Humanoid), "StartAttack")]
public static class Patch_HumanoidStartAttack
{
[HarmonyPrefix]
public static bool Prefix(Humanoid __instance, ref bool __result)
{
if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
{
return true;
}
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsBlockingInput)
{
__result = false;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Humanoid), "UpdateEquipment")]
public static class Patch_HumanoidUpdateEquipment
{
[HarmonyPrefix]
public static bool Prefix(Humanoid __instance)
{
if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
{
return true;
}
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsBlockingInput)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(GameCamera), "UpdateCamera")]
public static class Patch_GameCameraUpdateCamera
{
private static bool _wasBlocking = false;
private static readonly FieldInfo s_yawField = typeof(Player).GetField("m_lookYaw", BindingFlags.Instance | BindingFlags.NonPublic);
private static readonly FieldInfo s_pitchField = typeof(Player).GetField("m_lookPitch", BindingFlags.Instance | BindingFlags.NonPublic);
private static Quaternion _savedYaw;
private static float _savedPitch;
[HarmonyPrefix]
public static bool Prefix()
{
//IL_00b7: 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_0051: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsBlockingInput)
{
if (!_wasBlocking && (Object)(object)Player.m_localPlayer != (Object)null)
{
try
{
_savedYaw = (Quaternion)s_yawField.GetValue(Player.m_localPlayer);
_savedPitch = (float)s_pitchField.GetValue(Player.m_localPlayer);
}
catch
{
}
}
_wasBlocking = true;
Input.ResetInputAxes();
return false;
}
if (_wasBlocking)
{
_wasBlocking = false;
if ((Object)(object)Player.m_localPlayer != (Object)null)
{
try
{
s_yawField.SetValue(Player.m_localPlayer, _savedYaw);
s_pitchField.SetValue(Player.m_localPlayer, _savedPitch);
}
catch
{
}
}
Input.ResetInputAxes();
}
return true;
}
}
[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
public static class Patch_GameCameraMouseCapture
{
[HarmonyPrefix]
public static bool Prefix()
{
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsBlockingInput)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Chat), "Update")]
public static class Patch_ChatUpdate
{
[HarmonyPrefix]
public static bool Prefix()
{
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsBlockingInput)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Chat), "HasFocus")]
public static class Patch_ChatHasFocus
{
[HarmonyPostfix]
public static void Postfix(ref bool __result)
{
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsBlockingInput)
{
__result = false;
}
}
}
[HarmonyPatch(typeof(Menu), "Update")]
public static class Patch_MenuUpdate
{
[HarmonyPrefix]
public static bool Prefix()
{
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsBlockingInput)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Terminal), "Update")]
public static class Patch_TerminalUpdate
{
[HarmonyPrefix]
public static bool Prefix()
{
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsBlockingInput)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Minimap), "Update")]
public static class Patch_MinimapUpdate
{
[HarmonyPrefix]
public static bool Prefix()
{
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsBlockingInput)
{
Input.ResetInputAxes();
}
return true;
}
}
[HarmonyPatch(typeof(Minimap), "SetMapMode")]
public static class Patch_MinimapSetMapMode
{
[HarmonyPrefix]
public static bool Prefix()
{
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsVisible)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Minimap), "UpdateMap")]
public static class Patch_MinimapUpdateMap
{
[HarmonyPrefix]
public static bool Prefix()
{
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsMouseOverPanel)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Minimap), "OnMapLeftDown")]
public static class Patch_MinimapOnMapLeftDown
{
[HarmonyPrefix]
public static bool Prefix()
{
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsMouseOverPanel)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Minimap), "OnMapLeftUp")]
public static class Patch_MinimapOnMapLeftUp
{
[HarmonyPrefix]
public static bool Prefix()
{
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsMouseOverPanel)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Minimap), "OnMapDblClick")]
public static class Patch_MinimapOnMapDblClick
{
[HarmonyPrefix]
public static bool Prefix()
{
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsMouseOverPanel)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Minimap), "OnMapLeftClick")]
public static class Patch_MinimapOnMapLeftClick
{
[HarmonyPrefix]
public static bool Prefix()
{
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsMouseOverPanel)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Minimap), "OnMapMiddleClick")]
public static class Patch_MinimapOnMapMiddleClick
{
[HarmonyPrefix]
public static bool Prefix()
{
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsMouseOverPanel)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Minimap), "OnMapRightClick")]
public static class Patch_MinimapOnMapRightClick
{
[HarmonyPrefix]
public static bool Prefix()
{
if ((Object)(object)LocationPanel.Instance != (Object)null && LocationPanel.Instance.IsMouseOverPanel)
{
return false;
}
return true;
}
}
}
namespace LocationFinder.UI
{
public class LocationPanel : MonoBehaviour
{
private struct POINT
{
public int X;
public int Y;
}
private bool _visible = false;
private float _closedAt = -10f;
private const float CloseCooldown = 0.05f;
private int _tab = 0;
private string _searchInput = "";
private string _searchStatus = "";
private float _statusTimer = 0f;
private const float StatusDuration = 4f;
private Vector2 _scrollPos = Vector2.zero;
private const float PanelW = 420f;
private const float PanelH = 520f;
private const float TabH = 32f;
private const float FootH = 80f;
private const float Pad = 12f;
private static readonly Color C_Yellow = new Color(1f, 0.85f, 0.35f, 1f);
private static readonly Color C_YellowDim = new Color(0.78f, 0.62f, 0.2f, 1f);
private static readonly Color C_White = new Color(1f, 1f, 1f, 1f);
private static readonly Color C_SubText = new Color(0.75f, 0.75f, 0.75f, 1f);
private static readonly Color C_Shadow = new Color(0f, 0f, 0f, 0.85f);
private static readonly Color C_DarkBox = new Color(0.05f, 0.03f, 0.01f, 0.94f);
private static readonly Color C_TabOn = new Color(0.2f, 0.14f, 0.03f, 1f);
private static readonly Color C_TabOff = new Color(0.1f, 0.07f, 0.01f, 0.9f);
private static readonly Color C_RowHover = new Color(1f, 0.75f, 0.2f, 0.1f);
private static readonly Color C_Green = new Color(0.4f, 0.9f, 0.4f, 1f);
private static readonly Color C_Red = new Color(0.9f, 0.4f, 0.4f, 1f);
private static readonly Color C_Border = new Color(0.55f, 0.42f, 0.12f, 1f);
private GUIStyle _titleStyle;
private GUIStyle _tabOnStyle;
private GUIStyle _tabOffStyle;
private GUIStyle _labelStyle;
private GUIStyle _subStyle;
private GUIStyle _btnStyle;
private GUIStyle _inputStyle;
private GUIStyle _statusOkStyle;
private GUIStyle _statusErrStyle;
private GUIStyle _checkStyle;
private bool _stylesBuilt = false;
private const int WindowId = 1280262977;
public static LocationPanel Instance { get; private set; }
public bool IsVisible => _visible;
public bool IsBlockingInput => _visible || Time.time - _closedAt < 0.05f;
public bool IsMouseOverPanel { get; private set; } = false;
[DllImport("user32.dll")]
private static extern bool SetCursorPos(int x, int y);
[DllImport("user32.dll")]
private static extern bool GetCursorPos(out POINT p);
private static void WarpCursor()
{
if (GetCursorPos(out var p))
{
SetCursorPos(p.X, p.Y);
}
}
private void Awake()
{
Instance = this;
}
private void Update()
{
//IL_00ac: 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)
if (_statusTimer > 0f)
{
_statusTimer -= Time.deltaTime;
}
if (_visible)
{
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
if (Input.GetKeyDown((KeyCode)27) || Input.GetKeyDown(LocationFinderPlugin.PanelKey.Value))
{
Close();
}
if (_tab == 1 && (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)))
{
DoSearch();
}
Input.ResetInputAxes();
}
else if ((Object)(object)Player.m_localPlayer != (Object)null && Input.GetKeyDown(LocationFinderPlugin.PanelKey.Value))
{
Open();
}
}
public void Open()
{
//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)
_visible = true;
_scrollPos = Vector2.zero;
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
WarpCursor();
}
public void Close()
{
_visible = false;
_closedAt = Time.time;
IsMouseOverPanel = false;
WarpCursor();
Cursor.lockState = (CursorLockMode)1;
Cursor.visible = false;
}
private void BuildStyles()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Expected O, but got Unknown
//IL_00db: Expected O, but got Unknown
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Expected O, but got Unknown
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Expected O, but got Unknown
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: 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_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Expected O, but got Unknown
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: 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_01fe: Expected O, but got Unknown
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: 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_022d: Expected O, but got Unknown
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Expected O, but got Unknown
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Expected O, but got Unknown
//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: Expected O, but got Unknown
if (!_stylesBuilt)
{
_stylesBuilt = true;
GUIStyle val = new GUIStyle
{
fontSize = 15,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4
};
val.normal.background = null;
val.normal.textColor = C_Yellow;
_titleStyle = val;
GUIStyle val2 = new GUIStyle
{
fontSize = 12,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4
};
val2.normal.background = MakeTex(C_TabOn);
val2.normal.textColor = C_Yellow;
val2.hover.background = MakeTex(C_TabOn);
val2.hover.textColor = C_White;
val2.padding = new RectOffset(4, 4, 4, 4);
_tabOnStyle = val2;
GUIStyle val3 = new GUIStyle(_tabOnStyle);
val3.normal.background = MakeTex(C_TabOff);
val3.normal.textColor = C_SubText;
val3.hover.background = MakeTex(C_TabOn);
val3.hover.textColor = C_Yellow;
_tabOffStyle = val3;
GUIStyle val4 = new GUIStyle
{
fontSize = 12,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)3
};
val4.normal.background = null;
val4.normal.textColor = C_White;
_labelStyle = val4;
GUIStyle val5 = new GUIStyle
{
fontSize = 11,
alignment = (TextAnchor)4
};
val5.normal.background = null;
val5.normal.textColor = C_SubText;
_subStyle = val5;
GUIStyle val6 = new GUIStyle(GUI.skin.button)
{
fontSize = 11,
fontStyle = (FontStyle)1
};
val6.normal.textColor = C_Yellow;
val6.hover.textColor = C_White;
_btnStyle = val6;
GUIStyle val7 = new GUIStyle(GUI.skin.textField)
{
fontSize = 13
};
val7.normal.textColor = C_White;
_inputStyle = val7;
GUIStyle val8 = new GUIStyle
{
fontSize = 11,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4,
wordWrap = true
};
val8.normal.background = null;
val8.normal.textColor = C_Green;
_statusOkStyle = val8;
GUIStyle val9 = new GUIStyle(_statusOkStyle);
val9.normal.background = null;
val9.normal.textColor = C_Red;
_statusErrStyle = val9;
GUIStyle val10 = new GUIStyle(GUI.skin.toggle)
{
fontSize = 12
};
val10.normal.textColor = C_White;
val10.hover.textColor = C_Yellow;
val10.onNormal.textColor = C_Yellow;
_checkStyle = val10;
}
}
private void OnGUI()
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
//IL_0084: 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_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
if (_visible)
{
BuildStyles();
float num = (float)Screen.width * 0.5f - 210f;
float num2 = (float)Screen.height * 0.5f - 260f;
GUIStyle val = new GUIStyle();
val.normal.background = MakeTex(C_DarkBox);
GUIStyle val2 = val;
GUI.Window(1280262977, new Rect(num, num2, 420f, 520f), new WindowFunction(DrawWindow), "", val2);
Rect val3 = new Rect(num, num2, 420f, 520f);
IsMouseOverPanel = ((Rect)(ref val3)).Contains(Event.current.mousePosition);
}
}
private void DrawWindow(int id)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Invalid comparison between Unknown and I4
//IL_00a5: 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_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Invalid comparison between Unknown and I4
//IL_002e: 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_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: 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_006d: Invalid comparison between Unknown and I4
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Invalid comparison between Unknown and I4
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
//IL_032b: Unknown result type (might be due to invalid IL or missing references)
//IL_0500: Unknown result type (might be due to invalid IL or missing references)
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
//IL_053d: Unknown result type (might be due to invalid IL or missing references)
//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
//IL_03de: Unknown result type (might be due to invalid IL or missing references)
//IL_042a: Unknown result type (might be due to invalid IL or missing references)
//IL_0461: Unknown result type (might be due to invalid IL or missing references)
float num = 0f;
float num2 = 0f;
Event current = Event.current;
if ((int)current.type == 4)
{
if ((int)current.keyCode == 27 || current.keyCode == LocationFinderPlugin.PanelKey.Value)
{
Close();
current.Use();
return;
}
if (_tab == 1 && ((int)current.keyCode == 13 || (int)current.keyCode == 271))
{
DoSearch();
current.Use();
}
}
DrawBorder(num, num2, 420f, 520f, C_Border, 2f);
float num3 = num2 + 12f;
ShadowLabel(new Rect(num, num3, 420f, 22f), "⚑ LOCATION FINDER", _titleStyle);
num3 += 26f;
string text = (WorldMapPinner.IsReady ? $"{WorldMapPinner.PinCount} mod pin(s) on map" : "Loading world data...");
GUI.Label(new Rect(num, num3, 420f, 16f), text, _subStyle);
num3 += 20f;
if (GUI.Button(new Rect(num + 420f - 30f, num2 + 8f, 22f, 22f), "✕", _btnStyle))
{
Close();
}
float num4 = 198f;
if (GUI.Button(new Rect(num + 12f, num3, num4, 32f), "Locations", (_tab == 0) ? _tabOnStyle : _tabOffStyle))
{
_tab = 0;
_scrollPos = Vector2.zero;
}
if (GUI.Button(new Rect(num + 12f + num4, num3, num4, 32f), "Custom Search", (_tab == 1) ? _tabOnStyle : _tabOffStyle))
{
_tab = 1;
_scrollPos = Vector2.zero;
}
num3 += 36f;
float num5 = 520f - (num3 - num2) - 80f - 12f;
Rect area = default(Rect);
((Rect)(ref area))..ctor(num + 12f, num3, 396f, num5);
Fill(((Rect)(ref area)).x, ((Rect)(ref area)).y, ((Rect)(ref area)).width, ((Rect)(ref area)).height, new Color(0f, 0f, 0f, 0.3f));
if (_tab == 0)
{
DrawChecklistTab(area);
}
else
{
DrawSearchTab(area);
}
num3 += num5 + 12f;
DrawBorder(num, num3 - 2f, 420f, 2f, C_Border, 2f);
if (_tab == 0)
{
float num6 = 80f;
float num7 = 6f;
float num8 = num + (420f - num6 * 4f - num7 * 3f) * 0.5f;
if (GUI.Button(new Rect(num8, num3 + 8f, num6, 28f), "APPLY", _btnStyle))
{
WorldMapPinner.ApplyCheckedCategories();
}
if (GUI.Button(new Rect(num8 + (num6 + num7), num3 + 8f, num6, 28f), "SEL ALL", _btnStyle))
{
SetAllChecked(value: true);
}
if (GUI.Button(new Rect(num8 + (num6 + num7) * 2f, num3 + 8f, num6, 28f), "DESEL ALL", _btnStyle))
{
SetAllChecked(value: false);
}
if (GUI.Button(new Rect(num8 + (num6 + num7) * 3f, num3 + 8f, num6, 28f), "CLR LAST", _btnStyle))
{
WorldMapPinner.ClearLastPin();
}
float num9 = num + (420f - num6 * 2f - num7) * 0.5f;
if (GUI.Button(new Rect(num9, num3 + 40f, num6, 24f), "CLR ALL", _btnStyle))
{
WorldMapPinner.ClearAllPins();
}
if (GUI.Button(new Rect(num9 + num6 + num7, num3 + 40f, num6, 24f), "CLOSE", _btnStyle))
{
Close();
}
}
else
{
float num10 = 95f;
float num11 = 8f;
float num12 = num + (420f - num10 * 3f - num11 * 2f) * 0.5f;
if (GUI.Button(new Rect(num12, num3 + 8f, num10, 28f), "CLR LAST", _btnStyle))
{
WorldMapPinner.ClearLastPin();
}
if (GUI.Button(new Rect(num12 + num10 + num11, num3 + 8f, num10, 28f), "CLEAR PINS", _btnStyle))
{
WorldMapPinner.ClearAllPins();
}
if (GUI.Button(new Rect(num12 + (num10 + num11) * 2f, num3 + 8f, num10, 28f), "CLOSE", _btnStyle))
{
Close();
}
}
}
private static void SetAllChecked(bool value)
{
foreach (LocationCategory category in LocationConfig.Categories)
{
category.Checked = value;
}
foreach (LocationCategory userCategory in LocationConfig.UserCategories)
{
userCategory.Checked = value;
}
}
private void DrawChecklistTab(Rect area)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
List<LocationCategory> list = new List<LocationCategory>();
list.AddRange(LocationConfig.Categories);
list.AddRange(LocationConfig.UserCategories);
float num = 26f;
float num2 = (float)list.Count * num + 12f;
Rect val = default(Rect);
((Rect)(ref val))..ctor(0f, 0f, ((Rect)(ref area)).width - 16f, num2);
_scrollPos = GUI.BeginScrollView(area, _scrollPos, val);
float num3 = 6f;
Rect val2 = default(Rect);
foreach (LocationCategory item in list)
{
((Rect)(ref val2))..ctor(12f, num3, ((Rect)(ref area)).width - 16f - 24f, num);
if (((Rect)(ref val2)).Contains(Event.current.mousePosition))
{
Fill(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height, C_RowHover);
}
item.Checked = GUI.Toggle(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y + 4f, ((Rect)(ref val2)).width, 20f), item.Checked, " " + item.Name, _checkStyle);
num3 += num;
}
GUI.EndScrollView();
}
private void DrawSearchTab(Rect area)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Expected O, but got Unknown
//IL_01e1: 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_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_032f: Unknown result type (might be due to invalid IL or missing references)
//IL_0334: Unknown result type (might be due to invalid IL or missing references)
//IL_033c: Unknown result type (might be due to invalid IL or missing references)
//IL_0356: Unknown result type (might be due to invalid IL or missing references)
//IL_0363: Expected O, but got Unknown
//IL_0365: Unknown result type (might be due to invalid IL or missing references)
//IL_036c: Expected O, but got Unknown
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0398: Unknown result type (might be due to invalid IL or missing references)
//IL_03db: Unknown result type (might be due to invalid IL or missing references)
//IL_0465: Unknown result type (might be due to invalid IL or missing references)
float num = ((Rect)(ref area)).y + 12f;
GUI.Label(new Rect(((Rect)(ref area)).x + 12f, num, ((Rect)(ref area)).width - 24f, 18f), "Search location prefab names (e.g. WoodHouse, Crypt, Ruin)", _subStyle);
num += 22f;
GUI.SetNextControlName("LocationSearch");
_searchInput = GUI.TextField(new Rect(((Rect)(ref area)).x + 12f, num, ((Rect)(ref area)).width - 24f - 90f, 26f), _searchInput, _inputStyle);
GUI.FocusControl("LocationSearch");
if (GUI.Button(new Rect(((Rect)(ref area)).x + ((Rect)(ref area)).width - 12f - 84f, num, 84f, 26f), "SEARCH", _btnStyle))
{
DoSearch();
}
num += 34f;
if (_statusTimer > 0f && !string.IsNullOrEmpty(_searchStatus))
{
bool flag = _searchStatus.Contains("Pinned");
GUI.Label(new Rect(((Rect)(ref area)).x + 12f, num, ((Rect)(ref area)).width - 24f, 40f), _searchStatus, flag ? _statusOkStyle : _statusErrStyle);
num += 44f;
}
float num2 = num + 8f;
float num3 = (((Rect)(ref area)).width - 24f) * 0.5f;
float num4 = ((Rect)(ref area)).x + 12f;
float num5 = ((Rect)(ref area)).x + 12f + num3;
GUIStyle val = new GUIStyle(_subStyle)
{
fontStyle = (FontStyle)1
};
val.normal.textColor = C_Yellow;
GUIStyle val2 = val;
GUI.Label(new Rect(num4, num2, num3, 18f), "Seeds & Loot", val2);
GUI.Label(new Rect(num5, num2, num3, 18f), "Rare Items", val2);
num2 += 20f;
Fill(num4, num2, ((Rect)(ref area)).width - 24f, 1f, new Color(0.55f, 0.42f, 0.12f, 0.5f));
num2 += 4f;
string[] array = new string[12]
{
"OnionSeeds", "Pickable_SeedCarrot", "Pickable_SeedTurnip", "Pickable_Barley", "Pickable_Flax", "Pickable_Mushroom", "Pickable_Thistle", "BlueberryBush", "RaspberryBush", "Pickable_Flint",
"Pickable_Obsidian", "Pickable_Meteorite"
};
string[] array2 = new string[12]
{
"DragonEgg", "AncientSeed", "WitheredBone", "GoblinTotem", "BellFragment", "DvergrKeyFragment", "Obsidian", "Coins", "Ruby", "Amber",
"AxeHead1", "AxeHead2"
};
GUIStyle val3 = new GUIStyle(_subStyle)
{
alignment = (TextAnchor)3
};
val3.normal.textColor = new Color(0.85f, 0.85f, 0.85f, 1f);
GUIStyle val4 = val3;
GUIStyle val5 = new GUIStyle(val4);
float num6 = 18f;
for (int i = 0; i < array.Length; i++)
{
float num7 = num2 + (float)i * num6;
if (GUI.Button(new Rect(num4, num7, num3 - 4f, num6 - 1f), array[i], val4))
{
_searchInput = array[i];
}
if (i < array2.Length && GUI.Button(new Rect(num5, num7, num3 - 4f, num6 - 1f), array2[i], val4))
{
_searchInput = array2[i];
}
}
float num8 = ((Rect)(ref area)).y + ((Rect)(ref area)).height - 18f;
string text = ((!string.IsNullOrEmpty(WorldMapPinner.LastSearchTerm)) ? ("Tracking: " + WorldMapPinner.LastSearchTerm) : "Tip: comma-separate terms e.g. AxeHead1, AxeHead2");
GUI.Label(new Rect(num4, num8, ((Rect)(ref area)).width - 24f, 16f), text, _subStyle);
}
private void DoSearch()
{
string text = _searchInput.Trim();
if (string.IsNullOrEmpty(text))
{
_searchStatus = "Enter a location name.";
_statusTimer = 4f;
return;
}
if (!WorldMapPinner.IsReady)
{
_searchStatus = "Still loading world data...";
_statusTimer = 4f;
return;
}
int num = WorldMapPinner.SearchAndPin(text);
if (num < 0)
{
_searchStatus = "Not ready yet.";
}
else if (num == 0)
{
_searchStatus = "Nothing found for '" + text + "'.";
}
else
{
_searchStatus = $"Pinned {num} result(s) for '{text}'.";
}
_statusTimer = 4f;
}
private static void ShadowLabel(Rect r, string text, GUIStyle style)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_000e: 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_004e: Unknown result type (might be due to invalid IL or missing references)
GUIStyle val = new GUIStyle(style);
val.normal.textColor = C_Shadow;
GUI.Label(new Rect(((Rect)(ref r)).x + 1f, ((Rect)(ref r)).y + 1f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, val);
GUI.Label(r, text, style);
}
private static void Fill(float x, float y, float w, float h, Color c)
{
//IL_0004: 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)
GUI.DrawTexture(new Rect(x, y, w, h), (Texture)(object)MakeTex(c));
}
private static void DrawBorder(float x, float y, float w, float h, Color c, float t)
{
//IL_0006: 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_0025: 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)
Fill(x, y, w, t, c);
Fill(x, y + h - t, w, t, c);
Fill(x, y, t, h, c);
Fill(x + w - t, y, t, h, c);
}
private static Texture2D MakeTex(Color c)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(1, 1);
val.SetPixel(0, 0, c);
val.Apply();
return val;
}
}
}
namespace LocationFinder.Core
{
public static class Assets
{
public static Texture2D PanelHeader;
public static Texture2D BtnNormal;
public static Texture2D BtnHover;
public static Texture2D Separator;
private static readonly Assembly _asm = Assembly.GetExecutingAssembly();
private const string NS = "LocationFinder";
public static bool Loaded { get; private set; }
public static void Load()
{
if (!Loaded)
{
PanelHeader = LoadTex("woodpanel_flik.png");
BtnNormal = LoadTex("button_tab.png");
BtnHover = LoadTex("button_tab_hover.png");
Separator = LoadTex("panel_separator.png");
Loaded = true;
LocationFinderPlugin.Log.LogInfo((object)"Assets loaded.");
}
}
private static Texture2D LoadTex(string filename)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
byte[] array = ReadResource(filename);
if (array == null)
{
return Fallback();
}
Texture2D val = new Texture2D(2, 2);
try
{
Type type = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule");
if (type != null)
{
MethodInfo method = type.GetMethod("LoadImage", new Type[2]
{
typeof(Texture2D),
typeof(byte[])
});
if (method != null)
{
method.Invoke(null, new object[2] { val, array });
return val;
}
}
MethodInfo method2 = typeof(Texture2D).GetMethod("LoadImage", new Type[1] { typeof(byte[]) });
if (method2 != null)
{
method2.Invoke(val, new object[1] { array });
return val;
}
}
catch
{
}
return Fallback();
}
private static byte[] ReadResource(string filename)
{
string name = "LocationFinder.Resources." + filename;
using Stream stream = _asm.GetManifestResourceStream(name);
if (stream == null)
{
return null;
}
MemoryStream memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
return memoryStream.ToArray();
}
private static Texture2D Fallback()
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(1, 1);
val.SetPixel(0, 0, new Color(0.1f, 0.08f, 0.04f));
val.Apply();
return val;
}
}
public class LocationCategory
{
public string Name;
public string[] Prefabs;
public bool Checked;
public LocationCategory(string name, bool defaultChecked, params string[] prefabs)
{
Name = name;
Prefabs = prefabs;
Checked = defaultChecked;
}
}
public static class LocationConfig
{
public static readonly List<LocationCategory> Categories = new List<LocationCategory>
{
new LocationCategory("Haldor", true, "Vendor_BlackForest"),
new LocationCategory("Hildir", true, "Hildir_camp"),
new LocationCategory("Bog Witch", true, "BogWitch_Camp"),
new LocationCategory("Eikthyr Altar", false, "Eikthyrnir"),
new LocationCategory("Elder Altar", false, "GDKing"),
new LocationCategory("Bonemass Altar", false, "Bonemass"),
new LocationCategory("Moder Altar", false, "Dragonqueen"),
new LocationCategory("Yagluth Altar", false, "GoblinKing"),
new LocationCategory("Queen Altar", false, "Mistlands_DvergrBossEntrance1"),
new LocationCategory("Fader Altar", false, "FaderLocation"),
new LocationCategory("Hildir Quest", false, "Hildir_plainsfortress", "Hildir_cave", "Hildir_crypt"),
new LocationCategory("Dyrnwyn Piece", false, "PlaceofMystery1", "PlaceofMystery2", "PlaceofMystery3"),
new LocationCategory("Burial Chamber", false, "Crypt2", "Crypt3", "Crypt4"),
new LocationCategory("Sunken Crypt", false, "SunkenCrypt4"),
new LocationCategory("Troll Cave", false, "TrollCave02"),
new LocationCategory("Frost Cave", false, "MountainCave02"),
new LocationCategory("Infested Mine", false, "Mistlands_DvergrTownEntrance1", "Mistlands_DvergrTownEntrance2"),
new LocationCategory("Morgen Cave", false, "MorgenHole1", "MorgenHole2", "MorgenHole3"),
new LocationCategory("Charred Fortress", false, "CharredFortress"),
new LocationCategory("Fuling Village", false, "GoblinCamp2"),
new LocationCategory("Draugr Village", false, "WoodVillage1"),
new LocationCategory("Dvergr Guard Tower", false, "Mistlands_GuardTower1_new", "Mistlands_GuardTower2_new", "Mistlands_GuardTower3_new"),
new LocationCategory("Dvergr Excavation", false, "Mistlands_Excavation1", "Mistlands_Excavation2", "Mistlands_Excavation3"),
new LocationCategory("Dvergr Harbour", false, "Mistlands_Harbour1"),
new LocationCategory("Abandoned Cabin", false, "AbandonedLogCabin02", "AbandonedLogCabin03", "AbandonedLogCabin04"),
new LocationCategory("Abandoned Outpost", false, "CharredTowerRuins1_dvergr"),
new LocationCategory("Wood House", false, "WoodHouse1", "WoodHouse2", "WoodHouse3", "WoodHouse4", "WoodHouse5", "WoodHouse6", "WoodHouse7", "WoodHouse8", "WoodHouse9", "WoodHouse10", "WoodHouse11", "WoodHouse12", "WoodHouse13"),
new LocationCategory("Dragon Egg Nest", false, "DrakeNest01"),
new LocationCategory("Giant Remain", false, "Mistlands_Giant1", "Mistlands_Giant2"),
new LocationCategory("Giant Scrap", false, "Mistlands_Swords1", "Mistlands_Swords2", "Mistlands_Swords3"),
new LocationCategory("Lava Leviathan", false, "LeviathanLava"),
new LocationCategory("Sulfur Arch", false, "SulfurArch"),
new LocationCategory("Fire Hole", false, "FireHole"),
new LocationCategory("Tar Pit", false, "TarPit1", "TarPit2", "TarPit3"),
new LocationCategory("Volture Nest", false, "VoltureNest"),
new LocationCategory("Greydwarf Nest", false, "Greydwarf_camp1"),
new LocationCategory("Waymarker", false, "Waymarker01", "Waymarker02"),
new LocationCategory("Stone Henge", false, "StoneHenge1", "StoneHenge2", "StoneHenge3", "StoneHenge4", "StoneHenge5", "StoneHenge6"),
new LocationCategory("Stone Circle", false, "StoneCircle"),
new LocationCategory("Fuling Tower", false, "StoneTower1", "StoneTower3"),
new LocationCategory("Stone Tower Ruin", false, "StoneTowerRuins03", "StoneTowerRuins04", "StoneTowerRuins05", "StoneTowerRuins07", "StoneTowerRuins08", "StoneTowerRuins09", "StoneTowerRuins10"),
new LocationCategory("Ruin", false, "Ruin1", "Ruin2", "Ruin3"),
new LocationCategory("Swamp Ruin", false, "SwampRuin1", "SwampRuin2"),
new LocationCategory("Swamp Hut", false, "SwampHut1", "SwampHut2", "SwampHut3", "SwampHut4", "SwampHut5"),
new LocationCategory("Dolmen", false, "Dolmen01", "Dolmen02", "Dolmen03"),
new LocationCategory("Shipwreck", false, "ShipWreck01", "ShipWreck02", "ShipWreck03", "ShipWreck04"),
new LocationCategory("Ashlands Ruin", false, "CharredRuins1", "CharredRuins2", "CharredRuins3", "CharredRuins4", "CharredTowerRuins1", "CharredTowerRuins2", "CharredTowerRuins3", "AshlandRuins", "FortressRuins"),
new LocationCategory("Mistlands Structure", false, "Mistlands_Viaduct1", "Mistlands_Viaduct2", "Mistlands_RockSpire1", "Mistlands_RoadPost1", "Mistlands_StatueGroup1", "Mistlands_Statue1", "Mistlands_Statue2", "Mistlands_Lighthouse1_new"),
new LocationCategory("Runestone", false, "Runestone_Boars", "Runestone_BlackForest", "Runestone_Draugr", "Runestone_Greydwarfs", "Runestone_Swamps", "Runestone_Mountains", "Runestone_Plains", "Runestone_Mistlands", "Runestone_Ashlands", "Runestone_Meadows", "DrakeLorestone"),
new LocationCategory("Big Rock Clearing", false, "BigRockClearing"),
new LocationCategory("Start Temple", false, "StartTemple")
};
public static readonly List<LocationCategory> UserCategories = new List<LocationCategory>();
private static string ConfigPath => Path.Combine(Paths.ConfigPath, "YouDied.LocationFinder.checklist.txt");
private static string UserConfigPath => Path.Combine(Paths.ConfigPath, "YouDied.LocationFinder.custom.txt");
public static void SaveChecked()
{
try
{
List<string> list = new List<string>();
foreach (LocationCategory category in Categories)
{
list.Add($"{category.Name}={category.Checked}");
}
foreach (LocationCategory userCategory in UserCategories)
{
list.Add(string.Format("[user]{0}={1}|{2}", userCategory.Name, userCategory.Checked, string.Join(",", userCategory.Prefabs)));
}
File.WriteAllLines(ConfigPath, list);
}
catch (Exception ex)
{
LocationFinderPlugin.Log.LogWarning((object)("[LocationFinder] Could not save checklist: " + ex.Message));
}
}
public static void LoadChecked()
{
if (!File.Exists(ConfigPath))
{
return;
}
try
{
string[] array = File.ReadAllLines(ConfigPath);
foreach (string text in array)
{
if (string.IsNullOrWhiteSpace(text))
{
continue;
}
if (text.StartsWith("[user]"))
{
string text2 = text.Substring("[user]".Length);
int num = text2.IndexOf('=');
if (num < 0)
{
continue;
}
string text3 = text2.Substring(0, num);
string text4 = text2.Substring(num + 1);
int num2 = text4.IndexOf('|');
if (num2 < 0)
{
continue;
}
bool.TryParse(text4.Substring(0, num2), out var result);
string[] prefabs = text4.Substring(num2 + 1).Split(new char[1] { ',' });
bool flag = false;
foreach (LocationCategory userCategory in UserCategories)
{
if (userCategory.Name == text3)
{
userCategory.Checked = result;
flag = true;
break;
}
}
if (!flag)
{
UserCategories.Add(new LocationCategory(text3, result, prefabs));
}
continue;
}
string[] array2 = text.Split(new char[1] { '=' });
if (array2.Length != 2)
{
continue;
}
bool.TryParse(array2[1].Trim(), out var result2);
foreach (LocationCategory category in Categories)
{
if (category.Name == array2[0].Trim())
{
category.Checked = result2;
break;
}
}
}
}
catch (Exception ex)
{
LocationFinderPlugin.Log.LogWarning((object)("[LocationFinder] Could not load checklist: " + ex.Message));
}
}
public static void LoadUserCategories()
{
if (!File.Exists(UserConfigPath))
{
File.WriteAllText(UserConfigPath, "# Location Finder - Custom Categories\n# Format: CategoryName=PrefabName1,PrefabName2\n# Example:\n# My Spots=SomeLocation1,SomeLocation2\n");
return;
}
string[] array = File.ReadAllLines(UserConfigPath);
foreach (string text in array)
{
if (string.IsNullOrWhiteSpace(text) || text.TrimStart(Array.Empty<char>()).StartsWith("#"))
{
continue;
}
string[] array2 = text.Split(new char[1] { '=' });
if (array2.Length != 2)
{
continue;
}
string name = array2[0].Trim();
string[] array3 = array2[1].Split(new char[1] { ',' });
List<string> list = new List<string>();
string[] array4 = array3;
foreach (string text2 in array4)
{
if (!string.IsNullOrWhiteSpace(text2))
{
list.Add(text2.Trim());
}
}
if (list.Count != 0)
{
UserCategories.Add(new LocationCategory(name, defaultChecked: false, list.ToArray()));
}
}
LocationFinderPlugin.Log.LogInfo((object)$"[LocationFinder] Loaded {UserCategories.Count} custom categories.");
}
}
public static class WorldMapPinner
{
[CompilerGenerated]
private sealed class <WaitForReady>d__13 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
private FieldInfo <locField>5__1;
private object <raw>5__2;
private IDictionary <dict>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForReady>d__13(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<locField>5__1 = null;
<raw>5__2 = null;
<dict>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
goto IL_0050;
case 1:
<>1__state = -1;
goto IL_0050;
case 2:
<>1__state = -1;
<raw>5__2 = null;
<dict>5__3 = null;
goto IL_012f;
case 3:
{
<>1__state = -1;
break;
}
IL_0050:
if (!_shutdown && (Object)(object)ZoneSystem.instance == (Object)null)
{
<>2__current = null;
<>1__state = 1;
return true;
}
if (_shutdown)
{
return false;
}
<locField>5__1 = FindLocationInstancesField();
if (<locField>5__1 != null)
{
goto IL_012f;
}
goto IL_0141;
IL_0141:
if (_shutdown)
{
return false;
}
break;
IL_012f:
if (!_shutdown)
{
if ((Object)(object)ZoneSystem.instance == (Object)null)
{
return false;
}
<raw>5__2 = <locField>5__1.GetValue(ZoneSystem.instance);
<dict>5__3 = <raw>5__2 as IDictionary;
if (<dict>5__3 == null || <dict>5__3.Count <= 0)
{
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 2;
return true;
}
_locationDict = <dict>5__3;
}
goto IL_0141;
}
if (!_shutdown && (Object)(object)Minimap.instance == (Object)null)
{
<>2__current = null;
<>1__state = 3;
return true;
}
if (_shutdown)
{
return false;
}
BuildLocationCache();
LocationConfig.LoadChecked();
_ready = true;
LocationFinderPlugin.Log.LogInfo((object)$"[LocationFinder] Ready. {_locationCache.Count} world locations cached.");
ApplyCheckedCategories();
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static readonly Dictionary<string, PinData> _pins = new Dictionary<string, PinData>();
private static readonly List<(string prefab, Vector3 pos)> _locationCache = new List<(string, Vector3)>();
private static bool _ready = false;
private static bool _shutdown = false;
private static IDictionary _locationDict = null;
private static FieldInfo _locField = null;
private static FieldInfo _posField = null;
private static FieldInfo _nameField = null;
private static string[] _activeTerms = new string[0];
private static readonly Dictionary<string, (Vector3 pos, List<string> items)> _chestRegistry = new Dictionary<string, (Vector3, List<string>)>();
public static bool IsReady => _ready;
public static int PinCount => _pins.Count;
public static string LastSearchTerm { get; private set; } = null;
public static int ChestRegistryCount => _chestRegistry.Count;
public static void BeginInit(MonoBehaviour host)
{
_shutdown = false;
host.StartCoroutine(WaitForReady());
}
[IteratorStateMachine(typeof(<WaitForReady>d__13))]
private static IEnumerator WaitForReady()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForReady>d__13(0);
}
private static void BuildLocationCache()
{
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
_locationCache.Clear();
if (_locationDict == null)
{
return;
}
foreach (object value in _locationDict.Values)
{
if (value == null)
{
continue;
}
if (_locField == null)
{
Type type = value.GetType();
_locField = type.GetField("m_location");
_posField = type.GetField("m_position");
}
object obj = _locField?.GetValue(value);
if (obj != null)
{
if (_nameField == null)
{
_nameField = obj.GetType().GetField("m_prefabName");
}
string text = _nameField?.GetValue(obj) as string;
if (!string.IsNullOrEmpty(text))
{
Vector3 item = (Vector3)_posField.GetValue(value);
_locationCache.Add((text, item));
}
}
}
LocationFinderPlugin.Log.LogInfo((object)$"[LocationFinder] Cache built: {_locationCache.Count} entries.");
}
public static void ApplyCheckedCategories()
{
//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
//IL_03da: Unknown result type (might be due to invalid IL or missing references)
if (!_ready || (Object)(object)Minimap.instance == (Object)null)
{
return;
}
HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
foreach (LocationCategory category in LocationConfig.Categories)
{
if (!category.Checked)
{
continue;
}
string[] prefabs = category.Prefabs;
foreach (string text in prefabs)
{
hashSet.Add(text);
if (!dictionary.ContainsKey(text))
{
dictionary[text] = category.Name;
}
}
}
foreach (LocationCategory userCategory in LocationConfig.UserCategories)
{
if (!userCategory.Checked)
{
continue;
}
string[] prefabs2 = userCategory.Prefabs;
foreach (string text2 in prefabs2)
{
hashSet.Add(text2);
if (!dictionary.ContainsKey(text2))
{
dictionary[text2] = userCategory.Name;
}
}
}
List<string> list = new List<string>();
foreach (KeyValuePair<string, PinData> pin in _pins)
{
if (!pin.Key.StartsWith("loc_"))
{
continue;
}
bool flag = false;
foreach (string item in hashSet)
{
if (pin.Key.StartsWith("loc_" + item + "_", StringComparison.OrdinalIgnoreCase))
{
flag = true;
break;
}
}
if (!flag)
{
list.Add(pin.Key);
}
}
foreach (string item2 in list)
{
if (_pins.TryGetValue(item2, out var value))
{
Minimap.instance.RemovePin(value);
}
_pins.Remove(item2);
}
LocationFinderPlugin.Log.LogInfo((object)$"[LocationFinder] Applying {hashSet.Count} prefab type(s)...");
foreach (var (text3, val) in _locationCache)
{
if (!hashSet.Contains(text3))
{
continue;
}
string key = $"loc_{text3}_{Mathf.RoundToInt(val.x)}_{Mathf.RoundToInt(val.z)}";
if (_pins.ContainsKey(key))
{
continue;
}
string value2;
string text4 = (dictionary.TryGetValue(text3, out value2) ? value2 : text3);
if (char.IsDigit(text3[text3.Length - 1]))
{
int num = text3.Length - 1;
while (num > 0 && char.IsDigit(text3[num - 1]))
{
num--;
}
string text5 = text3.Substring(num);
if (!text4.EndsWith(text5))
{
text4 = text4 + " " + text5;
}
}
PinData value3 = Minimap.instance.AddPin(val, (PinType)3, text4, false, false, 0L, default(PlatformUserID));
_pins[key] = value3;
}
LocationFinderPlugin.Log.LogInfo((object)$"[LocationFinder] Applied. {_pins.Count} location pin(s) on map.");
LocationConfig.SaveChecked();
}
public static void ClearLastPin()
{
if ((Object)(object)Minimap.instance == (Object)null || _pins.Count == 0)
{
return;
}
string text = null;
foreach (string key in _pins.Keys)
{
text = key;
}
if (text != null)
{
Minimap.instance.RemovePin(_pins[text]);
_pins.Remove(text);
LocationFinderPlugin.Log.LogInfo((object)"[LocationFinder] Last pin cleared.");
}
}
public static void ClearAllPins()
{
if ((Object)(object)Minimap.instance != (Object)null)
{
foreach (PinData value in _pins.Values)
{
if (value != null)
{
Minimap.instance.RemovePin(value);
}
}
}
_pins.Clear();
LocationFinderPlugin.Log.LogInfo((object)"[LocationFinder] All pins cleared.");
}
public static void Shutdown()
{
_shutdown = true;
_ready = false;
_locationDict = null;
_locationCache.Clear();
_chestRegistry.Clear();
LastSearchTerm = null;
_activeTerms = new string[0];
_locField = (_posField = (_nameField = null));
_pins.Clear();
LocationFinderPlugin.Log.LogInfo((object)"[LocationFinder] Shutdown.");
}
public static int SearchAndPin(string input)
{
if (!_ready || (Object)(object)Minimap.instance == (Object)null)
{
return -1;
}
if (string.IsNullOrWhiteSpace(input))
{
return 0;
}
string[] array = input.Split(new char[1] { ',' });
List<string> list = new List<string>();
string[] array2 = array;
foreach (string text in array2)
{
string text2 = text.Trim();
if (!string.IsNullOrEmpty(text2))
{
list.Add(text2);
}
}
if (list.Count == 0)
{
return 0;
}
LastSearchTerm = string.Join(", ", list);
_activeTerms = list.ToArray();
int num = ScanLoadedPickables();
int num2 = num;
foreach (string item in list)
{
int num3 = SearchLocations(item);
int num4 = SearchChests(item);
num2 += num3 + num4;
LocationFinderPlugin.Log.LogInfo((object)$"[LocationFinder] Search '{item}': {num3} location(s), {num4} chest(s), {num} pickable(s).");
}
return num2;
}
private static int SearchLocations(string searchTerm)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: 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_00a0: 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_00af: Unknown result type (might be due to invalid IL or missing references)
int num = 0;
foreach (var (text, val) in _locationCache)
{
if (text.IndexOf(searchTerm, StringComparison.OrdinalIgnoreCase) >= 0)
{
string key = $"search_{text}_{Mathf.RoundToInt(val.x)}_{Mathf.RoundToInt(val.z)}";
if (!_pins.ContainsKey(key))
{
LocationFinderPlugin.Log.LogInfo((object)("[LocationFinder] Location hit: '" + text + "'"));
PinData value = Minimap.instance.AddPin(val, (PinType)3, text, false, false, 0L, default(PlatformUserID));
_pins[key] = value;
num++;
}
}
}
return num;
}
public static void RegisterContainer(Container container)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)container == (Object)null)
{
return;
}
Inventory inventory;
try
{
inventory = container.GetInventory();
}
catch
{
return;
}
if (inventory == null)
{
return;
}
Vector3 position = ((Component)container).transform.position;
string key = $"{Mathf.RoundToInt(position.x)}_{Mathf.RoundToInt(position.z)}";
List<string> list = new List<string>();
foreach (ItemData allItem in inventory.GetAllItems())
{
if ((Object)(object)allItem?.m_dropPrefab != (Object)null)
{
list.Add(((Object)allItem.m_dropPrefab).name);
}
}
if (list.Count == 0)
{
return;
}
_chestRegistry[key] = (position, list);
if (_activeTerms.Length == 0 || !((Object)(object)Minimap.instance != (Object)null))
{
return;
}
string[] activeTerms = _activeTerms;
foreach (string text in activeTerms)
{
foreach (string item in list)
{
if (!string.Equals(item, text, StringComparison.OrdinalIgnoreCase))
{
continue;
}
string key2 = $"chest_{text}_{Mathf.RoundToInt(position.x)}_{Mathf.RoundToInt(position.z)}";
if (!_pins.ContainsKey(key2))
{
LocationFinderPlugin.Log.LogInfo((object)$"[LocationFinder] Auto-pin: '{text}' in new chest at {position}");
PinData value = Minimap.instance.AddPin(position, (PinType)3, text, false, false, 0L, default(PlatformUserID));
_pins[key2] = value;
}
break;
}
}
}
private static int ScanLoadedPickables()
{
if (_activeTerms.Length == 0 || (Object)(object)Minimap.instance == (Object)null)
{
return 0;
}
Pickable[] array = Object.FindObjectsOfType<Pickable>();
int num = 0;
Pickable[] array2 = array;
foreach (Pickable val in array2)
{
if ((Object)(object)val != (Object)null && RegisterPickable(val))
{
num++;
}
}
return num;
}
public static void UnregisterPickable(Pickable pickable)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: 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_0065: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)pickable == (Object)null) && !((Object)(object)Minimap.instance == (Object)null))
{
string arg = ((Object)((Component)pickable).gameObject).name.Replace("(Clone)", "").Trim();
Vector3 position = ((Component)pickable).transform.position;
string key = $"pickable_{arg}_{Mathf.RoundToInt(position.x)}_{Mathf.RoundToInt(position.z)}";
if (_pins.TryGetValue(key, out var value))
{
Minimap.instance.RemovePin(value);
_pins.Remove(key);
}
}
}
public static bool RegisterPickable(Pickable pickable)
{
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)pickable == (Object)null || _activeTerms.Length == 0 || (Object)(object)Minimap.instance == (Object)null)
{
return false;
}
try
{
FieldInfo field = typeof(Pickable).GetField("m_picked", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null && (bool)field.GetValue(pickable))
{
return false;
}
}
catch
{
}
string a = ((Object)((Component)pickable).gameObject).name.Replace("(Clone)", "").Trim();
string[] activeTerms = _activeTerms;
foreach (string text in activeTerms)
{
if (string.Equals(a, text, StringComparison.OrdinalIgnoreCase))
{
Vector3 position = ((Component)pickable).transform.position;
string key = $"pickable_{text}_{Mathf.RoundToInt(position.x)}_{Mathf.RoundToInt(position.z)}";
if (_pins.ContainsKey(key))
{
return false;
}
PinData value = Minimap.instance.AddPin(position, (PinType)3, text, false, false, 0L, default(PlatformUserID));
_pins[key] = value;
LocationFinderPlugin.Log.LogInfo((object)$"[LocationFinder] Pickable pinned: '{text}' at {position}");
return true;
}
}
return false;
}
public static void RegisterLeviathan(Vector3 pos)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: 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)
if (!((Object)(object)Minimap.instance == (Object)null))
{
string key = $"leviathan_{Mathf.RoundToInt(pos.x)}_{Mathf.RoundToInt(pos.z)}";
if (!_pins.ContainsKey(key))
{
PinData value = Minimap.instance.AddPin(pos, (PinType)3, "Leviathan", false, false, 0L, default(PlatformUserID));
_pins[key] = value;
LocationFinderPlugin.Log.LogInfo((object)$"[LocationFinder] Leviathan pinned at {pos}");
}
}
}
public static void RegisterBeehive(Vector3 pos)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: 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)
if (!((Object)(object)Minimap.instance == (Object)null))
{
string key = $"beehive_{Mathf.RoundToInt(pos.x)}_{Mathf.RoundToInt(pos.z)}";
if (!_pins.ContainsKey(key))
{
PinData value = Minimap.instance.AddPin(pos, (PinType)3, "Beehive", false, false, 0L, default(PlatformUserID));
_pins[key] = value;
LocationFinderPlugin.Log.LogInfo((object)$"[LocationFinder] Beehive pinned at {pos}");
}
}
}
private static int SearchChests(string itemPrefab)
{
//IL_003c: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Minimap.instance == (Object)null)
{
return 0;
}
int num = 0;
foreach (KeyValuePair<string, (Vector3, List<string>)> item3 in _chestRegistry)
{
(Vector3, List<string>) value = item3.Value;
Vector3 item = value.Item1;
List<string> item2 = value.Item2;
bool flag = false;
foreach (string item4 in item2)
{
if (string.Equals(item4, itemPrefab, StringComparison.OrdinalIgnoreCase))
{
flag = true;
break;
}
}
if (flag)
{
string key = $"chest_{itemPrefab}_{Mathf.RoundToInt(item.x)}_{Mathf.RoundToInt(item.z)}";
if (!_pins.ContainsKey(key))
{
LocationFinderPlugin.Log.LogInfo((object)$"[LocationFinder] Chest hit: '{itemPrefab}' at {item}");
PinData value2 = Minimap.instance.AddPin(item, (PinType)3, itemPrefab, false, false, 0L, default(PlatformUserID));
_pins[key] = value2;
num++;
}
}
}
return num;
}
private static FieldInfo FindLocationInstancesField()
{
FieldInfo field = typeof(ZoneSystem).GetField("m_locationInstances", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
return field;
}
FieldInfo[] fields = typeof(ZoneSystem).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (FieldInfo fieldInfo in fields)
{
Type fieldType = fieldInfo.FieldType;
if (fieldType.IsGenericType)
{
Type[] genericArguments = fieldType.GetGenericArguments();
if (genericArguments.Length == 2 && genericArguments[1].Name.Contains("LocationInstance"))
{
return fieldInfo;
}
}
}
return null;
}
}
}