using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ChestFinder")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Floating icons for nearby tome chests (same range as your compass, grows with compass upgrades) and for the cave entrance.")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1+46818220f47215c37c94eb58d02b271ced4c7d5b")]
[assembly: AssemblyProduct("ChestFinder")]
[assembly: AssemblyTitle("ChestFinder")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ChestFinder
{
internal class ChestFinderOverlay : MonoBehaviour
{
private struct ChestTarget
{
public Vector3 Position;
public float Distance;
public Rarity? Rarity;
public ChestKind Kind;
}
private const float CompassBaseDistance = 10f;
private static readonly Vector3 CaveEntrancePosition = new Vector3(66.76f, 8.5f, 149.64f);
private const float InsideCaveMaxX = 70f;
private const float RefreshInterval = 0.25f;
private const float ChestIconHeight = 0.9f;
private readonly List<ChestTarget> _chests = new List<ChestTarget>();
private float _refreshTimer;
private bool _visible = true;
private FirstPersonController _player;
private float _currentRange;
private float _entranceDistance;
private bool _active;
private Sprite _entranceSprite;
private bool _spritesResolved;
private GUIStyle _labelStyle;
private GUIStyle _shadowStyle;
private GUIStyle _noticeStyle;
private float _toggleNoticeUntil;
private string _lastScene;
private readonly HashSet<ChestKind> _loggedKinds = new HashSet<ChestKind>();
private string _lastDiag;
private float _nextDiagTime;
private void Update()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(Plugin.ToggleKey.Value))
{
_visible = !_visible;
_toggleNoticeUntil = Time.unscaledTime + 2.5f;
Plugin.Log.LogInfo((object)("ChestFinder: " + (_visible ? "ligado" : "desligado")));
}
Scene activeScene = SceneManager.GetActiveScene();
string name = ((Scene)(ref activeScene)).name;
if (name != _lastScene)
{
_lastScene = name;
if (!_visible)
{
Plugin.Log.LogInfo((object)"ChestFinder: novo mapa, ícones religados.");
}
_visible = true;
}
_refreshTimer -= Time.unscaledDeltaTime;
if (_refreshTimer > 0f)
{
return;
}
_refreshTimer = 0.25f;
try
{
Refresh();
}
catch (Exception ex)
{
_active = false;
Plugin.Log.LogError((object)("ChestFinder: " + ex));
}
}
private void Refresh()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Invalid comparison between Unknown and I4
//IL_0073: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: 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)
_active = false;
_chests.Clear();
GameManager instance = GameManager.Instance;
if ((Object)(object)instance == (Object)null || !instance.IsInitialized || (int)instance.SceneType != 1)
{
_spritesResolved = false;
return;
}
_player = instance.LocalPlayer;
if ((Object)(object)_player == (Object)null || (Object)(object)_player.PlayerStats == (Object)null)
{
return;
}
Vector3 position = ((Component)_player).transform.position;
if (position.x > 70f)
{
return;
}
if (!_spritesResolved)
{
ResolveSprites();
}
_currentRange = 10f * _player.PlayerStats.CompassRange.Value * Plugin.RangeMultiplier.Value;
_entranceDistance = Vector3.Distance(position, CaveEntrancePosition);
_active = true;
if (!Plugin.ShowChests.Value)
{
return;
}
int num = 0;
int num2 = 0;
float num3 = float.MaxValue;
TreasureChest[] array = Object.FindObjectsByType<TreasureChest>((FindObjectsSortMode)0);
foreach (TreasureChest val in array)
{
num++;
if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled && !val.isOpened)
{
num2++;
Vector3 position2 = ((Component)val).transform.position;
float num4 = Vector3.Distance(position, position2);
num3 = Mathf.Min(num3, num4);
if (!(num4 >= _currentRange))
{
_chests.Add(new ChestTarget
{
Position = position2 + Vector3.up * 0.9f,
Distance = num4,
Rarity = GetRarity(val),
Kind = ChestIcons.KindOf(val)
});
}
}
}
_chests.Sort((ChestTarget a, ChestTarget b) => a.Distance.CompareTo(b.Distance));
if (_chests.Count > 0 && _loggedKinds.Add(_chests[0].Kind))
{
Plugin.Log.LogInfo((object)$"ChestFinder: tipo de bau detectado = {_chests[0].Kind}");
}
LogDiagnostics(num, num2, num3, position);
}
private void LogDiagnostics(int total, int closed, float nearestAny, Vector3 playerPos)
{
//IL_0021: 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_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_0152: 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)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
if (!(Time.unscaledTime < _nextDiagTime))
{
Camera camera = GetCamera();
object[] array = new object[5];
Scene activeScene = SceneManager.GetActiveScene();
array[0] = ((Scene)(ref activeScene)).name;
array[1] = total;
array[2] = closed;
array[3] = _chests.Count;
array[4] = (((Object)(object)camera != (Object)null) ? ((Object)camera).name : "null");
string text = string.Format("{0}|{1}|{2}|{3}|{4}", array);
if (!(text == _lastDiag))
{
_lastDiag = text;
_nextDiagTime = Time.unscaledTime + 5f;
ManualLogSource log = Plugin.Log;
string[] obj = new string[8] { "ChestFinder diag: mapa=", null, null, null, null, null, null, null };
activeScene = SceneManager.GetActiveScene();
obj[1] = ((Scene)(ref activeScene)).name;
obj[2] = " ";
obj[3] = $"baus_no_mapa={total} fechados={closed} no_alcance={_chests.Count} alcance={_currentRange:0.0}m ";
obj[4] = "mais_proximo=";
obj[5] = ((nearestAny < float.MaxValue) ? (nearestAny.ToString("0.0") + "m") : "-");
obj[6] = " ";
obj[7] = string.Format("jogador=({0:0.0},{1:0.0},{2:0.0}) camera={3}", playerPos.x, playerPos.y, playerPos.z, ((Object)(object)camera != (Object)null) ? ((Object)camera).name : "NENHUMA");
log.LogInfo((object)string.Concat(obj));
}
}
}
private static Camera GetCamera()
{
if ((Object)(object)CameraManager.Instance != (Object)null && (Object)(object)CameraManager.Instance.MainCamera != (Object)null && ((Behaviour)CameraManager.Instance.MainCamera).isActiveAndEnabled)
{
return CameraManager.Instance.MainCamera;
}
return Camera.main;
}
private static Rarity? GetRarity(TreasureChest chest)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
ChestDataSO val = chest.ChestDataSO;
if ((Object)(object)val == (Object)null && (Object)(object)ItemManager.Instance != (Object)null && !string.IsNullOrEmpty(((CarriableObject)chest).SyncCarriableID))
{
CarriableDataSO carriableDataSoByID = ItemManager.Instance.GetCarriableDataSoByID(((CarriableObject)chest).SyncCarriableID);
val = (ChestDataSO)(object)((carriableDataSoByID is ChestDataSO) ? carriableDataSoByID : null);
}
if (!((Object)(object)val != (Object)null))
{
return null;
}
return val.Rarity;
}
private void ResolveSprites()
{
_spritesResolved = true;
HudCompass val = (((Object)(object)Hud.Instance != (Object)null) ? Hud.Instance.HudCompass : null);
if (val != null && (Object)(object)val.compassSO != (Object)null)
{
_entranceSprite = val.compassSO.CaveEntrySprite;
}
if ((Object)(object)_entranceSprite == (Object)null)
{
Plugin.Log.LogWarning((object)"ChestFinder: icone da entrada da caverna nao encontrado, usando icone simples.");
}
}
private void OnGUI()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Invalid comparison between Unknown and I4
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: 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_01dc: 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_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: 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_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
if ((int)Event.current.type == 7 && Time.unscaledTime < _toggleNoticeUntil)
{
DrawToggleNotice();
}
if (!_visible || !_active || (Object)(object)_player == (Object)null || (int)Event.current.type != 7 || (Plugin.HideWhenCursorVisible.Value && Cursor.visible))
{
return;
}
Camera camera = GetCamera();
if ((Object)(object)camera == (Object)null)
{
return;
}
EnsureStyles();
float value = Plugin.IconSize.Value;
for (int num = _chests.Count - 1; num >= 0; num--)
{
ChestTarget chestTarget = _chests[num];
bool flag = num == 0;
if (TryWorldToGui(camera, chestTarget.Position, clampToScreen: false, value, out var guiPos))
{
float iconSize = (flag ? (value * 1.5f) : value) * 1.375f;
float alpha = (flag ? 1f : 0.8f);
Rarity? rarity = (Plugin.ShowRarity.Value ? chestTarget.Rarity : ((Rarity?)null));
Texture2D texture = ChestIcons.Get(rarity, Plugin.ShowContentBadge.Value ? chestTarget.Kind : ChestKind.Unknown);
DrawMarker(guiPos, iconSize, (Texture)(object)texture, new Rect(0f, 0f, 1f, 1f), $"{chestTarget.Distance:0}m", ChestIcons.MetalColor(rarity), alpha);
}
}
if (Plugin.ShowCaveEntrance.Value && TryWorldToGui(camera, CaveEntrancePosition, clampToScreen: true, value, out var guiPos2))
{
Texture2D texture2 = (((Object)(object)_entranceSprite != (Object)null) ? _entranceSprite.texture : Texture2D.whiteTexture);
Rect uv = (Rect)(((Object)(object)_entranceSprite != (Object)null) ? SpriteUV(_entranceSprite) : new Rect(0f, 0f, 1f, 1f));
DrawMarker(guiPos2, value, (Texture)(object)texture2, uv, $"{Plugin.EntranceLabel.Value} {_entranceDistance:0}m", new Color(0.7f, 0.9f, 1f), 0.95f);
}
GUI.color = Color.white;
}
private void DrawToggleNotice()
{
//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_001f: 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_0033: Expected O, but got Unknown
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: 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)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
if (_noticeStyle == null)
{
_noticeStyle = new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)4,
fontSize = 20,
fontStyle = (FontStyle)1
};
_noticeStyle.normal.textColor = Color.white;
}
string text = (_visible ? $"ChestFinder: ícones LIGADOS ({Plugin.ToggleKey.Value})" : $"ChestFinder: ícones DESLIGADOS ({Plugin.ToggleKey.Value} para ligar)");
Rect val = default(Rect);
((Rect)(ref val))..ctor(0f, (float)Screen.height * 0.12f, (float)Screen.width, 32f);
GUI.color = new Color(0f, 0f, 0f, 0.85f);
GUI.Label(new Rect(((Rect)(ref val)).x + 2f, ((Rect)(ref val)).y + 2f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), text, _noticeStyle);
GUI.color = (_visible ? new Color(0.55f, 1f, 0.55f) : new Color(1f, 0.6f, 0.4f));
GUI.Label(val, text, _noticeStyle);
GUI.color = Color.white;
}
private static Rect SpriteUV(Sprite sprite)
{
//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_004a: Unknown result type (might be due to invalid IL or missing references)
Rect textureRect = sprite.textureRect;
Texture2D texture = sprite.texture;
return new Rect(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height);
}
private static bool TryWorldToGui(Camera cam, Vector3 world, bool clampToScreen, float margin, out Vector2 guiPos)
{
//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_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)
//IL_0051: 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_0042: 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_005e: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: 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_0093: 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_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = cam.WorldToScreenPoint(world);
bool flag = val.z < 0f;
if (flag)
{
if (!clampToScreen)
{
guiPos = default(Vector2);
return false;
}
val.x = (float)Screen.width - val.x;
val.y = (float)Screen.height - val.y;
}
bool flag2 = flag || val.x < 0f || val.x > (float)Screen.width || val.y < 0f || val.y > (float)Screen.height;
if (flag2 && !clampToScreen)
{
guiPos = default(Vector2);
return false;
}
if (flag2)
{
if (flag)
{
val.y = 0f;
}
val.x = Mathf.Clamp(val.x, margin, (float)Screen.width - margin);
val.y = Mathf.Clamp(val.y, margin, (float)Screen.height - margin);
}
guiPos = new Vector2(val.x, (float)Screen.height - val.y);
return true;
}
private void DrawMarker(Vector2 center, float iconSize, Texture texture, Rect uv, string text, Color textColor, float alpha)
{
//IL_0002: 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_0046: 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_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: 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_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
Rect val = default(Rect);
((Rect)(ref val))..ctor(Mathf.Round(center.x - iconSize / 2f), Mathf.Round(center.y - iconSize / 2f), iconSize, iconSize);
GUI.color = new Color(0f, 0f, 0f, alpha * 0.45f);
GUI.DrawTextureWithTexCoords(new Rect(((Rect)(ref val)).x + 2f, ((Rect)(ref val)).y + 2f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), texture, uv, true);
GUI.color = new Color(1f, 1f, 1f, alpha);
GUI.DrawTextureWithTexCoords(val, texture, uv, true);
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(center.x - 80f, ((Rect)(ref val)).yMax, 160f, 22f);
GUI.color = new Color(0f, 0f, 0f, alpha * 0.85f);
GUI.Label(new Rect(((Rect)(ref val2)).x + 1f, ((Rect)(ref val2)).y + 1f, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height), text, _shadowStyle);
GUI.color = new Color(textColor.r, textColor.g, textColor.b, alpha);
GUI.Label(val2, text, _labelStyle);
}
private void EnsureStyles()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
//IL_003f: 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_005a: Expected O, but got Unknown
if (_labelStyle == null)
{
_labelStyle = new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)1,
fontStyle = (FontStyle)1,
fontSize = 15
};
_labelStyle.normal.textColor = Color.white;
_shadowStyle = new GUIStyle(_labelStyle);
}
}
}
internal enum ChestKind
{
Unknown,
Items,
Tomes
}
internal static class ChestIcons
{
private const int CanvasSize = 22;
private static readonly string[] ChestPixels = new string[16]
{
"................", "...OOOOOOOOOO...", "..OHHMHHHHMHHO..", ".OHWWMWWWWMWWHO.", ".OWWWMWWWWMWWWO.", ".OwwwmwwwwmwwwO.", "OMMMMMLLLLMMMMMO", "OmmmmmLKKLmmmmmO", "OWWWWMLLLLMWWWWO", "OHWWWMWWWWMWWWHO",
"OWWWWMWWWWMWWWWO", "OwWWWMWWWWMWWWwO", "OwwwwmwwwwmwwwwO", "OMMMMMMMMMMMMMMO", "OOOOOOOOOOOOOOOO", "................"
};
private static readonly string[] SwordPixels = new string[10] { "......OOO.", ".....OSSO.", "....OSSO..", "...OSSO...", "O.OSSO....", "OOSSO.....", ".OGGO.....", "OHOOGO....", "OHO.OO....", ".O........" };
private static readonly string[] BookPixels = new string[10] { ".OOOOOOOO.", "OBBBBBBPPO", "OBBYYBBPPO", "OBYBBYBPPO", "OBBYYBBPPO", "OBBBBBBPPO", "OBBBBBBPPO", "ObbbbbbPPO", "OOOOOOOOOO", ".........." };
private static readonly Color Outline = Hex(36, 22, 14);
private static readonly Dictionary<int, Texture2D> Cache = new Dictionary<int, Texture2D>();
public static Texture2D Get(Rarity? rarity, ChestKind kind)
{
//IL_000f: 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)
int key = (int)(((!rarity.HasValue) ? 9 : ((int)rarity.Value)) * 10 + kind);
if (Cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
{
return value;
}
Texture2D val = Build(MetalColor(rarity), kind);
Cache[key] = val;
return val;
}
public static ChestKind KindOf(TreasureChest chest)
{
string name = ((Object)((Component)chest).gameObject).name;
string text = ((CarriableObject)chest).SyncCarriableID ?? "";
if (name.IndexOf("Upgrade", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("UPGRADE", StringComparison.OrdinalIgnoreCase) >= 0)
{
return ChestKind.Tomes;
}
if (name.IndexOf("Treasure_Chest", StringComparison.OrdinalIgnoreCase) >= 0)
{
return ChestKind.Items;
}
return ChestKind.Unknown;
}
public static Color MetalColor(Rarity? rarity)
{
//IL_00a0: 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_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected I4, but got Unknown
//IL_00a6: 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_0044: 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_0055: 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_0069: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: 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)
return (Color)(rarity switch
{
(Rarity)0L => Hex(184, 188, 196),
(Rarity)1L => Hex(92, 214, 92),
(Rarity)2L => Hex(76, 154, byte.MaxValue),
(Rarity)3L => Hex(184, 102, byte.MaxValue),
(Rarity)4L => Hex(byte.MaxValue, 184, 38),
_ => Hex(242, 192, 64),
});
}
private static Texture2D Build(Color metal, ChestKind kind)
{
//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)
//IL_0046: 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_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_0069: 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_007d: Expected O, but got Unknown
Color metalDark = new Color(metal.r * 0.6f, metal.g * 0.6f, metal.b * 0.6f, 1f);
Texture2D val = new Texture2D(22, 22, (TextureFormat)4, false)
{
filterMode = (FilterMode)0,
wrapMode = (TextureWrapMode)1,
hideFlags = (HideFlags)61,
name = "ChestFinder_ChestIcon"
};
Color[] pixels = (Color[])(object)new Color[484];
val.SetPixels(pixels);
Draw(val, ChestPixels, 0, 2, (char c) => c switch
{
'O' => Outline,
'H' => Hex(192, 132, 72),
'W' => Hex(150, 94, 46),
'w' => Hex(106, 64, 30),
'M' => metal,
'm' => metalDark,
'L' => Hex(byte.MaxValue, 240, 176),
'K' => Hex(32, 20, 8),
_ => null,
});
switch (kind)
{
case ChestKind.Items:
Draw(val, SwordPixels, 12, 12, (char c) => c switch
{
'O' => Outline,
'S' => Hex(232, 236, 242),
'G' => Hex(byte.MaxValue, 200, 58),
'H' => Hex(192, 132, 72),
_ => null,
});
break;
case ChestKind.Tomes:
Draw(val, BookPixels, 12, 12, (char c) => c switch
{
'O' => Outline,
'B' => Hex(138, 60, 200),
'b' => Hex(94, 38, 138),
'Y' => Hex(byte.MaxValue, 216, 80),
'P' => Hex(244, 236, 216),
_ => null,
});
break;
}
val.Apply(false, false);
return val;
}
private static void Draw(Texture2D tex, string[] rows, int x, int y, Func<char, Color?> palette)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < rows.Length; i++)
{
string text = rows[i];
for (int j = 0; j < text.Length; j++)
{
Color? val = palette(text[j]);
if (val.HasValue)
{
int num = x + j;
int num2 = 21 - (y + i);
if (num >= 0 && num < 22 && num2 >= 0 && num2 < 22)
{
tex.SetPixel(num, num2, val.Value);
}
}
}
}
}
private static Color Hex(byte r, byte g, byte b)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
return new Color((float)(int)r / 255f, (float)(int)g / 255f, (float)(int)b / 255f, 1f);
}
}
[BepInPlugin("catedralemchamas.stonewards.chestfinder", "ChestFinder", "1.2.1")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
internal static ConfigEntry<KeyCode> ToggleKey;
internal static ConfigEntry<bool> ShowChests;
internal static ConfigEntry<bool> ShowCaveEntrance;
internal static ConfigEntry<float> RangeMultiplier;
internal static ConfigEntry<float> IconSize;
internal static ConfigEntry<bool> ShowRarity;
internal static ConfigEntry<bool> HideWhenCursorVisible;
internal static ConfigEntry<string> EntranceLabel;
internal static ConfigEntry<bool> ShowContentBadge;
private void Awake()
{
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected O, but got Unknown
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)287, "Tecla para mostrar/esconder os ícones.");
ShowChests = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowChests", true, "Mostra ícones nos baús de tomos dentro do alcance da bússola.");
ShowCaveEntrance = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowCaveEntrance", true, "Mostra um ícone flutuante na entrada da caverna.");
RangeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Range", "RangeMultiplier", 1f, new ConfigDescription("Multiplica o alcance da bússola (1 = igual à bússola do jogo, que já cresce com os tomos de bússola).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 5f), Array.Empty<object>()));
IconSize = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "IconSize", 32f, new ConfigDescription("Tamanho dos ícones em pixels (múltiplos de 16 ficam mais nítidos). O baú mais próximo fica 1.5x maior.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(16f, 96f), Array.Empty<object>()));
ShowRarity = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "ShowRarity", true, "Colore as ferragens e o texto do baú de acordo com a raridade (quando disponível).");
HideWhenCursorVisible = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "HideWhenCursorVisible", true, "Esconde os ícones quando um menu está aberto (cursor visível).");
EntranceLabel = ((BaseUnityPlugin)this).Config.Bind<string>("Display", "EntranceLabel", "Entrance", "Texto mostrado antes da distância no ícone da entrada da caverna (ex.: Entrada).");
ShowContentBadge = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "ShowContentBadge", true, "Mostra um selo no canto do ícone: espada = baú de itens/armas, livro = baú de tomos.");
((Component)this).gameObject.AddComponent<ChestFinderOverlay>();
Log.LogInfo((object)string.Format("{0} v{1} carregado. {2} liga/desliga.", "ChestFinder", "1.2.1", ToggleKey.Value));
}
}
internal static class MyPluginInfo
{
public const string PLUGIN_GUID = "catedralemchamas.stonewards.chestfinder";
public const string PLUGIN_NAME = "ChestFinder";
public const string PLUGIN_VERSION = "1.2.1";
public const string PLUGIN_AUTHOR = "CatedralEmChamas";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}