using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon.Movement;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Speedometer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-alpha.0+4e6bbd6c5b379b6d3219ebf9cfe23db02f3bc134")]
[assembly: AssemblyProduct("Speedometer")]
[assembly: AssemblyTitle("Speedometer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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;
}
}
}
[BepInPlugin("sparroh.speedometer", "Speedometer", "1.1.0")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class SpeedometerMod : BaseUnityPlugin
{
public const string PluginGUID = "sparroh.speedometer";
public const string PluginName = "Speedometer";
public const string PluginVersion = "1.1.0";
private TextMeshProUGUI speedText;
private GameObject hudContainer;
private FieldInfo currentMoveSpeedField;
private FieldInfo vkField;
private FieldInfo rbField;
private FieldInfo moveVelocityField;
private PropertyInfo vkProp;
private PropertyInfo rbProp;
private bool uiVisible = true;
private bool wasLocked;
private static readonly Color sky = new Color(0.529f, 0.808f, 0.922f);
private void Awake()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("sparroh.speedometer").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Speedometer loaded successfully.");
currentMoveSpeedField = typeof(Player).GetField("currentMoveSpeed", BindingFlags.Instance | BindingFlags.NonPublic);
vkField = typeof(Player).GetField("velocity", BindingFlags.Instance | BindingFlags.NonPublic) ?? typeof(Player).GetField("velocity", BindingFlags.Instance | BindingFlags.Public);
if (vkField != null)
{
return;
}
vkProp = typeof(Player).GetProperty("velocity", BindingFlags.Instance | BindingFlags.Public);
if (vkProp != null)
{
return;
}
rbField = typeof(Player).GetField("rb", BindingFlags.Instance | BindingFlags.NonPublic) ?? typeof(Player).GetField("rb", BindingFlags.Instance | BindingFlags.Public);
if (!(rbField != null))
{
rbProp = typeof(Player).GetProperty("rb", BindingFlags.Instance | BindingFlags.Public);
if (!(rbProp != null))
{
moveVelocityField = typeof(Player).GetField("moveVelocity", BindingFlags.Instance | BindingFlags.NonPublic) ?? typeof(Player).GetField("moveVelocity", BindingFlags.Instance | BindingFlags.Public);
_ = moveVelocityField != null;
}
}
}
private void CreateHUD()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_008e: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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)
//IL_00e1: Expected O, but got Unknown
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)hudContainer != (Object)null) && !((Object)(object)Player.LocalPlayer == (Object)null) && !((Object)(object)Player.LocalPlayer.PlayerLook == (Object)null) && !((Object)(object)Player.LocalPlayer.PlayerLook.Reticle == (Object)null))
{
RectTransform reticle = Player.LocalPlayer.PlayerLook.Reticle;
hudContainer = new GameObject("SpeedometerHUD");
hudContainer.transform.SetParent((Transform)(object)reticle, false);
RectTransform obj = hudContainer.AddComponent<RectTransform>();
obj.anchorMin = new Vector2(0.2f, 0.9f);
obj.anchorMax = new Vector2(0.2f, 0.9f);
obj.anchoredPosition = new Vector2(0f, 0f);
obj.sizeDelta = new Vector2(300f, 25f);
GameObject val = new GameObject("SpeedText");
val.transform.SetParent(hudContainer.transform, false);
speedText = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)speedText).fontSize = 18f;
((Graphic)speedText).color = Color.white;
((TMP_Text)speedText).enableWordWrapping = false;
((TMP_Text)speedText).alignment = (TextAlignmentOptions)513;
((TMP_Text)speedText).verticalAlignment = (VerticalAlignmentOptions)512;
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.anchoredPosition = new Vector2(0f, 0f);
}
}
private void Update()
{
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: 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_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)hudContainer == (Object)null)
{
CreateHUD();
return;
}
if (((ButtonControl)Keyboard.current.f6Key).wasPressedThisFrame)
{
uiVisible = !uiVisible;
if ((Object)(object)hudContainer != (Object)null)
{
hudContainer.SetActive(uiVisible);
}
}
if (!uiVisible || (Object)(object)hudContainer == (Object)null || (Object)(object)speedText == (Object)null || (Object)(object)Player.LocalPlayer == (Object)null)
{
if ((Object)(object)speedText != (Object)null && uiVisible)
{
((TMP_Text)speedText).text = "No Player";
}
return;
}
GameObject val = GameObject.Find("DamageMeterHUD");
hudContainer.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, ((Object)(object)val != (Object)null && val.activeSelf) ? (-100f) : 0f);
float num = 0f;
if (vkField != null || vkProp != null)
{
if (vkField != null)
{
if (vkField.GetValue(Player.LocalPlayer) is Vector3 val2)
{
num = ((Vector3)(ref val2)).magnitude;
}
}
else if (vkProp != null && vkProp.GetValue(Player.LocalPlayer) is Vector3 val3)
{
num = ((Vector3)(ref val3)).magnitude;
}
}
else if (rbField != null || rbProp != null)
{
Vector3 velocity;
if (rbField != null)
{
object? value = rbField.GetValue(Player.LocalPlayer);
Rigidbody val4 = (Rigidbody)((value is Rigidbody) ? value : null);
if (val4 != null)
{
velocity = val4.velocity;
num = ((Vector3)(ref velocity)).magnitude;
}
}
else if (rbProp != null)
{
object? value2 = rbProp.GetValue(Player.LocalPlayer);
Rigidbody val5 = (Rigidbody)((value2 is Rigidbody) ? value2 : null);
if (val5 != null)
{
velocity = val5.velocity;
num = ((Vector3)(ref velocity)).magnitude;
}
}
}
if (num == 0f && currentMoveSpeedField != null && currentMoveSpeedField.GetValue(Player.LocalPlayer) is float num2)
{
num = num2;
}
if (num == 0f && moveVelocityField != null && moveVelocityField.GetValue(Player.LocalPlayer) is Vector3 val6)
{
num = ((Vector3)(ref val6)).magnitude;
}
if (num > 0f)
{
((TMP_Text)speedText).text = $"Speed: <color=#{ColorUtility.ToHtmlStringRGB(sky)}>{num:F1}</color> m/s";
}
else
{
((TMP_Text)speedText).text = "No Speed Detected";
}
}
public void OnApplicationFocus(bool hasFocus)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Invalid comparison between Unknown and I4
if (!hasFocus)
{
wasLocked = (int)Cursor.lockState == 1;
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
return;
}
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
if (wasLocked && (Object)(object)Player.LocalPlayer != (Object)null && !((ButtonControl)Keyboard.current.tabKey).isPressed)
{
Cursor.lockState = (CursorLockMode)1;
Cursor.visible = false;
}
}
private void OnDestroy()
{
if ((Object)(object)hudContainer != (Object)null)
{
Object.Destroy((Object)(object)hudContainer);
}
}
}
[CompilerGenerated]
[ExcludeFromCodeCoverage]
internal static class GitVersionInformation
{
public const string AssemblySemFileVer = "0.0.1.0";
public const string AssemblySemVer = "0.0.1.0";
public const string BranchName = "master";
public const string BuildMetaData = "";
public const string CommitDate = "2025-10-17";
public const string CommitsSinceVersionSource = "1";
public const string EscapedBranchName = "master";
public const string FullBuildMetaData = "Branch.master.Sha.4e6bbd6c5b379b6d3219ebf9cfe23db02f3bc134";
public const string FullSemVer = "0.0.1-1";
public const string InformationalVersion = "0.0.1-1+Branch.master.Sha.4e6bbd6c5b379b6d3219ebf9cfe23db02f3bc134";
public const string Major = "0";
public const string MajorMinorPatch = "0.0.1";
public const string Minor = "0";
public const string Patch = "1";
public const string PreReleaseLabel = "";
public const string PreReleaseLabelWithDash = "";
public const string PreReleaseNumber = "1";
public const string PreReleaseTag = "1";
public const string PreReleaseTagWithDash = "-1";
public const string SemVer = "0.0.1-1";
public const string Sha = "4e6bbd6c5b379b6d3219ebf9cfe23db02f3bc134";
public const string ShortSha = "4e6bbd6";
public const string UncommittedChanges = "12";
public const string VersionSourceSha = "";
public const string WeightedPreReleaseNumber = "55001";
}
namespace Speedometer
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Speedometer";
public const string PLUGIN_NAME = "Speedometer";
public const string PLUGIN_VERSION = "0.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}