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 ScrapLauncherReload v1.0.1
ScrapLauncherReload.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using EntityStates; using EntityStates.Toolbot; using On.EntityStates.Toolbot; using RiskyMod.Survivors; using RiskyMod.Survivors.Toolbot; using RoR2; using RoR2.Skills; using UnityEngine; using UnityEngine.AddressableAssets; 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.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ScrapLauncherReload")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ScrapLauncherReload")] [assembly: AssemblyTitle("ScrapLauncherReload")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace ScrapLauncherReload { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.Moffein.ScrapLauncherReload", "ScrapLauncherReload", "1.0.1")] public class ScrapLauncherReload : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_OnEnter <>9__0_0; internal void <Awake>b__0_0(orig_OnEnter orig, FireGrenadeLauncher self) { orig.Invoke(self); GrenadeStockController component = ((EntityState)self).gameObject.GetComponent<GrenadeStockController>(); if (Object.op_Implicit((Object)(object)component)) { component.FireSkill(self.activatorSkillSlot, ((GenericProjectileBaseState)self).duration); } } } public void Awake() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0086: Expected O, but got Unknown bool flag = true; if (Chainloader.PluginInfos.ContainsKey("com.RiskyLives.RiskyMod")) { flag = !RiskyModAppliedFix(); } if (!flag) { Debug.LogError((object)"ScrapLauncherReload: RiskyMod already applied change. Code will not be run."); return; } GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterBodies/ToolbotBody"); val.AddComponent<GrenadeStockController>(); SkillDef val2 = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Toolbot/ToolbotBodyFireGrenadeLauncher.asset").WaitForCompletion(); val2.rechargeStock = 0; object obj = <>c.<>9__0_0; if (obj == null) { hook_OnEnter val3 = delegate(orig_OnEnter orig, FireGrenadeLauncher self) { orig.Invoke(self); GrenadeStockController component = ((EntityState)self).gameObject.GetComponent<GrenadeStockController>(); if (Object.op_Implicit((Object)(object)component)) { component.FireSkill(self.activatorSkillSlot, ((GenericProjectileBaseState)self).duration); } }; <>c.<>9__0_0 = val3; obj = (object)val3; } FireGrenadeLauncher.OnEnter += (hook_OnEnter)obj; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private bool RiskyModAppliedFix() { return SurvivorsCore.enabled && ToolbotCore.enabled && ToolbotCore.enableScrapChanges; } } public class GrenadeStockController : MonoBehaviour { private class SkillStatus { public GenericSkill skill; public float reloadStopwatch = 0f; public float delayStopwatch = 0f; public SkillStatus(GenericSkill skill) { this.skill = skill; } } public static float graceDuration = 0.4f; public static float baseDuration = 1.5f; private CharacterBody body; private SkillLocator skills; private List<SkillStatus> skillStatuses; private void Awake() { body = ((Component)this).GetComponent<CharacterBody>(); skills = ((Component)this).GetComponent<SkillLocator>(); skillStatuses = new List<SkillStatus>(); } private void FixedUpdate() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)skills).hasAuthority) { return; } foreach (SkillStatus skillStatus in skillStatuses) { SerializableEntityStateType activationState = skillStatus.skill.activationState; if (!(((SerializableEntityStateType)(ref activationState)).stateType == typeof(FireGrenadeLauncher))) { continue; } if (skillStatus.skill.stock < skillStatus.skill.maxStock) { if (skillStatus.skill.stock <= 0) { skillStatus.delayStopwatch = 0f; } if (skillStatus.delayStopwatch > 0f) { skillStatus.delayStopwatch -= Time.fixedDeltaTime; continue; } skillStatus.reloadStopwatch -= Time.fixedDeltaTime; if (skillStatus.reloadStopwatch <= 0f) { skillStatus.reloadStopwatch += baseDuration / body.attackSpeed; skillStatus.skill.stock = skillStatus.skill.maxStock; Util.PlaySound("Play_captain_m1_reload", ((Component)this).gameObject); } } else { skillStatus.reloadStopwatch = baseDuration / body.attackSpeed; } } } public void FireSkill(GenericSkill g, float duration) { bool flag = false; foreach (SkillStatus skillStatus2 in skillStatuses) { if ((Object)(object)skillStatus2.skill == (Object)(object)g) { flag = true; skillStatus2.delayStopwatch = graceDuration; skillStatus2.reloadStopwatch = baseDuration / body.attackSpeed; } } if (!flag) { SkillStatus skillStatus = new SkillStatus(g); skillStatus.delayStopwatch = graceDuration; skillStatus.reloadStopwatch = baseDuration / body.attackSpeed; skillStatuses.Add(skillStatus); } } } } namespace R2API.Utils { [AttributeUsage(AttributeTargets.Assembly)] public class ManualNetworkRegistrationAttribute : Attribute { } }