Decompiled source of MoreCommands v0.8.1

MoreCommands.dll

Decompiled 2 weeks 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 BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreCommands.Accessors;
using MoreCommands.Commands;
using MoreCommands.Common;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("MoreCommands")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Useful console commands for White Knuckle.")]
[assembly: AssemblyFileVersion("0.8.1.0")]
[assembly: AssemblyInformationalVersion("0.8.1+07b0dd14fbb4e8c11300f546f79718445f26eaa8")]
[assembly: AssemblyProduct("MoreCommands")]
[assembly: AssemblyTitle("MoreCommands")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.8.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;
		}
	}
}
public static class ArgParse
{
	public static int GetMult(string[] args, int fallback = 1)
	{
		if (args.Length != 0)
		{
			int.TryParse(args[0], out fallback);
		}
		return fallback;
	}

	public static bool ParseEnabled(bool enabled, string[] args)
	{
		if (args.Length == 0 || !bool.TryParse(args[0], out var result))
		{
			return !enabled;
		}
		return result;
	}
}
namespace MoreCommands
{
	[BepInPlugin("shishyando.WK.MoreCommands", "MoreCommands", "0.8.1")]
	public class MoreCommandsPlugin : BaseUnityPlugin
	{
		public static ManualLogSource Beep;

		private readonly Harmony Harmony = new Harmony("shishyando.WK.MoreCommands");

		private void Awake()
		{
			Beep = ((BaseUnityPlugin)this).Logger;
			CommandRegistry.InitializeCommands();
			Harmony.PatchAll();
			Beep.LogInfo((object)"shishyando.WK.MoreCommands is loaded");
			SceneManager.sceneUnloaded += OnSceneUnloaded;
		}

		public static void OnSceneUnloaded(Scene s)
		{
			if (((Scene)(ref s)).name == "Game-Main")
			{
				CommandRegistry.DisableAllTogglableCommands();
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "shishyando.WK.MoreCommands";

		public const string PLUGIN_NAME = "MoreCommands";

		public const string PLUGIN_VERSION = "0.8.1";
	}
}
namespace MoreCommands.Patches
{
	[HarmonyPatch(typeof(CommandConsole), "Awake")]
	public static class CommandConsole_Patcher
	{
		[HarmonyPostfix]
		public static void AddMorePlayerCommands(CommandConsole __instance)
		{
			foreach (ICommand item in CommandRegistry.GetCommandsByTag(CommandTag.Console))
			{
				string[] aliases = item.Aliases;
				foreach (string text in aliases)
				{
					CommandConsole.AddCommand(text, item.GetCallback(), false);
				}
			}
			foreach (ICommand item2 in CommandRegistry.GetCommandsByTag(CommandTag.World))
			{
				string[] aliases2 = item2.Aliases;
				foreach (string text2 in aliases2)
				{
					CommandConsole.AddCommand(text2, item2.GetCallback(), false);
				}
			}
		}
	}
	[HarmonyPatch(typeof(ENT_Player), "CreateCommands")]
	public static class ENT_Player_Patcher
	{
		[HarmonyPostfix]
		public static void AddMorePlayerCommands(ENT_Player __instance)
		{
			foreach (ICommand item in CommandRegistry.GetCommandsByTag(CommandTag.Player))
			{
				string[] aliases = item.Aliases;
				foreach (string text in aliases)
				{
					CommandConsole.AddCommand(text, item.GetCallback(), false);
				}
			}
		}
	}
}
namespace MoreCommands.Common
{
	public interface ICommand
	{
		string[] Aliases { get; }

		CommandTag Tag { get; }

		string Description { get; }

		bool CheatsOnly { get; }

		Action<string[]> GetCallback();
	}
	public interface ITogglableCommand : ICommand
	{
		bool Enabled { get; set; }

		void UpdateEnabled(string[] args);
	}
	public abstract class CommandBase : ICommand
	{
		public abstract string[] Aliases { get; }

		public abstract CommandTag Tag { get; }

		public abstract string Description { get; }

		public abstract bool CheatsOnly { get; }

		protected abstract Action<string[]> GetLogicCallback();

		public void EnsureCheats(string[] args)
		{
			if (CheatsOnly)
			{
				CommandConsoleAccessor.EnsureCheatsAreEnabled();
			}
		}

		public void PrintSuffix(string[] args)
		{
			CommandConsoleAccessor.EchoToConsole("<color=grey>---------------------</color>");
		}

		public virtual Action<string[]> GetCallback()
		{
			return (Action<string[]>)Delegate.Combine((Action<string[]>)Delegate.Combine(new Action<string[]>(EnsureCheats), GetLogicCallback()), new Action<string[]>(PrintSuffix));
		}
	}
	public abstract class TogglableCommandBase : CommandBase, ITogglableCommand, ICommand
	{
		public bool Enabled { get; set; }

		public void UpdateEnabled(string[] args)
		{
			Enabled = ArgParse.ParseEnabled(Enabled, args);
		}

		public sealed override Action<string[]> GetCallback()
		{
			return (Action<string[]>)Delegate.Combine((Action<string[]>)Delegate.Combine(new Action<string[]>(UpdateEnabled), new Action<string[]>(base.EnsureCheats)), GetLogicCallback());
		}

		public static string[] WhenEnabled(bool enabled)
		{
			return new string[1] { enabled.ToString().ToLower() };
		}

		public static string[] WhenDisabled(bool enabled)
		{
			return new string[1] { (!enabled).ToString().ToLower() };
		}
	}
	public enum CommandTag
	{
		Player,
		World,
		Console
	}
	public static class ItemGod
	{
		public static List<Item> GetAllItems()
		{
			List<GameObject> itemPrefabs = CL_AssetManager.GetFullCombinedAssetDatabase().itemPrefabs;
			List<Item> list = new List<Item>();
			foreach (GameObject item in itemPrefabs)
			{
				Item_Object component = item.GetComponent<Item_Object>();
				if ((Object)(object)component != (Object)null)
				{
					list.Add(component.itemData);
				}
			}
			return list;
		}

		public static Item GetItemByPrefabName(string prefabName)
		{
			return GetAllItems().Find((Item x) => x.prefabName.ToLower() == prefabName);
		}

		public static Item FindAndClone(string prefabSubstr)
		{
			Item val = GetAllItems().Find((Item x) => x.prefabName.ToLower().Contains(prefabSubstr));
			if (val == null)
			{
				return null;
			}
			return val.GetClone();
		}

		public static List<string> PrefabNames()
		{
			List<Item> allItems = GetAllItems();
			return allItems.Select((Item x) => x.prefabName.ToLower()).ToList();
		}

		public static string PrefabNames(string delimiter)
		{
			return string.Join(delimiter, PrefabNames());
		}
	}
	public static class PerkChanger
	{
		public static void MaxOutPerk(string perkId)
		{
			ENT_Player playerObject = ENT_Player.playerObject;
			if ((Object)(object)playerObject == (Object)null)
			{
				return;
			}
			Perk perk = playerObject.GetPerk(perkId);
			if ((Object)(object)perk != (Object)null)
			{
				int num = perk.stackMax - perk.stackAmount;
				if (num > 0)
				{
					perk.AddStack(num);
				}
				return;
			}
			Perk perkAsset = CL_AssetManager.GetPerkAsset(perkId, "");
			if ((Object)(object)perkAsset != (Object)null)
			{
				Perk val = Object.Instantiate<Perk>(perkAsset);
				int stackMax = val.stackMax;
				if (stackMax > 0)
				{
					playerObject.AddPerk(val, stackMax);
				}
			}
			else
			{
				MoreCommandsPlugin.Beep.LogWarning((object)("Perk " + perkId + " not found!"));
			}
		}
	}
	public static class CommandRegistry
	{
		public static List<ICommand> RegisteredCommands = new List<ICommand>();

		public static bool Initialized = false;

		private static void RegisterAll()
		{
			Register(new BanhammerCommand());
			Register(new BetterListPerksCommand());
			Register(new BuffCommand());
			Register(new CargoCommand());
			Register(new ExploreCommand());
			Register(new FlashCommand());
			Register(new FreerunCommand());
			Register(new GiveCommand());
			Register(new GiveLeftCommand());
			Register(new GiveRightCommand());
			Register(new GravityCommand());
			Register(new GrubbyCommand());
			Register(new ManCommand());
			Register(new SpeedyCommand());
			Register(new TeleportCommand());
		}

		public static void InitializeCommands()
		{
			if (!Initialized)
			{
				RegisterAll();
				Initialized = true;
			}
		}

		public static void Register(ICommand command)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			string[] aliases = command.Aliases;
			foreach (string alias in aliases)
			{
				ICommand command2 = RegisteredCommands.Find((ICommand c) => c.Aliases.Contains(alias));
				if (command2 != null)
				{
					dictionary.Add(alias, command2.GetType().ToString());
				}
			}
			if (dictionary.Count > 0)
			{
				MoreCommandsPlugin.Beep.LogWarning((object)string.Format("Failed to register command {0}:\n{1}", command.GetType(), GeneralExtensions.Join<KeyValuePair<string, string>>((IEnumerable<KeyValuePair<string, string>>)dictionary, (Func<KeyValuePair<string, string>, string>)((KeyValuePair<string, string> x) => "\t" + x.Key + " taken by " + x.Value), "\n")));
			}
			else
			{
				RegisteredCommands.Add(command);
			}
		}

		public static List<ICommand> GetAllCommands()
		{
			return RegisteredCommands.OrderBy((ICommand c) => c.Aliases[0]).ToList();
		}

		public static List<ICommand> GetCommandsByTag(CommandTag tag)
		{
			return RegisteredCommands.Where((ICommand c) => c.Tag == tag).ToList();
		}

		public static ICommand GetCommand<T>() where T : ICommand
		{
			return RegisteredCommands.FirstOrDefault((ICommand c) => c.GetType() == typeof(T));
		}

		public static Action<string[]> GetCallback<T>() where T : ICommand
		{
			return RegisteredCommands.FirstOrDefault((ICommand c) => c.GetType() == typeof(T))?.GetCallback() ?? ((Action<string[]>)delegate
			{
				MoreCommandsPlugin.Beep.LogWarning((object)$"Command {typeof(T)} not found");
			});
		}

		public static void DisableAllTogglableCommands()
		{
			foreach (ICommand registeredCommand in RegisteredCommands)
			{
				if (registeredCommand is ITogglableCommand togglableCommand)
				{
					togglableCommand.Enabled = false;
				}
			}
		}
	}
}
namespace MoreCommands.Commands
{
	public sealed class BanhammerCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "banhammer" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "give banhammer to player";

		public override bool CheatsOnly => true;

		protected override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				Inventory.instance.AddItemToHand(ItemGod.GetItemByPrefabName("item_banhammer").GetClone(), 0);
			};
		}
	}
	public sealed class BetterListPerksCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "lp" };

		public override CommandTag Tag => CommandTag.Console;

		public override string Description => "List perks info, filtered by `arg`";

		public override bool CheatsOnly => false;

		protected override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				foreach (Perk perkAsset in CL_AssetManager.GetFullCombinedAssetDatabase().perkAssets)
				{
					if (args.Length == 0 || Has(((Object)perkAsset).name, args[0]) || Has(perkAsset.description, args[0]) || Has(perkAsset.id, args[0]))
					{
						CommandConsoleAccessor.EchoToConsole("- " + perkAsset.GetTitle(false) + " (<color=grey>" + perkAsset.id + "</color>)\n" + perkAsset.GetDescription(false, false, false) + "</color></color></color>\n");
					}
				}
			};
		}

		private bool Has(string text, string check)
		{
			return text != null && text.IndexOf(check, StringComparison.OrdinalIgnoreCase) >= 0;
		}
	}
	public sealed class BuffCommand : TogglableCommandBase
	{
		private readonly string BuffId = "shishyando.WK.MoreCommands.buffCommand";

		public override string[] Aliases => new string[1] { "buff" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "buff everything, but without perks";

		public override bool CheatsOnly => true;

		protected override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: 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_006a: Expected O, but got Unknown
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Expected O, but got Unknown
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: Expected O, but got Unknown
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f1: Expected O, but got Unknown
				//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Unknown result type (might be due to invalid IL or missing references)
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_011e: Expected O, but got Unknown
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_0125: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_013b: Unknown result type (might be due to invalid IL or missing references)
				//IL_014b: Expected O, but got Unknown
				//IL_014d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0152: Unknown result type (might be due to invalid IL or missing references)
				//IL_015d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Expected O, but got Unknown
				//IL_017a: Unknown result type (might be due to invalid IL or missing references)
				//IL_017f: Unknown result type (might be due to invalid IL or missing references)
				//IL_018a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0195: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a5: Expected O, but got Unknown
				//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d2: Expected O, but got Unknown
				//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ff: Expected O, but got Unknown
				//IL_0201: Unknown result type (might be due to invalid IL or missing references)
				//IL_0206: Unknown result type (might be due to invalid IL or missing references)
				//IL_0211: Unknown result type (might be due to invalid IL or missing references)
				//IL_021c: Unknown result type (might be due to invalid IL or missing references)
				//IL_022c: Expected O, but got Unknown
				//IL_0232: Unknown result type (might be due to invalid IL or missing references)
				//IL_0239: Unknown result type (might be due to invalid IL or missing references)
				//IL_0245: Expected O, but got Unknown
				ENT_Player playerObject = ENT_Player.playerObject;
				if (!((Object)(object)playerObject == (Object)null))
				{
					if (base.Enabled)
					{
						BuffContainer val = new BuffContainer
						{
							id = BuffId,
							buffs = new List<Buff>(11)
							{
								new Buff
								{
									id = "addReach",
									amount = 1.25f,
									maxAmount = 1.25f
								},
								new Buff
								{
									id = "buffTimeMult",
									amount = 3f,
									maxAmount = 3f
								},
								new Buff
								{
									id = "addExtraJumps",
									amount = 100f,
									maxAmount = 100f
								},
								new Buff
								{
									id = "addJumpBoost",
									amount = 0.6f,
									maxAmount = 0.6f
								},
								new Buff
								{
									id = "grabAnything",
									amount = 1E+09f,
									maxAmount = 1E+09f
								},
								new Buff
								{
									id = "addSpeed",
									amount = 3.5f,
									maxAmount = 3.5f
								},
								new Buff
								{
									id = "addClimb",
									amount = 3.5f,
									maxAmount = 3.5f
								},
								new Buff
								{
									id = "addJump",
									amount = 1.5f,
									maxAmount = 1.5f
								},
								new Buff
								{
									id = "addStrike",
									amount = 100f,
									maxAmount = 100f
								},
								new Buff
								{
									id = "addHammer",
									amount = 100f,
									maxAmount = 100f
								},
								new Buff
								{
									id = "addCapacity",
									amount = 1000f,
									maxAmount = 1000f
								}
							},
							loseOverTime = false,
							multiplier = 1f
						};
						playerObject.Buff(val);
					}
					else
					{
						playerObject.curBuffs.RemoveBuffContainer(BuffId);
					}
				}
			};
		}
	}
	public sealed class CargoCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "cargo" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "max backstrength";

		public override bool CheatsOnly => true;

		protected override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				PerkChanger.MaxOutPerk("Perk_BackStrengtheners");
			};
		}
	}
	public sealed class ExploreCommand : TogglableCommandBase
	{
		public override string[] Aliases => new string[1] { "explore" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "freerun + noclip";

		public override bool CheatsOnly => true;

		protected override Action<string[]> GetLogicCallback()
		{
			return (Action<string[]>)Delegate.Combine(CommandRegistry.GetCallback<FreerunCommand>(), (Action<string[]>)delegate
			{
				ENT_Player playerObject = ENT_Player.playerObject;
				if (playerObject != null)
				{
					playerObject.Noclip(TogglableCommandBase.WhenEnabled(base.Enabled));
				}
			});
		}
	}
	public sealed class FlashCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "flash" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "freerun + buff";

		public override bool CheatsOnly => true;

		protected override Action<string[]> GetLogicCallback()
		{
			return (Action<string[]>)Delegate.Combine(CommandRegistry.GetCallback<FreerunCommand>(), CommandRegistry.GetCallback<BuffCommand>());
		}
	}
	public sealed class FreerunCommand : TogglableCommandBase
	{
		public override string[] Aliases => new string[1] { "freerun" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "godmode + deathgoo-stop + fullbright + infinitestamina + notarget";

		public override bool CheatsOnly => true;

		protected override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				ENT_Player playerObject = ENT_Player.playerObject;
				if (playerObject != null)
				{
					playerObject.SetGodMode(base.Enabled);
				}
				if (playerObject != null)
				{
					playerObject.InfiniteStaminaCommand(TogglableCommandBase.WhenEnabled(base.Enabled));
				}
				FXManager.Fullbright(TogglableCommandBase.WhenEnabled(base.Enabled));
				DEN_DeathFloor instance = DEN_DeathFloor.instance;
				if (instance != null)
				{
					instance.DeathGooToggle(TogglableCommandBase.WhenDisabled(base.Enabled));
				}
				CL_GameManager gMan = CL_GameManager.gMan;
				if (gMan != null)
				{
					gMan.NoTarget(TogglableCommandBase.WhenEnabled(base.Enabled));
				}
			};
		}
	}
	public sealed class GiveCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "give" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "give item to player";

		public override bool CheatsOnly => true;

		protected override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				if (args.Length == 0)
				{
					CommandConsoleAccessor.EchoToConsole("Available items:\n" + ItemGod.PrefabNames("\n"));
				}
				else
				{
					Item val = ItemGod.FindAndClone(args[0]);
					if (val == null)
					{
						CommandConsoleAccessor.EchoToConsole("No such item: " + args[0]);
					}
					else
					{
						Inventory.instance.AddItemToInventoryScreen(new Vector3(0f, 0f, 1f) + Random.insideUnitSphere * 0.01f, val, true, false);
					}
				}
			};
		}
	}
	public sealed class GiveLeftCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "left" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "give item to left hand or inventory";

		public override bool CheatsOnly => true;

		protected override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				if (args.Length == 0)
				{
					CommandConsoleAccessor.EchoToConsole("Available items:\n" + ItemGod.PrefabNames("\n"));
				}
				else
				{
					Item val = ItemGod.FindAndClone(args[0]);
					if (val == null)
					{
						CommandConsoleAccessor.EchoToConsole("No such item: " + args[0]);
					}
					else
					{
						Item clone = val.GetClone();
						clone.bagRotation = new Quaternion(1f, 2f, 3f, 4f);
						Inventory.instance.AddItemToHand(clone, 0);
					}
				}
			};
		}
	}
	public sealed class GiveRightCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "right" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "give item to right hand or inventory";

		public override bool CheatsOnly => true;

		protected override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				if (args.Length == 0)
				{
					CommandConsoleAccessor.EchoToConsole("Available items:\n" + ItemGod.PrefabNames("\n"));
				}
				else
				{
					Item val = ItemGod.FindAndClone(args[0]);
					if (val == null)
					{
						CommandConsoleAccessor.EchoToConsole("No such item: " + args[0]);
					}
					else
					{
						Item clone = val.GetClone();
						clone.bagRotation = new Quaternion(1f, 2f, 3f, 4f);
						Inventory.instance.AddItemToHand(clone, 1);
					}
				}
			};
		}
	}
	public sealed class GravityCommand : CommandBase
	{
		public override string[] Aliases => new string[2] { "sv_gravity", "grav" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "set player gravity multiplier (1 is default)";

		public override bool CheatsOnly => true;

		protected override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				ENT_Player playerObject = ENT_Player.playerObject;
				float result;
				if (args.Length == 0)
				{
					playerObject.SetGravityMult(1f);
				}
				else if (float.TryParse(args[0], out result))
				{
					playerObject.SetGravityMult(result);
				}
				else
				{
					CommandConsoleAccessor.EchoToConsole("Invalid arguments for gravity command: " + GeneralExtensions.Join<string>((IEnumerable<string>)args, (Func<string, string>)null, " "));
				}
			};
		}
	}
	public sealed class GrubbyCommand : TogglableCommandBase
	{
		private readonly string BuffId = "shishyando.WK.MoreCommands.grubbyCommand";

		public override string[] Aliases => new string[1] { "grubby" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "grab anything";

		public override bool CheatsOnly => true;

		protected override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Expected O, but got Unknown
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Expected O, but got Unknown
				ENT_Player playerObject = ENT_Player.playerObject;
				if (!((Object)(object)playerObject == (Object)null))
				{
					if (base.Enabled)
					{
						BuffContainer val = new BuffContainer
						{
							id = BuffId,
							buffs = new List<Buff>(1)
							{
								new Buff
								{
									id = "grabAnything",
									amount = 1E+09f,
									maxAmount = 1E+09f
								}
							},
							loseOverTime = false
						};
						playerObject.Buff(val);
					}
					else
					{
						playerObject.curBuffs.RemoveBuffContainer(BuffId);
					}
				}
			};
		}
	}
	public sealed class ManCommand : CommandBase
	{
		private const string CHEAT_SIGN = "<color=orange>+</color>";

		public override string[] Aliases => new string[3] { "man", "mhelp", "morecommandshelp" };

		public override CommandTag Tag => CommandTag.Console;

		public override string Description => "prints MoreCommands with their descriptions ('+' = enables cheats)";

		public override bool CheatsOnly => false;

		protected override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				foreach (ICommand allCommand in CommandRegistry.GetAllCommands())
				{
					if (args.Length == 0 || allCommand.Aliases.Contains(args[0]))
					{
						CommandConsoleAccessor.EchoToConsole(Colored((allCommand.CheatsOnly ? "<color=orange>+</color>" : "-") + " " + GeneralExtensions.Join<string>((IEnumerable<string>)allCommand.Aliases, (Func<string, string>)null, ", ") + ":\n" + allCommand.Description, ColorByTag(allCommand.Tag)));
					}
				}
			};
		}

		private static string Colored(string m, string color)
		{
			return "<color=" + color + ">" + m + "</color>";
		}

		private static string ColorByTag(CommandTag tag)
		{
			if (1 == 0)
			{
			}
			string result = tag switch
			{
				CommandTag.Player => "#dafeffff", 
				CommandTag.World => "#cfffe9ff", 
				CommandTag.Console => "#f4e2ffff", 
				_ => "white", 
			};
			if (1 == 0)
			{
			}
			return result;
		}
	}
	public sealed class SpeedyCommand : CommandBase
	{
		private static List<string> MovementPerks = new List<string>(17)
		{
			"Perk_ArmoredPlating", "Perk_ElasticLimbs", "Perk_MetabolicStasis", "Perk_PulseOrgan", "Perk_RabbitDNA", "Perk_SomaticPainkillers", "Perk_SystemReorganization", "Perk_AutotomousSkeleton", "Perk_AdrenalinePumps", "Perk_HeavyStrike",
			"Perk_VelocityAugments", "Perk_LatissimusOptimization", "Perk_SteadiedStance", "Perk_Rho_Blessing_Protection", "Perk_Rho_Blessing_Regeneration", "Perk_Rho_Blessing_Swift", "Perk_Rho_Blessing_Overwhelm"
		};

		public override string[] Aliases => new string[1] { "speedy" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "get some movement perks";

		public override bool CheatsOnly => true;

		protected override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				foreach (string movementPerk in MovementPerks)
				{
					PerkChanger.MaxOutPerk(movementPerk);
				}
			};
		}
	}
	public sealed class TeleportCommand : CommandBase
	{
		private static readonly Dictionary<string, string> Locations = new Dictionary<string, string>
		{
			{ "intro", "m1_intro_01" },
			{ "exp", "m1_silos_safearea_01" },
			{ "prepipes", "campaign_interlude_silo_to_pipeworks" },
			{ "elevator", "campaign_interlude_pipeworks_to_habitation_01" },
			{ "teeth", "m3_habitation_shaft_intro" },
			{ "pier", "m3_habitation_pier_entrance_01" },
			{ "abyss", "m3_habitation_lab_ending" }
		};

		public override string[] Aliases => new string[1] { "tp" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "teleport to `arg`, no `arg` = list locations";

		public override bool CheatsOnly => true;

		protected override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				ENT_Player playerObject = ENT_Player.playerObject;
				if (args.Length == 0)
				{
					CommandConsoleAccessor.EchoToConsole("Available locations:\n- " + GeneralExtensions.Join<string>((IEnumerable<string>)Locations.Keys, (Func<string, string>)null, "\n- "));
				}
				else
				{
					List<string> list = new List<string>();
					foreach (KeyValuePair<string, string> location in Locations)
					{
						if (location.Key.Contains(args[0].ToLower()))
						{
							list.Add(location.Value);
						}
					}
					if (list.Count == 0)
					{
						CommandConsoleAccessor.EchoToConsole("No such tp option, available options:\n- " + string.Join("\n- ", Locations.Keys));
					}
					else
					{
						if (list.Count > 1)
						{
							CommandConsoleAccessor.EchoToConsole("Ambiguous place to tp: " + args[0] + " maps to " + string.Join(", ", list) + "\n teleporting to first");
						}
						WorldLoader.instance.TeleportPlayerToTargetLevel(new string[1] { list[0] });
					}
				}
			};
		}
	}
}
namespace MoreCommands.Accessors
{
	public static class CommandConsoleAccessor
	{
		private static readonly Action<CommandConsole, string[]> EnableCheatsRaw = AccessTools.MethodDelegate<Action<CommandConsole, string[]>>(AccessTools.Method(typeof(CommandConsole), "EnableCheatsCommand", new Type[1] { typeof(string[]) }, (Type[])null), (object)null, true);

		private static readonly Action<CommandConsole, string> AddMessageToHistory = AccessTools.MethodDelegate<Action<CommandConsole, string>>(AccessTools.Method(typeof(CommandConsole), "AddMessageToHistory", new Type[1] { typeof(string) }, (Type[])null), (object)null, true);

		private static readonly Action<CommandConsole> CheatsEnabler = delegate(CommandConsole inst)
		{
			EnableCheatsRaw(inst, new string[1] { "true" });
		};

		public static void EnsureCheatsAreEnabled()
		{
			if (!CommandConsole.hasCheated)
			{
				CommandConsole instance = CommandConsole.instance;
				if ((Object)(object)instance == (Object)null)
				{
					MoreCommandsPlugin.Beep.LogWarning((object)"CommandConsoleAccessor::EnableCheats instance is null");
				}
				else
				{
					CheatsEnabler(CommandConsole.instance);
				}
			}
		}

		public static void EchoToConsole(string msg)
		{
			CommandConsole instance = CommandConsole.instance;
			if ((Object)(object)instance == (Object)null)
			{
				MoreCommandsPlugin.Beep.LogWarning((object)"CommandConsoleAccessor::EnableCheats instance is null");
			}
			else
			{
				AddMessageToHistory(instance, msg);
			}
		}
	}
}