Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BaboonRizz v1.0.0
BaboonRizzMod.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BaboonRizzMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BaboonRizzMod")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("a67e69b4-b4d5-4297-8395-09c2fde656de")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace BaboonRizzMod; internal class ConfigurationController { private ConfigEntry<float> MovementSpeedCfg; private ConfigEntry<bool> InfiniteSprintCfg; private ConfigEntry<float> JumpForceCfg; private ConfigEntry<float> ClimbSpeedCfg; private ConfigEntry<bool> AllowSprintCommandCfg; private ConfigEntry<bool> AllowSpeedCommandCfg; private ConfigEntry<bool> AllowJumpCommandCfg; private ConfigEntry<bool> AllowClimbCommandCfg; private ConfigEntry<bool> AllowScrapCommandCfg; private ConfigEntry<bool> AllowHealthCommandCfg; private ConfigEntry<bool> AllowDoorCommandCfg; internal float MovementSpeed { get { return MovementSpeedCfg.Value; } set { MovementSpeedCfg.Value = value; } } internal bool InfiniteSprint { get { return InfiniteSprintCfg.Value; } set { InfiniteSprintCfg.Value = value; } } internal float JumpForce { get { return JumpForceCfg.Value; } set { JumpForceCfg.Value = value; } } internal float ClimbSpeed { get { return ClimbSpeedCfg.Value; } set { ClimbSpeedCfg.Value = value; } } internal bool AllowSprintCommand { get { return AllowSprintCommandCfg.Value; } set { AllowSprintCommandCfg.Value = value; } } internal bool AllowSpeedCommand { get { return AllowSpeedCommandCfg.Value; } set { AllowSpeedCommandCfg.Value = value; } } internal bool AllowJumpCommand { get { return AllowJumpCommandCfg.Value; } set { AllowJumpCommandCfg.Value = value; } } internal bool AllowClimbCommand { get { return AllowClimbCommandCfg.Value; } set { AllowClimbCommandCfg.Value = value; } } internal bool AllowScrapCommand { get { return AllowScrapCommandCfg.Value; } set { AllowScrapCommandCfg.Value = value; } } internal bool AllowHealthCommand { get { return AllowHealthCommandCfg.Value; } set { AllowHealthCommandCfg.Value = value; } } internal bool AllowDoorCommand { get { return AllowDoorCommandCfg.Value; } set { AllowDoorCommandCfg.Value = value; } } public ConfigurationController(ConfigFile config) { MovementSpeedCfg = config.Bind<float>("Options", "Set Custom Movement Speed", 4.6f, (ConfigDescription)null); InfiniteSprintCfg = config.Bind<bool>("Options", "Enable Infinite Sprint", false, (ConfigDescription)null); JumpForceCfg = config.Bind<float>("Options", "Set Custom Jump Force", 13f, (ConfigDescription)null); ClimbSpeedCfg = config.Bind<float>("Options", "Set Custom Climb Speed", 3f, (ConfigDescription)null); AllowSprintCommandCfg = config.Bind<bool>("Chat Commands", "Enable Infinite Sprint Command /sprint", true, (ConfigDescription)null); AllowSpeedCommandCfg = config.Bind<bool>("Chat Commands", "Enable Movement Speed Command /speed <value>", true, (ConfigDescription)null); AllowJumpCommandCfg = config.Bind<bool>("Chat Commands", "Enable Jump Force Command /jump <value>", true, (ConfigDescription)null); AllowClimbCommandCfg = config.Bind<bool>("Chat Commands", "Enable Climb Speed Command /climb <value>", true, (ConfigDescription)null); AllowScrapCommandCfg = config.Bind<bool>("Chat Commands", "Enable Scrap Value Command /scrap <value>", true, (ConfigDescription)null); AllowHealthCommandCfg = config.Bind<bool>("Chat Commands", "Enable Player Health Command /health <value>", true, (ConfigDescription)null); AllowDoorCommandCfg = config.Bind<bool>("Chat Commands", "Enable Open Door Command /door <code>", true, (ConfigDescription)null); } } [HarmonyPatch] internal class GamePatcher { internal static PlayerControllerB player; internal static List<TerminalAccessibleObject> BigDoorsList = new List<TerminalAccessibleObject>(); [HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")] [HarmonyPrefix] private static void HUDPatch(ref HUDManager __instance) { try { if (Utilities.HandleCommand(__instance.chatTextField.text)) { __instance.chatTextField.text = ""; } } catch (Exception ex) { Plugin.mls.LogInfo((object)("Unable to handle command " + ex.Message)); } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPrefix] private static void UpdatePatch(ref PlayerControllerB __instance) { player = __instance; if (Plugin.Instance.ConfigManager.InfiniteSprint && __instance.sprintMeter < 1f) { __instance.sprintMeter = 1f; } } [HarmonyPatch(typeof(PlayerControllerB), "Start")] [HarmonyPostfix] private static void MovementPatch(ref PlayerControllerB __instance) { float movementSpeed = Plugin.Instance.ConfigManager.MovementSpeed; float jumpForce = Plugin.Instance.ConfigManager.JumpForce; float climbSpeed = Plugin.Instance.ConfigManager.ClimbSpeed; __instance.movementSpeed = movementSpeed; __instance.jumpForce = jumpForce; __instance.climbSpeed = climbSpeed; Plugin.mls.LogInfo((object)$"Player movementSpeed loaded from config: {movementSpeed}"); Plugin.mls.LogInfo((object)$"Player jumpForce loaded from config: {jumpForce}"); Plugin.mls.LogInfo((object)$"Player climbSpeed loaded from config: {climbSpeed}"); } [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPrefix] private static void StartOfRoundPatch() { BigDoorsList.Clear(); Plugin.mls.LogInfo((object)"BigDoorsList cleared"); } [HarmonyPatch(typeof(TerminalAccessibleObject), "SetCodeTo")] [HarmonyPostfix] private static void BigDoorPatch(ref TerminalAccessibleObject __instance) { if (__instance.isBigDoor) { BigDoorsList.Add(__instance); Plugin.mls.LogInfo((object)("objectCode: " + __instance.objectCode)); } } } [BepInPlugin("BaboonRizzMod.Chris", "Baboon Rizz Mod", "1.0.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("BaboonRizzMod.Chris"); internal static Plugin Instance; internal static ManualLogSource mls; internal ConfigurationController ConfigManager; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("Baboon Rizz Mod"); mls.LogInfo((object)"Loaded Succesfully"); ConfigManager = new ConfigurationController(((BaseUnityPlugin)this).Config); harmony.PatchAll(typeof(GamePatcher)); } } internal class Utilities { private static readonly Dictionary<string, Action<string[]>> CommandHandlers = new Dictionary<string, Action<string[]>> { { "/sprint", HandleSprintCommand }, { "/speed", HandleSpeedCommand }, { "/jump", HandleJumpCommand }, { "/climb", HandleClimbCommand }, { "/scrap", HandleScrapCommand }, { "/health", HandleHealthCommand }, { "/door", HandleDoorCommand } }; internal static bool HandleCommand(string command) { if (!command.ToLower().StartsWith("/".ToLower())) { return false; } string[] array = command.ToLower().Split(new char[1] { ' ' }); command = array[0]; if (CommandHandlers.TryGetValue(command, out var value)) { value(array); return true; } Plugin.mls.LogInfo((object)("Unknown command: " + command)); return true; } internal static void HandleSprintCommand(string[] commandInfo) { if (!Plugin.Instance.ConfigManager.AllowSprintCommand) { Plugin.mls.LogInfo((object)("The use of the '" + commandInfo[0] + "' command is disabled in the config file")); return; } bool infiniteSprint = Plugin.Instance.ConfigManager.InfiniteSprint; Plugin.Instance.ConfigManager.InfiniteSprint = !infiniteSprint; Plugin.mls.LogInfo((object)$"/sprint => {!infiniteSprint}"); } internal static void HandleSpeedCommand(string[] commandInfo) { float result; if (!Plugin.Instance.ConfigManager.AllowSpeedCommand) { Plugin.mls.LogInfo((object)("The use of the '" + commandInfo[0] + "' command is disabled in the config file")); } else if (commandInfo.Length == 0 || commandInfo == null || commandInfo.Length < 2) { Plugin.mls.LogInfo((object)"Invalid command. Please specify the speed"); } else if (float.TryParse(commandInfo[1], out result)) { Plugin.Instance.ConfigManager.MovementSpeed = result; GamePatcher.player.movementSpeed = result; Plugin.mls.LogInfo((object)$"/speed => {result}"); } else { Plugin.mls.LogInfo((object)"Invalid number"); } } internal static void HandleJumpCommand(string[] commandInfo) { float result; if (!Plugin.Instance.ConfigManager.AllowJumpCommand) { Plugin.mls.LogInfo((object)("The use of the '" + commandInfo[0] + "' command is disabled in the config file")); } else if (commandInfo.Length == 0 || commandInfo == null || commandInfo.Length < 2) { Plugin.mls.LogInfo((object)"Invalid command. Please specify the jump force"); } else if (float.TryParse(commandInfo[1], out result)) { Plugin.Instance.ConfigManager.JumpForce = result; GamePatcher.player.jumpForce = result; Plugin.mls.LogInfo((object)$"/jump => {result}"); } else { Plugin.mls.LogInfo((object)"Invalid number"); } } internal static void HandleClimbCommand(string[] commandInfo) { float result; if (!Plugin.Instance.ConfigManager.AllowClimbCommand) { Plugin.mls.LogInfo((object)("The use of the '" + commandInfo[0] + "' command is disabled in the config file")); } else if (commandInfo.Length == 0 || commandInfo == null || commandInfo.Length < 2) { Plugin.mls.LogInfo((object)"Invalid command. Please specify the climb speed"); } else if (float.TryParse(commandInfo[1], out result)) { Plugin.Instance.ConfigManager.ClimbSpeed = result; GamePatcher.player.climbSpeed = result; Plugin.mls.LogInfo((object)$"/climb => {result}"); } else { Plugin.mls.LogInfo((object)"Invalid number"); } } internal static void HandleScrapCommand(string[] commandInfo) { int result; if (!Plugin.Instance.ConfigManager.AllowScrapCommand) { Plugin.mls.LogInfo((object)("The use of the '" + commandInfo[0] + "' command is disabled in the config file")); } else if (commandInfo.Length == 0 || commandInfo == null || commandInfo.Length < 2) { Plugin.mls.LogInfo((object)"Invalid command. Please specify the scrap amount"); } else if (int.TryParse(commandInfo[1], out result)) { PlayerControllerB player = GamePatcher.player; if ((Object)(object)player != (Object)null && (Object)(object)player.currentlyHeldObjectServer != (Object)null) { player.currentlyHeldObjectServer.SetScrapValue(result); Plugin.mls.LogInfo((object)$"/scrap => {result} (server)"); Plugin.mls.LogInfo((object)$"PlayerControllerB.currentlyHeldObject = {player.currentlyHeldObject}"); Plugin.mls.LogInfo((object)$"PlayerControllerB.currentlyHeldObjectServer = {player.currentlyHeldObjectServer}"); } else { Plugin.mls.LogInfo((object)"No object currently held (PlayerControllerB.currentlyHeldObject = null)"); } } else { Plugin.mls.LogInfo((object)$"Invalid scrap value: '{result}'. Please provide a valid number."); } } internal static void HandleHealthCommand(string[] commandInfo) { int result; if (!Plugin.Instance.ConfigManager.AllowHealthCommand) { Plugin.mls.LogInfo((object)("The use of the '" + commandInfo[0] + "' command is disabled in the config file")); } else if (commandInfo.Length == 0 || commandInfo == null || commandInfo.Length < 2) { Plugin.mls.LogInfo((object)"Invalid command. Please specify the health amount"); } else if (int.TryParse(commandInfo[1], out result)) { GamePatcher.player.health = result; Plugin.mls.LogInfo((object)$"/health => {result}"); } else { Plugin.mls.LogInfo((object)"Invalid number"); } } internal static void HandleDoorCommand(string[] commandInfo) { if (!Plugin.Instance.ConfigManager.AllowDoorCommand) { Plugin.mls.LogInfo((object)("The use of the '" + commandInfo[0] + "' command is disabled in the config file")); return; } if (commandInfo.Length == 0 || commandInfo == null || commandInfo.Length < 2) { Plugin.mls.LogInfo((object)"Invalid command. Please specify the door code"); return; } if (GamePatcher.BigDoorsList.Count == 0) { Plugin.mls.LogInfo((object)"doorCodesList is empty."); } TerminalAccessibleObject val = ((IEnumerable<TerminalAccessibleObject>)GamePatcher.BigDoorsList).FirstOrDefault((Func<TerminalAccessibleObject, bool>)((TerminalAccessibleObject obj) => obj.objectCode == commandInfo[1])); if ((Object)(object)val != (Object)null) { val.SetDoorOpenServerRpc(true); Plugin.mls.LogInfo((object)("Door " + commandInfo[1] + " opened")); } else { Plugin.mls.LogInfo((object)("Door " + commandInfo[1] + " is not present")); } } }