Decompiled source of TooManyPotions v2.0.2

plugins/EasierUI.dll

Decompiled 5 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using EasierUI.Controls.Contrainers;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("EasierUI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EasierUI")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a0208842-3da2-4cf4-a5ab-d09ccc9f1578")]
[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 EasierUI
{
	public static class ControlsResources
	{
		public struct Resources
		{
			public Sprite standard;

			public Sprite background;

			public Sprite childBackground;

			public Sprite inputField;

			public Sprite knob;

			public Sprite checkmark;

			public Sprite dropdown;

			public Sprite mask;

			public TMP_FontAsset font;
		}

		public static Resources ConvertToTMP(Resources resources)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			Resources result = default(Resources);
			result.standard = resources.standard;
			result.background = resources.background;
			result.inputField = resources.inputField;
			result.knob = resources.knob;
			result.checkmark = resources.checkmark;
			result.dropdown = resources.dropdown;
			result.mask = resources.mask;
			return result;
		}

		public static Resources ConvertToDefault(Resources resources)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			Resources result = default(Resources);
			result.standard = resources.standard;
			result.background = resources.background;
			result.inputField = resources.inputField;
			result.knob = resources.knob;
			result.checkmark = resources.checkmark;
			result.dropdown = resources.dropdown;
			result.mask = resources.mask;
			return result;
		}
	}
}
namespace EasierUI.Controls
{
	public abstract class ControlsFactory
	{
		protected abstract PanelContainer CreatePanel(ControlsResources.Resources resources = default(ControlsResources.Resources));

		protected abstract ButtonContrainer CreateButton(ControlsResources.Resources resources = default(ControlsResources.Resources));

		protected abstract InputFieldContrainer CreateInputField(ControlsResources.Resources resources = default(ControlsResources.Resources));

		protected abstract ToggleContrainer CreateToggle(ControlsResources.Resources resources = default(ControlsResources.Resources));

		protected abstract SliderContrainer CreateSlider(ControlsResources.Resources resources = default(ControlsResources.Resources));

		protected abstract ScrollContainer CreateVerticalScroll(ControlsResources.Resources resources = default(ControlsResources.Resources));

		protected abstract ImageContrainer CreateImage(ControlsResources.Resources resources = default(ControlsResources.Resources));

		public PanelContainer CreatePanel(Transform parent, string name = null)
		{
			PanelContainer panelContainer = CreatePanel();
			panelContainer.SetParent(parent);
			if (name != null)
			{
				panelContainer.SetName(name);
			}
			return panelContainer;
		}

		public ButtonContrainer CreateButton(Transform parent, string name = null, Action handler = null, Sprite sprite = null, bool? fillCenter = null, string text = null)
		{
			ButtonContrainer buttonContrainer = CreateButton();
			buttonContrainer.SetParent(parent);
			if (name != null)
			{
				buttonContrainer.SetName(name);
			}
			if (handler != null)
			{
				buttonContrainer.AddHandler(handler);
			}
			if ((Object)(object)sprite != (Object)null)
			{
				buttonContrainer.Image.sprite = sprite;
			}
			if (fillCenter.HasValue)
			{
				buttonContrainer.Image.fillCenter = fillCenter.Value;
			}
			if (text != null)
			{
				((TMP_Text)buttonContrainer.Text).text = text;
			}
			return buttonContrainer;
		}

		public InputFieldContrainer CreateInputField(Transform parent, string name = null, Action<string> handler = null, ContentType? type = null, string placeholderText = null)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			InputFieldContrainer inputFieldContrainer = CreateInputField();
			inputFieldContrainer.SetParent(parent);
			if (name != null)
			{
				inputFieldContrainer.SetName(name);
			}
			if (handler != null)
			{
				inputFieldContrainer.AddHandler(handler);
			}
			if (type.HasValue)
			{
				inputFieldContrainer.InputField.contentType = type.Value;
			}
			if (placeholderText != null)
			{
				((TMP_Text)inputFieldContrainer.TextPlaceHolder).text = placeholderText;
			}
			return inputFieldContrainer;
		}

		public ToggleContrainer CreateToggle(Transform parent, string name = null, Action<bool> handler = null, string text = null)
		{
			ToggleContrainer toggleContrainer = CreateToggle();
			toggleContrainer.SetParent(parent);
			if (name != null)
			{
				toggleContrainer.SetName(name);
			}
			if (handler != null)
			{
				toggleContrainer.AddHandler(handler);
			}
			if (text != null)
			{
				((TMP_Text)toggleContrainer.Text).text = text;
			}
			return toggleContrainer;
		}

		public SliderContrainer CreateSlider(Transform parent, string name = null, Action<float> handler = null, bool? wholeNumbers = null, float? minValue = null, float? maxValue = null)
		{
			SliderContrainer sliderContrainer = CreateSlider();
			sliderContrainer.SetParent(parent);
			if (name != null)
			{
				sliderContrainer.SetName(name);
			}
			if (handler != null)
			{
				sliderContrainer.AddHandler(handler);
			}
			if (wholeNumbers.HasValue)
			{
				sliderContrainer.Slider.wholeNumbers = wholeNumbers.Value;
			}
			if (minValue.HasValue)
			{
				sliderContrainer.Slider.minValue = minValue.Value;
			}
			if (maxValue.HasValue)
			{
				sliderContrainer.Slider.maxValue = maxValue.Value;
			}
			return sliderContrainer;
		}

		public ScrollContainer CreateVerticalScroll(Transform parent, string name = null)
		{
			ScrollContainer scrollContainer = CreateVerticalScroll();
			scrollContainer.SetParent(parent);
			if (name != null)
			{
				scrollContainer.SetName(name);
			}
			return scrollContainer;
		}

		public ImageContrainer CreateImage(Transform parent, string name = null, Sprite sprite = null)
		{
			ImageContrainer imageContrainer = CreateImage();
			imageContrainer.SetParent(parent);
			if (name != null)
			{
				imageContrainer.SetName(name);
			}
			if ((Object)(object)sprite != (Object)null)
			{
				imageContrainer.Image.sprite = sprite;
			}
			return imageContrainer;
		}
	}
}
namespace EasierUI.Controls.Factories
{
	public class DefaultControlsFactory : ControlsFactory
	{
		private const float DefaultSensivity = 10f;

		public static DefaultControlsFactory Instance { get; } = new DefaultControlsFactory();


		protected override ButtonContrainer CreateButton(ControlsResources.Resources resources = default(ControlsResources.Resources))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = TMP_DefaultControls.CreateButton(ControlsResources.ConvertToTMP(resources));
			TextMeshProUGUI componentInChildren = val.GetComponentInChildren<TextMeshProUGUI>();
			if ((Object)(object)resources.font != (Object)null)
			{
				((TMP_Text)componentInChildren).font = resources.font;
			}
			return new ButtonContrainer(val, val.GetComponent<Button>(), val.GetComponent<Image>(), componentInChildren);
		}

		protected override InputFieldContrainer CreateInputField(ControlsResources.Resources resources = default(ControlsResources.Resources))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = TMP_DefaultControls.CreateInputField(ControlsResources.ConvertToTMP(resources));
			TextMeshProUGUI component = ((Component)val.transform.Find("Text Area/Text")).gameObject.GetComponent<TextMeshProUGUI>();
			TextMeshProUGUI component2 = ((Component)val.transform.Find("Text Area/Placeholder")).gameObject.GetComponent<TextMeshProUGUI>();
			if ((Object)(object)resources.font != (Object)null)
			{
				((TMP_Text)component).font = resources.font;
				((TMP_Text)component2).font = resources.font;
			}
			return new InputFieldContrainer(val, val.GetComponent<TMP_InputField>(), component, component2, val.GetComponent<Image>());
		}

		protected override PanelContainer CreatePanel(ControlsResources.Resources resources = default(ControlsResources.Resources))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = DefaultControls.CreatePanel(ControlsResources.ConvertToDefault(resources));
			return new PanelContainer(obj, obj.GetComponent<RectTransform>());
		}

		protected override SliderContrainer CreateSlider(ControlsResources.Resources resources = default(ControlsResources.Resources))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = DefaultControls.CreateSlider(ControlsResources.ConvertToDefault(resources));
			return new SliderContrainer(val, val.GetComponent<Slider>(), ((Component)val.transform.Find("Background")).gameObject.GetComponent<Image>());
		}

		protected override ToggleContrainer CreateToggle(ControlsResources.Resources resources = default(ControlsResources.Resources))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = DefaultControls.CreateToggle(ControlsResources.ConvertToDefault(resources));
			Toggle component = val.GetComponent<Toggle>();
			component.isOn = false;
			Object.DestroyImmediate((Object)(object)((Component)val.GetComponentInChildren<Text>()).gameObject);
			GameObject obj = TMP_DefaultControls.CreateText(ControlsResources.ConvertToTMP(resources));
			obj.transform.SetParent(val.transform, false);
			SetLayerRecursively(obj, val.layer);
			TextMeshProUGUI component2 = obj.GetComponent<TextMeshProUGUI>();
			if ((Object)(object)resources.font != (Object)null)
			{
				((TMP_Text)component2).font = resources.font;
			}
			return new ToggleContrainer(val, component, ((Component)val.transform.Find("Background")).gameObject.GetComponent<Image>(), ((Component)val.transform.Find("Background/Checkmark")).gameObject.GetComponent<Image>(), component2);
		}

		private static void SetLayerRecursively(GameObject go, int layer)
		{
			go.layer = layer;
			Transform transform = go.transform;
			for (int i = 0; i < transform.childCount; i++)
			{
				SetLayerRecursively(((Component)transform.GetChild(i)).gameObject, layer);
			}
		}

		protected override ScrollContainer CreateVerticalScroll(ControlsResources.Resources resources = default(ControlsResources.Resources))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = DefaultControls.CreateScrollView(ControlsResources.ConvertToDefault(resources));
			ScrollRect component = val.GetComponent<ScrollRect>();
			component.horizontal = false;
			component.scrollSensitivity = 10f;
			GameObject gameObject = ((Component)val.transform.Find("Scrollbar Vertical")).gameObject;
			GameObject gameObject2 = ((Component)val.transform.Find("Scrollbar Horizontal")).gameObject;
			gameObject.GetComponent<Image>().sprite = resources.childBackground;
			gameObject2.GetComponent<Image>().sprite = resources.childBackground;
			return new ScrollContainer(val, component, val.GetComponent<Image>(), ((Component)val.transform.Find("Viewport/Content")).gameObject, gameObject, gameObject2);
		}

		protected override ImageContrainer CreateImage(ControlsResources.Resources resources = default(ControlsResources.Resources))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = DefaultControls.CreateImage(ControlsResources.ConvertToDefault(resources));
			return new ImageContrainer(obj, obj.GetComponent<Image>());
		}
	}
}
namespace EasierUI.Controls.Contrainers
{
	public class ButtonContrainer : ControlContainer
	{
		public readonly Button Button;

		public readonly Image Image;

		public readonly TextMeshProUGUI Text;

		public ButtonContrainer(GameObject GO, Button button, Image image, TextMeshProUGUI text)
			: base(GO)
		{
			Button = button;
			Image = image;
			Text = text;
		}

		public void AddHandler(Action listener)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((UnityEvent)Button.onClick).AddListener(new UnityAction(listener.Invoke));
		}
	}
	public abstract class ControlContainer
	{
		public readonly GameObject GameObject;

		public ControlContainer(GameObject GO)
		{
			GameObject = GO;
		}

		public void SetParent(Transform parentTransform)
		{
			GameObject.transform.SetParent(parentTransform, false);
		}

		public void SetName(string name)
		{
			((Object)GameObject).name = name;
		}
	}
	public class ImageContrainer : ControlContainer
	{
		public readonly Image Image;

		public ImageContrainer(GameObject GO, Image image)
			: base(GO)
		{
			Image = image;
		}
	}
	public class InputFieldContrainer : ControlContainer
	{
		public readonly TMP_InputField InputField;

		public readonly TextMeshProUGUI Text;

		public readonly TextMeshProUGUI TextPlaceHolder;

		public readonly Image BackgroundImage;

		public InputFieldContrainer(GameObject GO, TMP_InputField inputField, TextMeshProUGUI text, TextMeshProUGUI textPlaceHolder, Image backgroundImage)
			: base(GO)
		{
			InputField = inputField;
			Text = text;
			TextPlaceHolder = textPlaceHolder;
			BackgroundImage = backgroundImage;
		}

		public void AddHandler(Action<string> handler)
		{
			((UnityEvent<string>)(object)InputField.onValueChanged).AddListener((UnityAction<string>)handler.Invoke);
		}
	}
	public class PanelContainer : ControlContainer
	{
		public readonly RectTransform RectTransform;

		public PanelContainer(GameObject GO, RectTransform rectTransform)
			: base(GO)
		{
			RectTransform = rectTransform;
		}
	}
	public class ScrollContainer : ControlContainer
	{
		public readonly GameObject ContentHolder;

		public readonly GameObject VerticalScroll;

		public readonly GameObject HorizontalScroll;

		public readonly ScrollRect Scroll;

		public readonly Image Background;

		public ScrollContainer(GameObject GO, ScrollRect scroll, Image background, GameObject contentHolder, GameObject verticalScroll, GameObject horizontalScroll)
			: base(GO)
		{
			Scroll = scroll;
			ContentHolder = contentHolder;
			Background = background;
			VerticalScroll = verticalScroll;
			HorizontalScroll = horizontalScroll;
		}

		internal void SetHeight(float height)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ContentHolder.transform;
			RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			if ((Object)(object)val != (Object)null)
			{
				Vector2 sizeDelta = val.sizeDelta;
				val.sizeDelta = new Vector2(sizeDelta.x, height);
			}
		}
	}
	public class SliderContrainer : ControlContainer
	{
		public readonly Slider Slider;

		public readonly Image BackgroundImage;

		public SliderContrainer(GameObject GO, Slider slider, Image backgroundImage)
			: base(GO)
		{
			BackgroundImage = backgroundImage;
			Slider = slider;
		}

		public void AddHandler(Action<float> handler)
		{
			((UnityEvent<float>)(object)Slider.onValueChanged).AddListener((UnityAction<float>)handler.Invoke);
		}
	}
	public class ToggleContrainer : ControlContainer
	{
		public readonly Toggle Toggle;

		public readonly Image CheckmarkImage;

		public readonly Image BackgroundImage;

		public readonly TextMeshProUGUI Text;

		public ToggleContrainer(GameObject GO, Toggle toggle, Image backgroundImage, Image checkmarkImage, TextMeshProUGUI text)
			: base(GO)
		{
			Toggle = toggle;
			BackgroundImage = backgroundImage;
			CheckmarkImage = checkmarkImage;
			Text = text;
		}

		public void AddHandler(Action<bool> action)
		{
			((UnityEvent<bool>)(object)Toggle.onValueChanged).AddListener((UnityAction<bool>)action.Invoke);
		}
	}
}

plugins/TooManyPotions.dll

Decompiled 5 days ago
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using EasierUI;
using EasierUI.Controls;
using EasierUI.Controls.Contrainers;
using EasierUI.Controls.Factories;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PotionCraft;
using PotionCraft.DebugObjects.DebugWindows;
using PotionCraft.DebugObjects.DebugWindows.Buttons;
using PotionCraft.InputSystem;
using PotionCraft.LocalizationSystem;
using PotionCraft.ManagersSystem;
using PotionCraft.ManagersSystem.Application;
using PotionCraft.ManagersSystem.Debug;
using PotionCraft.ManagersSystem.Game;
using PotionCraft.ManagersSystem.Input;
using PotionCraft.ManagersSystem.Input.ControlProviders;
using PotionCraft.ManagersSystem.Player;
using PotionCraft.ManagersSystem.Trade;
using PotionCraft.Markers;
using PotionCraft.ObjectBased.Haggle;
using PotionCraft.ObjectBased.InteractiveItem;
using PotionCraft.ObjectBased.InteractiveItem.InventoryObject;
using PotionCraft.ObjectBased.RecipeMap;
using PotionCraft.ObjectBased.RecipeMap.Path;
using PotionCraft.ObjectBased.RecipeMap.RecipeMapItem;
using PotionCraft.ObjectBased.RecipeMap.RecipeMapItem.Zones;
using PotionCraft.ObjectBased.UIElements;
using PotionCraft.SceneLoader;
using PotionCraft.ScriptableObjects;
using PotionCraft.ScriptableObjects.AlchemyMachineProducts;
using PotionCraft.ScriptableObjects.BuildableInventoryItem;
using PotionCraft.ScriptableObjects.Ingredient;
using PotionCraft.ScriptableObjects.Salts;
using PotionCraft.ScriptableObjects.TradableUpgrades;
using PotionCraft.ScriptableObjects.WateringPot;
using PotionCraft.Settings;
using ReLocalization;
using TMPro;
using TooManyPotions.Controls.Factories;
using TooManyPotions.Displays;
using TooManyPotions.Extensions;
using TooManyPotions.Helpers;
using TooManyPotions.Patches;
using TooManyPotions.Scripts.CheatModules;
using TooManyPotions.Scripts.Controls;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.UI;
using UnityEngine.UI;
using UnityExplorer.UI;
using UniverseLib.UI.Models;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("TooManyPotions")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TooManyPotions")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8e8be687-07f6-46c9-9298-1611415e4adc")]
[assembly: AssemblyFileVersion("2.0.2")]
[assembly: IgnoresAccessChecksTo("PotionCraft.Scripts")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TooManyPotions
{
	public static class GlobalConfigs
	{
		private static bool _isForceDevMode;

		public static Command toggleMenu = new Command("Toggle Menu Panel", (HotKey[])(object)new HotKey[2]
		{
			new HotKey((Button[])(object)new Button[2]
			{
				GamepadTrigger.Get((Side)1, 0.02f),
				GamepadTrigger.Get((Side)2, 0.02f)
			}),
			new HotKey((Button[])(object)new Button[1] { KeyboardKey.Get((KeyCode)111) })
		}, false);

		public static Command rotatePotion = new Command("Rotate potion to cursor", (HotKey[])(object)new HotKey[2]
		{
			new HotKey((Button[])(object)new Button[1] { GamepadButton.Get((ButtonCode)12) }),
			new HotKey((Button[])(object)new Button[1] { KeyboardKey.Get((KeyCode)306) })
		}, false);

		public static Command teleportPotion = new Command("Teleport potion to cursor", (HotKey[])(object)new HotKey[2]
		{
			new HotKey((Button[])(object)new Button[1] { GamepadButton.Get((ButtonCode)13) }),
			new HotKey((Button[])(object)new Button[1] { MouseButton.Get(2) })
		}, false);

		public static Command duplicateInInventory = new Command("Duplicate item in inventory when clicked once, or multiple times if hold", (HotKey[])(object)new HotKey[5]
		{
			new HotKey((Button[])(object)new Button[1] { GamepadButton.Get((ButtonCode)30) }),
			new HotKey((Button[])(object)new Button[2]
			{
				MouseButton.Get(0),
				KeyboardKey.Get((KeyCode)304)
			}),
			new HotKey((Button[])(object)new Button[2]
			{
				MouseButton.Get(0),
				KeyboardKey.Get((KeyCode)303)
			}),
			new HotKey((Button[])(object)new Button[2]
			{
				MouseButton.Get(1),
				KeyboardKey.Get((KeyCode)304)
			}),
			new HotKey((Button[])(object)new Button[2]
			{
				MouseButton.Get(1),
				KeyboardKey.Get((KeyCode)303)
			})
		}, false);

		public static bool IsForceDevMode
		{
			get
			{
				return _isForceDevMode;
			}
			set
			{
				_isForceDevMode |= value;
			}
		}

		public static bool IsPositionModifyingAllowed
		{
			get
			{
				MonoBehaviour? instance = CheatBehaviour<PotionPositionModifier>.Instance;
				if (instance == null)
				{
					return false;
				}
				return ((Behaviour)instance).enabled;
			}
			set
			{
				MonoBehaviour instance = CheatBehaviour<PotionPositionModifier>.Instance;
				if ((Object)(object)instance != (Object)null)
				{
					((Behaviour)instance).enabled = value;
				}
			}
		}

		public static bool IsDangerZonesDisabled { get; set; }

		public static bool IsDuplicateOnClickAllowed
		{
			get
			{
				MonoBehaviour? instance = CheatBehaviour<ItemDuplicator>.Instance;
				if (instance == null)
				{
					return false;
				}
				return ((Behaviour)instance).enabled;
			}
			set
			{
				MonoBehaviour instance = CheatBehaviour<ItemDuplicator>.Instance;
				if ((Object)(object)instance != (Object)null)
				{
					((Behaviour)instance).enabled = value;
				}
			}
		}

		public static bool IsHaggleAutoplayAllowed
		{
			get
			{
				MonoBehaviour? instance = CheatBehaviour<HaggleAutoplayer>.Instance;
				if (instance == null)
				{
					return false;
				}
				return ((Behaviour)instance).enabled;
			}
			set
			{
				MonoBehaviour instance = CheatBehaviour<HaggleAutoplayer>.Instance;
				if ((Object)(object)instance != (Object)null)
				{
					((Behaviour)instance).enabled = value;
				}
			}
		}

		public static bool IsEffectOverflowAllowed { get; set; }

		public static bool IsUEUnfocused => !UnityExplorerHelper.IsFocused;

		public static bool IsRotating
		{
			get
			{
				if (IsUEUnfocused)
				{
					return IsInState(rotatePotion, (State)1);
				}
				return false;
			}
		}

		public static bool IsTeleporting
		{
			get
			{
				if (IsUEUnfocused)
				{
					return IsInState(teleportPotion, (State)1);
				}
				return false;
			}
		}

		public static bool IsDuplicating
		{
			get
			{
				if (IsUEUnfocused)
				{
					return IsInState(duplicateInInventory, (State)2);
				}
				return false;
			}
		}

		public static bool IsDuplicatingMultiple
		{
			get
			{
				if (IsUEUnfocused)
				{
					return IsInState(duplicateInInventory, (State)1);
				}
				return false;
			}
		}

		public static bool IsInState(Command command, State state)
		{
			//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)
			return command.State == state;
		}
	}
	[BepInPlugin("ReuloTeam.TooManyPotions", "TooManyPotions", "2.0.0")]
	[BepInProcess("Potion Craft.exe")]
	public class ModInfo : BaseUnityPlugin
	{
		private const string GUID = "ReuloTeam.TooManyPotions";

		private const string MODNAME = "TooManyPotions";

		private const string VERSION = "2.0.0";

		private static ManualLogSource Logger = new ManualLogSource("TooManyPotions");

		public static GameObject? CheatHolder;

		public void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			GlobalConfigs.IsForceDevMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Game", "ForceDevMode", false, "Determines should game start up in Dev Mode.\t\n Setting this to 'true' will make it impossible to disable DevMode ingame.\t\n Setting this to 'false' still allows to toggle DevMode ingame.").Value;
			Localization.AddLocalizationFor((BaseUnityPlugin)(object)this);
			HandleUnityExplorer();
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			Logger.LogInfo((object)"TooManyPotions succesfully loaded");
		}

		private static void HandleUnityExplorer()
		{
			UnityExplorerHelper.IsExplorerLoaded = Chainloader.PluginInfos.Any((KeyValuePair<string, PluginInfo> plugin) => plugin.Value.Metadata.Name == "UnityExplorer");
		}

		public static void InitializeCheatGameObject()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			CheatHolder = new GameObject("CheatHolder");
			DisplayToggler.Init();
			Object.DontDestroyOnLoad((Object)(object)CheatHolder);
		}

		public static void Log(object message, LogLevel level = 16)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Logger.Log(level, message);
		}
	}
}
namespace TooManyPotions.Displays
{
	internal abstract class AbstractDisplay : MonoBehaviour
	{
		public const string UISortingLayerName = "Debug";

		protected float scaleFactor = 0.02f;

		protected int defaultPadding = 4;

		protected int headPadding = 26;

		protected int sortingOrderIncrement = 80;

		private SpriteRenderer _sortingOrderController;

		protected Canvas _canvas;

		protected PanelContainer _panel;

		private BoxCollider2D _backgroundCollider;

		public DebugWindow Window { get; private set; }

		private int SortingOrder
		{
			get
			{
				SpriteRenderer sortingOrderController = _sortingOrderController;
				return (((sortingOrderController != null) ? new int?(((Renderer)sortingOrderController).sortingOrder) : null) + sortingOrderIncrement).GetValueOrDefault();
			}
		}

		private void Update()
		{
			//IL_002b: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_008f: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_00f1: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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)
			if (!((Object)(object)Window == (Object)null))
			{
				TryReorder();
				Vector2 val = scaleFactor * (((ControlContainer)_panel).GameObject.GetComponent<RectTransform>().sizeDelta + new Vector2((float)(2 * defaultPadding + 1), (float)(headPadding + 2 * defaultPadding)));
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor(val.x, 0.5f);
				Window.colliderBackground.size = val2;
				((Collider2D)Window.colliderBackground).offset = val2 / 2f * (Vector2.right + Vector2.down);
				Window.spriteBackground.size = val;
				Window.spriteScratches.size = val;
				_backgroundCollider.size = val;
				((Collider2D)_backgroundCollider).offset = val / 2f * (Vector2.right + Vector2.down);
				Vector3 localPosition = Window.headTransform.localPosition;
				Window.headTransform.localPosition = new Vector3(val.x - 0.06f, localPosition.y, localPosition.z);
				DisplayUpdate();
			}
		}

		private void Awake()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			SetupCanvas();
			SetupPanel();
			SetupElements();
			TryReorder();
			((Transform)((Component)this).gameObject.GetComponent<RectTransform>()).localScale = new Vector3(scaleFactor, scaleFactor, 1f);
		}

		protected void TryReorder()
		{
			int sortingOrder = SortingOrder;
			if (_canvas.sortingOrder != sortingOrder)
			{
				_canvas.sortingOrder = sortingOrder;
			}
		}

		private void SetupCanvas()
		{
			//IL_0084: 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)
			_canvas = ((Component)this).gameObject.AddComponent<Canvas>();
			_canvas.renderMode = (RenderMode)2;
			_canvas.worldCamera = Managers.Game.Cam;
			_canvas.sortingLayerName = "Debug";
			_sortingOrderController = ((Component)((Component)this).gameObject.transform.parent).gameObject.GetComponent<SpriteRenderer>();
			((Component)this).gameObject.AddComponent<GraphicRaycaster>();
			RectTransform component = ((Component)this).gameObject.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(0f, 0f);
			((Transform)component).localPosition = new Vector3(0f, 0f, 0f);
		}

		private void SetupPanel()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			_panel = ControlsFactory.Instance.CreatePanel(((Component)this).transform, (string)null);
			RectTransform rectTransform = _panel.RectTransform;
			rectTransform.pivot = new Vector2(0f, 1f);
			((Transform)rectTransform).localPosition = new Vector3((float)defaultPadding, (float)(-defaultPadding - headPadding), 0f);
			VerticalLayoutGroup obj = ((ControlContainer)_panel).GameObject.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj).padding = new RectOffset(defaultPadding, defaultPadding, defaultPadding, defaultPadding);
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = false;
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 4f;
			ContentSizeFitter obj2 = ((ControlContainer)_panel).GameObject.AddComponent<ContentSizeFitter>();
			obj2.verticalFit = (FitMode)2;
			obj2.horizontalFit = (FitMode)2;
			Object.Destroy((Object)(object)((ControlContainer)_panel).GameObject.GetComponent<Image>());
		}

		protected abstract void SetupElements();

		protected static GameObject CreateLayout(Transform parent, string name, float width, float height)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent);
			LayoutElement obj = val.AddComponent<LayoutElement>();
			obj.preferredWidth = width;
			obj.preferredHeight = height;
			HorizontalLayoutGroup obj2 = val.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj2).spacing = 4f;
			ContentSizeFitter obj3 = val.AddComponent<ContentSizeFitter>();
			obj3.verticalFit = (FitMode)2;
			obj3.horizontalFit = (FitMode)2;
			return val;
		}

		protected static ImageContrainer CreateIconOnLayout(Transform parent, string objectName, Sprite? sprite, int width = 32, int height = 32)
		{
			ImageContrainer obj = ControlsFactory.Instance.CreateImage(parent, objectName, sprite);
			LayoutElement obj2 = ((ControlContainer)obj).GameObject.AddComponent<LayoutElement>();
			obj2.preferredHeight = height;
			obj2.preferredWidth = width;
			return obj;
		}

		protected void DisplayUpdate()
		{
		}

		protected static T Init<T>(string title, string objectName) where T : AbstractDisplay
		{
			//IL_0092: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			DebugWindow component = Object.Instantiate<GameObject>(Settings<DebugManagerSettings>.Asset.debugWindowPrefab).GetComponent<DebugWindow>();
			((TMP_Text)component.captionText).text = title;
			((Component)component.captionText).gameObject.AddComponent<LocalizedText>();
			((Window)component).Visible = true;
			component.resizeAfter = float.MaxValue;
			GameObject gameObject = ((Component)component).gameObject;
			((Object)gameObject).name = objectName + " GUI";
			gameObject.SetActive(true);
			gameObject.transform.SetParent(((Component)Managers.Game.Cam).transform);
			gameObject.transform.localPosition = new Vector3(-10f, 6f, 0f);
			GameObject val = new GameObject(objectName + " Menu Display");
			Transform val2 = ((gameObject != null) ? gameObject.transform.Find("Maximized/Background") : null);
			val.transform.SetParent(val2);
			T val3 = val.AddComponent<T>();
			val3.Window = component;
			GameObject val4 = new GameObject("BackgroundRaycastCollider");
			val3._backgroundCollider = val4.AddComponent<BoxCollider2D>();
			val4.AddComponent<RightPanelColliderForItemsRaycasting>();
			val4.transform.SetParent(val2);
			val4.layer = ((Component)val2).gameObject.layer;
			val4.transform.localPosition = Vector3.zero;
			return val3;
		}
	}
	internal class CheatMenuDisplay : AbstractDisplay
	{
		private const int preferedWidth = 200;

		public Action? potionEffectMenuOpenHandler;

		private InputFieldContrainer? _goldInput;

		private InputFieldContrainer? _popularityInput;

		private InputFieldContrainer? _experienceInput;

		private SliderContrainer? _karmaSlider;

		private ScrollContainer? _itemsScroll;

		private ToggleContrainer? _devmodeToggle;

		private ToggleContrainer? _teleportToggle;

		private ToggleContrainer? _nodamageToggle;

		private ToggleContrainer? _dupingToggle;

		private ToggleContrainer? _autohaggleToggle;

		private ButtonContrainer? _button;

		public static CheatMenuDisplay Init()
		{
			return AbstractDisplay.Init<CheatMenuDisplay>("#cheat_menu_title", "Cheat");
		}

		protected override void SetupElements()
		{
			SetupGoldInput();
			SetupPopularityInput();
			SetupExperienceInput();
			SetupKarmaSlider();
			SetupItemsScroll();
			SetupDevmodeToggle();
			SetupTeleportationToggle();
			SetupNodamageToggle();
			SetupDupingToggle();
			SetupAutoHaggleToggle();
			SetupPotionEditWindowButton();
		}

		private GameObject CreateLayout(string name)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.transform.SetParent((Transform)(object)_panel.RectTransform);
			val.AddComponent<LayoutElement>().preferredWidth = 200f;
			HorizontalLayoutGroup obj = val.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 4f;
			ContentSizeFitter obj2 = val.AddComponent<ContentSizeFitter>();
			obj2.verticalFit = (FitMode)2;
			obj2.horizontalFit = (FitMode)2;
			return val;
		}

		private void CreateIconOnLayout(Transform parent, string objectName, int size = 32)
		{
			AbstractDisplay.CreateIconOnLayout(parent, objectName, SpritesHelper.GetByName(objectName), size, size);
		}

		private InputFieldContrainer CreateInputField(Transform parent, Sprite sprite, Action<string> action, string objectName, string text, ContentType type = 2)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			InputFieldContrainer obj = ControlsFactory.Instance.CreateInputField(parent, objectName, action, (ContentType?)type, text);
			((ControlContainer)obj).GameObject.AddComponent<LayoutElement>().flexibleWidth = 1f;
			obj.BackgroundImage.sprite = sprite;
			return obj;
		}

		public ScrollContainer CreateVerticalScroll(Transform parent, string objectName)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_007d: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			ScrollContainer obj = ControlsFactory.Instance.CreateVerticalScroll(parent, objectName);
			CreateCorner(obj, "Left", new Vector2(0.03f, 0.985f), new Vector2(0f, 0.035f));
			CreateCorner(obj, "Top", new Vector2(0.99f, 1.01f), new Vector2(0f, 0.98f));
			CreateCorner(obj, "Right", new Vector2(1f, 1f), new Vector2(0.97f, 0.035f));
			CreateCorner(obj, "Bottom", new Vector2(1f, 0.04f), new Vector2(0f, -0.01f));
			return obj;
		}

		private static void CreateCorner(ScrollContainer scroll, string sideName, Vector2 max, Vector2 min)
		{
			//IL_0026: 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)
			CreateCorner(((ControlContainer)scroll).GameObject.transform, sideName + " Corner", SpritesHelper.RequestSpriteByName("InventoryWindow Foreground Var2 " + sideName), max, min);
		}

		private static void CreateCorner(Transform parent, string name, Sprite sprite, Vector2 max, Vector2 min)
		{
			//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_0025: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(Image) });
			val.transform.SetParent(parent);
			val.GetComponent<Image>().sprite = sprite;
			RectTransform val2 = (RectTransform)val.transform;
			val2.sizeDelta = Vector2.zero;
			val2.anchoredPosition = Vector2.zero;
			val2.anchorMax = max;
			val2.anchorMin = min;
		}

		private void SetupGoldInput()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			GameObject val = CreateLayout("Gold Holder");
			CreateIconOnLayout(val.transform, "Gold Icon");
			_goldInput = CreateInputField(val.transform, SpritesHelper.RequestSpriteByName("Gold Plate Idle"), handler, "Gold Input", "0", (ContentType)2);
			Managers.Player.onGoldChanged.AddListener((UnityAction)delegate
			{
				_goldInput.InputField.text = PlayerStatsHelper.Gold.ToString();
			});
			static void handler(string value)
			{
				if (int.TryParse(value, out var result))
				{
					PlayerStatsHelper.Gold = result;
				}
			}
		}

		private void SetupPopularityInput()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			GameObject val = CreateLayout("Popularity Holder");
			CreateIconOnLayout(val.transform, "PopularityIcon Tier 5");
			_popularityInput = CreateInputField(val.transform, SpritesHelper.RequestSpriteByName("Popularity Plate Idle"), delegate(string value)
			{
				if (int.TryParse(value, out var result))
				{
					PlayerStatsHelper.Popularity = result;
				}
			}, "Popularity Input", "0", (ContentType)2);
			Managers.Player.popularity.onPopularityChanged.AddListener((UnityAction)delegate
			{
				_popularityInput.InputField.text = PlayerStatsHelper.Popularity.ToString();
			});
		}

		private void SetupExperienceInput()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			GameObject val = CreateLayout("Experience Holder");
			CreateIconOnLayout(val.transform, "XP Icon");
			_experienceInput = CreateInputField(val.transform, SpritesHelper.RequestSpriteByName("Karma Plate Idle"), delegate(string value)
			{
				if (float.TryParse(value, out var result))
				{
					PlayerStatsHelper.Experience = result;
				}
			}, "Experience Input", "0", (ContentType)3);
			_experienceInput.InputField.characterValidation = (CharacterValidation)3;
			Managers.Player.experience.OnCurrentExpChanged.AddListener((UnityAction)delegate
			{
				_experienceInput.InputField.text = PlayerStatsHelper.Experience.ToString("#0.#");
			});
		}

		private void SetupKarmaSlider()
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			GameObject val = CreateLayout("Karma Holder");
			CreateIconOnLayout(val.transform, "KarmaIcon Good 3");
			_karmaSlider = ControlsFactory.Instance.CreateSlider(val.transform, "Karma Slider", (Action<float>)delegate(float value)
			{
				PlayerStatsHelper.Karma = (int)value;
			}, (bool?)true, (float?)(-100f), (float?)100f);
			((ControlContainer)_karmaSlider).GameObject.AddComponent<LayoutElement>().flexibleWidth = 1f;
			Managers.Player.karma.onKarmaChanged.AddListener((UnityAction)delegate
			{
				_karmaSlider.Slider.value = PlayerStatsHelper.Karma;
			});
		}

		private void SetupItemsScroll()
		{
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			_itemsScroll = CreateVerticalScroll((Transform)(object)_panel.RectTransform, "Items Scroll Selector");
			LayoutElement obj = ((ControlContainer)_itemsScroll).GameObject.AddComponent<LayoutElement>();
			obj.preferredWidth = 200f;
			obj.flexibleWidth = 1f;
			int num = 0;
			foreach (InventoryItem item in PlayerStatsHelper.Items)
			{
				ButtonContrainer obj2 = ControlsFactory.Instance.CreateButton(_itemsScroll.ContentHolder.transform, ((Object)item).name, (Action)delegate
				{
					PlayerStatsHelper.AddItem(item, (!(item is Salt)) ? 1 : 1000);
				}, SpritesHelper.RequestSpriteByName($"Inventory Item Slot {1 + num++ % 18} Normal"), (bool?)true, (string)null);
				Object.Destroy((Object)(object)((Component)obj2.Text).gameObject);
				((Graphic)obj2.Image).color = new Color(1f, 1f, 1f, 0.3f);
				(Sprite, Vector2) iconData = item.GetIconData();
				RectTransform component = ((ControlContainer)AbstractDisplay.CreateIconOnLayout(((ControlContainer)obj2).GameObject.transform, ((Object)item).name + " Icon", iconData.Item1)).GameObject.GetComponent<RectTransform>();
				component.anchoredPosition = iconData.Item2;
				component.anchorMax = new Vector2(0.9f, 0.9f);
				component.anchorMin = new Vector2(0.1f, 0.1f);
				component.sizeDelta = Vector2.zero;
			}
		}

		private ToggleContrainer CreateToggle(RectTransform parent, string name, Action<bool> handler, string label)
		{
			ToggleContrainer obj = ControlsFactory.Instance.CreateToggle((Transform)(object)parent, name, handler, label);
			((ControlContainer)obj).GameObject.AddComponent<LayoutElement>().preferredWidth = 200f;
			((Component)obj.Text).gameObject.AddComponent<LocalizedText>();
			return obj;
		}

		private void SetupDevmodeToggle()
		{
			_devmodeToggle = CreateToggle(_panel.RectTransform, "DevMode Toggle", delegate(bool value)
			{
				DebugManager.IsDeveloperMode = value || GlobalConfigs.IsForceDevMode;
			}, "#devmode_toggle_text");
			_devmodeToggle.Toggle.isOn = GlobalConfigs.IsForceDevMode;
		}

		private void SetupTeleportationToggle()
		{
			_teleportToggle = CreateToggle(_panel.RectTransform, "Teleport Toggle", delegate(bool value)
			{
				GlobalConfigs.IsPositionModifyingAllowed = value;
			}, "#position_modifying_toggle_text");
		}

		private void SetupNodamageToggle()
		{
			_nodamageToggle = CreateToggle(_panel.RectTransform, "Godmode Toggle", delegate(bool value)
			{
				GlobalConfigs.IsDangerZonesDisabled = value;
			}, "#disable_damage_toggle_text");
		}

		private void SetupDupingToggle()
		{
			_dupingToggle = CreateToggle(_panel.RectTransform, "Duping Toggle", delegate(bool value)
			{
				GlobalConfigs.IsDuplicateOnClickAllowed = value;
			}, "#inventory_items_dupe_toggle_text");
		}

		private void SetupAutoHaggleToggle()
		{
			_autohaggleToggle = CreateToggle(_panel.RectTransform, "Autohaggle Toggle", delegate(bool value)
			{
				GlobalConfigs.IsHaggleAutoplayAllowed = value;
			}, "#haggle_autoplay_toggle_text");
		}

		private void SetupPotionEditWindowButton()
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			_button = ControlsFactory.Instance.CreateButton((Transform)(object)_panel.RectTransform, "Open Potion Editor Button", (Action)PotionEditWindowAction, SpritesHelper.RequestSpriteByName("SaveRecipe Active Slot"), (bool?)true, "#effects_editor_button_text");
			((Component)_button.Text).gameObject.AddComponent<LocalizedText>();
			((Graphic)_button.Image).color = new Color(1f, 1f, 1f, 0.3f);
			((ControlContainer)_button).GameObject.AddComponent<LayoutElement>().preferredWidth = 200f;
		}

		private void PotionEditWindowAction()
		{
			potionEffectMenuOpenHandler?.Invoke();
		}
	}
	internal static class DisplayToggler
	{
		private static CheatMenuDisplay _cheatMenu;

		private static PotionEditorDisplay? _effectsMenu;

		private static MaximizeButton _maximize;

		private static GameObject _cheatMenuObject;

		private static GameObject? _effectsMenuObject;

		public static bool IsActive => _cheatMenuObject.activeSelf;

		static DisplayToggler()
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			_cheatMenu = CheatMenuDisplay.Init();
			_effectsMenu = PotionEditorDisplay.Init();
			_cheatMenuObject = ((Component)_cheatMenu.Window).gameObject;
			_maximize = ((Component)_cheatMenuObject.transform.Find("Minimized/Head/Maximize")).GetComponent<MaximizeButton>();
			PotionEditorDisplay? effectsMenu = _effectsMenu;
			_effectsMenuObject = ((effectsMenu != null) ? ((Component)effectsMenu.Window).gameObject : null);
			GameObject? effectsMenuObject = _effectsMenuObject;
			if (effectsMenuObject != null)
			{
				effectsMenuObject.SetActive(false);
			}
			_cheatMenu.potionEffectMenuOpenHandler = delegate
			{
				GameObject? effectsMenuObject2 = _effectsMenuObject;
				if (effectsMenuObject2 != null)
				{
					effectsMenuObject2.SetActive(true);
				}
			};
			GlobalConfigs.toggleMenu.onJustUppedEvent.AddListener(new UnityAction(ToggleMenu));
		}

		public static void Init()
		{
		}

		private static void ToggleMenu()
		{
			MaximizeButton maximize = _maximize;
			if (maximize != null && ((Behaviour)maximize).isActiveAndEnabled)
			{
				GameObject? effectsMenuObject = _effectsMenuObject;
				if (effectsMenuObject != null)
				{
					effectsMenuObject.SetActive(false);
				}
				((Button)_maximize).OnButtonReleasedPointerInside();
			}
			else
			{
				_cheatMenuObject.SetActive(!IsActive);
			}
		}
	}
	internal class PotionEditorDisplay : AbstractDisplay
	{
		private const int baseScrollWidth = 76;

		private const int effectScrollWidth = 736;

		private const int width = 812;

		private const int height = 120;

		private DebugWindow? _warningWindow;

		private Button? currentState;

		private ScrollContainer? _effectsScroll;

		public static PotionEditorDisplay Init()
		{
			return AbstractDisplay.Init<PotionEditorDisplay>("#potion_editor_title", "Potion Editor");
		}

		protected override void SetupElements()
		{
			GameObject val = AbstractDisplay.CreateLayout((Transform)(object)_panel.RectTransform, "Potion Editor Scrolls", 812f, 120f);
			SetupBaseScroll(val.transform);
			SetupEffectsScroll(val.transform);
			CreateToggle(_panel.RectTransform, "Overflow Toggle", delegate(bool value)
			{
				GlobalConfigs.IsEffectOverflowAllowed = value;
			}, "#overflow_toggle_text");
		}

		private ToggleContrainer CreateToggle(RectTransform parent, string name, Action<bool> handler, string label)
		{
			ToggleContrainer obj = ControlsFactory.Instance.CreateToggle((Transform)(object)parent, name, handler, label);
			((ControlContainer)obj).GameObject.AddComponent<LayoutElement>().preferredWidth = 812f;
			((Component)obj.Text).gameObject.AddComponent<LocalizedText>();
			return obj;
		}

		public ScrollContainer CreateVerticalScroll(Transform parent, string objectName)
		{
			ScrollContainer obj = ControlsFactory.Instance.CreateVerticalScroll(parent, objectName);
			Object.Destroy((Object)(object)obj.Background);
			return obj;
		}

		private void SetupEffectsScroll(Transform parent)
		{
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			_effectsScroll = CreateVerticalScroll(parent, "Effects Scroll Selector");
			((ControlContainer)_effectsScroll).GameObject.GetComponent<ScrollRectCellResize>().iconsInRow = 12;
			((ControlContainer)_effectsScroll).GameObject.AddComponent<LayoutElement>().preferredWidth = 736f;
			int num = 0;
			foreach (PotionEffect effect in PlayerStatsHelper.Effects)
			{
				ButtonContrainer obj = ControlsFactory.Instance.CreateButton(_effectsScroll.ContentHolder.transform, ((Object)effect).name, (Action)delegate
				{
					if (!GlobalConfigs.IsEffectOverflowAllowed && !PlayerStatsHelper.CanAddEffect(effect))
					{
						ShowWarning();
					}
					else
					{
						DebugWindow? warningWindow = _warningWindow;
						if (warningWindow != null && ((Window)warningWindow).Visible)
						{
							((Window)_warningWindow).Visible = false;
						}
						PlayerStatsHelper.AddEffect(effect);
					}
				}, SpritesHelper.RequestSpriteByName($"Inventory Item Slot {1 + num++ % 18} Normal"), (bool?)true, (string)null);
				Object.Destroy((Object)(object)((Component)obj.Text).gameObject);
				((Graphic)obj.Image).color = new Color(1f, 1f, 1f, 0.3f);
				RectTransform component = ((ControlContainer)AbstractDisplay.CreateIconOnLayout(((ControlContainer)obj).GameObject.transform, ((Object)effect).name + " Icon", effect.icon.GetSprite((ColorObject)null, (Color[])null, true, true))).GameObject.GetComponent<RectTransform>();
				component.anchoredPosition = new Vector2(0f, 0f);
				component.anchorMax = new Vector2(0.9f, 0.9f);
				component.anchorMin = new Vector2(0.1f, 0.1f);
				component.sizeDelta = Vector2.zero;
			}
		}

		private void SetupBaseScroll(Transform parent)
		{
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Expected O, but got Unknown
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			_effectsScroll = CreateVerticalScroll(parent, "Base Scroll Selector");
			((ControlContainer)_effectsScroll).GameObject.GetComponent<ScrollRectCellResize>().iconsInRow = 1;
			LayoutElement obj = ((ControlContainer)_effectsScroll).GameObject.AddComponent<LayoutElement>();
			obj.preferredWidth = 76f;
			obj.flexibleWidth = 1f;
			int num = 0;
			foreach (MapState map in PlayerStatsHelper.MapBases)
			{
				ButtonContrainer newButton = ControlsFactory.Instance.CreateButton(_effectsScroll.ContentHolder.transform, ((Object)map.potionBase).name, (Action)delegate
				{
				}, SpritesHelper.RequestSpriteByName($"Inventory Item Slot {1 + num++ % 18} Normal"), (bool?)true, (string)null);
				Object.Destroy((Object)(object)((Component)newButton.Text).gameObject);
				if ((Object)(object)currentState == (Object)null)
				{
					currentState = newButton.Button;
					((Selectable)currentState).interactable = false;
				}
				newButton.AddHandler((Action)delegate
				{
					PlayerStatsHelper.SetMapBase(map);
					NewState(newButton.Button);
				});
				Managers.RecipeMap.onPotionBaseSelect.AddListener((UnityAction)delegate
				{
					if (Managers.RecipeMap.currentMap == map)
					{
						NewState(newButton.Button);
					}
				});
				((Graphic)newButton.Image).color = new Color(1f, 1f, 1f, 0.3f);
				RectTransform component = ((ControlContainer)AbstractDisplay.CreateIconOnLayout(((ControlContainer)newButton).GameObject.transform, ((Object)map.potionBase).name + " Icon", map.potionBase.markerIconSelectedSprite)).GameObject.GetComponent<RectTransform>();
				component.anchoredPosition = new Vector2(0f, 0f);
				component.anchorMax = new Vector2(0.9f, 0.9f);
				component.anchorMin = new Vector2(0.1f, 0.1f);
				component.sizeDelta = Vector2.zero;
			}
		}

		private void NewState(Button n)
		{
			if ((Object)(object)currentState != (Object)null)
			{
				((Selectable)currentState).interactable = true;
			}
			currentState = n;
			((Selectable)currentState).interactable = false;
		}

		private void ShowWarning()
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_warningWindow == (Object)null)
			{
				_warningWindow = DebugWindow.Init("#warning_window_title", true);
				_warningWindow.ShowText("#warning_window_text");
				((Component)_warningWindow.captionText).gameObject.AddComponent<LocalizedText>();
				((Component)_warningWindow.bodyText).gameObject.AddComponent<LocalizedText>();
				_warningWindow.resizeAfter = 0f;
				((Component)_warningWindow).gameObject.transform.localPosition = new Vector3(-4.5f, 1f, 0f);
			}
			((Window)_warningWindow).Visible = true;
		}
	}
}
namespace TooManyPotions.Scripts.Controls
{
	public class ScrollRectCellResize : MonoBehaviour
	{
		public RectTransform? panel;

		public RectTransform? content;

		public RectTransform? scroll;

		public GridLayoutGroup? group;

		public int iconsInRow = 4;

		private float _gridCellSize;

		public void Update()
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)group == (Object)null) && !((Object)(object)panel == (Object)null) && !((Object)(object)scroll == (Object)null))
			{
				if ((Object)(object)content == (Object)null)
				{
					Transform obj = ((Transform)panel).Find("Viewport");
					content = (RectTransform)((obj != null) ? obj.Find("Content") : null);
				}
				Rect rect = panel.rect;
				float width = ((Rect)(ref rect)).width;
				RectTransform? obj2 = content;
				float? num = ((obj2 != null) ? new float?(obj2.anchorMax.x) : null);
				RectTransform? obj3 = content;
				float num2 = width * (num - ((obj3 != null) ? new float?(obj3.anchorMin.x) : null)).GetValueOrDefault(1f);
				rect = scroll.rect;
				float width2 = ((Rect)(ref rect)).width;
				float num3 = (num2 - width2) / (float)iconsInRow;
				if (num3 < 0f)
				{
					num3 = 0f;
				}
				if (num3 != _gridCellSize)
				{
					group.cellSize = new Vector2(num3, num3);
					_gridCellSize = num3;
				}
			}
		}
	}
}
namespace TooManyPotions.Scripts.CheatModules
{
	public class CheatBehaviour<T> : MonoBehaviour where T : MonoBehaviour
	{
		private static MonoBehaviour? _instance;

		public static MonoBehaviour? Instance
		{
			get
			{
				if ((Object)(object)_instance == (Object)null && (Object)(object)ModInfo.CheatHolder != (Object)null)
				{
					_instance = (MonoBehaviour?)(object)(ModInfo.CheatHolder.GetComponent<T>() ?? ModInfo.CheatHolder.AddComponent<T>());
				}
				return _instance;
			}
		}
	}
	public class HaggleAutoplayer : CheatBehaviour<HaggleAutoplayer>
	{
		private static HaggleWindow Window => HaggleWindow.Instance;

		private static HaggleSubManager Manager => Managers.Trade.haggle;

		public void FixedUpdate()
		{
			HaggleAutoplay();
		}

		private static void HaggleAutoplay()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Window == (Object)null || Window.IsPaused || Manager == null || (int)Manager.HaggleState == 0)
			{
				return;
			}
			List<BonusInfo> haggleCurrentBonuses = Manager.haggleCurrentBonuses;
			BonusInfo val = ((IEnumerable<BonusInfo>)haggleCurrentBonuses).FirstOrDefault((Func<BonusInfo, bool>)((BonusInfo info) => Mathf.Abs(info.haggleBonus.Position - Manager.pointerPosition) <= info.size / 2f));
			if (val != null)
			{
				int num = haggleCurrentBonuses.IndexOf(val);
				if (num != 0 && num != haggleCurrentBonuses.Count - 1)
				{
					((Button)Window.bargainButton).OnButtonClicked(false);
				}
			}
		}
	}
	public class ItemDuplicator : CheatBehaviour<ItemDuplicator>
	{
		private readonly float PRESS_TIME = 1f;

		private readonly float DELAY_TIME = 0.125f;

		private float timer = -1f;

		private void OnEnable()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			GlobalConfigs.duplicateInInventory.onJustDownedEvent.AddListener(new UnityAction(StartTimer));
			GlobalConfigs.duplicateInInventory.onJustUppedEvent.AddListener(new UnityAction(EndTimer));
		}

		private void OnDisable()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			timer = -1f;
			GlobalConfigs.duplicateInInventory.onJustDownedEvent.RemoveListener(new UnityAction(StartTimer));
			GlobalConfigs.duplicateInInventory.onJustUppedEvent.RemoveListener(new UnityAction(EndTimer));
		}

		public void Update()
		{
			if (GlobalConfigs.IsDuplicating)
			{
				DuplicateHoveredInventoryItem(1);
			}
		}

		public void FixedUpdate()
		{
			if (GlobalConfigs.IsDuplicatingMultiple && IsTimerTriggered())
			{
				timer += DELAY_TIME;
				DuplicateHoveredInventoryItem(1);
			}
		}

		private void StartTimer()
		{
			if (GlobalConfigs.IsUEUnfocused)
			{
				timer = Time.time;
			}
		}

		private void EndTimer()
		{
			if (GlobalConfigs.IsUEUnfocused)
			{
				timer = -1f;
			}
		}

		private bool IsTimerTriggered()
		{
			if (timer > 0f)
			{
				return Time.time - timer > PRESS_TIME;
			}
			return false;
		}

		private static void DuplicateHoveredInventoryItem(int count)
		{
			InteractiveItem obj = Managers.Cursor?.hoveredInteractiveItem;
			InventoryObject val = (InventoryObject)(object)((obj is InventoryObject) ? obj : null);
			if (!((Object)(object)val == (Object)null))
			{
				InventoryItem inventoryItem = val.InventoryItem;
				if (inventoryItem is Salt)
				{
					count *= 1000;
				}
				val.ItemsPanel.Inventory.AddItem(inventoryItem, count, true, true);
			}
		}
	}
	public class PotionPositionModifier : CheatBehaviour<PotionPositionModifier>
	{
		private static Vector2 CursorPosition => Vector2.op_Implicit(Managers.Cursor.cursor.transform.position);

		private static Vector2 CursorMapPosition => Vector2.op_Implicit(Managers.RecipeMap.currentMap.referencesContainer.transform.InverseTransformPoint(Vector2.op_Implicit(Managers.RecipeMap.recipeMapObject.transmitterWindow.ViewToCamera(CursorPosition))));

		public void Update()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Managers.Cursor == (Object)null) && !((Object)(object)Managers.Cursor.grabbedInteractiveItem != (Object)null) && ((Collider2D)Managers.RecipeMap.recipeMapObject.visibilityZoneCollider).OverlapPoint(CursorPosition))
			{
				if (GlobalConfigs.IsRotating)
				{
					RotatePotionToCursor();
				}
				if (GlobalConfigs.IsTeleporting)
				{
					TranslatePotionToCursor();
				}
			}
		}

		public static void TranslatePotionToCursor()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			((RecipeMapItem)Managers.RecipeMap.indicator).SetPositionOnMap(CursorMapPosition);
		}

		public static void RotatePotionToCursor()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			Managers.RecipeMap.path.pathHints.RemoveAll((NonFixedHint hint) => (Object)(object)hint.ingredient == (Object)null);
			Vector2 val = CursorMapPosition - Vector2.op_Implicit(Managers.RecipeMap.recipeMapObject.indicatorContainer.localPosition);
			Managers.RecipeMap.indicatorRotation.RotateTo(Mathf.Atan2(0f - val.x, val.y) * 57.29578f);
		}
	}
}
namespace TooManyPotions.Patches
{
	[HarmonyPatch(typeof(DangerZonePart), "GetHpChange")]
	internal class DangerZonePatch
	{
		public static bool Prefix()
		{
			return !GlobalConfigs.IsDangerZonesDisabled;
		}
	}
	[HarmonyPatch(typeof(GameManager), "Start")]
	internal class GameManagerPatcher
	{
		public static void Postfix()
		{
			ObjectsLoader.AddLast("SaveLoadManager.SaveNewGameState", (Action)ModInfo.InitializeCheatGameObject);
			ModInfo.Log("Patched start been called", (LogLevel)16);
		}
	}
	[HarmonyPatch(typeof(GamepadFreeCursorPositionUpdater), "UpdateCursorPosition")]
	internal class GamepadCursorPatch
	{
		public static Vector2 Postfix(Vector2 currentMouseWorldPosition)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (!DisplayToggler.IsActive)
			{
				return currentMouseWorldPosition;
			}
			Vector2 val = Vector2.op_Implicit(Camera.current.WorldToScreenPoint(Vector2.op_Implicit(currentMouseWorldPosition)));
			Mouse.current.WarpCursorPosition(val);
			return currentMouseWorldPosition;
		}
	}
	[HarmonyPatch(typeof(Gamepad), "OnDisable")]
	internal class GamepadDisablePatch
	{
		public static bool Prefix()
		{
			return !DisplayToggler.IsActive;
		}
	}
	[HarmonyPatch(typeof(InputManager), "HasInputGotToBeDisabled")]
	internal class InputSystemPatch
	{
		public static void Postfix(ref bool __result)
		{
			__result = __result || !GlobalConfigs.IsUEUnfocused;
		}
	}
	[HarmonyPatch(typeof(ScrollRect))]
	internal class ScrollRectPatch
	{
		private static readonly Dictionary<GameObject, Vector2> slidersDictionary = new Dictionary<GameObject, Vector2>();

		public static void SetSliderSize(GameObject scrollRectObject, Vector2 size)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			slidersDictionary.Add(scrollRectObject, size);
		}

		[HarmonyPatch("UpdateScrollbars")]
		[HarmonyPostfix]
		public static void Postfix(ScrollRect __instance, ref Scrollbar ___m_HorizontalScrollbar, ref Scrollbar ___m_VerticalScrollbar)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (slidersDictionary.TryGetValue(((Component)__instance).gameObject, out var value))
			{
				if (Object.op_Implicit((Object)(object)___m_HorizontalScrollbar))
				{
					___m_HorizontalScrollbar.size = value.x;
					___m_HorizontalScrollbar.value = __instance.horizontalNormalizedPosition;
				}
				if (Object.op_Implicit((Object)(object)___m_VerticalScrollbar))
				{
					___m_VerticalScrollbar.size = value.y;
					___m_VerticalScrollbar.value = __instance.verticalNormalizedPosition;
				}
			}
		}
	}
	[HarmonyPatch(typeof(LoadingQueue), "Add")]
	internal class StartupPatch
	{
		[HarmonyPatch("Add", new Type[]
		{
			typeof(string),
			typeof(Action)
		})]
		[HarmonyPrefix]
		public static bool Add(string name, Action action)
		{
			if (GlobalConfigs.IsForceDevMode && name.Equals("InitializeDeveloperMode"))
			{
				Settings<ApplicationManagerSettings>.Asset.developerModeOnStartInBuild = true;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(InputSystemUIInputModule), "Awake")]
	internal class UnityInputSystemPatch
	{
		public static void Postfix(InputSystemUIInputModule __instance)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			InputActionSetupExtensions.AddBinding(__instance.leftClick.action, "<Gamepad>/buttonSouth", (string)null, (string)null, (string)null);
		}
	}
}
namespace TooManyPotions.Helpers
{
	public static class FontsHelper
	{
		private static readonly Dictionary<string, TMP_FontAsset> fontsDictionary;

		static FontsHelper()
		{
			fontsDictionary = new Dictionary<string, TMP_FontAsset>();
			ModInfo.Log("Loading Fonts", (LogLevel)16);
			RequestFonts(Enumerable.Empty<string>().Append("Vollkorn-PC-Numbers Bold SDF").Append("Vollkorn-PC SemiBold SDF"));
			ModInfo.Log($"Loaded {fontsDictionary.Count} Fonts", (LogLevel)16);
		}

		public static TMP_FontAsset RequestFont(string name)
		{
			string name2 = name;
			if (fontsDictionary.TryGetValue(name2, out TMP_FontAsset value))
			{
				return value;
			}
			value = Array.Find(Resources.FindObjectsOfTypeAll<TMP_FontAsset>(), (TMP_FontAsset s) => ((Object)s).name?.Equals(name2) ?? false);
			fontsDictionary.Add(name2, value);
			return value;
		}

		public static void RequestFonts(IEnumerable<string> names)
		{
			IEnumerable<string> names2 = names;
			foreach (TMP_FontAsset item in from s in Resources.FindObjectsOfTypeAll<TMP_FontAsset>()
				where names2.Contains(((Object)s).name) && !fontsDictionary.Keys.Contains(((Object)s).name)
				select s)
			{
				fontsDictionary.Add(((Object)item).name, item);
			}
		}
	}
	public static class PlayerStatsHelper
	{
		public static readonly ReadOnlyCollection<InventoryItem> Items;

		public static readonly ReadOnlyCollection<PotionEffect> Effects;

		public static readonly ReadOnlyCollection<MapState> MapBases;

		public static int Gold
		{
			get
			{
				return Managers.Player.Gold;
			}
			set
			{
				if (value >= 0)
				{
					Managers.Player.AddGold(value - Gold);
				}
			}
		}

		public static int Popularity
		{
			get
			{
				return Managers.Player.popularity.Popularity;
			}
			set
			{
				Managers.Player.popularity.Popularity = value;
			}
		}

		public static float Experience
		{
			get
			{
				return Managers.Player.experience.CurrentExp;
			}
			set
			{
				if (value < 0f)
				{
					return;
				}
				if (value > 1E+20f)
				{
					value = 1E+20f;
				}
				ExperienceSubManager experience = Managers.Player.experience;
				float num = Settings<PlayerManagerSettings>.Asset.levelStep;
				int num2 = Mathf.FloorToInt(0.5f * (Mathf.Sqrt(8f * value / num + 1f) + 1f));
				int num3 = num2 - experience.currentLvl;
				bool flag = num3 > 50 || num3 < 0;
				if (flag || value < experience.CurrentExp)
				{
					experience.currentExp = value;
					if (flag)
					{
						experience.currentLvl = num2;
						experience.currentLvlAt = (float)((num2 - 1) * num2 / 2) * num;
						experience.nextLvlAt = experience.currentLvlAt + (float)num2 * num;
						if (num3 > 0)
						{
							TalentsSubManager talents = Managers.Player.talents;
							talents.currentPoints += num3 - 1;
							UnityEvent onLvlUp = experience.OnLvlUp;
							if (onLvlUp != null)
							{
								onLvlUp.Invoke();
							}
							experience.CheckLvlGoal();
						}
					}
					UnityEvent onCurrentExpChanged = experience.OnCurrentExpChanged;
					if (onCurrentExpChanged != null)
					{
						onCurrentExpChanged.Invoke();
					}
				}
				else
				{
					experience.AddExperience(value - experience.CurrentExp, (ExperienceCategory)0);
				}
			}
		}

		public static int Karma
		{
			get
			{
				return Managers.Player.karma.Karma;
			}
			set
			{
				Managers.Player.karma.Karma = value;
			}
		}

		static PlayerStatsHelper()
		{
			List<InventoryItem> list = new List<InventoryItem>();
			list.AddRange((IEnumerable<InventoryItem>)Ingredient.allIngredients.OrderBy((Ingredient x) => ((InventoryItem)x).GetItemType()));
			list.AddRange((IEnumerable<InventoryItem>)AlchemyMachineProduct.allProducts.Where((AlchemyMachineProduct x) => !((Object)x).name.Contains("Useless") && !((Object)x).name.Contains("Salt Pile")));
			list.AddRange((IEnumerable<InventoryItem>)Salt.allSalts);
			Dictionary<BuildableInventoryItemType, List<BuildableInventoryItem>> allBuildableItems = BuildableInventoryItem.allBuildableItems;
			list.AddRange((IEnumerable<InventoryItem>)allBuildableItems[(BuildableInventoryItemType)1]);
			list.AddRange((IEnumerable<InventoryItem>)WateringPot.AllPots);
			list.AddRange((IEnumerable<InventoryItem>)DecorDynamic.allDecorItems);
			list.AddRange((IEnumerable<InventoryItem>)allBuildableItems[(BuildableInventoryItemType)0]);
			list.AddRange((IEnumerable<InventoryItem>)TradableUpgrade.allTradableUpgrades);
			Items = list.AsReadOnly();
			Effects = PotionEffect.allPotionEffects.AsReadOnly();
			MapBases = new ReadOnlyCollection<MapState>(MapStatesManager.MapStates);
		}

		public static void AddItem(InventoryItem item, int amount)
		{
			try
			{
				Managers.Player.Inventory.AddItem(item, amount, true, true);
			}
			catch (Exception ex)
			{
				ModInfo.Log(ex.Message, (LogLevel)4);
			}
		}

		public static bool CanAddEffect(PotionEffect effect)
		{
			if (Managers.Potion.GetEffectTier(effect) >= 3)
			{
				return false;
			}
			return true;
		}

		public static void AddEffect(PotionEffect effect)
		{
			Managers.Potion.ApplyEffectToPotion(effect, 1);
		}

		public static void SetMapBase(MapState based)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			MapState based2 = based;
			if (Managers.RecipeMap.potionBaseSubManager.IsBaseUnlocked(based2.potionBase))
			{
				SelectMap(based2);
				return;
			}
			Managers.RecipeMap.potionBaseSubManager.UnlockPotionBase(based2.potionBase, false, false, false);
			Managers.Game.LoadScenes(new List<SceneIndexEnum> { based2.potionBase.GetSceneIndexEnum() }, (Action)null, (Action)delegate
			{
				SelectMap(based2);
			});
		}

		private static void SelectMap(MapState based)
		{
			float zoomNow = Managers.RecipeMap.recipeMapObject.GetZoomObject().ZoomNow;
			MapStatesManager.SelectMap(based.index, true);
			Managers.RecipeMap.currentMap.ResetCamState(zoomNow);
			Managers.RecipeMap.potionBaseSubManager.ReadPotionBase(based.potionBase);
		}
	}
	public static class SpritesHelper
	{
		private static readonly Dictionary<string, List<Sprite>> SpritesDictionary;

		private static readonly Dictionary<string, Sprite> RequestedSpritesDictionary;

		static SpritesHelper()
		{
			RequestedSpritesDictionary = new Dictionary<string, Sprite>();
			ModInfo.Log("Loading Sprites", (LogLevel)16);
			SpritesDictionary = (from resource in Resources.LoadAll<Sprite>("Sprite Assets")
				group resource by ((Object)resource).name).ToDictionary((IGrouping<string, Sprite> pair) => pair.Key, (IGrouping<string, Sprite> pair) => pair.ToList());
			RequestSprites((from i in Enumerable.Range(1, 19)
				select $"Inventory Item Slot {i} Normal").Append("InventoryScroller Pointer").Append("InventoryScroller Axis Var1 Active").Append("GoalsTrackPanel Background")
				.Append("InventoryWindow Background Var2")
				.Append("Gold Plate Idle")
				.Append("Popularity Plate Idle")
				.Append("Karma Plate Idle")
				.Append("SaveRecipe Active Slot"));
			ModInfo.Log($"Loaded {SpritesDictionary.Count + RequestedSpritesDictionary.Count} Sprites", (LogLevel)16);
		}

		public static List<Sprite>? GetByListName(string name)
		{
			if (SpritesDictionary.ContainsKey(name))
			{
				return SpritesDictionary[name];
			}
			return null;
		}

		public static Sprite? GetByName(string name)
		{
			return GetByListName(name)?.FirstOrDefault();
		}

		public static Sprite RequestSpriteByName(string name)
		{
			string name2 = name;
			if (RequestedSpritesDictionary.TryGetValue(name2, out Sprite value))
			{
				return value;
			}
			value = Array.Find(Resources.FindObjectsOfTypeAll<Sprite>(), (Sprite s) => ((Object)s).name?.Equals(name2) ?? false);
			RequestedSpritesDictionary.Add(name2, value);
			return value;
		}

		public static void RequestSprites(IEnumerable<string> names)
		{
			IEnumerable<string> names2 = names;
			foreach (Sprite item in from s in Resources.FindObjectsOfTypeAll<Sprite>()
				where names2.Contains(((Object)s).name) && !RequestedSpritesDictionary.Keys.Contains(((Object)s).name)
				select s)
			{
				RequestedSpritesDictionary.Add(((Object)item).name, item);
			}
		}
	}
	public static class UnityExplorerHelper
	{
		public static bool IsExplorerLoaded { get; internal set; }

		public static bool IsFocused
		{
			get
			{
				if (IsExplorerLoaded)
				{
					return GetExplorerState();
				}
				return false;
			}
		}

		private static bool GetExplorerState()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			foreach (Panels value in Enum.GetValues(typeof(Panels)))
			{
				if (((UIModel)UIManager.GetPanel(value)).Enabled)
				{
					return true;
				}
			}
			return false;
		}
	}
}
namespace TooManyPotions.Extensions
{
	public static class InventoryItemExtension
	{
		public static (Sprite, Vector2) GetIconData(this InventoryItem item)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			Ingredient val = (Ingredient)(object)((item is Ingredient) ? item : null);
			if (val == null)
			{
				Salt val2 = (Salt)(object)((item is Salt) ? item : null);
				if (val2 == null)
				{
					AlchemyMachineProduct val3 = (AlchemyMachineProduct)(object)((item is AlchemyMachineProduct) ? item : null);
					if (val3 == null)
					{
						Seed val4 = (Seed)(object)((item is Seed) ? item : null);
						if (val4 == null)
						{
							Furniture val5 = (Furniture)(object)((item is Furniture) ? item : null);
							if (val5 != null)
							{
								return (((BuildableInventoryItem)val5).prefab.visualObjectController.renderersToOutline[^1].sprite, Vector2.zero);
							}
							return (item.GetInventoryIcon(), Vector2.zero);
						}
						return (val4.smallIcon, new Vector2(5f, 0f));
					}
					return (val3.GetActiveMarkerIcon(), Vector2.zero);
				}
				return (val2.smallIcon, new Vector2(5f, 0f));
			}
			return (val.smallIcon, new Vector2(5f, 0f));
		}
	}
}
namespace TooManyPotions.Controls.Factories
{
	public abstract class ControlsFactory
	{
		public static ControlsFactory Instance => (ControlsFactory)(object)PotionCraftControlsFactory.Instance;
	}
	public class PotionCraftControlsFactory : DefaultControlsFactory
	{
		private Resources _resourcesDefault = new Resources
		{
			font = FontsHelper.RequestFont("Vollkorn-PC SemiBold SDF")
		};

		private Resources _resourcesInputField = new Resources
		{
			font = FontsHelper.RequestFont("Vollkorn-PC-Numbers Bold SDF")
		};

		private Resources _resourcesToggle = new Resources
		{
			standard = SpritesHelper.GetByName("Alchemist'sPathBook FollowIcon Default"),
			checkmark = SpritesHelper.GetByName("Alchemist'sPathBook FollowIcon AlwaysFollow")
		};

		private Resources _resourcesScroll = new Resources
		{
			knob = SpritesHelper.RequestSpriteByName("InventoryScroller Pointer"),
			background = SpritesHelper.RequestSpriteByName("InventoryScroller Axis Var1 Active")
		};

		private Resources _resourcesScrollView = new Resources
		{
			standard = SpritesHelper.RequestSpriteByName("InventoryScroller Pointer"),
			knob = SpritesHelper.RequestSpriteByName("InventoryScroller Pointer"),
			background = SpritesHelper.RequestSpriteByName("InventoryWindow Background Var2"),
			childBackground = SpritesHelper.RequestSpriteByName("InventoryScroller Axis Var1 Active")
		};

		public static PotionCraftControlsFactory Instance { get; } = new PotionCraftControlsFactory();


		protected override ButtonContrainer CreateButton(Resources resources = default(Resources))
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			ButtonContrainer obj = ((DefaultControlsFactory)this).CreateButton(_resourcesDefault);
			((TMP_Text)obj.Text).enableWordWrapping = false;
			return obj;
		}

		protected override InputFieldContrainer CreateInputField(Resources resources = default(Resources))
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return ((DefaultControlsFactory)this).CreateInputField(_resourcesInputField);
		}

		protected override SliderContrainer CreateSlider(Resources resources = default(Resources))
		{
			//IL_0002: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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)
			SliderContrainer obj = ((DefaultControlsFactory)this).CreateSlider(_resourcesScroll);
			GameObject gameObject = ((ControlContainer)obj).GameObject;
			Object.Destroy((Object)(object)((Component)gameObject.transform.Find("Fill Area")).gameObject);
			RectTransform val = (RectTransform)((Component)obj.BackgroundImage).gameObject.transform;
			((Transform)val).localEulerAngles = new Vector3(0f, 0f, 90f);
			val.anchorMin = new Vector2(0.46f, -2f);
			val.anchorMax = new Vector2(0.54f, 3f);
			RectTransform val2 = (RectTransform)gameObject.transform.Find("Handle Slide Area");
			val2.sizeDelta = new Vector2(val2.sizeDelta.x, -10f);
			return obj;
		}

		protected override ToggleContrainer CreateToggle(Resources resources = default(Resources))
		{
			//IL_0002: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			ToggleContrainer obj = ((DefaultControlsFactory)this).CreateToggle(_resourcesToggle);
			((ControlContainer)obj).GameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 22f);
			TextMeshProUGUI text = obj.Text;
			((TMP_Text)text).fontSize = 16f;
			((Graphic)text).color = new Color(0f, 0f, 0f, 1f);
			((TMP_Text)text).enableWordWrapping = false;
			RectTransform component = ((Component)text).gameObject.GetComponent<RectTransform>();
			component.anchoredPosition = new Vector2(120f, -25f);
			Vector2 anchorMax = (component.anchorMin = Vector2.up);
			component.anchorMax = anchorMax;
			return obj;
		}

		protected override ScrollContainer CreateVerticalScroll(Resources resources = default(Resources))
		{
			//IL_0002: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_005a: 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)
			//IL_008e: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			ScrollContainer val = ((DefaultControlsFactory)this).CreateVerticalScroll(_resourcesScrollView);
			((Graphic)val.Background).color = new Color(1f, 1f, 1f, 1f);
			val.Scroll.movementType = (MovementType)2;
			GameObject gameObject = ((ControlContainer)val).GameObject;
			RectTransform val2 = (RectTransform)gameObject.transform;
			val2.pivot = new Vector2(1f, 0f);
			RectTransform component = val.ContentHolder.GetComponent<RectTransform>();
			component.anchorMax = new Vector2(0.98f, 1f);
			component.anchorMin = new Vector2(0.02f, 0f);
			RectTransform component2 = val.VerticalScroll.GetComponent<RectTransform>();
			component2.sizeDelta = new Vector2(12f, 0f);
			component2.pivot = new Vector2(1f, 0f);
			component2.anchorMax = new Vector2(0.975f, 1f);
			component2.anchorMin = new Vector2(0.975f, 0f);
			component2.anchoredPosition = Vector2.zero;
			ScrollRectPatch.SetSliderSize(gameObject, Vector2.zero);
			RectTransform val3 = (RectTransform)((Transform)component2).Find("Sliding Area");
			val3.sizeDelta = new Vector2(-10f, -10f);
			((RectTransform)((Transform)val3).Find("Handle")).sizeDelta = new Vector2(15f, 15f);
			ScrollRectCellResize scrollRectCellResize = gameObject.AddComponent<ScrollRectCellResize>();
			scrollRectCellResize.panel = val2;
			scrollRectCellResize.scroll = component2;
			scrollRectCellResize.group = val.ContentHolder.AddComponent<GridLayoutGroup>();
			val.ContentHolder.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			return val;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}