using System;
using System.Diagnostics;
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 UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.SceneManagement;
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")]
[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("com.yourname.speedometer", "Speedometer Mod", "1.0.1")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class SpeedometerMod : BaseUnityPlugin
{
private Text speedText;
private Image backgroundImage;
private Canvas uiCanvas;
private FieldInfo currentMoveSpeedField;
private FieldInfo moveVelocityField;
private bool hasLoggedUpdateOnce;
private bool hasLoggedScene;
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)
//IL_000b: Expected O, but got Unknown
Harmony val = new Harmony("com.yourname.speedometer");
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)(val.Id + " loaded!"));
currentMoveSpeedField = typeof(Player).GetField("currentMoveSpeed", BindingFlags.Instance | BindingFlags.NonPublic);
moveVelocityField = typeof(Player).GetField("moveVelocity", BindingFlags.Instance | BindingFlags.NonPublic);
if (currentMoveSpeedField == null || moveVelocityField == null)
{
((Behaviour)this).enabled = false;
}
}
private void Start()
{
CreateUI();
}
private void CreateUI()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Expected O, but got Unknown
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: 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_013e: Expected O, but got Unknown
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: 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_01fd: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)uiCanvas != (Object)null))
{
GameObject val = new GameObject("SpeedometerCanvas");
uiCanvas = val.AddComponent<Canvas>();
uiCanvas.renderMode = (RenderMode)0;
uiCanvas.sortingOrder = 9999;
uiCanvas.pixelPerfect = true;
CanvasScaler obj = val.AddComponent<CanvasScaler>();
obj.uiScaleMode = (ScaleMode)1;
obj.referenceResolution = new Vector2(1920f, 1080f);
obj.scaleFactor = 1f;
val.AddComponent<GraphicRaycaster>();
GameObject val2 = new GameObject("SpeedBg");
val2.transform.SetParent(val.transform, false);
backgroundImage = val2.AddComponent<Image>();
((Graphic)backgroundImage).color = new Color(0f, 0f, 0f, 0.6f);
((Graphic)backgroundImage).raycastTarget = false;
RectTransform component = val2.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0.11f, 1f);
component.anchorMax = new Vector2(0.11f, 1f);
component.anchoredPosition = new Vector2(0f, -15f);
component.sizeDelta = new Vector2(150f, 25f);
GameObject val3 = new GameObject("SpeedText");
val3.transform.SetParent(val2.transform, false);
speedText = val3.AddComponent<Text>();
speedText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
speedText.text = "Speed: Loading...";
speedText.fontSize = 15;
((Graphic)speedText).color = Color.white;
speedText.alignment = (TextAnchor)4;
((Graphic)speedText).raycastTarget = false;
speedText.verticalOverflow = (VerticalWrapMode)1;
RectTransform component2 = val3.GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.offsetMin = new Vector2(1f, 1f);
component2.offsetMax = new Vector2(-1f, -1f);
Object.DontDestroyOnLoad((Object)(object)val);
}
}
private void Update()
{
//IL_00a8: 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_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
if (((ButtonControl)Keyboard.current.f6Key).wasPressedThisFrame)
{
uiVisible = !uiVisible;
if ((Object)(object)backgroundImage != (Object)null)
{
((Behaviour)backgroundImage).enabled = uiVisible;
}
if ((Object)(object)speedText != (Object)null)
{
((Behaviour)speedText).enabled = uiVisible;
}
}
if (!uiVisible || (Object)(object)speedText == (Object)null || (Object)(object)Player.LocalPlayer == (Object)null)
{
if ((Object)(object)speedText != (Object)null && uiVisible)
{
speedText.text = "No Player";
}
return;
}
Scene activeScene = SceneManager.GetActiveScene();
_ = ((Scene)(ref activeScene)).name;
if (!hasLoggedScene)
{
hasLoggedScene = true;
}
float num = 0f;
if (currentMoveSpeedField.GetValue(Player.LocalPlayer) is float num2)
{
num = num2;
}
else if (moveVelocityField.GetValue(Player.LocalPlayer) is Vector3 val)
{
Vector3 val2 = new Vector3(val.x, 0f, val.z);
num = ((Vector3)(ref val2)).magnitude;
}
if (num > 0f)
{
speedText.text = $"Speed: <color=#{ColorUtility.ToHtmlStringRGB(sky)}>{num:F1}</color> m/s";
}
else
{
speedText.text = "No Speed Detected";
}
if (!hasLoggedUpdateOnce && num > 0f)
{
hasLoggedUpdateOnce = true;
}
}
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
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
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;
}
_ = Cursor.lockState;
}
private void OnDestroy()
{
if ((Object)(object)uiCanvas != (Object)null)
{
Object.Destroy((Object)(object)((Component)uiCanvas).gameObject);
}
}
}
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)
{
}
}
}