Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of Engi M1 Autofire v1.2.1
EngiAutoFire.dll
Decompiled a year agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using EntityStates.Engi.EngiWeapon; using On.EntityStates.Engi.EngiWeapon; using On.RoR2.UI; using RiskOfOptions; using RiskOfOptions.Options; using RoR2.Skills; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; [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("EngiAutoFire")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EngiAutoFire")] [assembly: AssemblyTitle("EngiAutoFire")] [assembly: AssemblyVersion("1.0.0.0")] namespace R2API.Utils { [AttributeUsage(AttributeTargets.Assembly)] public class ManualNetworkRegistrationAttribute : Attribute { } } namespace EngiAutoFire { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.Moffein.EngiAutoFire", "EngiAutoFire", "1.2.0")] public class EngiAutoFire : BaseUnityPlugin { private enum FireModes { Auto, Hold } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_OnEnter <>9__7_0; internal void <Awake>b__7_0(orig_OnEnter orig, ChargeGrenades self) { float baseTotalDuration = ChargeGrenades.baseTotalDuration; if (selectedMode == FireModes.Auto || !allowFireSelect) { ChargeGrenades.baseTotalDuration = ChargeGrenades.baseMaxChargeTime; } else { ChargeGrenades.baseTotalDuration = 1000000f; } orig.Invoke(self); ChargeGrenades.baseTotalDuration = baseTotalDuration; } } public static bool allowFireSelect = true; private static FireModes selectedMode = FireModes.Auto; public static ConfigEntry<bool> selectWithScrollWheel; public static ConfigEntry<KeyboardShortcut> selectButton; public static ConfigEntry<KeyboardShortcut> autoButton; public static ConfigEntry<KeyboardShortcut> holdButton; public void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002c: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0061: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0095: Expected O, but got Unknown //IL_0095: Expected O, but got Unknown //IL_00aa: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00c9: Expected O, but got Unknown //IL_00de: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_00fd: Expected O, but got Unknown //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) //IL_0178: Expected O, but got Unknown //IL_0134: 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) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown allowFireSelect = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Enable Fire Mode Selection"), true, new ConfigDescription("Allows you to choose between holding and autofiring.", (AcceptableValueBase)null, Array.Empty<object>())).Value; selectWithScrollWheel = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Select with ScrollWheel"), true, new ConfigDescription("Scroll wheel swaps between firemodes.", (AcceptableValueBase)null, Array.Empty<object>())); selectButton = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Settings", "Select Button"), KeyboardShortcut.Empty, new ConfigDescription("Button to swap between firemodes.", (AcceptableValueBase)null, Array.Empty<object>())); autoButton = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Settings", "Auto Button"), KeyboardShortcut.Empty, new ConfigDescription("Button to swap to Auto mode.", (AcceptableValueBase)null, Array.Empty<object>())); holdButton = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Settings", "Hold Button"), KeyboardShortcut.Empty, new ConfigDescription("Button to swap to Hold mode.", (AcceptableValueBase)null, Array.Empty<object>())); if (allowFireSelect) { if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { RiskOfOptionsCompat(); } SkillDef engiGrenadeDef = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Engi/EngiBodyFireGrenade.asset").WaitForCompletion(); SkillIcon.Update += (hook_Update)delegate(orig_Update orig, SkillIcon self) { orig.Invoke(self); if (Object.op_Implicit((Object)(object)self.targetSkill) && (Object)(object)self.targetSkill.skillDef == (Object)(object)engiGrenadeDef) { ((Component)self.stockText).gameObject.SetActive(true); ((TMP_Text)self.stockText).fontSize = 12f; ((TMP_Text)self.stockText).SetText(selectedMode.ToString(), true); } }; } object obj = <>c.<>9__7_0; if (obj == null) { hook_OnEnter val = delegate(orig_OnEnter orig, ChargeGrenades self) { float baseTotalDuration = ChargeGrenades.baseTotalDuration; if (selectedMode == FireModes.Auto || !allowFireSelect) { ChargeGrenades.baseTotalDuration = ChargeGrenades.baseMaxChargeTime; } else { ChargeGrenades.baseTotalDuration = 1000000f; } orig.Invoke(self); ChargeGrenades.baseTotalDuration = baseTotalDuration; }; <>c.<>9__7_0 = val; obj = (object)val; } ChargeGrenades.OnEnter += (hook_OnEnter)obj; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private void RiskOfOptionsCompat() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(selectWithScrollWheel)); ModSettingsManager.AddOption((BaseOption)new KeyBindOption(selectButton)); ModSettingsManager.AddOption((BaseOption)new KeyBindOption(autoButton)); ModSettingsManager.AddOption((BaseOption)new KeyBindOption(holdButton)); } public void ToggleFireMode() { if (selectedMode == FireModes.Auto) { selectedMode = FireModes.Hold; } else { selectedMode = FireModes.Auto; } } public void Update() { if (allowFireSelect) { if (selectWithScrollWheel.Value && Input.GetAxis("Mouse ScrollWheel") != 0f) { ToggleFireMode(); } if (GetKeyPressed(selectButton)) { ToggleFireMode(); } else if (GetKeyPressed(holdButton)) { selectedMode = FireModes.Hold; } else if (GetKeyPressed(autoButton)) { selectedMode = FireModes.Auto; } } } private static bool GetKeyPressed(ConfigEntry<KeyboardShortcut> entry) { //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_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) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = entry.Value; foreach (KeyCode modifier in ((KeyboardShortcut)(ref value)).Modifiers) { if (!Input.GetKey(modifier)) { return false; } } value = entry.Value; return Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey); } } }