Decompiled source of EndOfDayCountdown V2 v2.0.2

NoteBoxz.EndOfDayCountdown.dll

Decompiled 2 months 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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
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("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.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("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("NoteBoxz.EndOfDayCountdown")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("2.0.2.0")]
[assembly: AssemblyInformationalVersion("2.0.2")]
[assembly: AssemblyProduct("EndOfDayCountdown")]
[assembly: AssemblyTitle("NoteBoxz.EndOfDayCountdown")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.2.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.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;
		}
	}
	[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 EndOfDayCountdown
{
	[BepInPlugin("NoteBoxz.EndOfDayCountdown", "EndOfDayCountdown", "2.0.2")]
	public class EndOfDayCountdown : BaseUnityPlugin
	{
		internal static AssetBundle assetBundle;

		public static Countdown? CountDownInstace;

		public static GameObject countdownPrefab;

		public static ConfigEntry<string> TextColor;

		public static ConfigEntry<string> CircleColor;

		public static ConfigEntry<float> CountdownAlertDuration;

		public static EndOfDayCountdown Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		public static ConfigEntry<bool> SpawnCountdownInfrountOfUI { get; private set; }

		public static ConfigEntry<bool> StopCountdownWhenDead { get; private set; }

		public static ConfigEntry<bool> StopCountdownWhenShipLeave { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			BindConfigs();
			LoadAssetBundle();
			countdownPrefab = assetBundle.LoadAsset<GameObject>("Assets/CountDownAssets/Countdown.prefab");
			Logger.LogInfo((object)"NoteBoxz.EndOfDayCountdown v2.0.2 has loaded!");
		}

		private void BindConfigs()
		{
			SpawnCountdownInfrountOfUI = ((BaseUnityPlugin)this).Config.Bind<bool>("Countdown", "Show coundown in front", false, "Spawns the countdown infront of the main UI");
			TextColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Text Color", "(214,98,41,255)", "Color for the text. Format: (R,G,B,A)");
			CircleColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Circle Color", "(214,98,41,255)", "Color for the circle. Format: (R,G,B,A)");
			CountdownAlertDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Countdown", "Countdown Alert Duration", 3.5f, "Duration of the countdown alert in seconds.");
			StopCountdownWhenDead = ((BaseUnityPlugin)this).Config.Bind<bool>("Countdown", "Stop Countdown When Dead", true, "Stops the countdown when the player is dead.");
			StopCountdownWhenShipLeave = ((BaseUnityPlugin)this).Config.Bind<bool>("Countdown", "Stop Countdown When Ship Leaves", true, "Stops the countdown when the ship is leaving.");
		}

		internal static void LoadAssetBundle()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			if (directoryName == null)
			{
				throw new InvalidOperationException("Unable to determine assembly location.");
			}
			string text = Path.Combine(directoryName, "endofdaycountdown");
			assetBundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)assetBundle == (Object)null)
			{
				throw new InvalidOperationException("Failed to load AssetBundle.");
			}
		}

		internal static Color ParseColor(string colorString)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			string[] array = colorString.Trim('(', ')').Split(',');
			if (array.Length == 4 && int.TryParse(array[0], out var result) && int.TryParse(array[1], out var result2) && int.TryParse(array[2], out var result3) && int.TryParse(array[3], out var result4))
			{
				return new Color((float)result / 255f, (float)result2 / 255f, (float)result3 / 255f, (float)result4 / 255f);
			}
			Logger.LogWarning((object)("Unable to parse color config!!!: Input " + colorString + " The input should be somthing like (000,000,000,000) for (R,G,B,A)"));
			return Color.white;
		}

		public static string GetClock(float timeNormalized, float numberOfHours)
		{
			int num = (int)(timeNormalized * (60f * numberOfHours)) + 360;
			int num2 = (int)Mathf.Floor((float)(num / 60));
			string text = "AM";
			if (num2 >= 24)
			{
				return "12:00\nAM";
			}
			text = ((num2 >= 12) ? "PM" : "AM");
			if (num2 > 12)
			{
				num2 %= 12;
			}
			int num3 = num % 60;
			return $"{num2:00}:{num3:00}".TrimStart('0') + text;
		}

		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.EndOfDayCountdown");
			}
			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 Countdown : MonoBehaviour
	{
		public Animator anim = null;

		public AudioSource sfx = null;

		public TMP_Text text = null;

		public Image sprite = null;

		public static Dictionary<float, string> TimeMap = new Dictionary<float, string>();

		public const int numbCountdownAlerts = 11;

		private void Awake()
		{
			anim = ((Component)this).GetComponent<Animator>();
			sfx = ((Component)this).GetComponentInChildren<AudioSource>();
			text = ((Component)this).GetComponentInChildren<TMP_Text>();
			sprite = ((Component)this).GetComponentInChildren<Image>();
		}

		public void CountdownAlert(string message, Color? OverrideColor = null)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			if (OverrideColor.HasValue)
			{
				((Graphic)text).color = OverrideColor.Value;
				((Graphic)sprite).color = OverrideColor.Value;
			}
			else
			{
				((Graphic)text).color = EndOfDayCountdown.ParseColor(EndOfDayCountdown.TextColor.Value);
				((Graphic)sprite).color = EndOfDayCountdown.ParseColor(EndOfDayCountdown.CircleColor.Value);
			}
			text.text = message;
			anim.Play("CountDown");
			sfx.Play();
		}

		public static void UpdateTimeMap(float? overrideEndTime = null)
		{
			TimeMap.Clear();
			TimeOfDay instance = TimeOfDay.Instance;
			int numberOfHours = instance.numberOfHours;
			float totalTime = instance.totalTime;
			float num = instance.shipLeaveAutomaticallyTime * totalTime;
			if (overrideEndTime.HasValue)
			{
				num = overrideEndTime.Value;
			}
			float num2 = num - EndOfDayCountdown.CountdownAlertDuration.Value * 11f;
			for (int i = 0; i < 11; i++)
			{
				float key = num2 + (float)i * EndOfDayCountdown.CountdownAlertDuration.Value;
				TimeMap.Add(key, $"{10 - i}");
			}
			EndOfDayCountdown.Logger.LogInfo((object)"═══════════════════════════════════");
			EndOfDayCountdown.Logger.LogInfo((object)"              TIME MAP             ");
			EndOfDayCountdown.Logger.LogInfo((object)"═══════════════════════════════════");
			foreach (KeyValuePair<float, string> item in TimeMap)
			{
				EndOfDayCountdown.Logger.LogInfo((object)$"({item.Value}) Time: {item.Key:F2} - Clock: {EndOfDayCountdown.GetClock(item.Key / totalTime, numberOfHours)}");
			}
			EndOfDayCountdown.Logger.LogInfo((object)"═══════════════════════════════════");
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void MakeCountdown(HUDManager __instance)
		{
			try
			{
				EndOfDayCountdown.CountDownInstace = Object.Instantiate<GameObject>(EndOfDayCountdown.countdownPrefab, __instance.HUDContainer.transform.parent).AddComponent<Countdown>();
				Transform val = __instance.HUDContainer.transform.parent.Find("Panel");
				if ((Object)(object)val != (Object)null && !EndOfDayCountdown.SpawnCountdownInfrountOfUI.Value)
				{
					((Component)EndOfDayCountdown.CountDownInstace).transform.SetSiblingIndex(val.GetSiblingIndex() + 1);
				}
				else if (!EndOfDayCountdown.SpawnCountdownInfrountOfUI.Value)
				{
					EndOfDayCountdown.Logger.LogWarning((object)"No 'pannle' found");
				}
				EndOfDayCountdown.Logger.LogInfo((object)"Created countdown instance");
			}
			catch (Exception ex)
			{
				EndOfDayCountdown.Logger.LogError((object)("Error in HUDManagerPatch: " + ex.Message + "\n" + ex.StackTrace));
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[CompilerGenerated]
		private sealed class <MesureTimeDelayed>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public StartOfRound __instance;

			private TimeOfDay <time>5__1;

			private float <timeSpeedMultiplier>5__2;

			private float <hourLength>5__3;

			private int <hoursCount>5__4;

			private float <dayLength>5__5;

			private float <dayEndTime>5__6;

			private float <startOffset>5__7;

			private float <realTimeSecondsPerHour>5__8;

			private float <realTimeToReachDayEnd>5__9;

			private string <endClock>5__10;

			private int <i>5__11;

			private float <actualHourIndex>5__12;

			private float <gameTimeAtHour>5__13;

			private float <realTimeToReachHour>5__14;

			private string <gameClock>5__15;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <MesureTimeDelayed>d__1(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<time>5__1 = null;
				<endClock>5__10 = null;
				<gameClock>5__15 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitUntil((Func<bool>)(() => TimeOfDay.Instance.timeHasStarted));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<time>5__1 = TimeOfDay.Instance;
					<timeSpeedMultiplier>5__2 = <time>5__1.globalTimeSpeedMultiplier;
					<hourLength>5__3 = <time>5__1.lengthOfHours;
					<hoursCount>5__4 = <time>5__1.numberOfHours;
					<dayLength>5__5 = <time>5__1.totalTime;
					<dayEndTime>5__6 = <time>5__1.shipLeaveAutomaticallyTime * <dayLength>5__5;
					<startOffset>5__7 = 100f;
					<realTimeSecondsPerHour>5__8 = <hourLength>5__3 / <timeSpeedMultiplier>5__2;
					EndOfDayCountdown.Logger.LogDebug((object)"═══════════════════════════════════");
					EndOfDayCountdown.Logger.LogDebug((object)"     TIME CALCULATION RESULTS      ");
					EndOfDayCountdown.Logger.LogDebug((object)"═══════════════════════════════════");
					EndOfDayCountdown.Logger.LogDebug((object)$"Time Speed: {<timeSpeedMultiplier>5__2}x");
					EndOfDayCountdown.Logger.LogDebug((object)$"Starting Time Offset: {<startOffset>5__7:F2}");
					EndOfDayCountdown.Logger.LogDebug((object)("1 Game Hour = " + FormatTime(<realTimeSecondsPerHour>5__8) + " real time"));
					EndOfDayCountdown.Logger.LogDebug((object)"───────────────────────────────────");
					EndOfDayCountdown.Logger.LogDebug((object)"HOUR-BY-HOUR BREAKDOWN:");
					<i>5__11 = 0;
					while (<i>5__11 < <hoursCount>5__4)
					{
						<actualHourIndex>5__12 = <i>5__11;
						<gameTimeAtHour>5__13 = <actualHourIndex>5__12 * <hourLength>5__3 + <startOffset>5__7;
						<realTimeToReachHour>5__14 = (<gameTimeAtHour>5__13 - <startOffset>5__7) / <timeSpeedMultiplier>5__2;
						<gameClock>5__15 = EndOfDayCountdown.GetClock(<gameTimeAtHour>5__13 / <dayLength>5__5, <hoursCount>5__4);
						EndOfDayCountdown.Logger.LogDebug((object)$"► Hour {<gameClock>5__15} ({<i>5__11}) - Reached after {FormatTime(<realTimeToReachHour>5__14)} real time");
						<gameClock>5__15 = null;
						<i>5__11++;
					}
					EndOfDayCountdown.Logger.LogDebug((object)"───────────────────────────────────");
					<realTimeToReachDayEnd>5__9 = (<dayEndTime>5__6 - <startOffset>5__7) / <timeSpeedMultiplier>5__2;
					<endClock>5__10 = EndOfDayCountdown.GetClock(<dayEndTime>5__6 / <dayLength>5__5, <hoursCount>5__4);
					EndOfDayCountdown.Logger.LogDebug((object)("⚠ SHIP LEAVES (" + <endClock>5__10 + ") - Reached after " + FormatTime(<realTimeToReachDayEnd>5__9) + " real time"));
					EndOfDayCountdown.Logger.LogDebug((object)"═══════════════════════════════════");
					Countdown.UpdateTimeMap();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[HarmonyPatch("openingDoorsSequence")]
		[HarmonyPostfix]
		private static void MesureTime(StartOfRound __instance)
		{
			try
			{
				((MonoBehaviour)__instance).StartCoroutine(MesureTimeDelayed(__instance));
			}
			catch (Exception ex)
			{
				EndOfDayCountdown.Logger.LogError((object)("Error in StartOfRoundPatch: " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		[IteratorStateMachine(typeof(<MesureTimeDelayed>d__1))]
		private static IEnumerator MesureTimeDelayed(StartOfRound __instance)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <MesureTimeDelayed>d__1(0)
			{
				__instance = __instance
			};
		}

		private static string FormatTime(float seconds)
		{
			TimeSpan timeSpan = TimeSpan.FromSeconds(seconds);
			if (timeSpan.TotalHours >= 1.0)
			{
				return $"{(int)timeSpan.TotalHours}h {timeSpan.Minutes}m {timeSpan.Seconds}s";
			}
			if (timeSpan.TotalMinutes >= 1.0)
			{
				return $"{timeSpan.Minutes}m {timeSpan.Seconds}s";
			}
			return $"{timeSpan.Seconds}s";
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class TimeOfDayPatch
	{
		[HarmonyPatch("MoveGlobalTime")]
		[HarmonyPostfix]
		private static void checkForCountdown(TimeOfDay __instance)
		{
			try
			{
				if ((Object)(object)EndOfDayCountdown.CountDownInstace == (Object)null || (!StartOfRound.Instance.localPlayerController.isPlayerControlled && EndOfDayCountdown.StopCountdownWhenDead.Value) || (StartOfRound.Instance.shipIsLeaving && EndOfDayCountdown.StopCountdownWhenShipLeave.Value))
				{
					return;
				}
				float globalTime = __instance.globalTime;
				float? num = null;
				foreach (KeyValuePair<float, string> item in Countdown.TimeMap)
				{
					if (Mathf.Abs(globalTime - item.Key) < 0.1f)
					{
						EndOfDayCountdown.Logger.LogDebug((object)$"Time match found: {globalTime:F2} matches {item.Key:F2} - {item.Value}");
						EndOfDayCountdown.CountDownInstace.CountdownAlert(item.Value);
						num = item.Key;
						break;
					}
				}
				if (num.HasValue)
				{
					Countdown.TimeMap.Remove(num.Value);
					num = null;
				}
			}
			catch (Exception ex)
			{
				EndOfDayCountdown.Logger.LogError((object)("Error in TimeOfDayPatch: " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		[HarmonyPatch("SetShipLeaveEarlyClientRpc")]
		[HarmonyPrefix]
		private static void MesureTime(TimeOfDay __instance, float timeToLeaveEarly, int votes)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
			if (networkManager != null && networkManager.IsListening && (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				Countdown.UpdateTimeMap(timeToLeaveEarly * TimeOfDay.Instance.totalTime);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "NoteBoxz.EndOfDayCountdown";

		public const string PLUGIN_NAME = "EndOfDayCountdown";

		public const string PLUGIN_VERSION = "2.0.2";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}