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.Configuration; using BepInEx.Logging; using CommandsExtended.Behaviors; using CommandsExtended.Commands; using CommandsExtended.Commands.Common; using CommandsExtended.Commands.CustomCrosshair; using CommandsExtended.Common; using CommandsExtended.Patches; using HarmonyLib; using Microsoft.CodeAnalysis; using MoreCommands; using MoreCommands.Accessors; using MoreCommands.Common; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CommandsExtended")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("An extension to MoreCommands")] [assembly: AssemblyFileVersion("0.5.0.0")] [assembly: AssemblyInformationalVersion("0.5.0+d50c170aceb9b1d4b85fd3d154bf5a2d77fca87f")] [assembly: AssemblyProduct("CommandsExtended")] [assembly: AssemblyTitle("CommandsExtended")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.5.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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; } } } namespace CommandsExtended { [BepInPlugin("dotlake.CommandsExtended", "CommandsExtended", "0.5.0")] [BepInDependency("shishyando.WK.MoreCommands", "0.13.0")] public class Plugin : BaseUnityPlugin { public static ManualLogSource Logger; public void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; LoadConfig(); Harmony val = new Harmony("dotlake.CommandsExtended"); val.PatchAll(); Registry.RegisterAll(); OnApplicationFocus(hasFocus: true); Logger.LogInfo((object)"dotlake.CommandsExtended is loaded"); } public static void Assert(bool condition) { if (!condition) { Logger.LogFatal((object)"Assert failed"); throw new Exception("[CommandsExtended] Assert failed"); } } private void OnApplicationFocus(bool hasFocus) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (hasFocus && ResolutionPatch.Enabled != null && ResolutionPatch.Enabled.Value) { Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != null) { Global.RefreshAllSettings(); } } } private void LoadConfig() { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) ResolutionPatch.Enabled = ((BaseUnityPlugin)this).Config.Bind("FullscreenExclusive", "Enabled", false, "Is exclusive fullscreen override active"); ResolutionPatch.CustomResActive = ((BaseUnityPlugin)this).Config.Bind("FullscreenExclusive", "CustomResActive", false, "Define custom resolution"); ResolutionPatch.Width = ((BaseUnityPlugin)this).Config.Bind("FullscreenExclusive", "Width", 1920, "Resolution width"); ResolutionPatch.Height = ((BaseUnityPlugin)this).Config.Bind("FullscreenExclusive", "Height", 1080, "Resolution height"); CrosshairPatch.Enabled = ((BaseUnityPlugin)this).Config.Bind("CustomCrosshair", "Enabled", false, "Is custom crosshair enabled"); CrosshairPatch.CrosshairColor = ((BaseUnityPlugin)this).Config.Bind("CustomCrosshair", "Color", Color.green, "Crosshair color and transparency"); CrosshairPatch.InvertBehind = ((BaseUnityPlugin)this).Config.Bind("CustomCrosshair", "InvertBehind", false, "Is image behind crosshair inverted"); CrosshairPatch.Length = ((BaseUnityPlugin)this).Config.Bind("CustomCrosshair", "Length", 25f, "Length of crosshair lines"); CrosshairPatch.Thickness = ((BaseUnityPlugin)this).Config.Bind("CustomCrosshair", "Thickness", 25f, "Thickness of crosshair lines"); CrosshairPatch.Gap = ((BaseUnityPlugin)this).Config.Bind("CustomCrosshair", "Gap", 25f, "Gap distance of crosshair lines from center"); CrosshairPatch.DotScale = ((BaseUnityPlugin)this).Config.Bind("CustomCrosshair", "DotScale", 25f, "Scale of the center crosshair dot"); } } public static class Registry { public static void RegisterAll() { CommandRegistry.Register((ICommand)(object)new Raycast()); CommandRegistry.Register((ICommand)(object)new ShowGrabs()); CommandRegistry.Register((ICommand)(object)new Marathon()); CommandRegistry.Register((ICommand)(object)new Fov()); CommandRegistry.Register((ICommand)(object)new Volume()); CommandRegistry.Register((ICommand)(object)new Music()); CommandRegistry.Register((ICommand)(object)new Sensitivity()); CommandRegistry.Register((ICommand)(object)new ClearBuffs()); CommandRegistry.Register((ICommand)(object)new ClearPerks()); CommandRegistry.Register((ICommand)(object)new ClearAll()); CommandRegistry.Register((ICommand)(object)new Playground()); CommandRegistry.Register((ICommand)(object)new HandScale()); CommandRegistry.Register((ICommand)(object)new FullscreenExclusive()); CommandRegistry.Register((ICommand)(object)new CustomCrosshair()); CommandRegistry.Register((ICommand)(object)new CrosshairColor()); CommandRegistry.Register((ICommand)(object)new CrosshairInvert()); CommandRegistry.Register((ICommand)(object)new CrosshairDot()); CommandRegistry.Register((ICommand)(object)new CrosshairGap()); CommandRegistry.Register((ICommand)(object)new CrosshairLength()); CommandRegistry.Register((ICommand)(object)new CrosshairScale()); CommandRegistry.Register((ICommand)(object)new CrosshairThickness()); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "dotlake.CommandsExtended"; public const string PLUGIN_NAME = "CommandsExtended"; public const string PLUGIN_VERSION = "0.5.0"; } } namespace CommandsExtended.Patches { [HarmonyPatch(typeof(UI_CrosshairController))] public static class CrosshairPatch { public static ConfigEntry Enabled; public static ConfigEntry CrosshairColor; public static ConfigEntry Length; public static ConfigEntry Thickness; public static ConfigEntry Gap; public static ConfigEntry DotScale; public static ConfigEntry InvertBehind; private static GameObject customContainer; private static Material originalInvertMat; private static Image centerDotInvert; private static Image lineLeftInvert; private static Image lineRightInvert; private static Image lineTopInvert; private static Image lineBottomInvert; private static Image centerDotOverlay; private static Image lineLeftOverlay; private static Image lineRightOverlay; private static Image lineTopOverlay; private static Image lineBottomOverlay; [HarmonyPatch("Refresh")] [HarmonyPostfix] public static void PostfixRefresh(UI_CrosshairController __instance) { if ((Object)(object)__instance == (Object)null) { return; } if (Enabled == null || !Enabled.Value) { Image crosshairRenderer = __instance.crosshairRenderer; if (crosshairRenderer != null) { ((Behaviour)crosshairRenderer).enabled = true; } GameObject obj = customContainer; if (obj != null) { obj.SetActive(false); } return; } if ((Object)(object)__instance.crosshairRenderer != (Object)null) { if ((Object)(object)originalInvertMat == (Object)null && (Object)(object)((Graphic)__instance.crosshairRenderer).material != (Object)null) { originalInvertMat = ((Graphic)__instance.crosshairRenderer).material; } ((Behaviour)__instance.crosshairRenderer).enabled = false; } if ((Object)(object)__instance.crosshair != (Object)null) { if ((Object)(object)customContainer == (Object)null || (Object)(object)customContainer.gameObject == (Object)null) { BuildCrosshair(__instance.crosshair); } UpdateCrosshair(); } } private static void UpdateCrosshair() { //IL_002f: 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_0034: 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_0046: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: 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_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) customContainer.SetActive(true); float num = (float)SettingsManager.settings.crosshairScale * 0.04f; Color val = CrosshairColor?.Value ?? Color.green; float num2 = Mathf.Max(new float[3] { val.r, val.g, val.b }); Color color = default(Color); ((Color)(ref color))..ctor(num2, num2, num2, 1f); float num3 = (Length?.Value ?? 1f) * num; float num4 = (Thickness?.Value ?? 1f) * num; float num5 = (Gap?.Value ?? 1f) * num; float num6 = DotScale?.Value ?? 1f; float num7 = num6 * num; bool flag = num3 > 0f && num4 > 0f; bool flag2 = num6 > 0f; bool flag3 = InvertBehind != null && InvertBehind.Value; bool show = flag && flag3; bool show2 = flag2 && flag3; Material mat = (flag3 ? originalInvertMat : null); Vector2 size = default(Vector2); ((Vector2)(ref size))..ctor(num7, num7); Vector2 size2 = default(Vector2); ((Vector2)(ref size2))..ctor(num3, num4); Vector2 size3 = default(Vector2); ((Vector2)(ref size3))..ctor(num4, num3); Vector2 pos = default(Vector2); ((Vector2)(ref pos))..ctor(0f - num5 - num3 / 2f, 0f); Vector2 pos2 = default(Vector2); ((Vector2)(ref pos2))..ctor(num5 + num3 / 2f, 0f); Vector2 pos3 = default(Vector2); ((Vector2)(ref pos3))..ctor(0f, num5 + num3 / 2f); Vector2 pos4 = default(Vector2); ((Vector2)(ref pos4))..ctor(0f, 0f - num5 - num3 / 2f); UpdateElement(centerDotInvert, show2, color, mat, size, Vector2.zero); UpdateElement(lineLeftInvert, show, color, mat, size2, pos); UpdateElement(lineRightInvert, show, color, mat, size2, pos2); UpdateElement(lineTopInvert, show, color, mat, size3, pos3); UpdateElement(lineBottomInvert, show, color, mat, size3, pos4); UpdateElement(centerDotOverlay, flag2, val, null, size, Vector2.zero); UpdateElement(lineLeftOverlay, flag, val, null, size2, pos); UpdateElement(lineRightOverlay, flag, val, null, size2, pos2); UpdateElement(lineTopOverlay, flag, val, null, size3, pos3); UpdateElement(lineBottomOverlay, flag, val, null, size3, pos4); } private static void UpdateElement(Image img, bool show, Color color, Material mat, Vector2 size, Vector2 pos) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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) ((Component)img).gameObject.SetActive(show); if (show) { ((Graphic)img).color = color; ((Graphic)img).material = mat; ((Graphic)img).rectTransform.sizeDelta = size; ((Graphic)img).rectTransform.anchoredPosition = pos; } } private static void BuildCrosshair(Transform parent) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) customContainer = new GameObject("CustomCrosshairContainer", new Type[1] { typeof(RectTransform) }); customContainer.transform.SetParent(parent, false); ((Transform)customContainer.GetComponent()).localScale = Vector3.one; centerDotInvert = CreateLineElement("XhairInvertCenterDot", customContainer.transform); lineLeftInvert = CreateLineElement("XhairInvertLeft", customContainer.transform); lineRightInvert = CreateLineElement("XhairInvertRight", customContainer.transform); lineTopInvert = CreateLineElement("XhairInvertTop", customContainer.transform); lineBottomInvert = CreateLineElement("XhairInvertBottom", customContainer.transform); centerDotOverlay = CreateLineElement("XhairCenterDotOverlay", customContainer.transform); lineLeftOverlay = CreateLineElement("XhairLeftOverlay", customContainer.transform); lineRightOverlay = CreateLineElement("XhairRightOverlay", customContainer.transform); lineTopOverlay = CreateLineElement("XhairTopOverlay", customContainer.transform); lineBottomOverlay = CreateLineElement("XhairBottomOverlay", customContainer.transform); } private static Image CreateLineElement(string name, Transform parent) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); Image val2 = val.AddComponent(); ((Graphic)val2).raycastTarget = false; RectTransform component = val.GetComponent(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); return val2; } } [HarmonyPatch(typeof(Screen))] public static class ResolutionPatch { public static ConfigEntry Enabled; public static ConfigEntry CustomResActive; public static ConfigEntry Width; public static ConfigEntry Height; [HarmonyPatch("SetResolution", new Type[] { typeof(int), typeof(int), typeof(FullScreenMode), typeof(RefreshRate) })] [HarmonyPrefix] public static void Prefix(ref int width, ref int height, ref FullScreenMode fullscreenMode) { if (Enabled != null && Enabled.Value) { fullscreenMode = (FullScreenMode)0; if (CustomResActive != null && CustomResActive.Value) { width = Width.Value; height = Height.Value; } } } } } namespace CommandsExtended.Common { public static class ConsoleExt { public static void EchoWithCommand(string[] aliases, string msg) { CommandConsoleAccessor.EchoToConsole("[" + Colors.Highlighted(aliases.First()) + "] " + msg); } } public static class CrosshairManager { public static bool IsCustomEnabled(string[] aliases) { if (CrosshairPatch.Enabled != null && CrosshairPatch.Enabled.Value) { return true; } ConsoleExt.EchoWithCommand(aliases, "Crosshair is disabled"); return false; } public static void ToggleState(string[] aliases) { CrosshairPatch.Enabled.Value = !CrosshairPatch.Enabled.Value; ((ConfigEntryBase)CrosshairPatch.Enabled).ConfigFile.Save(); ConsoleExt.EchoWithCommand(aliases, "Crosshair toggled"); Global.RefreshAllSettings(); } public static void ShowSettings(string[] aliases) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (!CrosshairPatch.Enabled.Value) { ConsoleExt.EchoWithCommand(aliases, "Crosshair is disabled"); return; } float value = CrosshairPatch.Length.Value; float value2 = CrosshairPatch.Thickness.Value; float value3 = CrosshairPatch.Gap.Value; float value4 = CrosshairPatch.DotScale.Value; int num = (CrosshairPatch.InvertBehind.Value ? 1 : 0); string text = ColorToString(CrosshairPatch.CrosshairColor.Value); ConsoleExt.EchoWithCommand(aliases, $"customcrosshair {value} {value2} {value3} {value4} {text} {num}"); } public static bool TryUpdateFullConfig(string[] args, string[] aliases) { if (args.Length == 9 && float.TryParse(args[0], out var result) && float.TryParse(args[1], out var result2) && float.TryParse(args[2], out var result3) && float.TryParse(args[3], out var result4) && int.TryParse(args[4], out var result5) && int.TryParse(args[5], out var result6) && int.TryParse(args[6], out var result7) && int.TryParse(args[7], out var result8) && int.TryParse(args[8], out var result9)) { CrosshairPatch.Length.Value = result; CrosshairPatch.Thickness.Value = result2; CrosshairPatch.Gap.Value = result3; CrosshairPatch.DotScale.Value = result4; CrosshairPatch.InvertBehind.Value = result9 == 1; SetColorConfig(result5, result6, result7, result8); CrosshairPatch.Enabled.Value = true; ((ConfigEntryBase)CrosshairPatch.Enabled).ConfigFile.Save(); ConsoleExt.EchoWithCommand(aliases, "Crosshair updated"); Global.RefreshAllSettings(); return true; } return false; } public static bool TryUpdateSingleFloat(string[] args, ConfigEntry configEntry, string[] aliases, string valueName) { if (args == null || args.Length == 0) { ConsoleExt.EchoWithCommand(aliases, $"{configEntry.Value}"); return true; } if (args.Length == 1 && float.TryParse(args[0], out var result)) { configEntry.Value = result; ((ConfigEntryBase)CrosshairPatch.Enabled).ConfigFile.Save(); ConsoleExt.EchoWithCommand(aliases, $"Crosshair {valueName} updated to {result}."); Global.RefreshAllSettings(); return true; } return false; } public static bool TryUpdateColor(string[] args, string[] aliases) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (args == null || args.Length == 0) { ConsoleExt.EchoWithCommand(aliases, ColorToString(CrosshairPatch.CrosshairColor.Value) ?? ""); return true; } if (args.Length == 4 && int.TryParse(args[0], out var result) && int.TryParse(args[1], out var result2) && int.TryParse(args[2], out var result3) && int.TryParse(args[3], out var result4)) { SetColorConfig(result, result2, result3, result4); ((ConfigEntryBase)CrosshairPatch.Enabled).ConfigFile.Save(); ConsoleExt.EchoWithCommand(aliases, "Crosshair color updated"); Global.RefreshAllSettings(); return true; } return false; } public static bool TryUpdateInversion(string[] args, string[] aliases) { if (args == null || args.Length == 0) { ConsoleExt.EchoWithCommand(aliases, $"{(CrosshairPatch.InvertBehind.Value ? 1 : 0)}"); return true; } if (args.Length == 1 && int.TryParse(args[0], out var result)) { bool value = result == 1; CrosshairPatch.InvertBehind.Value = value; ((ConfigEntryBase)CrosshairPatch.Enabled).ConfigFile.Save(); ConsoleExt.EchoWithCommand(aliases, "Crosshair inversion toggled"); Global.RefreshAllSettings(); return true; } return false; } private static void SetColorConfig(int r, int g, int b, int a) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) CrosshairPatch.CrosshairColor.Value = new Color(Mathf.Clamp01((float)r / 255f), Mathf.Clamp01((float)g / 255f), Mathf.Clamp01((float)b / 255f), Mathf.Clamp01((float)a / 255f)); } private static string ColorToString(Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0037: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.RoundToInt(color.r * 255f); int num2 = Mathf.RoundToInt(color.g * 255f); int num3 = Mathf.RoundToInt(color.b * 255f); int num4 = Mathf.RoundToInt(color.a * 255f); return $"{num} {num2} {num3} {num4}"; } } public static class Global { public static void RefreshAllSettings() { try { SettingsManager.RefreshSettings(string.Empty); } catch (NullReferenceException) { Plugin.Logger.LogInfo((object)"Refresh settings attempt failed, most likely not initialized yet."); } } } public static class Player { public static void ClearBuffs() { ENT_Player playerObject = ENT_Player.playerObject; if (playerObject != null) { EntityBuff curBuffs = ((GameEntity)playerObject).curBuffs; if (curBuffs != null) { curBuffs.Initialize(); } } } public static void ClearPerks() { ENT_Player playerObject = ENT_Player.playerObject; if (playerObject != null) { playerObject.RemoveAllPerks(true); } if ((Object)(object)ENT_Player.playerObject != (Object)null) { FieldInfo fieldInfo = AccessTools.Field(typeof(ENT_Player), "extraJumpsRemaining"); fieldInfo.SetValue(ENT_Player.playerObject, 0); } } } public static class String { public static bool EqualsIgnoreCase(this string one, string two) { return one.Equals(two, StringComparison.OrdinalIgnoreCase); } public static bool StartsWithIgnoreCase(this string one, string two) { return one.StartsWith(two, StringComparison.OrdinalIgnoreCase); } public static bool ContainsIgnoreCase(this string one, string two) { return one.Contains(two, StringComparison.OrdinalIgnoreCase); } } } namespace CommandsExtended.Commands { public sealed class ClearAll : CommandBase { public override string[] Aliases => new string[1] { "clearall" }; public override CommandTag Tag => (CommandTag)0; public override string Description => "Clear any current perks and buffs"; public override bool EnablesCheatsOnUse => true; public override Action GetLogicCallback() { return delegate { Player.ClearBuffs(); Player.ClearPerks(); }; } } public sealed class ClearBuffs : CommandBase { public override string[] Aliases => new string[1] { "clearbuff" }; public override CommandTag Tag => (CommandTag)0; public override string Description => "Clear any current buffs"; public override bool EnablesCheatsOnUse => true; public override Action GetLogicCallback() { return delegate { Player.ClearBuffs(); }; } } public sealed class ClearPerks : CommandBase { public override string[] Aliases => new string[1] { "clearperk" }; public override CommandTag Tag => (CommandTag)0; public override string Description => "Clear any current perks"; public override bool EnablesCheatsOnUse => true; public override Action GetLogicCallback() { return delegate { Player.ClearPerks(); }; } } public sealed class Fov : DoubleSettingCommand { public override string[] Aliases => new string[1] { "fov" }; protected override double Min => 60.0; protected override double Max => 140.0; protected override string SettingName => "Player FOV"; protected override bool RequiresRefresh => false; protected override double SettingValue { get { return SettingsManager.settings.playerFOV; } set { SettingsManager.settings.playerFOV = (float)Math.Round(value, 2); } } } public sealed class FullscreenExclusive : CommandBase { public override string[] Aliases => new string[2] { "exclusivemode", "exmode" }; public override CommandTag Tag => (CommandTag)0; public override string Description => "Toggle exclusive fullscreen/borderless, or set resolution if two numbers are provided. Allows for stretched resolutions (example: fsmode 1920 1440)"; public override bool EnablesCheatsOnUse => false; public override Action GetLogicCallback() { return delegate(string[] args) { if ((args != null && args.Length == 2) || !ResolutionPatch.Enabled.Value) { ResolutionPatch.Enabled.Value = true; ResolutionPatch.CustomResActive.Value = false; if (args != null && args.Length >= 2 && int.TryParse(args[0], out var result) && int.TryParse(args[1], out var result2)) { ResolutionPatch.Width.Value = result; ResolutionPatch.Height.Value = result2; ResolutionPatch.CustomResActive.Value = true; ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, "Custom resolution set"); } ((ConfigEntryBase)ResolutionPatch.Enabled).ConfigFile.Save(); ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, "Exclusive fullscreen enabled"); } else { if (!ResolutionPatch.Enabled.Value) { ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, "Invalid input"); return; } ResolutionPatch.Enabled.Value = false; ResolutionPatch.CustomResActive.Value = false; ((ConfigEntryBase)ResolutionPatch.Enabled).ConfigFile.Save(); ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, "Exclusive fullscreen disabled"); } Global.RefreshAllSettings(); }; } } public sealed class HandScale : DoubleSettingCommand { public override string[] Aliases => new string[2] { "handscale", "hscale" }; protected override double Min => 0.0; protected override double Max => 10.0; protected override string SettingName => "hand scale"; protected override bool RequiresRefresh => true; protected override double SettingValue { get { return SettingsManager.settings.handIconScale; } set { SettingsManager.settings.handIconScale = value; } } } public sealed class Marathon : CommandBase { private static readonly string[] levelOrder = new string[36] { "m1_intro_01", "m1_silos_storage_", "m1_silos_safearea_01", "m1_silos_broken_", "m1_silos_air_", "campaign_interlude_silo_to_pipeworks_01", "m2_pipeworks_drainage_", "m2_pipeworks_waste_", "m2_pipeworks_organ_", "campaign_interlude_pipeworks_to_habitation_01", "m3_habitation_entryway_01", "campaign_interlude_pipeworks_to_habitation_02", "m3_habitation_entryway_01", "campaign_interlude_pipeworks_to_habitation_03", "m3_habitation_entryway_01", "m3_habitation_shaft_intro", "m3_habitation_shaft_to_pier", "m3_habitation_pier_entrance_01", "m3_habitation_pier_03", "m3_habitation_pier_entrance_01", "m3_habitation_pier_04", "m3_habitation_pier_entrance_01", "m3_habitation_pier_01", "m3_habitation_pier_entrance_01", "m3_habitation_pier_02", "m3_habitation_lab_lobby", "m3_habitation_lab_", "m3_habitation_lab_ending", "campaign_interlude_habitation_to_abyss_01", "m4_abyss_transit_", "m4_abyss_handle_", "m4_abyss_garden_", "m4_abyss_outro_01", "campaign_interlude_abyss_to_nest_01_safearea", "campaign_interlude_abyss_to_nest_introclimb_01", "campaign_interlude_abyss_to_nest_01_prison" }; public override string[] Aliases => new string[1] { "marathon" }; public override CommandTag Tag => (CommandTag)1; public override string Description => "Loads most levels in a completable manner."; public override bool EnablesCheatsOnUse => false; public override Action GetLogicCallback() { return delegate { List source = (from x in Prefabs.Levels().Data() select ((Object)x).name).ToList(); List list = new List(); List list2 = new List(); int i; for (i = 0; i < levelOrder.Length; i++) { list2 = source.Where((string x) => x.EqualsIgnoreCase(levelOrder[i])).ToList(); if (!list2.Any()) { list2 = source.Where((string x) => x.StartsWithIgnoreCase(levelOrder[i])).ToList(); list2.RemoveAll((string x) => x.ContainsIgnoreCase("lobby")); list2.RemoveAll((string x) => x.ContainsIgnoreCase("ending")); } list.AddRange(list2); } CL_GameManager.gMan.LoadLevels(list.ToArray()); }; } } public sealed class Music : DoubleSettingCommand { public override string[] Aliases => new string[1] { "music" }; protected override double Min => 0.0; protected override double Max => 1.0; protected override string SettingName => "music volume"; protected override bool RequiresRefresh => true; protected override double SettingValue { get { return SettingsManager.settings.musicVolume; } set { SettingsManager.settings.musicVolume = value; } } } public sealed class Playground : CommandBase { public override string[] Aliases => new string[2] { "playground", "pg" }; public override CommandTag Tag => (CommandTag)1; public override string Description => "Loads the playground scene"; public override bool EnablesCheatsOnUse => false; public override Action GetLogicCallback() { return delegate { M_Gamemode gamemodeAsset = CL_AssetManager.GetGamemodeAsset("GM_Playground", ""); CL_GameManager.gMan.SetGamemode(gamemodeAsset); SceneManager.LoadScene("Playground"); }; } } public sealed class Raycast : TogglableCommandBase { public override string[] Aliases => new string[1] { "raycast" }; public override CommandTag Tag => (CommandTag)1; public override string Description => "For dev purposes, determines name of game object at crosshair when pressing left click"; public override bool EnablesCheatsOnUse => true; public override Action GetLogicCallback() { return delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GameObject val = new GameObject("RaycastListener"); if (((TogglableCommandBase)this).Enabled) { val.AddComponent(); } else { Object.Destroy((Object)(object)val); } }; } } public sealed class Sensitivity : DoubleSettingCommand { public override string[] Aliases => new string[2] { "sensitivity", "sens" }; protected override double Min => 0.0; protected override double Max => 100.0; protected override string SettingName => "mouse sensitivity"; protected override bool RequiresRefresh => false; protected override double SettingValue { get { return SettingsManager.settings.mouseSensitivity; } set { SettingsManager.settings.mouseSensitivity = value; } } } public sealed class ShowGrabs : TogglableCommandBase { public static Material HighlightMat; private GameObject animationObj; private const string rgb = "rgb"; public override string[] Aliases => new string[2] { "showgrabs", "sg" }; public override CommandTag Tag => (CommandTag)1; public override string Description => "Shows grabbable surfaces\nPass color like 'red', 'green' or '#RRGGBB' as argument to set custom color, or 'rgb' for rgb mode\nPass a number after 'rgb' to set the rgb speed."; public override bool EnablesCheatsOnUse => true; public override Action GetLogicCallback() { return delegate(string[] args) { if (((TogglableCommandBase)this).Enabled) { SetupVisualizer(args); } else if (!((TogglableCommandBase)this).Enabled) { ((CommandBase)this).OnExit(); } }; } private void SetupVisualizer(string[] args) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0044: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown bool flag = false; bool flag2 = args.Length != 0; if (flag2) { flag = args[0].EqualsIgnoreCase("rgb"); } HighlightMat = new Material(Shader.Find("Hidden/Internal-Colored")); HighlightMat.renderQueue = 2001; Color green = Color.green; if (flag2 && !flag) { ColorUtility.TryParseHtmlString(args[0], ref green); } HighlightMat.color = green; HighlightMat.DisableKeyword("_EMISSION"); HighlightMat.SetInt("_Cull", 0); HighlightMat.SetInt("_SrcBlend", 1); HighlightMat.SetInt("_DstBlend", 0); HighlightMat.SetInt("_ZWrite", 1); HighlightMat.SetFloat("_ZBias", -10f); if ((Object)(object)animationObj == (Object)null && flag) { flag2 = args.Length > 1; HandholdRgb.Speed = HandholdRgb.DefaultSpeed; if (flag2 && float.TryParse(args[1], out var result)) { HandholdRgb.Speed = result; } animationObj = new GameObject("ShowGrabableAnimation"); animationObj.AddComponent(); } CL_Handhold[] array = Resources.FindObjectsOfTypeAll(); CL_Handhold[] array2 = array; foreach (CL_Handhold val in array2) { GameObject gameObject = ((Component)val).gameObject; gameObject.AddComponent(); } } public override void OnExit() { CL_Handhold[] array = Resources.FindObjectsOfTypeAll(); if ((Object)(object)animationObj != (Object)null) { Object.Destroy((Object)(object)animationObj); animationObj = null; } CL_Handhold[] array2 = array; HandholdVisualizer handholdVisualizer = default(HandholdVisualizer); foreach (CL_Handhold val in array2) { GameObject gameObject = ((Component)val).gameObject; if (gameObject.TryGetComponent(ref handholdVisualizer)) { handholdVisualizer.HideHandholds(); Object.Destroy((Object)(object)handholdVisualizer); } } ((TogglableCommandBase)this).Enabled = false; } } public sealed class Volume : DoubleSettingCommand { public override string[] Aliases => new string[2] { "volume", "vol" }; protected override double Min => 0.0; protected override double Max => 1.0; protected override string SettingName => "master volume"; protected override bool RequiresRefresh => true; protected override double SettingValue { get { return SettingsManager.settings.masterVolume; } set { SettingsManager.settings.masterVolume = value; } } } } namespace CommandsExtended.Commands.CustomCrosshair { public sealed class CrosshairColor : CommandBase { public override string[] Aliases => new string[2] { "crosshaircolor", "xcolor" }; public override CommandTag Tag => (CommandTag)0; public override string Description => "Adjust custom crosshair color (example: crosshaircolor 255 125 35 255)"; public override bool EnablesCheatsOnUse => false; public override Action GetLogicCallback() { return delegate(string[] args) { if (CrosshairManager.IsCustomEnabled(((CommandBase)this).Aliases) && !CrosshairManager.TryUpdateColor(args, ((CommandBase)this).Aliases)) { ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, "Invalid input"); } }; } } public sealed class CrosshairDot : CommandBase { public override string[] Aliases => new string[2] { "crosshairdot", "xdot" }; public override CommandTag Tag => (CommandTag)0; public override string Description => "Adjust custom crosshair center dot scale"; public override bool EnablesCheatsOnUse => false; public override Action GetLogicCallback() { return delegate(string[] args) { if (CrosshairManager.IsCustomEnabled(((CommandBase)this).Aliases) && !CrosshairManager.TryUpdateSingleFloat(args, CrosshairPatch.DotScale, ((CommandBase)this).Aliases, "dot scale")) { ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, "Invalid input"); } }; } } public sealed class CrosshairGap : CommandBase { public override string[] Aliases => new string[2] { "crosshairgap", "xgap" }; public override CommandTag Tag => (CommandTag)0; public override string Description => "Adjust custom crosshair gap"; public override bool EnablesCheatsOnUse => false; public override Action GetLogicCallback() { return delegate(string[] args) { if (CrosshairManager.IsCustomEnabled(((CommandBase)this).Aliases) && !CrosshairManager.TryUpdateSingleFloat(args, CrosshairPatch.Gap, ((CommandBase)this).Aliases, "gap")) { ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, "Invalid input"); } }; } } public sealed class CrosshairInvert : CommandBase { public override string[] Aliases => new string[2] { "crosshairinvert", "xinvert" }; public override CommandTag Tag => (CommandTag)0; public override string Description => "Toggle crosshair inversion effect (like original crosshair). 0 or 1"; public override bool EnablesCheatsOnUse => false; public override Action GetLogicCallback() { return delegate(string[] args) { if (CrosshairManager.IsCustomEnabled(((CommandBase)this).Aliases) && !CrosshairManager.TryUpdateInversion(args, ((CommandBase)this).Aliases)) { ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, "Invalid input"); } }; } } public sealed class CrosshairLength : CommandBase { public override string[] Aliases => new string[2] { "crosshairlength", "xlength" }; public override CommandTag Tag => (CommandTag)0; public override string Description => "Adjust custom crosshair length"; public override bool EnablesCheatsOnUse => false; public override Action GetLogicCallback() { return delegate(string[] args) { if (CrosshairManager.IsCustomEnabled(((CommandBase)this).Aliases) && !CrosshairManager.TryUpdateSingleFloat(args, CrosshairPatch.Length, ((CommandBase)this).Aliases, "length")) { ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, "Invalid input"); } }; } } public sealed class CrosshairScale : DoubleSettingCommand { public override string[] Aliases => new string[2] { "crosshairscale", "xscale" }; protected override double Min => 0.0; protected override double Max => 10.0; protected override string SettingName => "crosshair scale"; protected override bool RequiresRefresh => true; protected override double SettingValue { get { return SettingsManager.settings.crosshairScale; } set { SettingsManager.settings.crosshairScale = value; } } } public sealed class CrosshairThickness : CommandBase { public override string[] Aliases => new string[2] { "crosshairthickness", "xthick" }; public override CommandTag Tag => (CommandTag)0; public override string Description => "Adjust custom crosshair thickness"; public override bool EnablesCheatsOnUse => false; public override Action GetLogicCallback() { return delegate(string[] args) { if (CrosshairManager.IsCustomEnabled(((CommandBase)this).Aliases) && !CrosshairManager.TryUpdateSingleFloat(args, CrosshairPatch.Thickness, ((CommandBase)this).Aliases, "thickness")) { ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, "Invalid input"); } }; } } public sealed class CustomCrosshair : CommandBase { public override string[] Aliases => new string[2] { "customcrosshair", "xhair" }; public override CommandTag Tag => (CommandTag)0; public override string Description => "Toggles custom crosshair if no args. Pass args for config: [length] [thickness] [gap] [dot_scale] [r] [g] [b] [a] [invert(0/1)], or 'customcrosshair show' to view config."; public override bool EnablesCheatsOnUse => false; public override Action GetLogicCallback() { return delegate(string[] args) { if (CrosshairPatch.Enabled != null) { if (args == null || args.Length == 0) { CrosshairManager.ToggleState(((CommandBase)this).Aliases); } else { if (args.Length == 1) { if (args[0].Equals("show", StringComparison.OrdinalIgnoreCase)) { CrosshairManager.ShowSettings(((CommandBase)this).Aliases); return; } } else if (args.Length == 9 && CrosshairManager.TryUpdateFullConfig(args, ((CommandBase)this).Aliases)) { return; } ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, "Invalid input"); } } }; } } } namespace CommandsExtended.Commands.Common { public abstract class DoubleSettingCommand : CommandBase { public override string Description => $"Change {SettingName}, saves to player's settings (min: {Min}, max: {Max})"; public override CommandTag Tag => (CommandTag)0; public override bool EnablesCheatsOnUse => false; protected abstract double SettingValue { get; set; } protected abstract string SettingName { get; } protected abstract double Min { get; } protected abstract double Max { get; } protected abstract bool RequiresRefresh { get; } public override Action GetLogicCallback() { return delegate(string[] args) { double result; if (args.Length == 0) { ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, $"Current {SettingName}: {SettingValue}"); } else if (double.TryParse(args[0], out result)) { if (result < Min) { ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, $"{SettingName} cannot be below {Min}"); } else if (result > Max) { ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, $"{SettingName} cannot be above {Max}"); } else { SettingsManager.instance.LoadSettings(); SettingValue = result; SettingsManager.instance.SaveSettings(); if (RequiresRefresh) { Global.RefreshAllSettings(); } ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, $"{SettingName} set to {result}"); } } else { ConsoleExt.EchoWithCommand(((CommandBase)this).Aliases, "Invalid arguments for " + SettingName + " command: " + GeneralExtensions.Join((IEnumerable)args, (Func)null, " ")); } }; } } } namespace CommandsExtended.Behaviors { public sealed class HandholdRgb : MonoBehaviour { public static float Speed; public static float DefaultSpeed = 0.1f; public void Update() { //IL_002e: 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_003e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ShowGrabs.HighlightMat != (Object)null) { float num = Time.time * Speed % 1f; Color val = Color.HSVToRGB(num, 1f, 1f); ShowGrabs.HighlightMat.SetColor("_Color", val); } } } public sealed class HandholdVisualizer : MonoBehaviour { private Material[] existingMaterials; private Renderer currentRenderer; private bool wasEnabled = false; public void Start() { CL_Handhold handhold = default(CL_Handhold); if (((Component)this).TryGetComponent(ref handhold)) { RevealHandholds(handhold); } } public void HideHandholds() { if ((Object)(object)currentRenderer != (Object)null) { currentRenderer.enabled = wasEnabled; currentRenderer.sharedMaterials = existingMaterials.ToArray(); } } private void RevealHandholds(CL_Handhold handhold) { MeshFilter filter = default(MeshFilter); MeshCollider meshCol = default(MeshCollider); BoxCollider box = default(BoxCollider); SphereCollider sphere = default(SphereCollider); if ((Object)(object)handhold.handholdRenderer != (Object)null) { RevealRenderer(handhold); } else if (((Component)handhold).TryGetComponent(ref filter)) { RevealExistingMesh(handhold, filter); } else if (((Component)handhold).TryGetComponent(ref meshCol)) { MatchMeshRendererToCollider(handhold, meshCol); } else if (((Component)handhold).TryGetComponent(ref box)) { VisualizeBoxCollider(box); } else if (((Component)handhold).TryGetComponent(ref sphere)) { VisualizeSphereCollider(sphere); } else { Plugin.Logger.LogInfo((object)("Unable to draw handhold: " + ((Object)handhold).name)); } } private void RevealRenderer(CL_Handhold handhold) { TrackExisting(handhold.handholdRenderer, handhold.handholdRenderer.enabled); handhold.handholdRenderer.enabled = true; handhold.handholdRenderer.sharedMaterials = (Material[])(object)new Material[1] { ShowGrabs.HighlightMat }; } private void RevealExistingMesh(CL_Handhold handhold, MeshFilter filter) { GameObject gameObject = ((Component)handhold).gameObject; if ((Object)(object)filter != (Object)null && (Object)(object)filter.sharedMesh != (Object)null) { MeshRenderer val = gameObject.GetComponent(); bool enabled = false; if ((Object)(object)val == (Object)null) { val = gameObject.AddComponent(); } else { enabled = ((Renderer)val).enabled; } TrackExisting((Renderer)(object)val, enabled); ((Renderer)val).sharedMaterials = (Material[])(object)new Material[1] { ShowGrabs.HighlightMat }; ((Renderer)val).enabled = enabled; } } private void MatchMeshRendererToCollider(CL_Handhold handhold, MeshCollider meshCol) { GameObject gameObject = ((Component)handhold).gameObject; MeshFilter val = gameObject.GetComponent(); if ((Object)(object)val == (Object)null) { val = gameObject.AddComponent(); } val.sharedMesh = meshCol.sharedMesh; MeshRenderer val2 = gameObject.GetComponent(); bool flag = false; if ((Object)(object)val2 == (Object)null) { val2 = gameObject.AddComponent(); } else { flag = ((Renderer)val2).enabled; } TrackExisting((Renderer)(object)val2, flag); ((Renderer)val2).sharedMaterials = (Material[])(object)new Material[1] { ShowGrabs.HighlightMat }; ((Renderer)val2).enabled = true; } private void VisualizeSphereCollider(SphereCollider sphere) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)0); Object.Destroy((Object)(object)val.GetComponent()); val.transform.SetParent(((Component)sphere).transform); val.transform.localPosition = sphere.center; val.transform.localRotation = Quaternion.identity; float num = sphere.radius * 2f; val.transform.localScale = new Vector3(num, num, num); MeshRenderer component = val.GetComponent(); TrackExisting((Renderer)(object)component); ((Renderer)component).sharedMaterials = (Material[])(object)new Material[1] { ShowGrabs.HighlightMat }; } private void VisualizeBoxCollider(BoxCollider box) { //IL_002d: 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_0050: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)3); Object.Destroy((Object)(object)val.GetComponent()); val.transform.SetParent(((Component)box).transform); val.transform.localPosition = box.center; val.transform.localScale = box.size; val.transform.localRotation = Quaternion.identity; Renderer component = val.GetComponent(); TrackExisting(component); component.sharedMaterials = (Material[])(object)new Material[1] { ShowGrabs.HighlightMat }; } private void TrackExisting(Renderer renderer, bool wasEnabled = false) { this.wasEnabled = wasEnabled; if (currentRenderer == null) { currentRenderer = renderer; } if (existingMaterials == null) { existingMaterials = renderer.sharedMaterials.ToArray(); } } } public sealed class Raycaster : MonoBehaviour { public void Update() { if (Input.GetMouseButtonDown(0)) { DoRaycast(); } } private void DoRaycast() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Ray val = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)); RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, ref val2)) { Plugin.Logger.LogInfo((object)("Hit Object: " + ((Object)((Component)((RaycastHit)(ref val2)).collider).gameObject).name)); } } } }