Decompiled source of MoreCommands v0.13.0

MoreCommands.dll

Decompiled a month ago
using System;
using System.Collections;
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 MoreCommands.HandleProviders;
using MoreCommands.Outlines;
using MoreCommands.Patches;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements.Collections;

[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("MoreCommands")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Useful console commands for White Knuckle.")]
[assembly: AssemblyFileVersion("0.13.0.0")]
[assembly: AssemblyInformationalVersion("0.13.0+88b839aa6bbc8a64e1bdee52262bd9a24daac180")]
[assembly: AssemblyProduct("MoreCommands")]
[assembly: AssemblyTitle("MoreCommands")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.13.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Count;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Count;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Count;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyList(List<T> items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return _items.Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		_items.CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return _items.IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 Colors
{
	public static Color HIGHLIGHT = new Color(0.25f, 0.45f, 0.5f);

	public static Color C_PLAYER = new Color(0.68f, 0.95f, 0.96f);

	public static Color C_WORLD = new Color(0.929f, 0.855f, 0.714f);

	public static Color C_CONSOLE = new Color(0.898f, 0.796f, 0.949f);

	public static Color C_DESCRIPTION = new Color(0.792f, 0.792f, 0.792f);

	public static Color WHITE = Color.white;

	public static Color MAGENTA = Color.magenta;

	public static Color CYAN = Color.cyan;

	public static Color LIGHT_GREEN = new Color(0.3f, 0.9f, 0.3f);

	public static Color BRIGHT_YELLOW = new Color(1f, 1f, 0f, 0.8f);

	public static Color BROWN = new Color(0.6f, 0.3f, 0f);

	public static Color REDDISH = new Color(0.78f, 0.13f, 0.25f);

	private const string CHEAT_SIGN = "<color=orange>+</color>";

	public const string COMMAND_SEP = "<color=grey>---------------------</color>";

	public static string Str(Color c)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		return "#" + ColorUtility.ToHtmlStringRGB(c);
	}

	public static string Tagged(string s, Color c)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		return "<color=" + Str(c) + ">" + s + "</color>";
	}

	public static string Highlighted(string s)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		return Tagged(s, HIGHLIGHT);
	}

	public static string FormatCommand(ICommand c)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: 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_0035: 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_0044: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		CommandTag tag = c.Tag;
		if (1 == 0)
		{
		}
		Color val = (Color)(tag switch
		{
			CommandTag.Player => C_PLAYER, 
			CommandTag.World => C_WORLD, 
			CommandTag.Console => C_CONSOLE, 
			_ => WHITE, 
		});
		if (1 == 0)
		{
		}
		Color c2 = val;
		string text = (c.EnablesCheatsOnUse ? "<color=orange>+</color>" : "-");
		return text + " " + Tagged(GeneralExtensions.Join<string>((IEnumerable<string>)c.Aliases, (Func<string, string>)null, ", "), c2) + ":\n" + Tagged(c.Description, C_DESCRIPTION);
	}
}
public static class Helpers
{
	public static bool Substr(string text, string check)
	{
		return check == "" || (text?.IndexOf(check, StringComparison.OrdinalIgnoreCase) ?? (-1)) >= 0;
	}
}
namespace MoreCommands
{
	[BepInPlugin("shishyando.WK.MoreCommands", "MoreCommands", "0.13.0")]
	public class Plugin : 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.OnExit();
			}
		}

		public static void Assert(bool condition)
		{
			if (!condition)
			{
				Beep.LogFatal((object)"Assert failed");
				throw new Exception("[MoreCommands] Assert failed");
			}
		}
	}
	public static class Prefabs
	{
		private static readonly Levels _levels = new Levels();

		private static readonly Regions _regions = new Regions();

		private static readonly Subregions _subregions = new Subregions();

		private static readonly Entities _entities = new Entities();

		private static readonly Items _items = new Items();

		public static Handle<M_Level> Levels()
		{
			return _levels.Handle();
		}

		public static Levels LevelProvider()
		{
			return _levels;
		}

		public static Handle<M_Region> Regions()
		{
			return _regions.Handle();
		}

		public static Regions RegionProvider()
		{
			return _regions;
		}

		public static Handle<M_Subregion> Subregions()
		{
			return _subregions.Handle();
		}

		public static Subregions SubregionProvider()
		{
			return _subregions;
		}

		public static Handle<GameEntity> Entities()
		{
			return _entities.Handle();
		}

		public static Entities EntityProvider()
		{
			return _entities;
		}

		public static Handle<Item> Items()
		{
			return _items.Handle();
		}

		public static Items ItemProvider()
		{
			return _items;
		}
	}
	public abstract class HandleProvider<T>
	{
		public abstract Func<T, string> Name { get; }

		public virtual Func<T, T> Finalizer { get; } = (T obj) => obj;

		public abstract Handle<T> Handle();

		public virtual T FromCommand(string[] args)
		{
			if (args.Length == 0)
			{
				CommandConsoleAccessor.EchoToConsole("Available " + typeof(T).Name + ":\n- " + Handle().Join());
				return default(T);
			}
			T val = Handle().Filter(args[0]).Any();
			if (val == null)
			{
				CommandConsoleAccessor.EchoToConsole("No such " + typeof(T).Name + ": " + args[0]);
				return default(T);
			}
			CommandConsoleAccessor.EchoToConsole("Found " + typeof(T).Name + ": " + Colors.Highlighted(Name(val)));
			return val;
		}

		public virtual Handle<T> FromCommandMany(string[] args)
		{
			if (args.Length == 0)
			{
				CommandConsoleAccessor.EchoToConsole("Available " + typeof(T).Name + ":\n- " + Handle().Join());
				return new Handle<T>(Array.Empty<T>(), Name, Finalizer);
			}
			List<T> list = new List<T>();
			foreach (string text in args)
			{
				Handle<T> handle = Handle().Filter(text);
				if (handle.Count() > 1)
				{
					CommandConsoleAccessor.EchoToConsole("Ambiguous " + typeof(T).Name + ": " + text + " matches\n- " + handle.Join() + "\nchoosing first");
				}
				T val = handle.Any();
				if (val == null)
				{
					CommandConsoleAccessor.EchoToConsole("No such " + typeof(T).Name + ": " + text);
					return new Handle<T>(Array.Empty<T>(), Name, Finalizer);
				}
				list.Add(val);
			}
			return new Handle<T>(list, Name, Finalizer);
		}
	}
	public class Handle<T>
	{
		private readonly IEnumerable<T> _data;

		private readonly Func<T, string> _nameGetter;

		private readonly Func<T, T> _finalizer;

		public Handle(IEnumerable<T> d, Func<T, string> nameGetter, Func<T, T> finalizer)
		{
			_data = d;
			_nameGetter = (T x) => nameGetter(x)?.ToLower() ?? null;
			_finalizer = finalizer;
			base..ctor();
		}

		public Handle<T> Filter(string filter)
		{
			return new Handle<T>(_data.Where((T x) => Helpers.Substr(_nameGetter(x), filter.ToLower())), _nameGetter, _finalizer);
		}

		public T Any()
		{
			T val = _data.FirstOrDefault();
			return (val != null) ? _finalizer(val) : default(T);
		}

		public string AnyName()
		{
			return _nameGetter(Any());
		}

		public string[] Names()
		{
			return _data.Select((T x) => _nameGetter(x)).ToArray();
		}

		public string Join(string delimiter = "\n- ")
		{
			return string.Join(delimiter, Names());
		}

		public List<T> ToList()
		{
			return _data.ToList();
		}

		public IEnumerable<T> Data()
		{
			return _data;
		}

		public int Count()
		{
			return _data.Count();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "shishyando.WK.MoreCommands";

		public const string PLUGIN_NAME = "MoreCommands";

		public const string PLUGIN_VERSION = "0.13.0";
	}
}
namespace MoreCommands.HandleProviders
{
	public class Entities : HandleProvider<GameEntity>
	{
		public override Func<GameEntity, string> Name { get; } = (GameEntity x) => x?.entityPrefabID?.ToLower() ?? null;

		public override Handle<GameEntity> Handle()
		{
			return new Handle<GameEntity>(CL_GameManager.gMan?.gameEntityPrefabs ?? new List<GameEntity>(), Name, base.Finalizer);
		}
	}
	public class Items : HandleProvider<Item>
	{
		private List<Item> _items = new List<Item>();

		public override Func<Item, string> Name { get; } = (Item x) => x?.prefabName?.ToLower() ?? null;

		public override Func<Item, Item> Finalizer { get; } = (Item obj) => obj.GetClone((Item)null, false);

		public void Initialize(List<Item> items)
		{
			_items = items;
		}

		public void InitializeFromAssetDatabase()
		{
			List<GameObject> itemPrefabs = CL_AssetManager.GetFullCombinedAssetDatabase().itemPrefabs;
			foreach (GameObject item in itemPrefabs)
			{
				Item_Object component = item.GetComponent<Item_Object>();
				if ((Object)(object)component != (Object)null)
				{
					_items.Add(component.itemData);
				}
			}
		}

		public override Handle<Item> Handle()
		{
			if (_items.Count == 0)
			{
				InitializeFromAssetDatabase();
			}
			return new Handle<Item>(_items, Name, Finalizer);
		}
	}
	public class Levels : HandleProvider<M_Level>
	{
		private List<M_Level> _levels = new List<M_Level>();

		private readonly Dictionary<M_Region, List<M_Level>> _regions = new Dictionary<M_Region, List<M_Level>>();

		private readonly Dictionary<M_Subregion, List<M_Level>> _subregions = new Dictionary<M_Subregion, List<M_Level>>();

		public override Func<M_Level, string> Name { get; } = (M_Level x) => ((x == null) ? null : ((Object)x).name?.ToLower()) ?? null;

		public void Initialize()
		{
			_levels = (from x in CL_AssetManager.GetFullCombinedAssetDatabase().levelAssets
				select x.level into c
				where (Object)(object)c != (Object)null
				select c).Distinct().ToList();
			foreach (M_Level level in _levels)
			{
				if ((Object)(object)level?.region != (Object)null)
				{
					if (!_regions.TryGetValue(level.region, out var value))
					{
						value = new List<M_Level>();
						_regions[level.region] = value;
					}
					value.Add(level);
				}
				if ((Object)(object)level?.subRegion != (Object)null)
				{
					if (!_subregions.TryGetValue(level.subRegion, out var value2))
					{
						value2 = new List<M_Level>();
						_subregions[level.subRegion] = value2;
					}
					value2.Add(level);
				}
			}
		}

		public override Handle<M_Level> Handle()
		{
			if (_levels.Count == 0)
			{
				Initialize();
			}
			return new Handle<M_Level>(_levels, Name, base.Finalizer);
		}

		public Handle<M_Level> Regional(M_Region region)
		{
			if (_levels.Count == 0)
			{
				Initialize();
			}
			return new Handle<M_Level>(_regions[region], Name, base.Finalizer);
		}

		public Handle<M_Level> Subregional(M_Subregion subregion)
		{
			if (_levels.Count == 0)
			{
				Initialize();
			}
			return new Handle<M_Level>(_subregions[subregion], Name, base.Finalizer);
		}
	}
	public class Regions : HandleProvider<M_Region>
	{
		private List<M_Region> _regions = new List<M_Region>();

		public override Func<M_Region, string> Name { get; } = (M_Region x) => (x == null) ? null : ((Object)x).name?.ToLower();

		public void Initialize()
		{
			_regions = CL_AssetManager.GetFullCombinedAssetDatabase().regionAssets.Where((M_Region x) => (Object)(object)x != (Object)null).Distinct().ToList();
		}

		public override Handle<M_Region> Handle()
		{
			if (_regions.Count == 0)
			{
				Initialize();
			}
			return new Handle<M_Region>(_regions, Name, base.Finalizer);
		}
	}
	public class Subregions : HandleProvider<M_Subregion>
	{
		private List<M_Subregion> _subregions = new List<M_Subregion>();

		public override Func<M_Subregion, string> Name { get; } = (M_Subregion x) => (x == null) ? null : ((Object)x).name?.ToLower();

		public void Initialize()
		{
			_subregions = CL_AssetManager.GetFullCombinedAssetDatabase().subRegionAssets.Where((M_Subregion x) => (Object)(object)x != (Object)null && (x.levelReferences?.Count ?? 0) > 0).Distinct().ToList();
		}

		public override Handle<M_Subregion> Handle()
		{
			if (_subregions.Count == 0)
			{
				Initialize();
			}
			return new Handle<M_Subregion>(_subregions, Name, base.Finalizer);
		}
	}
}
namespace MoreCommands.Patches
{
	[HarmonyPatch(typeof(CL_GameManager), "Awake")]
	public static class CL_GameManager_Awake_Patcher
	{
		[HarmonyPostfix]
		public static void PatchDatabases(CL_GameManager __instance)
		{
			WKAssetDatabase fullCombinedAssetDatabase = CL_AssetManager.GetFullCombinedAssetDatabase();
			IEnumerable<GameObject> enumerable = (from x in fullCombinedAssetDatabase.entityPrefabs.Concat(fullCombinedAssetDatabase.denizenPrefabs).Concat(fullCombinedAssetDatabase.itemPrefabs)
				where (Object)(object)x != (Object)null && ((Object)x).name != null
				select x).Distinct();
			Dictionary<string, GameEntity> dictionary = new Dictionary<string, GameEntity>();
			foreach (GameObject item in enumerable)
			{
				GameEntity componentInChildren = item.GetComponentInChildren<GameEntity>(true);
				if (!((Object)(object)componentInChildren == (Object)null) && !string.IsNullOrWhiteSpace(componentInChildren.entityPrefabID))
				{
					dictionary.TryAdd(componentInChildren.entityPrefabID.ToLower(), componentInChildren);
				}
			}
			__instance.gameEntityPrefabs = dictionary.Values.ToList();
		}
	}
	[HarmonyPatch(typeof(CL_GameManager), "Start")]
	public static class CL_GameManager_Start_CommandRegistration_Patcher
	{
		[HarmonyPostfix]
		public static void RegisterWorldCommands(CL_GameManager __instance)
		{
			CommandRegistration.AddCommandsByTag(CommandTag.World);
		}
	}
	[HarmonyPatch(typeof(CommandConsole), "Awake")]
	public static class CommandConsole_Awake_Patcher
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static OnValidateInput <0>__ValidateAscii;
		}

		[HarmonyPostfix]
		public static void RegisterMoreCommands(CommandConsole __instance)
		{
			CommandRegistration.AddCommandsByTag(CommandTag.Console);
		}

		[HarmonyPostfix]
		public static void FixVanillaGameBug(CommandConsole __instance)
		{
			//IL_002b: 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_0036: Expected O, but got Unknown
			TMP_InputField[] componentsInChildren = ((Component)__instance).gameObject.GetComponentsInChildren<TMP_InputField>(true);
			TMP_InputField[] array = componentsInChildren;
			foreach (TMP_InputField val in array)
			{
				object obj = <>O.<0>__ValidateAscii;
				if (obj == null)
				{
					OnValidateInput val2 = ValidateAscii;
					<>O.<0>__ValidateAscii = val2;
					obj = (object)val2;
				}
				val.onValidateInput = (OnValidateInput)obj;
			}
			static char ValidateAscii(string text, int charIndex, char addedChar)
			{
				if (addedChar <= '\u007f')
				{
					return addedChar;
				}
				return '\0';
			}
		}
	}
	public static class CommandRegistration
	{
		public static void AddCommandsByTag(CommandTag tag)
		{
			foreach (ICommand item in CommandRegistry.GetCommandsByTag(tag))
			{
				string[] aliases = item.Aliases;
				foreach (string alias in aliases)
				{
					AddCommandIfFree(alias, item);
				}
			}
		}

		public static void AddCommandIfFree(string alias, ICommand source)
		{
			string text = alias.ToLower();
			if ((Object)(object)CommandConsole.instance != (Object)null)
			{
				IDictionary commands = CommandConsoleAccessor.GetCommands(CommandConsole.instance);
				if (commands.Contains(text))
				{
					Plugin.Beep.LogInfo((object)("Skipping MoreCommands alias '" + text + "' because an existing command already uses it"));
					return;
				}
			}
			CommandBuilder builder = CommandConsole.BuildCommand(text, source.GetCallback()).NotCheat().Description(source.Description);
			if (source is CommandBase commandBase)
			{
				commandBase.ConfigureBuilder(builder);
			}
		}
	}
	[HarmonyPatch(typeof(CommandConsole), "RegisterCommand")]
	public static class CommandConsole_RegisterCommand_Patcher
	{
		[HarmonyPrefix]
		public static bool DoNotOverrideExistingCommands(CommandConsole __instance, ref string command, ref object __result)
		{
			if (command == null || (Object)(object)__instance == (Object)null)
			{
				return true;
			}
			string key = command.ToLower();
			IDictionary commands = CommandConsoleAccessor.GetCommands(__instance);
			if (!commands.Contains(key))
			{
				return true;
			}
			__result = commands[key];
			return false;
		}
	}
	[HarmonyPatch(typeof(GameEntity), "Start")]
	public static class GameEntity_Start_Patcher
	{
		private static void Postfix(GameEntity __instance)
		{
			OutlinesController.RegisterEntity(__instance);
		}
	}
	[HarmonyPatch(typeof(GameEntity), "OnDestroy")]
	public static class GameEntity_OnDestroy_Patcher
	{
		private static void Prefix(GameEntity __instance)
		{
			OutlinesController.UnregisterEntity(__instance);
		}
	}
	[HarmonyPatch(typeof(ENT_Player), "CreateCommands")]
	public static class ENT_Player_CreateCommands_Patcher
	{
		public static void Postfix(ENT_Player __instance)
		{
			CommandRegistration.AddCommandsByTag(CommandTag.Player);
		}
	}
	[HarmonyPatch(typeof(ENT_Player), "Movement")]
	public static class ENT_Player_Movement_Patcher
	{
		public static readonly FieldRef<ENT_Player, CL_GameManager> gManRef = AccessTools.FieldRefAccess<ENT_Player, CL_GameManager>("gMan");

		public static readonly FieldRef<ENT_Player, Vector3> moveAxisRef = AccessTools.FieldRefAccess<ENT_Player, Vector3>("moveAxis");

		public static readonly FieldRef<ENT_Player, Vector3> velRef = AccessTools.FieldRefAccess<ENT_Player, Vector3>("vel");

		public static float NoclipSpeedMultiplier = 1f;

		public static void Postfix(ENT_Player __instance)
		{
			//IL_003f: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.noclip && !gManRef.Invoke(__instance).freecam && !gManRef.Invoke(__instance).lockPlayerInput)
			{
				Transform transform = ((Component)__instance).transform;
				transform.position += (moveAxisRef.Invoke(__instance) * 6f + velRef.Invoke(__instance)) * Time.fixedDeltaTime * (NoclipSpeedMultiplier - 1f);
			}
		}
	}
	[HarmonyPatch(typeof(UT_SpawnChance), "Start")]
	public static class UT_SpawnChance_Start_Patcher
	{
		public static bool AlwaysSpawn = false;

		public static HashSet<string> ExcludeFromAlwaysSpawn = new HashSet<string> { "Level_Secret_Entrance_Blocked", "Secret area spawn" };

		public static bool Prefix(UT_SpawnChance __instance)
		{
			if (AlwaysSpawn)
			{
				((Component)__instance).gameObject.SetActive(!ExcludeFromAlwaysSpawn.Contains(((Object)__instance).name));
				return false;
			}
			return true;
		}
	}
}
namespace MoreCommands.Outlines
{
	public static class OutlinesController
	{
		private static Dictionary<GameEntity, string> _trackedEntitiesIds = new Dictionary<GameEntity, string>();

		private static Dictionary<string, Color> _activeOutlines = new Dictionary<string, Color>();

		private static readonly Dictionary<string, Color> _defaultOutlines = new Dictionary<string, Color>
		{
			{
				"item_injector",
				Colors.LIGHT_GREEN
			},
			{
				"item_blinkeye",
				Colors.MAGENTA
			},
			{
				"denizen_sluggrub",
				Colors.BRIGHT_YELLOW
			},
			{
				"item_pillbottle",
				Colors.CYAN
			},
			{
				"item_food_bar",
				Colors.BROWN
			}
		};

		public static bool ToggleDefault()
		{
			if (new HashSet<string>(_activeOutlines.Keys, StringComparer.OrdinalIgnoreCase).SetEquals(_defaultOutlines.Keys))
			{
				_activeOutlines.Clear();
			}
			else
			{
				_activeOutlines = ObjectExtensions.Copy<Dictionary<string, Color>>(_defaultOutlines);
			}
			RefreshAll();
			return _activeOutlines.Count > 0;
		}

		public static void ClearAll()
		{
			_activeOutlines.Clear();
			_trackedEntitiesIds.Clear();
		}

		public static bool IsEnabled(string entityIdLower)
		{
			Plugin.Assert(entityIdLower == entityIdLower.ToLower());
			return _activeOutlines.ContainsKey(entityIdLower);
		}

		public static Color EnableOutlines(string entityIdLower, Color color, bool useDefaultColor = true)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Assert(entityIdLower == entityIdLower.ToLower());
			Plugin.Assert(!IsEnabled(entityIdLower));
			Color val = (_activeOutlines[entityIdLower] = (useDefaultColor ? DictionaryExtensions.Get<string, Color>((IDictionary<string, Color>)_defaultOutlines, entityIdLower, color) : color));
			Color result = val;
			RefreshAll();
			return result;
		}

		public static Color SetColor(string entityIdLower, Color color)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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)
			Plugin.Assert(entityIdLower == entityIdLower.ToLower());
			Plugin.Assert(IsEnabled(entityIdLower));
			_activeOutlines[entityIdLower] = color;
			RefreshAll();
			return color;
		}

		public static bool DisableOutlines(string entityIdLower)
		{
			Plugin.Assert(entityIdLower == entityIdLower.ToLower());
			Plugin.Assert(IsEnabled(entityIdLower));
			bool flag = _activeOutlines.Remove(entityIdLower);
			if (flag)
			{
				RefreshAll();
			}
			return flag;
		}

		public static void RegisterEntity(GameEntity entity)
		{
			string value = entity?.entityPrefabID?.ToLower();
			if (!string.IsNullOrEmpty(value) && !_trackedEntitiesIds.ContainsKey(entity) && Prefabs.Entities().Names().Contains(value))
			{
				Renderer[] array = (from r in ((Component)entity).GetComponentsInChildren<Renderer>(true)
					where !(r is ParticleSystemRenderer) && !(r is TrailRenderer)
					select r).ToArray();
				if (array.Length != 0)
				{
					_trackedEntitiesIds[entity] = value;
					RefreshSingle(entity);
				}
			}
		}

		public static void UnregisterEntity(GameEntity entity)
		{
			_trackedEntitiesIds.Remove(entity);
		}

		private static void RefreshAll()
		{
			List<GameEntity> list = _trackedEntitiesIds.Keys.Where((GameEntity key) => (Object)(object)key == (Object)null).ToList();
			foreach (GameEntity item in list)
			{
				Plugin.Beep.LogWarning((object)("Refreshing outlines, dead object: " + _trackedEntitiesIds[item]));
				_trackedEntitiesIds.Remove(item);
			}
			foreach (GameEntity key in _trackedEntitiesIds.Keys)
			{
				RefreshSingle(key);
			}
		}

		private static void RefreshSingle(GameEntity entity)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			string text = entity?.entityPrefabID?.ToLower();
			if (string.IsNullOrEmpty(text))
			{
				return;
			}
			Color value;
			bool flag = _activeOutlines.TryGetValue(text, out value);
			Material val = (flag ? OutlinesMaterialFactory.Get(value) : null);
			Renderer[] array = (from r in ((Component)entity).GetComponentsInChildren<Renderer>(true)
				where !(r is ParticleSystemRenderer) && !(r is TrailRenderer)
				select r).ToArray();
			Renderer[] array2 = array;
			foreach (Renderer val2 in array2)
			{
				if (!((Object)(object)val2 == (Object)null))
				{
					List<Material> list = val2.sharedMaterials.ToList();
					bool flag2 = false;
					int num2 = list.RemoveAll((Material m) => (Object)(object)m != (Object)null && ((Object)m.shader).name == "GUI/Text Shader");
					if (num2 > 0)
					{
						flag2 = true;
					}
					if (flag && (Object)(object)val != (Object)null)
					{
						list.Add(val);
						flag2 = true;
					}
					if (flag2)
					{
						val2.materials = list.ToArray();
					}
				}
			}
		}
	}
	public static class OutlinesMaterialFactory
	{
		public const string SHADER_NAME = "GUI/Text Shader";

		private static Dictionary<Color, Material> _cache = new Dictionary<Color, Material>();

		public static Material Get(Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			if (_cache.TryGetValue(color, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Shader val = Shader.Find("GUI/Text Shader");
			Material val2 = new Material(val);
			val2.SetInt("unity_GUIZTestMode", 8);
			val2.SetInt("_ZTest", 8);
			val2.SetInt("_ZWrite", 1);
			val2.color = color;
			val2.mainTexture = (Texture)(object)Texture2D.whiteTexture;
			val2.renderQueue = 5000;
			_cache[color] = val2;
			return val2;
		}
	}
}
namespace MoreCommands.Common
{
	public static class AutocompleteHelpers
	{
		private static readonly string[] BoolValues = new string[2] { "true", "false" };

		public static readonly string[] ColorValues = new string[11]
		{
			"red", "green", "blue", "yellow", "cyan", "magenta", "white", "black", "grey", "gray",
			"orange"
		};

		public static void OptionalSingleFloat(CommandAutocomplete autocomplete)
		{
			if (autocomplete.activeArg > 0)
			{
				autocomplete.Reject();
			}
		}

		public static void ValidateOptionalSingleFloat(CommandValidator validator)
		{
			if (validator.activeArg != 0 || !float.TryParse(validator.ArgumentAt(validator.activeArg), out var _))
			{
				validator.Reject();
			}
		}

		public static void OptionalSingleBool(CommandAutocomplete autocomplete)
		{
			if (autocomplete.activeArg == 0)
			{
				autocomplete.FromArray((IReadOnlyList<string>)BoolValues);
			}
			else
			{
				autocomplete.Reject();
			}
		}

		public static void ValidateOptionalSingleBool(CommandValidator validator)
		{
			if (validator.activeArg != 0 || !bool.TryParse(validator.ArgumentAt(validator.activeArg), out var _))
			{
				validator.Reject();
			}
		}

		public static void OptionalSingleFrom<T>(CommandAutocomplete autocomplete, Func<Handle<T>> getHandle)
		{
			if (autocomplete.activeArg == 0)
			{
				autocomplete.FromArray((IReadOnlyList<string>)Names(getHandle));
			}
			else
			{
				autocomplete.Reject();
			}
		}

		public static void ValidateOptionalSingleFrom<T>(CommandValidator validator, Func<Handle<T>> getHandle)
		{
			if (validator.activeArg != 0 || !HasMatch(getHandle, validator.ArgumentAt(validator.activeArg)))
			{
				validator.Reject();
			}
		}

		public static void VariadicFrom<T>(CommandAutocomplete autocomplete, Func<Handle<T>> getHandle)
		{
			autocomplete.FromArray((IReadOnlyList<string>)Names(getHandle));
		}

		public static void ValidateVariadicFrom<T>(CommandValidator validator, Func<Handle<T>> getHandle)
		{
			if (!HasMatch(getHandle, validator.ArgumentAt(validator.activeArg)))
			{
				validator.Reject();
			}
		}

		public static string[] Names<T>(Func<Handle<T>> getHandle)
		{
			return (from x in getHandle().Names()
				where !string.IsNullOrWhiteSpace(x)
				select x).ToArray();
		}

		public static bool HasMatch<T>(Func<Handle<T>> getHandle, string value)
		{
			return !string.IsNullOrWhiteSpace(value) && getHandle().Filter(value).Names().Any((string x) => !string.IsNullOrWhiteSpace(x));
		}
	}
	public interface ICommand
	{
		string[] Aliases { get; }

		CommandTag Tag { get; }

		string Description { get; }

		bool EnablesCheatsOnUse { get; }

		Action<string[]> GetCallback(bool withSuffix = true);

		Action<string[]> GetLogicCallback();

		void OnExit();
	}
	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 EnablesCheatsOnUse { get; }

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

		public virtual void OnExit()
		{
		}

		public virtual void ConfigureBuilder(CommandBuilder builder)
		{
		}

		public void EnableCheatsIfNeeded(string[] args)
		{
			if (EnablesCheatsOnUse)
			{
				CommandConsoleAccessor.EnsureCheatsAreEnabled();
			}
		}

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

		protected bool HasRequiredContext()
		{
			switch (Tag)
			{
			case CommandTag.Player:
				if ((Object)(object)ENT_Player.GetPlayer() != (Object)null)
				{
					return true;
				}
				CommandConsoleAccessor.EchoToConsole("No player found");
				return false;
			case CommandTag.World:
				if ((Object)(object)CL_GameManager.gMan != (Object)null)
				{
					return true;
				}
				CommandConsoleAccessor.EchoToConsole("No active game world found");
				return false;
			default:
				return true;
			}
		}

		protected static Inventory GetInventoryOrWarn()
		{
			if ((Object)(object)Inventory.instance != (Object)null)
			{
				return Inventory.instance;
			}
			CommandConsoleAccessor.EchoToConsole("No inventory found");
			return null;
		}

		public virtual Action<string[]> GetCallback(bool withSuffix = true)
		{
			return delegate(string[] args)
			{
				if (HasRequiredContext())
				{
					EnableCheatsIfNeeded(args);
					GetLogicCallback()(args);
					if (withSuffix)
					{
						PrintSuffix(args);
					}
				}
			};
		}
	}
	public abstract class TogglableCommandBase : CommandBase, ITogglableCommand, ICommand
	{
		public bool Enabled { get; set; }

		public string EnabledStr => Enabled ? "enabled" : "disabled";

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)AutocompleteHelpers.OptionalSingleBool).AutocompleteValidator((Action<CommandValidator>)AutocompleteHelpers.ValidateOptionalSingleBool).OverValue((Func<object>)(() => Enabled));
		}

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

		public void PrintEnabled(string[] args)
		{
			CommandConsoleAccessor.EchoToConsole(Colors.Highlighted(Aliases.First()) + " " + EnabledStr);
		}

		public sealed override Action<string[]> GetCallback(bool withSuffix = true)
		{
			return delegate(string[] args)
			{
				if (HasRequiredContext())
				{
					UpdateEnabled(args);
					EnableCheatsIfNeeded(args);
					GetLogicCallback()(args);
					PrintEnabled(args);
					if (withSuffix)
					{
						PrintSuffix(args);
					}
				}
			};
		}

		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 static bool ParseEnabled(bool enabled, string[] args)
		{
			if (args.Length == 0 || !bool.TryParse(args[0], out var result))
			{
				return !enabled;
			}
			return result;
		}

		public override void OnExit()
		{
			if (Enabled)
			{
				Enabled = false;
				GetLogicCallback()(new string[1] { "false" });
			}
		}
	}
	public enum CommandTag
	{
		Player,
		World,
		Console
	}
	public static class CommandRegistry
	{
		public static List<ICommand> RegisteredCommands = new List<ICommand>();

		public static bool Initialized = false;

		private static void RegisterAll()
		{
			Register(new AlwaysSpawnCommand());
			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 JustCauseCommand());
			Register(new ListEntitiesCommand());
			Register(new ListItemsCommand());
			Register(new ListRegionsCommand());
			Register(new ListSubregionsCommand());
			Register(new LoadRandomLevelsCommand());
			Register(new LoadRandomLevelsNoDeathgooCommand());
			Register(new LoadRandomLevelsSpidermanCommand());
			Register(new LoadRegionCommand());
			Register(new LoadSubregionCommand());
			Register(new ManCommand());
			Register(new NoclipSpeed());
			Register(new SpeedyPerksCommand());
			Register(new SpidermanCommand());
			Register(new TeleportCommand());
			Register(new WallhackCommand());
		}

		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)
			{
				Plugin.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>(bool withSuffix = true) where T : ICommand
		{
			return RegisteredCommands.FirstOrDefault((ICommand c) => c.GetType() == typeof(T))?.GetCallback(withSuffix) ?? ((Action<string[]>)delegate
			{
				Plugin.Beep.LogWarning((object)$"Command {typeof(T)} not found");
			});
		}

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

		public static void SetTogglable<T>(bool enabled) where T : ICommand
		{
			if (!(GetCommand<T>() is ITogglableCommand togglableCommand))
			{
				Plugin.Beep.LogWarning((object)$"Togglable command {typeof(T)} not found");
				return;
			}
			togglableCommand.Enabled = enabled;
			togglableCommand.GetLogicCallback()(new string[1] { enabled.ToString().ToLower() });
		}

		public static void OnExit()
		{
			foreach (ICommand registeredCommand in RegisteredCommands)
			{
				registeredCommand.OnExit();
			}
		}
	}
	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, true);
				}
				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, true);
				}
			}
			else
			{
				Plugin.Beep.LogWarning((object)("Perk " + perkId + " not found!"));
			}
		}
	}
}
namespace MoreCommands.Commands
{
	public sealed class AlwaysSpawnCommand : TogglableCommandBase
	{
		public override string[] Aliases => new string[1] { "alwaysspawn" };

		public override CommandTag Tag => CommandTag.World;

		public override string Description => "Guarantee spawns (items, handholds, supply crates, etc.)";

		public override bool EnablesCheatsOnUse => true;

		public override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				UT_SpawnChance_Start_Patcher.AlwaysSpawn = base.Enabled;
			};
		}
	}
	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 EnablesCheatsOnUse => true;

		public override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				Inventory inventoryOrWarn = CommandBase.GetInventoryOrWarn();
				if (!((Object)(object)inventoryOrWarn == (Object)null))
				{
					Item val = Prefabs.Items().Filter("item_banhammer").Any();
					if (val != null)
					{
						inventoryOrWarn.AddItemToHand(val, 0);
						CommandConsoleAccessor.EchoToConsole(Colors.Tagged("banhammer", Colors.REDDISH) + " given");
					}
				}
			};
		}
	}
	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, without perks";

		public override bool EnablesCheatsOnUse => true;

		public 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
						};
						((GameEntity)playerObject).Buff(val);
					}
					else
					{
						((GameEntity)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 EnablesCheatsOnUse => true;

		public override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				PerkChanger.MaxOutPerk("Perk_BackStrengtheners");
				CommandConsoleAccessor.EchoToConsole("Max backstrength perks given");
			};
		}
	}
	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 EnablesCheatsOnUse => true;

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

		public override CommandTag Tag => CommandTag.Player;

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

		public override bool EnablesCheatsOnUse => true;

		public override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				CommandRegistry.SetTogglable<FreerunCommand>(base.Enabled);
				CommandRegistry.SetTogglable<BuffCommand>(base.Enabled);
			};
		}
	}
	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 EnablesCheatsOnUse => true;

		public 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's inventory by its id with substring search";

		public override bool EnablesCheatsOnUse => true;

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)delegate(CommandAutocomplete autocomplete)
			{
				AutocompleteHelpers.OptionalSingleFrom(autocomplete, Prefabs.Items);
			}).AutocompleteValidator((Action<CommandValidator>)delegate(CommandValidator validator)
			{
				AutocompleteHelpers.ValidateOptionalSingleFrom(validator, Prefabs.Items);
			});
		}

		public override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				//IL_003a: 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_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				Inventory inventoryOrWarn = CommandBase.GetInventoryOrWarn();
				if (!((Object)(object)inventoryOrWarn == (Object)null))
				{
					Item val = Prefabs.ItemProvider().FromCommand(args);
					if (val != null)
					{
						inventoryOrWarn.AddItemToInventoryScreen(new Vector3(0f, 0f, 1f) + Random.insideUnitSphere * 0.01f, val, true, false, true);
					}
				}
			};
		}
	}
	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 by its id with substring search";

		public override bool EnablesCheatsOnUse => true;

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)delegate(CommandAutocomplete autocomplete)
			{
				AutocompleteHelpers.OptionalSingleFrom(autocomplete, Prefabs.Items);
			}).AutocompleteValidator((Action<CommandValidator>)delegate(CommandValidator validator)
			{
				AutocompleteHelpers.ValidateOptionalSingleFrom(validator, Prefabs.Items);
			});
		}

		public override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				//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)
				Inventory inventoryOrWarn = CommandBase.GetInventoryOrWarn();
				if (!((Object)(object)inventoryOrWarn == (Object)null))
				{
					Item val = Prefabs.ItemProvider().FromCommand(args);
					if (val != null)
					{
						val.bagRotation = new Quaternion(1f, 2f, 3f, 4f);
						inventoryOrWarn.AddItemToHand(val, 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 by its id with substring search";

		public override bool EnablesCheatsOnUse => true;

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)delegate(CommandAutocomplete autocomplete)
			{
				AutocompleteHelpers.OptionalSingleFrom(autocomplete, Prefabs.Items);
			}).AutocompleteValidator((Action<CommandValidator>)delegate(CommandValidator validator)
			{
				AutocompleteHelpers.ValidateOptionalSingleFrom(validator, Prefabs.Items);
			});
		}

		public override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				//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)
				Inventory inventoryOrWarn = CommandBase.GetInventoryOrWarn();
				if (!((Object)(object)inventoryOrWarn == (Object)null))
				{
					Item val = Prefabs.ItemProvider().FromCommand(args);
					if (val != null)
					{
						val.bagRotation = new Quaternion(1f, 2f, 3f, 4f);
						inventoryOrWarn.AddItemToHand(val, 1);
					}
				}
			};
		}
	}
	public sealed class GravityCommand : CommandBase
	{
		private static readonly FieldRef<ENT_Player, float> GravityMultRef = AccessTools.FieldRefAccess<ENT_Player, float>("gravityMult");

		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 EnablesCheatsOnUse => true;

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)AutocompleteHelpers.OptionalSingleFloat).AutocompleteValidator((Action<CommandValidator>)AutocompleteHelpers.ValidateOptionalSingleFloat).OverValue((Func<object>)CurrentGravityMultiplier);
		}

		private static object CurrentGravityMultiplier()
		{
			ENT_Player playerObject = ENT_Player.playerObject;
			return ((Object)(object)playerObject == (Object)null) ? null : ((object)GravityMultRef.Invoke(playerObject));
		}

		public override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				ENT_Player playerObject = ENT_Player.playerObject;
				float result;
				if ((Object)(object)playerObject == (Object)null)
				{
					CommandConsoleAccessor.EchoToConsole("No player found");
				}
				else if (args.Length == 0)
				{
					playerObject.SetGravityMult(1f);
					CommandConsoleAccessor.EchoToConsole("Player gravity set to 1.0");
				}
				else if (float.TryParse(args[0], out result))
				{
					playerObject.SetGravityMult(result);
					CommandConsoleAccessor.EchoToConsole($"Player gravity set to {result:F1}");
				}
				else
				{
					CommandConsoleAccessor.EchoToConsole("Invalid arguments for gravity command: " + GeneralExtensions.Join<string>((IEnumerable<string>)args, (Func<string, string>)null, " "));
				}
			};
		}

		public override void OnExit()
		{
			ENT_Player playerObject = ENT_Player.playerObject;
			if (playerObject != null)
			{
				playerObject.SetGravityMult(1f);
			}
		}
	}
	public sealed class JustCauseCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "justcause" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "Give debug handgun to left hand and infinite barnacle hook to right hand";

		public override bool EnablesCheatsOnUse => true;

		public override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				CommandConsole.instance.ExecuteCommand("left item_handgun_debug; right item_barnaclehook_infinite", true);
			};
		}
	}
	public sealed class ListEntitiesCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "listentities" };

		public override CommandTag Tag => CommandTag.Console;

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

		public override bool EnablesCheatsOnUse => false;

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)delegate(CommandAutocomplete autocomplete)
			{
				AutocompleteHelpers.OptionalSingleFrom(autocomplete, Prefabs.Entities);
			}).AutocompleteValidator((Action<CommandValidator>)delegate(CommandValidator validator)
			{
				AutocompleteHelpers.ValidateOptionalSingleFrom(validator, Prefabs.Entities);
			});
		}

		public override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				CommandConsoleAccessor.EchoToConsole("- " + Prefabs.Entities().Filter(args.FirstOrDefault() ?? "").Join());
			};
		}
	}
	public sealed class ListItemsCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "listitems" };

		public override CommandTag Tag => CommandTag.Console;

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

		public override bool EnablesCheatsOnUse => false;

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)delegate(CommandAutocomplete autocomplete)
			{
				AutocompleteHelpers.OptionalSingleFrom(autocomplete, Prefabs.Items);
			}).AutocompleteValidator((Action<CommandValidator>)delegate(CommandValidator validator)
			{
				AutocompleteHelpers.ValidateOptionalSingleFrom(validator, Prefabs.Items);
			});
		}

		public override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				CommandConsoleAccessor.EchoToConsole("- " + Prefabs.Items().Filter(args.FirstOrDefault() ?? "").Join());
			};
		}
	}
	public sealed class BetterListPerksCommand : CommandBase
	{
		public override string[] Aliases => new string[2] { "lp", "mclistperks" };

		public override CommandTag Tag => CommandTag.Console;

		public override string Description => "Enhanced perk list with titles, ids, descriptions, and filtering";

		public override bool EnablesCheatsOnUse => false;

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)AutocompletePerks).AutocompleteValidator((Action<CommandValidator>)ValidatePerks);
		}

		private static void AutocompletePerks(CommandAutocomplete autocomplete)
		{
			if (autocomplete.activeArg == 0)
			{
				autocomplete.FromArrayWithDesc(PerkEntries());
			}
			else
			{
				autocomplete.Reject();
			}
		}

		private static void ValidatePerks(CommandValidator validator)
		{
			string value = validator.ArgumentAt(validator.activeArg);
			if (validator.activeArg != 0 || !PerkMatches(value))
			{
				validator.Reject();
			}
		}

		private static IReadOnlyList<(string name, string desc)> PerkEntries()
		{
			List<(string, string)> list = new List<(string, string)>();
			list.AddRange(from perk in CL_AssetManager.GetFullCombinedAssetDatabase().perkAssets
				where (Object)(object)perk != (Object)null && !string.IsNullOrWhiteSpace(perk.id)
				select (perk.id.ToLower(), perk.GetTitle(false)));
			return new <>z__ReadOnlyList<(string, string)>(list);
		}

		private static bool PerkMatches(string value)
		{
			return !string.IsNullOrWhiteSpace(value) && CL_AssetManager.GetFullCombinedAssetDatabase().perkAssets.Where((Perk perk) => (Object)(object)perk != (Object)null).Any((Perk perk) => Helpers.Substr(((Object)perk).name, value) || Helpers.Substr(perk.description, value) || Helpers.Substr(perk.id, value));
		}

		public override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				foreach (Perk perkAsset in CL_AssetManager.GetFullCombinedAssetDatabase().perkAssets)
				{
					if (args.Length == 0 || Helpers.Substr(((Object)perkAsset).name, args[0]) || Helpers.Substr(perkAsset.description, args[0]) || Helpers.Substr(perkAsset.id, args[0]))
					{
						string description = perkAsset.GetDescription(false, false, false, true);
						string msg = "- " + perkAsset.GetTitle(false) + " (" + Colors.Highlighted(perkAsset.id) + ")\n" + description + "</color></color></color>\n";
						CommandConsoleAccessor.EchoToConsole(msg);
					}
				}
			};
		}
	}
	public sealed class ListRegionsCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "listregions" };

		public override CommandTag Tag => CommandTag.Console;

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

		public override bool EnablesCheatsOnUse => false;

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)delegate(CommandAutocomplete autocomplete)
			{
				AutocompleteHelpers.OptionalSingleFrom(autocomplete, Prefabs.Regions);
			}).AutocompleteValidator((Action<CommandValidator>)delegate(CommandValidator validator)
			{
				AutocompleteHelpers.ValidateOptionalSingleFrom(validator, Prefabs.Regions);
			});
		}

		public override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				CommandConsoleAccessor.EchoToConsole("- " + Prefabs.Regions().Filter(args.FirstOrDefault() ?? "").Join());
			};
		}
	}
	public sealed class ListSubregionsCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "listsubregions" };

		public override CommandTag Tag => CommandTag.Console;

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

		public override bool EnablesCheatsOnUse => false;

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)delegate(CommandAutocomplete autocomplete)
			{
				AutocompleteHelpers.OptionalSingleFrom(autocomplete, Prefabs.Subregions);
			}).AutocompleteValidator((Action<CommandValidator>)delegate(CommandValidator validator)
			{
				AutocompleteHelpers.ValidateOptionalSingleFrom(validator, Prefabs.Subregions);
			});
		}

		public override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				CommandConsoleAccessor.EchoToConsole("- " + Prefabs.Subregions().Filter(args.FirstOrDefault() ?? "").Join());
			};
		}
	}
	public sealed class LoadRandomLevelsCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "loadrandomlevels" };

		public override CommandTag Tag => CommandTag.World;

		public override string Description => "Load completely random levels\nRecommended commands: `godmode`, `deathgoo-goaway`\nHave fun";

		public override bool EnablesCheatsOnUse => false;

		public override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				IEnumerable<M_Level> source = Prefabs.Levels().Data();
				int num = source.Count();
				string[] array = (from x in source.OrderBy((M_Level x) => Random.value).Take(Random.RandomRangeInt(0, num))
					select ((Object)x).name.ToLower()).ToArray();
				CommandConsoleAccessor.EchoToConsole("Loading random levels:\n- " + string.Join("\n- ", array));
				CL_GameManager.gMan.LoadLevels(array);
			};
		}
	}
	public sealed class LoadRandomLevelsNoDeathgooCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "loadrandomlevels_nodeathgoo" };

		public override CommandTag Tag => CommandTag.World;

		public override string Description => "Load random levels, then send deathgoo away";

		public override bool EnablesCheatsOnUse => true;

		public override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				CommandConsole.instance.ExecuteCommand("loadrandomlevels; deathgoo-goaway", true);
			};
		}
	}
	public sealed class LoadRandomLevelsSpidermanCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "loadrandomlevels_spiderman" };

		public override CommandTag Tag => CommandTag.World;

		public override string Description => "Load random levels, then give infinite barnacle hooks to both hands";

		public override bool EnablesCheatsOnUse => true;

		public override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				CommandConsole.instance.ExecuteCommand("loadrandomlevels; spiderman", true);
			};
		}
	}
	public sealed class LoadRegionCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "loadregions" };

		public override CommandTag Tag => CommandTag.World;

		public override string Description => "Load some region levels by region name, filtered by `arg`";

		public override bool EnablesCheatsOnUse => false;

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)delegate(CommandAutocomplete autocomplete)
			{
				AutocompleteHelpers.VariadicFrom(autocomplete, Prefabs.Regions);
			}).AutocompleteValidator((Action<CommandValidator>)delegate(CommandValidator validator)
			{
				AutocompleteHelpers.ValidateVariadicFrom(validator, Prefabs.Regions);
			});
		}

		public override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				Handle<M_Region> handle = Prefabs.RegionProvider().FromCommandMany(args);
				if (handle == null || handle.Count() == 0)
				{
					return;
				}
				try
				{
					string[] array = (from x in handle.Data().SelectMany((M_Region x) => x.GetLevels((M_Region)null, (M_Subregion)null))
						select x.level.levelName.ToLower()).ToArray();
					if (array.Length == 0)
					{
						CommandConsoleAccessor.EchoToConsole("Failed to generate levels for regions:\n- " + handle.Join());
					}
					else
					{
						CommandConsoleAccessor.EchoToConsole("Loading regions:\n- " + handle.Join() + "\n");
						CommandConsoleAccessor.EchoToConsole("levels:\n- " + string.Join("\n- ", array));
						CL_GameManager.gMan.LoadLevels(array);
					}
				}
				catch
				{
					CommandConsoleAccessor.EchoToConsole("Failed to generate levels for regions:\n- " + handle.Join());
				}
			};
		}
	}
	public sealed class LoadSubregionCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "loadsubregions" };

		public override CommandTag Tag => CommandTag.World;

		public override string Description => "Load all subregion levels by subregion name, filtered by `arg`";

		public override bool EnablesCheatsOnUse => false;

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)delegate(CommandAutocomplete autocomplete)
			{
				AutocompleteHelpers.VariadicFrom(autocomplete, Prefabs.Subregions);
			}).AutocompleteValidator((Action<CommandValidator>)delegate(CommandValidator validator)
			{
				AutocompleteHelpers.ValidateVariadicFrom(validator, Prefabs.Subregions);
			});
		}

		public override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				Handle<M_Subregion> handle = Prefabs.SubregionProvider().FromCommandMany(args);
				if (handle != null && handle.Count() != 0)
				{
					string[] array = (from x in handle.Data().SelectMany((M_Subregion x) => x.levelReferences)
						select ((Object)x.level).name.ToLower()).ToArray();
					if (array.Length == 0)
					{
						CommandConsoleAccessor.EchoToConsole("Failed to get levels for subregions:\n- " + handle.Join());
					}
					else
					{
						CommandConsoleAccessor.EchoToConsole("Loading subregions:\n- " + handle.Join());
						CommandConsoleAccessor.EchoToConsole("levels:\n- " + string.Join("\n- ", array));
						CL_GameManager.gMan.LoadLevels(array);
					}
				}
			};
		}
	}
	public sealed class ManCommand : CommandBase
	{
		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 EnablesCheatsOnUse => false;

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)AutocompleteCommand).AutocompleteValidator((Action<CommandValidator>)ValidateCommand);
		}

		private static void AutocompleteCommand(CommandAutocomplete autocomplete)
		{
			if (autocomplete.activeArg == 0)
			{
				List<string> list = new List<string>();
				list.AddRange(CommandRegistry.GetAllCommands().SelectMany((ICommand command) => command.Aliases));
				autocomplete.FromArray((IReadOnlyList<string>)new <>z__ReadOnlyList<string>(list));
			}
			else
			{
				autocomplete.Reject();
			}
		}

		private static void ValidateCommand(CommandValidator validator)
		{
			string value = validator.ArgumentAt(validator.activeArg);
			if (validator.activeArg != 0 || !CommandRegistry.GetAllCommands().Any((ICommand command) => command.Aliases.Contains(value)))
			{
				validator.Reject();
			}
		}

		public override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				foreach (ICommand item in from x in CommandRegistry.GetAllCommands()
					orderby (Tag: x.Tag, x.Aliases[0])
					select x)
				{
					if (args.Length == 0 || item.Aliases.Contains(args[0]))
					{
						CommandConsoleAccessor.EchoToConsole(Colors.FormatCommand(item));
					}
				}
			};
		}
	}
	public sealed class NoclipSpeed : CommandBase
	{
		public override string[] Aliases => new string[2] { "ns", "noclipspeed" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "set noclip speed multiplier (1 is default)";

		public override bool EnablesCheatsOnUse => true;

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)AutocompleteHelpers.OptionalSingleFloat).AutocompleteValidator((Action<CommandValidator>)AutocompleteHelpers.ValidateOptionalSingleFloat).OverValue((Func<object>)(() => ENT_Player_Movement_Patcher.NoclipSpeedMultiplier));
		}

		public override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				float result;
				if (args.Length == 0)
				{
					ENT_Player_Movement_Patcher.NoclipSpeedMultiplier = 1f;
					CommandConsoleAccessor.EchoToConsole("Noclip speed set to default");
				}
				else if (float.TryParse(args[0], out result))
				{
					ENT_Player_Movement_Patcher.NoclipSpeedMultiplier = result;
					CommandConsoleAccessor.EchoToConsole($"Noclip speed set to {result:F1}");
				}
				else
				{
					CommandConsoleAccessor.EchoToConsole("Invalid arguments for noclipspeed command: " + GeneralExtensions.Join<string>((IEnumerable<string>)args, (Func<string, string>)null, " "));
				}
			};
		}

		public override void OnExit()
		{
			ENT_Player_Movement_Patcher.NoclipSpeedMultiplier = 1f;
		}
	}
	public sealed class SpeedyPerksCommand : 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] { "speedyperks" };

		public override CommandTag Tag => CommandTag.Player;

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

		public override bool EnablesCheatsOnUse => true;

		public override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				foreach (string movementPerk in MovementPerks)
				{
					PerkChanger.MaxOutPerk(movementPerk);
				}
				CommandConsoleAccessor.EchoToConsole("Movement perks given");
			};
		}
	}
	public sealed class SpidermanCommand : CommandBase
	{
		public override string[] Aliases => new string[1] { "spiderman" };

		public override CommandTag Tag => CommandTag.Player;

		public override string Description => "Give infinite barnacle hooks to both hands";

		public override bool EnablesCheatsOnUse => true;

		public override Action<string[]> GetLogicCallback()
		{
			return delegate
			{
				CommandConsole.instance.ExecuteCommand("left item_barnaclehook_infinite; right item_barnaclehook_infinite", true);
			};
		}
	}
	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" },
			{ "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 EnablesCheatsOnUse => true;

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)AutocompleteLocation).AutocompleteValidator((Action<CommandValidator>)ValidateLocation);
		}

		private static void AutocompleteLocation(CommandAutocomplete autocomplete)
		{
			if (autocomplete.activeArg == 0)
			{
				autocomplete.FromArray((IReadOnlyList<string>)new <>z__ReadOnlyArray<string>(Locations.Keys.ToArray()));
			}
			else
			{
				autocomplete.Reject();
			}
		}

		private static void ValidateLocation(CommandValidator validator)
		{
			string value = validator.ArgumentAt(validator.activeArg);
			if (validator.activeArg != 0 || !Locations.Keys.Any((string x) => x.Contains(value.ToLower())))
			{
				validator.Reject();
			}
		}

		public override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				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");
						}
						if ((Object)(object)WorldLoader.instance == (Object)null)
						{
							CommandConsoleAccessor.EchoToConsole("No world loader found");
						}
						else
						{
							WorldLoader.instance.TeleportPlayerToTargetLevel(new string[1] { list[0] });
							CommandConsoleAccessor.EchoToConsole("Teleported to " + Colors.Highlighted(list[0]));
						}
					}
				}
			};
		}
	}
	public sealed class WallhackCommand : CommandBase
	{
		public override string[] Aliases => new string[2] { "wallhack", "wh" };

		public override CommandTag Tag => CommandTag.World;

		public override string Description => "Add outlines to any game entity\n wh [entity] (optional color like 'red', 'green' or '#RRGGBB')\nentity is searched by substring\nwithout params will toggle default behaviour";

		public override bool EnablesCheatsOnUse => true;

		public override void ConfigureBuilder(CommandBuilder builder)
		{
			builder.AutocompleteCustom((Action<CommandAutocomplete>)AutocompleteArgs).AutocompleteValidator((Action<CommandValidator>)ValidateArgs);
		}

		private static void AutocompleteArgs(CommandAutocomplete autocomplete)
		{
			switch (autocomplete.activeArg)
			{
			case 0:
				autocomplete.FromArray((IReadOnlyList<string>)AutocompleteHelpers.Names(Prefabs.Entities));
				break;
			case 1:
				autocomplete.FromArray((IReadOnlyList<string>)AutocompleteHelpers.ColorValues);
				break;
			default:
				autocomplete.Reject();
				break;
			}
		}

		private static void ValidateArgs(CommandValidator validator)
		{
			string text = validator.ArgumentAt(validator.activeArg);
			switch (validator.activeArg)
			{
			case 0:
				if (AutocompleteHelpers.HasMatch(Prefabs.Entities, text))
				{
					return;
				}
				break;
			case 1:
			{
				Color val = default(Color);
				if (ColorUtility.TryParseHtmlString(text, ref val))
				{
					return;
				}
				break;
			}
			}
			validator.Reject();
		}

		public override Action<string[]> GetLogicCallback()
		{
			return delegate(string[] args)
			{
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: 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_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
				if (args.Length == 0)
				{
					if (OutlinesController.ToggleDefault())
					{
						CommandConsoleAccessor.EchoToConsole("Switching wallhacks to default mode");
					}
					else
					{
						CommandConsoleAccessor.EchoToConsole("Switching wallhacks off");
					}
				}
				else
				{
					string text = Prefabs.Entities().Filter(args[0]).AnyName();
					if (text == null)
					{
						CommandConsoleAccessor.EchoToConsole("No such entity found: " + args[0]);
					}
					else
					{
						bool flag = args.Length == 2;
						Color color = Random.ColorHSV();
						if (flag && !ColorUtility.TryParseHtmlString(args[1], ref color))
						{
							CommandConsoleAccessor.EchoToConsole("Failed to parse color " + args[1]);
						}
						else if (OutlinesController.IsEnabled(text))
						{
							if (flag)
							{
								color = OutlinesController.SetColor(text, color);
								CommandConsoleAccessor.EchoToConsole("Changed outlines for " + Colors.Tagged(text, color) + ", color: " + Colors.Tagged(Colors.Str(color), color));
							}
							else
							{
								OutlinesController.DisableOutlines(text);
								CommandConsoleAccessor.EchoToConsole("Disabled outlines for: " + text);
							}
						}
						else
						{
							color = OutlinesController.EnableOutlines(text, color, !flag);
							CommandConsoleAccessor.EchoToConsole("Enabled outlines for " + Colors.Tagged(text, color) + ", color: " + Colors.Tagged(Colors.Str(color), color));
						}
					}
				}
			};
		}

		public override void OnExit()
		{
			OutlinesController.ClearAll();
		}
	}
}
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 IDictionary GetCommands(CommandConsole instance)
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(CommandConsole), "states");
			object value = fieldInfo.GetValue(instance);
			object obj = fieldInfo.FieldType.GetMethod("Peek").Invoke(value, null);
			FieldInfo fieldInfo2 = AccessTools.Field(AccessTools.Inner(typeof(CommandConsole), "CommandLineState"), "commands");
			return (IDictionary)fieldInfo2.GetValue(obj);
		}

		public static void EnsureCheatsAreEnabled()
		{
			if (!CommandConsole.hasCheated)
			{
				CommandConsole instance = CommandConsole.instance;
				if ((Object)(object)instance == (Object)null)
				{
					Plugin.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)
			{
				Plugin.Beep.LogWarning((object)"CommandConsoleAccessor::EnableCheats instance is null");
			}
			else
			{
				AddMessageToHistory(instance, msg);
			}
		}
	}
}