using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreCommands.Accessors;
using MoreCommands.Commands;
using MoreCommands.Common;
using 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.11.2.0")]
[assembly: AssemblyInformationalVersion("0.11.2+ec5d1334db5a93911acc2dbbc4ffb1c1bdbc2ee3")]
[assembly: AssemblyProduct("MoreCommands")]
[assembly: AssemblyTitle("MoreCommands")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.11.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public static class 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.CheatsOnly ? "<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.11.2")]
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.11.2";
}
}
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();
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 obj in CL_AssetManager.GetFullCombinedAssetDatabase().levelPrefabs
select obj.GetComponent<M_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.levels?.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 baseAssetDatabase = CL_AssetManager.GetBaseAssetDatabase();
IEnumerable<GameObject> enumerable = (from x in baseAssetDatabase.entityPrefabs.Concat(baseAssetDatabase.denizenPrefabs).Concat(baseAssetDatabase.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 value = item.GetComponentInChildren<GameEntity>() ?? item.AddComponent<GameEntity>();
dictionary.TryAdd(((Object)item).name.ToLower(), value);
}
__instance.gameEntityPrefabs = dictionary.Values.ToList();
}
}
[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)
{
foreach (ICommand item in CommandRegistry.GetCommandsByTag(CommandTag.Console))
{
string[] aliases = item.Aliases;
foreach (string text in aliases)
{
CommandConsole.RemoveCommand(text);
CommandConsole.AddCommand(text, item.GetCallback(), false);
}
}
foreach (ICommand item2 in CommandRegistry.GetCommandsByTag(CommandTag.World))
{
string[] aliases2 = item2.Aliases;
foreach (string text2 in aliases2)
{
CommandConsole.RemoveCommand(text2);
CommandConsole.AddCommand(text2, item2.GetCallback(), false);
}
}
}
[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';
}
}
}
[HarmonyPatch(typeof(CommandConsole), "RegisterCommand")]
public static class CommandConsole_RegisterCommand_Patcher
{
[HarmonyPrefix]
public static bool DoNotOverrideExistingCommands(CommandConsole __instance, ref string command)
{
if (command == null || (Object)(object)CommandConsole.instance == (Object)null || (Object)(object)__instance == (Object)null)
{
return false;
}
Dictionary<string, Command> dictionary = CommandConsoleAccessor.commandsRef.Invoke(CommandConsole.instance);
return !dictionary.ContainsKey(command);
}
}
[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)
{
foreach (ICommand item in CommandRegistry.GetCommandsByTag(CommandTag.Player))
{
string[] aliases = item.Aliases;
foreach (string text in aliases)
{
CommandConsole.AddCommand(text, item.GetCallback(), false);
}
}
}
}
[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)
{
//IL_002e: 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_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_003c: 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_0048: Unknown result type (might be due to invalid IL or missing references)
Plugin.Assert(entityIdLower == entityIdLower.ToLower());
Plugin.Assert(!IsEnabled(entityIdLower));
Color val2 = (_activeOutlines[entityIdLower] = DictionaryExtensions.Get<string, Color>((IDictionary<string, Color>)_defaultOutlines, entityIdLower, color));
Color result = val2;
RefreshAll();
return result;
}
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)
{
if (!((Object)(object)entity == (Object)null) && !_trackedEntitiesIds.ContainsKey(entity) && Prefabs.Entities().Names().Contains(entity.entityPrefabID.ToLower()))
{
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] = entity.entityPrefabID.ToLower();
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_001f: Unknown result type (might be due to invalid IL or missing references)
Color value;
bool flag = _activeOutlines.TryGetValue(entity.entityPrefabID.ToLower(), 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 num = list.RemoveAll((Material m) => (Object)(object)m != (Object)null && ((Object)m.shader).name == "GUI/Text Shader");
if (num > 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 interface ICommand
{
string[] Aliases { get; }
CommandTag Tag { get; }
string Description { get; }
bool CheatsOnly { 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 CheatsOnly { get; }
public abstract Action<string[]> GetLogicCallback();
public virtual void OnExit()
{
}
public void EnsureCheats(string[] args)
{
if (CheatsOnly)
{
CommandConsoleAccessor.EnsureCheatsAreEnabled();
}
}
public void PrintSuffix(string[] args)
{
CommandConsoleAccessor.EchoToConsole("<color=grey>---------------------</color>");
}
public virtual Action<string[]> GetCallback(bool withSuffix = true)
{
return (Action<string[]>)Delegate.Combine((Action<string[]>)Delegate.Combine(new Action<string[]>(EnsureCheats), GetLogicCallback()), withSuffix ? new Action<string[]>(PrintSuffix) : ((Action<string[]>)delegate
{
}));
}
}
public abstract class TogglableCommandBase : CommandBase, ITogglableCommand, ICommand
{
public bool Enabled { get; set; }
public string EnabledStr => Enabled ? "enabled" : "disabled";
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 (Action<string[]>)Delegate.Combine((Action<string[]>)Delegate.Combine((Action<string[]>)Delegate.Combine((Action<string[]>)Delegate.Combine(new Action<string[]>(UpdateEnabled), new Action<string[]>(base.EnsureCheats)), GetLogicCallback()), new Action<string[]>(PrintEnabled)), withSuffix ? new Action<string[]>(base.PrintSuffix) : ((Action<string[]>)delegate
{
}));
}
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()
{
GetCallback(withSuffix: false)(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 GrubbyCommand());
Register(new ListEntitiesCommand());
Register(new ListItemsCommand());
Register(new ListLevelsCommand());
Register(new ListRegionsCommand());
Register(new ListSubregionsCommand());
Register(new LoadLevelsCommand());
Register(new LoadRandomLevelsCommand());
Register(new LoadRegionCommand());
Register(new LoadSubregionCommand());
Register(new ManCommand());
Register(new NoclipSpeed());
Register(new SpawnEntityCommand());
Register(new SpeedyPerksCommand());
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 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);
}
return;
}
Perk perkAsset = CL_AssetManager.GetPerkAsset(perkId, "");
if ((Object)(object)perkAsset != (Object)null)
{
Perk val = Object.Instantiate<Perk>(perkAsset);
int stackMax = val.stackMax;
if (stackMax > 0)
{
playerObject.AddPerk(val, stackMax);
}
}
else
{
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 CheatsOnly => 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 CheatsOnly => true;
public override Action<string[]> GetLogicCallback()
{
return delegate
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
Inventory.instance.AddItemToHand(Prefabs.Items().Filter("item_banhammer").Any(), 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 CheatsOnly => 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
};
playerObject.Buff(val);
}
else
{
playerObject.curBuffs.RemoveBuffContainer(BuffId);
}
}
};
}
}
public sealed class CargoCommand : CommandBase
{
public override string[] Aliases => new string[1] { "cargo" };
public override CommandTag Tag => CommandTag.Player;
public override string Description => "max backstrength";
public override bool CheatsOnly => true;
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 CheatsOnly => true;
public override Action<string[]> GetLogicCallback()
{
return (Action<string[]>)Delegate.Combine(CommandRegistry.GetCallback<FreerunCommand>(), (Action<string[]>)delegate
{
ENT_Player playerObject = ENT_Player.playerObject;
if (playerObject != null)
{
playerObject.Noclip(TogglableCommandBase.WhenEnabled(base.Enabled));
}
});
}
}
public sealed class FlashCommand : TogglableCommandBase
{
public override string[] Aliases => new string[1] { "flash" };
public override CommandTag Tag => CommandTag.Player;
public override string Description => "freerun + buff";
public override bool CheatsOnly => true;
public override Action<string[]> GetLogicCallback()
{
return (Action<string[]>)Delegate.Combine(CommandRegistry.GetCallback<FreerunCommand>(withSuffix: false), CommandRegistry.GetCallback<BuffCommand>(withSuffix: false));
}
}
public sealed class FreerunCommand : TogglableCommandBase
{
public override string[] Aliases => new string[1] { "freerun" };
public override CommandTag Tag => CommandTag.Player;
public override string Description => "godmode + deathgoo-stop + fullbright + infinitestamina + notarget";
public override bool CheatsOnly => true;
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 CheatsOnly => true;
public override Action<string[]> GetLogicCallback()
{
return delegate(string[] args)
{
//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_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)
Item val = Prefabs.ItemProvider().FromCommand(args);
if (val != null)
{
Inventory.instance.AddItemToInventoryScreen(new Vector3(0f, 0f, 1f) + Random.insideUnitSphere * 0.01f, val, true, false);
}
};
}
}
public sealed class GiveLeftCommand : CommandBase
{
public override string[] Aliases => new string[1] { "left" };
public override CommandTag Tag => CommandTag.Player;
public override string Description => "give item to left hand or inventory by its id with substring search";
public override bool CheatsOnly => true;
public override Action<string[]> GetLogicCallback()
{
return delegate(string[] args)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
Item val = Prefabs.ItemProvider().FromCommand(args);
if (val != null)
{
val.bagRotation = new Quaternion(1f, 2f, 3f, 4f);
Inventory.instance.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 CheatsOnly => true;
public override Action<string[]> GetLogicCallback()
{
return delegate(string[] args)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
Item val = Prefabs.ItemProvider().FromCommand(args);
if (val != null)
{
val.bagRotation = new Quaternion(1f, 2f, 3f, 4f);
Inventory.instance.AddItemToHand(val, 1);
}
};
}
}
public sealed class GravityCommand : CommandBase
{
public override string[] Aliases => new string[2] { "sv_gravity", "grav" };
public override CommandTag Tag => CommandTag.Player;
public override string Description => "set player gravity multiplier (1 is default)";
public override bool CheatsOnly => true;
public override Action<string[]> GetLogicCallback()
{
return delegate(string[] args)
{
ENT_Player playerObject = ENT_Player.playerObject;
float result;
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;
playerObject.SetGravityMult(1f);
}
}
public sealed class GrubbyCommand : TogglableCommandBase
{
private readonly string BuffId = "shishyando.WK.MoreCommands.grubbyCommand";
public override string[] Aliases => new string[1] { "grubby" };
public override CommandTag Tag => CommandTag.Player;
public override string Description => "grab anything";
public override bool CheatsOnly => true;
public override Action<string[]> GetLogicCallback()
{
return delegate
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
ENT_Player playerObject = ENT_Player.playerObject;
if (!((Object)(object)playerObject == (Object)null))
{
if (base.Enabled)
{
BuffContainer val = new BuffContainer
{
id = BuffId,
buffs = new List<Buff>(1)
{
new Buff
{
id = "grabAnything",
amount = 1E+09f,
maxAmount = 1E+09f
}
},
loseOverTime = false
};
playerObject.Buff(val);
}
else
{
playerObject.curBuffs.RemoveBuffContainer(BuffId);
}
}
};
}
}
public sealed class 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 CheatsOnly => false;
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 CheatsOnly => false;
public override Action<string[]> GetLogicCallback()
{
return delegate(string[] args)
{
CommandConsoleAccessor.EchoToConsole("- " + Prefabs.Items().Filter(args.FirstOrDefault() ?? "").Join());
};
}
}
public sealed class ListLevelsCommand : CommandBase
{
public override string[] Aliases => new string[1] { "listlevels" };
public override CommandTag Tag => CommandTag.Console;
public override string Description => "List levels, filtered by `arg`";
public override bool CheatsOnly => false;
public override Action<string[]> GetLogicCallback()
{
return delegate(string[] args)
{
CommandConsoleAccessor.EchoToConsole("- " + Prefabs.Levels().Filter(args.FirstOrDefault() ?? "").Join());
};
}
}
public sealed class BetterListPerksCommand : CommandBase
{
public override string[] Aliases => new string[2] { "lp", "listperks" };
public override CommandTag Tag => CommandTag.Console;
public override string Description => "List perks info, filtered by `arg`";
public override bool CheatsOnly => false;
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);
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 CheatsOnly => false;
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 CheatsOnly => false;
public override Action<string[]> GetLogicCallback()
{
return delegate(string[] args)
{
CommandConsoleAccessor.EchoToConsole("- " + Prefabs.Subregions().Filter(args.FirstOrDefault() ?? "").Join());
};
}
}
public sealed class LoadLevelsCommand : CommandBase
{
public override string[] Aliases => new string[1] { "loadlevels" };
public override CommandTag Tag => CommandTag.World;
public override string Description => "Load levels by its names with substring search";
public override bool CheatsOnly => false;
public override Action<string[]> GetLogicCallback()
{
return delegate(string[] args)
{
Handle<M_Level> handle = Prefabs.LevelProvider().FromCommandMany(args);
if (handle != null && handle.Count() != 0)
{
CommandConsoleAccessor.EchoToConsole("Loading levels:\n- " + handle.Join());
CL_GameManager.gMan.LoadLevels(handle.Names());
}
};
}
}
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-stop`, `deathgoo-height NaN`\nHave fun";
public override bool CheatsOnly => false;
public override Action<string[]> GetLogicCallback()
{
return delegate
{
IEnumerable<M_Level> source = Prefabs.Levels().Data();
int num = source.Count();
source = source.OrderBy((M_Level x) => Random.value).Take(Random.RandomRangeInt(0, num));
CL_GameManager.gMan.LoadLevels(source.Select((M_Level x) => ((Object)x).name.ToLower()).ToArray());
};
}
}
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 CheatsOnly => false;
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 ((Object)x).name.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 CheatsOnly => false;
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.levels)
select ((Object)x).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 CheatsOnly => false;
public override Action<string[]> GetLogicCallback()
{
return delegate(string[] args)
{
foreach (ICommand item in from x in CommandRegistry.GetAllCommands()
orderby (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 CheatsOnly => true;
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 SpawnEntityCommand : CommandBase
{
public override string[] Aliases => new string[2] { "spawn", "spawnentity" };
public override CommandTag Tag => CommandTag.World;
public override string Description => "Spawn entity by its prefab id with substring search";
public override bool CheatsOnly => true;
public override Action<string[]> GetLogicCallback()
{
return delegate(string[] args)
{
//IL_0029: 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_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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: 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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: 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)
GameEntity val = Prefabs.EntityProvider().FromCommand(args);
if (!((Object)(object)val == (Object)null))
{
Vector3 val2 = ((Component)Camera.main).transform.position + ((Component)Camera.main).transform.forward;
Quaternion identity = Quaternion.identity;
RaycastHit val3 = default(RaycastHit);
if (Physics.Raycast(((Component)Camera.main).transform.position, ((Component)Camera.main).transform.forward, ref val3, float.PositiveInfinity))
{
val2 = ((RaycastHit)(ref val3)).point;
identity = Quaternion.LookRotation(((RaycastHit)(ref val3)).normal);
GameEntity val4 = Object.Instantiate<GameEntity>(val, val2, identity);
if (val4.spawnWithBounds)
{
Collider component = ((Component)val4).GetComponent<Collider>();
if ((Object)(object)component != (Object)null)
{
Bounds bounds = component.bounds;
Vector3 normal = ((RaycastHit)(ref val3)).normal;
Vector3 extents = ((Bounds)(ref bounds)).extents;
Vector3 val5 = normal * ((Vector3)(ref extents)).magnitude;
Transform transform = ((Component)val4).transform;
transform.position += val5;
}
}
}
else
{
Object.Instantiate<GameObject>(((Component)val).gameObject, val2, identity);
}
}
};
}
}
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 CheatsOnly => true;
public override Action<string[]> GetLogicCallback()
{
return delegate
{
foreach (string movementPerk in MovementPerks)
{
PerkChanger.MaxOutPerk(movementPerk);
}
CommandConsoleAccessor.EchoToConsole("Movement perks given");
};
}
}
public sealed class TeleportCommand : CommandBase
{
private static readonly Dictionary<string, string> Locations = new Dictionary<string, string>
{
{ "intro", "m1_intro_01" },
{ "exp", "m1_silos_safearea_01" },
{ "prepipes", "campaign_interlude_silo_to_pipeworks" },
{ "elevator", "campaign_interlude_pipeworks_to_habitation_01" },
{ "teeth", "m3_habitation_shaft_intro" },
{ "pier", "m3_habitation_pier_entrance_01" },
{ "abyss", "m3_habitation_lab_ending" }
};
public override string[] Aliases => new string[1] { "tp" };
public override CommandTag Tag => CommandTag.Player;
public override string Description => "teleport to `arg`, no `arg` = list locations";
public override bool CheatsOnly => true;
public override Action<string[]> GetLogicCallback()
{
return delegate(string[] args)
{
ENT_Player playerObject = ENT_Player.playerObject;
if (args.Length == 0)
{
CommandConsoleAccessor.EchoToConsole("Available locations:\n- " + GeneralExtensions.Join<string>((IEnumerable<string>)Locations.Keys, (Func<string, string>)null, "\n- "));
}
else
{
List<string> list = new List<string>();
foreach (KeyValuePair<string, string> location in Locations)
{
if (location.Key.Contains(args[0].ToLower()))
{
list.Add(location.Value);
}
}
if (list.Count == 0)
{
CommandConsoleAccessor.EchoToConsole("No such tp option, available options:\n- " + string.Join("\n- ", Locations.Keys));
}
else
{
if (list.Count > 1)
{
CommandConsoleAccessor.EchoToConsole("Ambiguous place to tp: " + args[0] + " maps to " + string.Join(", ", list) + "\n teleporting to first");
}
WorldLoader.instance.TeleportPlayerToTargetLevel(new string[1] { list[0] });
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 CheatsOnly => true;
public override Action<string[]> GetLogicCallback()
{
return delegate(string[] args)
{
//IL_0092: 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)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: 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 if (OutlinesController.IsEnabled(text))
{
OutlinesController.DisableOutlines(text);
CommandConsoleAccessor.EchoToConsole("Disabled outlines for: " + text);
}
else
{
Color color = Random.ColorHSV();
if (args.Length == 2 && !ColorUtility.TryParseHtmlString(args[1], ref color))
{
CommandConsoleAccessor.EchoToConsole("Failed to parse color " + args[1]);
}
else
{
color = OutlinesController.EnableOutlines(text, color);
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
{
public static readonly FieldRef<CommandConsole, Dictionary<string, Command>> commandsRef = AccessTools.FieldRefAccess<CommandConsole, Dictionary<string, Command>>("commands");
private static readonly Action<CommandConsole, string[]> EnableCheatsRaw = AccessTools.MethodDelegate<Action<CommandConsole, string[]>>(AccessTools.Method(typeof(CommandConsole), "EnableCheatsCommand", new Type[1] { typeof(string[]) }, (Type[])null), (object)null, true);
private static readonly Action<CommandConsole, string> AddMessageToHistory = AccessTools.MethodDelegate<Action<CommandConsole, string>>(AccessTools.Method(typeof(CommandConsole), "AddMessageToHistory", new Type[1] { typeof(string) }, (Type[])null), (object)null, true);
private static readonly Action<CommandConsole> CheatsEnabler = delegate(CommandConsole inst)
{
EnableCheatsRaw(inst, new string[1] { "true" });
};
public static void EnsureCheatsAreEnabled()
{
if (!CommandConsole.hasCheated)
{
CommandConsole instance = CommandConsole.instance;
if ((Object)(object)instance == (Object)null)
{
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);
}
}
}
}