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 BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using EasierUI;
using EasierUI.Controls;
using EasierUI.Controls.Contrainers;
using EasierUI.Controls.Factories;
using HarmonyLib;
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.Markers;
using PotionCraft.ObjectBased.Haggle;
using PotionCraft.ObjectBased.InteractiveItem;
using PotionCraft.ObjectBased.InteractiveItem.InventoryObject;
using PotionCraft.ObjectBased.RecipeMap;
using PotionCraft.ObjectBased.RecipeMap.RecipeMapItem;
using PotionCraft.ObjectBased.RecipeMap.RecipeMapItem.Zones;
using PotionCraft.ObjectBased.UIElements;
using PotionCraft.SceneLoader;
using PotionCraft.ScriptableObjects;
using PotionCraft.ScriptableObjects.Ingredient;
using PotionCraft.ScriptableObjects.Salts;
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.EventSystems;
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 © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8e8be687-07f6-46c9-9298-1611415e4adc")]
[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 TooManyPotions
{
[BepInPlugin("ReuloTeam.TooManyPotions", "TooManyPotions", "1.0.0")]
[BepInProcess("Potion Craft.exe")]
public class ModInfo : BaseUnityPlugin
{
private static ManualLogSource Logger;
private const string GUID = "ReuloTeam.TooManyPotions";
private const string MODNAME = "TooManyPotions";
private const string VERSION = "1.0.0";
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: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
GameObject val = new GameObject("CheatHolder");
DisplayToggler.Init();
val.AddComponent<PotionPositionModifier>();
val.AddComponent<ItemDuplicator>();
val.AddComponent<HaggleAutoplayer>();
Object.DontDestroyOnLoad((Object)val);
}
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);
}
}
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", (HotKey[])(object)new HotKey[2]
{
new HotKey((Button[])(object)new Button[1] { GamepadButton.Get((ButtonCode)30) }),
new HotKey((Button[])(object)new Button[2]
{
MouseButton.Get(0),
KeyboardKey.Get((KeyCode)306)
})
}, false);
public static Command duplicateInInventoryMultiple = new Command("Duplicate item in inventory multiple times", (HotKey[])(object)new HotKey[2]
{
new HotKey((Button[])(object)new Button[1] { GamepadButton.Get((ButtonCode)31) }),
new HotKey((Button[])(object)new Button[2]
{
MouseButton.Get(1),
KeyboardKey.Get((KeyCode)306)
})
}, false);
public static bool IsForceDevMode
{
get
{
return _isForceDevMode;
}
set
{
_isForceDevMode |= value;
}
}
public static bool IsPositionModifyingAllowed { get; set; }
public static bool IsDangerZonesDisabled { get; set; }
public static bool IsDuplicateOnClickAllowed { get; set; }
public static bool IsHaggleAutoplayAllowed { get; set; }
public static bool IsEffectOverflowAllowed { get; set; }
public static bool IsUnfocused => UnityExplorerHelper.IsFocused;
public static bool IsRotating
{
get
{
if (!IsUnfocused)
{
return IsInState(rotatePotion, (State)1);
}
return false;
}
}
public static bool IsTeleporting
{
get
{
if (!IsUnfocused)
{
return IsInState(teleportPotion, (State)1);
}
return false;
}
}
public static bool IsDuplicating
{
get
{
if (!IsUnfocused)
{
return IsInState(duplicateInInventory, (State)2);
}
return false;
}
}
public static bool IsDuplicatingMultiple
{
get
{
if (!IsUnfocused)
{
return IsInState(duplicateInInventoryMultiple, (State)2);
}
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;
}
}
}
namespace TooManyPotions.Extensions
{
public static class InventoryItemExtension
{
public static Sprite GetIcon(this InventoryItem item)
{
Salt val = (Salt)(object)((item is Salt) ? item : null);
if (val == null)
{
Ingredient val2 = (Ingredient)(object)((item is Ingredient) ? item : null);
if (val2 != null)
{
return val2.smallIcon;
}
return item.inventoryIconObject;
}
return val.smallIcon;
}
}
}
namespace TooManyPotions.Helpers
{
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 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);
list.AddRange((IEnumerable<InventoryItem>)Salt.allSalts);
Items = list.AsReadOnly();
List<PotionEffect> list2 = new List<PotionEffect>();
list2.AddRange(PotionEffect.allPotionEffects);
Effects = list2.AsReadOnly();
List<MapState> list3 = new List<MapState>();
list3.AddRange(MapStatesManager.MapStates);
MapBases = list3.AsReadOnly();
}
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)
{
Managers.RecipeMap.potionBaseSubManager.UnlockPotionBase(based.potionBase, false, false);
ModInfo.Log(((Object)based.potionBase).name, (LogLevel)16);
MapStatesManager.SelectMap(based.index, true);
}
}
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;
}
}
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("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)
{
if (RequestedSpritesDictionary.TryGetValue(name, out var value))
{
return value;
}
value = Array.Find(Resources.FindObjectsOfTypeAll<Sprite>(), (Sprite s) => ((Object)s).name?.Equals(name) ?? false);
RequestedSpritesDictionary.Add(name, value);
return value;
}
public static void RequestSprites(IEnumerable<string> names)
{
foreach (Sprite item in from s in Resources.FindObjectsOfTypeAll<Sprite>()
where names.Contains(((Object)s).name) && !RequestedSpritesDictionary.Keys.Contains(((Object)s).name)
select s)
{
RequestedSpritesDictionary.Add(((Object)item).name, item);
}
}
}
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)
{
if (fontsDictionary.TryGetValue(name, out var value))
{
return value;
}
value = Array.Find(Resources.FindObjectsOfTypeAll<TMP_FontAsset>(), (TMP_FontAsset s) => ((Object)s).name?.Equals(name) ?? false);
fontsDictionary.Add(name, value);
return value;
}
public static void RequestFonts(IEnumerable<string> names)
{
foreach (TMP_FontAsset item in from s in Resources.FindObjectsOfTypeAll<TMP_FontAsset>()
where names.Contains(((Object)s).name) && !fontsDictionary.Keys.Contains(((Object)s).name)
select s)
{
fontsDictionary.Add(((Object)item).name, item);
}
}
}
}
namespace TooManyPotions.Patches
{
[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(InputManager), "HasInputGotToBeDisabled")]
internal class InputSystemPatch
{
public static void Postfix(ref bool __result)
{
__result = __result || GlobalConfigs.IsUnfocused;
}
}
[HarmonyPatch(typeof(DangerZonePart), "GetHpChange")]
internal class DangerZonePatch
{
public static bool Prefix()
{
return !GlobalConfigs.IsDangerZonesDisabled;
}
}
[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(ScrollRect))]
internal class ScrollRectPatch
{
private static 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(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(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.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")
};
private const float DefaultSensivity = 10f;
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)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: 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);
new PointerEventData(EventSystem.current).position = Vector2.op_Implicit(Managers.Cursor.cursor.transform.position);
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_0032: 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)
ToggleContrainer obj = ((DefaultControlsFactory)this).CreateToggle(_resourcesToggle);
TextMeshPro text = obj.Text;
((TMP_Text)text).fontSize = 144f;
((Graphic)text).color = new Color(0f, 0f, 0f, 1f);
((TMP_Text)text).enableWordWrapping = false;
((ControlContainer)obj).GameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 22f);
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_007b: 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_009b: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
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.VerticalScroll.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(16f, 0f);
component.pivot = new Vector2(1f, 0f);
component.anchorMax = Vector2.one;
component.anchorMin = new Vector2(1f, 0f);
component.anchoredPosition = Vector2.zero;
ScrollRectPatch.SetSliderSize(gameObject, Vector2.zero);
((RectTransform)((Transform)component).Find("Sliding Area")).sizeDelta = new Vector2(-10f, -15f);
ScrollRectCellResize scrollRectCellResize = gameObject.AddComponent<ScrollRectCellResize>();
scrollRectCellResize.scrollRectTransform = val2;
scrollRectCellResize.scrollbarVTransform = component;
scrollRectCellResize.group = val.ContentHolder.AddComponent<GridLayoutGroup>();
val.ContentHolder.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
new PointerEventData(EventSystem.current)
{
position = Vector2.op_Implicit(Managers.Cursor.cursor.transform.position),
button = (InputButton)0
};
return val;
}
}
}
namespace TooManyPotions.Scripts.Controls
{
public class ScrollRectCellResize : MonoBehaviour
{
public RectTransform scrollRectTransform;
public RectTransform scrollbarVTransform;
public GridLayoutGroup group;
public int iconsInRow = 4;
private float _gridCellSize;
public void Update()
{
if (!((Object)(object)group == (Object)null) && !((Object)(object)scrollRectTransform == (Object)null) && !((Object)(object)scrollbarVTransform == (Object)null))
{
TryResizeCell();
}
}
private void TryResizeCell()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: 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_0052: Unknown result type (might be due to invalid IL or missing references)
Rect rect = scrollRectTransform.rect;
float width = ((Rect)(ref rect)).width;
rect = scrollbarVTransform.rect;
float width2 = ((Rect)(ref rect)).width;
float num = (width - width2) / (float)iconsInRow;
if (num < 0f)
{
num = 0f;
}
if (num != _gridCellSize)
{
group.cellSize = new Vector2(num, num);
_gridCellSize = num;
}
}
}
}
namespace TooManyPotions.Scripts.CheatModules
{
public class PotionPositionModifier : MonoBehaviour
{
public static bool CanModify
{
get
{
if (GlobalConfigs.IsPositionModifyingAllowed)
{
return IsCursorOverMap();
}
return false;
}
}
private static Vector2 CursorPosition => Managers.RecipeMap.recipeMapObject.transmitterWindow.ViewToCamera(Vector2.op_Implicit(Managers.Cursor.cursor.transform.position));
public void Update()
{
if (CanModify)
{
if (GlobalConfigs.IsRotating)
{
RotatePotionToCursor();
}
if (GlobalConfigs.IsTeleporting)
{
TranslatePotionToCursor();
}
}
}
public static bool IsCursorOverMap()
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Managers.Cursor == (Object)null)
{
return false;
}
if ((Object)(object)Managers.Cursor.grabbedInteractiveItem == (Object)null)
{
return ((Collider2D)Managers.RecipeMap.recipeMapObject.visibilityZoneCollider).OverlapPoint(Vector2.op_Implicit(Managers.Cursor.cursor.transform.position));
}
return false;
}
public static void TranslatePotionToCursor()
{
//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_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
((RecipeMapItem)Managers.RecipeMap.indicator).SetPositionOnMap(Vector2.op_Implicit(Managers.RecipeMap.currentMap.transform.InverseTransformPoint(Vector2.op_Implicit(CursorPosition))));
}
public static void RotatePotionToCursor()
{
//IL_0000: 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_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = CursorPosition - Vector2.op_Implicit(((Component)Managers.RecipeMap.indicator).transform.position);
Managers.RecipeMap.indicatorRotation.RotateTo(Mathf.Atan2(val.y, val.x) * 57.29578f - 90f);
}
}
public class ItemDuplicator : MonoBehaviour
{
public void Update()
{
if (GlobalConfigs.IsDuplicateOnClickAllowed && GlobalConfigs.IsDuplicating)
{
DuplicateHoveredInventoryItem(1);
}
}
public void FixedUpdate()
{
if (GlobalConfigs.IsDuplicateOnClickAllowed && GlobalConfigs.IsDuplicatingMultiple)
{
DuplicateHoveredInventoryItem(100);
}
}
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))
{
val.ObjectDebugInfo();
Inventory inventory = val.itemsPanel.Inventory;
object value = Traverse.Create((object)val).Field("inventoryItem").GetValue();
InventoryItem val2 = (InventoryItem)((value is InventoryItem) ? value : null);
if (val2 is Salt)
{
count *= 1000;
}
inventory.AddItem(val2, count, true, true);
}
}
}
public class HaggleAutoplayer : MonoBehaviour
{
public void FixedUpdate()
{
if (GlobalConfigs.IsHaggleAutoplayAllowed)
{
HaggleAutoplay();
}
}
private static void HaggleAutoplay()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
HaggleWindow instance = HaggleWindow.Instance;
if (instance.isPaused || (int)instance.state == 0)
{
return;
}
List<BonusInfo> currentBonuses = instance.currentBonuses;
Pointer pointer = default(Pointer);
ref Pointer reference = ref pointer;
object value = Traverse.Create((object)instance).Field("pointer").GetValue();
reference = (Pointer)((value is Pointer) ? value : null);
if ((Object)(object)pointer == (Object)null)
{
return;
}
BonusInfo val = ((IEnumerable<BonusInfo>)currentBonuses).FirstOrDefault((Func<BonusInfo, bool>)((BonusInfo info) => Mathf.Abs(info.haggleBonus.Position - pointer.Position) <= info.size / 2f));
if (val != null)
{
int num = currentBonuses.IndexOf(val);
if (num != 0 && num != currentBonuses.Count - 1)
{
((Button)instance.bargainButton).OnButtonClicked(false);
}
}
}
}
}
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 List<TextMeshPro> _unsortedTextElements = new List<TextMeshPro>();
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)
{
return;
}
_canvas.sortingOrder = sortingOrder;
foreach (TextMeshPro unsortedTextElement in _unsortedTextElements)
{
unsortedTextElement.sortingOrder = _canvas.sortingOrder + 1;
}
}
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 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();
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)
{
InputFieldContrainer obj = ControlsFactory.Instance.CreateInputField(parent, objectName, action, (ContentType?)(ContentType)2, 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_0021: 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_004a: 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_0073: 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_009c: 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, 1f), Vector2.zero);
CreateCorner(obj, "Top", new Vector2(0.98f, 1.008f), new Vector2(0.02f, 0.984f));
CreateCorner(obj, "Right", new Vector2(1f, 0.998f), new Vector2(0.97f, -0.002f));
CreateCorner(obj, "Bottom", new Vector2(0.98f, 0.01f), new Vector2(0.02f, -0.006f));
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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: 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");
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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: 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");
Managers.Player.popularity.onPopularityChanged.AddListener((UnityAction)delegate
{
_popularityInput.InputField.text = PlayerStatsHelper.Popularity.ToString();
});
}
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_0137: 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)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: 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);
RectTransform component = ((ControlContainer)AbstractDisplay.CreateIconOnLayout(((ControlContainer)obj2).GameObject.transform, ((Object)item).name + " Icon", item.GetIcon())).GameObject.GetComponent<RectTransform>();
component.anchoredPosition = new Vector2(0f, 0f);
component.anchorMax = new Vector2(1.3f, 1.05f);
component.anchorMin = new Vector2(0.1f, -0.05f);
component.sizeDelta = Vector2.zero;
}
}
private ToggleContrainer CreateToggle(RectTransform parent, string name, Action<bool> handler, string label)
{
ToggleContrainer val = ControlsFactory.Instance.CreateToggle((Transform)(object)parent, name, handler, label);
((ControlContainer)val).GameObject.AddComponent<LayoutElement>().preferredWidth = 200f;
val.Text.sortingLayerID = SortingLayer.NameToID("Debug");
((Component)val.Text).gameObject.AddComponent<LocalizedText>();
_unsortedTextElements.Add(val.Text);
return val;
}
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();
}
}
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 val = ControlsFactory.Instance.CreateToggle((Transform)(object)parent, name, handler, label);
((ControlContainer)val).GameObject.AddComponent<LayoutElement>().preferredWidth = 812f;
val.Text.sortingLayerID = SortingLayer.NameToID("Debug");
((Component)val.Text).gameObject.AddComponent<LocalizedText>();
_unsortedTextElements.Add(val.Text);
return val;
}
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_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: 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)
_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))).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.markerIconIdleSprite)).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;
}
}
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_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: 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);
_effectsMenuObject.SetActive(false);
_cheatMenu.potionEffectMenuOpenHandler = delegate
{
_effectsMenuObject.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)
{
_effectsMenuObject.SetActive(false);
((Button)_maximize).OnButtonReleasedPointerInside();
}
else
{
_cheatMenuObject.SetActive(!IsActive);
}
}
}
}