Decompiled source of Auto Start New Day Mod v1.0.0

SupermarketTogetherMod.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SupermarketTogetherMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SupermarketTogetherMod")]
[assembly: AssemblyTitle("SupermarketTogetherMod")]
[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;
		}
	}
}
[BepInPlugin("com.yourname.supermarkettogether.autostart", "Auto Start New Day Mod", "1.0.0")]
public class AutoStartNewDayMod : BaseUnityPlugin
{
	[HarmonyPatch(typeof(GameData), "WaitUntilNewDay")]
	public class WaitUntilNewDayPatch
	{
		private static void Postfix(GameData __instance)
		{
			Debug.Log((object)"New day process started...");
			((MonoBehaviour)__instance).StartCoroutine(HideEndDayStatsCoroutine(__instance));
		}

		private static IEnumerator HideEndDayStatsCoroutine(GameData __instance)
		{
			yield return (object)new WaitForSeconds(10f);
			GameObject endDayStats = GameObject.Find("EndDayStats");
			if ((Object)(object)endDayStats != (Object)null)
			{
				Debug.Log((object)"Hiding EndDayStats screen after 10 seconds...");
				endDayStats.SetActive(false);
			}
			else
			{
				Debug.LogError((object)"EndDayStats object not found!");
			}
		}
	}

	private void Awake()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		Debug.Log((object)"AutoStartNewDayMod: Awake called, patching...");
		Harmony val = new Harmony("com.yourname.supermarkettogether.autostart");
		val.PatchAll();
	}

	private void Update()
	{
		if ((Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) && Input.GetKeyDown((KeyCode)61))
		{
			SkipTimeForward(1f);
		}
	}

	private void SkipTimeForward(float hoursToSkip)
	{
		GameData val = Object.FindObjectOfType<GameData>();
		if ((Object)(object)val != (Object)null)
		{
			Debug.Log((object)$"Skipping time forward by {hoursToSkip} hour.");
			val.NetworktimeOfDay += hoursToSkip;
			if (val.NetworktimeOfDay >= 24f)
			{
				val.NetworktimeOfDay -= 24f;
				int networkgameDay = val.NetworkgameDay;
				val.NetworkgameDay = networkgameDay + 1;
				Debug.Log((object)"A new day has started.");
			}
			Debug.Log((object)$"New time: {val.NetworktimeOfDay} hours, Day: {val.NetworkgameDay}.");
		}
		else
		{
			Debug.LogError((object)"GameData object not found!");
		}
	}
}