Decompiled source of HurryUp v1.0.0

NoteBoxz.HurryUp.dll

Decompiled 34 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;

[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: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("DunGen")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")]
[assembly: IgnoresAccessChecksTo("Unity.XR.Management")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")]
[assembly: AssemblyCompany("NoteBoxz.HurryUp")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HurryUp")]
[assembly: AssemblyTitle("NoteBoxz.HurryUp")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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;
		}
	}
	[CompilerGenerated]
	[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;
		}
	}
}
public class HurryUpSFX
{
	public AudioClip? ClockChimeNoon;

	public AudioClip? ClockChimeEvening;

	public AudioClip? ClockChimeHurryUp;
}
public enum HurryUpSFXType
{
	P3,
	P4
}
namespace HurryUp
{
	[BepInPlugin("NoteBoxz.HurryUp", "HurryUp", "1.0.0")]
	public class HurryUp : BaseUnityPlugin
	{
		public static HurryUp Instance { get; private set; } = null;

		internal static ManualLogSource Logger { get; private set; } = null;

		internal static Harmony? Harmony { get; set; }

		internal static ConfigEntry<HurryUpSFXType> SFXType { get; private set; } = null;

		internal static ConfigEntry<bool> AnimateClock { get; private set; } = null;

		internal static ConfigEntry<bool> EnableEvenClockChimes { get; private set; } = null;

		internal static ConfigEntry<bool> EnableNoonClockChimes { get; private set; } = null;

		internal static ConfigEntry<bool> EnableHurryUpClockChimes { get; private set; } = null;

		internal static ConfigEntry<bool> HearChimesWhileInside { get; private set; } = null;

		internal static ConfigEntry<bool> HearChimesWhileClockIsHidden { get; private set; } = null;

		internal static ConfigEntry<bool> HearChimesWhileDead { get; private set; } = null;

		internal static ConfigEntry<bool> HearHurryUpChimeAlways { get; private set; } = null;

		internal static HurryUpSFX P2Sfx { get; private set; } = new HurryUpSFX();

		internal static HurryUpSFX P3Sfx { get; private set; } = new HurryUpSFX();

		internal static HurryUpSFX P4Sfx { get; private set; } = new HurryUpSFX();

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			BindConfig();
			SoundLoader.PreloadAll();
			foreach (AudioClip allLoadedClip in SoundLoader.GetAllLoadedClips())
			{
				Logger.LogInfo((object)("Loaded sound: " + ((Object)allLoadedClip).name));
				if (((Object)allLoadedClip).name == "SEQ_GameTimer_ChimeNoon")
				{
					P3Sfx.ClockChimeNoon = allLoadedClip;
				}
				if (((Object)allLoadedClip).name == "SEQ_GameTimer_ChimeQuarter")
				{
					P3Sfx.ClockChimeEvening = allLoadedClip;
				}
				if (((Object)allLoadedClip).name == "SEQ_GameTimer_ChimeHurryUp")
				{
					P3Sfx.ClockChimeHurryUp = allLoadedClip;
				}
				if (((Object)allLoadedClip).name == "GameTimer_Day_Noon")
				{
					P4Sfx.ClockChimeNoon = allLoadedClip;
				}
				if (((Object)allLoadedClip).name == "GameTimer_Day_Scale")
				{
					P4Sfx.ClockChimeEvening = allLoadedClip;
				}
				if (((Object)allLoadedClip).name == "GameTimer_Day_HurryUp")
				{
					P4Sfx.ClockChimeHurryUp = allLoadedClip;
				}
			}
			Logger.LogInfo((object)"NoteBoxz.HurryUp v1.0.0 has loaded!");
		}

		internal static GameObject? FindClockUI()
		{
			if ((Object)(object)HUDManager.Instance == (Object)null)
			{
				Logger.LogWarning((object)"HUDManager.Instance is null!");
				return null;
			}
			if ((Object)(object)HUDManager.Instance.Clock.canvasGroup == (Object)null)
			{
				Logger.LogWarning((object)"HUDManager.Instance.Clock.canvasGroup is null!");
				return null;
			}
			return ((Component)HUDManager.Instance.Clock.canvasGroup).gameObject;
		}

		internal static void BindConfig()
		{
			SFXType = ((BaseUnityPlugin)Instance).Config.Bind<HurryUpSFXType>("General", "Game Generation", HurryUpSFXType.P3, "Which game's clock chimes to use.");
			AnimateClock = ((BaseUnityPlugin)Instance).Config.Bind<bool>("General", "Animate Clock", true, "Enables the pulse effect on the clock when a chime occours.");
			EnableNoonClockChimes = ((BaseUnityPlugin)Instance).Config.Bind<bool>("General", "Enable Noon Clock Chimes", true, "Whether to play clock chimes at noon.");
			EnableEvenClockChimes = ((BaseUnityPlugin)Instance).Config.Bind<bool>("General", "Enable Evening Clock Chimes", true, "Whether to play clock chimes at evening.");
			EnableHurryUpClockChimes = ((BaseUnityPlugin)Instance).Config.Bind<bool>("General", "Enable Hurry Up Clock Chimes", true, "Whether to play clock chimes when the ship is about to leave.");
			HearChimesWhileInside = ((BaseUnityPlugin)Instance).Config.Bind<bool>("General", "Hear Chimes While Inside", true, "Whether to hear the clock chimes while inside the interior.");
			HearChimesWhileClockIsHidden = ((BaseUnityPlugin)Instance).Config.Bind<bool>("General", "Hear Chimes While Clock Is Hidden", true, "Whether to hear the clock chimes while the UI clock is hidden.");
			HearChimesWhileDead = ((BaseUnityPlugin)Instance).Config.Bind<bool>("General", "Hear Chimes While Dead", false, "Whether to hear the clock chimes while the player is dead.");
			HearHurryUpChimeAlways = ((BaseUnityPlugin)Instance).Config.Bind<bool>("General", "Hear Hurry Up Chime Always", true, "Whether to hear the Hurry Up chime even when the clock is hidden, the player is dead, or is inside.");
		}

		internal static bool ConfigsAllowChimes(DayMode mode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected I4, but got Unknown
			if ((int)mode == 3 && HearHurryUpChimeAlways.Value && EnableHurryUpClockChimes.Value)
			{
				Logger.LogDebug((object)"HearHurryUpChimeAlways is true, chime will play.");
				return true;
			}
			if ((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.localPlayerController != (Object)null && StartOfRound.Instance.localPlayerController.isInsideFactory && !HearChimesWhileInside.Value)
			{
				Logger.LogDebug((object)"Player is inside and HearChimesWhileInside is false, chime will not play.");
				return false;
			}
			if ((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.localPlayerController != (Object)null && StartOfRound.Instance.localPlayerController.isPlayerDead && !HearChimesWhileDead.Value)
			{
				Logger.LogDebug((object)"Player is dead and HearChimesWhileDead is false, chime will not play.");
				return false;
			}
			if ((Object)(object)HUDManager.Instance != (Object)null && HUDManager.Instance.Clock.targetAlpha == 0f && !HearChimesWhileClockIsHidden.Value)
			{
				Logger.LogDebug((object)"Clock is hidden and HearChimesWhileClockIsHidden is false, chime will not play.");
				return false;
			}
			if (1 == 0)
			{
			}
			bool result = (mode - 1) switch
			{
				0 => EnableNoonClockChimes.Value, 
				1 => EnableEvenClockChimes.Value, 
				2 => EnableHurryUpClockChimes.Value, 
				_ => false, 
			};
			if (1 == 0)
			{
			}
			return result;
		}

		internal static HurryUpSFX GetConfiguredSFX()
		{
			HurryUpSFXType value = SFXType.Value;
			if (1 == 0)
			{
			}
			HurryUpSFX result = value switch
			{
				HurryUpSFXType.P3 => P3Sfx, 
				HurryUpSFXType.P4 => P4Sfx, 
				_ => P3Sfx, 
			};
			if (1 == 0)
			{
			}
			return result;
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("NoteBoxz.HurryUp");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public class HurryUpFlags : MonoBehaviour
	{
		public enum PSCStyle
		{
			None,
			Pikmin3,
			Pikmin4
		}

		private const string PSCGuid = "NoteBoxz.PikminStyledClock";

		public bool playedNoonChime = false;

		public bool playedEveningChime = false;

		public bool playedHurryUpChime = false;

		public static HurryUpFlags Instance { get; private set; }

		public static PSCStyle GetPSCStyle()
		{
			if (!Chainloader.PluginInfos.ContainsKey("NoteBoxz.PikminStyledClock"))
			{
				return PSCStyle.None;
			}
			GameObject val = HurryUp.FindClockUI();
			if ((Object)(object)val == (Object)null)
			{
				return PSCStyle.None;
			}
			Transform val2 = val.transform.Find("Container/Box");
			if ((Object)(object)val2 == (Object)null || ((Component)val2).gameObject.activeSelf)
			{
				return PSCStyle.None;
			}
			if ((Object)(object)HUDManager.Instance.clockIcon == (Object)null)
			{
				return PSCStyle.None;
			}
			Transform parent = ((Component)HUDManager.Instance.clockIcon).transform.parent;
			return ((Object)(object)parent != (Object)null && (Object)(object)parent.Find("Circle") != (Object)null) ? PSCStyle.Pikmin3 : PSCStyle.Pikmin4;
		}

		public void Awake()
		{
			Instance = this;
		}

		public bool ShouldAnimte(DayMode mode)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected I4, but got Unknown
			if (!HurryUp.AnimateClock.Value)
			{
				return false;
			}
			bool flag = false;
			switch (mode - 1)
			{
			case 0:
				flag = !HurryUp.EnableNoonClockChimes.Value;
				break;
			case 1:
				flag = !HurryUp.EnableEvenClockChimes.Value;
				break;
			case 2:
				flag = !HurryUp.EnableHurryUpClockChimes.Value;
				break;
			}
			if (flag)
			{
				return false;
			}
			return true;
		}

		public void PulseClock(DayMode mode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Invalid comparison between Unknown and I4
			if (!ShouldAnimte(mode))
			{
				return;
			}
			GameObject val = HurryUp.FindClockUI();
			if ((Object)(object)val == (Object)null)
			{
				HurryUp.Logger.LogWarning((object)"Clock UI not found for pulse animation.");
				return;
			}
			bool vanillaBox = false;
			Transform val2;
			switch (GetPSCStyle())
			{
			case PSCStyle.Pikmin4:
				return;
			case PSCStyle.Pikmin3:
				val2 = ((Component)HUDManager.Instance.clockIcon).transform.parent.Find("Circle");
				break;
			default:
				val2 = val.transform.Find("Container/Box");
				vanillaBox = true;
				break;
			}
			if ((Object)(object)val2 == (Object)null)
			{
				HurryUp.Logger.LogWarning((object)"Clock pulse source not found for pulse animation.");
				return;
			}
			int repeatCount = (((int)mode != 1) ? 1 : 2);
			((MonoBehaviour)this).StartCoroutine(RepeatPulse(val2, repeatCount, 0.75f, vanillaBox));
		}

		private IEnumerator RepeatPulse(Transform source, int repeatCount, float delayBetweenPulses, bool vanillaBox)
		{
			for (int i = 0; i < repeatCount; i++)
			{
				if ((Object)(object)source == (Object)null)
				{
					break;
				}
				yield return PulseAnimation(source, vanillaBox);
				yield return (object)new WaitForSeconds(delayBetweenPulses);
			}
		}

		private IEnumerator PulseAnimation(Transform source, bool vanillaBox)
		{
			GameObject pulse = Object.Instantiate<GameObject>(((Component)source).gameObject, source.parent);
			((Object)pulse).name = "HurryUpPulse";
			foreach (Transform item in pulse.transform)
			{
				Transform child = item;
				Object.Destroy((Object)(object)((Component)child).gameObject);
			}
			Image img = pulse.GetComponent<Image>();
			float duration = 0.5f;
			float elapsed = 0f;
			Vector3 originalScale = pulse.transform.localScale;
			Vector3 targetScale = originalScale * (vanillaBox ? 1.2f : 1.35f);
			if (vanillaBox)
			{
				targetScale.y += 0.1f;
			}
			while (elapsed < duration)
			{
				if ((Object)(object)pulse == (Object)null)
				{
					yield break;
				}
				elapsed += Time.deltaTime;
				float t = Mathf.Clamp01(elapsed / duration);
				pulse.transform.localScale = Vector3.Lerp(originalScale, targetScale, t);
				if ((Object)(object)img != (Object)null)
				{
					((Graphic)img).color = new Color(((Graphic)img).color.r, ((Graphic)img).color.g, ((Graphic)img).color.b, 1f - t);
				}
				yield return null;
			}
			Object.Destroy((Object)(object)pulse);
		}

		public void ShakeIcon(DayMode mode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_009e: Expected I4, but got Unknown
			if (!ShouldAnimte(mode))
			{
				return;
			}
			if ((Object)(object)HUDManager.Instance == (Object)null || (Object)(object)HUDManager.Instance.clockIcon == (Object)null)
			{
				HurryUp.Logger.LogWarning((object)"Clock icon not found for shake animation.");
				return;
			}
			Transform val = ((Component)HUDManager.Instance.clockIcon).transform;
			if (GetPSCStyle() == PSCStyle.Pikmin3 && (Object)(object)val.parent != (Object)null)
			{
				val = val.parent;
			}
			switch (mode - 1)
			{
			case 0:
				((MonoBehaviour)this).StartCoroutine(RepeatShake(val, 2, 0.5f, 3f, 0.5f));
				break;
			case 1:
				((MonoBehaviour)this).StartCoroutine(RepeatShake(val, 2, 0.5f, 3f, 0.5f));
				break;
			case 2:
				((MonoBehaviour)this).StartCoroutine(ShakeAnimation(val, 3f));
				break;
			default:
				((MonoBehaviour)this).StartCoroutine(ShakeAnimation(val));
				break;
			}
		}

		private IEnumerator RepeatShake(Transform icon, int repeatCount, float duration = 0.5f, float magnitude = 3f, float delayBetweenShakes = 0.1f)
		{
			for (int i = 0; i < repeatCount; i++)
			{
				yield return ShakeAnimation(icon, duration, magnitude);
				yield return (object)new WaitForSeconds(delayBetweenShakes);
			}
		}

		private IEnumerator ShakeAnimation(Transform icon, float duration = 0.5f, float magnitude = 3f, float frequency = 4f)
		{
			float elapsed = 0f;
			Vector3 basePosition = icon.localPosition;
			Vector3 lastWritten = basePosition;
			while (elapsed < duration)
			{
				if ((Object)(object)icon == (Object)null)
				{
					yield break;
				}
				FollowExternalMovement(icon, ref basePosition, lastWritten);
				elapsed += Time.deltaTime;
				float phase = elapsed * MathF.PI * 2f * frequency;
				float shakeAmountX = Mathf.Sin(phase) * magnitude;
				float shakeAmountY = Mathf.Sin(phase * 2f) * magnitude;
				lastWritten = (icon.localPosition = new Vector3(basePosition.x + shakeAmountX, basePosition.y + shakeAmountY, icon.localPosition.z));
				yield return null;
			}
			if (!((Object)(object)icon == (Object)null))
			{
				FollowExternalMovement(icon, ref basePosition, lastWritten);
				icon.localPosition = new Vector3(basePosition.x, basePosition.y, icon.localPosition.z);
			}
		}

		private static void FollowExternalMovement(Transform icon, ref Vector3 basePosition, Vector3 lastWritten)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localPosition = icon.localPosition;
			if (!Mathf.Approximately(localPosition.x, lastWritten.x))
			{
				basePosition.x = localPosition.x;
			}
			if (!Mathf.Approximately(localPosition.y, lastWritten.y))
			{
				basePosition.y = localPosition.y;
			}
		}
	}
	internal static class SoundLoader
	{
		private static readonly Dictionary<string, AudioClip> cache = new Dictionary<string, AudioClip>();

		public static void PreloadAll()
		{
			int num = 0;
			int num2 = 0;
			string[] manifestResourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
			foreach (string text in manifestResourceNames)
			{
				if (text.EndsWith(".wav", StringComparison.OrdinalIgnoreCase))
				{
					num2++;
					if ((Object)(object)Load(text) != (Object)null)
					{
						num++;
					}
				}
			}
			HurryUp.Logger.LogInfo((object)$"Preloaded {num}/{num2} embedded sounds.");
		}

		public static IEnumerable<AudioClip> GetAllLoadedClips()
		{
			return cache.Values;
		}

		public static AudioClip? Load(string path)
		{
			if (!path.EndsWith(".wav", StringComparison.OrdinalIgnoreCase))
			{
				path += ".wav";
			}
			string text = path.Replace('\\', '/');
			if (cache.TryGetValue(text, out AudioClip value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string text2 = null;
			string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
			foreach (string text3 in manifestResourceNames)
			{
				if (text3.Replace('\\', '/').Equals(text, StringComparison.OrdinalIgnoreCase))
				{
					text2 = text3;
					break;
				}
			}
			if (text2 == null)
			{
				HurryUp.Logger.LogError((object)("Embedded sound not found: " + path));
				return null;
			}
			using Stream stream = executingAssembly.GetManifestResourceStream(text2);
			AudioClip val = DecodeWav(stream, Path.GetFileNameWithoutExtension(text));
			if ((Object)(object)val != (Object)null)
			{
				cache[text] = val;
			}
			return val;
		}

		private static AudioClip? DecodeWav(Stream stream, string name)
		{
			using BinaryReader binaryReader = new BinaryReader(stream);
			if (new string(binaryReader.ReadChars(4)) != "RIFF")
			{
				return null;
			}
			binaryReader.ReadInt32();
			if (new string(binaryReader.ReadChars(4)) != "WAVE")
			{
				return null;
			}
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			while (stream.Position + 8 <= stream.Length)
			{
				string text = new string(binaryReader.ReadChars(4));
				int num4 = binaryReader.ReadInt32();
				long position = stream.Position + num4 + (num4 & 1);
				if (text == "fmt ")
				{
					int num5 = binaryReader.ReadInt16();
					num = binaryReader.ReadInt16();
					num2 = binaryReader.ReadInt32();
					binaryReader.ReadInt32();
					binaryReader.ReadInt16();
					num3 = binaryReader.ReadInt16();
					if (num5 != 1 || num3 != 16)
					{
						HurryUp.Logger.LogError((object)$"{name}: only 16-bit PCM WAV is supported (format {num5}, {num3} bit)");
						return null;
					}
				}
				else if (text == "data")
				{
					if (num == 0)
					{
						return null;
					}
					int num6 = num4 / 2;
					float[] array = new float[num6];
					for (int i = 0; i < num6; i++)
					{
						array[i] = (float)binaryReader.ReadInt16() / 32768f;
					}
					AudioClip val = AudioClip.Create(name, num6 / num, num, num2, false);
					val.SetData(array, 0);
					((Object)val).hideFlags = (HideFlags)61;
					return val;
				}
				stream.Position = position;
			}
			return null;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "NoteBoxz.HurryUp";

		public const string PLUGIN_NAME = "HurryUp";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace HurryUp.Patches
{
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class TimeOfDayPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void StartPostFix(TimeOfDay __instance)
		{
			if ((Object)(object)((Component)__instance).gameObject.GetComponent<HurryUpFlags>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<HurryUpFlags>();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		public static void UpdatePrefix(TimeOfDay __instance)
		{
			try
			{
				if ((Object)(object)HurryUpFlags.Instance == (Object)null)
				{
					HurryUp.Logger.LogWarning((object)"HurryUpFlags instance is null in TimeOfDay.Update prefix.");
				}
				else if (__instance.currentDayTimeStarted && __instance.timeStartedThisFrame)
				{
					HurryUpFlags.Instance.playedNoonChime = false;
					HurryUpFlags.Instance.playedEveningChime = false;
					HurryUpFlags.Instance.playedHurryUpChime = false;
					HurryUp.Logger.LogInfo((object)"Resetting chime flags for new day.");
				}
			}
			catch (Exception arg)
			{
				HurryUp.Logger.LogError((object)$"Error in TimeOfDay.Update prefix: {arg}");
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("TimeOfDayEvents")]
		public static void TimeOfDayEventsPrefix(TimeOfDay __instance)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected I4, but got Unknown
			try
			{
				if ((Object)(object)HurryUpFlags.Instance == (Object)null)
				{
					HurryUp.Logger.LogWarning((object)"HurryUpFlags instance is null in TimeOfDay.TimeOfDayEvents prefix.");
					return;
				}
				DayMode dayMode = __instance.dayMode;
				DayMode val = dayMode;
				switch (val - 1)
				{
				case 0:
					if (!HurryUpFlags.Instance.playedNoonChime)
					{
						HurryUpFlags.Instance.playedNoonChime = true;
						if (!HurryUp.ConfigsAllowChimes((DayMode)1))
						{
							HurryUp.Logger.LogDebug((object)"Noon chime event skipped.");
							break;
						}
						HUDManager.Instance.dialogueBoxSFX.PlayOneShot(HurryUp.GetConfiguredSFX().ClockChimeNoon);
						HurryUpFlags.Instance.PulseClock((DayMode)1);
						HurryUpFlags.Instance.ShakeIcon((DayMode)1);
						HurryUp.Logger.LogInfo((object)"Noon chime event triggered.");
					}
					break;
				case 1:
					if (!HurryUpFlags.Instance.playedEveningChime)
					{
						HurryUpFlags.Instance.playedEveningChime = true;
						if (!HurryUp.ConfigsAllowChimes((DayMode)2))
						{
							HurryUp.Logger.LogDebug((object)"Evening chime event skipped.");
							break;
						}
						HUDManager.Instance.dialogueBoxSFX.PlayOneShot(HurryUp.GetConfiguredSFX().ClockChimeEvening);
						HurryUpFlags.Instance.PulseClock((DayMode)2);
						HurryUpFlags.Instance.ShakeIcon((DayMode)2);
						HurryUp.Logger.LogInfo((object)"Evening chime event triggered.");
					}
					break;
				case 2:
					if (!HurryUpFlags.Instance.playedHurryUpChime)
					{
						HurryUpFlags.Instance.playedHurryUpChime = true;
						if (!HurryUp.ConfigsAllowChimes((DayMode)3))
						{
							HurryUp.Logger.LogDebug((object)"Hurry Up chime event skipped.");
							break;
						}
						HUDManager.Instance.dialogueBoxSFX.PlayOneShot(HurryUp.GetConfiguredSFX().ClockChimeHurryUp);
						HurryUpFlags.Instance.PulseClock((DayMode)3);
						HurryUpFlags.Instance.ShakeIcon((DayMode)3);
						HurryUp.Logger.LogInfo((object)"Hurry Up chime event triggered.");
					}
					break;
				}
			}
			catch (Exception arg)
			{
				HurryUp.Logger.LogError((object)$"Error in TimeOfDay.TimeOfDayEvents prefix: {arg}");
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("SetShipLeaveEarlyClientRpc")]
		public static void SetShipLeaveEarlyClientRpcPrefix(TimeOfDay __instance)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			try
			{
				NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
				if ((Object)(object)networkManager != (Object)null && networkManager.IsListening && (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost) && HurryUp.EnableHurryUpClockChimes.Value && !HurryUpFlags.Instance.playedHurryUpChime)
				{
					HurryUpFlags.Instance.playedEveningChime = true;
					HurryUpFlags.Instance.playedNoonChime = true;
					HurryUpFlags.Instance.playedHurryUpChime = true;
					HUDManager.Instance.dialogueBoxSFX.PlayOneShot(HurryUp.GetConfiguredSFX().ClockChimeHurryUp);
					HurryUp.Logger.LogInfo((object)"Hurry Up chime event triggered.");
				}
			}
			catch (Exception arg)
			{
				HurryUp.Logger.LogError((object)$"Error in TimeOfDay.SetShipLeaveEarlyClientRpc prefix: {arg}");
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}