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 CommandsExtended.Behaviors; using CommandsExtended.Commands; using CommandsExtended.Commands.Common; using CommandsExtended.Common; using HarmonyLib; using Microsoft.CodeAnalysis; using MoreCommands; using MoreCommands.Accessors; using MoreCommands.Common; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CommandsExtended")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("An extension to MoreCommands")] [assembly: AssemblyFileVersion("0.3.0.0")] [assembly: AssemblyInformationalVersion("0.3.0+c6597248cb2c475c0deb11c0f62ff75abf9e188a")] [assembly: AssemblyProduct("CommandsExtended")] [assembly: AssemblyTitle("CommandsExtended")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.0.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; } } } namespace CommandsExtended { [BepInPlugin("dotlake.CommandsExtended", "CommandsExtended", "0.3.0")] [BepInDependency("shishyando.WK.MoreCommands", "0.12.2")] public class Plugin : BaseUnityPlugin { public static ManualLogSource Logger; public void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Registry.RegisterAll(); 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"); } } } 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()); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "dotlake.CommandsExtended"; public const string PLUGIN_NAME = "CommandsExtended"; public const string PLUGIN_VERSION = "0.3.0"; } } namespace CommandsExtended.Common { 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) { AccessTools.Field(typeof(ENT_Player), "extraJumpsRemaining").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] { "clear" }; public override CommandTag Tag => (CommandTag)0; public override string Description => "Clear any current perks and buffs"; public override bool CheatsOnly => 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 CheatsOnly => 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 CheatsOnly => true; public override Action GetLogicCallback() { return delegate { Player.ClearPerks(); }; } } public sealed class Fov : FloatSettingCommand { public override string[] Aliases => new string[1] { "fov" }; protected override float Min => 60f; protected override float Max => 140f; protected override string SettingName => "Player FOV"; protected override string DisplayPrecision => "F1"; protected override bool RequiresRefresh => false; protected override float SettingValue { get { return SettingsManager.settings.playerFOV; } set { SettingsManager.settings.playerFOV = value; } } } public sealed class Marathon : CommandBase { private static readonly string[] levelOrder = new string[28] { "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_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" }; public override string[] Aliases => new string[1] { "marathon" }; public override CommandTag Tag => (CommandTag)1; public override string Description => "Loads all levels in a completable manner"; public override bool CheatsOnly => 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 : FloatSettingCommand { public override string[] Aliases => new string[1] { "music" }; protected override float Min => 0f; protected override float Max => 1f; protected override string SettingName => "music volume"; protected override string DisplayPrecision => "F2"; protected override bool RequiresRefresh => true; protected override float SettingValue { get { return Convert.ToSingle(SettingsManager.settings.musicVolume); } set { SettingsManager.settings.musicVolume = Convert.ToSingle(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 CheatsOnly => 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 CheatsOnly => true; public override Action GetLogicCallback() { return delegate { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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 : FloatSettingCommand { public override string[] Aliases => new string[2] { "sensitivity", "sens" }; protected override float Min => 0f; protected override float Max => 100f; protected override string SettingName => "mouse sensitivity"; protected override string DisplayPrecision => "F4"; protected override bool RequiresRefresh => false; protected override float SettingValue { get { return Convert.ToSingle(SettingsManager.settings.mouseSensitivity); } set { SettingsManager.settings.mouseSensitivity = Convert.ToDouble(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 CheatsOnly => 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown bool flag = false; bool num = args.Length != 0; if (num) { flag = args[0].EqualsIgnoreCase("rgb"); } HighlightMat = new Material(Shader.Find("Hidden/Internal-Colored")); HighlightMat.renderQueue = 2001; Color green = Color.green; if (num && !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) { bool num2 = args.Length > 1; HandholdRgb.Speed = HandholdRgb.DefaultSpeed; if (num2 && float.TryParse(args[1], out var result)) { HandholdRgb.Speed = result; } animationObj = new GameObject("ShowGrabableAnimation"); animationObj.AddComponent(); } CL_Handhold[] array = Resources.FindObjectsOfTypeAll(); for (int i = 0; i < array.Length; i++) { ((Component)array[i]).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); for (int i = 0; i < array2.Length; i++) { if (((Component)array2[i]).gameObject.TryGetComponent(ref handholdVisualizer)) { handholdVisualizer.HideHandholds(); Object.Destroy((Object)(object)handholdVisualizer); } } ((TogglableCommandBase)this).Enabled = false; } } public sealed class Volume : FloatSettingCommand { public override string[] Aliases => new string[2] { "volume", "vol" }; protected override float Min => 0f; protected override float Max => 1f; protected override string SettingName => "master volume"; protected override string DisplayPrecision => "F2"; protected override bool RequiresRefresh => true; protected override float SettingValue { get { return Convert.ToSingle(SettingsManager.settings.masterVolume); } set { SettingsManager.settings.masterVolume = Convert.ToDouble(value); } } } } namespace CommandsExtended.Commands.Common { public abstract class FloatSettingCommand : 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 CheatsOnly => false; protected abstract float SettingValue { get; set; } protected abstract string SettingName { get; } protected abstract float Min { get; } protected abstract float Max { get; } protected abstract string DisplayPrecision { get; } protected abstract bool RequiresRefresh { get; } public override Action GetLogicCallback() { return delegate(string[] args) { float result; if (args.Length == 0) { CommandConsoleAccessor.EchoToConsole("Current " + SettingName + ": " + SettingValue.ToString(DisplayPrecision)); } else if (float.TryParse(args[0], out result)) { if (result < Min) { CommandConsoleAccessor.EchoToConsole(SettingName + " cannot be below " + Min.ToString(DisplayPrecision)); } else if (result > Max) { CommandConsoleAccessor.EchoToConsole(SettingName + " cannot be above " + Max.ToString(DisplayPrecision)); } else { SettingsManager.instance.LoadSettings(); SettingValue = result; SettingsManager.instance.SaveSettings(); if (RequiresRefresh) { SettingsManager.RefreshSettings(""); } CommandConsoleAccessor.EchoToConsole(SettingName + " set to " + result.ToString(DisplayPrecision)); } } else { CommandConsoleAccessor.EchoToConsole("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_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_0038: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ShowGrabs.HighlightMat != (Object)null) { Color val = Color.HSVToRGB(Time.time * Speed % 1f, 1f, 1f); ShowGrabs.HighlightMat.SetColor("_Color", val); } } } public sealed class HandholdVisualizer : MonoBehaviour { private Material[] existingMaterials; private Renderer currentRenderer; private bool wasEnabled; 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0); Object.Destroy((Object)(object)obj.GetComponent()); obj.transform.SetParent(((Component)sphere).transform); obj.transform.localPosition = sphere.center; obj.transform.localRotation = Quaternion.identity; float num = sphere.radius * 2f; obj.transform.localScale = new Vector3(num, num, num); MeshRenderer component = obj.GetComponent(); TrackExisting((Renderer)(object)component); ((Renderer)component).sharedMaterials = (Material[])(object)new Material[1] { ShowGrabs.HighlightMat }; } private void VisualizeBoxCollider(BoxCollider box) { //IL_0029: 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_004a: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); Object.Destroy((Object)(object)obj.GetComponent()); obj.transform.SetParent(((Component)box).transform); obj.transform.localPosition = box.center; obj.transform.localScale = box.size; obj.transform.localRotation = Quaternion.identity; Renderer component = obj.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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (Physics.Raycast(Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)), ref val)) { Plugin.Logger.LogInfo((object)("Hit Object: " + ((Object)((Component)((RaycastHit)(ref val)).collider).gameObject).name)); } } } }