Decompiled source of HavensAlmanac v1.0.0

HavensAlmanac.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BirthdayReminder;
using BirthdayReminder.Data;
using HarmonyLib;
using HavenDevTools;
using HavensAlmanac.Config;
using HavensAlmanac.Data;
using HavensAlmanac.Integration;
using HavensAlmanac.UI;
using HavensBirthright;
using Microsoft.CodeAnalysis;
using SunHavenMuseumUtilityTracker;
using SunHavenMuseumUtilityTracker.Data;
using SunhavenMods.Shared;
using SunhavenTodo;
using SunhavenTodo.Data;
using TheVault;
using TheVault.Vault;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("HavensAlmanac")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+af039965a1880a192bb5ddf78776b738ccd4e046")]
[assembly: AssemblyProduct("HavensAlmanac")]
[assembly: AssemblyTitle("HavensAlmanac")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SunhavenMods.Shared
{
	public static class VersionChecker
	{
		public class VersionCheckResult
		{
			public bool Success { get; set; }

			public bool UpdateAvailable { get; set; }

			public string CurrentVersion { get; set; }

			public string LatestVersion { get; set; }

			public string ModName { get; set; }

			public string NexusUrl { get; set; }

			public string Changelog { get; set; }

			public string ErrorMessage { get; set; }
		}

		private class VersionCheckRunner : MonoBehaviour
		{
			public void StartCheck(string pluginGuid, string currentVersion, Action<VersionCheckResult> onComplete)
			{
				((MonoBehaviour)this).StartCoroutine(CheckVersionCoroutine(pluginGuid, currentVersion, onComplete));
			}

			private IEnumerator CheckVersionCoroutine(string pluginGuid, string currentVersion, Action<VersionCheckResult> onComplete)
			{
				VersionCheckResult result = new VersionCheckResult
				{
					CurrentVersion = currentVersion
				};
				UnityWebRequest www = UnityWebRequest.Get("https://azraelgodking.github.io/SunhavenMod/versions.json");
				try
				{
					www.timeout = 10;
					yield return www.SendWebRequest();
					if ((int)www.result == 2 || (int)www.result == 3)
					{
						result.Success = false;
						result.ErrorMessage = "Network error: " + www.error;
						LogWarning(result.ErrorMessage);
						onComplete?.Invoke(result);
						Object.Destroy((Object)(object)((Component)this).gameObject);
						yield break;
					}
					try
					{
						string json = www.downloadHandler.text;
						string modPattern = "\"" + Regex.Escape(pluginGuid) + "\"\\s*:\\s*\\{([^}]+)\\}";
						Match modMatch = Regex.Match(json, modPattern, RegexOptions.Singleline);
						if (!modMatch.Success)
						{
							result.Success = false;
							result.ErrorMessage = "Mod '" + pluginGuid + "' not found in versions.json";
							LogWarning(result.ErrorMessage);
							onComplete?.Invoke(result);
							Object.Destroy((Object)(object)((Component)this).gameObject);
							yield break;
						}
						string modJson = modMatch.Groups[1].Value;
						result.LatestVersion = ExtractJsonString(modJson, "version");
						result.ModName = ExtractJsonString(modJson, "name");
						result.NexusUrl = ExtractJsonString(modJson, "nexus");
						result.Changelog = ExtractJsonString(modJson, "changelog");
						if (string.IsNullOrEmpty(result.LatestVersion))
						{
							result.Success = false;
							result.ErrorMessage = "Could not parse version from response";
							LogWarning(result.ErrorMessage);
							onComplete?.Invoke(result);
							Object.Destroy((Object)(object)((Component)this).gameObject);
							yield break;
						}
						result.Success = true;
						result.UpdateAvailable = CompareVersions(currentVersion, result.LatestVersion) < 0;
						if (result.UpdateAvailable)
						{
							Log("Update available for " + result.ModName + ": " + currentVersion + " -> " + result.LatestVersion);
						}
						else
						{
							Log(result.ModName + " is up to date (v" + currentVersion + ")");
						}
					}
					catch (Exception ex)
					{
						result.Success = false;
						result.ErrorMessage = "Parse error: " + ex.Message;
						LogError(result.ErrorMessage);
					}
				}
				finally
				{
					((IDisposable)www)?.Dispose();
				}
				onComplete?.Invoke(result);
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}

			private string ExtractJsonString(string json, string key)
			{
				string pattern = "\"" + key + "\"\\s*:\\s*(?:\"([^\"]*)\"|null)";
				Match match = Regex.Match(json, pattern);
				return match.Success ? match.Groups[1].Value : null;
			}
		}

		private const string VersionsUrl = "https://azraelgodking.github.io/SunhavenMod/versions.json";

		private static ManualLogSource _logger;

		public static void CheckForUpdate(string pluginGuid, string currentVersion, ManualLogSource logger = null, Action<VersionCheckResult> onComplete = null)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			_logger = logger;
			VersionCheckRunner versionCheckRunner = new GameObject("VersionChecker").AddComponent<VersionCheckRunner>();
			Object.DontDestroyOnLoad((Object)(object)((Component)versionCheckRunner).gameObject);
			versionCheckRunner.StartCheck(pluginGuid, currentVersion, onComplete);
		}

		public static int CompareVersions(string v1, string v2)
		{
			if (string.IsNullOrEmpty(v1) || string.IsNullOrEmpty(v2))
			{
				return 0;
			}
			v1 = v1.TrimStart('v', 'V');
			v2 = v2.TrimStart('v', 'V');
			string[] array = v1.Split(new char[1] { '.' });
			string[] array2 = v2.Split(new char[1] { '.' });
			int num = Math.Max(array.Length, array2.Length);
			for (int i = 0; i < num; i++)
			{
				int result;
				int num2 = ((i < array.Length && int.TryParse(array[i], out result)) ? result : 0);
				int result2;
				int num3 = ((i < array2.Length && int.TryParse(array2[i], out result2)) ? result2 : 0);
				if (num2 < num3)
				{
					return -1;
				}
				if (num2 > num3)
				{
					return 1;
				}
			}
			return 0;
		}

		internal static void Log(string message)
		{
			ManualLogSource logger = _logger;
			if (logger != null)
			{
				logger.LogInfo((object)("[VersionChecker] " + message));
			}
		}

		internal static void LogWarning(string message)
		{
			ManualLogSource logger = _logger;
			if (logger != null)
			{
				logger.LogWarning((object)("[VersionChecker] " + message));
			}
		}

		internal static void LogError(string message)
		{
			ManualLogSource logger = _logger;
			if (logger != null)
			{
				logger.LogError((object)("[VersionChecker] " + message));
			}
		}
	}
	public static class VersionCheckerExtensions
	{
		public static void NotifyUpdateAvailable(this VersionChecker.VersionCheckResult result, ManualLogSource logger = null)
		{
			if (!result.UpdateAvailable)
			{
				return;
			}
			string text = result.ModName + " update available: v" + result.LatestVersion;
			try
			{
				Type type = ReflectionHelper.FindWishType("NotificationStack");
				if (type != null)
				{
					Type type2 = ReflectionHelper.FindType("SingletonBehaviour`1", "Wish");
					if (type2 != null)
					{
						Type type3 = type2.MakeGenericType(type);
						object obj = type3.GetProperty("Instance")?.GetValue(null);
						if (obj != null)
						{
							MethodInfo method = type.GetMethod("SendNotification", new Type[5]
							{
								typeof(string),
								typeof(int),
								typeof(int),
								typeof(bool),
								typeof(bool)
							});
							if (method != null)
							{
								method.Invoke(obj, new object[5] { text, 0, 1, false, true });
								return;
							}
						}
					}
				}
			}
			catch (Exception ex)
			{
				if (logger != null)
				{
					logger.LogWarning((object)("Failed to send native notification: " + ex.Message));
				}
			}
			if (logger != null)
			{
				logger.LogWarning((object)("[UPDATE AVAILABLE] " + text));
			}
			if (!string.IsNullOrEmpty(result.NexusUrl) && logger != null)
			{
				logger.LogWarning((object)("Download at: " + result.NexusUrl));
			}
		}
	}
	public static class ReflectionHelper
	{
		public static readonly BindingFlags AllBindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;

		public static Type FindType(string typeName, params string[] namespaces)
		{
			Type type = AccessTools.TypeByName(typeName);
			if (type != null)
			{
				return type;
			}
			foreach (string text in namespaces)
			{
				type = AccessTools.TypeByName(text + "." + typeName);
				if (type != null)
				{
					return type;
				}
			}
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				try
				{
					type = assembly.GetTypes().FirstOrDefault((Type t) => t.Name == typeName || t.FullName == typeName);
					if (type != null)
					{
						return type;
					}
				}
				catch (ReflectionTypeLoadException)
				{
				}
			}
			return null;
		}

		public static Type FindWishType(string typeName)
		{
			return FindType(typeName, "Wish");
		}

		public static object GetStaticValue(Type type, string memberName)
		{
			if (type == null)
			{
				return null;
			}
			PropertyInfo property = type.GetProperty(memberName, AllBindingFlags);
			if (property != null && property.GetMethod != null)
			{
				return property.GetValue(null);
			}
			FieldInfo field = type.GetField(memberName, AllBindingFlags);
			if (field != null)
			{
				return field.GetValue(null);
			}
			return null;
		}

		public static object GetSingletonInstance(Type type)
		{
			if (type == null)
			{
				return null;
			}
			string[] array = new string[5] { "Instance", "instance", "_instance", "Singleton", "singleton" };
			string[] array2 = array;
			foreach (string memberName in array2)
			{
				object staticValue = GetStaticValue(type, memberName);
				if (staticValue != null)
				{
					return staticValue;
				}
			}
			return null;
		}

		public static object GetInstanceValue(object instance, string memberName)
		{
			if (instance == null)
			{
				return null;
			}
			Type type = instance.GetType();
			while (type != null)
			{
				PropertyInfo property = type.GetProperty(memberName, AllBindingFlags);
				if (property != null && property.GetMethod != null)
				{
					return property.GetValue(instance);
				}
				FieldInfo field = type.GetField(memberName, AllBindingFlags);
				if (field != null)
				{
					return field.GetValue(instance);
				}
				type = type.BaseType;
			}
			return null;
		}

		public static bool SetInstanceValue(object instance, string memberName, object value)
		{
			if (instance == null)
			{
				return false;
			}
			Type type = instance.GetType();
			while (type != null)
			{
				PropertyInfo property = type.GetProperty(memberName, AllBindingFlags);
				if (property != null && property.SetMethod != null)
				{
					property.SetValue(instance, value);
					return true;
				}
				FieldInfo field = type.GetField(memberName, AllBindingFlags);
				if (field != null)
				{
					field.SetValue(instance, value);
					return true;
				}
				type = type.BaseType;
			}
			return false;
		}

		public static object InvokeMethod(object instance, string methodName, params object[] args)
		{
			if (instance == null)
			{
				return null;
			}
			Type type = instance.GetType();
			Type[] array = args?.Select((object a) => a?.GetType() ?? typeof(object)).ToArray() ?? Type.EmptyTypes;
			MethodInfo methodInfo = AccessTools.Method(type, methodName, array, (Type[])null);
			if (methodInfo == null)
			{
				methodInfo = type.GetMethod(methodName, AllBindingFlags);
			}
			if (methodInfo == null)
			{
				return null;
			}
			return methodInfo.Invoke(instance, args);
		}

		public static object InvokeStaticMethod(Type type, string methodName, params object[] args)
		{
			if (type == null)
			{
				return null;
			}
			Type[] array = args?.Select((object a) => a?.GetType() ?? typeof(object)).ToArray() ?? Type.EmptyTypes;
			MethodInfo methodInfo = AccessTools.Method(type, methodName, array, (Type[])null);
			if (methodInfo == null)
			{
				methodInfo = type.GetMethod(methodName, AllBindingFlags);
			}
			if (methodInfo == null)
			{
				return null;
			}
			return methodInfo.Invoke(null, args);
		}

		public static FieldInfo[] GetAllFields(Type type)
		{
			if (type == null)
			{
				return Array.Empty<FieldInfo>();
			}
			FieldInfo[] fields = type.GetFields(AllBindingFlags);
			IEnumerable<FieldInfo> second;
			if (!(type.BaseType != null) || !(type.BaseType != typeof(object)))
			{
				second = Enumerable.Empty<FieldInfo>();
			}
			else
			{
				IEnumerable<FieldInfo> allFields = GetAllFields(type.BaseType);
				second = allFields;
			}
			return fields.Concat(second).Distinct().ToArray();
		}

		public static PropertyInfo[] GetAllProperties(Type type)
		{
			if (type == null)
			{
				return Array.Empty<PropertyInfo>();
			}
			PropertyInfo[] properties = type.GetProperties(AllBindingFlags);
			IEnumerable<PropertyInfo> second;
			if (!(type.BaseType != null) || !(type.BaseType != typeof(object)))
			{
				second = Enumerable.Empty<PropertyInfo>();
			}
			else
			{
				IEnumerable<PropertyInfo> allProperties = GetAllProperties(type.BaseType);
				second = allProperties;
			}
			return (from p in properties.Concat(second)
				group p by p.Name into g
				select g.First()).ToArray();
		}

		public static T TryGetValue<T>(object instance, string memberName, T defaultValue = default(T))
		{
			try
			{
				object instanceValue = GetInstanceValue(instance, memberName);
				if (instanceValue is T result)
				{
					return result;
				}
				if (instanceValue != null && typeof(T).IsAssignableFrom(instanceValue.GetType()))
				{
					return (T)instanceValue;
				}
				return defaultValue;
			}
			catch
			{
				return defaultValue;
			}
		}
	}
	public static class GUIStyleHelper
	{
		public static class SunHavenColors
		{
			public static readonly Color Parchment = new Color(0.96f, 0.93f, 0.85f);

			public static readonly Color ParchmentDark = new Color(0.85f, 0.82f, 0.72f);

			public static readonly Color Wood = new Color(0.45f, 0.32f, 0.22f);

			public static readonly Color WoodLight = new Color(0.55f, 0.42f, 0.32f);

			public static readonly Color Gold = new Color(0.85f, 0.65f, 0.13f);

			public static readonly Color GoldDark = new Color(0.72f, 0.53f, 0.04f);

			public static readonly Color TextDark = new Color(0.2f, 0.15f, 0.1f);

			public static readonly Color TextLight = new Color(0.95f, 0.92f, 0.85f);

			public static readonly Color Success = new Color(0.2f, 0.6f, 0.2f);

			public static readonly Color Warning = new Color(0.8f, 0.6f, 0.2f);

			public static readonly Color Error = new Color(0.8f, 0.2f, 0.2f);

			public static readonly Color TransparentDark = new Color(0f, 0f, 0f, 0.7f);

			public static readonly Color TransparentLight = new Color(1f, 1f, 1f, 0.1f);
		}

		public static Texture2D MakeSolidTexture(Color color)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			val.SetPixel(0, 0, color);
			val.Apply();
			return val;
		}

		public static Texture2D MakeSolidTexture(int width, int height, Color color)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_001a: 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)
			Texture2D val = new Texture2D(width, height, (TextureFormat)4, false);
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = color;
			}
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		public static Texture2D MakeGradientTexture(int height, Color topColor, Color bottomColor)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_001b: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, height, (TextureFormat)4, false);
			for (int i = 0; i < height; i++)
			{
				float num = (float)i / (float)(height - 1);
				val.SetPixel(0, i, Color.Lerp(bottomColor, topColor, num));
			}
			val.Apply();
			return val;
		}

		public static Texture2D MakeBorderedTexture(int width, int height, Color fillColor, Color borderColor, int borderWidth = 1)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(width, height, (TextureFormat)4, false);
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < height; i++)
			{
				for (int j = 0; j < width; j++)
				{
					bool flag = j < borderWidth || j >= width - borderWidth || i < borderWidth || i >= height - borderWidth;
					array[i * width + j] = (flag ? borderColor : fillColor);
				}
			}
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		public static GUIStyle CreateWindowStyle(Texture2D background, int padding = 10)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_002a: 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_0039: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_004b: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.window);
			val.normal.background = background;
			val.onNormal.background = background;
			val.padding = new RectOffset(padding, padding, padding, padding);
			val.border = new RectOffset(4, 4, 4, 4);
			return val;
		}

		public static GUIStyle CreateLabelStyle(Color textColor, int fontSize = 14, TextAnchor alignment = 3, Texture2D background = null)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//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_0020: 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)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = fontSize,
				alignment = alignment,
				wordWrap = true
			};
			val.normal.textColor = textColor;
			GUIStyle val2 = val;
			if ((Object)(object)background != (Object)null)
			{
				val2.normal.background = background;
			}
			return val2;
		}

		public static GUIStyle CreateButtonStyle(Color textColor, Texture2D normalBg, Texture2D hoverBg = null, int fontSize = 14)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0026: 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_003a: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.button)
			{
				fontSize = fontSize,
				alignment = (TextAnchor)4
			};
			val.normal.textColor = textColor;
			val.normal.background = normalBg;
			val.hover.textColor = textColor;
			val.hover.background = hoverBg ?? normalBg;
			val.active.textColor = textColor;
			val.active.background = normalBg;
			return val;
		}

		public static GUIStyle CreateTextFieldStyle(Color textColor, Color bgColor, int fontSize = 14, int padding = 4)
		{
			//IL_0001: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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)
			//IL_002e: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			Texture2D background = MakeSolidTexture(bgColor);
			GUIStyle val = new GUIStyle(GUI.skin.textField)
			{
				fontSize = fontSize,
				padding = new RectOffset(padding, padding, padding, padding)
			};
			val.normal.textColor = textColor;
			val.normal.background = background;
			val.focused.textColor = textColor;
			val.focused.background = background;
			val.hover.textColor = textColor;
			val.hover.background = background;
			return val;
		}

		public static GUIStyle CreateHeaderStyle(Color textColor, int fontSize = 18, TextAnchor alignment = 4)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0021: 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)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = fontSize,
				fontStyle = (FontStyle)1,
				alignment = alignment
			};
			val.normal.textColor = textColor;
			return val;
		}

		public static GUIStyle CreateScrollViewStyle(Texture2D background)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.scrollView);
			val.normal.background = background;
			return val;
		}
	}
}
namespace HavensAlmanac
{
	[BepInPlugin("com.azraelgodking.havensalmanac", "Haven's Almanac", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__OnOvernightComplete;
		}

		private static AlmanacDataAggregator _staticAggregator;

		private static AlmanacHUD _staticHUD;

		private static AlmanacDashboard _staticDashboard;

		private static DailyBriefing _staticBriefing;

		private static GameObject _persistentRunner;

		private static AlmanacPersistentRunner _persistentRunnerComponent;

		private static bool _overnightHooked;

		private static UnityAction _overnightCallback;

		private Harmony _harmony;

		public static Plugin Instance { get; private set; }

		public static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Loading Haven's Almanac v1.0.0");
			AlmanacConfig.Initialize(((BaseUnityPlugin)this).Config);
			CreatePersistentRunner();
			_staticAggregator = new AlmanacDataAggregator();
			InitializeIntegrations();
			CreateUIComponents();
			ApplyPatches();
			SceneManager.sceneLoaded += OnSceneLoaded;
			if (AlmanacConfig.CheckForUpdates.Value)
			{
				VersionChecker.CheckForUpdate("com.azraelgodking.havensalmanac", "1.0.0", Log, delegate(VersionChecker.VersionCheckResult result)
				{
					result.NotifyUpdateAvailable(Log);
				});
			}
			Log.LogInfo((object)string.Format("{0} loaded with {1} mod(s) detected", "Haven's Almanac", _staticAggregator.InstalledModCount));
			if (_staticAggregator.InstalledModCount == 0)
			{
				Log.LogWarning((object)"No supported mods detected! Haven's Almanac requires at least one other mod to be useful.");
			}
		}

		private void CreatePersistentRunner()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			if (!((Object)(object)_persistentRunner != (Object)null) || !((Object)(object)_persistentRunnerComponent != (Object)null))
			{
				_persistentRunner = new GameObject("HavensAlmanac_PersistentRunner");
				Object.DontDestroyOnLoad((Object)(object)_persistentRunner);
				((Object)_persistentRunner).hideFlags = (HideFlags)61;
				_persistentRunnerComponent = _persistentRunner.AddComponent<AlmanacPersistentRunner>();
				Log.LogInfo((object)"[PersistentRunner] Created");
			}
		}

		private void InitializeIntegrations()
		{
			Dictionary<string, PluginInfo> pluginInfos = Chainloader.PluginInfos;
			TryRegisterProvider(pluginInfos, "com.azraelgodking.sunhaventodo", () => new TodoDataProvider(), "SunhavenTodo");
			TryRegisterProvider(pluginInfos, "com.azraelgodking.squirrelsbirthdayreminder", () => new BirthdayDataProvider(), "BirthdayReminder");
			TryRegisterProvider(pluginInfos, "com.azraelgodking.sunhavenmuseumutilitytracker", () => new MuseumDataProvider(), "S.M.U.T.");
			TryRegisterProvider(pluginInfos, "com.azraelgodking.senpaischest", () => new ChestDataProvider(), "SenpaisChest");
			TryRegisterProvider(pluginInfos, "com.azraelgodking.thevault", () => new VaultDataProvider(), "TheVault");
			TryRegisterProvider(pluginInfos, "com.azraelgodking.havensbirthright", () => new BirthrightDataProvider(), "HavensBirthright");
			TryRegisterProvider(pluginInfos, "com.azraelgodking.havendevtools", () => new DevToolsDataProvider(), "HavenDevTools");
		}

		private void TryRegisterProvider(Dictionary<string, PluginInfo> pluginInfos, string guid, Func<IModDataProvider> factory, string displayName)
		{
			try
			{
				if (pluginInfos.ContainsKey(guid))
				{
					_staticAggregator.RegisterProvider(factory());
					Log.LogInfo((object)("[Integration] " + displayName + " detected and registered"));
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("[Integration] Failed to load " + displayName + " provider: " + ex.Message));
			}
		}

		private void CreateUIComponents()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			try
			{
				GameObject val = new GameObject("HavensAlmanac_HUD");
				Object.DontDestroyOnLoad((Object)(object)val);
				_staticHUD = val.AddComponent<AlmanacHUD>();
				_staticHUD.Initialize(_staticAggregator);
				_staticHUD.OnPositionChanged = delegate(float x, float y)
				{
					AlmanacConfig.StaticHUDPositionX = x;
					AlmanacConfig.StaticHUDPositionY = y;
					ConfigEntry<float> hUDPositionX = AlmanacConfig.HUDPositionX;
					if (hUDPositionX != null)
					{
						((ConfigEntryBase)hUDPositionX).SetSerializedValue(x.ToString());
					}
					ConfigEntry<float> hUDPositionY = AlmanacConfig.HUDPositionY;
					if (hUDPositionY != null)
					{
						((ConfigEntryBase)hUDPositionY).SetSerializedValue(y.ToString());
					}
				};
				GameObject val2 = new GameObject("HavensAlmanac_Dashboard");
				Object.DontDestroyOnLoad((Object)(object)val2);
				_staticDashboard = val2.AddComponent<AlmanacDashboard>();
				_staticDashboard.Initialize(_staticAggregator);
				GameObject val3 = new GameObject("HavensAlmanac_Briefing");
				Object.DontDestroyOnLoad((Object)(object)val3);
				_staticBriefing = val3.AddComponent<DailyBriefing>();
				_staticBriefing.Initialize(_staticAggregator);
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"[UI] Error creating UI components: {arg}");
			}
		}

		public static void EnsureUIComponentsExist()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Expected O, but got Unknown
			try
			{
				if ((Object)(object)_persistentRunner == (Object)null || (Object)(object)_persistentRunnerComponent == (Object)null)
				{
					ManualLogSource log = Log;
					if (log != null)
					{
						log.LogInfo((object)"[EnsureUI] Recreating PersistentRunner...");
					}
					_persistentRunner = new GameObject("HavensAlmanac_PersistentRunner");
					Object.DontDestroyOnLoad((Object)(object)_persistentRunner);
					((Object)_persistentRunner).hideFlags = (HideFlags)61;
					_persistentRunnerComponent = _persistentRunner.AddComponent<AlmanacPersistentRunner>();
				}
				if ((Object)(object)_staticHUD == (Object)null)
				{
					ManualLogSource log2 = Log;
					if (log2 != null)
					{
						log2.LogInfo((object)"[EnsureUI] Recreating HUD...");
					}
					GameObject val = new GameObject("HavensAlmanac_HUD");
					Object.DontDestroyOnLoad((Object)(object)val);
					_staticHUD = val.AddComponent<AlmanacHUD>();
					_staticHUD.Initialize(_staticAggregator);
				}
				if ((Object)(object)_staticDashboard == (Object)null)
				{
					ManualLogSource log3 = Log;
					if (log3 != null)
					{
						log3.LogInfo((object)"[EnsureUI] Recreating Dashboard...");
					}
					GameObject val2 = new GameObject("HavensAlmanac_Dashboard");
					Object.DontDestroyOnLoad((Object)(object)val2);
					_staticDashboard = val2.AddComponent<AlmanacDashboard>();
					_staticDashboard.Initialize(_staticAggregator);
				}
				if ((Object)(object)_staticBriefing == (Object)null)
				{
					ManualLogSource log4 = Log;
					if (log4 != null)
					{
						log4.LogInfo((object)"[EnsureUI] Recreating Briefing...");
					}
					GameObject val3 = new GameObject("HavensAlmanac_Briefing");
					Object.DontDestroyOnLoad((Object)(object)val3);
					_staticBriefing = val3.AddComponent<DailyBriefing>();
					_staticBriefing.Initialize(_staticAggregator);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log5 = Log;
				if (log5 != null)
				{
					log5.LogError((object)("[EnsureUI] Error: " + ex.Message));
				}
			}
		}

		private void ApplyPatches()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			_harmony = new Harmony("com.azraelgodking.havensalmanac");
			try
			{
				Type type = AccessTools.TypeByName("Wish.Player");
				if (type != null)
				{
					MethodInfo methodInfo = AccessTools.Method(type, "InitializeAsOwner", (Type[])null, (Type[])null);
					if (methodInfo != null)
					{
						MethodInfo methodInfo2 = AccessTools.Method(typeof(Plugin), "OnPlayerInitialized", (Type[])null, (Type[])null);
						_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
						Log.LogInfo((object)"Applied player initialization patch");
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Failed to apply patches: " + ex.Message));
			}
		}

		private static void OnPlayerInitialized(object __instance)
		{
			try
			{
				ManualLogSource log = Log;
				if (log != null)
				{
					log.LogInfo((object)"[Almanac] Player initialized");
				}
				EnsureUIComponentsExist();
				_staticAggregator?.RefreshAll();
				ResetOvernightHook();
				TryHookOvernightEvent();
				_staticBriefing?.ShowBriefing();
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Log;
				if (log2 != null)
				{
					log2.LogError((object)("Error in OnPlayerInitialized: " + ex.Message));
				}
			}
		}

		public static void ResetOvernightHook()
		{
			_overnightHooked = false;
			_overnightCallback = null;
		}

		public static void TryHookOvernightEvent()
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Expected O, but got Unknown
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected O, but got Unknown
			if (_overnightHooked)
			{
				return;
			}
			try
			{
				Type type = AccessTools.TypeByName("Wish.DayCycle");
				if (type != null)
				{
					FieldInfo fieldInfo = AccessTools.Field(type, "OnDayStart");
					if (fieldInfo != null)
					{
						object? value = fieldInfo.GetValue(null);
						UnityAction val = (UnityAction)((value is UnityAction) ? value : null);
						object obj = <>O.<0>__OnOvernightComplete;
						if (obj == null)
						{
							UnityAction val2 = OnOvernightComplete;
							<>O.<0>__OnOvernightComplete = val2;
							obj = (object)val2;
						}
						_overnightCallback = (UnityAction)obj;
						if (val != null)
						{
							val = (UnityAction)Delegate.Combine((Delegate?)(object)val, (Delegate?)(object)_overnightCallback);
							fieldInfo.SetValue(null, val);
						}
						else
						{
							fieldInfo.SetValue(null, _overnightCallback);
						}
						_overnightHooked = true;
						ManualLogSource log = Log;
						if (log != null)
						{
							log.LogInfo((object)"Hooked into DayCycle.OnDayStart");
						}
						return;
					}
				}
				Type type2 = AccessTools.TypeByName("Wish.UIHandler");
				if (type2 == null)
				{
					return;
				}
				Type type3 = AccessTools.TypeByName("Wish.SingletonBehaviour`1");
				if (type3 == null)
				{
					return;
				}
				Type type4 = type3.MakeGenericType(type2);
				object obj2 = AccessTools.Property(type4, "Instance")?.GetValue(null);
				if (obj2 == null)
				{
					return;
				}
				FieldInfo fieldInfo2 = AccessTools.Field(type2, "OnCompleteOvernight");
				if (fieldInfo2 != null)
				{
					object? value2 = fieldInfo2.GetValue(obj2);
					UnityAction val3 = (UnityAction)((value2 is UnityAction) ? value2 : null);
					object obj3 = <>O.<0>__OnOvernightComplete;
					if (obj3 == null)
					{
						UnityAction val4 = OnOvernightComplete;
						<>O.<0>__OnOvernightComplete = val4;
						obj3 = (object)val4;
					}
					_overnightCallback = (UnityAction)obj3;
					if (val3 != null)
					{
						val3 = (UnityAction)Delegate.Combine((Delegate?)(object)val3, (Delegate?)(object)_overnightCallback);
						fieldInfo2.SetValue(obj2, val3);
					}
					else
					{
						fieldInfo2.SetValue(obj2, _overnightCallback);
					}
					_overnightHooked = true;
					ManualLogSource log2 = Log;
					if (log2 != null)
					{
						log2.LogInfo((object)"Hooked into UIHandler.OnCompleteOvernight");
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log3 = Log;
				if (log3 != null)
				{
					log3.LogWarning((object)("Failed to hook overnight event: " + ex.Message));
				}
			}
		}

		private static void OnOvernightComplete()
		{
			ManualLogSource log = Log;
			if (log != null)
			{
				log.LogInfo((object)"[Almanac] Day started - refreshing data and showing briefing");
			}
			_staticAggregator?.RefreshAll();
			_staticBriefing?.ShowBriefing();
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (((Scene)(ref scene)).name == "MainMenu" || ((Scene)(ref scene)).name == "Bootstrap")
			{
				Log.LogInfo((object)"[Almanac] Main menu detected - hiding UI");
				_staticHUD?.Hide();
				_staticDashboard?.Hide();
				_staticBriefing?.Hide();
			}
			else
			{
				EnsureUIComponentsExist();
				TryHookOvernightEvent();
			}
		}

		internal static AlmanacDataAggregator GetDataAggregator()
		{
			return _staticAggregator;
		}

		internal static AlmanacHUD GetAlmanacHUD()
		{
			return _staticHUD;
		}

		internal static AlmanacDashboard GetAlmanacDashboard()
		{
			return _staticDashboard;
		}

		internal static DailyBriefing GetDailyBriefing()
		{
			return _staticBriefing;
		}

		private void OnDestroy()
		{
			ManualLogSource log = Log;
			if (log != null)
			{
				log.LogInfo((object)"Plugin OnDestroy called - static references preserved");
			}
		}
	}
	public class AlmanacPersistentRunner : MonoBehaviour
	{
		private void Update()
		{
			DetectHotkeys();
		}

		private void DetectHotkeys()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			bool flag = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305);
			if (Input.GetKeyDown(AlmanacConfig.StaticDashboardToggleKey) && (!AlmanacConfig.StaticDashboardRequireCtrl || flag))
			{
				Plugin.EnsureUIComponentsExist();
				Plugin.GetAlmanacDashboard()?.Toggle();
			}
			if (Input.GetKeyDown(AlmanacConfig.StaticHUDToggleKey))
			{
				Plugin.EnsureUIComponentsExist();
				Plugin.GetAlmanacHUD()?.Toggle();
			}
		}

		private void OnDestroy()
		{
			ManualLogSource log = Plugin.Log;
			if (log != null)
			{
				log.LogWarning((object)"[PersistentRunner] OnDestroy called - this should NOT happen!");
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "com.azraelgodking.havensalmanac";

		public const string PLUGIN_NAME = "Haven's Almanac";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace HavensAlmanac.UI
{
	public class AlmanacDashboard : MonoBehaviour
	{
		private const int WINDOW_ID = 98781;

		private const float WIDTH = 500f;

		private const float HEIGHT = 550f;

		private AlmanacDataAggregator _aggregator;

		private Rect _windowRect;

		private bool _isVisible;

		private Vector2 _scrollPosition;

		private Dictionary<string, bool> _sectionExpanded = new Dictionary<string, bool>();

		private bool _stylesInitialized;

		private GUIStyle _windowStyle;

		private GUIStyle _titleStyle;

		private GUIStyle _sectionHeaderStyle;

		private GUIStyle _sectionHeaderExpandedStyle;

		private GUIStyle _contentStyle;

		private GUIStyle _closeButtonStyle;

		private GUIStyle _noModsStyle;

		private Texture2D _bgTexture;

		private Texture2D _sectionBgTexture;

		private Texture2D _sectionExpandedBgTexture;

		public bool IsVisible => _isVisible;

		public void Initialize(AlmanacDataAggregator aggregator)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			_aggregator = aggregator;
			_windowRect = new Rect(((float)Screen.width - 500f) / 2f, ((float)Screen.height - 550f) / 2f, 500f, 550f);
		}

		public void Show()
		{
			_aggregator?.RefreshAll();
			_isVisible = true;
		}

		public void Hide()
		{
			_isVisible = false;
		}

		public void Toggle()
		{
			if (_isVisible)
			{
				Hide();
			}
			else
			{
				Show();
			}
		}

		private void Update()
		{
			if (_isVisible && Input.GetKeyDown((KeyCode)27))
			{
				Hide();
			}
		}

		private void OnGUI()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (_isVisible && _aggregator != null)
			{
				if (!_stylesInitialized)
				{
					InitializeStyles();
				}
				_windowRect = GUI.Window(98781, _windowRect, new WindowFunction(DrawWindow), "", _windowStyle);
			}
		}

		private void DrawWindow(int id)
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Haven's Almanac - Dashboard", _titleStyle, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("X", _closeButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(24f),
				GUILayout.Height(24f)
			}))
			{
				Hide();
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(6f);
			if (_aggregator.InstalledModCount == 0)
			{
				GUILayout.Label("No mods detected. Install at least one supported mod to see data here.", _noModsStyle, Array.Empty<GUILayoutOption>());
				GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _windowRect)).width, 30f));
				return;
			}
			_scrollPosition = GUILayout.BeginScrollView(_scrollPosition, Array.Empty<GUILayoutOption>());
			foreach (IModDataProvider provider in _aggregator.Providers)
			{
				if (!_sectionExpanded.ContainsKey(provider.ModName))
				{
					_sectionExpanded[provider.ModName] = true;
				}
				bool flag = _sectionExpanded[provider.ModName];
				GUIStyle val = (flag ? _sectionHeaderExpandedStyle : _sectionHeaderStyle);
				string text = (flag ? "▼" : "▶");
				if (GUILayout.Button(text + "  " + provider.ModIcon + "  " + provider.ModName + "  —  " + provider.HudSummary, val, Array.Empty<GUILayoutOption>()))
				{
					_sectionExpanded[provider.ModName] = !flag;
				}
				if (flag)
				{
					GUILayout.BeginVertical(_contentStyle, Array.Empty<GUILayoutOption>());
					try
					{
						provider.DrawDashboardSection();
					}
					catch (Exception ex)
					{
						GUILayout.Label("Error: " + ex.Message, Array.Empty<GUILayoutOption>());
					}
					GUILayout.EndVertical();
				}
				GUILayout.Space(4f);
			}
			GUILayout.EndScrollView();
			GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _windowRect)).width, 30f));
		}

		private void InitializeStyles()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_00cd: 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_00dc: Expected O, but got Unknown
			//IL_00e2: Expected O, but got Unknown
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			//IL_018e: Expected O, but got Unknown
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Expected O, but got Unknown
			//IL_0242: Expected O, but got Unknown
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Expected O, but got Unknown
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Expected O, but got Unknown
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			_stylesInitialized = true;
			Color color = default(Color);
			((Color)(ref color))..ctor(0.12f, 0.1f, 0.08f, 0.96f);
			Color color2 = default(Color);
			((Color)(ref color2))..ctor(0.18f, 0.15f, 0.11f, 0.9f);
			Color color3 = default(Color);
			((Color)(ref color3))..ctor(0.22f, 0.18f, 0.13f, 0.9f);
			Color textColor = default(Color);
			((Color)(ref textColor))..ctor(0.95f, 0.85f, 0.55f);
			Color textColor2 = default(Color);
			((Color)(ref textColor2))..ctor(0.91f, 0.87f, 0.82f);
			_bgTexture = GUIStyleHelper.MakeSolidTexture(color);
			_sectionBgTexture = GUIStyleHelper.MakeSolidTexture(color2);
			_sectionExpandedBgTexture = GUIStyleHelper.MakeSolidTexture(color3);
			_windowStyle = new GUIStyle(GUI.skin.window)
			{
				padding = new RectOffset(12, 12, 10, 10),
				border = new RectOffset(2, 2, 2, 2)
			};
			_windowStyle.normal.background = _bgTexture;
			_windowStyle.onNormal.background = _bgTexture;
			_titleStyle = new GUIStyle(GUI.skin.label)
			{
				fontStyle = (FontStyle)1,
				fontSize = 16,
				alignment = (TextAnchor)3
			};
			_titleStyle.normal.textColor = textColor;
			_sectionHeaderStyle = new GUIStyle(GUI.skin.button)
			{
				fontStyle = (FontStyle)1,
				fontSize = 13,
				alignment = (TextAnchor)3,
				padding = new RectOffset(8, 8, 6, 6)
			};
			_sectionHeaderStyle.normal.background = _sectionBgTexture;
			_sectionHeaderStyle.normal.textColor = textColor2;
			_sectionHeaderStyle.hover.background = _sectionExpandedBgTexture;
			_sectionHeaderStyle.hover.textColor = textColor;
			_sectionHeaderExpandedStyle = new GUIStyle(_sectionHeaderStyle);
			_sectionHeaderExpandedStyle.normal.background = _sectionExpandedBgTexture;
			_sectionHeaderExpandedStyle.normal.textColor = textColor;
			_contentStyle = new GUIStyle(GUI.skin.box)
			{
				padding = new RectOffset(12, 12, 8, 8)
			};
			_contentStyle.normal.textColor = textColor2;
			_closeButtonStyle = new GUIStyle(GUI.skin.button)
			{
				fontStyle = (FontStyle)1,
				fontSize = 14,
				alignment = (TextAnchor)4
			};
			_noModsStyle = new GUIStyle(GUI.skin.label)
			{
				fontSize = 13,
				fontStyle = (FontStyle)2,
				alignment = (TextAnchor)4,
				wordWrap = true
			};
			_noModsStyle.normal.textColor = new Color(0.7f, 0.6f, 0.5f);
		}

		private void OnDestroy()
		{
			if ((Object)(object)_bgTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_bgTexture);
			}
			if ((Object)(object)_sectionBgTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_sectionBgTexture);
			}
			if ((Object)(object)_sectionExpandedBgTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_sectionExpandedBgTexture);
			}
		}
	}
	public class AlmanacHUD : MonoBehaviour
	{
		private const int WINDOW_ID = 98780;

		private const float WIDTH = 260f;

		private const float MIN_HEIGHT = 60f;

		private const float REFRESH_INTERVAL = 5f;

		private AlmanacDataAggregator _aggregator;

		private Rect _windowRect;

		private bool _isVisible = true;

		private float _refreshTimer;

		private bool _stylesInitialized;

		private GUIStyle _windowStyle;

		private GUIStyle _titleStyle;

		private GUIStyle _iconStyle;

		private GUIStyle _summaryStyle;

		private GUIStyle _noModsStyle;

		private Texture2D _bgTexture;

		private Texture2D _headerTexture;

		public Action<float, float> OnPositionChanged;

		public bool IsVisible => _isVisible;

		public void Initialize(AlmanacDataAggregator aggregator)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			_aggregator = aggregator;
			float num = AlmanacConfig.StaticHUDPositionX;
			float num2 = AlmanacConfig.StaticHUDPositionY;
			if (num < 0f || num2 < 0f)
			{
				num = (float)Screen.width - 260f - 20f;
				num2 = 80f;
			}
			_windowRect = new Rect(num, num2, 260f, 60f);
		}

		public void Show()
		{
			_isVisible = true;
		}

		public void Hide()
		{
			_isVisible = false;
		}

		public void Toggle()
		{
			_isVisible = !_isVisible;
		}

		public void SetPosition(float x, float y)
		{
			((Rect)(ref _windowRect)).x = x;
			((Rect)(ref _windowRect)).y = y;
		}

		private void Update()
		{
			if (_isVisible && _aggregator != null)
			{
				_refreshTimer += Time.unscaledDeltaTime;
				if (_refreshTimer >= 5f)
				{
					_refreshTimer = 0f;
					_aggregator.RefreshAll();
				}
			}
		}

		private void OnGUI()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			if (!_isVisible || !AlmanacConfig.StaticHUDEnabled || _aggregator == null)
			{
				return;
			}
			AlmanacDashboard almanacDashboard = Plugin.GetAlmanacDashboard();
			DailyBriefing dailyBriefing = Plugin.GetDailyBriefing();
			if ((!((Object)(object)almanacDashboard != (Object)null) || !almanacDashboard.IsVisible) && (!((Object)(object)dailyBriefing != (Object)null) || !dailyBriefing.IsVisible))
			{
				if (!_stylesInitialized)
				{
					InitializeStyles();
				}
				_windowRect = GUI.Window(98780, _windowRect, new WindowFunction(DrawWindow), "", _windowStyle);
				ClampToScreen();
			}
		}

		private void DrawWindow(int id)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Haven's Almanac", _titleStyle, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("x", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(18f),
				GUILayout.Height(18f)
			}))
			{
				Hide();
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(2f);
			if (_aggregator.InstalledModCount == 0)
			{
				GUILayout.Label("No mods detected", _noModsStyle, Array.Empty<GUILayoutOption>());
			}
			else
			{
				foreach (IModDataProvider provider in _aggregator.Providers)
				{
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					GUILayout.Label(provider.ModIcon, _iconStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(22f) });
					GUILayout.Label(provider.ModName + ": " + provider.HudSummary, _summaryStyle, Array.Empty<GUILayoutOption>());
					GUILayout.EndHorizontal();
				}
			}
			GUI.DragWindow();
		}

		private void ClampToScreen()
		{
			float x = ((Rect)(ref _windowRect)).x;
			float y = ((Rect)(ref _windowRect)).y;
			((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 0f, (float)Screen.width - ((Rect)(ref _windowRect)).width);
			((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 0f, (float)Screen.height - ((Rect)(ref _windowRect)).height);
			if (Math.Abs(x - ((Rect)(ref _windowRect)).x) > 1f || Math.Abs(y - ((Rect)(ref _windowRect)).y) > 1f)
			{
				OnPositionChanged?.Invoke(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y);
			}
		}

		private void InitializeStyles()
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00b7: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Expected O, but got Unknown
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			_stylesInitialized = true;
			Color color = default(Color);
			((Color)(ref color))..ctor(0.18f, 0.14f, 0.1f, 0.92f);
			Color color2 = default(Color);
			((Color)(ref color2))..ctor(0.22f, 0.17f, 0.12f, 0.95f);
			Color textColor = default(Color);
			((Color)(ref textColor))..ctor(0.95f, 0.85f, 0.55f);
			Color textColor2 = default(Color);
			((Color)(ref textColor2))..ctor(0.91f, 0.87f, 0.82f);
			_bgTexture = GUIStyleHelper.MakeSolidTexture(color);
			_headerTexture = GUIStyleHelper.MakeSolidTexture(color2);
			_windowStyle = new GUIStyle(GUI.skin.window)
			{
				padding = new RectOffset(8, 8, 6, 6),
				border = new RectOffset(2, 2, 2, 2)
			};
			_windowStyle.normal.background = _bgTexture;
			_windowStyle.onNormal.background = _bgTexture;
			_titleStyle = new GUIStyle(GUI.skin.label)
			{
				fontStyle = (FontStyle)1,
				fontSize = 13,
				alignment = (TextAnchor)3
			};
			_titleStyle.normal.textColor = textColor;
			_iconStyle = new GUIStyle(GUI.skin.label)
			{
				fontSize = 14,
				alignment = (TextAnchor)4
			};
			_summaryStyle = new GUIStyle(GUI.skin.label)
			{
				fontSize = 12,
				alignment = (TextAnchor)3
			};
			_summaryStyle.normal.textColor = textColor2;
			_noModsStyle = new GUIStyle(GUI.skin.label)
			{
				fontSize = 11,
				fontStyle = (FontStyle)2,
				alignment = (TextAnchor)4
			};
			_noModsStyle.normal.textColor = new Color(0.7f, 0.6f, 0.5f);
		}

		private void OnDestroy()
		{
			if ((Object)(object)_bgTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_bgTexture);
			}
			if ((Object)(object)_headerTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_headerTexture);
			}
		}
	}
	public class DailyBriefing : MonoBehaviour
	{
		private const int WINDOW_ID = 98782;

		private const float WIDTH = 500f;

		private const float MIN_HEIGHT = 250f;

		private AlmanacDataAggregator _aggregator;

		private Rect _windowRect;

		private bool _isVisible;

		private float _contentHeight = 250f;

		private bool _stylesInitialized;

		private GUIStyle _windowStyle;

		private GUIStyle _titleStyle;

		private GUIStyle _sectionTitleStyle;

		private GUIStyle _contentStyle;

		private GUIStyle _dismissButtonStyle;

		private Texture2D _bgTexture;

		public bool IsVisible => _isVisible;

		public void Initialize(AlmanacDataAggregator aggregator)
		{
			_aggregator = aggregator;
			CenterWindow();
		}

		public void ShowBriefing()
		{
			if (!AlmanacConfig.StaticBriefingEnabled || _aggregator == null || _aggregator.InstalledModCount == 0)
			{
				return;
			}
			_aggregator.RefreshAll();
			bool flag = false;
			foreach (IModDataProvider provider in _aggregator.Providers)
			{
				if (provider.IsReady)
				{
					flag = true;
					break;
				}
			}
			if (flag)
			{
				CenterWindow();
				_isVisible = true;
			}
		}

		public void Hide()
		{
			_isVisible = false;
		}

		private void CenterWindow()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			_windowRect = new Rect(((float)Screen.width - 500f) / 2f, ((float)Screen.height - 250f) / 2f - 50f, 500f, 250f);
		}

		private void Update()
		{
			if (_isVisible && Input.GetKeyDown((KeyCode)27))
			{
				Hide();
			}
		}

		private void OnGUI()
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			if (_isVisible && _aggregator != null)
			{
				if (!_stylesInitialized)
				{
					InitializeStyles();
				}
				float num = (float)Screen.height - 60f;
				((Rect)(ref _windowRect)).height = Mathf.Clamp(_contentHeight, 250f, num);
				((Rect)(ref _windowRect)).x = ((float)Screen.width - ((Rect)(ref _windowRect)).width) / 2f;
				((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 20f, (float)Screen.height - ((Rect)(ref _windowRect)).height - 20f);
				_windowRect = GUI.Window(98782, _windowRect, new WindowFunction(DrawWindow), "", _windowStyle);
			}
		}

		private void DrawWindow(int id)
		{
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Invalid comparison between Unknown and I4
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label("Good Morning!", _titleStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			bool flag = false;
			foreach (IModDataProvider provider in _aggregator.Providers)
			{
				if (!provider.IsReady)
				{
					continue;
				}
				try
				{
					GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
					GUILayout.Label(provider.ModIcon + " " + provider.ModName, _sectionTitleStyle, Array.Empty<GUILayoutOption>());
					bool flag2 = provider.DrawBriefingSection();
					GUILayout.EndVertical();
					if (flag2)
					{
						flag = true;
						GUILayout.Space(6f);
					}
				}
				catch
				{
					GUILayout.EndVertical();
				}
			}
			if (!flag)
			{
				GUILayout.Label("Nothing noteworthy today. Have a great day!", _contentStyle, Array.Empty<GUILayoutOption>());
			}
			GUILayout.Space(10f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("Dismiss", _dismissButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(120f),
				GUILayout.Height(30f)
			}))
			{
				Hide();
			}
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			if ((int)Event.current.type == 7)
			{
				Rect lastRect = GUILayoutUtility.GetLastRect();
				_contentHeight = ((Rect)(ref lastRect)).yMax + 28f;
			}
			GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _windowRect)).width, 30f));
		}

		private void InitializeStyles()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_00aa: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_0111: 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_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Expected O, but got Unknown
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Expected O, but got Unknown
			_stylesInitialized = true;
			Color color = default(Color);
			((Color)(ref color))..ctor(0.15f, 0.12f, 0.09f, 0.96f);
			Color textColor = default(Color);
			((Color)(ref textColor))..ctor(0.95f, 0.85f, 0.55f);
			Color textColor2 = default(Color);
			((Color)(ref textColor2))..ctor(0.91f, 0.87f, 0.82f);
			Color val = default(Color);
			((Color)(ref val))..ctor(0.6f, 0.55f, 0.45f);
			_bgTexture = GUIStyleHelper.MakeSolidTexture(color);
			_windowStyle = new GUIStyle(GUI.skin.window)
			{
				padding = new RectOffset(16, 16, 12, 12),
				border = new RectOffset(2, 2, 2, 2)
			};
			_windowStyle.normal.background = _bgTexture;
			_windowStyle.onNormal.background = _bgTexture;
			_titleStyle = new GUIStyle(GUI.skin.label)
			{
				fontStyle = (FontStyle)1,
				fontSize = 18,
				alignment = (TextAnchor)4
			};
			_titleStyle.normal.textColor = textColor;
			_sectionTitleStyle = new GUIStyle(GUI.skin.label)
			{
				fontStyle = (FontStyle)1,
				fontSize = 13
			};
			_sectionTitleStyle.normal.textColor = textColor;
			_contentStyle = new GUIStyle(GUI.skin.label)
			{
				fontSize = 12,
				fontStyle = (FontStyle)2,
				alignment = (TextAnchor)4,
				wordWrap = true
			};
			_contentStyle.normal.textColor = textColor2;
			_dismissButtonStyle = new GUIStyle(GUI.skin.button)
			{
				fontSize = 13,
				fontStyle = (FontStyle)1
			};
		}

		private void OnDestroy()
		{
			if ((Object)(object)_bgTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_bgTexture);
			}
		}
	}
}
namespace HavensAlmanac.Integration
{
	public class BirthdayDataProvider : IModDataProvider
	{
		private List<BirthdayDisplayInfo> _birthdays = new List<BirthdayDisplayInfo>();

		private int _ungiftedCount;

		private string _hudSummary = "Loading...";

		private bool _isReady;

		public string ModName => "Birthday";

		public string ModIcon => "★";

		public string HudSummary => _hudSummary;

		public bool IsReady => _isReady;

		public void Refresh()
		{
			try
			{
				BirthdayManager manager = Plugin.GetManager();
				if (manager == null)
				{
					_isReady = false;
					return;
				}
				_birthdays = manager.TodaysBirthdays ?? new List<BirthdayDisplayInfo>();
				_ungiftedCount = 0;
				foreach (BirthdayDisplayInfo birthday in _birthdays)
				{
					if (!birthday.HasBeenGifted)
					{
						_ungiftedCount++;
					}
				}
				if (_birthdays.Count == 0)
				{
					_hudSummary = "No birthdays";
				}
				else
				{
					_hudSummary = string.Format("{0} birthday{1} / {2} ungifted", _birthdays.Count, (_birthdays.Count != 1) ? "s" : "", _ungiftedCount);
				}
				_isReady = true;
			}
			catch (Exception ex)
			{
				_hudSummary = "Error";
				_isReady = false;
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("[BirthdayProvider] Refresh error: " + ex.Message));
				}
			}
		}

		public void DrawDashboardSection()
		{
			if (_birthdays.Count == 0)
			{
				GUILayout.Label("No birthdays today.", Array.Empty<GUILayoutOption>());
				return;
			}
			GUILayout.Label($"Today's Birthdays ({_birthdays.Count}):", Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			foreach (BirthdayDisplayInfo birthday in _birthdays)
			{
				string text = (birthday.HasBeenGifted ? " [Gifted]" : " [Not gifted]");
				GUILayout.Label("  " + birthday.NPCName + text, Array.Empty<GUILayoutOption>());
				if (!string.IsNullOrEmpty(birthday.GiftHint))
				{
					GUILayout.Label("    " + birthday.GiftHint, Array.Empty<GUILayoutOption>());
				}
			}
		}

		public bool DrawBriefingSection()
		{
			if (_birthdays.Count == 0)
			{
				return false;
			}
			foreach (BirthdayDisplayInfo birthday in _birthdays)
			{
				string text = (birthday.HasBeenGifted ? " (gifted)" : "");
				GUILayout.Label("  It's " + birthday.NPCName + "'s birthday!" + text, Array.Empty<GUILayoutOption>());
			}
			if (_ungiftedCount > 0)
			{
				GUILayout.Label("  Don't forget to bring a gift!", Array.Empty<GUILayoutOption>());
			}
			return true;
		}
	}
	public class BirthrightDataProvider : IModDataProvider
	{
		private string _raceName = "None";

		private int _bonusCount;

		private List<RacialBonus> _bonuses = new List<RacialBonus>();

		private string _hudSummary = "Loading...";

		private bool _isReady;

		public string ModName => "Birthright";

		public string ModIcon => "⚔";

		public string HudSummary => _hudSummary;

		public bool IsReady => _isReady;

		public void Refresh()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				RacialBonusManager racialBonusManager = Plugin.GetRacialBonusManager();
				if (racialBonusManager == null)
				{
					_isReady = false;
					return;
				}
				Race? playerRace = racialBonusManager.GetPlayerRace();
				if (playerRace.HasValue)
				{
					Race value = playerRace.Value;
					_raceName = ((object)(Race)(ref value)).ToString();
					_bonuses = racialBonusManager.GetCurrentPlayerBonuses() ?? new List<RacialBonus>();
					_bonusCount = _bonuses.Count;
					_hudSummary = string.Format("{0} ({1} bonus{2})", _raceName, _bonusCount, (_bonusCount != 1) ? "es" : "");
				}
				else
				{
					_raceName = "None";
					_bonusCount = 0;
					_bonuses.Clear();
					_hudSummary = "No race set";
				}
				_isReady = true;
			}
			catch (Exception ex)
			{
				_hudSummary = "Error";
				_isReady = false;
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("[BirthrightProvider] Refresh error: " + ex.Message));
				}
			}
		}

		public void DrawDashboardSection()
		{
			GUILayout.Label("Race: " + _raceName, Array.Empty<GUILayoutOption>());
			if (_bonusCount == 0)
			{
				GUILayout.Label("No active bonuses.", Array.Empty<GUILayoutOption>());
				return;
			}
			GUILayout.Label($"Active Bonuses ({_bonusCount}):", Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			foreach (RacialBonus bonuse in _bonuses)
			{
				string formattedValue = bonuse.GetFormattedValue();
				GUILayout.Label("  " + bonuse.Description + ": " + formattedValue, Array.Empty<GUILayoutOption>());
			}
		}

		public bool DrawBriefingSection()
		{
			return false;
		}
	}
	public class ChestDataProvider : IModDataProvider
	{
		private int _smartChestCount;

		private string _hudSummary = "Loading...";

		private bool _isReady;

		public string ModName => "Chests";

		public string ModIcon => "▣";

		public string HudSummary => _hudSummary;

		public bool IsReady => _isReady;

		public void Refresh()
		{
			try
			{
				Type type = ReflectionHelper.FindType("SenpaisChest.Plugin");
				if (type == null)
				{
					_isReady = false;
					return;
				}
				object obj = ReflectionHelper.InvokeStaticMethod(type, "GetManager");
				if (obj == null)
				{
					_isReady = false;
					return;
				}
				object obj2 = ReflectionHelper.InvokeMethod(obj, "GetSaveData");
				if (obj2 != null)
				{
					object instanceValue = ReflectionHelper.GetInstanceValue(obj2, "ChestConfigs");
					if (instanceValue is ICollection collection)
					{
						_smartChestCount = collection.Count;
					}
					else
					{
						_smartChestCount = 0;
					}
				}
				else
				{
					_smartChestCount = 0;
				}
				_hudSummary = ((_smartChestCount == 0) ? "No smart chests" : string.Format("{0} smart chest{1}", _smartChestCount, (_smartChestCount != 1) ? "s" : ""));
				_isReady = true;
			}
			catch (Exception ex)
			{
				_hudSummary = "Error";
				_isReady = false;
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("[ChestProvider] Refresh error: " + ex.Message));
				}
			}
		}

		public void DrawDashboardSection()
		{
			GUILayout.Label($"Configured Smart Chests: {_smartChestCount}", Array.Empty<GUILayoutOption>());
		}

		public bool DrawBriefingSection()
		{
			return false;
		}
	}
	public class DevToolsDataProvider : IModDataProvider
	{
		private bool _isAuthorized;

		private string _playerName = "";

		private string _hudSummary = "Loading...";

		private bool _isReady;

		public string ModName => "DevTools";

		public string ModIcon => "⚒";

		public string HudSummary => _hudSummary;

		public bool IsReady => _isReady;

		public void Refresh()
		{
			try
			{
				_isAuthorized = Plugin.IsAuthorized;
				_playerName = Plugin.CurrentPlayerName ?? "";
				_hudSummary = (_isAuthorized ? "Active" : "Inactive");
				_isReady = true;
			}
			catch (Exception ex)
			{
				_hudSummary = "Error";
				_isReady = false;
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("[DevToolsProvider] Refresh error: " + ex.Message));
				}
			}
		}

		public void DrawDashboardSection()
		{
			GUILayout.Label("Status: " + (_isAuthorized ? "Authorized" : "Not Authorized"), Array.Empty<GUILayoutOption>());
			if (!string.IsNullOrEmpty(_playerName))
			{
				GUILayout.Label("Player: " + _playerName, Array.Empty<GUILayoutOption>());
			}
		}

		public bool DrawBriefingSection()
		{
			return false;
		}
	}
	public class MuseumDataProvider : IModDataProvider
	{
		private int _donated;

		private int _total;

		private float _completionPercent;

		private int _neededCount;

		private string _hudSummary = "Loading...";

		private bool _isReady;

		public string ModName => "Museum";

		public string ModIcon => "⌂";

		public string HudSummary => _hudSummary;

		public bool IsReady => _isReady;

		public void Refresh()
		{
			try
			{
				DonationManager donationManager = Plugin.GetDonationManager();
				if (donationManager == null || !donationManager.IsLoaded)
				{
					_isReady = false;
					return;
				}
				(int, int) overallStats = donationManager.GetOverallStats();
				_donated = overallStats.Item1;
				_total = overallStats.Item2;
				_completionPercent = donationManager.GetOverallCompletionPercent();
				_neededCount = donationManager.GetAllNeededItems()?.Count ?? 0;
				_hudSummary = $"{_completionPercent:F0}% ({_donated}/{_total})";
				_isReady = true;
			}
			catch (Exception ex)
			{
				_hudSummary = "Error";
				_isReady = false;
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("[MuseumProvider] Refresh error: " + ex.Message));
				}
			}
		}

		public void DrawDashboardSection()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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)
			GUILayout.Label($"Donated: {_donated} / {_total}", Array.Empty<GUILayoutOption>());
			Rect rect = GUILayoutUtility.GetRect(0f, 16f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			GUI.Box(rect, "");
			if (_total > 0)
			{
				float num = (float)_donated / (float)_total;
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((Rect)(ref rect)).x + 1f, ((Rect)(ref rect)).y + 1f, (((Rect)(ref rect)).width - 2f) * num, ((Rect)(ref rect)).height - 2f);
				GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture);
			}
			GUILayout.Label($"{_completionPercent:F1}% complete", Array.Empty<GUILayoutOption>());
			if (_neededCount > 0)
			{
				GUILayout.Label($"{_neededCount} items still needed", Array.Empty<GUILayoutOption>());
			}
		}

		public bool DrawBriefingSection()
		{
			GUILayout.Label($"Museum: {_completionPercent:F0}% complete ({_donated}/{_total})", Array.Empty<GUILayoutOption>());
			if (_neededCount > 0)
			{
				GUILayout.Label($"  {_neededCount} items still needed", Array.Empty<GUILayoutOption>());
			}
			return true;
		}
	}
	public class TodoDataProvider : IModDataProvider
	{
		private int _activeCount;

		private int _totalCount;

		private int _completedCount;

		private float _completionPercent;

		private List<TodoItem> _highPriorityItems = new List<TodoItem>();

		private string _hudSummary = "Loading...";

		private bool _isReady;

		public string ModName => "Todo";

		public string ModIcon => "✎";

		public string HudSummary => _hudSummary;

		public bool IsReady => _isReady;

		public void Refresh()
		{
			try
			{
				TodoManager todoManager = Plugin.GetTodoManager();
				if (todoManager == null)
				{
					_isReady = false;
					return;
				}
				(int, int, int) stats = todoManager.GetStats();
				_totalCount = stats.Item1;
				_completedCount = stats.Item2;
				_activeCount = stats.Item3;
				_completionPercent = todoManager.GetCompletionPercent();
				_highPriorityItems = (from t in todoManager.GetActiveTodos()
					where (int)t.Priority >= 2
					orderby (int)t.Priority descending
					select t).Take(5).ToList();
				_hudSummary = ((_totalCount == 0) ? "No tasks" : $"{_activeCount} active / {_completionPercent:F0}%");
				_isReady = true;
			}
			catch (Exception ex)
			{
				_hudSummary = "Error";
				_isReady = false;
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("[TodoProvider] Refresh error: " + ex.Message));
				}
			}
		}

		public void DrawDashboardSection()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_0142: Invalid comparison between Unknown and I4
			GUILayout.Label($"Total: {_totalCount}  |  Completed: {_completedCount}  |  Active: {_activeCount}", Array.Empty<GUILayoutOption>());
			Rect rect = GUILayoutUtility.GetRect(0f, 16f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			GUI.Box(rect, "");
			if (_totalCount > 0)
			{
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((Rect)(ref rect)).x + 1f, ((Rect)(ref rect)).y + 1f, (((Rect)(ref rect)).width - 2f) * (_completionPercent / 100f), ((Rect)(ref rect)).height - 2f);
				GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture);
			}
			GUILayout.Label($"{_completionPercent:F0}% complete", Array.Empty<GUILayoutOption>());
			if (_highPriorityItems.Count <= 0)
			{
				return;
			}
			GUILayout.Space(4f);
			GUILayout.Label("High Priority Tasks:", GUI.skin.label, Array.Empty<GUILayoutOption>());
			foreach (TodoItem highPriorityItem in _highPriorityItems)
			{
				string text = (((int)highPriorityItem.Priority == 3) ? "[!] " : "[*] ");
				GUILayout.Label("  " + text + highPriorityItem.Title, Array.Empty<GUILayoutOption>());
			}
		}

		public bool DrawBriefingSection()
		{
			if (_activeCount == 0)
			{
				return false;
			}
			int count = _highPriorityItems.Count;
			GUILayout.Label(string.Format("You have {0} active task{1}.", _activeCount, (_activeCount != 1) ? "s" : ""), Array.Empty<GUILayoutOption>());
			if (count > 0)
			{
				GUILayout.Label(string.Format("  {0} {1} high priority!", count, (count != 1) ? "are" : "is"), Array.Empty<GUILayoutOption>());
			}
			return true;
		}
	}
	public class VaultDataProvider : IModDataProvider
	{
		private int _currencyCount;

		private Dictionary<string, int> _currencies = new Dictionary<string, int>();

		private string _hudSummary = "Loading...";

		private bool _isReady;

		public string ModName => "Vault";

		public string ModIcon => "⚿";

		public string HudSummary => _hudSummary;

		public bool IsReady => _isReady;

		public void Refresh()
		{
			try
			{
				VaultManager vaultManager = Plugin.GetVaultManager();
				if (vaultManager == null)
				{
					_isReady = false;
					return;
				}
				_currencies = vaultManager.GetAllNonZeroCurrencies() ?? new Dictionary<string, int>();
				_currencyCount = _currencies.Count;
				_hudSummary = ((_currencyCount == 0) ? "Vault empty" : string.Format("{0} currenc{1} stored", _currencyCount, (_currencyCount != 1) ? "ies" : "y"));
				_isReady = true;
			}
			catch (Exception ex)
			{
				_hudSummary = "Error";
				_isReady = false;
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("[VaultProvider] Refresh error: " + ex.Message));
				}
			}
		}

		public void DrawDashboardSection()
		{
			if (_currencyCount == 0)
			{
				GUILayout.Label("Vault is empty.", Array.Empty<GUILayoutOption>());
				return;
			}
			GUILayout.Label($"Stored Currencies ({_currencyCount}):", Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			int num = 0;
			foreach (KeyValuePair<string, int> currency in _currencies)
			{
				if (num >= 10)
				{
					GUILayout.Label($"  ... and {_currencyCount - 10} more", Array.Empty<GUILayoutOption>());
					break;
				}
				GUILayout.Label($"  {currency.Key}: {currency.Value}", Array.Empty<GUILayoutOption>());
				num++;
			}
		}

		public bool DrawBriefingSection()
		{
			if (_currencyCount == 0)
			{
				return false;
			}
			GUILayout.Label(string.Format("Vault holds {0} currenc{1}.", _currencyCount, (_currencyCount != 1) ? "ies" : "y"), Array.Empty<GUILayoutOption>());
			return true;
		}
	}
}
namespace HavensAlmanac.Data
{
	public class AlmanacDataAggregator
	{
		private readonly List<IModDataProvider> _providers = new List<IModDataProvider>();

		public IReadOnlyList<IModDataProvider> Providers => _providers;

		public int InstalledModCount => _providers.Count;

		public bool HasAnyData => _providers.Any((IModDataProvider p) => p.IsReady);

		public void RegisterProvider(IModDataProvider provider)
		{
			_providers.Add(provider);
		}

		public void RefreshAll()
		{
			foreach (IModDataProvider provider in _providers)
			{
				try
				{
					provider.Refresh();
				}
				catch (Exception ex)
				{
					ManualLogSource log = Plugin.Log;
					if (log != null)
					{
						log.LogWarning((object)("[Almanac] Error refreshing " + provider.ModName + ": " + ex.Message));
					}
				}
			}
		}
	}
	public interface IModDataProvider
	{
		string ModName { get; }

		string ModIcon { get; }

		string HudSummary { get; }

		bool IsReady { get; }

		void Refresh();

		void DrawDashboardSection();

		bool DrawBriefingSection();
	}
}
namespace HavensAlmanac.Config
{
	public static class AlmanacConfig
	{
		internal static KeyCode StaticDashboardToggleKey = (KeyCode)286;

		internal static bool StaticDashboardRequireCtrl = true;

		internal static KeyCode StaticHUDToggleKey = (KeyCode)285;

		internal static bool StaticHUDEnabled = true;

		internal static float StaticHUDPositionX = -1f;

		internal static float StaticHUDPositionY = -1f;

		internal static bool StaticBriefingEnabled = true;

		internal static float StaticBriefingAutoDismiss = 0f;

		public static ConfigEntry<KeyCode> DashboardToggleKey { get; private set; }

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

		public static ConfigEntry<KeyCode> HUDToggleKey { get; private set; }

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

		public static ConfigEntry<float> HUDPositionX { get; private set; }

		public static ConfigEntry<float> HUDPositionY { get; private set; }

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

		public static ConfigEntry<float> BriefingAutoDismissSeconds { get; private set; }

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

		public static void Initialize(ConfigFile config)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			DashboardToggleKey = config.Bind<KeyCode>("Hotkeys", "DashboardToggleKey", (KeyCode)286, "Key to toggle the full dashboard");
			StaticDashboardToggleKey = DashboardToggleKey.Value;
			DashboardToggleKey.SettingChanged += delegate
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				StaticDashboardToggleKey = DashboardToggleKey.Value;
			};
			DashboardRequireCtrl = config.Bind<bool>("Hotkeys", "DashboardRequireCtrl", true, "Require Ctrl modifier for dashboard toggle");
			StaticDashboardRequireCtrl = DashboardRequireCtrl.Value;
			DashboardRequireCtrl.SettingChanged += delegate
			{
				StaticDashboardRequireCtrl = DashboardRequireCtrl.Value;
			};
			HUDToggleKey = config.Bind<KeyCode>("Hotkeys", "HUDToggleKey", (KeyCode)285, "Key to toggle HUD visibility");
			StaticHUDToggleKey = HUDToggleKey.Value;
			HUDToggleKey.SettingChanged += delegate
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				StaticHUDToggleKey = HUDToggleKey.Value;
			};
			HUDEnabled = config.Bind<bool>("HUD", "Enabled", true, "Show the compact HUD");
			StaticHUDEnabled = HUDEnabled.Value;
			HUDEnabled.SettingChanged += delegate
			{
				StaticHUDEnabled = HUDEnabled.Value;
			};
			HUDPositionX = config.Bind<float>("HUD", "PositionX", -1f, "HUD X position (-1 for default)");
			StaticHUDPositionX = HUDPositionX.Value;
			HUDPositionY = config.Bind<float>("HUD", "PositionY", -1f, "HUD Y position (-1 for default)");
			StaticHUDPositionY = HUDPositionY.Value;
			BriefingEnabled = config.Bind<bool>("DailyBriefing", "Enabled", true, "Show daily briefing when you wake up");
			StaticBriefingEnabled = BriefingEnabled.Value;
			BriefingEnabled.SettingChanged += delegate
			{
				StaticBriefingEnabled = BriefingEnabled.Value;
			};
			BriefingAutoDismissSeconds = config.Bind<float>("DailyBriefing", "AutoDismissSeconds", 0f, "Auto-dismiss briefing after this many seconds (0 to require manual dismiss)");
			StaticBriefingAutoDismiss = BriefingAutoDismissSeconds.Value;
			BriefingAutoDismissSeconds.SettingChanged += delegate
			{
				StaticBriefingAutoDismiss = BriefingAutoDismissSeconds.Value;
			};
			CheckForUpdates = config.Bind<bool>("Updates", "CheckForUpdates", true, "Check for mod updates on startup");
		}
	}
}