Decompiled source of Speedometer v1.0.1

ScheduleISpeedometerMod.dll

Decompiled 5 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using MelonLoader;
using ScheduleISpeedometerMod;
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: MelonInfo(typeof(Class1), "Schedule I Speedometer", "1.0.0", "Jay", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: MelonInfo(typeof(Class1), "Schedule I Speedometer Mod", "1.0.0", "YourName", null)]
[assembly: AssemblyTitle("ScheduleISpeedometerMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ScheduleISpeedometerMod")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5051edac-a07f-4834-bbcb-bf35635f0288")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ScheduleISpeedometerMod;

public class Class1 : MelonMod
{
	private Rigidbody playerRigidbody;

	private Text speedText;

	private const string SpeedUnit = "mph";

	public override void OnApplicationStart()
	{
		MelonLogger.Msg("Speedometer mod loaded.");
		CreateSpeedUI();
	}

	public override void OnUpdate()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)playerRigidbody == (Object)null)
		{
			playerRigidbody = Object.FindObjectOfType<Rigidbody>();
		}
		if ((Object)(object)playerRigidbody != (Object)null && (Object)(object)speedText != (Object)null)
		{
			Vector3 velocity = playerRigidbody.velocity;
			float magnitude = ((Vector3)(ref velocity)).magnitude;
			float num = magnitude * 2.23694f;
			speedText.text = string.Format("Speed: {0:F1} {1}", num, "mph".ToUpper());
		}
	}

	private void CreateSpeedUI()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Expected O, but got Unknown
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("SpeedometerCanvas");
		Canvas val2 = val.AddComponent<Canvas>();
		val2.renderMode = (RenderMode)0;
		CanvasScaler val3 = val.AddComponent<CanvasScaler>();
		val3.uiScaleMode = (ScaleMode)1;
		val3.referenceResolution = new Vector2(1920f, 1080f);
		val.AddComponent<GraphicRaycaster>();
		GameObject val4 = new GameObject("SpeedText");
		val4.transform.SetParent(val.transform);
		speedText = val4.AddComponent<Text>();
		speedText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
		speedText.fontSize = 30;
		speedText.alignment = (TextAnchor)4;
		((Graphic)speedText).color = Color.white;
		RectTransform rectTransform = ((Graphic)speedText).rectTransform;
		rectTransform.anchorMin = new Vector2(0.5f, 0f);
		rectTransform.anchorMax = new Vector2(0.5f, 0f);
		rectTransform.pivot = new Vector2(0.5f, 0f);
		rectTransform.anchoredPosition = new Vector2(0f, 50f);
		rectTransform.sizeDelta = new Vector2(400f, 50f);
	}
}