Decompiled source of SpeedHud v1.0.0

SpeedHud.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = "")]
[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 SpeedHud
{
	[BepInPlugin("com.yourname.speedhud", "Speed HUD", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SpeedHudPlugin : BaseUnityPlugin
	{
		private GameObject _textObject;

		private Text _label;

		private const float UpdateInterval = 0.2f;

		private float _timer;

		private void Awake()
		{
			GUIManager.OnCustomGUIAvailable += BuildGui;
		}

		private void BuildGui()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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)
			_textObject = GUIManager.Instance.CreateText("", GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 90f), GUIManager.Instance.AveriaSerifBold, 20, GUIManager.Instance.ValheimOrange, true, Color.black, 300f, 30f, false);
			_label = _textObject.GetComponent<Text>();
			_label.alignment = (TextAnchor)4;
		}

		private void Update()
		{
			//IL_0077: 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)
			if ((Object)(object)_label == (Object)null)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				_textObject.SetActive(false);
				return;
			}
			_textObject.SetActive(true);
			_timer += Time.deltaTime;
			if (!(_timer < 0.2f))
			{
				_timer = 0f;
				Vector3 velocity = ((Character)localPlayer).GetVelocity();
				velocity.y = 0f;
				_label.text = $"{((Vector3)(ref velocity)).magnitude:0.0} m/s";
			}
		}
	}
}