using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Assets.Scripts.Actors.Player;
using Assets.Scripts.Inventory__Items__Pickups.Items;
using Assets.Scripts.Saves___Serialization.Progression.Achievements;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ItemAddMenu")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Simple add item menu")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5ca0a6d17f2c7ba8d9af68a29e264fd7dc9690dd")]
[assembly: AssemblyProduct("ItemAddMenu")]
[assembly: AssemblyTitle("ItemAddMenu")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ItemAddMenu
{
[BepInPlugin("Wooshibou_ItemAddMenu", "ItemAddMenu", "1.0.0")]
public class Core : BasePlugin
{
[HarmonyPatch(typeof(MyPlayer), "Spawn")]
private static class Patch_OnSpawn
{
private static void Postfix()
{
CurrentPlayer = MyPlayer.Instance;
if (AllItems == null)
{
FetchAllItems();
GuiController.canIPlayPlz = true;
}
}
}
public const string MODNAME = "ItemAddMenu";
public const string AUTHOR = "Wooshibou";
public const string GUID = "Wooshibou_ItemAddMenu";
public const string VERSION = "1.0.0";
private Harmony _harmony;
private static ChestWindowUi currentChestWindowUiInstance;
public static ManualLogSource log;
public static GameObject ModMenuGUI;
public static Core Instance;
public static List<ItemData> AllItems;
public static ItemInventory CurrentPlayerInventory;
public static MyPlayer CurrentPlayer;
public Core()
{
log = ((BasePlugin)this).Log;
}
public override void Load()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Expected O, but got Unknown
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Expected O, but got Unknown
Instance = this;
ManualLogSource val = log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(14, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Loading ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("ItemAddMenu");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" v");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" by ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("Wooshibou");
}
val.LogInfo(val2);
if (!ClassInjector.IsTypeRegisteredInIl2Cpp(typeof(GuiController)))
{
ClassInjector.RegisterTypeInIl2Cpp<GuiController>();
}
ModMenuGUI = new GameObject("ItemAddMenu");
((Object)ModMenuGUI).hideFlags = (HideFlags)61;
ModMenuGUI.AddComponent<GuiController>();
Object.DontDestroyOnLoad((Object)(object)ModMenuGUI);
_harmony = new Harmony("Wooshibou_ItemAddMenu");
_harmony.PatchAll();
}
public void AddItem(ItemData item, int amount = 1)
{
//IL_003a: 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_0056: Expected O, but got Unknown
if (amount < 1)
{
log.LogError((object)"You can't give yourself negative items (or 0 items)");
}
else if (!((Object)(object)item == (Object)null))
{
CurrentPlayer.inventory.itemInventory.AddItem(item.eItem, amount);
ManualLogSource val = log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(8, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Added ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(amount);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("x ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((UnlockableBase)item).GetName());
}
val.LogInfo(val2);
}
}
public void RemoveItem(ItemData item, int amount = 1)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
if (amount < 1)
{
log.LogError((object)"You can't remove negative items (or 0 items)");
}
else if (!((Object)(object)item == (Object)null))
{
for (int i = 0; i < amount; i++)
{
CurrentPlayer.inventory.itemInventory.RemoveItem(item.eItem, true);
}
ManualLogSource val = log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Removed ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(amount);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("x ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((UnlockableBase)item).GetName());
}
val.LogInfo(val2);
}
}
public static void FetchAllItems()
{
AllItems = DataManager.Instance.unsortedItems;
}
}
internal class GuiController : MonoBehaviour
{
public static bool canIPlayPlz;
private bool visible = false;
private Vector2 scrollPos;
private int selectedIndex = 0;
private int amount = 1;
private bool showDropdown = false;
private Rect windowRect = new Rect(10f, 10f, 400f, 250f);
private void Update()
{
if (!canIPlayPlz)
{
visible = false;
}
if (Input.GetKeyDown((KeyCode)289) && canIPlayPlz)
{
visible = !visible;
}
}
private void OnGUI()
{
//IL_0013: 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_0033: Unknown result type (might be due to invalid IL or missing references)
if (visible)
{
windowRect = GUI.Window(0, windowRect, WindowFunction.op_Implicit((Action<int>)DrawWindow), "Item Menu v1.0.0");
}
}
private void DrawWindow(int windowID)
{
//IL_0027: 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_005d: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: 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_0452: Unknown result type (might be due to invalid IL or missing references)
//IL_045d: Unknown result type (might be due to invalid IL or missing references)
//IL_0468: Unknown result type (might be due to invalid IL or missing references)
if (Core.AllItems == null)
{
return;
}
List<ItemData> allItems = Core.AllItems;
GUI.backgroundColor = new Color(0.15f, 0.15f, 0.15f);
GUI.contentColor = Color.white;
GUI.Box(new Rect(0f, 0f, ((Rect)(ref windowRect)).width, ((Rect)(ref windowRect)).height), GUIContent.none);
GUI.Label(new Rect(10f, 5f, ((Rect)(ref windowRect)).width - 20f, 20f), "Item Menu");
GUILayout.BeginArea(new Rect(10f, 30f, ((Rect)(ref windowRect)).width - 20f, ((Rect)(ref windowRect)).height - 40f));
GUILayout.BeginVertical((Il2CppReferenceArray<GUILayoutOption>)null);
GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
if (GUILayout.Button(((UnlockableBase)allItems[selectedIndex]).GetName(), Array.Empty<GUILayoutOption>()))
{
showDropdown = !showDropdown;
}
if (showDropdown)
{
scrollPos = GUILayout.BeginScrollView(scrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(120f) });
for (int i = 0; i < allItems.Count; i++)
{
if (GUILayout.Button(((UnlockableBase)allItems[i]).GetName(), Array.Empty<GUILayoutOption>()))
{
selectedIndex = i;
showDropdown = false;
}
}
GUILayout.EndScrollView();
}
else
{
GUILayout.Label("", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(5f) });
GUILayout.Label("Name: " + ((UnlockableBase)allItems[selectedIndex]).GetName(), (Il2CppReferenceArray<GUILayoutOption>)null);
EItemRarity rarity = allItems[selectedIndex].rarity;
GUILayout.Label("Rarity: " + ((object)(EItemRarity)(ref rarity)).ToString(), (Il2CppReferenceArray<GUILayoutOption>)null);
GUILayout.Label("Description: " + ((UnlockableBase)allItems[selectedIndex]).GetDescription(), (Il2CppReferenceArray<GUILayoutOption>)null);
}
GUILayout.EndVertical();
GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
if (GUILayout.Button("Remove", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }))
{
Core.Instance.RemoveItem(allItems[selectedIndex], amount);
}
if (GUILayout.Button("-", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(20f) }))
{
amount = Mathf.Max(1, amount - 1);
}
if (GUILayout.Button("-10", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }))
{
amount = Mathf.Max(1, amount - 10);
}
if (GUILayout.Button("-100", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(45f) }))
{
amount = Mathf.Max(1, amount - 100);
}
GUILayout.Label(amount.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) });
if (GUILayout.Button("+", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(20f) }))
{
amount++;
}
if (GUILayout.Button("+10", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }))
{
amount += 10;
}
if (GUILayout.Button("+100", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(45f) }))
{
amount += 100;
}
if (GUILayout.Button("Add", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }))
{
Core.Instance.AddItem(allItems[selectedIndex], amount);
}
GUILayout.EndHorizontal();
GUILayout.EndVertical();
GUILayout.EndArea();
GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref windowRect)).width, 20f));
GUI.backgroundColor = Color.white;
GUI.contentColor = Color.black;
}
}
}