Decompiled source of Valheim Death Ledger v1.1.1

ValheimDeathLedger.dll

Decompiled 12 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[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 ValheimDeathLedger
{
	internal sealed class DeathHud : MonoBehaviour
	{
		private static bool _visible = true;

		private GUIStyle _titleStyle;

		private GUIStyle _rowStyle;

		private GUIStyle _highlightStyle;

		private GUIStyle _countStyle;

		private GUIStyle _highlightCountStyle;

		private void Update()
		{
			//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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			DeathLedger.Tick();
			if (!((Object)(object)ZNet.instance == (Object)null))
			{
				KeyboardShortcut value = Plugin.ToggleHudHotkey.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					_visible = !_visible;
				}
				value = Plugin.ResetHotkey.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					DeathLedger.RequestReset();
				}
			}
		}

		private void OnGUI()
		{
			//IL_0224: 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_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			if (!_visible || !Plugin.ShowHud.Value || (Object)(object)ZNet.instance == (Object)null)
			{
				return;
			}
			EnsureStyles();
			float num = Mathf.Clamp(Plugin.HudScale.Value, 0.6f, 1.5f);
			float num2 = (float)Mathf.Clamp(Plugin.HudFontSize.Value, 10, 24) * num;
			_titleStyle.fontSize = Mathf.RoundToInt(num2 + 1f);
			_rowStyle.fontSize = Mathf.RoundToInt(num2);
			_highlightStyle.fontSize = Mathf.RoundToInt(num2);
			_countStyle.fontSize = Mathf.RoundToInt(num2);
			_highlightCountStyle.fontSize = Mathf.RoundToInt(num2);
			List<DeathLedger.Row> list = (Plugin.SortByDeaths.Value ? DeathLedger.Current.OrderByDescending((DeathLedger.Row row2) => row2.Deaths).ThenBy<DeathLedger.Row, string>((DeathLedger.Row row2) => row2.Name, StringComparer.OrdinalIgnoreCase).ToList() : DeathLedger.Current.OrderBy<DeathLedger.Row, string>((DeathLedger.Row row2) => row2.Name, StringComparer.OrdinalIgnoreCase).ToList());
			float num3 = 188f * num;
			float num4 = (num2 + 7f) * num;
			float num5 = 31f * num;
			float num6 = num5 + (float)Math.Max(1, list.Count) * num4 + 8f * num;
			float num7 = (float)Screen.width - num3 - 18f * num + Plugin.HudOffsetX.Value;
			float num8 = (Minimap.IsOpen() ? ((float)Screen.height * 0.84f) : ((float)Screen.height * 0.34f)) + Plugin.HudOffsetY.Value;
			num7 = Mathf.Clamp(num7, 4f, Mathf.Max(4f, (float)Screen.width - num3 - 4f));
			num8 = Mathf.Clamp(num8, 4f, Mathf.Max(4f, (float)Screen.height - num6 - 4f));
			DrawPanel(new Rect(num7, num8, num3, num6));
			DrawBraidedEdge(num7, num8, num6, num);
			GUI.Label(new Rect(num7 + 25f * num, num8 + 5f * num, num3 - 34f * num, num5 - 4f * num), "☠  Mortes", _titleStyle);
			float num9 = num8 + num5;
			if (list.Count == 0)
			{
				GUI.Label(new Rect(num7 + 25f * num, num9, num3 - 34f * num, num4), "Aguardando jogadores", _rowStyle);
				return;
			}
			long num10 = (((Object)(object)Player.m_localPlayer != (Object)null) ? Player.m_localPlayer.GetPlayerID() : 0);
			Rect val = default(Rect);
			for (int num11 = 0; num11 < list.Count; num11++)
			{
				DeathLedger.Row row = list[num11];
				float num12 = num9 + (float)num11 * num4;
				((Rect)(ref val))..ctor(num7 + 25f * num, num12, num3 - 70f * num, num4);
				Rect val2 = new Rect(num7 + num3 - 43f * num, num12, 32f * num, num4);
				bool flag = row.PlayerId == num10;
				GUI.Label(val, row.Name, flag ? _highlightStyle : _rowStyle);
				GUI.Label(val2, row.Deaths.ToString(), flag ? _highlightCountStyle : _countStyle);
				if (num11 < list.Count - 1)
				{
					DrawRect(new Rect(num7 + 24f * num, num9 + (float)(num11 + 1) * num4, num3 - 31f * num, 1f), new Color(0.72f, 0.68f, 0.56f, 0.15f));
				}
			}
		}

		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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00c4: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			if (_titleStyle == null)
			{
				GUIStyle val = new GUIStyle(GUI.skin.label)
				{
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3
				};
				val.normal.textColor = new Color(0.94f, 0.87f, 0.72f);
				_titleStyle = val;
				GUIStyle val2 = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)3,
					clipping = (TextClipping)1
				};
				val2.normal.textColor = new Color(0.91f, 0.88f, 0.8f);
				_rowStyle = val2;
				GUIStyle val3 = new GUIStyle(_rowStyle)
				{
					fontStyle = (FontStyle)1
				};
				val3.normal.textColor = new Color(1f, 0.82f, 0.48f);
				_highlightStyle = val3;
				_countStyle = new GUIStyle(_rowStyle)
				{
					alignment = (TextAnchor)5
				};
				_highlightCountStyle = new GUIStyle(_highlightStyle)
				{
					alignment = (TextAnchor)5
				};
			}
		}

		private static void DrawPanel(Rect rect)
		{
			//IL_0000: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_012a: 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)
			DrawRect(rect, new Color(0.035f, 0.065f, 0.085f, 0.88f));
			DrawRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 2f), new Color(0.7f, 0.56f, 0.34f, 0.78f));
			DrawRect(new Rect(((Rect)(ref rect)).x + 1f, ((Rect)(ref rect)).y + 1f, 1f, ((Rect)(ref rect)).height - 2f), new Color(0.7f, 0.56f, 0.34f, 0.58f));
			DrawRect(new Rect(((Rect)(ref rect)).x + ((Rect)(ref rect)).width - 1f, ((Rect)(ref rect)).y + 1f, 1f, ((Rect)(ref rect)).height - 2f), new Color(0.7f, 0.56f, 0.34f, 0.25f));
			DrawRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + ((Rect)(ref rect)).height - 1f, ((Rect)(ref rect)).width, 1f), new Color(0.7f, 0.56f, 0.34f, 0.28f));
		}

		private static void DrawBraidedEdge(float x, float y, float height, float scale)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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)
			DrawRect(new Rect(x + 13f * scale, y + 6f * scale, 1f * scale, height - 12f * scale), new Color(0.69f, 0.55f, 0.34f, 0.65f));
			for (float num = 9f * scale; num < height - 5f * scale; num += 10f * scale)
			{
				DrawRect(new Rect(x + 8f * scale, y + num, 4f * scale, 1.2f * scale), new Color(0.76f, 0.64f, 0.43f, 0.72f));
				DrawRect(new Rect(x + 14f * scale, y + num + 4f * scale, 4f * scale, 1.2f * scale), new Color(0.76f, 0.64f, 0.43f, 0.56f));
			}
		}

		private static void DrawRect(Rect rect, Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Color color2 = GUI.color;
			GUI.color = color;
			GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture);
			GUI.color = color2;
		}
	}
	internal static class DeathLedger
	{
		internal sealed class Row
		{
			internal long PlayerId;

			internal string Name;

			internal int Deaths;
		}

		private const string RpcReportDeath = "VDL_ReportDeath";

		private const string RpcRequestSnapshot = "VDL_RequestSnapshot";

		private const string RpcSnapshot = "VDL_Snapshot";

		private const string RpcReset = "VDL_Reset";

		private const string RpcNotice = "VDL_Notice";

		private static readonly Dictionary<long, Row> Rows = new Dictionary<long, Row>();

		private static ZRoutedRpc _registeredOn;

		private static bool _started;

		private static float _startAt;

		private static float _nextSnapshotRequest;

		private static bool _clientHasSnapshot;

		private static World _activeWorld;

		internal static IReadOnlyList<Row> Current => Rows.Values.ToList();

		internal static void Tick()
		{
			RegisterRpcs();
			if ((Object)(object)ZNet.instance == (Object)null || ZRoutedRpc.instance == null)
			{
				return;
			}
			World world = ZNet.World;
			if (world != _activeWorld)
			{
				_activeWorld = world;
				_started = false;
				_startAt = 0f;
				_clientHasSnapshot = false;
				_nextSnapshotRequest = 0f;
				Rows.Clear();
			}
			if (world == null)
			{
				return;
			}
			if (ZNet.instance.IsServer())
			{
				if (!_started)
				{
					_started = true;
					_startAt = Time.realtimeSinceStartup + Plugin.AutoStartDelaySeconds.Value;
				}
				if (!Plugin.AutoStart.Value || Time.realtimeSinceStartup >= _startAt)
				{
					StartNewRound();
				}
			}
			else if ((Object)(object)Player.m_localPlayer != (Object)null && !_clientHasSnapshot && Time.realtimeSinceStartup >= _nextSnapshotRequest)
			{
				_nextSnapshotRequest = Time.realtimeSinceStartup + 2f;
				ZRoutedRpc.instance.InvokeRoutedRPC("VDL_RequestSnapshot", Array.Empty<object>());
			}
		}

		internal static void RegisterRpcs()
		{
			if (ZRoutedRpc.instance != null && _registeredOn != ZRoutedRpc.instance)
			{
				ZRoutedRpc.instance.Register("VDL_ReportDeath", (Action<long>)RPC_ReportDeath);
				ZRoutedRpc.instance.Register("VDL_RequestSnapshot", (Action<long>)RPC_RequestSnapshot);
				ZRoutedRpc.instance.Register<ZPackage>("VDL_Snapshot", (Action<long, ZPackage>)RPC_Snapshot);
				ZRoutedRpc.instance.Register("VDL_Reset", (Action<long>)RPC_Reset);
				ZRoutedRpc.instance.Register<ZPackage>("VDL_Notice", (Action<long, ZPackage>)RPC_Notice);
				_registeredOn = ZRoutedRpc.instance;
			}
		}

		internal static void ReportLocalDeath()
		{
			if (!((Object)(object)ZNet.instance == (Object)null) && ZRoutedRpc.instance != null && !((Object)(object)Player.m_localPlayer == (Object)null))
			{
				if (ZNet.instance.IsServer())
				{
					AddDeath(Player.m_localPlayer.GetPlayerID());
				}
				else
				{
					ZRoutedRpc.instance.InvokeRoutedRPC("VDL_ReportDeath", Array.Empty<object>());
				}
			}
		}

		internal static void RequestReset()
		{
			if (!((Object)(object)ZNet.instance == (Object)null) && ZRoutedRpc.instance != null)
			{
				if (ZNet.instance.IsServer())
				{
					ResetRoster();
					_started = true;
					_startAt = float.PositiveInfinity;
					BroadcastSnapshot();
					BroadcastNotice("Contador de mortes reiniciado.");
				}
				else
				{
					ZRoutedRpc.instance.InvokeRoutedRPC("VDL_Reset", Array.Empty<object>());
				}
			}
		}

		private static void StartNewRound()
		{
			if (!_started || _startAt != float.PositiveInfinity)
			{
				_started = true;
				_startAt = float.PositiveInfinity;
				ResetRoster();
				BroadcastSnapshot();
				Plugin.Log.LogInfo((object)$"Placar iniciado com {Rows.Count} jogador(es).");
			}
		}

		private static void RPC_ReportDeath(long sender)
		{
			if (IsServer())
			{
				ZNetPeer peer = ZNet.instance.GetPeer(sender);
				if (peer == null || ((ZDOID)(ref peer.m_characterID)).UserID == 0L)
				{
					Plugin.Log.LogWarning((object)$"Ignorada morte recebida de conexão desconhecida ({sender}).");
				}
				else
				{
					AddDeath(((ZDOID)(ref peer.m_characterID)).UserID);
				}
			}
		}

		private static void RPC_RequestSnapshot(long sender)
		{
			if (IsServer() && _started && _startAt == float.PositiveInfinity)
			{
				SendSnapshot(sender);
			}
		}

		private static void RPC_Reset(long sender)
		{
			if (IsServer())
			{
				ZNetPeer peer = ZNet.instance.GetPeer(sender);
				if (peer == null || !ZNet.instance.IsAdmin(peer.m_socket.GetHostName()))
				{
					SendNotice(sender, "Somente host ou administrador pode reiniciar o contador.");
					return;
				}
				ResetRoster();
				_started = true;
				_startAt = float.PositiveInfinity;
				BroadcastSnapshot();
				BroadcastNotice("Contador de mortes reiniciado.");
			}
		}

		private static void RPC_Snapshot(long sender, ZPackage pkg)
		{
			if (IsServer())
			{
				return;
			}
			ZNetPeer peer = ZNet.instance.GetPeer(sender);
			if (peer != null && peer.m_server)
			{
				int num = pkg.ReadInt();
				Rows.Clear();
				for (int i = 0; i < num; i++)
				{
					Row row = new Row
					{
						PlayerId = pkg.ReadLong(),
						Name = pkg.ReadString(),
						Deaths = pkg.ReadInt()
					};
					Rows[row.PlayerId] = row;
				}
				_clientHasSnapshot = true;
			}
		}

		private static void RPC_Notice(long sender, ZPackage pkg)
		{
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				return;
			}
			ZNetPeer peer = ZNet.instance.GetPeer(sender);
			if (peer != null && peer.m_server)
			{
				MessageHud instance = MessageHud.instance;
				if (instance != null)
				{
					instance.ShowMessage((MessageType)1, pkg.ReadString(), 0, (Sprite)null, false, true);
				}
			}
		}

		private static void AddDeath(long playerId)
		{
			if (Rows.TryGetValue(playerId, out var value))
			{
				value.Deaths++;
				BroadcastSnapshot();
			}
		}

		private static void ResetRoster()
		{
			Rows.Clear();
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				long playerID = localPlayer.GetPlayerID();
				Rows[playerID] = new Row
				{
					PlayerId = playerID,
					Name = localPlayer.GetPlayerName(),
					Deaths = 0
				};
			}
			foreach (ZNetPeer peer in ZNet.instance.GetPeers())
			{
				if (peer.IsReady())
				{
					long userID = ((ZDOID)(ref peer.m_characterID)).UserID;
					if (userID != 0L && !Rows.ContainsKey(userID) && !string.IsNullOrWhiteSpace(peer.m_playerName))
					{
						Rows[userID] = new Row
						{
							PlayerId = userID,
							Name = peer.m_playerName,
							Deaths = 0
						};
					}
				}
			}
		}

		private static ZPackage MakeSnapshot()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			ZPackage val = new ZPackage();
			val.Write(Rows.Count);
			foreach (Row item in Rows.Values.OrderBy<Row, string>((Row x) => x.Name, StringComparer.OrdinalIgnoreCase))
			{
				val.Write(item.PlayerId);
				val.Write(item.Name ?? string.Empty);
				val.Write(item.Deaths);
			}
			return val;
		}

		private static void SendSnapshot(long target)
		{
			ZRoutedRpc.instance.InvokeRoutedRPC(target, "VDL_Snapshot", new object[1] { MakeSnapshot() });
		}

		private static void BroadcastSnapshot()
		{
			ZRoutedRpc.instance.InvokeRoutedRPC(0L, "VDL_Snapshot", new object[1] { MakeSnapshot() });
		}

		private static void BroadcastNotice(string text)
		{
			ZRoutedRpc.instance.InvokeRoutedRPC(0L, "VDL_Notice", new object[1] { MakeNotice(text) });
		}

		private static void SendNotice(long target, string text)
		{
			ZRoutedRpc.instance.InvokeRoutedRPC(target, "VDL_Notice", new object[1] { MakeNotice(text) });
		}

		private static ZPackage MakeNotice(string text)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			ZPackage val = new ZPackage();
			val.Write(text);
			return val;
		}

		private static bool IsServer()
		{
			if ((Object)(object)ZNet.instance != (Object)null)
			{
				return ZNet.instance.IsServer();
			}
			return false;
		}

		internal static void OnWorldStopped()
		{
			_activeWorld = null;
			_started = false;
			_startAt = 0f;
			_clientHasSnapshot = false;
			_nextSnapshotRequest = 0f;
			Rows.Clear();
		}
	}
	[HarmonyPatch(typeof(ZNet), "Awake")]
	internal static class ZNetAwakePatch
	{
		private static void Postfix()
		{
			DeathLedger.RegisterRpcs();
		}
	}
	[HarmonyPatch(typeof(ZNet), "Shutdown")]
	internal static class ZNetShutdownPatch
	{
		private static void Postfix()
		{
			DeathLedger.OnWorldStopped();
		}
	}
	[HarmonyPatch(typeof(Player), "OnDeath")]
	internal static class PlayerDeathPatch
	{
		private static void Postfix(Player __instance)
		{
			if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				DeathLedger.ReportLocalDeath();
			}
		}
	}
	[HarmonyPatch(typeof(Player), "Awake")]
	internal static class PlayerAwakePatch
	{
		private static void Postfix(Player __instance)
		{
			if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				DeathLedger.RegisterRpcs();
			}
		}
	}
	[BepInPlugin("com.hugoc.valheimdeathledger", "Valheim Death Ledger", "1.1.1")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.hugoc.valheimdeathledger";

		public const string PluginName = "Valheim Death Ledger";

		public const string PluginVersion = "1.1.1";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> ShowHud;

		internal static ConfigEntry<KeyboardShortcut> ResetHotkey;

		internal static ConfigEntry<KeyboardShortcut> ToggleHudHotkey;

		internal static ConfigEntry<float> HudOffsetX;

		internal static ConfigEntry<float> HudOffsetY;

		internal static ConfigEntry<float> HudScale;

		internal static ConfigEntry<int> HudFontSize;

		internal static ConfigEntry<bool> SortByDeaths;

		internal static ConfigEntry<bool> AutoStart;

		internal static ConfigEntry<float> AutoStartDelaySeconds;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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_0188: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			ShowHud = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Mostrar HUD", true, "Exibe o placar de mortes abaixo do minimapa.");
			ToggleHudHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("HUD", "Atalho para ocultar/mostrar", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), "Atalho local para ocultar ou mostrar o placar.");
			HudOffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "Deslocamento horizontal", 0f, "Move o placar para a esquerda/direita em relação ao canto superior direito.");
			HudOffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "Deslocamento vertical", 0f, "Move o placar para cima/baixo. Com o mapa aberto, ele permanece na faixa inferior.");
			HudScale = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "Escala", 0.9f, "Escala do placar (0.60 a 1.50).");
			HudFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("HUD", "Tamanho da fonte", 14, "Tamanho da fonte do placar (10 a 24).");
			SortByDeaths = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Ordenar por mortes", true, "Ordena por mais mortes; desative para ordenar alfabeticamente.");
			ResetHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Atalhos", "Atalho para reiniciar", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Atalho configurável pelo ConfigurationManager. O servidor verifica a permissão de host/admin.");
			AutoStart = ((BaseUnityPlugin)this).Config.Bind<bool>("Sessão", "Iniciar automaticamente", true, "Inicia o placar ao carregar o mundo/servidor.");
			AutoStartDelaySeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Sessão", "Atraso de início (segundos)", 20f, "Aguarda jogadores terminarem de conectar antes de congelar a lista inicial.");
			_harmony = new Harmony("com.hugoc.valheimdeathledger");
			_harmony.PatchAll();
			((Component)this).gameObject.AddComponent<DeathHud>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Valheim Death Ledger 1.1.1 carregado.");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	[HarmonyPatch(typeof(Terminal), "InitTerminal")]
	internal static class TerminalCommandPatch
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ConsoleEvent <>9__1_0;

			internal void <Register>b__1_0(ConsoleEventArgs args)
			{
				DeathLedger.RequestReset();
			}
		}

		private static void Postfix()
		{
			Register("resetmortes");
			Register("resetdeaths");
		}

		private static void Register(string name)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			object obj = <>c.<>9__1_0;
			if (obj == null)
			{
				ConsoleEvent val = delegate
				{
					DeathLedger.RequestReset();
				};
				<>c.<>9__1_0 = val;
				obj = (object)val;
			}
			new ConsoleCommand(name, "Reinicia o contador de mortes desta sessão (host/admin).", (ConsoleEvent)obj, false, false, false, false, true, false, (ConsoleOptionsFetcher)null, false, false, false);
		}
	}
}