Decompiled source of InGameClock v1.0.4

Mods/InGameClock.dll

Decompiled 4 months ago
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Il2CppSystem;
using Il2CppTMPro;
using InGameClock;
using MelonLoader;
using RumbleModdingAPI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(main), "InGame Clock", "1.0.4", "ERROR", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 255, 0, 0)]
[assembly: MelonAuthorColor(255, 255, 0, 0)]
[assembly: AssemblyTitle("In Game Clock")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("InGame Clock")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: VerifyLoaderVersion(0, 6, 2, true)]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b10c94a1-8a40-4701-bc5b-98eabb44dfea")]
[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 InGameClock;

public class main : MelonMod
{
	private bool init = false;

	private string currentScene = "Loader";

	private int sceneCount = 0;

	private GameObject textGameObject;

	private TextMeshPro timeDisplayText;

	private float textYValue = 2.0332f;

	private DateTime RightNow;

	public override void OnLateInitializeMelon()
	{
		Calls.onMapInitialized += OnMapInitialized;
		MelonLogger.Msg("InGameClock Initiated");
	}

	public void OnMapInitialized()
	{
		if (currentScene != "Loader")
		{
			MelonCoroutines.Start(InitializeWithPause(sceneCount));
		}
	}

	private IEnumerator InitializeWithPause(int sceneNumber)
	{
		DateTime now = DateTime.Now;
		DateTime targetTime = ((DateTime)(ref now)).AddSeconds(1.0);
		while (DateTime.Now < targetTime)
		{
			yield return (object)new WaitForFixedUpdate();
		}
		if (sceneNumber == sceneCount)
		{
			Initialize();
		}
	}

	public void Initialize()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		if (init)
		{
			return;
		}
		textGameObject = Create.NewText("Hour:Minute", 5f, Color.white, Vector3.zero, Quaternion.identity);
		if ((Object)(object)textGameObject == (Object)null)
		{
			MelonLogger.Error("Failed to create textGameObject.");
			return;
		}
		timeDisplayText = textGameObject.GetComponent<TextMeshPro>();
		if ((Object)(object)timeDisplayText == (Object)null)
		{
			MelonLogger.Error("Failed to retrieve TextMeshPro component from textGameObject.");
			return;
		}
		((TMP_Text)timeDisplayText).alignment = (TextAlignmentOptions)514;
		((TMP_Text)timeDisplayText).enableWordWrapping = false;
		((Object)textGameObject).name = "Time Clock Text";
		Vector3 position = default(Vector3);
		Vector3 localScale = default(Vector3);
		Vector3 val = default(Vector3);
		if (currentScene == "Gym")
		{
			textYValue = 2.0332f;
			((Vector3)(ref position))..ctor(2.4095f, textYValue, 0.9112f);
			((Vector3)(ref localScale))..ctor(1f, 1f, 1.318f);
			val = Vector3.zero;
		}
		else if (currentScene == "Map1")
		{
			textYValue = 5.5709f;
			((Vector3)(ref position))..ctor(-14.4782f, textYValue, 2.1164f);
			((Vector3)(ref localScale))..ctor(4f, 4f, 4f);
			((Vector3)(ref val))..ctor(0f, 288.0543f, 0f);
		}
		else if (currentScene == "Map0")
		{
			textYValue = 1.5564f;
			((Vector3)(ref position))..ctor(17.951f, textYValue, 3.2618f);
			((Vector3)(ref localScale))..ctor(3f, 3f, 3f);
			((Vector3)(ref val))..ctor(0f, 76.8618f, 0f);
		}
		else
		{
			textYValue = -1.38f;
			((Vector3)(ref position))..ctor(10.24f, textYValue, 0.9517f);
			((Vector3)(ref localScale))..ctor(2.5f, 2.5f, 2.5f);
			((Vector3)(ref val))..ctor(0f, 73.0908f, 0f);
		}
		textGameObject.transform.position = position;
		textGameObject.transform.localScale = localScale;
		textGameObject.transform.rotation = Quaternion.Euler(val);
		init = true;
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		currentScene = sceneName;
		init = false;
	}

	private Quaternion GetAngleToFaceMe(Vector3 objectPosition, Vector3 lookAtPosition)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = objectPosition - lookAtPosition;
		return Quaternion.LookRotation(val);
	}

	public override void OnUpdate()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: 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)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)timeDisplayText != (Object)null && init)
		{
			RightNow = DateTime.Now;
			string text = ((DateTime)(ref RightNow)).ToString("hh:mm tt");
			((TMP_Text)timeDisplayText).text = text;
			float num = textYValue + Mathf.Sin(Time.time) * 0.05f;
			textGameObject.transform.position = new Vector3(textGameObject.transform.position.x, num, textGameObject.transform.position.z);
			if (currentScene == "Gym")
			{
				textGameObject.transform.rotation = GetAngleToFaceMe(textGameObject.transform.position, ((Component)Camera.main).transform.position);
			}
		}
	}
}