Please disclose if any significant portion of your mod was created 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 CaptainUtilitySwap v1.3.0
plugins/captainswap/CaptainSwap.dll
Decompiled 2 years agousing System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using On.RoR2; using On.RoR2.UI; using RoR2; using RoR2.Skills; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.Networking; [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.0", FrameworkDisplayName = "")] [assembly: AssemblyCompany("CaptainSwap")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CaptainSwap")] [assembly: AssemblyTitle("CaptainSwap")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace CaptainSwap; [BepInPlugin("CrazyAmphibian.CaptainSwap", "CaptainSwap", "1.3.0")] public class Plugin : BaseUnityPlugin { public abstract class BaseUnityPlugin : MonoBehaviour { protected ConfigFile Config { get; } public static ConfigEntry<int> captainutilityswapkeycode { get; set; } } public const string PluginGUID = "CrazyAmphibian.CaptainSwap"; public const string PluginAuthor = "CrazyAmphibian"; public const string PluginName = "CaptainSwap"; public const string PluginVersion = "1.3.0"; private GameObject playerbody; private int probestocks = 1; private int diablostocks = 1; private float proberecharge = 0f; private float diablorecharge = 0f; public int captainutilityswapkeycode = 116; private bool pressedlastframe = false; private bool pressedthisframe = false; private int totalmaxstocks = 1; public void Awake() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); captainutilityswapkeycode = ((BaseUnityPlugin)this).Config.Bind<int>("input", "hotkey (unity keycode)", 116, "which keypress will swap utilities.\nTakes the form of a unity keycode.").Value; PlayerCharacterMasterController.SetBody += new hook_SetBody(PCMC_stetbodyhook); SkillIcon.Update += new hook_Update(skilliconhotkeyshow); Run.BeginStage += new hook_BeginStage(refreshallcaptainutilities); } internal void skilliconhotkeyshow(orig_Update orig, SkillIcon self) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_0075: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); if (Object.op_Implicit((Object)(object)self.targetSkill) && (int)self.targetSkillSlot == 2 && self.targetSkill.characterBody.baseNameToken == "CAPTAIN_BODY_NAME") { ((Component)self.stockText).gameObject.SetActive(true); ((TMP_Text)self.stockText).fontSize = 12f; TextMeshProUGUI stockText = self.stockText; KeyCode val = (KeyCode)captainutilityswapkeycode; ((TMP_Text)stockText).SetText("[" + ((object)(KeyCode)(ref val)).ToString() + "]\n" + self.targetSkill.stock, true); } } internal void PCMC_stetbodyhook(orig_SetBody orig, PlayerCharacterMasterController self, GameObject newbody) { orig.Invoke(self, newbody); if (Object.op_Implicit((Object)(object)newbody)) { CharacterBody component = newbody.GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component) && component.baseNameToken == "CAPTAIN_BODY_NAME" && ((NetworkBehaviour)component).localPlayerAuthority) { playerbody = newbody; } } } public void FixedUpdate() { if (!Object.op_Implicit((Object)(object)playerbody)) { return; } CharacterBody component = playerbody.GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component) && component.baseNameToken == "CAPTAIN_BODY_NAME") { if (Object.op_Implicit((Object)(object)component.skillLocator.utility)) { totalmaxstocks = component.skillLocator.utility.maxStock; } pressedthisframe = Input.GetKey((KeyCode)captainutilityswapkeycode); if (pressedthisframe && !pressedlastframe) { swapcaptainutilityskills(component); } pressedlastframe = pressedthisframe; } } public int swapcaptainutilityskills(CharacterBody charbod) { GenericSkill utility = charbod.skillLocator.utility; Variant[] array = charbod.skillLocator.utility?._skillFamily.variants; if (((utility != null) ? utility.skillNameToken : null) == "CAPTAIN_UTILITY_ALT1_NAME") { diablorecharge = utility.rechargeStopwatch; diablostocks = utility.stock; charbod.skillLocator.utility.AssignSkill(array[0].skillDef); charbod.skillLocator.utility.stock = probestocks; charbod.skillLocator.utility.rechargeStopwatch = proberecharge; return 0; } if (((utility != null) ? utility.skillNameToken : null) == "CAPTAIN_UTILITY_NAME") { proberecharge = utility.rechargeStopwatch; probestocks = utility.stock; charbod.skillLocator.utility.AssignSkill(array[1].skillDef); charbod.skillLocator.utility.stock = diablostocks; charbod.skillLocator.utility.rechargeStopwatch = diablorecharge; return 1; } return -1; } public void refreshallcaptainutilities(orig_BeginStage orig, Run self) { orig.Invoke(self); Log.Debug("Refilling for end of scene..."); probestocks = totalmaxstocks; diablostocks = totalmaxstocks; proberecharge = 0f; diablorecharge = 0f; } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } }