Decompiled source of InGameClock v1.0.2

Mods/InGameClock.dll

Decompiled 5 days 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.2", "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 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_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(2.4095f, 2.0332f, 0.9112f);
		Quaternion val2 = Quaternion.Euler(0f, 359.3656f, 0f);
		textGameObject = Create.NewText("Hour:Minute", 5f, Color.white, val, val2);
		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;
		}
		textGameObject.transform.position = val;
		textGameObject.transform.rotation = val2;
		((TMP_Text)timeDisplayText).alignment = (TextAlignmentOptions)514;
		((TMP_Text)timeDisplayText).enableWordWrapping = false;
		((Object)textGameObject).name = "Time Clock Text";
		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_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: 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_00c7: 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)
		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 = 2.0332f + Mathf.Sin(Time.time) * 0.05f;
			textGameObject.transform.position = new Vector3(textGameObject.transform.position.x, num, textGameObject.transform.position.z);
			textGameObject.transform.rotation = GetAngleToFaceMe(textGameObject.transform.position, ((Component)Camera.main).transform.position);
		}
	}
}