Decompiled source of MorePeak v1.8.1

BepInEx/plugins/MorePeak/MorePeak.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MorePeak")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MorePeak")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("550498aa-38bc-4749-a19b-f72fb7b24473")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MorePeak;

[BepInPlugin("com.smckeen.morepeak", "MorePeak", "1.8.0")]
public class MorePeakPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(MapBaker), "GetLevel")]
	private static class MapBaker_GetLevel_Patch
	{
		private static bool hasLoggedLevels;

		private static bool Prefix(MapBaker __instance, int levelIndex, ref string __result)
		{
			try
			{
				if (__instance?.AllLevels == null || __instance.AllLevels.Length == 0)
				{
					return true;
				}
				if (!hasLoggedLevels)
				{
					ModLogger.LogInfo((object)"=== AVAILABLE LEVELS ===");
					for (int i = 0; i < __instance.AllLevels.Length; i++)
					{
						SceneReference obj = __instance.AllLevels[i];
						string path = ((obj != null) ? obj.ScenePath : null) ?? "Unknown";
						string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
						ModLogger.LogInfo((object)$"Level {i}: {fileNameWithoutExtension}");
					}
					ModLogger.LogInfo((object)"========================");
					ModLogger.LogInfo((object)"You can now set 'SelectedLevel' in the config file to any of these level names, or keep it as 'Random'");
					hasLoggedLevels = true;
				}
				if (PhotonNetwork.InRoom && !PhotonNetwork.IsMasterClient)
				{
					ModLogger.LogInfo((object)"[CLIENT] Non-master client called GetLevel - using original method");
					return true;
				}
				int instanceID = ((Object)__instance).GetInstanceID();
				float time = Time.time;
				if (lastRandomizeTime.ContainsKey(instanceID) && time - lastRandomizeTime[instanceID] < 1f)
				{
					return true;
				}
				lastRandomizeTime[instanceID] = time;
				if (lastRandomizeTime.Count > 10)
				{
					List<int> list = new List<int>();
					float num = time - 300f;
					foreach (KeyValuePair<int, float> item in lastRandomizeTime)
					{
						if (item.Value < num)
						{
							list.Add(item.Key);
						}
					}
					foreach (int item2 in list)
					{
						lastRandomizeTime.Remove(item2);
					}
					if (list.Count > 0)
					{
						ModLogger.LogDebug((object)$"Cleaned up {list.Count} old randomize time entries");
					}
				}
				string text = selectedLevelConfig?.Value?.Trim() ?? "Random";
				string text2 = (PhotonNetwork.InRoom ? "[MASTER]" : "[OFFLINE]");
				if (text.Equals("Daily", StringComparison.OrdinalIgnoreCase))
				{
					ModLogger.LogInfo((object)(text2 + " Using vanilla daily map"));
					return true;
				}
				if (text.Equals("Random", StringComparison.OrdinalIgnoreCase))
				{
					int num2 = Random.Range(0, __instance.AllLevels.Length);
					SceneReference obj2 = __instance.AllLevels[num2];
					string path2 = ((obj2 != null) ? obj2.ScenePath : null) ?? "";
					__result = Path.GetFileNameWithoutExtension(path2);
					ModLogger.LogInfo((object)$"{text2} Random level selected: {__result} (index {num2})");
					currentLevelName = __result;
					showLevelGUI = true;
					return false;
				}
				if (text.Contains(","))
				{
					string[] array = text.Split(new char[1] { ',' });
					List<string> list2 = new List<string>();
					string[] array2 = array;
					foreach (string text3 in array2)
					{
						string value = text3.Trim();
						if (string.IsNullOrEmpty(value))
						{
							continue;
						}
						for (int k = 0; k < __instance.AllLevels.Length; k++)
						{
							SceneReference obj3 = __instance.AllLevels[k];
							string path3 = ((obj3 != null) ? obj3.ScenePath : null) ?? "";
							string fileNameWithoutExtension2 = Path.GetFileNameWithoutExtension(path3);
							if (fileNameWithoutExtension2.Equals(value, StringComparison.OrdinalIgnoreCase))
							{
								list2.Add(fileNameWithoutExtension2);
								break;
							}
						}
					}
					if (list2.Count > 0)
					{
						string text4 = list2[Random.Range(0, list2.Count)];
						__result = text4;
						ModLogger.LogInfo((object)$"{text2} Random level from list selected: {__result} (from {list2.Count} valid options)");
						currentLevelName = __result;
						showLevelGUI = true;
						return false;
					}
					ModLogger.LogWarning((object)("No valid levels found in list '" + text + "'! Using random level instead."));
					int num3 = Random.Range(0, __instance.AllLevels.Length);
					SceneReference obj4 = __instance.AllLevels[num3];
					string path4 = ((obj4 != null) ? obj4.ScenePath : null) ?? "";
					__result = Path.GetFileNameWithoutExtension(path4);
					ModLogger.LogInfo((object)$"{text2} Fallback random level: {__result} (index {num3})");
					currentLevelName = __result;
					showLevelGUI = true;
					return false;
				}
				for (int l = 0; l < __instance.AllLevels.Length; l++)
				{
					SceneReference obj5 = __instance.AllLevels[l];
					string path5 = ((obj5 != null) ? obj5.ScenePath : null) ?? "";
					string fileNameWithoutExtension3 = Path.GetFileNameWithoutExtension(path5);
					if (fileNameWithoutExtension3.Equals(text, StringComparison.OrdinalIgnoreCase))
					{
						__result = fileNameWithoutExtension3;
						ModLogger.LogInfo((object)$"{text2} Specific level selected: {__result} (index {l})");
						currentLevelName = __result;
						showLevelGUI = true;
						return false;
					}
				}
				ModLogger.LogWarning((object)("Level '" + text + "' not found! Using random level instead."));
				int num4 = Random.Range(0, __instance.AllLevels.Length);
				SceneReference obj6 = __instance.AllLevels[num4];
				string path6 = ((obj6 != null) ? obj6.ScenePath : null) ?? "";
				__result = Path.GetFileNameWithoutExtension(path6);
				ModLogger.LogInfo((object)$"{text2} Fallback random level: {__result} (index {num4})");
				currentLevelName = __result;
				showLevelGUI = true;
				return false;
			}
			catch (Exception ex)
			{
				ModLogger.LogError((object)("Error in MapBaker.GetLevel patch: " + ex.Message));
				return true;
			}
		}
	}

	[HarmonyPatch(typeof(AirportCheckInKiosk), "BeginIslandLoadRPC")]
	private static class AirportCheckInKiosk_BeginIslandLoadRPC_Patch
	{
		private static void Prefix(string sceneName, int ascent)
		{
			try
			{
				currentLevelName = sceneName;
				showLevelGUI = true;
				string arg = (PhotonNetwork.IsMasterClient ? "[MASTER]" : "[CLIENT]");
				ModLogger.LogInfo((object)$"{arg} Loading level: {sceneName} (ascent: {ascent})");
			}
			catch (Exception ex)
			{
				ModLogger.LogError((object)("Error in BeginIslandLoadRPC patch: " + ex.Message));
			}
		}
	}

	[HarmonyPatch(typeof(LoadingScreenHandler), "LoadSceneProcess")]
	private static class LoadingScreenHandler_LoadSceneProcess_Patch
	{
		private static void Prefix(string sceneName)
		{
			try
			{
				if (sceneName.Equals("Airport", StringComparison.OrdinalIgnoreCase))
				{
					showLevelGUI = false;
					currentLevelName = "";
					ModLogger.LogInfo((object)"Clearing level GUI - returning to Airport");
					guiStyle = null;
				}
			}
			catch (Exception ex)
			{
				ModLogger.LogError((object)("Error in LoadSceneProcess patch: " + ex.Message));
			}
		}
	}

	[HarmonyPatch(typeof(NetworkConnector), "OnLeftRoom")]
	private static class NetworkConnector_OnLeftRoom_Patch
	{
		private static void Postfix()
		{
			try
			{
				showLevelGUI = false;
				currentLevelName = "";
				ModLogger.LogInfo((object)"Clearing level GUI - left multiplayer room");
			}
			catch (Exception ex)
			{
				ModLogger.LogError((object)("Error in OnLeftRoom patch: " + ex.Message));
			}
		}
	}

	[HarmonyPatch(typeof(LevelGeneration), "RandomizeBiomeVariants")]
	private static class LevelGeneration_RandomizeBiomeVariants_Patch
	{
		private static void Postfix()
		{
			try
			{
				Random.InitState(Random.Range(0, int.MaxValue));
			}
			catch (Exception ex)
			{
				ManualLogSource modLogger = ModLogger;
				if (modLogger != null)
				{
					modLogger.LogError((object)("Error in biome variant randomization: " + ex.Message));
				}
			}
		}
	}

	private static ManualLogSource ModLogger;

	private static ConfigEntry<string> selectedLevelConfig;

	private static ConfigEntry<bool> showCurrentLevelGUIConfig;

	private static ConfigEntry<bool> showSelectedLevelConfigGUIConfig;

	private static Dictionary<int, float> lastRandomizeTime = new Dictionary<int, float>();

	private const float RANDOMIZE_COOLDOWN = 1f;

	private static string currentLevelName = "";

	private static bool showLevelGUI = false;

	private static Texture2D guiBackgroundTexture;

	private static GUIStyle guiStyle;

	private static bool showSettingsGUI = false;

	private static Rect settingsWindowRect = new Rect(0f, 0f, 330f, 200f);

	private static string tempSelectedLevel = "";

	private static bool tempShowCurrentLevel = true;

	private static bool tempShowSelectedLevelConfig = true;

	private static Vector2 scrollPosition = Vector2.zero;

	private static Texture2D settingsCogTexture;

	private static int onGUICallCount = 0;

	private static GUIStyle cachedCogStyle;

	private static GUIStyle cachedLabelStyle;

	private static GUIStyle cachedTextFieldStyle;

	private static GUIStyle cachedButtonStyle;

	private static GUIStyle cachedToggleStyle;

	private static GUIStyle cachedWindowStyle;

	private static Texture2D cachedDarkBackgroundTexture;

	private static Texture2D cachedButtonBackgroundTexture;

	private static Texture2D cachedButtonHoverTexture;

	private static Texture2D cachedButtonActiveTexture;

	private static Texture2D cachedTextFieldBackgroundTexture;

	private static Texture2D cachedWindowBackgroundTexture;

	private void Awake()
	{
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Expected O, but got Unknown
		ModLogger = ((BaseUnityPlugin)this).Logger;
		LoadSettingsCogTexture();
		selectedLevelConfig = ((BaseUnityPlugin)this).Config.Bind<string>("Settings", "SelectedLevel", "Random", "Set to 'Daily' for the daily map, 'Random' for random levels, specify exact level name (e.g., 'Level_0'), or specify multiple levels separated by commas for random selection from that list (e.g., 'Level_0, Level_1, Level_2')");
		showCurrentLevelGUIConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("GUI", "ShowCurrentLevel", false, "Whether to show the current level name on screen during gameplay");
		showSelectedLevelConfigGUIConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("GUI", "ShowSelectedLevelConfig", false, "Whether to show the selected level configuration on screen during gameplay");
		ModLogger.LogInfo((object)"MorePeak v1.8.0 loaded!");
		ModLogger.LogInfo((object)("Config: SelectedLevel = " + selectedLevelConfig.Value));
		ModLogger.LogInfo((object)("Config: ShowCurrentLevel = " + showCurrentLevelGUIConfig.Value));
		ModLogger.LogInfo((object)("Config: ShowSelectedLevelConfig = " + showSelectedLevelConfigGUIConfig.Value));
		ModLogger.LogInfo((object)"Available levels will be listed when you start a game.");
		Harmony val = new Harmony("com.smckeen.morepeak");
		val.PatchAll();
	}

	private void OnGUI()
	{
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Expected O, but got Unknown
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Expected O, but got Unknown
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Expected O, but got Unknown
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: Expected O, but got Unknown
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: 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_0274: Unknown result type (might be due to invalid IL or missing references)
		onGUICallCount++;
		if (onGUICallCount % 60 == 0)
		{
			ModLogger.LogDebug((object)$"OnGUI called {onGUICallCount} times, showLevelGUI={showLevelGUI}");
		}
		if (cachedCogStyle == null)
		{
			ModLogger.LogDebug((object)"Initializing cached styles in OnGUI");
			InitializeCachedStyles();
		}
		DrawSettingsCog();
		if (showSettingsGUI)
		{
			ModLogger.LogDebug((object)"Drawing settings window");
			DrawSettingsWindow();
		}
		if (showLevelGUI && !string.IsNullOrEmpty(currentLevelName))
		{
			if (cachedCogStyle == null)
			{
				ModLogger.LogDebug((object)"Initializing cached styles in OnGUI");
				InitializeCachedStyles();
			}
			Texture2D val = cachedDarkBackgroundTexture ?? MakeTexture(2, 2, new Color(0f, 0f, 0f, 0.7f));
			if (guiStyle == null || (Object)(object)guiStyle.normal.background != (Object)(object)val)
			{
				guiStyle = new GUIStyle(GUI.skin.box);
				guiStyle.fontSize = 16;
				guiStyle.normal.textColor = Color.white;
				guiStyle.normal.background = val;
				guiStyle.padding = new RectOffset(10, 10, 5, 5);
			}
			float num = 20f;
			float num2 = 30f;
			if (showCurrentLevelGUIConfig.Value)
			{
				string text = "Current Level: " + currentLevelName;
				Vector2 val2 = guiStyle.CalcSize(new GUIContent(text));
				float num3 = ((float)Screen.width - val2.x) / 2f;
				GUI.Box(new Rect(num3, num, val2.x, val2.y), text, guiStyle);
				num += num2;
			}
			if (showSelectedLevelConfigGUIConfig.Value)
			{
				string text2 = "Config: " + selectedLevelConfig.Value;
				Vector2 val3 = guiStyle.CalcSize(new GUIContent(text2));
				float num4 = ((float)Screen.width - val3.x) / 2f;
				GUI.Box(new Rect(num4, num, val3.x, val3.y), text2, guiStyle);
			}
		}
	}

	private void OnDestroy()
	{
		if ((Object)(object)guiBackgroundTexture != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)guiBackgroundTexture);
			guiBackgroundTexture = null;
		}
		if ((Object)(object)settingsCogTexture != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)settingsCogTexture);
			settingsCogTexture = null;
		}
		if ((Object)(object)cachedDarkBackgroundTexture != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)cachedDarkBackgroundTexture);
			cachedDarkBackgroundTexture = null;
		}
		if ((Object)(object)cachedButtonBackgroundTexture != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)cachedButtonBackgroundTexture);
			cachedButtonBackgroundTexture = null;
		}
		if ((Object)(object)cachedButtonHoverTexture != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)cachedButtonHoverTexture);
			cachedButtonHoverTexture = null;
		}
		if ((Object)(object)cachedButtonActiveTexture != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)cachedButtonActiveTexture);
			cachedButtonActiveTexture = null;
		}
		if ((Object)(object)cachedTextFieldBackgroundTexture != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)cachedTextFieldBackgroundTexture);
			cachedTextFieldBackgroundTexture = null;
		}
		if ((Object)(object)cachedWindowBackgroundTexture != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)cachedWindowBackgroundTexture);
			cachedWindowBackgroundTexture = null;
		}
		guiStyle = null;
		cachedCogStyle = null;
		cachedLabelStyle = null;
		cachedTextFieldStyle = null;
		cachedButtonStyle = null;
		cachedToggleStyle = null;
		cachedWindowStyle = null;
	}

	private Texture2D MakeTexture(int width, int height, Color color)
	{
		//IL_0011: 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_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		Color[] array = (Color[])(object)new Color[width * height];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = color;
		}
		Texture2D val = new Texture2D(width, height);
		val.SetPixels(array);
		val.Apply();
		return val;
	}

	private void DrawSettingsCog()
	{
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Expected O, but got Unknown
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		if (showLevelGUI)
		{
			if (showSettingsGUI)
			{
				showSettingsGUI = false;
			}
			ModLogger.LogDebug((object)"Settings cog hidden - in a round (showLevelGUI = true)");
			return;
		}
		ModLogger.LogDebug((object)"Drawing settings cog - not in a round");
		float num = 32f;
		float num2 = (float)Screen.width - num - 10f;
		float num3 = 10f;
		ModLogger.LogDebug((object)$"Settings cog position: x={num2}, y={num3}, size={num}");
		ModLogger.LogDebug((object)$"Screen size: {Screen.width}x{Screen.height}");
		if ((Object)(object)settingsCogTexture != (Object)null)
		{
			ModLogger.LogDebug((object)"Using settings cog texture");
			GUIStyle val = cachedCogStyle ?? GUI.skin.button;
			if (!GUI.Button(new Rect(num2, num3, num, num), (Texture)(object)settingsCogTexture, val))
			{
				return;
			}
			ModLogger.LogInfo((object)"Settings cog clicked!");
			showSettingsGUI = !showSettingsGUI;
			if (showSettingsGUI)
			{
				tempSelectedLevel = selectedLevelConfig.Value;
				tempShowCurrentLevel = showCurrentLevelGUIConfig.Value;
				tempShowSelectedLevelConfig = showSelectedLevelConfigGUIConfig.Value;
				float num4 = num2 - 330f + num;
				float num5 = num3 + num + 5f;
				if (num4 < 10f)
				{
					num4 = 10f;
				}
				if (num5 + 200f > (float)(Screen.height - 10))
				{
					num5 = Screen.height - 210;
				}
				settingsWindowRect = new Rect(num4, num5, 330f, 200f);
				ModLogger.LogInfo((object)"Settings window opened");
			}
			else
			{
				ModLogger.LogInfo((object)"Settings window closed");
			}
			return;
		}
		ModLogger.LogDebug((object)"Using fallback text cog (⚙)");
		GUIStyle val2 = new GUIStyle(cachedCogStyle ?? GUI.skin.button);
		val2.fontSize = 14;
		val2.fontStyle = (FontStyle)1;
		val2.normal.textColor = Color.white;
		val2.hover.textColor = Color.yellow;
		if (!GUI.Button(new Rect(num2, num3, num, num), "⚙", val2))
		{
			return;
		}
		ModLogger.LogInfo((object)"Settings cog clicked!");
		showSettingsGUI = !showSettingsGUI;
		if (showSettingsGUI)
		{
			tempSelectedLevel = selectedLevelConfig.Value;
			tempShowCurrentLevel = showCurrentLevelGUIConfig.Value;
			tempShowSelectedLevelConfig = showSelectedLevelConfigGUIConfig.Value;
			float num6 = num2 - 330f + num;
			float num7 = num3 + num + 5f;
			if (num6 < 10f)
			{
				num6 = 10f;
			}
			if (num7 + 200f > (float)(Screen.height - 10))
			{
				num7 = Screen.height - 210;
			}
			settingsWindowRect = new Rect(num6, num7, 330f, 200f);
			ModLogger.LogInfo((object)"Settings window opened");
		}
		else
		{
			ModLogger.LogInfo((object)"Settings window closed");
		}
	}

	private void DrawSettingsWindow()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: 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_0086: Expected O, but got Unknown
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		GUI.color = new Color(0f, 0f, 0f, 0.9f);
		GUI.Box(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), "");
		GUI.color = Color.white;
		GUIStyle val = cachedWindowStyle ?? GUI.skin.window;
		settingsWindowRect = GUI.Window(12345, settingsWindowRect, new WindowFunction(DrawSettingsWindowContents), "MorePeak Settings", val);
	}

	private void DrawSettingsWindowContents(int windowID)
	{
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: Unknown result type (might be due to invalid IL or missing references)
		//IL_0343: Unknown result type (might be due to invalid IL or missing references)
		float num = 30f;
		float num2 = 25f;
		float num3 = 150f;
		float num4 = 150f;
		GUIStyle val = cachedLabelStyle ?? GUI.skin.label;
		GUIStyle val2 = cachedTextFieldStyle ?? GUI.skin.textField;
		GUIStyle val3 = cachedButtonStyle ?? GUI.skin.button;
		GUIStyle val4 = cachedToggleStyle ?? GUI.skin.toggle;
		GUI.Label(new Rect(10f, num, num3, 20f), "Selected Level:", val);
		num += num2;
		string text = GUI.TextField(new Rect(10f, num, num4, 20f), tempSelectedLevel, val2);
		if (text != tempSelectedLevel)
		{
			tempSelectedLevel = text;
			selectedLevelConfig.Value = tempSelectedLevel;
			((BaseUnityPlugin)this).Config.Save();
			ModLogger.LogInfo((object)("SelectedLevel updated to: " + tempSelectedLevel));
		}
		num += num2 + 5f;
		if (GUI.Button(new Rect(10f, num, 70f, 20f), "Random", val3))
		{
			tempSelectedLevel = "Random";
			selectedLevelConfig.Value = tempSelectedLevel;
			((BaseUnityPlugin)this).Config.Save();
			ModLogger.LogInfo((object)"SelectedLevel set to Random");
		}
		if (GUI.Button(new Rect(85f, num, 70f, 20f), "Daily", val3))
		{
			tempSelectedLevel = "Daily";
			selectedLevelConfig.Value = tempSelectedLevel;
			((BaseUnityPlugin)this).Config.Save();
			ModLogger.LogInfo((object)"SelectedLevel set to Daily");
		}
		num += num2 + 10f;
		GUI.Label(new Rect(10f, num, num3, 20f), "Display Options:", val);
		num += num2;
		bool flag = GUI.Toggle(new Rect(10f, num, num4, 20f), tempShowCurrentLevel, "Show Current Level", val4);
		if (flag != tempShowCurrentLevel)
		{
			tempShowCurrentLevel = flag;
			showCurrentLevelGUIConfig.Value = tempShowCurrentLevel;
			((BaseUnityPlugin)this).Config.Save();
			ModLogger.LogInfo((object)("ShowCurrentLevel updated to: " + tempShowCurrentLevel));
		}
		num += num2;
		bool flag2 = GUI.Toggle(new Rect(10f, num, num4, 20f), tempShowSelectedLevelConfig, "Show Config", val4);
		if (flag2 != tempShowSelectedLevelConfig)
		{
			tempShowSelectedLevelConfig = flag2;
			showSelectedLevelConfigGUIConfig.Value = tempShowSelectedLevelConfig;
			((BaseUnityPlugin)this).Config.Save();
			ModLogger.LogInfo((object)("ShowSelectedLevelConfig updated to: " + tempShowSelectedLevelConfig));
		}
		num += num2 + 10f;
		if (GUI.Button(new Rect(10f, num, 70f, 20f), "Close", val3))
		{
			showSettingsGUI = false;
		}
		if (GUI.Button(new Rect(((Rect)(ref settingsWindowRect)).width - 25f, 5f, 20f, 20f), "X", val3))
		{
			showSettingsGUI = false;
		}
		GUI.DragWindow();
	}

	private void LoadSettingsCogTexture()
	{
		//IL_00b9: 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_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Expected O, but got Unknown
		try
		{
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MorePeak.assets.settings-cog.png");
			if (stream != null)
			{
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				settingsCogTexture = new Texture2D(2, 2);
				ImageConversion.LoadImage(settingsCogTexture, array);
				ModLogger.LogInfo((object)"Settings cog texture loaded successfully from embedded resource");
			}
			else
			{
				ModLogger.LogWarning((object)"settings-cog.png embedded resource not found");
				settingsCogTexture = MakeTexture(32, 32, Color.gray);
			}
		}
		catch (Exception ex)
		{
			ModLogger.LogError((object)("Error loading settings cog texture: " + ex.Message));
			settingsCogTexture = MakeTexture(32, 32, Color.gray);
		}
	}

	private void InitializeCachedStyles()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Expected O, but got Unknown
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Expected O, but got Unknown
		//IL_018f: 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_01ae: Expected O, but got Unknown
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Expected O, but got Unknown
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Expected O, but got Unknown
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_029a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Expected O, but got Unknown
		ModLogger.LogDebug((object)"Initializing cached styles and textures");
		cachedDarkBackgroundTexture = MakeTexture(2, 2, new Color(0f, 0f, 0f, 0.7f));
		cachedButtonBackgroundTexture = MakeTexture(2, 2, new Color(0.2f, 0.2f, 0.2f, 0.8f));
		cachedButtonHoverTexture = MakeTexture(2, 2, new Color(0.3f, 0.3f, 0.3f, 0.9f));
		cachedButtonActiveTexture = MakeTexture(2, 2, new Color(0.4f, 0.4f, 0.4f, 0.9f));
		cachedTextFieldBackgroundTexture = MakeTexture(2, 2, new Color(0.2f, 0.2f, 0.2f, 0.9f));
		cachedWindowBackgroundTexture = MakeTexture(2, 2, new Color(0.1f, 0.1f, 0.1f, 0.95f));
		ModLogger.LogDebug((object)"Cached textures created");
		cachedCogStyle = new GUIStyle(GUI.skin.button);
		cachedCogStyle.normal.background = cachedButtonBackgroundTexture;
		cachedCogStyle.hover.background = cachedButtonHoverTexture;
		cachedCogStyle.active.background = cachedButtonActiveTexture;
		cachedLabelStyle = new GUIStyle(GUI.skin.label);
		cachedLabelStyle.fontSize = 12;
		cachedLabelStyle.wordWrap = true;
		cachedLabelStyle.normal.textColor = Color.white;
		cachedTextFieldStyle = new GUIStyle(GUI.skin.textField);
		cachedTextFieldStyle.fontSize = 12;
		cachedTextFieldStyle.normal.background = cachedTextFieldBackgroundTexture;
		cachedTextFieldStyle.normal.textColor = Color.white;
		cachedButtonStyle = new GUIStyle(GUI.skin.button);
		cachedButtonStyle.fontSize = 12;
		cachedButtonStyle.normal.background = cachedButtonBackgroundTexture;
		cachedButtonStyle.hover.background = cachedButtonHoverTexture;
		cachedButtonStyle.normal.textColor = Color.white;
		cachedButtonStyle.hover.textColor = Color.yellow;
		cachedToggleStyle = new GUIStyle(GUI.skin.toggle);
		cachedToggleStyle.fontSize = 12;
		cachedToggleStyle.normal.textColor = Color.white;
		cachedWindowStyle = new GUIStyle(GUI.skin.window);
		cachedWindowStyle.fontSize = 14;
		cachedWindowStyle.normal.background = cachedWindowBackgroundTexture;
		cachedWindowStyle.onNormal.background = cachedWindowBackgroundTexture;
		ModLogger.LogDebug((object)"Cached styles created successfully");
	}
}