Decompiled source of Game Clock v0.1.0

FrizzQOL.GameClock.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("FrizzQOL.GameClock")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3c91dcdbbb067e0c7117eea9d14fb7f59afff30e")]
[assembly: AssemblyProduct("FrizzQOL.GameClock")]
[assembly: AssemblyTitle("FrizzQOL.GameClock")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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;
		}
	}
}
namespace GameClock
{
	public struct ClockSnapshot
	{
		public float DayFraction;

		public int Day;

		public string Weather;

		public float WindX;

		public float WindZ;

		public float WindIntensity;

		public bool IsCold;

		public bool IsWet;

		public bool IsFreezing;
	}
	public struct ClockOptions
	{
		public bool Use24Hour;

		public bool ShowAmPm;

		public bool ShowDay;

		public bool ShowWeather;

		public bool ShowWind;

		public bool ShowCold;

		public bool ShowWet;

		public bool ShowFreezing;

		public static ClockOptions TimeOnly(bool use24Hour, bool showAmPm)
		{
			return new ClockOptions
			{
				Use24Hour = use24Hour,
				ShowAmPm = showAmPm
			};
		}

		public static ClockOptions AllOn(bool use24Hour)
		{
			return new ClockOptions
			{
				Use24Hour = use24Hour,
				ShowAmPm = true,
				ShowDay = true,
				ShowWeather = true,
				ShowWind = true,
				ShowCold = true,
				ShowWet = true,
				ShowFreezing = true
			};
		}
	}
	public static class ClockText
	{
		public static bool Use24Hour(string clockFormat)
		{
			return clockFormat == "24h";
		}

		public static string NormalizeCorner(string corner)
		{
			switch (corner)
			{
			case "TopLeft":
			case "TopCenter":
			case "TopRight":
				return corner;
			default:
				return "TopRight";
			}
		}

		public static bool IsTimeReady(float dayFraction)
		{
			if (!float.IsNaN(dayFraction))
			{
				return !float.IsInfinity(dayFraction);
			}
			return false;
		}

		public static string Format(ClockSnapshot snapshot, ClockOptions options)
		{
			List<string> list = new List<string>();
			string text = FormatTime(snapshot.DayFraction, options.Use24Hour, options.ShowAmPm);
			if (text.Length > 0)
			{
				list.Add(text);
			}
			if (options.ShowDay)
			{
				list.Add("Day " + snapshot.Day.ToString(CultureInfo.InvariantCulture));
			}
			List<string> list2 = new List<string>();
			if (options.ShowWeather && !string.IsNullOrEmpty(snapshot.Weather))
			{
				list2.Add(snapshot.Weather);
			}
			if (options.ShowWind)
			{
				list2.Add(FormatWind(snapshot.WindX, snapshot.WindZ, snapshot.WindIntensity));
			}
			List<string> list3 = new List<string>();
			if (list.Count > 0)
			{
				list3.Add(Join(list));
			}
			if (list2.Count > 0)
			{
				list3.Add(Join(list2));
			}
			string text2 = FormatStatus(snapshot, options);
			if (text2.Length > 0)
			{
				list3.Add(text2);
			}
			return string.Join("\n", list3);
		}

		private static string Join(List<string> parts)
		{
			return string.Join(" · ", parts);
		}

		private static string FormatTime(float dayFraction, bool use24Hour, bool showAmPm)
		{
			if (!IsTimeReady(dayFraction))
			{
				return "";
			}
			double num = (double)dayFraction * 1440.0;
			if (num < 0.0 || num >= 1440.0)
			{
				num = 0.0;
			}
			int num2 = (int)Math.Floor(num + 0.0001);
			if (num2 >= 1440)
			{
				num2 = 0;
			}
			int num3 = num2 / 60;
			int num4 = num2 % 60;
			if (use24Hour)
			{
				return num3.ToString("00", CultureInfo.InvariantCulture) + ":" + num4.ToString("00", CultureInfo.InvariantCulture);
			}
			int num5 = num3 % 12;
			if (num5 == 0)
			{
				num5 = 12;
			}
			string text = num5.ToString(CultureInfo.InvariantCulture) + ":" + num4.ToString("00", CultureInfo.InvariantCulture);
			if (!showAmPm)
			{
				return text;
			}
			string text2 = ((num3 < 12) ? "AM" : "PM");
			return text + " " + text2;
		}

		private static string FormatWind(float x, float z, float intensity)
		{
			if (intensity < 0.01f)
			{
				return "Wind 0%";
			}
			int num = (int)Math.Round((double)intensity * 100.0, MidpointRounding.AwayFromZero);
			if (num < 0)
			{
				num = 0;
			}
			if (num > 100)
			{
				num = 100;
			}
			return "Wind " + Compass(x, z) + " " + num.ToString(CultureInfo.InvariantCulture) + "%";
		}

		private static string Compass(float x, float z)
		{
			double num = Math.Atan2(x, z) * (180.0 / Math.PI);
			if (num < 0.0)
			{
				num += 360.0;
			}
			int num2 = (int)Math.Floor((num + 22.5) / 45.0) % 8;
			if (num2 < 0)
			{
				num2 += 8;
			}
			return (new string[8] { "N", "NE", "E", "SE", "S", "SW", "W", "NW" })[num2];
		}

		private static string FormatStatus(ClockSnapshot snapshot, ClockOptions options)
		{
			List<string> list = new List<string>();
			if (options.ShowCold && snapshot.IsCold)
			{
				list.Add("Cold");
			}
			if (options.ShowWet && snapshot.IsWet)
			{
				list.Add("Wet");
			}
			if (options.ShowFreezing && snapshot.IsFreezing)
			{
				list.Add("Freezing");
			}
			return string.Join(", ", list);
		}
	}
	public class ClockView : MonoBehaviour
	{
		private static bool _loggedFont;

		private TextMeshProUGUI _text;

		private float _sourceFontSize;

		private float _timer;

		private bool _force;

		private bool _wasReady;

		private string _shown = "";

		private bool _hasMapPoint;

		private Vector2 _mapPoint;

		private float _mapWidth = 220f;

		internal static void RequestRefresh()
		{
			ClockView clockView = FindView();
			if ((Object)(object)clockView != (Object)null)
			{
				clockView._force = true;
			}
		}

		internal static void Attach(Hud hud)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)hud == (Object)null || (Object)(object)hud.m_rootObject == (Object)null)
			{
				return;
			}
			TMP_Text healthText = hud.m_healthText;
			if ((Object)(object)healthText == (Object)null || (Object)(object)healthText.font == (Object)null)
			{
				if (!_loggedFont)
				{
					_loggedFont = true;
					Plugin.LogWarning("HUD health text is missing. Game Clock label skipped.");
				}
			}
			else if (!((Object)(object)hud.m_rootObject.transform.Find("GameClock") != (Object)null))
			{
				GameObject val = new GameObject("GameClock");
				val.SetActive(false);
				val.transform.SetParent(hud.m_rootObject.transform, false);
				TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val2).font = healthText.font;
				((TMP_Text)val2).fontSharedMaterial = healthText.fontSharedMaterial;
				((TMP_Text)val2).fontSize = healthText.fontSize;
				((TMP_Text)val2).fontStyle = healthText.fontStyle;
				((Graphic)val2).color = ((Graphic)healthText).color;
				((Graphic)val2).raycastTarget = false;
				((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0;
				((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
				((TMP_Text)val2).alignment = (TextAlignmentOptions)258;
				((TMP_Text)val2).lineSpacing = 0f;
				((TMP_Text)val2).text = "";
				((TMP_Text)val2).rectTransform.sizeDelta = new Vector2(220f, 48f);
				ClockView clockView = val.AddComponent<ClockView>();
				clockView._text = val2;
				clockView._sourceFontSize = healthText.fontSize;
				val.SetActive(true);
			}
		}

		private void Update()
		{
			bool flag = IsReady();
			((Behaviour)_text).enabled = flag;
			if (!flag)
			{
				_wasReady = false;
				return;
			}
			ApplyPlacement();
			_timer += Time.unscaledDeltaTime;
			if (!_wasReady || _force || _timer >= 1f)
			{
				_wasReady = true;
				_force = false;
				_timer = 0f;
				string text = BuildText();
				if (text != _shown)
				{
					_shown = text;
					((TMP_Text)_text).text = text;
				}
				FitToMap();
			}
			SnapUnderMap();
		}

		private static bool IsReady()
		{
			if ((Object)(object)EnvMan.instance == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null)
			{
				return false;
			}
			Hud instance = Hud.instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_rootObject == (Object)null || !instance.m_rootObject.activeInHierarchy)
			{
				return false;
			}
			return ClockText.IsTimeReady(EnvMan.instance.GetDayFraction());
		}

		private string BuildText()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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)
			EnvMan instance = EnvMan.instance;
			string weather = "";
			EnvSetup currentEnvironment = instance.GetCurrentEnvironment();
			if (currentEnvironment != null && !string.IsNullOrEmpty(currentEnvironment.m_name))
			{
				weather = ((Localization.instance != null) ? Localization.instance.Localize(currentEnvironment.m_name) : currentEnvironment.m_name);
			}
			Vector3 windDir = instance.GetWindDir();
			return ClockText.Format(new ClockSnapshot
			{
				DayFraction = instance.GetDayFraction(),
				Day = instance.GetDay(),
				Weather = weather,
				WindX = windDir.x,
				WindZ = windDir.z,
				WindIntensity = instance.GetWindIntensity(),
				IsCold = EnvMan.IsCold(),
				IsWet = EnvMan.IsWet(),
				IsFreezing = EnvMan.IsFreezing()
			}, Plugin.CurrentOptions());
		}

		private void ApplyPlacement()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			string text = ClockText.NormalizeCorner(Plugin.Corner.Value);
			float value = Plugin.OffsetX.Value;
			float value2 = Plugin.OffsetY.Value;
			RectTransform rectTransform = ((TMP_Text)_text).rectTransform;
			if (TryGetMap(out var bottomRight, out var width))
			{
				_mapPoint = bottomRight;
				_hasMapPoint = true;
				_mapWidth = width;
			}
			float width2 = Mathf.Max(40f, _mapWidth - 8f);
			ApplyWidth(rectTransform, width2);
			if (text == "TopLeft")
			{
				SetCorner(rectTransform, 0f, (TextAlignmentOptions)257);
				rectTransform.anchoredPosition = new Vector2(24f + value, -24f + value2);
				return;
			}
			if (text == "TopCenter")
			{
				SetCorner(rectTransform, 0.5f, (TextAlignmentOptions)258);
				rectTransform.anchoredPosition = new Vector2(value, -24f + value2);
				return;
			}
			SetCorner(rectTransform, 1f, (TextAlignmentOptions)258);
			if (_hasMapPoint)
			{
				rectTransform.anchoredPosition = _mapPoint + new Vector2(value - 4f, value2);
			}
			else
			{
				rectTransform.anchoredPosition = new Vector2(-24f + value, -24f + value2);
			}
		}

		private void ApplyWidth(RectTransform rect, float width)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			Vector2 sizeDelta = rect.sizeDelta;
			if (Mathf.Abs(sizeDelta.x - width) > 0.5f)
			{
				sizeDelta.x = width;
				rect.sizeDelta = sizeDelta;
				_force = true;
			}
		}

		private void FitToMap()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(40f, ((TMP_Text)_text).rectTransform.sizeDelta.x);
			float num2 = ((_sourceFontSize > 0f) ? _sourceFontSize : 18f);
			((TMP_Text)_text).fontSize = Mathf.Clamp(num / 12f, 12f, num2);
			((TMP_Text)_text).textWrappingMode = (TextWrappingModes)0;
			for (int i = 0; i < 2; i++)
			{
				((TMP_Text)_text).ForceMeshUpdate(false, false);
				float preferredWidth = ((TMP_Text)_text).preferredWidth;
				if (preferredWidth <= num || preferredWidth <= 1f)
				{
					break;
				}
				((TMP_Text)_text).fontSize = Mathf.Max(11f, ((TMP_Text)_text).fontSize * (num / preferredWidth));
			}
			((TMP_Text)_text).ForceMeshUpdate(false, false);
			Vector2 sizeDelta = ((TMP_Text)_text).rectTransform.sizeDelta;
			sizeDelta.y = Mathf.Max(18f, ((TMP_Text)_text).preferredHeight);
			((TMP_Text)_text).rectTransform.sizeDelta = sizeDelta;
		}

		private void SnapUnderMap()
		{
			//IL_007e: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			if (_hasMapPoint && !(ClockText.NormalizeCorner(Plugin.Corner.Value) != "TopRight"))
			{
				((TMP_Text)_text).ForceMeshUpdate(false, false);
				float num = 0f;
				if (((TMP_Text)_text).textInfo != null && ((TMP_Text)_text).textInfo.lineCount > 0)
				{
					num = ((TMP_Text)_text).textInfo.lineInfo[0].ascender;
				}
				Vector2 anchoredPosition = ((TMP_Text)_text).rectTransform.anchoredPosition;
				anchoredPosition.y = _mapPoint.y - 2f - num + Plugin.OffsetY.Value;
				((TMP_Text)_text).rectTransform.anchoredPosition = anchoredPosition;
			}
		}

		private static void SetCorner(RectTransform rect, float anchorX, TextAlignmentOptions alignment)
		{
			//IL_000e: 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_001c: 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)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(anchorX, 1f);
			rect.anchorMin = val;
			rect.anchorMax = val;
			rect.pivot = val;
			((TMP_Text)((Component)rect).GetComponent<TextMeshProUGUI>()).alignment = alignment;
		}

		private static bool TryGetMap(out Vector2 bottomRight, out float width)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			bottomRight = Vector2.zero;
			width = 0f;
			Minimap instance = Minimap.instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_smallRoot == (Object)null || (Object)(object)Hud.instance == (Object)null || (Object)(object)Hud.instance.m_rootObject == (Object)null)
			{
				return false;
			}
			RectTransform val = null;
			if ((Object)(object)instance.m_mapImageSmall != (Object)null)
			{
				val = ((Graphic)instance.m_mapImageSmall).rectTransform;
			}
			Rect rect;
			if (!((Object)(object)val == (Object)null))
			{
				rect = val.rect;
				if (!(((Rect)(ref rect)).width < 1f))
				{
					goto IL_0097;
				}
			}
			val = instance.m_smallRoot.GetComponent<RectTransform>();
			goto IL_0097;
			IL_0097:
			RectTransform component = Hud.instance.m_rootObject.GetComponent<RectTransform>();
			if ((Object)(object)val == (Object)null || (Object)(object)component == (Object)null)
			{
				return false;
			}
			rect = val.rect;
			if (!(((Rect)(ref rect)).width < 1f))
			{
				rect = val.rect;
				if (!(((Rect)(ref rect)).height < 1f))
				{
					Vector3[] array = (Vector3[])(object)new Vector3[4];
					val.GetWorldCorners(array);
					Vector3 val2 = ((Transform)component).InverseTransformPoint(array[0]);
					Vector3 val3 = ((Transform)component).InverseTransformPoint(array[3]);
					Rect rect2 = component.rect;
					bottomRight = new Vector2(val3.x - ((Rect)(ref rect2)).xMax, val3.y - ((Rect)(ref rect2)).yMax);
					width = Mathf.Abs(val3.x - val2.x);
					return width >= 1f;
				}
			}
			return false;
		}

		private static ClockView FindView()
		{
			if ((Object)(object)Hud.instance == (Object)null || (Object)(object)Hud.instance.m_rootObject == (Object)null)
			{
				return null;
			}
			Transform val = Hud.instance.m_rootObject.transform.Find("GameClock");
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			return ((Component)val).GetComponent<ClockView>();
		}
	}
	[BepInPlugin("com.frizzqol.gameclock", "FrizzQOL Game Clock", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.frizzqol.gameclock";

		public const string PluginName = "FrizzQOL Game Clock";

		public const string PluginVersion = "0.1.0";

		internal static ConfigEntry<string> ClockFormat;

		internal static ConfigEntry<bool> ShowAmPm;

		internal static ConfigEntry<bool> ShowDay;

		internal static ConfigEntry<bool> ShowWeather;

		internal static ConfigEntry<bool> ShowWind;

		internal static ConfigEntry<bool> ShowCold;

		internal static ConfigEntry<bool> ShowWet;

		internal static ConfigEntry<bool> ShowFreezing;

		internal static ConfigEntry<string> Corner;

		internal static ConfigEntry<float> OffsetX;

		internal static ConfigEntry<float> OffsetY;

		private static string _loggedFormat;

		private static string _loggedCorner;

		private Harmony _harmony;

		internal static Plugin Instance { get; private set; }

		private void Awake()
		{
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			Instance = this;
			AcceptableValueList<string> acceptable = new AcceptableValueList<string>(new string[2] { "12h", "24h" });
			AcceptableValueList<string> acceptable2 = new AcceptableValueList<string>(new string[3] { "TopRight", "TopLeft", "TopCenter" });
			ClockFormat = Bind("ClockFormat", "12h", "12h or 24h. Example: 6:42 PM or 18:42.", (AcceptableValueBase)(object)acceptable);
			ShowAmPm = Bind("ShowAmPm", defaultValue: true, "Adds AM or PM in 12-hour mode. Unused in 24-hour mode.");
			ShowDay = Bind("ShowDay", defaultValue: true, "Shows the day number.");
			ShowWeather = Bind("ShowWeather", defaultValue: true, "Shows the current weather name.");
			ShowWind = Bind("ShowWind", defaultValue: true, "Shows wind direction and strength.");
			ShowCold = Bind("ShowCold", defaultValue: true, "Shows Cold while the world is cold.");
			ShowWet = Bind("ShowWet", defaultValue: true, "Shows Wet while the world is wet.");
			ShowFreezing = Bind("ShowFreezing", defaultValue: true, "Shows Freezing while the world is freezing.");
			Corner = Bind("Corner", "TopRight", "TopRight sits under the small minimap. TopLeft and TopCenter use that corner of the HUD.", (AcceptableValueBase)(object)acceptable2);
			OffsetX = Bind("OffsetX", 0f, "Pixels. Positive moves the label right.");
			OffsetY = Bind("OffsetY", 0f, "Pixels. Positive moves the label up.");
			_harmony = new Harmony("com.frizzqol.gameclock");
			try
			{
				_harmony.PatchAll();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"FrizzQOL Game Clock 0.1.0 loaded");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Harmony patch failed: " + ex.Message));
			}
		}

		internal static ClockOptions CurrentOptions()
		{
			string value = ClockFormat.Value;
			if (value != "12h" && value != "24h" && _loggedFormat != value)
			{
				_loggedFormat = value;
				LogWarning("ClockFormat '" + value + "' is not 12h or 24h. Using 12h.");
			}
			string value2 = Corner.Value;
			if (ClockText.NormalizeCorner(value2) != value2 && _loggedCorner != value2)
			{
				_loggedCorner = value2;
				LogWarning("Corner '" + value2 + "' is not TopRight, TopLeft, or TopCenter. Using TopRight.");
			}
			return new ClockOptions
			{
				Use24Hour = ClockText.Use24Hour(value),
				ShowAmPm = ShowAmPm.Value,
				ShowDay = ShowDay.Value,
				ShowWeather = ShowWeather.Value,
				ShowWind = ShowWind.Value,
				ShowCold = ShowCold.Value,
				ShowWet = ShowWet.Value,
				ShowFreezing = ShowFreezing.Value
			};
		}

		internal static void LogWarning(string message)
		{
			if ((Object)(object)Instance != (Object)null)
			{
				((BaseUnityPlugin)Instance).Logger.LogWarning((object)message);
			}
		}

		private ConfigEntry<T> Bind<T>(string key, T defaultValue, string description, AcceptableValueBase acceptable = null)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			ConfigEntry<T> obj = ((acceptable == null) ? ((BaseUnityPlugin)this).Config.Bind<T>("Display", key, defaultValue, description) : ((BaseUnityPlugin)this).Config.Bind<T>("Display", key, defaultValue, new ConfigDescription(description, acceptable, Array.Empty<object>())));
			obj.SettingChanged += delegate
			{
				ClockView.RequestRefresh();
			};
			return obj;
		}
	}
	[HarmonyPatch(typeof(Hud), "Awake")]
	internal static class HudAwakePatch
	{
		private static void Postfix(Hud __instance)
		{
			ClockView.Attach(__instance);
		}
	}
}