Decompiled source of DayCounter v2.0.0

DayCounter.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using DayCounter;
using Il2CppInterop.Runtime.Injection;
using Il2CppScheduleOne.GameTime;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppSystem;
using Il2CppTMPro;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "DayCounter", "2.0.0", "sav", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DayCounter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DayCounter")]
[assembly: AssemblyTitle("DayCounter")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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;
		}
	}
}
namespace DayCounter
{
	public class Core : MelonMod
	{
		private static bool HasPlayerSpawned;

		private bool InMainGame;

		private static GameObject DayUIElement;

		private static TextMeshProUGUI DayText;

		private static MelonPreferences_Category ConfigCategory;

		public static MelonPreferences_Entry<float> SavedPosX;

		public static MelonPreferences_Entry<float> SavedPosY;

		public static MelonPreferences_Entry<float> SavedScale;

		private static Vector3 DefaultPosition = new Vector3(850f, 510f, 0f);

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("sav's Day Counter mod loaded successfully!!");
			ConfigCategory = MelonPreferences.CreateCategory("DayCounter");
			SavedPosX = ConfigCategory.CreateEntry<float>("PosX", DefaultPosition.x, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			SavedPosY = ConfigCategory.CreateEntry<float>("PosY", DefaultPosition.y, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			SavedScale = ConfigCategory.CreateEntry<float>("Scale", 1f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName == "Main")
			{
				InMainGame = true;
				MelonCoroutines.Start(WaitForPlayer());
			}
			else
			{
				InMainGame = false;
				HasPlayerSpawned = false;
			}
		}

		private static IEnumerator WaitForPlayer()
		{
			while ((Object)(object)Player.Local == (Object)null || (Object)(object)((Component)Player.Local).gameObject == (Object)null)
			{
				yield return null;
			}
			if (!HasPlayerSpawned)
			{
				HasPlayerSpawned = true;
				MelonCoroutines.Start(OnPlayerSpawned());
				ClassInjector.RegisterTypeInIl2Cpp<UIDragging>();
			}
		}

		private static IEnumerator OnPlayerSpawned()
		{
			yield return (object)new WaitForSeconds(1f);
			if ((Object)(object)((Component)Player.Local).gameObject != (Object)null)
			{
				DayUIElement = Object.Instantiate<GameObject>(GameObject.Find("UI/HUD/Background"));
				GameObject ParentObj = GameObject.Find("UI/HUD/");
				DayUIElement.transform.SetParent(ParentObj.transform);
				Vector3 SavedPosition = new Vector3(SavedPosX.Value, SavedPosY.Value, 0f);
				DayUIElement.transform.localPosition = SavedPosition;
				DayUIElement.SetActive(true);
				((Object)DayUIElement).name = "DayManagerUI";
				DayText = GameObject.Find("UI/HUD/DayManagerUI/TopScreenText").GetComponent<TextMeshProUGUI>();
				TimeManager TManager = Object.FindObjectOfType<TimeManager>();
				int DaysGone = TManager.ElapsedDays + 1;
				TManager.onDayPass += Action.op_Implicit((Action)ChangeDayText);
				((TMP_Text)DayText).text = "DAY " + DaysGone;
				DayUIElement.AddComponent<UIDragging>();
			}
		}

		private static void ChangeDayText()
		{
			TimeManager val = Object.FindObjectOfType<TimeManager>();
			int num = val.ElapsedDays + 1;
			((TMP_Text)DayText).text = "DAY " + num;
		}
	}
	public class UIDragging : MonoBehaviour
	{
		private Vector3 Offset;

		private bool Dragging = false;

		private RectTransform Rect;

		private float ScaleFactor = 1f;

		private void Start()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			Rect = ((Component)this).GetComponent<RectTransform>();
			ScaleFactor = Core.SavedScale.Value;
			((Transform)Rect).localScale = Vector3.one * ScaleFactor;
		}

		private void Update()
		{
			//IL_000b: 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_0028: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue();
			if (Mouse.current.leftButton.wasPressedThisFrame && RectTransformUtility.RectangleContainsScreenPoint(Rect, val))
			{
				Offset = Vector2.op_Implicit(val) - ((Component)this).transform.position;
				Dragging = true;
			}
			if (Mouse.current.leftButton.wasReleasedThisFrame)
			{
				Dragging = false;
				Vector3 localPosition = ((Component)this).transform.localPosition;
				Core.SavedPosX.Value = localPosition.x;
				Core.SavedPosY.Value = localPosition.y;
				MelonPreferences.Save();
			}
			if (Dragging)
			{
				Vector3 mousePosition = Input.mousePosition;
				((Component)this).transform.position = mousePosition - Offset;
				float y = ((InputControl<Vector2>)(object)Mouse.current.scroll).ReadValue().y;
				if (Mathf.Abs(y) > 0.01f)
				{
					ScaleFactor += y * 0.0027f;
					ScaleFactor = Mathf.Clamp(ScaleFactor, 0.5f, 3f);
					((Transform)Rect).localScale = Vector3.one * ScaleFactor;
					Core.SavedScale.Value = ScaleFactor;
				}
			}
		}
	}
}