using 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 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("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+308fb7b3c1965660a6df8d2ebc5f959d85629e1c")]
[assembly: AssemblyProduct("NeedolinArsenal")]
[assembly: AssemblyTitle("NeedolinArsenal")]
[assembly: NeutralResourcesLanguage("EN")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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.*/)]
[BepInPlugin("io.github.danielstegink.needolinarsenal", "NeedolinArsenal", "1.0.1")]
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 => "1.0.1";
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();
MusicToolHelper.shimasenClip = GetAudioClip.GetAudioClipFromAssembly("NeedolinArsenal", "NeedolinArsenal.Resources.Sakura (Zambolino).wav", false);
MusicToolHelper.countryClip = GetAudioClip.GetAudioClipFromAssembly("NeedolinArsenal", "NeedolinArsenal.Resources.Desert West (Dagored).wav", false);
MusicToolHelper.jazzClip = GetAudioClip.GetAudioClipFromAssembly("NeedolinArsenal", "NeedolinArsenal.Resources.At Ease (Hazelwood).wav", false);
MusicToolHelper.metalClip = GetAudioClip.GetAudioClipFromAssembly("NeedolinArsenal", "NeedolinArsenal.Resources.Leader (Zambolino).wav", false);
if ((Object)(object)MusicToolHelper.shimasenClip == (Object)null)
{
Log("Audio clips not loaded successfully");
}
((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__5 : 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__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<timer>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: 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 = 1000f;
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:
SpawnNeedleStrike();
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();
}
}
internal static bool isArsenalActive;
internal static bool continueArsenal;
private static GameObject? beamPrefab;
internal static GameObject? needlePrefab;
internal static void StartArsenal()
{
if (!isArsenalActive && MusicToolHelper.chosenTool.HasValue)
{
isArsenalActive = true;
continueArsenal = true;
((MonoBehaviour)GameManager.instance).StartCoroutine(Arsenal());
}
}
[IteratorStateMachine(typeof(<Arsenal>d__5))]
private static IEnumerator Arsenal()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Arsenal>d__5(0);
}
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(20f);
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;
}
}
private static void SpawnNeedleStrike()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
List<GameObject> enemies = GetEnemy.GetEnemies(20f);
if (enemies.Count > 0)
{
Transform transform = Extensions.GetRandomElement<GameObject>(enemies).transform;
Vector3 val = default(Vector3);
val.x = transform.position.x;
val.y = transform.position.y;
val.z = transform.position.z;
Vector3 val2 = val;
GameObject obj = ObjectPoolExtensions.Spawn(needlePrefab, val2);
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>();
}
}
}
[HarmonyPatch(typeof(FsmState), "OnEnter")]
public static class FsmState_OnEnter
{
[HarmonyPostfix]
public static void Postfix(FsmState __instance)
{
if (StopArsenal(__instance.Name))
{
ArsenalEffects.continueArsenal = false;
}
if (RestartArsenal(__instance.Name))
{
ArsenalEffects.StartArsenal();
}
}
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);
}
}
[HarmonyPatch(typeof(GameManager), "Awake")]
public static class GameStart_Awake
{
[HarmonyPostfix]
public static void Postfix(GameManager __instance)
{
GetCrossSlash();
}
private static void GetCrossSlash()
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
AssetBundle bundle = GetAssetBundle.GetBundle("localpoolprefabs_assets_areaswamp.bundle", false);
if ((Object)(object)bundle == (Object)null)
{
NeedolinArsenal.Instance.Log("Error loading bundle");
return;
}
try
{
GameObject val = (GameObject)bundle.LoadAsset("Assets/Prefabs/Hornet Enemies/Pinstress CrossSlash.prefab");
if ((Object)(object)val == (Object)null)
{
NeedolinArsenal.Instance.Log("Cross Slash prefab not found");
return;
}
ArsenalEffects.needlePrefab = Object.Instantiate<GameObject>(val);
((Object)ArsenalEffects.needlePrefab).name = "NeedolinArsenal.NeedleStrike";
ArsenalEffects.needlePrefab.SetActive(false);
Object.DontDestroyOnLoad((Object)(object)ArsenalEffects.needlePrefab);
}
catch (Exception ex)
{
NeedolinArsenal.Instance.Log("Error getting Cross Slash prefab: " + ex.Message + "\n\n" + ex.StackTrace);
}
finally
{
bundle.Unload(true);
}
}
}
public enum MusicTool
{
Voltvessel,
Lifeblood,
Lantern,
PinBadge
}
public static class MusicToolHelper
{
public static MusicTool? chosenTool;
public static AudioClip? metalClip;
public static AudioClip? countryClip;
public static AudioClip? jazzClip;
public static AudioClip? shimasenClip;
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);
}
return list;
}
public static AudioClip? GetAudioClip(MusicTool? tool)
{
return (AudioClip?)(tool switch
{
MusicTool.Voltvessel => metalClip,
MusicTool.Lantern => countryClip,
MusicTool.Lifeblood => jazzClip,
_ => shimasenClip,
});
}
}
public class NeedleStrikeDamage : MonoBehaviour
{
public void OnTriggerEnter2D(Collider2D other)
{
if (!((Object)(object)other == (Object)null) && ((Component)other).gameObject.layer == 11)
{
DamageEnemy.DealDamage(((Component)other).gameObject.GetComponent<HealthManager>(), PlayerData.instance.nailDamage / 4, (AttackTypes)2, ((Component)this).gameObject);
}
}
}
[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();
}
}
}