using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Jotunn.Managers; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("DistanceFromWorldCenter")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+411d42229b53bacd6a9b9230b912cfd2e14d55c2")] [assembly: AssemblyProduct("DistanceFromWorldCenter")] [assembly: AssemblyTitle("DistanceFromWorldCenter")] [assembly: AssemblyVersion("1.0.0.0")] namespace DistanceFromWorldCenter; [BepInPlugin("DeathMonger.DistanceFromWorldCenter", "Distance From World Center", "1.0.0")] [BepInProcess("valheim.exe")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class DistanceFromWorldCenterMod : BaseUnityPlugin { private const string ModGuid = "DeathMonger.DistanceFromWorldCenter"; public static DistanceFromWorldCenterMod Instance; public ConfigEntry ShowDistanceHud; public ConfigEntry ShowDistanceCoords; public ConfigEntry DistanceHudOffsetX; public ConfigEntry DistanceHudOffsetY; private void Awake() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown Instance = this; ShowDistanceHud = ((BaseUnityPlugin)this).Config.Bind("Distance HUD", "Enabled", true, new ConfigDescription("Show a small always-on widget displaying the player's horizontal distance from the world center.", (AcceptableValueBase)null, Array.Empty())); ShowDistanceCoords = ((BaseUnityPlugin)this).Config.Bind("Distance HUD", "Show Coordinates", false, new ConfigDescription("Also include the player's (X, Z) coordinates in the distance widget.", (AcceptableValueBase)null, Array.Empty())); DistanceHudOffsetX = ((BaseUnityPlugin)this).Config.Bind("Distance HUD", "Offset X (px)", 10f, new ConfigDescription("Horizontal offset from the upper-left corner of the screen.", (AcceptableValueBase)null, Array.Empty())); DistanceHudOffsetY = ((BaseUnityPlugin)this).Config.Bind("Distance HUD", "Offset Y (px)", 10f, new ConfigDescription("Vertical offset from the top of the screen.", (AcceptableValueBase)null, Array.Empty())); } private void Update() { DistanceHud.Tick(); } } public static class DistanceHud { private const float UpdateInterval = 0.2f; private const float Width = 320f; private const float Height = 30f; private static GameObject _go; private static Text _text; private static RectTransform _rect; private static float _lastUpdate; private static bool Enabled => (DistanceFromWorldCenterMod.Instance?.ShowDistanceHud?.Value).GetValueOrDefault(true); private static bool ShowCoords => (DistanceFromWorldCenterMod.Instance?.ShowDistanceCoords?.Value).GetValueOrDefault(); private static float OffsetX => (DistanceFromWorldCenterMod.Instance?.DistanceHudOffsetX?.Value).GetValueOrDefault(10f); private static float OffsetY => (DistanceFromWorldCenterMod.Instance?.DistanceHudOffsetY?.Value).GetValueOrDefault(10f); public static void Tick() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) EnsureCreated(); if ((Object)(object)_text == (Object)null) { return; } Player localPlayer = Player.m_localPlayer; bool flag = Enabled && (Object)(object)localPlayer != (Object)null; if (_go.activeSelf != flag) { _go.SetActive(flag); } if (flag) { _rect.anchoredPosition = new Vector2(OffsetX, 0f - OffsetY); float time = Time.time; if (!(time - _lastUpdate < 0.2f)) { _lastUpdate = time; Vector3 position = ((Component)localPlayer).transform.position; float num = Mathf.Sqrt(position.x * position.x + position.z * position.z); _text.text = (ShowCoords ? $"World Center: {num:F0}m ({position.x:F0}, {position.z:F0})" : $"World Center: {num:F0}m"); } } } private static void EnsureCreated() { //IL_0041: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_00dd: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_go != (Object)null) && GUIManager.Instance != null && !((Object)(object)GUIManager.CustomGUIFront == (Object)null)) { _go = GUIManager.Instance.CreateText(string.Empty, GUIManager.CustomGUIFront.transform, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(OffsetX, 0f - OffsetY), GUIManager.Instance.AveriaSerifBold, 16, GUIManager.Instance.ValheimOrange, true, Color.black, 320f, 30f, false); ((Object)_go).name = "DistanceFromWorldCenter_DistanceHud"; _rect = _go.GetComponent(); _rect.pivot = new Vector2(0f, 1f); _rect.anchoredPosition = new Vector2(OffsetX, 0f - OffsetY); _text = _go.GetComponent(); _text.alignment = (TextAnchor)0; ((Graphic)_text).raycastTarget = false; } } }