Decompiled source of DevMenuTurbo ZH v0.0.2

DevMenuTurbo.dll

Decompiled 6 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Characters.Gear;
using Characters.Gear.Items;
using Characters.Player;
using GameResources;
using HarmonyLib;
using Level;
using Microsoft.CodeAnalysis;
using Services;
using Singletons;
using TMPro;
using UI.TestingTool;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Plugins.Singletons")]
[assembly: AssemblyCompany("DevMenuTurbo")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Access the Secret Developer \"Cheat Menu\", with improvements!")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("DevMenuTurbo")]
[assembly: AssemblyTitle("DevMenuTurbo")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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 DevMenu
{
	public class ButtonRightClickHandler : MonoBehaviour, IPointerClickHandler, IEventSystemHandler
	{
		public delegate void RightClickDelegate();

		public event RightClickDelegate OnRightClick;

		public void OnPointerClick(PointerEventData eventData)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)eventData.button == 1)
			{
				this.OnRightClick?.Invoke();
			}
		}
	}
	[HarmonyPatch]
	public class DevMenuTurboPatch
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static bool Prefix(ref Panel __instance, ref bool __result)
		{
			__result = true;
			return false;
		}

		[HarmonyPatch(typeof(Panel), "Awake")]
		[HarmonyPostfix]
		private static void TranslateToEnglish(ref Panel __instance)
		{
			SetText((Component)(object)__instance._openMapList, "地图");
			SetText((Component)(object)__instance._nextStage, "下一章节");
			SetText((Component)(object)__instance._nextMap, "下一地图");
			SetText((Component)(object)__instance._openGearList, "装备清单");
			SetText((Component)(object)__instance._hideUI, "隐藏UI");
			SetText((Component)(object)__instance._getGold, "+10000 金币");
			SetText((Component)(object)__instance._getDarkquartz, "+1000 魔石");
			SetText((Component)(object)__instance._getBone, "+100 碎骨");
			SetText((Component)(object)__instance._getHeartQuartz, "+100 魔石核心");
			SetText((Component)(object)__instance._testMap, "测试地图");
			SetText((Component)(object)__instance._awake, "升级头骨");
			SetText((Component)(object)__instance._damageBuff, "伤害Buff");
			SetText((Component)(object)__instance._hp10k, "+10000 HP");
			SetText((Component)(object)__instance._noCooldown, "无冷却");
			SetText((Component)(object)__instance._shield10, "+10 护盾");
			SetText((Component)(object)__instance._hardmodeToggle, "魔镜");
			SetText((Component)(object)__instance._rerollSkill, "重置技能");
			SetText((Component)(object)__instance._timeScaleReset, "重置");
			SetText((Component)(object)__instance._infiniteRevive, "不朽");
			SetText((Component)(object)__instance._verification, "血量显示");
			SetText((Component)(object)__instance._right3, "所有Buff ->");
			SetText2((Component)(object)__instance._hardmodeLevelSlider, "魔镜等级");
			SetText2((Component)(object)__instance._hardmodeClearedLevelSlider, "魔镜解锁");
			SetText2((Component)(object)__instance._timeScaleSlider, "加速");
			SetText((Component)(object)__instance._gearList.transform, "返回");
			((Component)__instance._localNow).gameObject.SetActive(false);
			((Component)__instance._utcNow).gameObject.SetActive(false);
		}

		private static void SetText(Component obj, string text)
		{
			TextMeshProUGUI componentInChildren = obj.GetComponentInChildren<TextMeshProUGUI>(true);
			if (componentInChildren != null)
			{
				((TMP_Text)componentInChildren).SetText(text, true);
			}
		}

		private static void SetText2(Component obj, string text)
		{
			TextMeshProUGUI[] componentsInChildren = obj.GetComponentsInChildren<TextMeshProUGUI>(true);
			if (componentsInChildren != null && componentsInChildren.Length > 1)
			{
				((TMP_Text)componentsInChildren[1]).SetText(text, true);
			}
		}

		[HarmonyPatch(typeof(GearListElement), "Set")]
		[HarmonyPostfix]
		private static void FillInventoryOnClick(ref GearListElement __instance, GearReference gearReference)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			if ((int)gearReference.type != 1)
			{
				return;
			}
			((Component)__instance).gameObject.AddComponent<ButtonRightClickHandler>().OnRightClick += delegate
			{
				//IL_0077: 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_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Expected O, but got Unknown
				GearRequest val = gearReference.LoadAsync();
				((Request<Gear>)(object)val).WaitForCompletion();
				LevelManager levelManager = Singleton<Service>.Instance.levelManager;
				ItemInventory item = levelManager.player.playerComponents.inventory.item;
				Item val2 = null;
				for (int i = 0; i < item.items.Count; i++)
				{
					if ((Object)(object)item.items[i] == (Object)null)
					{
						if ((Object)(object)val2 == (Object)null)
						{
							val2 = (Item)levelManager.DropGear(val, Vector3.zero);
							item.EquipAt(val2, i);
						}
						else
						{
							Item val3 = levelManager.DropItem(val2, Vector3.zero);
							item.EquipAt(val3, i);
						}
					}
				}
			};
		}

		[HarmonyPatch(typeof(GearList), "Awake")]
		[HarmonyPostfix]
		private static void FixDarkAbilitySearch(ref GearList __instance)
		{
			GearList self = __instance;
			foreach (Button upgradeListElement in self._upgradeListElements)
			{
				Text componentInChildren = ((Component)upgradeListElement).GetComponentInChildren<Text>();
				((Object)upgradeListElement).name = componentInChildren.text;
				componentInChildren.fontSize = 29;
			}
			((UnityEventBase)self._inputField.onValueChanged).RemoveAllListeners();
			((UnityEvent<string>)(object)self._inputField.onValueChanged).AddListener((UnityAction<string>)delegate
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Invalid comparison between Unknown and I4
				if ((int)self._currentFilter == 3)
				{
					self.FilterUpgrade();
				}
				else
				{
					self.FilterGearList((Type?)null);
				}
			});
		}
	}
	[BepInPlugin("DevMenuTurbo", "DevMenuTurbo", "0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			Harmony.CreateAndPatchAll(typeof(DevMenuTurboPatch), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Mod DevMenuTurbo is loaded!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "DevMenuTurbo";

		public const string PLUGIN_NAME = "DevMenuTurbo";

		public const string PLUGIN_VERSION = "0.0.1";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}