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 : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { 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.Count => _items.Length; T IReadOnlyList.this[int index] => _items[index]; int ICollection.Count => _items.Length; bool ICollection.IsReadOnly => true; T IList.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 IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return ((ICollection)_items).Contains(item); } void ICollection.CopyTo(T[] array, int arrayIndex) { ((ICollection)_items).CopyTo(array, arrayIndex); } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { return ((IList)_items).IndexOf(item); } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } } [CompilerGenerated] internal sealed class <>z__ReadOnlyList : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { 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.Count => _items.Count; T IReadOnlyList.this[int index] => _items[index]; int ICollection.Count => _items.Count; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyList(List 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 IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return _items.Contains(item); } void ICollection.CopyTo(T[] array, int arrayIndex) { _items.CopyTo(array, arrayIndex); } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { return _items.IndexOf(item); } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.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 = "+"; public const string COMMAND_SEP = "---------------------"; 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 "" + s + ""; } 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 ? "+" : "-"); return text + " " + Tagged(GeneralExtensions.Join((IEnumerable)c.Aliases, (Func)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 Levels() { return _levels.Handle(); } public static Levels LevelProvider() { return _levels; } public static Handle Regions() { return _regions.Handle(); } public static Regions RegionProvider() { return _regions; } public static Handle Subregions() { return _subregions.Handle(); } public static Subregions SubregionProvider() { return _subregions; } public static Handle Entities() { return _entities.Handle(); } public static Entities EntityProvider() { return _entities; } public static Handle Items() { return _items.Handle(); } public static Items ItemProvider() { return _items; } } public abstract class HandleProvider { public abstract Func Name { get; } public virtual Func Finalizer { get; } = (T obj) => obj; public abstract Handle 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 FromCommandMany(string[] args) { if (args.Length == 0) { CommandConsoleAccessor.EchoToConsole("Available " + typeof(T).Name + ":\n- " + Handle().Join()); return new Handle(Array.Empty(), Name, Finalizer); } List list = new List(); foreach (string text in args) { Handle 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(Array.Empty(), Name, Finalizer); } list.Add(val); } return new Handle(list, Name, Finalizer); } } public class Handle { private readonly IEnumerable _data; private readonly Func _nameGetter; private readonly Func _finalizer; public Handle(IEnumerable d, Func nameGetter, Func finalizer) { _data = d; _nameGetter = (T x) => nameGetter(x)?.ToLower() ?? null; _finalizer = finalizer; base..ctor(); } public Handle Filter(string filter) { return new Handle(_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 ToList() { return _data.ToList(); } public IEnumerable 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 { public override Func Name { get; } = (GameEntity x) => x?.entityPrefabID?.ToLower() ?? null; public override Handle Handle() { return new Handle(CL_GameManager.gMan?.gameEntityPrefabs ?? new List(), Name, base.Finalizer); } } public class Items : HandleProvider { private List _items = new List(); public override Func Name { get; } = (Item x) => x?.prefabName?.ToLower() ?? null; public override Func Finalizer { get; } = (Item obj) => obj.GetClone((Item)null, false); public void Initialize(List items) { _items = items; } public void InitializeFromAssetDatabase() { List itemPrefabs = CL_AssetManager.GetFullCombinedAssetDatabase().itemPrefabs; foreach (GameObject item in itemPrefabs) { Item_Object component = item.GetComponent(); if ((Object)(object)component != (Object)null) { _items.Add(component.itemData); } } } public override Handle Handle() { if (_items.Count == 0) { InitializeFromAssetDatabase(); } return new Handle(_items, Name, Finalizer); } } public class Levels : HandleProvider { private List _levels = new List(); private readonly Dictionary> _regions = new Dictionary>(); private readonly Dictionary> _subregions = new Dictionary>(); public override Func 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(); _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(); _subregions[level.subRegion] = value2; } value2.Add(level); } } } public override Handle Handle() { if (_levels.Count == 0) { Initialize(); } return new Handle(_levels, Name, base.Finalizer); } public Handle Regional(M_Region region) { if (_levels.Count == 0) { Initialize(); } return new Handle(_regions[region], Name, base.Finalizer); } public Handle Subregional(M_Subregion subregion) { if (_levels.Count == 0) { Initialize(); } return new Handle(_subregions[subregion], Name, base.Finalizer); } } public class Regions : HandleProvider { private List _regions = new List(); public override Func 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 Handle() { if (_regions.Count == 0) { Initialize(); } return new Handle(_regions, Name, base.Finalizer); } } public class Subregions : HandleProvider { private List _subregions = new List(); public override Func 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 Handle() { if (_subregions.Count == 0) { Initialize(); } return new Handle(_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 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 dictionary = new Dictionary(); foreach (GameObject item in enumerable) { GameEntity componentInChildren = item.GetComponentInChildren(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(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 gManRef = AccessTools.FieldRefAccess("gMan"); public static readonly FieldRef moveAxisRef = AccessTools.FieldRefAccess("moveAxis"); public static readonly FieldRef velRef = AccessTools.FieldRefAccess("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 ExcludeFromAlwaysSpawn = new HashSet { "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 _trackedEntitiesIds = new Dictionary(); private static Dictionary _activeOutlines = new Dictionary(); private static readonly Dictionary _defaultOutlines = new Dictionary { { "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(_activeOutlines.Keys, StringComparer.OrdinalIgnoreCase).SetEquals(_defaultOutlines.Keys)) { _activeOutlines.Clear(); } else { _activeOutlines = ObjectExtensions.Copy>(_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((IDictionary)_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(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 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(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 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 _cache = new Dictionary(); 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)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(CommandAutocomplete autocomplete, Func> getHandle) { if (autocomplete.activeArg == 0) { autocomplete.FromArray((IReadOnlyList)Names(getHandle)); } else { autocomplete.Reject(); } } public static void ValidateOptionalSingleFrom(CommandValidator validator, Func> getHandle) { if (validator.activeArg != 0 || !HasMatch(getHandle, validator.ArgumentAt(validator.activeArg))) { validator.Reject(); } } public static void VariadicFrom(CommandAutocomplete autocomplete, Func> getHandle) { autocomplete.FromArray((IReadOnlyList)Names(getHandle)); } public static void ValidateVariadicFrom(CommandValidator validator, Func> getHandle) { if (!HasMatch(getHandle, validator.ArgumentAt(validator.activeArg))) { validator.Reject(); } } public static string[] Names(Func> getHandle) { return (from x in getHandle().Names() where !string.IsNullOrWhiteSpace(x) select x).ToArray(); } public static bool HasMatch(Func> 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 GetCallback(bool withSuffix = true); Action 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 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("---------------------"); } 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 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)AutocompleteHelpers.OptionalSingleBool).AutocompleteValidator((Action)AutocompleteHelpers.ValidateOptionalSingleBool).OverValue((Func)(() => 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 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 RegisteredCommands = new List(); 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 dictionary = new Dictionary(); 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>((IEnumerable>)dictionary, (Func, string>)((KeyValuePair x) => "\t" + x.Key + " taken by " + x.Value), "\n"))); } else { RegisteredCommands.Add(command); } } public static List GetAllCommands() { return RegisteredCommands.OrderBy((ICommand c) => c.Aliases[0]).ToList(); } public static List GetCommandsByTag(CommandTag tag) { return RegisteredCommands.Where((ICommand c) => c.Tag == tag).ToList(); } public static ICommand GetCommand() where T : ICommand { return RegisteredCommands.FirstOrDefault((ICommand c) => c.GetType() == typeof(T)); } public static Action GetCallback(bool withSuffix = true) where T : ICommand { return RegisteredCommands.FirstOrDefault((ICommand c) => c.GetType() == typeof(T))?.GetCallback(withSuffix) ?? ((Action)delegate { Plugin.Beep.LogWarning((object)$"Command {typeof(T)} not found"); }); } public static Action GetLogicCallback() where T : ICommand { return RegisteredCommands.FirstOrDefault((ICommand c) => c.GetType() == typeof(T))?.GetLogicCallback() ?? ((Action)delegate { Plugin.Beep.LogWarning((object)$"Command {typeof(T)} not found"); }); } public static void SetTogglable(bool enabled) where T : ICommand { if (!(GetCommand() 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(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 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 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 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(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 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 GetLogicCallback() { return delegate { CommandRegistry.SetTogglable(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 GetLogicCallback() { return delegate { CommandRegistry.SetTogglable(base.Enabled); CommandRegistry.SetTogglable(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 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)delegate(CommandAutocomplete autocomplete) { AutocompleteHelpers.OptionalSingleFrom(autocomplete, Prefabs.Items); }).AutocompleteValidator((Action)delegate(CommandValidator validator) { AutocompleteHelpers.ValidateOptionalSingleFrom(validator, Prefabs.Items); }); } public override Action 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)delegate(CommandAutocomplete autocomplete) { AutocompleteHelpers.OptionalSingleFrom(autocomplete, Prefabs.Items); }).AutocompleteValidator((Action)delegate(CommandValidator validator) { AutocompleteHelpers.ValidateOptionalSingleFrom(validator, Prefabs.Items); }); } public override Action 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)delegate(CommandAutocomplete autocomplete) { AutocompleteHelpers.OptionalSingleFrom(autocomplete, Prefabs.Items); }).AutocompleteValidator((Action)delegate(CommandValidator validator) { AutocompleteHelpers.ValidateOptionalSingleFrom(validator, Prefabs.Items); }); } public override Action 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 GravityMultRef = AccessTools.FieldRefAccess("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)AutocompleteHelpers.OptionalSingleFloat).AutocompleteValidator((Action)AutocompleteHelpers.ValidateOptionalSingleFloat).OverValue((Func)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 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((IEnumerable)args, (Func)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 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)delegate(CommandAutocomplete autocomplete) { AutocompleteHelpers.OptionalSingleFrom(autocomplete, Prefabs.Entities); }).AutocompleteValidator((Action)delegate(CommandValidator validator) { AutocompleteHelpers.ValidateOptionalSingleFrom(validator, Prefabs.Entities); }); } public override Action 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)delegate(CommandAutocomplete autocomplete) { AutocompleteHelpers.OptionalSingleFrom(autocomplete, Prefabs.Items); }).AutocompleteValidator((Action)delegate(CommandValidator validator) { AutocompleteHelpers.ValidateOptionalSingleFrom(validator, Prefabs.Items); }); } public override Action 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)AutocompletePerks).AutocompleteValidator((Action)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 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 + "\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)delegate(CommandAutocomplete autocomplete) { AutocompleteHelpers.OptionalSingleFrom(autocomplete, Prefabs.Regions); }).AutocompleteValidator((Action)delegate(CommandValidator validator) { AutocompleteHelpers.ValidateOptionalSingleFrom(validator, Prefabs.Regions); }); } public override Action 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)delegate(CommandAutocomplete autocomplete) { AutocompleteHelpers.OptionalSingleFrom(autocomplete, Prefabs.Subregions); }).AutocompleteValidator((Action)delegate(CommandValidator validator) { AutocompleteHelpers.ValidateOptionalSingleFrom(validator, Prefabs.Subregions); }); } public override Action 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 GetLogicCallback() { return delegate { IEnumerable 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 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 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)delegate(CommandAutocomplete autocomplete) { AutocompleteHelpers.VariadicFrom(autocomplete, Prefabs.Regions); }).AutocompleteValidator((Action)delegate(CommandValidator validator) { AutocompleteHelpers.ValidateVariadicFrom(validator, Prefabs.Regions); }); } public override Action GetLogicCallback() { return delegate(string[] args) { Handle 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)delegate(CommandAutocomplete autocomplete) { AutocompleteHelpers.VariadicFrom(autocomplete, Prefabs.Subregions); }).AutocompleteValidator((Action)delegate(CommandValidator validator) { AutocompleteHelpers.ValidateVariadicFrom(validator, Prefabs.Subregions); }); } public override Action GetLogicCallback() { return delegate(string[] args) { Handle 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)AutocompleteCommand).AutocompleteValidator((Action)ValidateCommand); } private static void AutocompleteCommand(CommandAutocomplete autocomplete) { if (autocomplete.activeArg == 0) { List list = new List(); list.AddRange(CommandRegistry.GetAllCommands().SelectMany((ICommand command) => command.Aliases)); autocomplete.FromArray((IReadOnlyList)new <>z__ReadOnlyList(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 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)AutocompleteHelpers.OptionalSingleFloat).AutocompleteValidator((Action)AutocompleteHelpers.ValidateOptionalSingleFloat).OverValue((Func)(() => ENT_Player_Movement_Patcher.NoclipSpeedMultiplier)); } public override Action 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((IEnumerable)args, (Func)null, " ")); } }; } public override void OnExit() { ENT_Player_Movement_Patcher.NoclipSpeedMultiplier = 1f; } } public sealed class SpeedyPerksCommand : CommandBase { private static List MovementPerks = new List(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 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 GetLogicCallback() { return delegate { CommandConsole.instance.ExecuteCommand("left item_barnaclehook_infinite; right item_barnaclehook_infinite", true); }; } } public sealed class TeleportCommand : CommandBase { private static readonly Dictionary Locations = new Dictionary { { "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)AutocompleteLocation).AutocompleteValidator((Action)ValidateLocation); } private static void AutocompleteLocation(CommandAutocomplete autocomplete) { if (autocomplete.activeArg == 0) { autocomplete.FromArray((IReadOnlyList)new <>z__ReadOnlyArray(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 GetLogicCallback() { return delegate(string[] args) { if (args.Length == 0) { CommandConsoleAccessor.EchoToConsole("Available locations:\n- " + GeneralExtensions.Join((IEnumerable)Locations.Keys, (Func)null, "\n- ")); } else { List list = new List(); foreach (KeyValuePair 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)AutocompleteArgs).AutocompleteValidator((Action)ValidateArgs); } private static void AutocompleteArgs(CommandAutocomplete autocomplete) { switch (autocomplete.activeArg) { case 0: autocomplete.FromArray((IReadOnlyList)AutocompleteHelpers.Names(Prefabs.Entities)); break; case 1: autocomplete.FromArray((IReadOnlyList)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 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 EnableCheatsRaw = AccessTools.MethodDelegate>(AccessTools.Method(typeof(CommandConsole), "EnableCheatsCommand", new Type[1] { typeof(string[]) }, (Type[])null), (object)null, true); private static readonly Action AddMessageToHistory = AccessTools.MethodDelegate>(AccessTools.Method(typeof(CommandConsole), "AddMessageToHistory", new Type[1] { typeof(string) }, (Type[])null), (object)null, true); private static readonly Action 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); } } } }