Decompiled source of Day Night Cycle v1.0.0

DayNightCycle.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using DayNightCycle;
using HarmonyLib;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.GameTime;
using Il2CppScheduleOne.Levelling;
using Il2CppScheduleOne.UI;
using MelonLoader;
using Microsoft.CodeAnalysis;
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(Core), "DayNightCycle", "1.0.0", "Miserrrr", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyCompany("DayNightCycle")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DayNightCycle")]
[assembly: AssemblyTitle("DayNightCycle")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace DayNightCycle
{
	public class Core : MelonMod
	{
		[HarmonyPatch(typeof(TimeManager), "Update")]
		public static class TimeUpdatePatch
		{
			[HarmonyPrefix]
			public static bool Prefix(TimeManager __instance)
			{
				try
				{
					DateTime now = DateTime.Now;
					long num = now.Hour * 3600 + now.Minute * 60 + now.Second;
					long num2 = num % 1800;
					float num3 = (float)num2 * 1440f / 1800f;
					int num4 = (int)(num3 / 60f);
					int num5 = (int)(num3 % 60f);
					__instance.CurrentTime = num4 * 100 + num5;
					if (_instance != null)
					{
						if (num4 == 6 && _instance.lastGameHour != 6)
						{
							if (!_instance.hasGainedLevelXpToday)
							{
								LevelManager instance = NetworkSingleton<LevelManager>.Instance;
								if ((Object)(object)instance != (Object)null)
								{
									instance.AddXP(25);
									MelonLogger.Msg("Awarded daily XP at 6AM");
									_instance.hasGainedLevelXpToday = true;
								}
							}
						}
						else if (num4 != 6 && _instance.lastGameHour == 6)
						{
							_instance.hasGainedLevelXpToday = false;
						}
						_instance.lastGameHour = num4;
					}
				}
				catch (Exception ex)
				{
					MelonLogger.Error("Error in TimeUpdatePatch: " + ex.Message);
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(SleepCanvas), "SetIsOpen")]
		public static class DisableSleepMenuPatch
		{
			[HarmonyPrefix]
			public static bool Prefix(bool open)
			{
				if (open)
				{
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(SleepCanvas), "SleepButtonPressed")]
		public static class DisableSleepButtonPatch
		{
			[HarmonyPrefix]
			public static bool Prefix()
			{
				return false;
			}
		}

		[HarmonyPatch(typeof(SleepCanvas), "SleepStart")]
		public static class DisableSleepStartPatch
		{
			[HarmonyPrefix]
			public static bool Prefix()
			{
				return false;
			}
		}

		private bool hasGainedLevelXpToday = false;

		private int lastGameHour = -1;

		private static Core _instance;

		public override void OnInitializeMelon()
		{
			_instance = this;
			MelonLogger.Msg(ConsoleColor.Cyan, "\r\n ____                _   _ _       _     _      ____            _      \r\n|  _ \\  __ _ _   _  | \\ | (_) __ _| |__ | |_   / ___|   _  ___| | ___ \r\n| | | |/ _` | | | | |  \\| | |/ _` | '_ \\| __| | |  | | | |/ __| |/ _ \\\r\n| |_| | (_| | |_| | | |\\  | | (_| | | | | |_  | |__| |_| | (__| |  __/\r\n|____/ \\__,_|\\__, | |_| \\_|_|\\__, |_| |_|\\__|  \\____\\__, |\\___|_|\\___|\r\n             |___/           |___/                  |___/             \r\n");
			MelonLogger.Msg(ConsoleColor.Magenta, "Created by Miserrrr");
			MelonLogger.Msg("Continuous Day Night Cycle Initialized.");
		}
	}
}