using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using FishNet.Connection; using FishNet.Object; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; 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("HowToFishDevToolsConsole")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("HowToFishDevToolsConsole")] [assembly: AssemblyTitle("HowToFishDevToolsConsole")] [assembly: AssemblyVersion("1.0.0.0")] [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 HowToFishConsole { public static class BanList { private static readonly HashSet banned = new HashSet(); private static string FilePath => Path.Combine(Paths.ConfigPath, "howtofish_console_bans.txt"); public static void Load() { try { if (!File.Exists(FilePath)) { return; } banned.Clear(); string[] array = File.ReadAllLines(FilePath); foreach (string text in array) { if (ulong.TryParse(text.Trim(), out var result)) { banned.Add(result); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not load ban list: " + ex.Message)); } } public static bool IsBanned(ulong steamId) { return banned.Contains(steamId); } public static void Add(ulong steamId) { if (banned.Add(steamId)) { Save(); } } public static void Remove(ulong steamId) { if (banned.Remove(steamId)) { Save(); } } private static void Save() { try { File.WriteAllLines(FilePath, banned.Select((ulong id) => id.ToString())); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not save ban list: " + ex.Message)); } } } public class HelpCommand : IConsoleCommand { public string Name => "help"; public string Usage => "help / cmds"; public string Description => "Lists all available commands."; public void Execute(string[] args, ConsoleUI console) { console.Log("Available commands:"); foreach (IConsoleCommand item in CommandProcessor.AllCommands.OrderBy((IConsoleCommand c) => c.Name)) { console.Log(" " + item.Usage + " - " + item.Description); } } } public class ClearCommand : IConsoleCommand { public string Name => "clear"; public string Usage => "clear"; public string Description => "Clears the console log."; public void Execute(string[] args, ConsoleUI console) { console.ClearLog(); } } public class PluginsCommand : IConsoleCommand { public string Name => "plugins"; public string Usage => "plugins [filter]"; public string Description => "Lists loaded BepInEx plugins, optionally filtered by name/GUID."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_Plugins_Enabled.Value) { console.LogError("'plugins' is disabled in config."); return; } string filter = ((args.Length != 0) ? string.Join(" ", args) : null); List list = (from p in Chainloader.PluginInfos.Values where string.IsNullOrEmpty(filter) || p.Metadata.Name.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0 || p.Metadata.GUID.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0 orderby p.Metadata.Name select p).ToList(); if (list.Count == 0) { console.Log("No plugins matched."); return; } console.Log($"Loaded plugins ({list.Count}):"); foreach (PluginInfo item in list) { console.Log($" {item.Metadata.Name} v{item.Metadata.Version} ({item.Metadata.GUID})"); } } } public class GodCommand : IConsoleCommand { public string Name => "god"; public string Usage => "god"; public string Description => "Toggles god mode. Global effect (PlayerManager.InGodMode gates all damage)."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_God_Enabled.Value) { console.LogError("'god' is disabled in config."); return; } PlayerManager.ToggleGodMode(); console.LogSuccess("God mode is now " + (PlayerManager.InGodMode ? "ON" : "OFF") + " (affects all players)."); } } public class FlyCommand : IConsoleCommand { public string Name => "fly"; public string Usage => "fly [target]"; public string Description => "Toggles hover/fly (gravity off, still collides). Own client only."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_Fly_Enabled.Value) { console.LogError("'fly' is disabled in config."); return; } Player val = PlayerFinder.Resolve((args.Length != 0) ? args[0] : null, console); if (!((Object)(object)val == (Object)null)) { FreeMoveMode freeMoveMode = FreeMovementPatch.Toggle(val, FreeMoveMode.Fly); console.LogSuccess("Fly " + ((freeMoveMode == FreeMoveMode.Fly) ? "enabled" : "disabled") + " for " + val.SteamName + "."); if (((NetworkBehaviour)val).Owner == (NetworkConnection)null || !((NetworkBehaviour)val).Owner.IsLocalClient) { console.LogWarning("Target isn't your local player - movement is client-authoritative, this likely won't be visible for them."); } } } } public class NoclipCommand : IConsoleCommand { public string Name => "noclip"; public string Usage => "noclip [target]"; public string Description => "Toggles noclip (gravity + collision off). Own client only."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_Noclip_Enabled.Value) { console.LogError("'noclip' is disabled in config."); return; } Player val = PlayerFinder.Resolve((args.Length != 0) ? args[0] : null, console); if (!((Object)(object)val == (Object)null)) { FreeMoveMode freeMoveMode = FreeMovementPatch.Toggle(val, FreeMoveMode.Noclip); console.LogSuccess("Noclip " + ((freeMoveMode == FreeMoveMode.Noclip) ? "enabled" : "disabled") + " for " + val.SteamName + "."); if (((NetworkBehaviour)val).Owner == (NetworkConnection)null || !((NetworkBehaviour)val).Owner.IsLocalClient) { console.LogWarning("Target isn't your local player - movement is client-authoritative, this likely won't be visible for them."); } } } } public class WalkSpeedCommand : IConsoleCommand { public string Name => "walkspeed"; public string Usage => "walkspeed [value] [target]"; public string Description => "Sets base walk speed (sprint scales proportionally). No value = reset to config default."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_WalkSpeed_Enabled.Value) { console.LogError("'walkspeed' is disabled in config."); return; } float num = ModConfig.WalkSpeed_Default.Value; int num2 = 0; if (args.Length != 0 && float.TryParse(args[0], out var result)) { num = result; num2 = 1; } Player val = PlayerFinder.Resolve((args.Length > num2) ? args[num2] : null, console); if (!((Object)(object)val == (Object)null)) { PlayerMovement movement = val.Movement; ReflectionUtil.TryGetField(movement, "_walkSpeed", out var value); ReflectionUtil.TryGetField(movement, "_sprintSpeed", out var value2); float num3 = ((value > 0.001f) ? (value2 / value) : 1.5f); bool flag = ReflectionUtil.TrySetField(movement, "_walkSpeed", num); ReflectionUtil.TrySetField(movement, "_sprintSpeed", num * num3); if (flag) { console.LogSuccess($"Walk speed for {val.SteamName} set to {num} (sprint scaled to {num * num3:0.##})."); } else { console.LogError("Could not reach PlayerMovement._walkSpeed."); } if (((NetworkBehaviour)val).Owner == (NetworkConnection)null || !((NetworkBehaviour)val).Owner.IsLocalClient) { console.LogWarning("Target isn't your local player - this only affects that player's own client."); } } } } public class JumpPowerCommand : IConsoleCommand { public string Name => "jumppower"; public string Usage => "jumppower [value] [target]"; public string Description => "Sets jump force. No value = reset to config default."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_JumpPower_Enabled.Value) { console.LogError("'jumppower' is disabled in config."); return; } float num = ModConfig.JumpPower_Default.Value; int num2 = 0; if (args.Length != 0 && float.TryParse(args[0], out var result)) { num = result; num2 = 1; } Player val = PlayerFinder.Resolve((args.Length > num2) ? args[num2] : null, console); if (!((Object)(object)val == (Object)null)) { if (ReflectionUtil.TrySetField(val.Movement, "_jumpForce", num)) { console.LogSuccess($"Jump power for {val.SteamName} set to {num}."); } else { console.LogError("Could not reach PlayerMovement._jumpForce."); } if (((NetworkBehaviour)val).Owner == (NetworkConnection)null || !((NetworkBehaviour)val).Owner.IsLocalClient) { console.LogWarning("Target isn't your local player - this only affects that player's own client."); } } } } public class InfJumpCommand : IConsoleCommand { public string Name => "infjump"; public string Usage => "infjump [target]"; public string Description => "Enables/disables infinite jumping (bypasses grounded/coyote-time checks)."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_InfJump_Enabled.Value) { console.LogError("'infjump' is disabled in config."); return; } if (args.Length < 1 || (args[0] != "on" && args[0] != "off")) { console.LogError("Usage: " + Usage); return; } bool flag = args[0] == "on"; Player val = PlayerFinder.Resolve((args.Length > 1) ? args[1] : null, console); if (!((Object)(object)val == (Object)null)) { InfiniteJumpPatch.SetEnabled(val, flag); console.LogSuccess("Infinite jump " + (flag ? "enabled" : "disabled") + " for " + val.SteamName + "."); if (((NetworkBehaviour)val).Owner == (NetworkConnection)null || !((NetworkBehaviour)val).Owner.IsLocalClient) { console.LogWarning("Target isn't your local player - jump input only fires on that player's own client."); } } } } public class GiveCommand : IConsoleCommand { public string Name => "give"; public string Usage => "give [target]"; public string Description => "Spawns an item by (partial) prefab name and gives it to target. Requires host/server."; public void Execute(string[] args, ConsoleUI console) { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) if (!ModConfig.Cmd_Give_Enabled.Value) { console.LogError("'give' is disabled in config."); return; } if (args.Length < 1) { console.LogError("Usage: " + Usage); return; } if (!Object.op_Implicit((Object)(object)Server.Instance) || !((NetworkBehaviour)Server.Instance).IsServerInitialized) { console.LogError("You must be the host/server to spawn items."); return; } if (!Object.op_Implicit((Object)(object)ItemManager.Instance)) { console.LogError("ItemManager isn't ready yet."); return; } Player val = PlayerFinder.Resolve((args.Length > 1) ? args[1] : null, console); if (!((Object)(object)val == (Object)null)) { Item val2 = FindItemPrefab(args[0]); if ((Object)(object)val2 == (Object)null) { console.LogError("No loaded item prefab matches '" + args[0] + "'."); return; } Vector3 val3 = val.Transform.position + val.CamObject.forward * 1.5f + Vector3.up; Item val4 = ItemManager.Instance.SpawnNewItem(val2, val3, Quaternion.identity); val4.SetSyncedHolder(val, true); console.LogSuccess("Gave '" + ((Object)((Component)val2).gameObject).name + "' to " + val.SteamName + "."); } } private static Item FindItemPrefab(string search) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) Item[] array = Resources.FindObjectsOfTypeAll(); foreach (Item val in array) { Scene scene = ((Component)val).gameObject.scene; if (!((Scene)(ref scene)).IsValid() && ((Object)((Component)val).gameObject).name.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0) { return val; } } return null; } } public class HungryCommand : IConsoleCommand { public string Name => "hungry"; public string Usage => "hungry [target]"; public string Description => "Enables/disables hunger drain and starvation damage. Requires host/server."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_Hungry_Enabled.Value) { console.LogError("'hungry' is disabled in config."); return; } if (args.Length < 1 || (args[0] != "on" && args[0] != "off")) { console.LogError("Usage: " + Usage); return; } if (!Object.op_Implicit((Object)(object)Server.Instance) || !((NetworkBehaviour)Server.Instance).IsServerInitialized) { console.LogError("You must be the host/server to change hunger."); return; } bool flag = args[0] == "on"; Player val = PlayerFinder.Resolve((args.Length > 1) ? args[1] : null, console); if (!((Object)(object)val == (Object)null)) { HungerPatch.SetHungerEnabled(val.Vitals, flag); if (!flag) { val.Vitals._syncedFullness.Value = 100; } console.LogSuccess("Hunger turned " + (flag ? "ON" : "OFF") + " for " + val.SteamName + "."); } } } public class AddMoneyCommand : IConsoleCommand { public string Name => "addmoney"; public string Usage => "addmoney [amount] [target]"; public string Description => "Adds money to the shared server economy. No amount = config default."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_AddMoney_Enabled.Value) { console.LogError("'addmoney' is disabled in config."); return; } int num = ModConfig.AddMoney_DefaultAmount.Value; int num2 = 0; if (args.Length != 0 && int.TryParse(args[0], out var result)) { num = result; num2 = 1; } if (!Object.op_Implicit((Object)(object)Server.Instance) || !((NetworkBehaviour)Server.Instance).IsServerInitialized) { console.LogError("You must be the host/server to add money."); return; } Player val = PlayerFinder.Resolve((args.Length > num2) ? args[num2] : null, console) ?? Player.LocalPlayer; if ((Object)(object)val == (Object)null) { console.LogError("No valid player found."); return; } MoneyManager.AddMoney(num, val); console.LogSuccess($"Added {num} money. Total is now {MoneyManager.Money}."); } } public class KillCommand : IConsoleCommand { public string Name => "kill"; public string Usage => "kill [target]"; public string Description => "Instantly kills the target. Requires host/server; blocked by active god mode."; public void Execute(string[] args, ConsoleUI console) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (!ModConfig.Cmd_Kill_Enabled.Value) { console.LogError("'kill' is disabled in config."); return; } if (!Object.op_Implicit((Object)(object)Server.Instance) || !((NetworkBehaviour)Server.Instance).IsServerInitialized) { console.LogError("You must be the host/server to kill players."); return; } Player val = PlayerFinder.Resolve((args.Length != 0) ? args[0] : null, console); if (!((Object)(object)val == (Object)null)) { if (PlayerManager.InGodMode) { console.LogWarning("God mode is currently ON, so damage (and this kill) will be ignored."); } val.Vitals.TakeDamage(9999, val.Transform.position, Vector3.zero, true); console.LogSuccess("Killed " + val.SteamName + "."); } } } public class SizeCommand : IConsoleCommand { public string Name => "size"; public string Usage => "size [target] OR size [target]"; public string Description => "Scales a player's transform (visual only - not guaranteed to sync to other clients)."; public void Execute(string[] args, ConsoleUI console) { //IL_008c: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) if (!ModConfig.Cmd_Size_Enabled.Value) { console.LogError("'size' is disabled in config."); return; } float result; float[] array = args.TakeWhile((string a) => float.TryParse(a, out result)).Select(float.Parse).ToArray(); string[] array2 = args.Skip(array.Length).ToArray(); Vector3 val = default(Vector3); if (array.Length == 1) { val = Vector3.one * array[0]; } else { if (array.Length != 3) { console.LogError("Usage: " + Usage); return; } ((Vector3)(ref val))..ctor(array[0], array[1], array[2]); } float value = ModConfig.Size_MinScale.Value; float value2 = ModConfig.Size_MaxScale.Value; ((Vector3)(ref val))..ctor(Mathf.Clamp(val.x, value, value2), Mathf.Clamp(val.y, value, value2), Mathf.Clamp(val.z, value, value2)); Player val2 = PlayerFinder.Resolve((array2.Length != 0) ? array2[0] : null, console); if (!((Object)(object)val2 == (Object)null)) { val2.Transform.localScale = val; console.LogSuccess($"Set {val2.SteamName}'s scale to {val.x:0.##}, {val.y:0.##}, {val.z:0.##}."); console.LogWarning("Scale is applied locally - it may not be visible on other clients unless the game networks Transform scale."); } } } public class GamePauseCommand : IConsoleCommand { public string Name => "game_pause"; public string Usage => "game_pause"; public string Description => "Toggles the game's pause state."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_GamePause_Enabled.Value) { console.LogError("'game_pause' is disabled in config."); return; } PauseManager.TogglePause(!PauseManager.IsPaused); console.LogSuccess("Game is now " + (PauseManager.IsPaused ? "PAUSED" : "UNPAUSED") + "."); } } public class GameDifficultyCommand : IConsoleCommand { public string Name => "game_difficulty"; public string Usage => "game_difficulty [easy/default/hard]"; public string Description => "Gets or sets server difficulty. Requires host/server to change."; public void Execute(string[] args, ConsoleUI console) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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) if (!ModConfig.Cmd_GameDifficulty_Enabled.Value) { console.LogError("'game_difficulty' is disabled in config."); return; } if (args.Length == 0) { console.Log($"Current difficulty: {ServerSettings.Difficulty} " + $"(health x{ServerSettings.HealthMultiplier:0.##}, damage x{ServerSettings.DamageMultiplier:0.##})"); return; } if (!Enum.TryParse(args[0], ignoreCase: true, out Difficulty result)) { console.LogError("Unknown difficulty '" + args[0] + "'. Try: easy, default, hard."); return; } if (!Object.op_Implicit((Object)(object)ServerSettings.Instance) || !((NetworkBehaviour)ServerSettings.Instance).IsServerInitialized) { console.LogError("You must be the host/server to change difficulty."); return; } ServerSettings.Instance.SetDifficulty(result); console.LogSuccess($"Difficulty set to {result}."); } } public class OneHitCommand : IConsoleCommand { public string Name => "onehit"; public string Usage => "onehit "; public string Description => "Enables/disables one-hit-kill damage for all players. Requires host/server."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_OneHit_Enabled.Value) { console.LogError("'onehit' is disabled in config."); return; } if (args.Length < 1 || (args[0] != "on" && args[0] != "off")) { console.LogError("Usage: " + Usage); return; } if (!Object.op_Implicit((Object)(object)ServerSettings.Instance) || !((NetworkBehaviour)ServerSettings.Instance).IsServerInitialized) { console.LogError("You must be the host/server to change one-hit-kill."); return; } bool flag = args[0] == "on"; ServerSettings.Instance._useOneShot.Value = flag; console.LogSuccess("One-hit-kill turned " + (flag ? "ON" : "OFF") + "."); } } public class DamageMultiplierCommand : IConsoleCommand { public string Name => "dmg"; public string Usage => "dmg <1-99>"; public string Description => "Sets the global damage multiplier (x1-x99). Requires host/server."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_Dmg_Enabled.Value) { console.LogError("'dmg' is disabled in config."); return; } if (args.Length < 1 || !float.TryParse(args[0], out var result)) { console.LogError("Usage: " + Usage); return; } result = Mathf.Clamp(result, 1f, 99f); if (!Object.op_Implicit((Object)(object)ServerSettings.Instance) || !((NetworkBehaviour)ServerSettings.Instance).IsServerInitialized) { console.LogError("You must be the host/server to change the damage multiplier."); } else if (ReflectionUtil.TrySetStaticProperty(typeof(ServerSettings), "DamageMultiplier", result)) { console.LogSuccess($"Damage multiplier set to x{result:0.##}."); console.LogWarning("Running 'game_difficulty' afterwards will reset this back to the difficulty preset."); } else { console.LogError("Could not reach ServerSettings.DamageMultiplier."); } } } public class FriendlyFireCommand : IConsoleCommand { public string Name => "ff"; public string Usage => "ff "; public string Description => "Enables/disables friendly fire between players. Requires host/server."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_FF_Enabled.Value) { console.LogError("'ff' is disabled in config."); return; } if (args.Length < 1 || (args[0] != "on" && args[0] != "off")) { console.LogError("Usage: " + Usage); return; } if (!Object.op_Implicit((Object)(object)ServerSettings.Instance) || !((NetworkBehaviour)ServerSettings.Instance).IsServerInitialized) { console.LogError("You must be the host/server to change friendly fire."); return; } bool flag = args[0] == "on"; ServerSettings.Instance._useFriendlyFire.Value = flag; console.LogSuccess("Friendly fire turned " + (flag ? "ON" : "OFF") + "."); } } public class ThirdPersonCommand : IConsoleCommand { public string Name => "thirdperson"; public string Usage => "thirdperson [target]"; public string Description => "Toggles third-person camera (offset + wall clipping via raycast)."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_ThirdPerson_Enabled.Value) { console.LogError("'thirdperson' is disabled in config."); return; } if (args.Length < 1 || (args[0] != "on" && args[0] != "off")) { console.LogError("Usage: " + Usage); return; } bool flag = args[0] == "on"; Player val = PlayerFinder.Resolve((args.Length > 1) ? args[1] : null, console); if (!((Object)(object)val == (Object)null)) { ThirdPersonPatch.SetEnabled(val, flag); console.LogSuccess("Third person " + (flag ? "enabled" : "disabled") + " for " + val.SteamName + "."); if (((NetworkBehaviour)val).Owner == (NetworkConnection)null || !((NetworkBehaviour)val).Owner.IsLocalClient) { console.LogWarning("Target isn't your local player - camera position only affects that player's own client."); } else { console.LogWarning("Aiming/interaction rays likely still originate from the camera - expect ADS and item pickup to feel off in third person."); } } } } public class GotoCommand : IConsoleCommand { public string Name => "goto"; public string Usage => "goto "; public string Description => "Teleports your local player to the target player."; public void Execute(string[] args, ConsoleUI console) { //IL_00c3: 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) if (!ModConfig.Cmd_Goto_Enabled.Value) { console.LogError("'goto' is disabled in config."); return; } if (args.Length < 1) { console.LogError("Usage: " + Usage); return; } if (!Object.op_Implicit((Object)(object)Player.LocalPlayer)) { console.LogError("Local player not found."); return; } Player val = PlayerFinder.Resolve(args[0], console); if (!((Object)(object)val == (Object)null)) { if ((Object)(object)val == (Object)(object)Player.LocalPlayer) { console.LogError("You're already there."); return; } float num = (Object.op_Implicit((Object)(object)val.CamObject) ? val.CamObject.eulerAngles.y : 0f); Player.LocalPlayer.LocalTeleport(val.Transform.position, num, true); console.LogSuccess("Teleported to " + val.SteamName + "."); } } } public class BringCommand : IConsoleCommand { public string Name => "bring"; public string Usage => "bring "; public string Description => "Teleports the target player to your local player. Requires host/server."; public void Execute(string[] args, ConsoleUI console) { //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) if (!ModConfig.Cmd_Bring_Enabled.Value) { console.LogError("'bring' is disabled in config."); return; } if (args.Length < 1) { console.LogError("Usage: " + Usage); return; } if (!Object.op_Implicit((Object)(object)Server.Instance) || !((NetworkBehaviour)Server.Instance).IsServerInitialized) { console.LogError("You must be the host/server to bring players."); return; } if (!Object.op_Implicit((Object)(object)Player.LocalPlayer)) { console.LogError("Local player not found."); return; } Player val = PlayerFinder.Resolve(args[0], console); if (!((Object)(object)val == (Object)null)) { if ((Object)(object)val == (Object)(object)Player.LocalPlayer) { console.LogError("That's you."); return; } float num = (Object.op_Implicit((Object)(object)Player.LocalPlayer.CamObject) ? Player.LocalPlayer.CamObject.eulerAngles.y : 0f); val.RPCTeleport(((NetworkBehaviour)val).Owner, Player.LocalPlayer.Transform.position, num); console.LogSuccess("Brought " + val.SteamName + " to you."); } } } public class KickCommand : IConsoleCommand { public string Name => "kick"; public string Usage => "kick "; public string Description => "Disconnects the target player from the server. Requires host/server."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_Kick_Enabled.Value) { console.LogError("'kick' is disabled in config."); return; } if (args.Length < 1) { console.LogError("Usage: " + Usage); return; } if (!Object.op_Implicit((Object)(object)Server.Instance) || !((NetworkBehaviour)Server.Instance).IsServerInitialized) { console.LogError("You must be the host/server to kick players."); return; } Player val = PlayerFinder.Resolve(args[0], console); if (!((Object)(object)val == (Object)null)) { if ((Object)(object)val == (Object)(object)Player.LocalPlayer) { console.LogError("You can't kick yourself."); return; } string steamName = val.SteamName; ((NetworkBehaviour)val).Owner.Disconnect(true); console.LogSuccess("Kicked " + steamName + "."); } } } public class BanCommand : IConsoleCommand { public string Name => "ban"; public string Usage => "ban "; public string Description => "Bans and kicks the target player by SteamID. Requires host/server."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_Ban_Enabled.Value) { console.LogError("'ban' is disabled in config."); return; } if (args.Length < 1) { console.LogError("Usage: " + Usage); return; } if (!Object.op_Implicit((Object)(object)Server.Instance) || !((NetworkBehaviour)Server.Instance).IsServerInitialized) { console.LogError("You must be the host/server to ban players."); return; } Player val = PlayerFinder.Resolve(args[0], console); if (!((Object)(object)val == (Object)null)) { if ((Object)(object)val == (Object)(object)Player.LocalPlayer) { console.LogError("You can't ban yourself."); return; } string steamName = val.SteamName; ulong steamID = val.SteamID; BanList.Add(steamID); ((NetworkBehaviour)val).Owner.Disconnect(true); console.LogSuccess($"Banned and kicked {steamName} ({steamID})."); console.LogWarning("This only stores the SteamID - auto-kick on rejoin requires patching Server.cs's connection logic."); } } } public class FreeBuyCommand : IConsoleCommand { public string Name => "freebuy"; public string Usage => "freebuy "; public string Description => "Toggles free purchases - all shop items cost nothing while enabled. Requires host/server."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_FreeBuy_Enabled.Value) { console.LogError("'freebuy' is disabled in config."); } else if (args.Length < 1 || (args[0] != "on" && args[0] != "off")) { console.LogError("Usage: " + Usage); } else if (!Object.op_Implicit((Object)(object)Server.Instance) || !((NetworkBehaviour)Server.Instance).IsServerInitialized) { console.LogError("You must be the host/server to change free buy."); } else { console.LogSuccess("Free buy turned " + ((FreeBuyPatch.Enabled = args[0] == "on") ? "ON" : "OFF") + "."); } } } public class AddSlotCommand : IConsoleCommand { private static readonly FieldInfo startingSlotsField = AccessTools.Field(typeof(PlayerInventory), "_startingSlots"); public string Name => "addslot"; public string Usage => "addslot "; public string Description => "Adds (or removes, with a negative amount) inventory slots for target, capped at the configured total. Requires host/server."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_AddSlot_Enabled.Value) { console.LogError("'addslot' is disabled in config."); return; } if (args.Length < 2 || !int.TryParse(args[1], out var result)) { console.LogError("Usage: " + Usage); return; } if (!Object.op_Implicit((Object)(object)Server.Instance) || !((NetworkBehaviour)Server.Instance).IsServerInitialized) { console.LogError("You must be the host/server to change inventory slots."); return; } Player val = PlayerFinder.Resolve(args[0], console); if ((Object)(object)val == (Object)null) { return; } PlayerInventory component = ((Component)val).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { console.LogError("Target has no PlayerInventory component."); return; } int num = 3; if (startingSlotsField != null && startingSlotsField.GetValue(component) is int num2) { num = num2; } int value = ModConfig.AddSlot_MaxTotalSlots.Value; int num3 = Mathf.Max(0, value - num); int value2 = component._extraSlots.Value; int num4 = Mathf.Clamp(value2 + result, 0, num3); if (num4 == value2) { console.LogWarning($"{val.SteamName} is already at the slot cap ({num + num3} total)."); return; } component._extraSlots.Value = (byte)num4; console.LogSuccess($"{val.SteamName} now has {num + num4} total slots ({num4} extra)."); console.LogWarning("The inventory UI has a fixed number of slot objects in the scene - slots beyond what's configured there may not render even though they're unlocked server-side."); } } public class RcsCommand : IConsoleCommand { public string Name => "rcs"; public string Usage => "rcs "; public string Description => "Toggles Random Creature Size - newly spawned fish get a randomized scale."; public void Execute(string[] args, ConsoleUI console) { if (!ModConfig.Cmd_Rcs_Enabled.Value) { console.LogError("'rcs' is disabled in config."); return; } if (args.Length < 1 || (args[0] != "on" && args[0] != "off")) { console.LogError("Usage: " + Usage); return; } console.LogSuccess("Random Creature Size turned " + ((RandomCreatureSizePatch.Enabled = args[0] == "on") ? "ON" : "OFF") + "."); console.LogWarning("Only affects creatures spawned after this is toggled, and the scale is rolled independently per client (visual only, not networked)."); } } public interface IConsoleCommand { string Name { get; } string Usage { get; } string Description { get; } void Execute(string[] args, ConsoleUI console); } public static class CommandProcessor { private static readonly Dictionary commands = new Dictionary(StringComparer.OrdinalIgnoreCase); public static IEnumerable AllCommands => commands.Values.Distinct(); public static void Register(IConsoleCommand command) { commands[command.Name] = command; } public static void RegisterAlias(string alias, string existingName) { if (commands.TryGetValue(existingName, out var value)) { commands[alias] = value; } } public static void RegisterDefaultCommands() { Register(new HelpCommand()); RegisterAlias("cmds", "help"); Register(new ClearCommand()); Register(new PluginsCommand()); Register(new GodCommand()); Register(new FlyCommand()); Register(new NoclipCommand()); Register(new WalkSpeedCommand()); Register(new JumpPowerCommand()); Register(new InfJumpCommand()); Register(new GiveCommand()); Register(new HungryCommand()); Register(new AddMoneyCommand()); Register(new KillCommand()); Register(new SizeCommand()); Register(new GamePauseCommand()); Register(new GameDifficultyCommand()); Register(new OneHitCommand()); Register(new DamageMultiplierCommand()); Register(new FriendlyFireCommand()); Register(new ThirdPersonCommand()); Register(new GotoCommand()); Register(new BringCommand()); Register(new KickCommand()); Register(new BanCommand()); Register(new FreeBuyCommand()); Register(new AddSlotCommand()); Register(new RcsCommand()); } public static void Execute(string line, ConsoleUI console) { string[] array = Tokenize(line); if (array.Length == 0) { return; } string text = array[0]; string[] args = array.Skip(1).ToArray(); if (!commands.TryGetValue(text, out var value)) { console.LogError("Unknown command '" + text + "'. Type 'help' for a list."); return; } try { value.Execute(args, console); } catch (Exception ex) { console.LogError("'" + text + "' threw an exception: " + ex.Message); Plugin.Log.LogError((object)ex); } } private static string[] Tokenize(string line) { List list = new List(); bool flag = false; StringBuilder stringBuilder = new StringBuilder(); foreach (char c in line) { if (c == '"') { flag = !flag; } else if (char.IsWhiteSpace(c) && !flag) { if (stringBuilder.Length > 0) { list.Add(stringBuilder.ToString()); stringBuilder.Clear(); } } else { stringBuilder.Append(c); } } if (stringBuilder.Length > 0) { list.Add(stringBuilder.ToString()); } return list.ToArray(); } } public static class PlayerFinder { public static Player Resolve(string token, ConsoleUI console) { if (string.IsNullOrWhiteSpace(token)) { if (!Object.op_Implicit((Object)(object)Player.LocalPlayer)) { console.LogError("Local player not found (not spawned yet?)."); } return Player.LocalPlayer; } if (ulong.TryParse(token, out var steamId)) { Player val = ((IEnumerable)PlayerManager.Players).FirstOrDefault((Func)((Player p) => Object.op_Implicit((Object)(object)p) && p.SteamID == steamId)); if (Object.op_Implicit((Object)(object)val)) { return val; } } Player val2 = ((IEnumerable)PlayerManager.Players).FirstOrDefault((Func)((Player p) => Object.op_Implicit((Object)(object)p) && string.Equals(p.SteamName, token, StringComparison.OrdinalIgnoreCase))); if (Object.op_Implicit((Object)(object)val2)) { return val2; } Player val3 = ((IEnumerable)PlayerManager.Players).FirstOrDefault((Func)((Player p) => Object.op_Implicit((Object)(object)p) && p.SteamName != null && p.SteamName.IndexOf(token, StringComparison.OrdinalIgnoreCase) >= 0)); if (Object.op_Implicit((Object)(object)val3)) { return val3; } console.LogError("No player found matching '" + token + "'."); return null; } } public static class ReflectionUtil { private static readonly Dictionary<(Type, string), FieldInfo> fieldCache = new Dictionary<(Type, string), FieldInfo>(); private static FieldInfo GetField(Type type, string name) { (Type, string) key = (type, name); if (fieldCache.TryGetValue(key, out var value)) { return value; } FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); fieldCache[key] = field; return field; } public static bool TrySetField(object target, string fieldName, T value) { if (target == null) { return false; } FieldInfo field = GetField(target.GetType(), fieldName); if (field == null) { return false; } field.SetValue(target, value); return true; } public static bool TryGetField(object target, string fieldName, out T value) { value = default(T); if (target == null) { return false; } FieldInfo field = GetField(target.GetType(), fieldName); if (field == null) { return false; } if (!(field.GetValue(target) is T val) || 1 == 0) { return false; } value = val; return true; } public static bool TrySetStaticProperty(Type type, string propertyName, T value) { PropertyInfo property = type.GetProperty(propertyName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (property == null || !property.CanWrite) { return false; } property.SetValue(null, value); return true; } } public class ConsoleUI : IDisposable { private class LogBridge : ILogListener, IDisposable { private readonly Action callback; public LogBridge(Action callback) { this.callback = callback; } public void LogEvent(object sender, LogEventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) callback(eventArgs.Level, ((object)eventArgs).ToString()); } public void Dispose() { } } private GameObject canvasObject; private GameObject windowObject; private RectTransform windowRect; private ScrollRect scrollRect; private Text logText; private RectTransform logContentRect; private RectTransform logViewportRect; private InputField commandInput; private InputField searchInput; private GameObject searchRow; private InputField copyField; private Font font; private readonly List rawLines = new List(); private readonly List plainLines = new List(); private readonly List history = new List(); private int historyIndex = -1; private LogBridge logBridge; private readonly ConcurrentQueue<(DateTime time, string message, Color color)> pendingLogs = new ConcurrentQueue<(DateTime, string, Color)>(); private CursorLockMode prevLockState; private bool prevCursorVisible; private bool loadedInitialLogFile; private int framesUntilInputClear; private readonly Color windowColor = new Color(0.04f, 0.04f, 0.05f, 0.96f); private readonly Color headerColor = new Color(0.07f, 0.07f, 0.09f, 1f); private readonly Color inputBgColor = new Color(0.09f, 0.09f, 0.11f, 1f); private readonly Color accentColor = new Color(0.3f, 0.85f, 0.78f, 1f); private readonly Color accentColorSoft = new Color(0.3f, 0.85f, 0.78f, 0.35f); private readonly Color textColor = new Color(0.85f, 0.86f, 0.9f, 1f); private static readonly Regex LogLevelRegex = new Regex("^\\[(\\w+)\\s*:", RegexOptions.Compiled); private static readonly Regex TagStripRegex = new Regex("<[^>]+>", RegexOptions.Compiled); public bool Visible => (Object)(object)windowObject != (Object)null && windowObject.activeSelf; public ConsoleUI() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) font = Resources.GetBuiltinResource("Arial.ttf"); CreateCanvas(); CreateWindow(); windowObject.SetActive(false); logBridge = new LogBridge(delegate(LogLevel level, string message) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) EnqueueBepInExLog(level, message); }); Logger.Listeners.Add((ILogListener)(object)logBridge); Log("Console UI initialized."); } public void Dispose() { if (logBridge != null) { Logger.Listeners.Remove((ILogListener)(object)logBridge); } } public void Tick() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) bool flag = false; (DateTime, string, Color) result; while (pendingLogs.TryDequeue(out result)) { AppendLineInternal(result.Item2, result.Item3, result.Item1); flag = true; } if (flag) { RefreshLogText(); } if (framesUntilInputClear > 0) { framesUntilInputClear--; if (framesUntilInputClear == 0 && (Object)(object)commandInput != (Object)null) { commandInput.text = string.Empty; } } } public void Log(string message) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) AppendLine(message, textColor); } public void LogSuccess(string message) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) AppendLine(message, new Color(0.45f, 0.9f, 0.55f)); } public void LogWarning(string message) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) AppendLine(message, new Color(0.55f, 0.9f, 0.5f)); } public void LogError(string message) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) AppendLine(message, new Color(1f, 0.4f, 0.4f)); } public void ClearLog() { rawLines.Clear(); plainLines.Clear(); RefreshLogText(); } public void Toggle() { if (Visible) { Close(); } else { Open(); } } public void Open() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) windowObject.SetActive(true); prevLockState = Cursor.lockState; prevCursorVisible = Cursor.visible; Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; commandInput.text = string.Empty; framesUntilInputClear = 2; EventSystem current = EventSystem.current; if (current != null) { current.SetSelectedGameObject(((Component)commandInput).gameObject); } commandInput.ActivateInputField(); if (!loadedInitialLogFile && ModConfig.LoadLogOutputOnFirstOpen.Value) { loadedInitialLogFile = true; LoadLogOutputTail(); } RefreshLogText(); } public void Close() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) windowObject.SetActive(false); Cursor.lockState = prevLockState; Cursor.visible = prevCursorVisible; } public void HandleGlobalShortcuts() { if (!Visible) { return; } bool flag = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305); if (flag && Input.GetKeyDown((KeyCode)102)) { ToggleSearch(); } if (flag && Input.GetKeyDown((KeyCode)97)) { SelectAllInFocusedField(); } if (Input.GetKeyDown((KeyCode)27)) { if (searchRow.activeSelf) { ToggleSearch(); } else { Close(); } } if (Input.GetKeyDown((KeyCode)273) && commandInput.isFocused) { NavigateHistory(-1); } if (Input.GetKeyDown((KeyCode)274) && commandInput.isFocused) { NavigateHistory(1); } } private void SelectAllInFocusedField() { if (commandInput.isFocused) { commandInput.selectionAnchorPosition = 0; commandInput.selectionFocusPosition = commandInput.text.Length; } else if (searchInput.isFocused) { searchInput.selectionAnchorPosition = 0; searchInput.selectionFocusPosition = searchInput.text.Length; } else if ((Object)(object)copyField != (Object)null) { EventSystem current = EventSystem.current; if (current != null) { current.SetSelectedGameObject(((Component)copyField).gameObject); } copyField.ActivateInputField(); copyField.selectionAnchorPosition = 0; copyField.selectionFocusPosition = copyField.text.Length; } } private void NavigateHistory(int direction) { if (history.Count != 0) { historyIndex = Mathf.Clamp(historyIndex + direction, 0, history.Count - 1); commandInput.text = history[historyIndex]; commandInput.caretPosition = commandInput.text.Length; } } private void CreateCanvas() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) canvasObject = new GameObject("HowToFishConsoleCanvas"); Object.DontDestroyOnLoad((Object)(object)canvasObject); Canvas val = canvasObject.AddComponent(); val.renderMode = (RenderMode)0; val.sortingOrder = 10000; CanvasScaler val2 = canvasObject.AddComponent(); val2.uiScaleMode = (ScaleMode)1; val2.referenceResolution = new Vector2(1920f, 1080f); val2.screenMatchMode = (ScreenMatchMode)0; val2.matchWidthOrHeight = 0.5f; canvasObject.AddComponent(); } private void CreateWindow() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_004f: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) windowObject = new GameObject("DevConsoleWindow"); windowObject.transform.SetParent(canvasObject.transform, false); windowRect = windowObject.AddComponent(); windowRect.anchorMin = new Vector2(0.5f, 0.5f); windowRect.anchorMax = new Vector2(0.5f, 0.5f); windowRect.pivot = new Vector2(0.5f, 0.5f); windowRect.sizeDelta = new Vector2(820f, 480f); Image val = windowObject.AddComponent(); ((Graphic)val).color = windowColor; Outline val2 = windowObject.AddComponent(); ((Shadow)val2).effectColor = accentColorSoft; ((Shadow)val2).effectDistance = new Vector2(1.5f, 1.5f); CreateHeader(windowObject.transform); CreateSearchRow(windowObject.transform); CreateLog(windowObject.transform); CreateInputRow(windowObject.transform); } private void CreateHeader(Transform parent) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_002c: 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_0058: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Header"); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent(); val2.anchorMin = new Vector2(0f, 1f); val2.anchorMax = new Vector2(1f, 1f); val2.pivot = new Vector2(0.5f, 1f); val2.sizeDelta = new Vector2(0f, 42f); ((Graphic)val.AddComponent()).color = headerColor; ConsoleDragHandle consoleDragHandle = val.AddComponent(); consoleDragHandle.Target = windowRect; Text val3 = CreateText(val.transform, "CONSOLE", 20, (FontStyle)1, (TextAnchor)3, accentColor); ((Graphic)val3).rectTransform.anchorMin = new Vector2(0f, 0f); ((Graphic)val3).rectTransform.anchorMax = new Vector2(0.6f, 1f); ((Graphic)val3).rectTransform.offsetMin = new Vector2(15f, 0f); ((Graphic)val3).rectTransform.offsetMax = Vector2.zero; Text val4 = CreateText(val.transform, "~ / F1 close • Ctrl+F search • Ctrl+A select all", 12, (FontStyle)0, (TextAnchor)5, new Color(0.5f, 0.5f, 0.55f)); ((Graphic)val4).rectTransform.anchorMin = new Vector2(0.4f, 0f); ((Graphic)val4).rectTransform.anchorMax = new Vector2(1f, 1f); ((Graphic)val4).rectTransform.offsetMin = Vector2.zero; ((Graphic)val4).rectTransform.offsetMax = new Vector2(-15f, 0f); } private void CreateSearchRow(Transform parent) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_00aa: Unknown result type (might be due to invalid IL or missing references) searchRow = new GameObject("SearchRow"); searchRow.transform.SetParent(parent, false); RectTransform val = searchRow.AddComponent(); val.anchorMin = new Vector2(0f, 1f); val.anchorMax = new Vector2(1f, 1f); val.pivot = new Vector2(0.5f, 1f); val.sizeDelta = new Vector2(-20f, 32f); val.anchoredPosition = new Vector2(0f, -48f); ((Graphic)searchRow.AddComponent()).color = inputBgColor; searchInput = CreateInputField(searchRow.transform, "Search log..."); ((UnityEvent)(object)searchInput.onValueChanged).AddListener((UnityAction)delegate { RefreshLogText(); }); searchRow.SetActive(false); } private void CreateLog(Transform parent) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0022: 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_0044: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Expected O, but got Unknown //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("LogScrollView"); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent(); val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = new Vector2(15f, 55f); val2.offsetMax = new Vector2(-15f, -55f); logViewportRect = val2; Image val3 = val.AddComponent(); ((Graphic)val3).color = new Color(0f, 0f, 0f, 0f); ((Graphic)val3).raycastTarget = true; scrollRect = val.AddComponent(); scrollRect.horizontal = false; scrollRect.vertical = true; scrollRect.movementType = (MovementType)2; scrollRect.scrollSensitivity = 25f; GameObject val4 = new GameObject("LogMask"); val4.transform.SetParent(val.transform, false); RectTransform val5 = val4.AddComponent(); val5.anchorMin = Vector2.zero; val5.anchorMax = Vector2.one; val5.offsetMin = Vector2.zero; val5.offsetMax = Vector2.zero; val4.AddComponent(); scrollRect.viewport = val5; GameObject val6 = new GameObject("LogContent"); val6.transform.SetParent(val4.transform, false); logContentRect = val6.AddComponent(); logContentRect.anchorMin = new Vector2(0f, 1f); logContentRect.anchorMax = new Vector2(1f, 1f); logContentRect.pivot = new Vector2(0.5f, 1f); logContentRect.sizeDelta = Vector2.zero; logContentRect.anchoredPosition = Vector2.zero; ContentSizeFitter val7 = val6.AddComponent(); val7.horizontalFit = (FitMode)0; val7.verticalFit = (FitMode)2; logText = val6.AddComponent(); logText.font = font; logText.fontSize = 15; logText.alignment = (TextAnchor)0; ((Graphic)logText).color = textColor; logText.supportRichText = true; logText.horizontalOverflow = (HorizontalWrapMode)0; logText.verticalOverflow = (VerticalWrapMode)1; ((Graphic)logText).raycastTarget = false; logText.text = ""; scrollRect.content = logContentRect; GameObject val8 = new GameObject("LogCopyField"); val8.transform.SetParent(val6.transform, false); RectTransform val9 = val8.AddComponent(); val9.anchorMin = Vector2.zero; val9.anchorMax = Vector2.one; val9.offsetMin = Vector2.zero; val9.offsetMax = Vector2.zero; Image val10 = val8.AddComponent(); ((Graphic)val10).color = new Color(0f, 0f, 0f, 0f); ((Graphic)val10).raycastTarget = true; Text val11 = CreateText(val8.transform, "", 15, (FontStyle)0, (TextAnchor)0, new Color(0f, 0f, 0f, 0f)); ((Graphic)val11).rectTransform.anchorMin = Vector2.zero; ((Graphic)val11).rectTransform.anchorMax = Vector2.one; ((Graphic)val11).rectTransform.offsetMin = Vector2.zero; ((Graphic)val11).rectTransform.offsetMax = Vector2.zero; val11.horizontalOverflow = (HorizontalWrapMode)0; val11.verticalOverflow = (VerticalWrapMode)1; ((Graphic)val11).raycastTarget = false; val11.supportRichText = false; copyField = val8.AddComponent(); ((Selectable)copyField).targetGraphic = (Graphic)(object)val10; copyField.textComponent = val11; copyField.lineType = (LineType)2; copyField.readOnly = true; copyField.selectionColor = new Color(0.3f, 0.85f, 0.78f, 0.35f); copyField.customCaretColor = true; copyField.caretColor = new Color(0f, 0f, 0f, 0f); copyField.caretWidth = 0; copyField.text = ""; } private void CreateInputRow(Transform parent) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_002c: 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_0058: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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) GameObject val = new GameObject("InputRow"); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent(); val2.anchorMin = new Vector2(0f, 0f); val2.anchorMax = new Vector2(1f, 0f); val2.pivot = new Vector2(0.5f, 0f); val2.sizeDelta = new Vector2(-20f, 40f); val2.anchoredPosition = new Vector2(0f, 10f); ((Graphic)val.AddComponent()).color = inputBgColor; Outline val3 = val.AddComponent(); ((Shadow)val3).effectColor = accentColorSoft; ((Shadow)val3).effectDistance = new Vector2(1f, 1f); Text val4 = CreateText(val.transform, ">", 18, (FontStyle)1, (TextAnchor)4, accentColor); ((Graphic)val4).rectTransform.anchorMin = new Vector2(0f, 0f); ((Graphic)val4).rectTransform.anchorMax = new Vector2(0f, 1f); ((Graphic)val4).rectTransform.sizeDelta = new Vector2(28f, 0f); ((Graphic)val4).rectTransform.anchoredPosition = new Vector2(14f, 0f); commandInput = CreateInputField(val.transform, "Type a command... (help)"); RectTransform component = ((Component)commandInput).GetComponent(); component.offsetMin = new Vector2(34f, component.offsetMin.y); ((UnityEvent)(object)commandInput.onEndEdit).AddListener((UnityAction)OnCommandSubmitted); } private InputField CreateInputField(Transform parent, string placeholder) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0022: 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_0044: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_0164: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("InputField"); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent(); val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = new Vector2(12f, 4f); val2.offsetMax = new Vector2(-12f, -4f); Image val3 = val.AddComponent(); ((Graphic)val3).color = new Color(0f, 0f, 0f, 0f); InputField val4 = val.AddComponent(); ((Selectable)val4).targetGraphic = (Graphic)(object)val3; Text val5 = CreateText(val.transform, placeholder, 15, (FontStyle)2, (TextAnchor)3, new Color(0.45f, 0.45f, 0.5f)); ((Graphic)val5).rectTransform.anchorMin = Vector2.zero; ((Graphic)val5).rectTransform.anchorMax = Vector2.one; ((Graphic)val5).rectTransform.offsetMin = Vector2.zero; ((Graphic)val5).rectTransform.offsetMax = Vector2.zero; Text val6 = CreateText(val.transform, "", 15, (FontStyle)0, (TextAnchor)3, textColor); ((Graphic)val6).rectTransform.anchorMin = Vector2.zero; ((Graphic)val6).rectTransform.anchorMax = Vector2.one; ((Graphic)val6).rectTransform.offsetMin = Vector2.zero; ((Graphic)val6).rectTransform.offsetMax = Vector2.zero; val4.textComponent = val6; val4.placeholder = (Graphic)(object)val5; return val4; } private Text CreateText(Transform parent, string text, int size, FontStyle style, TextAnchor alignment, Color color) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_003f: 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_0051: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Text"); val.transform.SetParent(parent, false); Text val2 = val.AddComponent(); val2.font = font; val2.text = text; val2.fontSize = size; val2.fontStyle = style; val2.alignment = alignment; ((Graphic)val2).color = color; val2.horizontalOverflow = (HorizontalWrapMode)0; val2.verticalOverflow = (VerticalWrapMode)0; return val2; } private void ToggleSearch() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) bool flag = !searchRow.activeSelf; searchRow.SetActive(flag); logViewportRect.offsetMax = new Vector2(-15f, (float)(flag ? (-91) : (-55))); RefreshLogText(); if (flag) { EventSystem current = EventSystem.current; if (current != null) { current.SetSelectedGameObject(((Component)searchInput).gameObject); } searchInput.ActivateInputField(); return; } searchInput.text = ""; RefreshLogText(); EventSystem current2 = EventSystem.current; if (current2 != null) { current2.SetSelectedGameObject(((Component)commandInput).gameObject); } commandInput.ActivateInputField(); } private void OnCommandSubmitted(string text) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if ((Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)) && !string.IsNullOrWhiteSpace(text)) { AppendLine("> " + text, textColor); history.Add(text); historyIndex = history.Count; commandInput.text = string.Empty; commandInput.ActivateInputField(); CommandProcessor.Execute(text, this); } } private Color ColorForLevelName(string levelName) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00a3: Unknown result type (might be due to invalid IL or missing references) string text = levelName.ToLowerInvariant(); if (1 == 0) { } Color result = (Color)(text switch { "fatal" => new Color(1f, 0.35f, 0.35f), "error" => new Color(1f, 0.4f, 0.4f), "warning" => new Color(0.55f, 0.9f, 0.5f), "debug" => new Color(0.5f, 0.5f, 0.55f), _ => textColor, }); if (1 == 0) { } return result; } private Color ColorForLevel(LogLevel level) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected I4, but got Unknown //IL_0034: 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_004b: 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) //IL_0082: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } Color result; switch (level - 1) { default: if ((int)level != 32) { goto case 2; } result = new Color(0.5f, 0.5f, 0.55f); break; case 0: result = new Color(1f, 0.35f, 0.35f); break; case 1: result = new Color(1f, 0.4f, 0.4f); break; case 3: result = new Color(0.55f, 0.9f, 0.5f); break; case 2: result = textColor; break; } if (1 == 0) { } return result; } private void LoadLogOutputTail() { //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) try { string path = Path.Combine(Paths.BepInExRootPath, "LogOutput.log"); if (!File.Exists(path)) { return; } using FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); using StreamReader streamReader = new StreamReader(stream); string[] array = (from l in streamReader.ReadToEnd().Split('\n') where !string.IsNullOrWhiteSpace(l) select l).ToArray(); int num = Mathf.Min(array.Length, ModConfig.LoadLogOutputLineCount.Value); foreach (string item in array.Skip(array.Length - num)) { string text = item.TrimEnd('\r'); Match match = LogLevelRegex.Match(text); Color val = (Color)(match.Success ? ColorForLevelName(match.Groups[1].Value) : new Color(0.5f, 0.5f, 0.55f)); AddRawLine((val == textColor) ? text : WrapColor(text, val)); } RefreshLogText(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not read LogOutput.log tail: " + ex.Message)); } } private void EnqueueBepInExLog(LogLevel level, string formattedLine) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) pendingLogs.Enqueue((DateTime.Now, formattedLine, ColorForLevel(level))); } private void AppendLine(string message, Color color) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) AppendLineInternal(message, color, DateTime.Now); RefreshLogText(); } private void AppendLineInternal(string message, Color color, DateTime time) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) string text = ((color == textColor) ? message : WrapColor(message, color)); string coloredLine = (ModConfig.ShowTimestamps.Value ? (WrapColor("[" + time.ToString(ModConfig.TimestampFormat.Value) + "] ", new Color(0.5f, 0.5f, 0.55f)) + text) : text); AddRawLine(coloredLine); } private void AddRawLine(string coloredLine) { rawLines.Add(coloredLine); plainLines.Add(StripTags(coloredLine)); int value = ModConfig.MaxLogLines.Value; while (rawLines.Count > value) { rawLines.RemoveAt(0); plainLines.RemoveAt(0); } } private static string StripTags(string s) { return TagStripRegex.Replace(s, string.Empty); } private static string WrapColor(string message, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) string text = ColorUtility.ToHtmlStringRGBA(color); return "" + message + ""; } private void RefreshLogText() { if ((Object)(object)logText == (Object)null) { return; } bool flag = (Object)(object)scrollRect != (Object)null && scrollRect.verticalNormalizedPosition < 0.02f; string value = (((Object)(object)searchInput != (Object)null) ? searchInput.text : null); List list = new List(); List list2 = new List(); for (int i = 0; i < rawLines.Count; i++) { if (string.IsNullOrEmpty(value) || plainLines[i].IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) { list.Add(rawLines[i]); list2.Add(plainLines[i]); } } logText.text = string.Join("\n", list); if ((Object)(object)copyField != (Object)null) { copyField.text = string.Join("\n", list2); } Canvas.ForceUpdateCanvases(); LayoutRebuilder.ForceRebuildLayoutImmediate(logContentRect); if (flag) { scrollRect.verticalNormalizedPosition = 0f; } } } public class ConsoleDragHandle : MonoBehaviour, IDragHandler, IEventSystemHandler, IBeginDragHandler { public RectTransform Target; private Vector2 startMousePos; private Vector2 startWindowPos; public void OnBeginDrag(PointerEventData eventData) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //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) startMousePos = eventData.position; startWindowPos = Target.anchoredPosition; } public void OnDrag(PointerEventData eventData) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //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) //IL_001e: Unknown result type (might be due to invalid IL or missing references) Target.anchoredPosition = startWindowPos + (eventData.position - startMousePos); } } [HarmonyPatch(typeof(PlayerVitals))] public static class HungerPatch { private static readonly HashSet hungerDisabledFor = new HashSet(); public static void SetHungerEnabled(PlayerVitals vitals, bool enabled) { if (enabled) { hungerDisabledFor.Remove(vitals); } else { hungerDisabledFor.Add(vitals); } } public static bool IsHungerDisabled(PlayerVitals vitals) { return hungerDisabledFor.Contains(vitals); } [HarmonyPatch("LowerFullnessTick")] [HarmonyPrefix] private static bool LowerFullnessTick_Prefix(PlayerVitals __instance) { return !hungerDisabledFor.Contains(__instance); } [HarmonyPatch("DamageFromFullness")] [HarmonyPrefix] private static bool DamageFromFullness_Prefix(PlayerVitals __instance) { return !hungerDisabledFor.Contains(__instance); } } public static class ModConfig { public static ConfigEntry ToggleKeyPrimary; public static ConfigEntry ToggleKeySecondary; public static ConfigEntry MaxLogLines; public static ConfigEntry ShowTimestamps; public static ConfigEntry TimestampFormat; public static ConfigEntry LoadLogOutputOnFirstOpen; public static ConfigEntry LoadLogOutputLineCount; public static ConfigEntry Cmd_God_Enabled; public static ConfigEntry Cmd_Fly_Enabled; public static ConfigEntry Fly_Speed; public static ConfigEntry Cmd_Noclip_Enabled; public static ConfigEntry Noclip_Speed; public static ConfigEntry Cmd_WalkSpeed_Enabled; public static ConfigEntry WalkSpeed_Default; public static ConfigEntry Cmd_JumpPower_Enabled; public static ConfigEntry JumpPower_Default; public static ConfigEntry Cmd_InfJump_Enabled; public static ConfigEntry Cmd_Give_Enabled; public static ConfigEntry Cmd_Hungry_Enabled; public static ConfigEntry Cmd_AddMoney_Enabled; public static ConfigEntry AddMoney_DefaultAmount; public static ConfigEntry Cmd_Kill_Enabled; public static ConfigEntry Cmd_Size_Enabled; public static ConfigEntry Size_MinScale; public static ConfigEntry Size_MaxScale; public static ConfigEntry Cmd_GamePause_Enabled; public static ConfigEntry Cmd_GameDifficulty_Enabled; public static ConfigEntry Cmd_Plugins_Enabled; public static ConfigEntry Cmd_OneHit_Enabled; public static ConfigEntry Cmd_Dmg_Enabled; public static ConfigEntry Cmd_FF_Enabled; public static ConfigEntry Cmd_ThirdPerson_Enabled; public static ConfigEntry ThirdPerson_Distance; public static ConfigEntry ThirdPerson_HeightOffset; public static ConfigEntry ThirdPerson_ClipRadius; public static ConfigEntry Cmd_Goto_Enabled; public static ConfigEntry Cmd_Bring_Enabled; public static ConfigEntry Cmd_Kick_Enabled; public static ConfigEntry Cmd_Ban_Enabled; public static ConfigEntry Cmd_FreeBuy_Enabled; public static ConfigEntry Cmd_AddSlot_Enabled; public static ConfigEntry AddSlot_MaxTotalSlots; public static ConfigEntry Cmd_Rcs_Enabled; public static ConfigEntry RCS_MinScale; public static ConfigEntry RCS_MaxScale; public static void Bind(ConfigFile config) { ToggleKeyPrimary = config.Bind("General", "ToggleKeyPrimary", (KeyCode)96, "Key to open/close the console."); ToggleKeySecondary = config.Bind("General", "ToggleKeySecondary", (KeyCode)282, "Secondary (fallback) key to open/close the console."); MaxLogLines = config.Bind("General", "MaxLogLines", 500, "Maximum number of lines kept in the console log buffer."); ShowTimestamps = config.Bind("General", "ShowTimestamps", true, "Show [HH:mm:ss] before each log line."); TimestampFormat = config.Bind("General", "TimestampFormat", "HH:mm:ss", "Time format (.NET DateTime format string)."); LoadLogOutputOnFirstOpen = config.Bind("General", "LoadLogOutputOnFirstOpen", true, "Load the tail of BepInEx/LogOutput.log when the console is first opened."); LoadLogOutputLineCount = config.Bind("General", "LoadLogOutputLineCount", 200, "How many trailing lines of LogOutput.log to load on first open."); Cmd_God_Enabled = config.Bind("Commands", "god.Enabled", true, "Enable the 'god' command."); Cmd_Fly_Enabled = config.Bind("Commands", "fly.Enabled", true, "Enable the 'fly' command."); Fly_Speed = config.Bind("Commands", "fly.Speed", 8f, "Fly mode movement speed."); Cmd_Noclip_Enabled = config.Bind("Commands", "noclip.Enabled", true, "Enable the 'noclip' command."); Noclip_Speed = config.Bind("Commands", "noclip.Speed", 10f, "Noclip movement speed."); Cmd_WalkSpeed_Enabled = config.Bind("Commands", "walkspeed.Enabled", true, "Enable the 'walkspeed' command."); WalkSpeed_Default = config.Bind("Commands", "walkspeed.Default", 5f, "Default value used when 'walkspeed' is called without a number (reset)."); Cmd_JumpPower_Enabled = config.Bind("Commands", "jumppower.Enabled", true, "Enable the 'jumppower' command."); JumpPower_Default = config.Bind("Commands", "jumppower.Default", 6f, "Default value used when 'jumppower' is called without a number (reset)."); Cmd_InfJump_Enabled = config.Bind("Commands", "infjump.Enabled", true, "Enable the 'infjump' command."); Cmd_Give_Enabled = config.Bind("Commands", "give.Enabled", true, "Enable the 'give' command."); Cmd_Hungry_Enabled = config.Bind("Commands", "hungry.Enabled", true, "Enable the 'hungry' command."); Cmd_AddMoney_Enabled = config.Bind("Commands", "addmoney.Enabled", true, "Enable the 'addmoney' command."); AddMoney_DefaultAmount = config.Bind("Commands", "addmoney.DefaultAmount", 1000, "Default amount used when 'addmoney' is called without a number."); Cmd_Kill_Enabled = config.Bind("Commands", "kill.Enabled", true, "Enable the 'kill' command."); Cmd_Size_Enabled = config.Bind("Commands", "size.Enabled", true, "Enable the 'size' command."); Size_MinScale = config.Bind("Commands", "size.MinScale", 0.1f, "Minimum scale per axis."); Size_MaxScale = config.Bind("Commands", "size.MaxScale", 5f, "Maximum scale per axis."); Cmd_GamePause_Enabled = config.Bind("Commands", "game_pause.Enabled", true, "Enable the 'game_pause' command."); Cmd_GameDifficulty_Enabled = config.Bind("Commands", "game_difficulty.Enabled", true, "Enable the 'game_difficulty' command."); Cmd_Plugins_Enabled = config.Bind("Commands", "plugins.Enabled", true, "Enable the 'plugins' command."); Cmd_OneHit_Enabled = config.Bind("Commands", "onehit.Enabled", true, "Enable the 'onehit' command."); Cmd_Dmg_Enabled = config.Bind("Commands", "dmg.Enabled", true, "Enable the 'dmg' command."); Cmd_FF_Enabled = config.Bind("Commands", "ff.Enabled", true, "Enable the 'ff' command."); Cmd_ThirdPerson_Enabled = config.Bind("Commands", "thirdperson.Enabled", true, "Enable the 'thirdperson' command."); ThirdPerson_Distance = config.Bind("Commands", "thirdperson.Distance", 3.5f, "Camera distance behind the player in third person."); ThirdPerson_HeightOffset = config.Bind("Commands", "thirdperson.HeightOffset", 0.3f, "Extra vertical offset added to the third-person camera."); ThirdPerson_ClipRadius = config.Bind("Commands", "thirdperson.ClipRadius", 0.2f, "SphereCast radius used to keep the camera out of walls."); Cmd_Goto_Enabled = config.Bind("Commands", "goto.Enabled", true, "Enable the 'goto' command."); Cmd_Bring_Enabled = config.Bind("Commands", "bring.Enabled", true, "Enable the 'bring' command."); Cmd_Kick_Enabled = config.Bind("Commands", "kick.Enabled", true, "Enable the 'kick' command."); Cmd_Ban_Enabled = config.Bind("Commands", "ban.Enabled", true, "Enable the 'ban' command."); Cmd_FreeBuy_Enabled = config.Bind("Commands", "freebuy.Enabled", true, "Enable the 'freebuy' command."); Cmd_AddSlot_Enabled = config.Bind("Commands", "addslot.Enabled", true, "Enable the 'addslot' command."); AddSlot_MaxTotalSlots = config.Bind("Commands", "addslot.MaxTotalSlots", 9, "Maximum total inventory slots (starting slots + extra slots) that 'addslot' will allow."); Cmd_Rcs_Enabled = config.Bind("Commands", "rcs.Enabled", true, "Enable the 'rcs' command."); RCS_MinScale = config.Bind("Commands", "rcs.MinScale", 0.5f, "Minimum random scale applied to newly spawned creatures."); RCS_MaxScale = config.Bind("Commands", "rcs.MaxScale", 2.5f, "Maximum random scale applied to newly spawned creatures."); } } public enum FreeMoveMode { None, Fly, Noclip } [HarmonyPatch(typeof(PlayerMovement))] public static class FreeMovementPatch { private static readonly Dictionary activeModes = new Dictionary(); private static readonly Dictionary originalGravity = new Dictionary(); private static readonly Dictionary originalDetectCollisions = new Dictionary(); private static readonly FieldInfo playerField = AccessTools.Field(typeof(PlayerMovement), "_player"); public static FreeMoveMode GetMode(Player player) { FreeMoveMode value; return activeModes.TryGetValue(player, out value) ? value : FreeMoveMode.None; } public static FreeMoveMode Toggle(Player player, FreeMoveMode mode) { FreeMoveMode mode2 = GetMode(player); if (mode2 == mode) { SetMode(player, FreeMoveMode.None); return FreeMoveMode.None; } SetMode(player, mode); return mode; } private static void SetMode(Player player, FreeMoveMode mode) { Rigidbody rigidbody = player.Rigidbody; if (mode != FreeMoveMode.None) { if (!originalGravity.ContainsKey(player) && Object.op_Implicit((Object)(object)rigidbody)) { originalGravity[player] = rigidbody.useGravity; } if (!originalDetectCollisions.ContainsKey(player) && Object.op_Implicit((Object)(object)rigidbody)) { originalDetectCollisions[player] = rigidbody.detectCollisions; } activeModes[player] = mode; return; } activeModes.Remove(player); if (Object.op_Implicit((Object)(object)rigidbody)) { if (originalGravity.TryGetValue(player, out var value)) { rigidbody.useGravity = value; } if (originalDetectCollisions.TryGetValue(player, out var value2)) { rigidbody.detectCollisions = value2; } } originalGravity.Remove(player); originalDetectCollisions.Remove(player); } [HarmonyPatch("FixedUpdate")] [HarmonyPostfix] private static void FixedUpdate_Postfix(PlayerMovement __instance) { //IL_008f: 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_0175: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) if (activeModes.Count == 0) { return; } object? obj = playerField?.GetValue(__instance); Player val = (Player)((obj is Player) ? obj : null); if (val == null || !activeModes.TryGetValue(val, out var value)) { return; } Rigidbody rigidbody = val.Rigidbody; if (!Object.op_Implicit((Object)(object)rigidbody)) { return; } rigidbody.useGravity = false; rigidbody.detectCollisions = value != FreeMoveMode.Noclip; Vector3 val2 = Vector3.zero; if (((NetworkBehaviour)val).Owner != (NetworkConnection)null && ((NetworkBehaviour)val).Owner.IsLocalClient) { Transform camObject = val.CamObject; float axisRaw = Input.GetAxisRaw("Horizontal"); float axisRaw2 = Input.GetAxisRaw("Vertical"); val2 = camObject.forward * axisRaw2 + camObject.right * axisRaw; if (((Vector3)(ref val2)).sqrMagnitude > 1f) { ((Vector3)(ref val2)).Normalize(); } if (Input.GetKey((KeyCode)32)) { val2 += Vector3.up; } if (Input.GetKey((KeyCode)306)) { val2 -= Vector3.up; } float num = ((value == FreeMoveMode.Noclip) ? ModConfig.Noclip_Speed.Value : ModConfig.Fly_Speed.Value); val2 *= num; } rigidbody.linearVelocity = val2; } } [HarmonyPatch(typeof(PlayerMovement))] public static class InfiniteJumpPatch { private static readonly HashSet enabledFor = new HashSet(); private static readonly FieldInfo playerField = AccessTools.Field(typeof(PlayerMovement), "_player"); public static void SetEnabled(Player player, bool enabled) { if (enabled) { enabledFor.Add(player); } else { enabledFor.Remove(player); } } public static bool IsEnabled(Player player) { return enabledFor.Contains(player); } [HarmonyPatch("JumpInput")] [HarmonyPrefix] private static bool JumpInput_Prefix(PlayerMovement __instance) { object? obj = playerField?.GetValue(__instance); Player val = (Player)((obj is Player) ? obj : null); if (val == null || !enabledFor.Contains(val)) { return true; } if (!val.BlockInputs) { __instance.Jump(); } return false; } } [HarmonyPatch(typeof(PlayerCamera))] public static class ThirdPersonPatch { private static readonly HashSet enabledFor = new HashSet(); private static readonly FieldInfo playerField = AccessTools.Field(typeof(PlayerCamera), "_player"); public static void SetEnabled(Player player, bool enabled) { if (enabled) { enabledFor.Add(player); } else { enabledFor.Remove(player); } } public static bool IsEnabled(Player player) { return (Object)(object)player != (Object)null && enabledFor.Contains(player); } [HarmonyPatch("SetCamPosRot")] [HarmonyPostfix] private static void SetCamPosRot_Postfix(PlayerCamera __instance) { //IL_0064: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) if (enabledFor.Count == 0) { return; } object? obj = playerField?.GetValue(__instance); Player val = (Player)((obj is Player) ? obj : null); if (val == null || !enabledFor.Contains(val)) { return; } Transform camTransform = __instance.CamTransform; Vector3 position = camTransform.position; Quaternion rotation = camTransform.rotation; float value = ModConfig.ThirdPerson_Distance.Value; float value2 = ModConfig.ThirdPerson_HeightOffset.Value; float value3 = ModConfig.ThirdPerson_ClipRadius.Value; Vector3 val2 = position - rotation * Vector3.forward * value + Vector3.up * value2; Vector3 val3 = val2 - position; float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude > 0.001f) { Vector3 val4 = val3 / magnitude; RaycastHit[] array = Physics.SphereCastAll(position, value3, val4, magnitude, -1, (QueryTriggerInteraction)1); float num = magnitude; RaycastHit[] array2 = array; for (int i = 0; i < array2.Length; i++) { RaycastHit val5 = array2[i]; if (!((Component)((RaycastHit)(ref val5)).collider).transform.IsChildOf(val.Transform) && !((Object)(object)((Component)((RaycastHit)(ref val5)).collider).transform == (Object)(object)val.Transform) && ((RaycastHit)(ref val5)).distance < num) { num = ((RaycastHit)(ref val5)).distance; } } if (num < magnitude) { val2 = position + val4 * Mathf.Max(num - value3, 0.05f); } } camTransform.position = val2; } } [HarmonyPatch(typeof(MoneyManager), "CanAfford", new Type[] { typeof(int) })] public static class FreeBuyPatch { public static bool Enabled; [HarmonyPrefix] private static bool CanAfford_Prefix(ref bool __result) { if (!Enabled) { return true; } __result = true; return false; } } [HarmonyPatch(typeof(Creature), "Awake")] public static class RandomCreatureSizePatch { public static bool Enabled; [HarmonyPostfix] private static void Awake_Postfix(Creature __instance) { //IL_0033: 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) if (Enabled) { float value = ModConfig.RCS_MinScale.Value; float value2 = ModConfig.RCS_MaxScale.Value; float num = Random.Range(value, value2); ((Component)__instance).transform.localScale = Vector3.one * num; } } } [BepInPlugin("com.neko.howtofish.console", "How To Fish Dev Console", "1.1.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; private Harmony harmony; private ConsoleUI consoleUI; public static Plugin Instance { get; private set; } private void Awake() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; ModConfig.Bind(((BaseUnityPlugin)this).Config); harmony = new Harmony("com.neko.howtofish.console"); harmony.PatchAll(); CommandProcessor.RegisterDefaultCommands(); consoleUI = new ConsoleUI(); Log.LogInfo((object)"How To Fish Dev Console loaded. Press ~ or F1 to open."); } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(ModConfig.ToggleKeyPrimary.Value) || Input.GetKeyDown(ModConfig.ToggleKeySecondary.Value)) { consoleUI.Toggle(); } consoleUI.Tick(); consoleUI.HandleGlobalShortcuts(); } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } consoleUI?.Dispose(); } } }