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 NeedolinArsenal v2.0.0
NeedolinArsenal.dll
Decompiled 5 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using DanielSteginkUtils.ExternalFiles; using DanielSteginkUtils.Helpers; using DanielSteginkUtils.Utilities; using GlobalSettings; using HarmonyLib; using HutongGames.PlayMaker; using HutongGames.PlayMaker.Actions; using Microsoft.CodeAnalysis; using NeedolinArsenal.Helpers; using Silksong.AssetHelper.ManagedAssets; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NeedolinArsenal")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("2.0.0.0")] [assembly: AssemblyInformationalVersion("2.0.0+ec69483f7f50ca2c33b3f51df3b29b81bebc5a04")] [assembly: AssemblyProduct("NeedolinArsenal")] [assembly: AssemblyTitle("NeedolinArsenal")] [assembly: NeutralResourcesLanguage("EN")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Microsoft.CodeAnalysis.Embedded] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Microsoft.CodeAnalysis.Embedded] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Microsoft.CodeAnalysis { [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace NeedolinArsenal { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("io.github.danielstegink.needolinarsenal", "NeedolinArsenal", "2.0.0")] public class NeedolinArsenal : BaseUnityPlugin { public const string Id = "io.github.danielstegink.needolinarsenal"; internal static NeedolinArsenal Instance { get; private set; } public static string Name => "NeedolinArsenal"; public static string Version => "2.0.0"; private void Awake() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) Instance = this; new Harmony("io.github.danielstegink.needolinarsenal").PatchAll(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); MusicToolHelper.shimasenClip = GetAudioClip.GetAudioClipFromAssembly(executingAssembly, "NeedolinArsenal.Resources.Sakura (Zambolino).wav", false); MusicToolHelper.countryClip = GetAudioClip.GetAudioClipFromAssembly(executingAssembly, "NeedolinArsenal.Resources.Desert West (Dagored).wav", false); MusicToolHelper.jazzClip = GetAudioClip.GetAudioClipFromAssembly(executingAssembly, "NeedolinArsenal.Resources.At Ease (Hazelwood).wav", false); MusicToolHelper.metalClip = GetAudioClip.GetAudioClipFromAssembly(executingAssembly, "NeedolinArsenal.Resources.Leader (Zambolino).wav", false); if ((Object)(object)MusicToolHelper.shimasenClip == (Object)null) { Log("Audio clips not loaded successfully"); } ArsenalEffects.needlePrefab = ManagedAsset<GameObject>.FromNonSceneAsset("Assets/Prefabs/Hornet Enemies/Pinstress CrossSlash.prefab", "localpoolprefabs_assets_areaswamp.bundle"); ArsenalEffects.trobbioPrefab = ManagedAsset<GameObject>.FromNonSceneAsset("Assets/Prefabs/Heroes/Effects/hero_dazzle_flash.prefab", "localpoolprefabs_assets_shared.bundle"); MusicToolHelper.trobbioAsset = ManagedAsset<AudioClip>.FromNonSceneAsset("Assets/Audio/HornetMusic/Battle/H144-71 WIP Trobbio.wav", "sfxstatic_assets_trobbio.bundle"); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin " + Name + " (io.github.danielstegink.needolinarsenal) has loaded!")); } internal void Log(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)message); } } } namespace NeedolinArsenal.Helpers { internal static class ArsenalEffects { [CompilerGenerated] private sealed class <Arsenal>d__6 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private Stopwatch <timer>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Arsenal>d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <timer>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <timer>5__2 = Stopwatch.StartNew(); break; case 1: <>1__state = -1; break; } while (continueArsenal) { if (GameManager.instance.isPaused) { continue; } try { float num = GetCooldownTime(MusicToolHelper.chosenTool); if (((ToolBase)Gameplay.MusicianCharmTool).IsEquipped) { num /= 1.2f; } if ((float)<timer>5__2.ElapsedMilliseconds >= num) { switch (MusicToolHelper.chosenTool) { case MusicTool.Lifeblood: GainLifeblood(); break; case MusicTool.Voltvessel: SpawnVoltvesselBeam(); break; case MusicTool.Lantern: SpawnWisp(); break; case MusicTool.PinBadge: ((MonoBehaviour)GameManager.instance).StartCoroutine(SpawnNeedleStrike()); break; case MusicTool.Trobbio1: case MusicTool.Trobbio2: ((MonoBehaviour)GameManager.instance).StartCoroutine(SpawnFireworks()); break; } <timer>5__2 = Stopwatch.StartNew(); } } catch (Exception ex) { NeedolinArsenal.Instance.Log("Error triggering effect: " + ex.Message + "\n" + ex.StackTrace); } <>2__current = (object)new WaitForSeconds(Time.deltaTime); <>1__state = 1; return true; } isArsenalActive = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <SpawnFireworks>d__12 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SpawnFireworks>d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //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_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_00da: 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) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (trobbioPrefab == null) { NeedolinArsenal.Instance.Log("Trobbio prefab not stored"); return false; } trobbioPrefab.Load(); <>2__current = trobbioPrefab.Handle; <>1__state = 1; return true; case 1: { <>1__state = -1; if (trobbioPrefab.Handle.OperationException != null) { NeedolinArsenal.Instance.Log($"Error loading asset: {trobbioPrefab.Handle.OperationException}"); return false; } List<GameObject> enemies = GetEnemy.GetEnemies(15f); if (enemies.Count > 0) { Transform transform = Extensions.GetRandomElement<GameObject>(enemies).transform; GameObject obj = ManagedAssetExtensions.InstantiateAsset<GameObject>(trobbioPrefab); ((Object)obj).name = "NeedolinArsenal.TrobbioFirework"; Extensions.SetPositionX(obj.transform, transform.position.x); Extensions.SetPositionY(obj.transform, transform.position.y); Object.Destroy((Object)(object)obj.GetComponent<TestGameObjectActivator>()); DamageEnemies component = ((Component)((Component)obj.transform.Find("Trobbio_dazzle_flash")).gameObject.transform.Find("hero_dazzle_flash_damager")).gameObject.GetComponent<DamageEnemies>(); component.damageDealt /= 2; } return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <SpawnNeedleStrike>d__11 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SpawnNeedleStrike>d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //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_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_00da: 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) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (needlePrefab == null) { NeedolinArsenal.Instance.Log("Cross Slash prefab not stored"); return false; } needlePrefab.Load(); <>2__current = needlePrefab.Handle; <>1__state = 1; return true; case 1: { <>1__state = -1; if (needlePrefab.Handle.OperationException != null) { NeedolinArsenal.Instance.Log($"Error loading asset: {needlePrefab.Handle.OperationException}"); return false; } List<GameObject> enemies = GetEnemy.GetEnemies(15f); if (enemies.Count > 0) { Transform transform = Extensions.GetRandomElement<GameObject>(enemies).transform; GameObject obj = ManagedAssetExtensions.InstantiateAsset<GameObject>(needlePrefab); ((Object)obj).name = "NeedolinArsenal.NeedleStrike"; Extensions.SetPositionX(obj.transform, transform.position.x); Extensions.SetPositionY(obj.transform, transform.position.y); Object.Destroy((Object)(object)obj.GetComponent<TestGameObjectActivator>()); GameObject gameObject = ((Component)obj.transform.Find("Damager1")).gameObject; gameObject.layer = 17; Components.RemoveComponent<DamageHero>(gameObject); gameObject.AddComponent<NeedleStrikeDamage>(); GameObject gameObject2 = ((Component)obj.transform.Find("Damager2")).gameObject; gameObject2.layer = 17; Components.RemoveComponent<DamageHero>(gameObject2); gameObject2.AddComponent<NeedleStrikeDamage>(); } return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static bool isArsenalActive; internal static bool continueArsenal; private static GameObject? beamPrefab; internal static ManagedAsset<GameObject>? needlePrefab; internal static ManagedAsset<GameObject>? trobbioPrefab; internal static void StartArsenal() { if (!isArsenalActive && MusicToolHelper.chosenTool.HasValue) { isArsenalActive = true; continueArsenal = true; ((MonoBehaviour)GameManager.instance).StartCoroutine(Arsenal()); } } [IteratorStateMachine(typeof(<Arsenal>d__6))] private static IEnumerator Arsenal() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Arsenal>d__6(0); } private static float GetCooldownTime(MusicTool? tool) { return tool switch { MusicTool.Lifeblood => 3000f, MusicTool.Trobbio2 => 1600f, MusicTool.Trobbio1 => 2000f, MusicTool.Lantern => 1500f, _ => 1000f, }; } private static void GainLifeblood() { if (PlayerData.instance.GetInt("healthBlue") < 8) { EventRegister.SendEvent(EventRegisterEvents.AddBlueHealth, (GameObject)null); } } private static void SpawnVoltvesselBeam() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)beamPrefab == (Object)null) { beamPrefab = ((SpawnObjectFromGlobalPool)FSMUtility.LocateMyFSM(((SpawnProjectileV2)HeroController.instance.toolsFSM.Fsm.GetState("LR Throw").Actions[4]).Prefab.Value, "Control").Fsm.GetState("Explode").Actions[0]).gameObject.Value; } int num = Random.Range(-2, 3); Transform transform = HeroController.instance.transform; Vector3 val = default(Vector3); val.x = transform.position.x + (float)(num * 5); val.y = transform.position.y; val.z = transform.position.z; Vector3 val2 = val; ObjectPoolExtensions.Spawn(beamPrefab, val2); } private static void SpawnWisp() { List<GameObject> enemies = GetEnemy.GetEnemies(15f); if (enemies.Count > 0) { HeroWispLantern val = Object.FindAnyObjectByType<HeroWispLantern>(); PlayMakerFSM component = ObjectPoolExtensions.Spawn(ClassIntegrations.GetField<HeroWispLantern, GameObject>(val, "wispPrefab", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), HeroController.instance.transform).GetComponent<PlayMakerFSM>(); component.FsmVariables.FindFsmGameObject("Target").Value = Extensions.GetRandomElement<GameObject>(enemies); component.FsmVariables.FindFsmGameObject("Spawner").Value = ((Component)val).gameObject; } } [IteratorStateMachine(typeof(<SpawnNeedleStrike>d__11))] private static IEnumerator SpawnNeedleStrike() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SpawnNeedleStrike>d__11(0); } [IteratorStateMachine(typeof(<SpawnFireworks>d__12))] private static IEnumerator SpawnFireworks() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SpawnFireworks>d__12(0); } } [HarmonyPatch(typeof(FsmState), "OnEnter")] public static class FsmState_OnEnter { [CompilerGenerated] private sealed class <LoadTrobbioMusic>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadTrobbioMusic>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //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_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) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (MusicToolHelper.trobbioAsset == null) { NeedolinArsenal.Instance.Log("Trobbio prefab not stored"); return false; } MusicToolHelper.trobbioAsset.Load(); <>2__current = MusicToolHelper.trobbioAsset.Handle; <>1__state = 1; return true; case 1: <>1__state = -1; if (MusicToolHelper.trobbioAsset.Handle.OperationException != null) { NeedolinArsenal.Instance.Log($"Error loading asset: {MusicToolHelper.trobbioAsset.Handle.OperationException}"); return false; } MusicToolHelper.trobbioClip = ManagedAssetExtensions.InstantiateAsset<AudioClip>(MusicToolHelper.trobbioAsset); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPostfix] public static void Postfix(FsmState __instance) { if (__instance.name.Equals("Try Needolin") && (Object)(object)MusicToolHelper.trobbioClip == (Object)null) { ((MonoBehaviour)GameManager.instance).StartCoroutine(LoadTrobbioMusic()); } if (StopArsenal(__instance.Name)) { ArsenalEffects.continueArsenal = false; } if (RestartArsenal(__instance.Name)) { ArsenalEffects.StartArsenal(); } } [IteratorStateMachine(typeof(<LoadTrobbioMusic>d__1))] private static IEnumerator LoadTrobbioMusic() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadTrobbioMusic>d__1(0); } private static bool StopArsenal(string stateName) { return new List<string> { "Break Loop", "Cancel Needolin?", "Pass CANCEL", "End Needolin", "Needolin Lock", "Needolin Lock 2", "Needolin Mem In", "Needolin FT In" }.Contains(stateName); } private static bool RestartArsenal(string stateName) { return new List<string> { "Play Needolin" }.Contains(stateName); } } public enum MusicTool { Voltvessel, Lifeblood, Lantern, PinBadge, Trobbio1, Trobbio2 } public static class MusicToolHelper { public static MusicTool? chosenTool; public static AudioClip? metalClip; public static AudioClip? countryClip; public static AudioClip? jazzClip; public static AudioClip? shimasenClip; internal static ManagedAsset<AudioClip>? trobbioAsset; internal static AudioClip? trobbioClip; public static List<MusicTool> GetMusicTools(List<string> equippedTools) { List<MusicTool> list = new List<MusicTool>(); if (equippedTools.Contains("Lightning Rod")) { list.Add(MusicTool.Voltvessel); } if (equippedTools.Contains("Wisp Lantern")) { list.Add(MusicTool.Lantern); } if (equippedTools.Contains("Lifeblood Syringe")) { list.Add(MusicTool.Lifeblood); } if (equippedTools.Contains("Pinstress Tool")) { list.Add(MusicTool.PinBadge); } if (equippedTools.Contains("Dazzle Bind")) { list.Add(MusicTool.Trobbio1); } if (equippedTools.Contains("Dazzle Bind Upgraded")) { list.Add(MusicTool.Trobbio2); } return list; } public static AudioClip? GetAudioClip(MusicTool? tool) { return (AudioClip?)(tool switch { MusicTool.Voltvessel => metalClip, MusicTool.Lantern => countryClip, MusicTool.Lifeblood => jazzClip, MusicTool.Trobbio1 => trobbioClip, MusicTool.Trobbio2 => trobbioClip, _ => shimasenClip, }); } } public class NeedleStrikeDamage : MonoBehaviour { public void OnTriggerEnter2D(Collider2D other) { if ((Object)(object)other == (Object)null || ((Component)other).gameObject.layer != 11) { return; } try { DamageEnemy.DealDamage(((Component)other).gameObject.GetComponent<HealthManager>(), PlayerData.instance.nailDamage / 2, (AttackTypes)2, ((Component)this).gameObject); } catch { } } } [HarmonyPatch(typeof(StartNeedolinAudioLoop), "OnEnter")] public static class StartNeedolinAudioLoop_OnEnter { [HarmonyPrefix] public static void Prefix(StartNeedolinAudioLoop __instance) { if (!((FsmStateAction)__instance).State.Name.Equals("Start Needolin Proper")) { return; } List<MusicTool> musicTools = MusicToolHelper.GetMusicTools(GetTools.GetEquippedTools()); if (musicTools.Count == 0) { if (Needolin.NeedolinFsm != null && (Object)(object)Needolin.DefaultClip != (Object)null) { MusicToolHelper.chosenTool = null; Needolin.ResetAudioClip(Needolin.NeedolinFsm, true, false); } return; } if (!ArsenalEffects.isArsenalActive) { MusicToolHelper.chosenTool = Extensions.GetRandomElement<MusicTool>(musicTools); } AudioClip audioClip = MusicToolHelper.GetAudioClip(MusicToolHelper.chosenTool); if ((Object)(object)audioClip != (Object)null) { Needolin.SetNewAudioClip(((FsmStateAction)__instance).Fsm, audioClip, false); } ArsenalEffects.StartArsenal(); } } }