Decompiled source of Dupe Mod v1.0.0

ScheduleIMods3.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.PlayerScripts;
using JoiveDupeMod;
using MelonLoader;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(DupePlugin), "Dupe Mod", "1.0.0", "Joive", null)]
[assembly: MelonGame(null, null)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("ScheduleIMods3")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ScheduleIMods3")]
[assembly: AssemblyTitle("ScheduleIMods3")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace JoiveDupeMod;

public class DupePlugin : MelonMod
{
	private KeyCode menuKey = (KeyCode)286;

	private KeyCode dupeKey = (KeyCode)108;

	private bool showMenu = false;

	private int rebindingState = 0;

	private Rect menuRect = new Rect(20f, 20f, 350f, 200f);

	public override void OnUpdate()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		if (rebindingState == 0)
		{
			if (Input.GetKeyDown(menuKey))
			{
				showMenu = !showMenu;
			}
			if (Input.GetKeyDown(dupeKey))
			{
				ExecuteDupe();
			}
		}
	}

	public override void OnGUI()
	{
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: 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_0027: Invalid comparison between Unknown and I4
		//IL_0126: 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)
		//IL_0040: 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_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		if (rebindingState != 0)
		{
			Event current = Event.current;
			if (current != null && current.isKey && (int)current.type == 4)
			{
				if (rebindingState == 1)
				{
					menuKey = current.keyCode;
				}
				if (rebindingState == 2)
				{
					dupeKey = current.keyCode;
				}
				rebindingState = 0;
			}
		}
		if (!showMenu)
		{
			return;
		}
		GUI.Box(menuRect, "Настройки Dupe Mod");
		GUILayout.BeginArea(new Rect(((Rect)(ref menuRect)).x + 15f, ((Rect)(ref menuRect)).y + 35f, ((Rect)(ref menuRect)).width - 30f, ((Rect)(ref menuRect)).height - 50f));
		if (rebindingState == 1)
		{
			GUILayout.Label("Нажмите любую новую клавишу для МЕНЮ...", (Il2CppReferenceArray<GUILayoutOption>)null);
		}
		else if (rebindingState == 2)
		{
			GUILayout.Label("Нажмите любую новую клавишу для ДЮПА...", (Il2CppReferenceArray<GUILayoutOption>)null);
		}
		else
		{
			GUILayout.Label($"Кнопка открытия настроек: {menuKey}", (Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("Изменить кнопку меню", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				rebindingState = 1;
			}
			GUILayout.Space(20f);
			GUILayout.Label($"Кнопка дюпа предмета (x2): {dupeKey}", (Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("Изменить кнопку дюпа", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				rebindingState = 2;
			}
		}
		GUILayout.EndArea();
	}

	private void ExecuteDupe()
	{
		PlayerInventory instance = PlayerSingleton<PlayerInventory>.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			MelonLogger.Warning("Инвентарь не найден! Вы в игре?");
			return;
		}
		ItemInstance equippedItem = instance.EquippedItem;
		if (equippedItem == null)
		{
			MelonLogger.Warning("В руках ничего нет! Возьмите предмет для дюпа.");
			return;
		}
		try
		{
			instance.AddItemToInventory(equippedItem);
			MelonLogger.Msg("Дюп сработал! Создана копия предмета.");
			instance.UpdateInventoryVariables();
			instance.RepositionUI();
		}
		catch (Exception ex)
		{
			MelonLogger.Error("Ошибка при дюпе: " + ex.Message);
		}
	}
}