Decompiled source of DebugMenu v2.0.2

DebugMenu.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using ATS_API;
using ATS_API.Helpers;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DebugMenu;
using DebugMenu.Scripts;
using DebugMenu.Scripts.Acts;
using DebugMenu.Scripts.All;
using DebugMenu.Scripts.Popups;
using DebugMenu.Scripts.Utils;
using Eremite;
using Eremite.Characters.Villagers;
using Eremite.Controller;
using Eremite.Model;
using Eremite.Model.Effects;
using Eremite.Model.Sound;
using Eremite.Model.State;
using Eremite.Services;
using Eremite.View.Cameras;
using GameMode1;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("DebugMenu")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("UI Screen to change the game at runtime")]
[assembly: AssemblyFileVersion("2.0.2.0")]
[assembly: AssemblyInformationalVersion("2.0.2+037ef73042a5b8b4968bc73a3d09a631dbb5ff41")]
[assembly: AssemblyProduct("DebugMenu")]
[assembly: AssemblyTitle("DebugMenu")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[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;
		}
	}
}
[Serializable]
public class SaveData
{
	public List<string> favouritedPerks = new List<string>();

	public List<string> favouritedGoods = new List<string>();

	public static string Path => Application.persistentDataPath + "/DebugMenuSaveData.json";

	public void Save()
	{
		string text = JsonConvert.SerializeObject((object)this);
		if (string.IsNullOrEmpty(text))
		{
			Plugin.Log.LogError((object)"Failed to serialize save data.");
		}
		else
		{
			File.WriteAllText(Path, text);
		}
	}

	public static SaveData Load()
	{
		if (!File.Exists(Path))
		{
			Plugin.Log.LogInfo((object)"Save data file does not exist.");
			return new SaveData();
		}
		string text = File.ReadAllText(Path);
		if (string.IsNullOrEmpty(text))
		{
			Plugin.Log.LogError((object)"Failed to read save data!");
			return new SaveData();
		}
		SaveData saveData = JsonConvert.DeserializeObject<SaveData>(text);
		if (saveData == null)
		{
			Plugin.Log.LogError((object)"Failed to deserialize save data.");
			return new SaveData();
		}
		return saveData;
	}
}
public class WindowBlocker : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
{
	public bool isHovered = false;

	public RectTransform RectTransform;

	private void Awake()
	{
		RectTransform = ((Component)this).GetComponent<RectTransform>();
	}

	private void OnDisable()
	{
		if (isHovered)
		{
			OnPointerExit(null);
		}
	}

	public void OnPointerEnter(PointerEventData eventData)
	{
		isHovered = true;
	}

	public void OnPointerExit(PointerEventData eventData)
	{
		isHovered = false;
	}
}
public enum ShowAll
{
	Any,
	Only,
	Except
}
public static class ShowAllExtensions
{
	public static bool Accepts(this ShowAll type, bool value)
	{
		return type switch
		{
			ShowAll.Any => true, 
			ShowAll.Only => value, 
			ShowAll.Except => !value, 
			_ => false, 
		};
	}
}
[HarmonyPatch]
public static class Input
{
	private static bool blockAllInput;

	public static InputActionAsset InputAsset;

	private static GameObject blockerParent;

	public static void Initialize()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		blockerParent = new GameObject("DebugMenuFullScreenBlocker");
		blockerParent.layer = LayerMask.NameToLayer("UI");
		Canvas val = blockerParent.AddComponent<Canvas>();
		val.renderMode = (RenderMode)0;
		val.sortingOrder = 32766;
		blockerParent.AddComponent<CanvasScaler>();
		blockerParent.AddComponent<GraphicRaycaster>();
		((Graphic)blockerParent.AddComponent<Image>()).color = new Color(0f, 0f, 1f, 0f);
		blockerParent.transform.SetParent(((Component)Plugin.Instance).transform);
		blockerParent.SetActive(false);
	}

	public static void DrawToggleBlockInput(DebugWindow window)
	{
		if (window.Toggle("Block All Input", ref blockAllInput))
		{
			blockerParent.SetActive(blockAllInput);
		}
	}

	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPostfix]
	private static void HookMainControllerSetup(InputConfig __instance)
	{
		InputAsset = __instance.asset;
	}

	[HarmonyPatch(typeof(InputService), "IsTriggering")]
	[HarmonyPrefix]
	private static bool InputService_IsTriggering()
	{
		return !blockAllInput;
	}

	[HarmonyPatch(typeof(InputService), "WasTriggered")]
	[HarmonyPrefix]
	private static bool InputService_WasTriggered()
	{
		return !blockAllInput;
	}

	[HarmonyPatch(typeof(InputService), "WasTriggeredAny")]
	[HarmonyPrefix]
	private static bool InputService_WasTriggeredAny()
	{
		return !blockAllInput;
	}

	[HarmonyPatch(typeof(InputService), "WasCanceled")]
	[HarmonyPrefix]
	private static bool InputService_WasCanceled()
	{
		return !blockAllInput;
	}

	[HarmonyPatch(typeof(InputService), "IsOverUI")]
	[HarmonyPrefix]
	private static bool InputService_IsOverUI()
	{
		return !blockAllInput;
	}

	[HarmonyPatch(typeof(InputService), "GetKey")]
	[HarmonyPrefix]
	private static bool InputService_GetKey()
	{
		return !blockAllInput;
	}

	[HarmonyPatch(typeof(InputService), "GetKeyDown")]
	[HarmonyPrefix]
	private static bool InputService_GetMouseButton()
	{
		return !blockAllInput;
	}

	[HarmonyPatch(typeof(InputService), "IsValidBind")]
	[HarmonyPrefix]
	private static bool InputService_IsValidBind()
	{
		return !blockAllInput;
	}

	[HarmonyPatch(typeof(InputService), "GetMouseButtonRaw")]
	[HarmonyPrefix]
	private static bool InputService_GetMouseButtonRaw()
	{
		return !blockAllInput;
	}

	[HarmonyPatch(typeof(InputService), "GetMouseButtonDownRaw")]
	[HarmonyPrefix]
	private static bool InputService_GetMouseButtonDownRaw()
	{
		return !blockAllInput;
	}

	[HarmonyPatch(typeof(InputService), "IsWorldDragging")]
	[HarmonyPrefix]
	private static bool InputService_IsWorldDragging()
	{
		return !blockAllInput;
	}

	[HarmonyPatch(typeof(InputService), "IsLocked")]
	[HarmonyPrefix]
	private static bool InputService_IsLocked(ref bool __result)
	{
		if (blockAllInput)
		{
			__result = true;
			return false;
		}
		return true;
	}

	[HarmonyPatch(typeof(CameraController), "EdgeScrollingEnabled")]
	[HarmonyPrefix]
	private static bool CameraController_EdgeScrollingEnabled()
	{
		return !blockAllInput;
	}
}
namespace ATS_DebugMenu
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "DebugMenu";

		public const string PLUGIN_NAME = "DebugMenu";

		public const string PLUGIN_VERSION = "2.0.2";
	}
}
namespace GameMode1
{
	public class ATSBattleSequence : BaseBattleSequence
	{
		public ATSBattleSequence(BaseWindow window)
			: base(window)
		{
		}

		public override void OnGUI()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			ReputationService val = (ReputationService)SO.ReputationService;
			using (window.HorizontalScope(2))
			{
				using (window.VerticalScope(2))
				{
					window.Label("Reputation: " + val.State.reputation + "/" + val.GetReputationToWin());
					using (window.HorizontalScope(2))
					{
						if (window.Button("+1"))
						{
							val.AddReputationPoints(1f, (ReputationChangeSource)0, (string)null);
						}
						if (window.Button("-1", null, null, () => new ADrawable.ButtonDisabledData("Not working")))
						{
							val.AddReputationPoints(-1f, (ReputationChangeSource)0, (string)null);
						}
					}
				}
				using (window.VerticalScope(2))
				{
					float reputationPenalty = val.State.reputationPenalty;
					int reputationPenaltyToLoose = val.GetReputationPenaltyToLoose();
					window.Label($"Impatience: {reputationPenalty:F1}/{reputationPenaltyToLoose:F1}");
					using (window.HorizontalScope(2))
					{
						if (window.Button("+1"))
						{
							val.AddReputationPenalty(1f, (ReputationChangeSource)1, false, (string)null);
						}
						if (window.Button("-1"))
						{
							val.AddReputationPenalty(-1f, (ReputationChangeSource)0, false, (string)null);
						}
					}
				}
			}
			window.Padding();
			if (window.Button("Villagers"))
			{
				Plugin.Instance.ToggleWindow<VillagersWindow>();
			}
			if (window.Button("Inventory"))
			{
				Plugin.Instance.ToggleWindow<InventoryWindow>();
			}
			if (window.Button("Perks"))
			{
				Plugin.Instance.ToggleWindow<PerksWindow>();
			}
			window.Padding();
			using (window.HorizontalScope(2))
			{
				if (window.Button("Win Now"))
				{
					val.ForceGameWin();
				}
				if (window.Button("Lose Now") && !val.State.finished)
				{
					val.GameLost();
				}
			}
			base.OnGUI();
		}
	}
	public class ATSGameMode : BaseGameMode
	{
		public ATSGameMode(DebugWindow window)
			: base(window)
		{
			m_mapSequence = new ATSMapSequence(this);
			m_battleSequence = new ATSBattleSequence(window);
		}

		public override void OnGUI()
		{
			Window.LabelHeader("Against The Storm");
			OnGUICurrentNode();
		}

		public override void OnGUIMinimal()
		{
			OnGUICurrentNode();
		}

		private void OnGUICurrentNode()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			if (name == "Game")
			{
				m_battleSequence.OnGUI();
			}
			else if (name == "WorldMap")
			{
				m_mapSequence.OnGUI();
			}
		}

		private void OnGUICardChoiceNodeSequence()
		{
		}

		private void OnGUIMap()
		{
			m_mapSequence.OnGUI();
		}

		public override void Restart()
		{
		}

		public override void Reload()
		{
		}
	}
	[HarmonyPatch]
	public class ATSMapSequence : BaseMapSequence
	{
		public static bool SkipNextNode = false;

		public static bool UnlockAllDifficulties = false;

		public static bool ActivateAllMapNodesActive = false;

		public static bool RegionOverride = false;

		public static string RegionNameOverride = "No region selected";

		private readonly ATSGameMode GameMode = null;

		private readonly DebugWindow Window = null;

		public ATSMapSequence(ATSGameMode gameMode)
		{
			GameMode = gameMode;
			Window = gameMode.Window;
		}

		public override void OnGUI()
		{
			Window.LabelHeader("WorldMap");
			Window.Toggle("Unlock all Difficulties", ref UnlockAllDifficulties);
		}

		public override void ToggleSkipNextNode()
		{
			SkipNextNode = !SkipNextNode;
		}

		public override void ToggleAllNodes()
		{
			ActivateAllMapNodesActive = !ActivateAllMapNodesActive;
		}

		[HarmonyPatch(typeof(MetaConditionsService), "GetMaxUnlockedDifficulty")]
		[HarmonyPrefix]
		private static bool ShowAllDifficulties(ref DifficultyModel __result)
		{
			if (UnlockAllDifficulties)
			{
				DifficultyModel val = (from a in Serviceable.Settings.difficulties
					where a.canBePicked
					orderby a.index descending
					select a).FirstOrDefault();
				__result = val;
				return false;
			}
			return true;
		}
	}
}
namespace DebugMenu
{
	public static class Configs
	{
		public enum WindowSizes
		{
			OneQuarter,
			Half,
			ThreeQuarters,
			Default,
			OneAndAQuarter,
			OneAndAHalf,
			OneAndThreeQuarters,
			Double
		}

		public static ConfigEntry<WindowSizes> m_windowSize = Bind("General", "Window Scale", WindowSizes.Default, "How big the menu windows should be.");

		public static ConfigEntry<bool> m_showDebugMenu = Bind("General", "Show Debug Menu", defaultValue: true, "Should the in-game debug menu window be shown?");

		public static bool ShowDebugMenu
		{
			get
			{
				return m_showDebugMenu.Value;
			}
			set
			{
				m_showDebugMenu.Value = value;
				((BaseUnityPlugin)Plugin.Instance).Config.Save();
			}
		}

		public static WindowSizes WindowSize
		{
			get
			{
				return m_windowSize.Value;
			}
			set
			{
				m_windowSize.Value = value;
				((BaseUnityPlugin)Plugin.Instance).Config.Save();
			}
		}

		private static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			return ((BaseUnityPlugin)Plugin.Instance).Config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
	[BepInPlugin("jamesgames.againstthestorm.debugmenu", "Debug Menu", "2.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "jamesgames.againstthestorm.debugmenu";

		public const string PluginName = "Debug Menu";

		public const string PluginVersion = "2.0.0";

		public static Plugin Instance;

		public static ManualLogSource Log;

		public static InputActionAsset InputAsset;

		public static string PluginDirectory;

		public static float StartingFixedDeltaTime;

		public static List<BaseWindow> AllWindows = new List<BaseWindow>();

		public static SaveData SaveData = null;

		private Harmony harmony;

		private GameObject blockerParent = null;

		private Canvas blockerParentCanvas = null;

		private List<WindowBlocker> activeRectTransforms = new List<WindowBlocker>();

		private List<WindowBlocker> rectTransformPool = new List<WindowBlocker>();

		private void Awake()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			StartingFixedDeltaTime = Time.fixedDeltaTime;
			PluginDirectory = ((BaseUnityPlugin)this).Info.Location.Replace("DebugMenu.dll", "");
			blockerParent = new GameObject("DebugMenuWindowBlocker");
			blockerParent.layer = LayerMask.NameToLayer("UI");
			blockerParentCanvas = blockerParent.AddComponent<Canvas>();
			blockerParentCanvas.renderMode = (RenderMode)0;
			blockerParentCanvas.sortingOrder = 32767;
			blockerParent.AddComponent<CanvasScaler>();
			blockerParent.AddComponent<GraphicRaycaster>();
			blockerParent.transform.SetParent(((Component)this).transform);
			Input.Initialize();
			harmony = Harmony.CreateAndPatchAll(typeof(Plugin).Assembly, "jamesgames.againstthestorm.debugmenu");
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			foreach (Type type in types)
			{
				if (type.IsSubclassOf(typeof(BaseWindow)))
				{
					AllWindows.Add((BaseWindow)Activator.CreateInstance(type));
				}
			}
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			try
			{
				SaveData = SaveData.Load();
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Failed to load save data: {arg}");
				SaveData = new SaveData();
			}
			Hotkeys.RegisterKey("Debug Menu", "toggleDebug", "Show/Hide Debug Menu", new List<KeyCode>(1) { (KeyCode)126 }, (Action)delegate
			{
				Configs.ShowDebugMenu = !Configs.ShowDebugMenu;
			}, (Action)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Debug Menu");
		}

		private void Update()
		{
			if (!Configs.ShowDebugMenu)
			{
				return;
			}
			for (int i = 0; i < AllWindows.Count; i++)
			{
				if (AllWindows[i].IsActive)
				{
					AllWindows[i].Update();
				}
			}
		}

		private void OnGUI()
		{
			if (!Configs.ShowDebugMenu)
			{
				return;
			}
			for (int i = 0; i < AllWindows.Count; i++)
			{
				if (AllWindows[i].IsActive)
				{
					AllWindows[i].OnWindowGUI();
				}
			}
		}

		public T ToggleWindow<T>() where T : BaseWindow, new()
		{
			return (T)ToggleWindow(typeof(T));
		}

		public BaseWindow ToggleWindow(Type t)
		{
			for (int i = 0; i < AllWindows.Count; i++)
			{
				BaseWindow baseWindow = AllWindows[i];
				if (baseWindow.GetType() == t)
				{
					baseWindow.IsActive = !baseWindow.IsActive;
					return baseWindow;
				}
			}
			return null;
		}

		public T GetWindow<T>() where T : BaseWindow, new()
		{
			return (T)GetWindow(typeof(T));
		}

		public BaseWindow GetWindow(Type t)
		{
			for (int i = 0; i < AllWindows.Count; i++)
			{
				BaseWindow baseWindow = AllWindows[i];
				if (baseWindow.GetType() == t)
				{
					return baseWindow;
				}
			}
			return null;
		}

		public WindowBlocker CreateWindowBlocker()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("WindowBlocker", new Type[2]
			{
				typeof(RectTransform),
				typeof(WindowBlocker)
			});
			val.transform.SetParent(blockerParent.transform);
			val.layer = LayerMask.NameToLayer("UI");
			Image val2 = val.AddComponent<Image>();
			Color magenta = Color.magenta;
			magenta.a = 0f;
			((Graphic)val2).color = magenta;
			RectTransform component = val.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2((float)(Screen.width / 4), (float)(Screen.height / 4));
			component.anchoredPosition = Vector2.zero;
			component.pivot = new Vector2(0f, 1f);
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.zero;
			WindowBlocker component2 = val.GetComponent<WindowBlocker>();
			activeRectTransforms.Add(component2);
			return component2;
		}

		public bool IsInputBlocked()
		{
			if (!Configs.ShowDebugMenu)
			{
				return false;
			}
			foreach (WindowBlocker activeRectTransform in activeRectTransforms)
			{
				if (activeRectTransform.isHovered)
				{
					return true;
				}
			}
			return false;
		}
	}
}
namespace DebugMenu.Scripts
{
	public abstract class ADrawable
	{
		public struct ButtonDisabledData
		{
			public bool Disabled;

			public string Reason;

			public ButtonDisabledData(string reason)
			{
				Disabled = true;
				Reason = reason;
			}
		}

		public struct LayoutScope : IDisposable
		{
			private readonly float originalX;

			private readonly Vector2 currentSize;

			private readonly int totalElements;

			private readonly bool horizontal;

			private readonly ADrawable scope;

			public readonly bool Horizontal => horizontal;

			public readonly int TotalElements => totalElements;

			public readonly Vector2 CurrentSize => currentSize;

			public LayoutScope(int totalElements, bool horizontal, ADrawable scope)
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				originalX = scope.X;
				this.totalElements = totalElements;
				this.horizontal = horizontal;
				this.scope = scope;
				currentSize = new Vector2(0f, 0f);
				scope.m_layoutScopes.Add(this);
			}

			public void Dispose()
			{
				scope.m_layoutScopes.Remove(this);
				if (horizontal)
				{
					scope.X = originalX;
					scope.Y += scope.RowHeight;
				}
			}
		}

		protected const float TopOffset = 20f;

		protected float X = 0f;

		protected float Y = 0f;

		protected float ColumnWidth = 200f;

		protected float RowHeight = 40f;

		protected float ColumnPadding = 5f;

		protected int Columns = 1;

		protected float MaxHeight = 1f;

		protected readonly Dictionary<string, string> m_buttonGroups = new Dictionary<string, string>();

		protected readonly List<LayoutScope> m_layoutScopes = new List<LayoutScope>();

		public float TotalWidth => (float)Columns * ColumnWidth + (float)(Columns - 1) * ColumnPadding;

		public float Height => MaxHeight + RowHeight;

		internal static float GetDisplayScalar()
		{
			Configs.WindowSizes windowSize = Configs.WindowSize;
			if (1 == 0)
			{
			}
			float result = windowSize switch
			{
				Configs.WindowSizes.OneQuarter => 0.25f, 
				Configs.WindowSizes.Half => 0.5f, 
				Configs.WindowSizes.ThreeQuarters => 0.75f, 
				Configs.WindowSizes.OneAndAQuarter => 1.25f, 
				Configs.WindowSizes.OneAndAHalf => 1.5f, 
				Configs.WindowSizes.OneAndThreeQuarters => 1.75f, 
				Configs.WindowSizes.Double => 2f, 
				_ => 1f, 
			};
			if (1 == 0)
			{
			}
			return result;
		}

		public virtual void OnGUI()
		{
		}

		public virtual void Reset()
		{
			X = ColumnPadding;
			Y = 20f;
			MaxHeight = 0f;
			Columns = 0;
		}

		public virtual void StartNewColumn()
		{
			X += ColumnWidth + ColumnPadding;
			Y = 20f;
			Columns++;
		}

		public abstract bool Button(string text, Vector2? size = null, string buttonGroup = null, Func<ButtonDisabledData> disabled = null);

		public abstract bool Toggle(string text, ref bool value, Vector2? size = null);

		public abstract bool Toggle(string text, ref ConfigEntry<bool> value, Vector2? size = null);

		public abstract void Label(string text, Vector2? size = null);

		public abstract void LabelHeader(string text, Vector2? size = null, bool leftAligned = false);

		public abstract void LabelBold(string text, Vector2? size = null);

		public abstract object InputField(object value, Type type, Vector2? size = null);

		public abstract string TextField(string text, Vector2? size = null);

		public abstract int IntField(int text, Vector2? size = null);

		public abstract float FloatField(float text, Vector2? size = null);

		public abstract void Padding(Vector2? size = null);

		public abstract (float X, float y, float w, float h) GetPosition(Vector2? size = null);

		public IDisposable HorizontalScope(int elementCount)
		{
			return new LayoutScope(elementCount, horizontal: true, this);
		}

		public IDisposable VerticalScope(int elementCount)
		{
			return new LayoutScope(elementCount, horizontal: false, this);
		}

		public abstract void Label(Sprite sprite, Vector2? size = null);
	}
	public abstract class DrawableGUI : ADrawable
	{
		private GUIStyle LabelHeaderStyle = GUIStyle.none;

		private GUIStyle LabelHeaderStyleLeft = GUIStyle.none;

		private GUIStyle LabelBoldStyle = GUIStyle.none;

		private GUIStyle ButtonStyle = GUIStyle.none;

		private GUIStyle ButtonDisabledStyle = GUIStyle.none;

		public override void OnGUI()
		{
			//IL_0017: 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_0025: 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: Expected O, but got Unknown
			//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_0057: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			LabelHeaderStyleLeft = Helpers.HeaderLabelStyle();
			LabelHeaderStyle = new GUIStyle(GUI.skin.label)
			{
				fontSize = 17,
				alignment = (TextAnchor)4,
				fontStyle = (FontStyle)1
			};
			LabelBoldStyle = new GUIStyle(GUI.skin.label)
			{
				fontStyle = (FontStyle)1
			};
			ButtonStyle = new GUIStyle(GUI.skin.button)
			{
				wordWrap = true
			};
			ButtonDisabledStyle = Helpers.DisabledButtonStyle();
			Reset();
		}

		public override void Reset()
		{
			X = ColumnPadding;
			Y = 20f;
			MaxHeight = 0f;
			Columns = 0;
		}

		public override void StartNewColumn()
		{
			X += ColumnWidth + ColumnPadding;
			Y = 20f;
			Columns++;
		}

		public override bool Button(string text, Vector2? size = null, string buttonGroup = null, Func<ButtonDisabledData> disabled = null)
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			(float X, float y, float w, float h) position = GetPosition(size);
			float item = position.X;
			float item2 = position.y;
			float item3 = position.w;
			float item4 = position.h;
			GUIStyle val = ButtonStyle;
			bool flag = false;
			ButtonDisabledData buttonDisabledData = disabled?.Invoke() ?? default(ButtonDisabledData);
			if (buttonDisabledData.Disabled)
			{
				if (!string.IsNullOrEmpty(buttonDisabledData.Reason))
				{
					GUI.Label(new Rect(item, item2, item3, item4), text + "\n(" + buttonDisabledData.Reason + ")", ButtonDisabledStyle);
				}
				else
				{
					GUI.Label(new Rect(item, item2, item3, item4), text, ButtonDisabledStyle);
				}
			}
			else if (buttonGroup == null)
			{
				flag = GUI.Button(new Rect(item, item2, item3, item4), text, ButtonStyle);
			}
			else
			{
				if (!m_buttonGroups.TryGetValue(buttonGroup, out var value))
				{
					m_buttonGroups[buttonGroup] = text;
				}
				if (value == text)
				{
					val = ButtonDisabledStyle;
				}
				flag = GUI.Button(new Rect(item, item2, item3, item4), text, val);
				if (flag)
				{
					m_buttonGroups[buttonGroup] = text;
				}
			}
			return flag;
		}

		public override bool Toggle(string text, ref bool value, Vector2? size = null)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			(float X, float y, float w, float h) position = GetPosition(size);
			float item = position.X;
			float item2 = position.y;
			float item3 = position.w;
			float item4 = position.h;
			bool flag = GUI.Toggle(new Rect(item, item2, item3, item4), value, text);
			if (flag != value)
			{
				value = flag;
				return true;
			}
			return false;
		}

		public override bool Toggle(string text, ref ConfigEntry<bool> value, Vector2? size = null)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			(float X, float y, float w, float h) position = GetPosition(size);
			float item = position.X;
			float item2 = position.y;
			float item3 = position.w;
			float item4 = position.h;
			bool value2 = value.Value;
			bool flag = GUI.Toggle(new Rect(item, item2, item3, item4), value2, text);
			if (flag != value2)
			{
				value.Value = flag;
				return true;
			}
			return false;
		}

		public override void Label(string text, Vector2? size = null)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			var (num, num2, num3, num4) = GetPosition(size);
			GUI.Label(new Rect(num, num2, num3, num4), text);
		}

		public override void Label(Sprite sprite, Vector2? size = null)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			if (!size.HasValue)
			{
				float num = Mathf.Min(RowHeight, ColumnWidth);
				size = new Vector2(num, num);
			}
			var (num2, num3, num4, num5) = GetPosition(size);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(num2, num3, num4, num5);
			Rect val2 = (Rect)(((Object)(object)sprite != (Object)null) ? sprite.GetTextureRect() : new Rect(0f, 0f, (float)((Texture)Texture2D.normalTexture).width, (float)((Texture)Texture2D.normalTexture).height));
			Texture2D val3 = (((Object)(object)sprite != (Object)null) ? sprite.texture : Texture2D.normalTexture);
			((Rect)(ref val2)).x = ((Rect)(ref val2)).x / (float)((Texture)val3).width;
			((Rect)(ref val2)).y = ((Rect)(ref val2)).y / (float)((Texture)val3).height;
			((Rect)(ref val2)).width = ((Rect)(ref val2)).width / (float)((Texture)val3).width;
			((Rect)(ref val2)).height = ((Rect)(ref val2)).height / (float)((Texture)val3).height;
			GUI.DrawTextureWithTexCoords(val, (Texture)(object)val3, val2);
		}

		public override void LabelHeader(string text, Vector2? size = null, bool leftAligned = false)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			var (num, num2, num3, num4) = GetPosition(size);
			GUI.Label(new Rect(num, num2, num3, num4), text, leftAligned ? LabelHeaderStyleLeft : LabelHeaderStyle);
		}

		public override void LabelBold(string text, Vector2? size = null)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			var (num, num2, num3, num4) = GetPosition(size);
			GUI.Label(new Rect(num, num2, num3, num4), text, LabelBoldStyle);
		}

		public override object InputField(object value, Type type, Vector2? size = null)
		{
			if (type == typeof(int))
			{
				return IntField((int)value, size);
			}
			if (type == typeof(float))
			{
				return FloatField((float)value, size);
			}
			if (type == typeof(string))
			{
				return TextField((string)value, size);
			}
			if (type == typeof(string))
			{
				bool value2 = (bool)value;
				Toggle("", ref value2, size);
				return value2;
			}
			Label("Unsupported type: " + type);
			return value;
		}

		public override string TextField(string text, Vector2? size = null)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			var (num, num2, num3, num4) = GetPosition(size);
			return GUI.TextField(new Rect(num, num2, num3, num4), text);
		}

		public override int IntField(int text, Vector2? size = null)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			(float X, float y, float w, float h) position = GetPosition(size);
			float item = position.X;
			float item2 = position.y;
			float item3 = position.w;
			float item4 = position.h;
			string s = GUI.TextField(new Rect(item, item2, item3, item4), text.ToString());
			if (!int.TryParse(s, out var result))
			{
				return text;
			}
			return result;
		}

		public override float FloatField(float text, Vector2? size = null)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			(float X, float y, float w, float h) position = GetPosition(size);
			float item = position.X;
			float item2 = position.y;
			float item3 = position.w;
			float item4 = position.h;
			string s = GUI.TextField(new Rect(item, item2, item3, item4), text.ToString());
			if (!float.TryParse(s, out var result))
			{
				return text;
			}
			return result;
		}

		public override void Padding(Vector2? size = null)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			float num = ((size.HasValue && size.Value.x != 0f) ? size.Value.x : ColumnWidth);
			float num2 = ((size.HasValue && size.Value.y != 0f) ? size.Value.y : RowHeight);
			float y = Y;
			Y += num2;
			MaxHeight = Mathf.Max(MaxHeight, Y);
			GUI.Label(new Rect(X, y, num, num2), "");
		}

		public override (float X, float y, float w, float h) GetPosition(Vector2? size = null)
		{
			//IL_001a: 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_004b: 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)
			float x = X;
			float y = Y;
			float num = ((size.HasValue && size.Value.y != 0f) ? size.Value.y : RowHeight);
			float num2 = ((size.HasValue && size.Value.x != 0f) ? size.Value.x : ColumnWidth);
			if (m_layoutScopes.Count == 0 || !m_layoutScopes[m_layoutScopes.Count - 1].Horizontal)
			{
				Y += num;
			}
			else
			{
				if (!size.HasValue)
				{
					num2 = ColumnWidth / (float)m_layoutScopes[m_layoutScopes.Count - 1].TotalElements;
				}
				X += num2;
			}
			MaxHeight = Mathf.Max(MaxHeight, Y);
			return (x, y, num2, num);
		}

		public new IDisposable HorizontalScope(int elementCount)
		{
			return new LayoutScope(elementCount, horizontal: true, this);
		}

		public new IDisposable VerticalScope(int elementCount)
		{
			return new LayoutScope(elementCount, horizontal: false, this);
		}
	}
}
namespace DebugMenu.Scripts.Utils
{
	public static class Helpers
	{
		public static bool IsInGame => GameController.IsGameActive;

		public static bool ContainsText(this string text, string substring, bool caseSensitive = true)
		{
			if (string.IsNullOrEmpty(text))
			{
				if (string.IsNullOrEmpty(substring))
				{
					return true;
				}
				return false;
			}
			if (string.IsNullOrEmpty(substring))
			{
				return false;
			}
			return text.IndexOf(substring, caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase) >= 0;
		}

		public static string DumpAllInfoAsJSONUsingReflection(object o)
		{
			if (o == null)
			{
				return "null";
			}
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			Type type = o.GetType();
			FieldInfo[] fields = type.GetFields();
			foreach (FieldInfo fieldInfo in fields)
			{
				dictionary[fieldInfo.Name] = SerializeData(fieldInfo.GetValue(o));
			}
			PropertyInfo[] properties = type.GetProperties();
			foreach (PropertyInfo propertyInfo in properties)
			{
				if (propertyInfo.CanRead)
				{
					dictionary[propertyInfo.Name] = SerializeData(propertyInfo.GetValue(o));
				}
			}
			return JSON.ToJson((object)dictionary);
		}

		private static string SerializeData(object o)
		{
			if (o == null)
			{
				return "null";
			}
			if (o.GetType().IsPrimitive || o is string)
			{
				return o.ToString();
			}
			return JSON.ToJson(o);
		}

		public static object GetDefaultValue(Type type)
		{
			if (type == null)
			{
				throw new ArgumentNullException("type");
			}
			Expression<Func<object>> expression = Expression.Lambda<Func<object>>(Expression.Convert(Expression.Default(type), typeof(object)), Array.Empty<ParameterExpression>());
			return expression.Compile()();
		}

		public static string ToLiteral(string input)
		{
			StringBuilder stringBuilder = new StringBuilder(input.Length + 2);
			stringBuilder.Append("\"");
			foreach (char c in input)
			{
				switch (c)
				{
				case '"':
					stringBuilder.Append("\\\"");
					continue;
				case '\\':
					stringBuilder.Append("\\\\");
					continue;
				case '\0':
					stringBuilder.Append("\\0");
					continue;
				case '\a':
					stringBuilder.Append("\\a");
					continue;
				case '\b':
					stringBuilder.Append("\\b");
					continue;
				case '\f':
					stringBuilder.Append("\\f");
					continue;
				case '\n':
					stringBuilder.Append("\\n");
					continue;
				case '\r':
					stringBuilder.Append("\\r");
					continue;
				case '\t':
					stringBuilder.Append("\\t");
					continue;
				case '\v':
					stringBuilder.Append("\\v");
					continue;
				}
				if (c >= ' ' && c <= '~')
				{
					stringBuilder.Append(c);
					continue;
				}
				stringBuilder.Append("\\u");
				int num = c;
				stringBuilder.Append(num.ToString("x4"));
			}
			stringBuilder.Append("\"");
			return stringBuilder.ToString();
		}

		public static GUIStyle ButtonWidth(float width, GUIStyle original = null)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = (GUIStyle)(((object)original) ?? ((object)new GUIStyle(GUI.skin.button)));
			val.fixedWidth = width;
			val.stretchWidth = true;
			return val;
		}

		public static GUIStyle DisabledButtonStyle()
		{
			//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_0021: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.button)
			{
				fontStyle = (FontStyle)1,
				wordWrap = true
			};
			val.normal.background = val.active.background;
			val.hover.background = val.active.background;
			val.onNormal.background = val.active.background;
			val.onHover.background = val.active.background;
			val.onActive.background = val.active.background;
			val.onFocused.background = val.active.background;
			val.normal.textColor = Color.black;
			return val;
		}

		public static GUIStyle HeaderLabelStyle()
		{
			//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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			return new GUIStyle(GUI.skin.label)
			{
				fontSize = 17,
				fontStyle = (FontStyle)1
			};
		}

		public static GUIStyle HeaderLabelStyleRight()
		{
			//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_0019: 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_002a: Expected O, but got Unknown
			return new GUIStyle(GUI.skin.label)
			{
				fontSize = 17,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)5
			};
		}
	}
	public static class KeyCodeExtensions
	{
		public static string Serialize(this KeyCode keyCode)
		{
			return ((object)(KeyCode)(ref keyCode)).ToString();
		}

		public static string Serialize(this IEnumerable<KeyCode> keyCode, string separator = ",", bool includeUnassigned = false)
		{
			string result = "";
			if (keyCode != null)
			{
				result = string.Join(separator, keyCode.Select((KeyCode a) => a.Serialize()));
			}
			if (includeUnassigned && string.IsNullOrEmpty(separator))
			{
				result = "Unassigned";
			}
			return result;
		}
	}
}
namespace DebugMenu.Scripts.All
{
	public class AllGameModes : BaseGameMode
	{
		public AllGameModes(DebugWindow window)
			: base(window)
		{
		}

		public override void Update()
		{
		}

		public override void OnGUI()
		{
			Input.DrawToggleBlockInput(Window);
			using (Window.HorizontalScope(5))
			{
				Window.Label("<b>Time Scale:</b>");
				if (Window.Button("0x"))
				{
					SetTimeScale(0f);
				}
				if (Window.Button("1x"))
				{
					SetTimeScale(1f);
				}
				if (Window.Button("5x"))
				{
					SetTimeScale(5f);
				}
				if (Window.Button("10x"))
				{
					SetTimeScale(10f);
				}
			}
			if (Window.Button("Show Game Info"))
			{
				Plugin.Instance.ToggleWindow<GameInfoPopup>();
			}
			using (Window.HorizontalScope(4))
			{
				Window.Label("<b>Menu Scale:</b>");
				Window.Label($"{ADrawable.GetDisplayScalar()}x");
				int sizeAsInt = (int)Configs.WindowSize;
				if (Window.Button("-", null, null, delegate
				{
					ADrawable.ButtonDisabledData result2 = default(ADrawable.ButtonDisabledData);
					result2.Disabled = sizeAsInt <= 0;
					return result2;
				}))
				{
					sizeAsInt--;
					Configs.WindowSize = (Configs.WindowSizes)sizeAsInt;
				}
				if (Window.Button("+", null, null, delegate
				{
					ADrawable.ButtonDisabledData result = default(ADrawable.ButtonDisabledData);
					result.Disabled = sizeAsInt > 6;
					return result;
				}))
				{
					sizeAsInt++;
					Configs.WindowSize = (Configs.WindowSizes)sizeAsInt;
				}
			}
		}

		public override void OnGUIMinimal()
		{
		}

		public void SetTimeScale(float speed)
		{
			Time.timeScale = speed;
			Time.fixedDeltaTime = Plugin.StartingFixedDeltaTime * Time.timeScale;
		}

		public override void Restart()
		{
		}

		public override void Reload()
		{
		}
	}
}
namespace DebugMenu.Scripts.Acts
{
	public class InventoryWindow : BaseWindow
	{
		private Vector2 position;

		private string filterText = "";

		private int amountToAdd = 1;

		private bool showEatables = true;

		private bool showFuels = true;

		private bool showOther = true;

		private bool[] favourites = new bool[2] { true, true };

		private bool[] ownershipType = new bool[2] { true, true };

		private bool hideEffectsWithMissingKeys = true;

		private List<GoodModel> allGoods = null;

		public override string PopupName => "Inventory";

		public override Vector2 Size => new Vector2(1000f, 800f);

		public override bool ClosableWindow => true;

		public override void OnGUI()
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: 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_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			base.OnGUI();
			IStorageService storageService = Serviceable.StorageService;
			StorageService val = (StorageService)(object)((storageService is StorageService) ? storageService : null);
			if (val == null)
			{
				Plugin.Log.LogError((object)"EffectsService is null");
				return;
			}
			LockedGoodsCollection goods = val.Main.Goods;
			if (allGoods == null)
			{
				allGoods = Serviceable.Settings.Goods.ToList();
				SortGoods();
			}
			List<GoodModel> itemsInStorage = new List<GoodModel>(((GoodsCollection)goods).goods.Keys.Select((string a) => Serviceable.Settings.GetGood(a)));
			ColumnWidth = 200f;
			int count = allGoods.Count;
			int num = Mathf.Max(Mathf.FloorToInt(Size.y / RowHeight) - 2, 1);
			int num2 = Mathf.CeilToInt((float)count / (float)num) + 1;
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(new Vector2(0f, 0f), new Vector2((float)num2 * ColumnWidth + (float)((num2 - 1) * 10), (float)num * RowHeight));
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(new Vector2(0f, 0f), Size - new Vector2(10f, 25f));
			position = GUI.BeginScrollView(val3, position, val2);
			Label("Amount to Give/Remove", (Vector2?)new Vector2(0f, RowHeight / 2f));
			amountToAdd = IntField(amountToAdd, (Vector2?)new Vector2(0f, RowHeight / 2f));
			Label("Filter", (Vector2?)new Vector2(0f, RowHeight / 2f));
			filterText = TextField(filterText, (Vector2?)new Vector2(0f, RowHeight / 2f));
			Label("Favourite", (Vector2?)new Vector2(0f, RowHeight / 2f));
			RadialButtons(favourites, new string[2] { "Favourited", "NotFavourited" }, RowHeight / 2f);
			Label("Ownership", (Vector2?)new Vector2(0f, RowHeight / 2f));
			RadialButtons(ownershipType, new string[2] { "Owned", "NotOwned" }, RowHeight / 2f);
			Label("Categories", (Vector2?)new Vector2(0f, RowHeight / 2f));
			Toggle("Eatables", ref showEatables, (Vector2?)new Vector2(0f, RowHeight / 2f));
			Toggle("Fuels", ref showFuels, (Vector2?)new Vector2(0f, RowHeight / 2f));
			Toggle("Other", ref showOther, (Vector2?)new Vector2(0f, RowHeight / 2f));
			Label("Other", (Vector2?)new Vector2(0f, RowHeight / 2f));
			Toggle("Hide Missing Keys", ref hideEffectsWithMissingKeys);
			StartNewColumn();
			ColumnWidth = 200f;
			int num3 = 0;
			Vector2 value2 = default(Vector2);
			for (int i = 0; i < count; i++)
			{
				GoodModel val4 = allGoods[i];
				bool flag = Plugin.SaveData.favouritedGoods.Contains(((Object)val4).name);
				if (!IsFiltered(itemsInStorage, val4, flag))
				{
					continue;
				}
				((GoodsCollection)goods).goods.TryGetValue(((Object)val4).name, out var value);
				using (HorizontalScope(4))
				{
					Label(val4.icon);
					if (Button(flag ? "✓" : "X", (Vector2?)new Vector2(30f, 0f), (string)null, (Func<ButtonDisabledData>)null))
					{
						if (flag)
						{
							Plugin.SaveData.favouritedGoods.Remove(((Object)val4).name);
						}
						else
						{
							Plugin.SaveData.favouritedGoods.Add(((Object)val4).name);
						}
						SaveDataChanged();
					}
					if (Button("-", (Vector2?)new Vector2(30f, 0f), (string)null, (Func<ButtonDisabledData>)null))
					{
						((GoodsCollection)goods).Remove(((Object)val4).name, amountToAdd);
					}
					if (Button("+", (Vector2?)new Vector2(30f, 0f), (string)null, (Func<ButtonDisabledData>)null))
					{
						((GoodsCollection)goods).Add(((Object)val4).name, amountToAdd);
					}
					((Vector2)(ref value2))..ctor(ColumnWidth - RowHeight * 3f, RowHeight);
					Label($"{value}x\n{val4.displayName}", value2);
				}
				num3++;
				if (num3 >= num)
				{
					StartNewColumn();
					num3 = 0;
				}
			}
			GUI.EndScrollView();
		}

		private bool IsFiltered(List<GoodModel> itemsInStorage, GoodModel good, bool favourited)
		{
			GoodModel val = ((IEnumerable<GoodModel>)itemsInStorage).FirstOrDefault((Func<GoodModel, bool>)((GoodModel a) => ((Object)a).name == ((SO)good).Name));
			if (!favourited && !favourites[1])
			{
				return false;
			}
			if (favourited && !favourites[0])
			{
				return false;
			}
			if ((Object)(object)val == (Object)null && !ownershipType[1])
			{
				return false;
			}
			if ((Object)(object)val != (Object)null && !ownershipType[0])
			{
				return false;
			}
			if (hideEffectsWithMissingKeys && string.IsNullOrEmpty(good.displayName.key))
			{
				return false;
			}
			if (!showEatables && good.eatable)
			{
				return false;
			}
			if (!showFuels && good.canBeBurned)
			{
				return false;
			}
			if (!showOther && !good.canBeBurned && !good.eatable)
			{
				return false;
			}
			string text = good.displayName.GetText();
			string description = good.Description;
			if (!string.IsNullOrEmpty(filterText) && !text.ContainsText(filterText, caseSensitive: false) && !description.ContainsText(filterText, caseSensitive: false))
			{
				return false;
			}
			return true;
		}

		private void RadialButtons(bool[] type, string[] buttons, float height)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			Vector2 value = default(Vector2);
			((Vector2)(ref value))..ctor(ColumnWidth / (float)buttons.Length, height);
			using (HorizontalScope(buttons.Length))
			{
				for (int i = 0; i < buttons.Length; i++)
				{
					bool value2 = type[i];
					if (Toggle(buttons[i], ref value2, value))
					{
						type[i] = !type[i];
					}
				}
			}
		}

		private void SortGoods()
		{
			allGoods.Sort(delegate(GoodModel a, GoodModel b)
			{
				bool flag = Plugin.SaveData.favouritedGoods.Contains(((Object)a).name);
				bool flag2 = Plugin.SaveData.favouritedGoods.Contains(((Object)b).name);
				return (flag != flag2) ? ((!flag) ? 1 : (-1)) : a.displayName.GetText().CompareTo(b.displayName.GetText());
			});
		}

		private void SaveDataChanged()
		{
			Plugin.SaveData.Save();
			SortGoods();
		}
	}
	public class PerksWindow : BaseWindow
	{
		private enum EffectType
		{
			Effect,
			Altar,
			Seasonal
		}

		private class Effect
		{
			public EffectModel model;

			public EffectType type;

			public Effect(EffectType effect, EffectModel effectModel)
			{
				type = effect;
				model = effectModel;
			}
		}

		private Dictionary<string, Effect> allEffectsLookup = null;

		private List<Effect> orderedEffects = null;

		private Vector2 position;

		private string filterText = "";

		private bool hideEffectsWithMissingKeys = true;

		private bool[] favourites = new bool[2] { true, true };

		private bool[] ownershipType = new bool[2] { true, true };

		private bool[] benefitType = new bool[2] { true, true };

		private bool[] effectType = new bool[3] { false, false, true };

		private Dictionary<EffectRarity, bool> rarityFilter = new Dictionary<EffectRarity, bool>();

		public override string PopupName => "Perks";

		public override Vector2 Size => new Vector2(1000f, 800f);

		public override bool ClosableWindow => true;

		public override void OnGUI()
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			base.OnGUI();
			IEffectsService effectsService = Serviceable.EffectsService;
			EffectsService val = (EffectsService)(object)((effectsService is EffectsService) ? effectsService : null);
			if (val == null)
			{
				Plugin.Log.LogError((object)"EffectsService is null");
				return;
			}
			IPerksService perksService = GameMB.PerksService;
			PerksService val2 = (PerksService)(object)((perksService is PerksService) ? perksService : null);
			if (val2 == null)
			{
				Plugin.Log.LogError((object)"PerksService is null");
				return;
			}
			if (allEffectsLookup == null)
			{
				SetupEffectLookup();
			}
			List<PerkState> sortedPerks = val2.SortedPerks;
			ColumnWidth = 200f;
			int count = orderedEffects.Count;
			int num = Mathf.Max(Mathf.FloorToInt((Size.y - 20f) / RowHeight) - 1, 1);
			int num2 = Mathf.CeilToInt((float)count / (float)num) + 1;
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(new Vector2(0f, 0f), new Vector2((float)(num2 * 300 + (num2 - 1) * 10), (float)num * RowHeight));
			Rect val4 = default(Rect);
			((Rect)(ref val4))..ctor(new Vector2(0f, 0f), Size - new Vector2(10f, 25f));
			position = GUI.BeginScrollView(val4, position, val3);
			DrawFilters();
			StartNewColumn();
			ColumnWidth = 300f;
			int num3 = 0;
			Vector2 value = default(Vector2);
			for (int i = 0; i < count; i++)
			{
				EffectModel model = orderedEffects[i].model;
				bool flag = Plugin.SaveData.favouritedPerks.Contains(((Object)model).name);
				if (!FilterEffect(model, orderedEffects, i, sortedPerks, flag, out var perk))
				{
					continue;
				}
				int num4 = perk?.stacks ?? 0;
				using (HorizontalScope(3))
				{
					Label(model.GetIcon());
					if (Button(flag ? "✓" : "X", (Vector2?)new Vector2(30f, 0f), (string)null, (Func<ButtonDisabledData>)null))
					{
						if (flag)
						{
							Plugin.SaveData.favouritedPerks.Remove(((Object)model).name);
						}
						else
						{
							Plugin.SaveData.favouritedPerks.Add(((Object)model).name);
						}
						SaveDataChanged();
					}
					if (Button("-1", (Vector2?)new Vector2(30f, 0f), (string)null, (Func<ButtonDisabledData>)null))
					{
						model.Remove((EffectContextType)0, (string)null, 0);
					}
					if (Button("+1", (Vector2?)new Vector2(30f, 0f), (string)null, (Func<ButtonDisabledData>)null))
					{
						model.Apply((EffectContextType)0, (string)null, 0);
					}
					((Vector2)(ref value))..ctor(ColumnWidth - RowHeight * 3f, RowHeight);
					Label($"{num4}x ({model.rarity})\n{model.DisplayName}", value);
				}
				num3++;
				if (num3 >= num)
				{
					StartNewColumn();
					num3 = 0;
				}
			}
			GUI.EndScrollView();
		}

		private void DrawFilters()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: 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_0233: Unknown result type (might be due to invalid IL or missing references)
			Label("Filter", (Vector2?)new Vector2(0f, RowHeight / 2f));
			filterText = TextField(filterText, (Vector2?)new Vector2(0f, RowHeight / 2f));
			Label("Favourite", (Vector2?)new Vector2(0f, RowHeight / 2f));
			RadialButtons(favourites, new string[2] { "Favourited", "NotFavourited" }, RowHeight / 2f);
			Label("Ownership", (Vector2?)new Vector2(0f, RowHeight / 2f));
			RadialButtons(ownershipType, new string[2] { "Owned", "NotOwned" }, RowHeight / 2f);
			Label("Benefit", (Vector2?)new Vector2(0f, RowHeight / 2f));
			RadialButtons(benefitType, new string[2] { "Positive", "Negative" }, RowHeight / 2f);
			Label("Type", (Vector2?)new Vector2(0f, RowHeight / 2f));
			RadialButtons(effectType, Enum.GetNames(typeof(EffectType)).ToArray(), RowHeight / 2f);
			Label("Rarity", (Vector2?)new Vector2(0f, RowHeight / 2f));
			foreach (EffectRarity value in Enum.GetValues(typeof(EffectRarity)))
			{
				RarityToggle(value);
			}
			Label("Other", (Vector2?)new Vector2(0f, RowHeight / 2f));
			Toggle("Hide Missing Keys", ref hideEffectsWithMissingKeys);
		}

		private void RarityToggle(EffectRarity rarity)
		{
			//IL_0007: 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_0050: 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)
			bool value = rarityFilter[rarity];
			if (Toggle(((object)(EffectRarity)(ref rarity)).ToString(), ref value, (Vector2?)new Vector2(ColumnWidth / 2f, RowHeight / 2f)))
			{
				rarityFilter[rarity] = !rarityFilter[rarity];
			}
		}

		private bool FilterEffect(EffectModel cornerStone, List<Effect> elements, int i, List<PerkState> ownedPerks, bool favourited, out PerkState perk)
		{
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			perk = null;
			if (!string.IsNullOrEmpty(filterText) && !cornerStone.DisplayName.ContainsText(filterText, caseSensitive: false) && !cornerStone.Description.ContainsText(filterText, caseSensitive: false))
			{
				return false;
			}
			if (!favourited && !favourites[1])
			{
				return false;
			}
			if (favourited && !favourites[0])
			{
				return false;
			}
			if (!cornerStone.IsPositive && !benefitType[1])
			{
				return false;
			}
			if (cornerStone.isPositive && !benefitType[0])
			{
				return false;
			}
			if (!effectType[(int)elements[i].type])
			{
				return false;
			}
			if (hideEffectsWithMissingKeys && string.IsNullOrEmpty(cornerStone.DisplayNameKey))
			{
				return false;
			}
			if (!rarityFilter[cornerStone.rarity])
			{
				return false;
			}
			perk = ((IEnumerable<PerkState>)ownedPerks).FirstOrDefault((Func<PerkState, bool>)((PerkState a) => a.name == ((SO)cornerStone).Name));
			if (perk == null && !ownershipType[1])
			{
				return false;
			}
			if (perk != null && !ownershipType[0])
			{
				return false;
			}
			return true;
		}

		private void RadialButtons(bool[] type, string[] buttons, float height)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			Vector2 value = default(Vector2);
			((Vector2)(ref value))..ctor(ColumnWidth / (float)buttons.Length, height);
			using (HorizontalScope(buttons.Length))
			{
				for (int i = 0; i < buttons.Length; i++)
				{
					bool value2 = type[i];
					if (Toggle(buttons[i], ref value2, value))
					{
						type[i] = !type[i];
					}
				}
			}
		}

		private IEnumerable<Effect> GetAllEffects()
		{
			EffectModel[] effects = SO.Settings.effects;
			foreach (EffectModel effect in effects)
			{
				yield return new Effect(EffectType.Effect, effect);
			}
			AltarEffectModel[] altarEffects = SO.Settings.altarEffects;
			foreach (AltarEffectModel effect3 in altarEffects)
			{
				yield return new Effect(EffectType.Altar, effect3.upgradedEffect);
				yield return new Effect(EffectType.Altar, effect3.regularEffect);
			}
			IEnumerable<EffectModel> effectModels = from e in Serviceable.StateService.Conditions.earlyEffects.Concat(Serviceable.StateService.Conditions.lateEffects).Concat(Serviceable.WorldStateService.Cycle.activeEventsEffects)
				select Serviceable.Settings.GetEffect(e);
			IEnumerable<EffectModel> models = Enumerable.Concat(second: Serviceable.BiomeService.Difficulty.modifiers.Select((AscensionModifierModel e) => e.effect), first: from e in effectModels.Concat(Serviceable.Biome.effects).Concat(Serviceable.Biome.seasons.SeasonRewards.SelectMany((SeasonRewardModel m) => m.effectsTable.GetAllEffects()))
				orderby e.IsPositive, e.DisplayName
				select e);
			foreach (EffectModel effect2 in models)
			{
				yield return new Effect(EffectType.Seasonal, effect2);
			}
		}

		private void SetupEffectLookup()
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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)
			Plugin.Log.LogInfo((object)"Finding all effects...");
			allEffectsLookup = new Dictionary<string, Effect>();
			foreach (Effect allEffect in GetAllEffects())
			{
				if ((Object)(object)allEffect.model != (Object)null)
				{
					allEffectsLookup[((SO)allEffect.model).Name] = allEffect;
				}
			}
			orderedEffects = allEffectsLookup.Values.ToList();
			SortEffects();
			Plugin.Log.LogInfo((object)("AllEffects count: " + orderedEffects.Count));
			foreach (EffectRarity value in Enum.GetValues(typeof(EffectRarity)))
			{
				rarityFilter[value] = true;
			}
		}

		private void SortEffects()
		{
			orderedEffects.Sort(delegate(Effect a, Effect b)
			{
				bool flag = Plugin.SaveData.favouritedPerks.Contains(((SO)a.model).Name);
				bool flag2 = Plugin.SaveData.favouritedPerks.Contains(((SO)b.model).Name);
				if (flag != flag2)
				{
					return (!flag) ? 1 : (-1);
				}
				return (a.model.IsPositive != b.model.IsPositive) ? ((!a.model.IsPositive) ? 1 : (-1)) : a.model.DisplayName.CompareTo(b.model.DisplayName);
			});
		}

		private void SaveDataChanged()
		{
			Plugin.SaveData.Save();
			SortEffects();
		}
	}
	public class VillagersWindow : BaseWindow
	{
		private Vector2 position;

		public override string PopupName => "Villagers";

		public override Vector2 Size => new Vector2(650f, 420f);

		public override bool ClosableWindow => true;

		public override void OnGUI()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			base.OnGUI();
			List<string> list = new List<string>(Serviceable.VillagersService.Races.Keys);
			ColumnWidth = 400f;
			int count = list.Count;
			int num = Mathf.Max(Mathf.FloorToInt(Size.y / RowHeight) - 2, 1);
			int num2 = Mathf.CeilToInt((float)count / (float)num) + 1;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(new Vector2(0f, 0f), new Vector2((float)num2 * ColumnWidth + (float)((num2 - 1) * 10), (float)num * RowHeight));
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(new Vector2(0f, 0f), Size - new Vector2(10f, 25f));
			position = GUI.BeginScrollView(val2, position, val);
			int num3 = 0;
			for (int i = 0; i < count; i++)
			{
				string text = list[i];
				List<Villager> list2 = Serviceable.VillagersService.Races[text];
				int count2 = list2.Count;
				RaceModel val3 = RaceTypesExtensions.ToRaceModel(text);
				using (HorizontalScope(5))
				{
					Label(val3.icon);
					Label($"{count2}x\n{text}");
					if (Button("+1"))
					{
						SO.VillagersService.SpawnNewVillager(RaceTypesExtensions.ToRaceModel(text));
					}
					if (Button("1 Leaves") && count2 > 0)
					{
						list2[count2 - 1].Die((VillagerLossType)2, "DebugMenu", false, 25f, (SoundModel)null);
					}
					if (Button("1 Dies") && count2 > 0)
					{
						list2[count2 - 1].Die((VillagerLossType)1, "DebugMenu", true, 25f, (SoundModel)null);
					}
				}
				num3++;
				if (num3 >= num)
				{
					StartNewColumn();
					num3 = 0;
				}
			}
			GUI.EndScrollView();
		}
	}
	public abstract class BaseBattleSequence
	{
		protected BaseWindow window;

		public BaseBattleSequence(BaseWindow window)
		{
			this.window = window;
		}

		public virtual void OnGUI()
		{
		}
	}
	public abstract class BaseGameMode
	{
		public readonly ManualLogSource Logger;

		public readonly DebugWindow Window;

		protected BaseBattleSequence m_battleSequence;

		protected BaseMapSequence m_mapSequence;

		public BaseBattleSequence BattleSequence => m_battleSequence;

		public BaseMapSequence MapSequence => m_mapSequence;

		public BaseGameMode(DebugWindow window)
		{
			Window = window;
			Logger = Plugin.Log;
		}

		public virtual void Update()
		{
		}

		public abstract void OnGUI();

		public abstract void OnGUIMinimal();

		public abstract void Reload();

		public abstract void Restart();

		public void Log(string log)
		{
			Logger.LogInfo((object)("[" + GetType().Name + "] " + log));
		}

		public void Warning(string log)
		{
			Logger.LogWarning((object)("[" + GetType().Name + "] " + log));
		}

		public void Error(string log)
		{
			Logger.LogError((object)("[" + GetType().Name + "] " + log));
		}

		public void DrawItemsGUI()
		{
		}
	}
	public abstract class BaseMapSequence
	{
		public virtual void OnGUI()
		{
		}

		public abstract void ToggleSkipNextNode();

		public abstract void ToggleAllNodes();
	}
	public class DebugWindow : BaseWindow
	{
		public enum ToggleStates
		{
			Off,
			Minimal,
			All
		}

		private BaseGameMode currentGameMode = null;

		private ToggleStates currentState = ToggleStates.Off;

		private readonly AllGameModes allGameModes;

		private readonly ATSGameMode _atsGameMode;

		private Vector2 position;

		public override string PopupName => "Debug Menu";

		public override Vector2 Size => new Vector2(650f, 420f);

		public override bool ClosableWindow => false;

		public BaseGameMode CurrentGameMode => currentGameMode;

		public AllGameModes AllGameModes => allGameModes;

		public DebugWindow()
		{
			allGameModes = new AllGameModes(this);
			_atsGameMode = new ATSGameMode(this);
			base.IsActive = true;
			isOpen = false;
		}

		public override void Update()
		{
			currentGameMode = _atsGameMode;
			_atsGameMode?.Update();
		}

		public override void OnGUI()
		{
			//IL_003b: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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)
			float num = Mathf.Max(base.TotalWidth, ((Rect)(ref windowRect)).width);
			float num2 = Mathf.Max(base.Height, ((Rect)(ref windowRect)).y);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(new Vector2(0f, 0f), new Vector2(num, num2));
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(new Vector2(0f, 0f), Size - new Vector2(10f, 0f));
			position = GUI.BeginScrollView(val2, position, val);
			DrawToggleButtons();
			if (currentState > ToggleStates.Off)
			{
				base.OnGUI();
				if (currentState == ToggleStates.All || currentGameMode == null)
				{
					allGameModes.OnGUI();
					StartNewColumn();
				}
				if (currentGameMode != null)
				{
					if (currentState == ToggleStates.Minimal)
					{
						currentGameMode.OnGUIMinimal();
					}
					else
					{
						currentGameMode.OnGUI();
					}
				}
			}
			GUI.EndScrollView();
		}

		private void DrawToggleButtons()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			if (GUI.Button(new Rect(5f, 0f, 20f, 20f), "-"))
			{
				currentState = ToggleStates.Off;
				position = Vector2.zero;
			}
			if (GUI.Button(new Rect(25f, 0f, 20f, 20f), "+"))
			{
				currentState = ToggleStates.Minimal;
			}
			if (GUI.Button(new Rect(45f, 0f, 25f, 20f), "X"))
			{
				currentState = ToggleStates.All;
			}
		}

		protected override bool OnToggleWindowDraw()
		{
			//IL_0078: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			switch (currentState)
			{
			case ToggleStates.Off:
				((Rect)(ref windowRect)).Set(((Rect)(ref windowRect)).x, ((Rect)(ref windowRect)).y, 100f, 60f);
				break;
			case ToggleStates.Minimal:
				((Rect)(ref windowRect)).Set(((Rect)(ref windowRect)).x, ((Rect)(ref windowRect)).y, ColumnWidth + 40f, Size.y);
				break;
			case ToggleStates.All:
				((Rect)(ref windowRect)).Set(((Rect)(ref windowRect)).x, ((Rect)(ref windowRect)).y, Size.x, Size.y);
				break;
			}
			BeginDrawingGUI();
			return false;
		}
	}
}
namespace DebugMenu.Scripts.Popups
{
	public abstract class BaseWindow : DrawableGUI
	{
		protected bool isActive = false;

		protected Rect windowRect = new Rect(20f, 20f, 512f, 512f);

		protected bool isOpen = true;

		protected WindowBlocker windowBlocker;

		public abstract string PopupName { get; }

		public abstract Vector2 Size { get; }

		public virtual bool ClosableWindow => true;

		public bool IsActive
		{
			get
			{
				return isActive;
			}
			set
			{
				isActive = value;
				((Component)windowBlocker).gameObject.SetActive(value);
			}
		}

		protected BaseWindow()
		{
			//IL_001c: 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)
			windowBlocker = Plugin.Instance.CreateWindowBlocker();
			((Object)((Component)windowBlocker).gameObject).name = PopupName + " Window Blocker";
			IsActive = false;
		}

		~BaseWindow()
		{
			Plugin.AllWindows.Remove(this);
		}

		public virtual void Update()
		{
		}

		private void SetMatrixGUI(float scalar)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(scalar, scalar, 1f);
			GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, val);
		}

		public void OnWindowGUI()
		{
			//IL_0021: 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_003d: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			float displayScalar = ADrawable.GetDisplayScalar();
			SetMatrixGUI(displayScalar);
			int num = GetType().GetHashCode() + 100;
			windowRect = GUI.Window(num, windowRect, new WindowFunction(OnWindowDraw), PopupName);
			RectTransform rectTransform = windowBlocker.RectTransform;
			((Object)((Component)rectTransform).gameObject).name = PopupName + " Blocker";
			rectTransform.anchoredPosition = new Vector2(((Rect)(ref windowRect)).position.x * displayScalar, (float)Screen.height - ((Rect)(ref windowRect)).position.y * displayScalar);
			rectTransform.sizeDelta = ((Rect)(ref windowRect)).size * displayScalar;
		}

		private void OnWindowDraw(int windowID)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			GUI.DragWindow(new Rect(25f, 0f, Size.x, 20f));
			if (ClosableWindow)
			{
				if (!OnClosableWindowDraw())
				{
					return;
				}
			}
			else if (!OnToggleWindowDraw())
			{
				return;
			}
			((Rect)(ref windowRect)).Set(((Rect)(ref windowRect)).x, ((Rect)(ref windowRect)).y, Size.x, Size.y);
			BeginDrawingGUI();
		}

		protected virtual void BeginDrawingGUI()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginArea(new Rect(5f, 25f, ((Rect)(ref windowRect)).width, ((Rect)(ref windowRect)).height));
			OnGUI();
			GUILayout.EndArea();
		}

		protected virtual bool OnToggleWindowDraw()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			isOpen = GUI.Toggle(new Rect(5f, 0f, 20f, 20f), isOpen, "");
			if (!isOpen)
			{
				((Rect)(ref windowRect)).Set(((Rect)(ref windowRect)).x, ((Rect)(ref windowRect)).y, 120f, 60f);
				return false;
			}
			return true;
		}

		protected bool OnClosableWindowDraw()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (GUI.Button(new Rect(5f, 0f, 20f, 20f), "X"))
			{
				IsActive = false;
				return false;
			}
			return true;
		}
	}
	public class ButtonListPopup : BaseWindow
	{
		private string header = "";

		private string filterText = "";

		private List<string> buttonNames = new List<string>();

		private List<string> buttonValues = new List<string>();

		private string popupNameOverride = "Button List";

		private Action<int, string, string> callback;

		private Vector2 position;

		private string disableMatch;

		public override string PopupName => popupNameOverride;

		public override Vector2 Size => new Vector2(630f, 600f);

		public override void OnGUI()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_009c: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			base.OnGUI();
			int count = buttonNames.Count;
			int num = Mathf.Max(Mathf.FloorToInt(Size.y / RowHeight) - 2, 1);
			int num2 = Mathf.CeilToInt((float)count / (float)num) + 1;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(new Vector2(0f, 0f), new Vector2((float)num2 * ColumnWidth + (float)((num2 - 1) * 10), (float)num * RowHeight));
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(new Vector2(0f, 0f), Size - new Vector2(10f, 25f));
			position = GUI.BeginScrollView(val2, position, val);
			LabelHeader(header);
			Label("Filter", (Vector2?)new Vector2(0f, RowHeight / 2f));
			filterText = TextField(filterText, (Vector2?)new Vector2(0f, RowHeight / 2f));
			DrawExtraTools();
			StartNewColumn();
			int num3 = 0;
			for (int i = 0; i < count; i++)
			{
				string text = buttonNames[i];
				string buttonValue = buttonValues[i];
				if ((string.IsNullOrEmpty(filterText) || text.ContainsText(filterText, caseSensitive: false) || buttonValue.ContainsText(filterText, caseSensitive: false)) && IsFiltered(text, buttonValue))
				{
					if (Button(text, null, null, delegate
					{
						ButtonDisabledData result = default(ButtonDisabledData);
						result.Disabled = buttonValue == disableMatch;
						return result;
					}))
					{
						callback(i, buttonValue, disableMatch);
						Plugin.Instance.ToggleWindow<ButtonListPopup>();
					}
					num3++;
					if (num3 >= num)
					{
						StartNewColumn();
						num3 = 0;
					}
				}
			}
			GUI.EndScrollView();
		}

		public virtual bool IsFiltered(string buttonName, string buttonValue)
		{
			return true;
		}

		public virtual void DrawExtraTools()
		{
		}

		public static bool OnGUI(DrawableGUI gui, string buttonText, string headerText, Func<Tuple<List<string>, List<string>>> GetDataCallback, Action<int, string, string> OnChoseButtonCallback, string disableMatch = null)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (gui.Button(buttonText))
			{
				Debug.Log((object)("ButtonListPopup pressed " + buttonText));
				Tuple<List<string>, List<string>> tuple = GetDataCallback();
				ButtonListPopup buttonListPopup = Plugin.Instance.ToggleWindow<ButtonListPopup>();
				buttonListPopup.position = Vector2.zero;
				buttonListPopup.popupNameOverride = buttonText;
				buttonListPopup.callback = OnChoseButtonCallback;
				buttonListPopup.buttonNames = tuple.Item1;
				buttonListPopup.buttonValues = tuple.Item2;
				buttonListPopup.header = headerText;
				buttonListPopup.filterText = "";
				buttonListPopup.disableMatch = disableMatch;
				return true;
			}
			return false;
		}
	}
	public class GameInfoPopup : BaseWindow
	{
		public float updateInterval = 0.5f;

		private float lastInterval;

		private int frames = 0;

		private int fps;

		public override string PopupName => "Game Info";

		public override Vector2 Size => new Vector2(220f, 500f);

		public override void OnGUI()
		{
			//IL_0054: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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)
			base.OnGUI();
			Label("FPS: " + fps);
			int sceneCount = SceneManager.sceneCount;
			LabelHeader($"Scenes ({sceneCount})");
			Scene activeScene = SceneManager.GetActiveScene();
			for (int i = 0; i < sceneCount; i++)
			{
				Scene sceneAt = SceneManager.GetSceneAt(i);
				if (sceneAt == activeScene)
				{
					Label($"{i}: {((Scene)(ref sceneAt)).name} (Active)");
				}
				else
				{
					Label($"{i}: {((Scene)(ref sceneAt)).name}");
				}
			}
		}

		public override void Update()
		{
			base.Update();
			frames++;
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (realtimeSinceStartup > lastInterval + updateInterval)
			{
				fps = (int)((float)frames / (realtimeSinceStartup - lastInterval));
				frames = 0;
				lastInterval = realtimeSinceStartup;
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}