Decompiled source of EnableConsole v1.0.3

BepInEx/plugins/EnableConsole/EnableConsole.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[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("EnableConsole")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("EnableConsole")]
[assembly: AssemblyTitle("EnableConsole")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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 EnableConsole
{
	[BepInPlugin("com.fizzy.enableconsole", "EnableConsole", "1.0.1")]
	public class UltraNightmare : BaseUnityPlugin
	{
		private void Awake()
		{
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading [EnableConsole]");
		}
	}
	[HarmonyPatch]
	public class Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static void PostfixStart()
		{
			ScriptableObjMgr val = Object.FindObjectOfType<ScriptableObjMgr>();
			val.testCtrller.MasterSwitch = true;
			val.testCtrller.CommandLine = true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CommandLineMgr), "RunDebugCmd")]
		public static void PostfixRunDebug(CommandLineMgr __instance, string cmdString)
		{
			if (!EventSystem.current.alreadySelecting)
			{
				EventSystem.current.SetSelectedGameObject((GameObject)null);
			}
			FieldInfo fieldInfo = AccessTools.Field(typeof(UnitProperty), "invincibleCounter");
			((Selectable)__instance.debugCmdInputField).Select();
			if (cmdString == "" || cmdString == "`")
			{
				return;
			}
			string[] array = (from e in cmdString.Split(' ')
				select e.Trim() into e
				where e.Length > 0
				select e).ToArray();
			if (array.Length == 0)
			{
				return;
			}
			switch (array[0])
			{
			case "immune":
			{
				int num2 = (int)fieldInfo.GetValue(PlayerMgr.Inst.PlayerPpt);
				Debug.Log((object)("test1: " + num2));
				if (num2 == 0)
				{
					PlayerMgr.Inst.PlayerPpt.InvincibleRegister();
					__instance.PrintLog("Invincibility enabled");
				}
				else
				{
					PlayerMgr.Inst.PlayerPpt.InvincibleUnregister();
					__instance.PrintLog("Invincibility disabled");
				}
				Debug.Log((object)("test1: " + num2));
				break;
			}
			case "hp":
				if (array.Length == 1)
				{
					float maxHP = PlayerMgr.Inst.PlayerCfg.maxHP;
					PlayerMgr.Inst.ChangeHPMax(120f - PlayerMgr.Inst.PlayerCfg.maxHP, (TextFloatQueueType)2);
					__instance.PrintLog("Max hp changed to the default 120");
				}
				else if (array.Length == 2)
				{
					int num = int.Parse(array[1]);
					PlayerMgr.Inst.ChangeHPMax((float)num - PlayerMgr.Inst.PlayerCfg.maxHP, (TextFloatQueueType)2);
					__instance.PrintLog("Max hp changed to your number");
				}
				else
				{
					__instance.PrintLog("Too many parameters");
				}
				break;
			case "heal":
				PlayerMgr.Inst.PlayerPpt.HPRecovery(PlayerMgr.Inst.PlayerCfg.maxHP, false);
				break;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CommandLineMgr), "Initialize")]
		public static bool PostfixInitialize(CommandLineMgr __instance)
		{
			PropertyInfo propertyInfo = AccessTools.Property(typeof(CommandLineMgr), "Inst");
			propertyInfo.SetValue(null, __instance);
			FieldInfo fieldInfo = AccessTools.Field(typeof(CommandLineMgr), "cmdList");
			FieldInfo fieldInfo2 = AccessTools.Field(typeof(CommandLineMgr), "autoCommandIsRun");
			Dictionary<string, string> dictionary = (Dictionary<string, string>)fieldInfo.GetValue(__instance);
			dictionary.Clear();
			fieldInfo2.SetValue(__instance, false);
			dictionary.Add("help", "List all commands");
			dictionary.Add("heal", "Heal to full hp");
			dictionary.Add("immune", "Enables or disables player invincibility");
			dictionary.Add("hp", "Set the player max hp, default 120");
			dictionary.Add("coin", "Get specified coins, default 1");
			dictionary.Add("key", "Get specified keys, default 1");
			dictionary.Add("crystal", "Get specified crystals, default 1");
			dictionary.Add("blood", "Get specified Ancient Blood, default 1");
			dictionary.Add("core", "Get specified Chaos Cores, default 1");
			dictionary.Add("allres", "Get specified amount of all resources, default 1");
			dictionary.Add("wand", "Get wand by ID, or random if no ID");
			dictionary.Add("allwand", "Get all wands");
			dictionary.Add("wandstage", "Get all wands of a stage, default stage 1");
			dictionary.Add("spell", "Get spell by ID, or random if no ID");
			dictionary.Add("allspell", "Get all spells of a level, default level 1");
			dictionary.Add("relic", "Get relic by ID");
			dictionary.Add("removerelic", "Downgrade relic by ID until removed");
			dictionary.Add("allrelic", "Get all relics");
			dictionary.Add("potion", "Get potion by ID");
			dictionary.Add("allpotion", "Get all potions");
			dictionary.Add("curse", "Get curse by ID");
			dictionary.Add("unit", "Create unit by ID");
			dictionary.Add("listwand", "List all wands");
			dictionary.Add("listspell", "List all spells");
			dictionary.Add("listpotion", "List all potions");
			dictionary.Add("listrelic", "List all relics");
			dictionary.Add("listcurse", "List all curses");
			dictionary.Add("listunit", "List all units");
			dictionary.Add("removecurse", "Remove all curses");
			dictionary.Add("clear", "Clear all objects, includes spells");
			dictionary.Add("god", "Full health, no mana/health loss");
			dictionary.Add("fps", "Set max frame rate");
			dictionary.Add("room", "Load specified room");
			dictionary.Add("listroom", "List all room names and IDs");
			dictionary.Add("stage", "Jump to specified stage room");
			dictionary.Add("gallery", "Unlock/restore all gallery items");
			dictionary.Add("finishnothing", "Complete no difficulty");
			dictionary.Add("finisheasy", "Complete easy difficulty");
			dictionary.Add("finishnormal", "Complete normal difficulty");
			dictionary.Add("finishnormal2", "Complete normal difficulty 2");
			dictionary.Add("finishnormal3", "Complete normal difficulty 3");
			dictionary.Add("finishnormal4", "Fully complete normal difficulty 4");
			dictionary.Add("finishhard", "Complete hard difficulty");
			dictionary.Add("finishnightmare1", "Complete nightmare difficulty 1");
			dictionary.Add("finishnightmare2", "Complete nightmare difficulty 2");
			dictionary.Add("finishnightmare3", "Complete nightmare difficulty 3");
			dictionary.Add("allnpc", "Unlock/restore all NPCs");
			dictionary.Add("npc3", "Rescue/restore NPC3");
			dictionary.Add("npc4", "Rescue/restore NPC4");
			dictionary.Add("npc5", "Rescue/restore NPC5");
			dictionary.Add("npc6", "Rescue/restore NPC6");
			dictionary.Add("clearrank", "Clear account's ranking records");
			dictionary.Add("loop", "Repeat command, e.g., loop 10 unit 101721");
			dictionary.Add("findset", "Unlock specified set ID, default all sets");
			dictionary.Add("autorun", "Execute auto-run commands");
			dictionary.Add("clearpool", "same as clear");
			dictionary.Add("enterbattletime", "Set battlefield entry count");
			dictionary.Add("easy", "Set difficulty to easy");
			dictionary.Add("normal", "Set difficulty to normal");
			dictionary.Add("hard", "Set difficulty to hard");
			dictionary.Add("nightmare1", "Set difficulty to nightmare1");
			dictionary.Add("nightmare2", "Set difficulty to nightmare2");
			dictionary.Add("nightmare3", "Set difficulty to nightmare3");
			dictionary.Add("blive", "Connect/disconnect live stream room");
			dictionary.Add("danmaku", "Simulate live stream comment");
			dictionary.Add("like", "Simulate streamer like");
			dictionary.Add("gift", "Simulate gift to streamer");
			dictionary.Add("gremovewand + id", "Remove wand from gallery by ID");
			dictionary.Add("gremovespell + id", "Remove spell from gallery by ID");
			dictionary.Add("gremoverelic + id", "Remove relic from gallery by ID");
			dictionary.Add("gremovepotion + id", "Remove potion from gallery by ID");
			dictionary.Add("gremovecurse + id", "Remove curse from gallery by ID");
			return false;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "EnableConsole";

		public const string PLUGIN_NAME = "EnableConsole";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}