Decompiled source of Muck Ultimate Menu v1.1.0

plugins/MuckItemSpawner.dll

Decompiled 4 days ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MuckItemSpawner")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MuckItemSpawner")]
[assembly: AssemblyTitle("MuckItemSpawner")]
[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 MuckItemSpawner
{
	[BepInPlugin("com.harrier.itemspawner", "Muck Ultimate Menu", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private bool isMenuOpen = false;

		private Vector2 scrollPos;

		private string searchText = "";

		private string itemAmount = "1";

		private int currentTab = 0;

		private bool godMode = false;

		private bool infiniteStamina = false;

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Muck Ultimate Menu loaded! Press F2 to open.");
		}

		private void Update()
		{
			if (Input.GetKeyDown((KeyCode)283))
			{
				isMenuOpen = !isMenuOpen;
				Cursor.visible = isMenuOpen;
				Cursor.lockState = (CursorLockMode)((!isMenuOpen) ? 1 : 0);
			}
			if ((Object)(object)PlayerStatus.Instance != (Object)null)
			{
				if (godMode && PlayerStatus.Instance.hp < (float)PlayerStatus.Instance.maxHp)
				{
					PlayerStatus.Instance.hp = PlayerStatus.Instance.maxHp;
				}
				if (infiniteStamina && PlayerStatus.Instance.stamina < PlayerStatus.Instance.maxStamina)
				{
					PlayerStatus.Instance.stamina = PlayerStatus.Instance.maxStamina;
				}
			}
		}

		private void OnGUI()
		{
			//IL_0040: 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)
			if (isMenuOpen)
			{
				Rect val = default(Rect);
				((Rect)(ref val))..ctor((float)(Screen.width / 2 - 225), (float)(Screen.height / 2 - 275), 450f, 550f);
				GUI.Box(val, "Muck Ultimate Menu by Harrier v1.1.0");
				GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 30f, 430f, 510f));
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				if (GUILayout.Button("Предметы", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
				{
					currentTab = 0;
				}
				if (GUILayout.Button("Игрок", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
				{
					currentTab = 1;
				}
				if (GUILayout.Button("Читы", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
				{
					currentTab = 2;
				}
				GUILayout.EndHorizontal();
				GUILayout.Space(10f);
				switch (currentTab)
				{
				case 0:
					DrawItemTab();
					break;
				case 1:
					DrawPlayerTab();
					break;
				case 2:
					DrawCheatTab();
					break;
				}
				GUILayout.EndArea();
			}
		}

		private void DrawItemTab()
		{
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Поиск:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
			searchText = GUILayout.TextField(searchText, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Кол-во:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
			itemAmount = GUILayout.TextField(itemAmount, 4, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) });
			GUILayout.EndHorizontal();
			GUILayout.Space(5f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("1", Array.Empty<GUILayoutOption>()))
			{
				itemAmount = "1";
			}
			if (GUILayout.Button("5", Array.Empty<GUILayoutOption>()))
			{
				itemAmount = "5";
			}
			if (GUILayout.Button("10", Array.Empty<GUILayoutOption>()))
			{
				itemAmount = "10";
			}
			if (GUILayout.Button("64", Array.Empty<GUILayoutOption>()))
			{
				itemAmount = "64";
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(10f);
			if (GUILayout.Button("Получить все предметы", Array.Empty<GUILayoutOption>()))
			{
				GetAllItems();
			}
			scrollPos = GUILayout.BeginScrollView(scrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(350f) });
			if ((Object)(object)ItemManager.Instance != (Object)null && ItemManager.Instance.allItems != null)
			{
				int.TryParse(itemAmount, out var result);
				if (result < 1)
				{
					result = 1;
				}
				if (result > 999)
				{
					result = 999;
				}
				IOrderedEnumerable<InventoryItem> orderedEnumerable = from item in ItemManager.Instance.allItems.Values
					where string.IsNullOrEmpty(searchText) || item.name.ToLower().Contains(searchText.ToLower())
					orderby item.name
					select item;
				foreach (InventoryItem item in orderedEnumerable)
				{
					if (GUILayout.Button(item.name ?? "", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(25f) }))
					{
						AddItemToInventory(item, result);
					}
				}
			}
			else
			{
				GUILayout.Label("Загрузка предметов...", Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndScrollView();
		}

		private void DrawPlayerTab()
		{
			if ((Object)(object)PlayerStatus.Instance == (Object)null)
			{
				GUILayout.Label("Зайдите в мир для управления статами.", Array.Empty<GUILayoutOption>());
				return;
			}
			PlayerStatus instance = PlayerStatus.Instance;
			GUILayout.Label($"Здоровье: {Mathf.Round(instance.hp)} / {instance.maxHp}", Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Полное исцеление", Array.Empty<GUILayoutOption>()))
			{
				instance.Heal(9999);
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(10f);
			GUILayout.Label($"Выносливость: {Mathf.Round(instance.stamina)} / {instance.maxStamina}", Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Восстановить выносливость", Array.Empty<GUILayoutOption>()))
			{
				instance.stamina = instance.maxStamina;
			}
			GUILayout.Space(20f);
			GUILayout.Label("ОПАСНО", GUI.skin.box, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Суицид (2 клика)", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				instance.Damage(-11, 0, false);
			}
		}

		private void DrawCheatTab()
		{
			GUILayout.Label("Режимы", GUI.skin.box, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			godMode = GUILayout.Toggle(godMode, " Режим бога (бессмертие)", Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			infiniteStamina = GUILayout.Toggle(infiniteStamina, " Бесконечная выносливость", Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.Space(20f);
			GUILayout.Label("Ресурсы", GUI.skin.box, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("1 стак монет (99999)", Array.Empty<GUILayoutOption>()))
			{
				AddCoinStacks(1);
			}
			if (GUILayout.Button("5 стаков монет", Array.Empty<GUILayoutOption>()))
			{
				AddCoinStacks(5);
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("10 стаков монет", Array.Empty<GUILayoutOption>()))
			{
				AddCoinStacks(10);
			}
			if (GUILayout.Button("64 стака монет", Array.Empty<GUILayoutOption>()))
			{
				AddCoinStacks(64);
			}
			GUILayout.EndHorizontal();
		}

		private void AddItemToInventory(InventoryItem item, int amount)
		{
			try
			{
				InventoryUI instance = InventoryUI.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"InventoryUI.Instance is null!");
					return;
				}
				for (int i = 0; i < amount; i++)
				{
					instance.AddItemToInventory(item);
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Added {amount}x {item.name}");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Error adding item: " + ex.Message));
			}
		}

		private void AddCoinStacks(int numberOfStacks)
		{
			try
			{
				if ((Object)(object)ItemManager.Instance == (Object)null)
				{
					return;
				}
				InventoryItem val = FindCoinItem();
				if ((Object)(object)val == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"Coin item not found!");
					return;
				}
				InventoryUI instance = InventoryUI.Instance;
				if (!((Object)(object)instance == (Object)null))
				{
					for (int i = 0; i < numberOfStacks; i++)
					{
						instance.AddItemToInventory(val);
					}
					int num = numberOfStacks * 999;
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Added {numberOfStacks} stacks of coins ({num} coins)");
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Error adding coins: " + ex.Message));
			}
		}

		private InventoryItem FindCoinItem()
		{
			if ((Object)(object)ItemManager.Instance == (Object)null)
			{
				return null;
			}
			string[] array = new string[6] { "Coin", "coin", "Gold", "gold", "Gold Coin", "gold coin" };
			string[] array2 = array;
			foreach (string text in array2)
			{
				InventoryItem itemByName = ItemManager.Instance.GetItemByName(text);
				if ((Object)(object)itemByName != (Object)null)
				{
					return itemByName;
				}
			}
			foreach (InventoryItem value in ItemManager.Instance.allItems.Values)
			{
				if (value.name.ToLower().Contains("coin") || value.name.ToLower().Contains("gold"))
				{
					return value;
				}
			}
			return null;
		}

		private void GetAllItems()
		{
			try
			{
				if ((Object)(object)ItemManager.Instance == (Object)null || ItemManager.Instance.allItems == null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"ItemManager not found!");
					return;
				}
				InventoryUI instance = InventoryUI.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"InventoryUI.Instance is null!");
					return;
				}
				int num = 0;
				foreach (InventoryItem value in ItemManager.Instance.allItems.Values)
				{
					instance.AddItemToInventory(value);
					num++;
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Added {num} unique items");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Error getting all items: " + ex.Message));
			}
		}
	}
}