Decompiled source of Nail Parry Everything v0.1.0

nailparryeverything.dll

Decompiled 3 days ago
using System;
using System.Collections;
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 GlobalEnums;
using HarmonyLib;
using InControl;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[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("nailparryeverything")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+3230c78650a75b1b43f8efdb6e6ea1d023896abf")]
[assembly: AssemblyProduct("nailparryeverything")]
[assembly: AssemblyTitle("nailparryeverything")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/astrum-nova/nailparryeverything")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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 nailparryeverything
{
	[BepInPlugin("io.github.astrum-nova.nailparryeverything", "nailparryeverything", "0.1.0")]
	public class nailparryeverythingPlugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <AddSilkPart>d__24 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			private int <i>5__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <AddSilkPart>d__24(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<i>5__1 = 0;
					break;
				case 1:
					<>1__state = -1;
					HeroController.instance.AddSilkParts(1, true);
					<i>5__1++;
					break;
				}
				if (<i>5__1 < SILK_GAIN_PER_PARRY)
				{
					<>2__current = (object)new WaitForSeconds(0.05f);
					<>1__state = 1;
					return true;
				}
				canAddSilk = true;
				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();
			}
		}

		public static bool ENEMY_INVINCIBILITY;

		public static bool DEBUG_INFO;

		public static bool PARRY_FREEZE;

		public static float PARRY_DAMAGE_MULTIPLIER;

		public static float PARRY_INVULNERABILITY;

		public static int SILK_GAIN_PER_PARRY;

		public static bool DEFAULT_PARRY_INVCINCIBILITY;

		public static bool ENABLE_CHEATS;

		public static bool firstSinnerScene;

		private static bool canAddSilk = true;

		private static bool keepMaxHP;

		private static Text? overlayText;

		private static GameObject? overlayCanvas;

		public const string Id = "io.github.astrum-nova.nailparryeverything";

		public static nailparryeverythingPlugin Instance { get; set; } = null;


		public static string Name => "nailparryeverything";

		public static string Version => "0.1.0";

		private void Awake()
		{
			Instance = this;
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin " + Name + " (io.github.astrum-nova.nailparryeverything) has loaded!"));
			PARRY_DAMAGE_MULTIPLIER = ((BaseUnityPlugin)this).Config.Bind<float>("Modifiers", "Parry Damage Multiplier", 0.55f, "Multiplier for the parry counter, used to balance the damage output with this formula: [nail damage * silk amount (9 min, 18 max) * multiplier], otherwise it would be too strong.").Value;
			PARRY_INVULNERABILITY = ((BaseUnityPlugin)this).Config.Bind<float>("Modifiers", "Parry Invulnerability Time", 0.43f, "The invulnerability time in seconds hornet receives against an attack for parrying it. Some parried attacks will give you global invulnerability time.").Value;
			SILK_GAIN_PER_PARRY = ((BaseUnityPlugin)this).Config.Bind<int>("Modifiers", "Silk Gain Per Parry", 5, "The amount of silk you gain for a successfull parry, 3 amounts to 1 bar of silk.").Value;
			ENEMY_INVINCIBILITY = ((BaseUnityPlugin)this).Config.Bind<bool>("Accessibility", "Enemies Immune To Normal Damage", true, "Whether enemies should be immune to damage with the exception of parry counters. Set this to false if you want to be able to damange enemies without parry counters.").Value;
			bool quickCharge = ((BaseUnityPlugin)this).Config.Bind<bool>("Accessibility", "Quick Nail Art Charge", true, "Quick charge for nail arts always active, basically the Pin Badge tool effect but better.").Value;
			DEBUG_INFO = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Show Debug Info", false, "Whether to show debug information at the top left of the screen.").Value;
			PARRY_FREEZE = ((BaseUnityPlugin)this).Config.Bind<bool>("Accessibility", "Parry Freeze", true, "Whether to freeze the game when you parry something.").Value;
			DEFAULT_PARRY_INVCINCIBILITY = ((BaseUnityPlugin)this).Config.Bind<bool>("Accessibility", "Default Parry Invincibility", false, "The default parry invincibility is a lot less forgiving, you might need to spam sometimes or be more precise but its pretty doable.").Value;
			ENABLE_CHEATS = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Enable Cheats", false, "You might run into arenas with enemies that havent been whitelisted for autokill, and have no parryable attacks, leading to a softlock. Thats why i provided some cheats with the mod: NEEDOLIN+UP > FULL SILK, NEEDOLIN+LEFT > GODMODE ON, NEEDOLIN+RIGHT > GODMODE OFF.").Value;
			Harmony.CreateAndPatchAll(typeof(nailparryeverythingPlugin), (string)null);
			SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode _)
			{
				firstSinnerScene = ((Scene)(ref scene)).name.Equals("Slab_10b");
				try
				{
					PlayerData.instance.hasChargeSlash = true;
					if (quickCharge)
					{
						HeroController.instance.NAIL_CHARGE_TIME = HeroController.instance.NAIL_CHARGE_TIME_QUICK / 2f;
						HeroController.instance.NAIL_CHARGE_BEGIN_TIME = HeroController.instance.NAIL_CHARGE_BEGIN_TIME_QUICK / 2f;
						if (DEBUG_INFO)
						{
							SetOverlayText("Debug info is enabled, use this to help development for the mod,\ninformation about the object you just hit will appear here.\nYou can turn it off in the mod settings if you want.");
						}
					}
				}
				catch
				{
				}
			};
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(NailSlash), "Awake")]
		[HarmonyPatch(typeof(DashStabNailAttack), "Awake")]
		[HarmonyPatch(typeof(Downspike), "StartSlash")]
		private static void AddParryCollision(MonoBehaviour __instance)
		{
			((Component)__instance).gameObject.AddComponent<ParryCollision>();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(DamageHero), "NailClash")]
		private static void DamageHero_NailClash(DamageHero __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				HeroController.instance.StartInvulnerable(tweaks.HandleAdditionalIframes(((Component)__instance).gameObject));
				OnParry();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(DamageHero), "OnEnable")]
		private static void DamageHero_OnEnable(DamageHero __instance)
		{
			__instance.canClashTink = true;
			__instance.forceParry = true;
			__instance.noClashFreeze = false;
			__instance.preventClashTink = false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HealthManager), "OnEnable")]
		private static void HealthManager_Start(HealthManager __instance)
		{
			SetHealthManagerInvincibility(__instance, invincibility: true);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(HealthManager), "Hit")]
		private static void HealthManager_Hit(HealthManager __instance, ref HitInstance hitInstance)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			Collider2D componentInParent = ((Component)__instance).gameObject.GetComponentInParent<Collider2D>();
			if ((tweaks.CheckList(componentInParent, 2) && !tweaks.CheckList(componentInParent, 3)) || (int)hitInstance.AttackType == 17)
			{
				__instance.doNotGiveSilk = true;
				SetHealthManagerInvincibility(__instance, invincibility: false);
			}
			else
			{
				SetHealthManagerInvincibility(__instance, invincibility: true);
				__instance.InvincibleFromDirection = 0;
				__instance.invincibleFromDirection = 0;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HealthManager), "Invincible")]
		private static void HealthManager_Invincible(HealthManager __instance, ref HitInstance hitInstance)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((Object)hitInstance.Source).name.StartsWith("Charge Slash") && !((Object)hitInstance.Source.transform.parent).name.StartsWith("Charge Slash") && !((Object)hitInstance.Source.transform.parent.parent).name.StartsWith("Charge Slash"))
				{
					return;
				}
				if (PlayerData.instance.silk >= 9)
				{
					__instance.TakeDamage(new HitInstance
					{
						Source = hitInstance.Source,
						AttackType = (AttackTypes)2,
						DamageDealt = (int)((float)(PlayerData.instance.nailDamage * PlayerData.instance.silk) * PARRY_DAMAGE_MULTIPLIER),
						Direction = hitInstance.Direction,
						Multiplier = 1f,
						MagnitudeMultiplier = 1f,
						IgnoreInvulnerable = true,
						HitEffectsType = hitInstance.HitEffectsType,
						IsNailTag = hitInstance.IsNailTag
					});
					HeroController.instance.TakeSilk(PlayerData.instance.silk);
					GameManager.instance.FreezeMoment((FreezeMomentTypes)4, (Action)null);
					return;
				}
				bool flag = firstSinnerScene;
				bool flag2 = flag;
				if (flag2)
				{
					string activeStateName = PlayMakerFSM.FindFsmOnGameObject(((Component)__instance).gameObject, "Control").ActiveStateName;
					bool flag3 = ((activeStateName == "Bind Silk" || activeStateName == "Bind Heal") ? true : false);
					flag2 = flag3;
				}
				if (flag2)
				{
					__instance.TakeDamage(new HitInstance
					{
						Source = hitInstance.Source,
						AttackType = (AttackTypes)2,
						DamageDealt = 0,
						Direction = hitInstance.Direction,
						Multiplier = 1f,
						MagnitudeMultiplier = 1f,
						IgnoreInvulnerable = true,
						HitEffectsType = hitInstance.HitEffectsType,
						IsNailTag = hitInstance.IsNailTag
					});
				}
			}
			catch
			{
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameManager), "FreezeMoment", new Type[]
		{
			typeof(FreezeMomentTypes),
			typeof(Action)
		})]
		private static bool GameManager_FreezeMoment(GameManager __instance, FreezeMomentTypes type, Action onFinish)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			return (int)type != 3 || PARRY_FREEZE;
		}

		public static void OnParry()
		{
			if (PlayerData.instance.silk < PlayerData.instance.CurrentSilkMax && canAddSilk)
			{
				canAddSilk = false;
				((MonoBehaviour)Instance).StartCoroutine(AddSilkPart());
			}
		}

		public static void SetHealthManagerInvincibility(HealthManager healthManager, bool invincibility)
		{
			bool invincible = (healthManager.invincible = invincibility && !healthManager.DoNotGiveSilk && ENEMY_INVINCIBILITY);
			if (!((Object)(object)healthManager.sendDamageTo == (Object)null))
			{
				healthManager.sendDamageTo.invincible = invincible;
			}
		}

		[IteratorStateMachine(typeof(<AddSilkPart>d__24))]
		private static IEnumerator AddSilkPart()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <AddSilkPart>d__24(0);
		}

		private void FixedUpdate()
		{
			if (!ENABLE_CHEATS)
			{
				return;
			}
			try
			{
				if (Object.op_Implicit((Object)(object)ManagerSingleton<InputHandler>.Instance) && OneAxisInputControl.op_Implicit((OneAxisInputControl)(object)ManagerSingleton<InputHandler>.Instance.inputActions.Up) && OneAxisInputControl.op_Implicit((OneAxisInputControl)(object)ManagerSingleton<InputHandler>.Instance.inputActions.DreamNail))
				{
					HeroController.instance.RefillSilkToMax();
				}
				if (Object.op_Implicit((Object)(object)ManagerSingleton<InputHandler>.Instance) && OneAxisInputControl.op_Implicit((OneAxisInputControl)(object)ManagerSingleton<InputHandler>.Instance.inputActions.Left) && OneAxisInputControl.op_Implicit((OneAxisInputControl)(object)ManagerSingleton<InputHandler>.Instance.inputActions.DreamNail))
				{
					keepMaxHP = true;
				}
				if (Object.op_Implicit((Object)(object)ManagerSingleton<InputHandler>.Instance) && OneAxisInputControl.op_Implicit((OneAxisInputControl)(object)ManagerSingleton<InputHandler>.Instance.inputActions.Right) && OneAxisInputControl.op_Implicit((OneAxisInputControl)(object)ManagerSingleton<InputHandler>.Instance.inputActions.DreamNail))
				{
					keepMaxHP = false;
				}
				if (keepMaxHP)
				{
					HeroController.instance.MaxHealth();
				}
			}
			catch
			{
			}
		}

		private static void CreateOverlay()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)overlayCanvas != (Object)null))
			{
				overlayCanvas = new GameObject("Nail Parry Everything Canvas");
				Object.DontDestroyOnLoad((Object)(object)overlayCanvas);
				Canvas val = overlayCanvas.AddComponent<Canvas>();
				val.renderMode = (RenderMode)0;
				val.sortingOrder = 1000;
				overlayCanvas.AddComponent<CanvasScaler>();
				CanvasGroup val2 = overlayCanvas.AddComponent<CanvasGroup>();
				val2.interactable = false;
				val2.blocksRaycasts = false;
				GameObject val3 = new GameObject("Nail Parry Everything Text");
				val3.transform.SetParent(overlayCanvas.transform, false);
				overlayText = val3.AddComponent<Text>();
				overlayText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
				overlayText.fontSize = 18;
				((Graphic)overlayText).color = Color.white;
				overlayText.alignment = (TextAnchor)0;
				Outline val4 = ((Component)overlayText).gameObject.AddComponent<Outline>();
				((Shadow)val4).effectColor = Color.black;
				((Shadow)val4).effectDistance = new Vector2(1f, -1f);
				overlayText.horizontalOverflow = (HorizontalWrapMode)1;
				overlayText.verticalOverflow = (VerticalWrapMode)1;
				RectTransform rectTransform = ((Graphic)overlayText).rectTransform;
				rectTransform.anchorMin = new Vector2(0.005f, 0f);
				rectTransform.anchorMax = new Vector2(0f, 0.8f);
				rectTransform.pivot = new Vector2(0f, 0f);
				rectTransform.offsetMin = new Vector2(10f, 10f);
				rectTransform.offsetMax = new Vector2(610f, -10f);
				((Graphic)overlayText).raycastTarget = false;
			}
		}

		public static void SetOverlayText(string text)
		{
			if (DEBUG_INFO)
			{
				if ((Object)(object)overlayText == (Object)null)
				{
					CreateOverlay();
				}
				overlayText.text = "[Nail Parry Everything]\n" + text;
			}
		}
	}
	public class ParryCollision : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <DisableDamageHero>d__3 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public DamageHero damageHero;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DisableDamageHero>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					((Behaviour)damageHero).enabled = false;
					<>2__current = (object)new WaitForSeconds(nailparryeverythingPlugin.PARRY_INVULNERABILITY);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((Behaviour)damageHero).enabled = true;
					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 <ImJustGettingADrink>d__4 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ParryCollision <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ImJustGettingADrink>d__4(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.3f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.canFreeze = true;
					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();
			}
		}

		public bool canFreeze = true;

		private Coroutine? disableDamageHeroRoutine;

		private void OnTriggerEnter2D(Collider2D other)
		{
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)((Component)other).gameObject).name == "HeroBox" || ((Object)((Component)other).gameObject).name.StartsWith("Enviro Region Simple") || ((Object)((Component)other).gameObject).name.StartsWith("Scene"))
			{
				return;
			}
			HealthManager componentInParent = ((Component)other).gameObject.GetComponentInParent<HealthManager>();
			if ((Object)(object)componentInParent != (Object)null && !componentInParent.doNotGiveSilk)
			{
				nailparryeverythingPlugin.SetHealthManagerInvincibility(componentInParent, invincibility: true);
				PlayMakerFSM val = PlayMakerFSM.FindFsmOnGameObject(((Component)componentInParent).gameObject, "Control");
				if ((Object)(object)val == (Object)null)
				{
					val = ((Component)componentInParent).gameObject.GetComponent<PlayMakerFSM>();
				}
				if (nailparryeverythingPlugin.DEBUG_INFO)
				{
					string[] gameObjectParentRootNames = tweaks.getGameObjectParentRootNames(((Component)other).gameObject);
					if (nailparryeverythingPlugin.DEBUG_INFO)
					{
						try
						{
							nailparryeverythingPlugin.SetOverlayText("INTERNAL ENEMY NAME: \"" + ((Object)val).name + "\"\nACTIVE STATE NAME: \"" + val.ActiveStateName + "\"\nAI TYPE: \"" + val.Fsm.name + "\"\nGAME OBJECT: \"" + gameObjectParentRootNames[0] + "\"\nPARENT OBJECT: \"" + gameObjectParentRootNames[1] + "\"\nROOT OBJECT: \"" + gameObjectParentRootNames[2] + "\"");
						}
						catch
						{
							nailparryeverythingPlugin.SetOverlayText("ERROR TRYING TO SET DEBUG TEXT");
						}
					}
				}
				if ((Object)(object)val != (Object)null && !tweaks.IsValidActiveState(((Object)val).name.Contains('(') ? ((Object)val).name.Substring(0, ((Object)val).name.IndexOf('(') - ((!((Object)val).name.EndsWith("(Clone)")) ? 1 : 0)) : ((Object)val).name, val.ActiveStateName) && !tweaks.CheckList(other, 1))
				{
					return;
				}
			}
			else if (nailparryeverythingPlugin.DEBUG_INFO)
			{
				try
				{
					string[] gameObjectParentRootNames2 = tweaks.getGameObjectParentRootNames(((Component)other).gameObject);
					nailparryeverythingPlugin.SetOverlayText("GAME OBJECT: \"" + gameObjectParentRootNames2[0] + "\"\nPARENT OBJECT: \"" + gameObjectParentRootNames2[1] + "\"\nROOT OBJECT: \"" + gameObjectParentRootNames2[2] + "\"");
				}
				catch
				{
					nailparryeverythingPlugin.SetOverlayText("ERROR TRYING TO SET DEBUG TEXT");
				}
			}
			DamageHero componentInParent2 = ((Component)other).gameObject.GetComponentInParent<DamageHero>();
			if (((Object)(object)componentInParent2 == (Object)null || tweaks.CheckList(other, 0)) && !tweaks.CheckList(other, 1))
			{
				return;
			}
			if ((Object)(object)componentInParent2 != (Object)null)
			{
				if (componentInParent2.nailClashRoutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(componentInParent2.nailClashRoutine);
				}
				((MonoBehaviour)this).StartCoroutine(componentInParent2.NailClash(((Component)this).GetComponentInParent<DamageEnemies>().direction, "Nail Attack", ((Component)this).transform.position));
				if (!nailparryeverythingPlugin.DEFAULT_PARRY_INVCINCIBILITY)
				{
					if (disableDamageHeroRoutine != null)
					{
						((MonoBehaviour)this).StopCoroutine(disableDamageHeroRoutine);
					}
					disableDamageHeroRoutine = ((MonoBehaviour)this).StartCoroutine(DisableDamageHero(componentInParent2));
				}
			}
			else
			{
				HeroController.instance.parryInvulnTimer = nailparryeverythingPlugin.PARRY_INVULNERABILITY;
				nailparryeverythingPlugin.OnParry();
			}
			if (canFreeze && nailparryeverythingPlugin.PARRY_FREEZE)
			{
				canFreeze = false;
				((MonoBehaviour)nailparryeverythingPlugin.Instance).StartCoroutine(ImJustGettingADrink());
				GameManager.instance.FreezeMoment((FreezeMomentTypes)3, (Action)null);
			}
		}

		[IteratorStateMachine(typeof(<DisableDamageHero>d__3))]
		private static IEnumerator DisableDamageHero(DamageHero damageHero)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DisableDamageHero>d__3(0)
			{
				damageHero = damageHero
			};
		}

		[IteratorStateMachine(typeof(<ImJustGettingADrink>d__4))]
		private IEnumerator ImJustGettingADrink()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ImJustGettingADrink>d__4(0)
			{
				<>4__this = this
			};
		}
	}
	public static class tweaks
	{
		private static readonly Dictionary<string, HashSet<string>> unparryableStates = new Dictionary<string, HashSet<string>>
		{
			{
				"Pilgrim 01",
				new HashSet<string> { "Attack Recover" }
			},
			{
				"Pilgrim 03",
				new HashSet<string> { "Attack Recover" }
			},
			{
				"Mossbone Mother",
				new HashSet<string> { "Swoop Return", "Swoop Antic", "Swoop Recover" }
			}
		};

		private static readonly Dictionary<string, HashSet<string>> parryableStates = new Dictionary<string, HashSet<string>>
		{
			{
				"Mossbone Mother",
				new HashSet<string> { "Swoop" }
			},
			{
				"Mossbone Crawler Fat",
				new HashSet<string> { "Charge" }
			},
			{
				"Bone Flyer Giant",
				new HashSet<string> { "Charge", "Stomp" }
			},
			{
				"Last Judge",
				new HashSet<string> { "Stomp Down", "Charge" }
			},
			{
				"Bone Beast",
				new HashSet<string> { "Charge", "Leap Out", "Descending" }
			},
			{
				"Phantom",
				new HashSet<string> { "A Dash", "G Dash", "Dragoon Down" }
			},
			{
				"Crawfather",
				new HashSet<string> { "Dive", "Peck Land" }
			},
			{
				"Bone Hunter Trapper",
				new HashSet<string> { "Charge", "Up Leap", "Diag Leap", "Fall" }
			},
			{
				"Conductor Boss",
				new HashSet<string> { "Charge" }
			},
			{
				"Slab Fly Broodmother",
				new HashSet<string> { "Leap", "Slam" }
			},
			{
				"Roachkeeper Chef",
				new HashSet<string> { "Slam In", "Butt Air", "Stomp", "Dive" }
			},
			{
				"Swamp Shaman",
				new HashSet<string> { "Dive" }
			},
			{
				"Hunter Queen Boss",
				new HashSet<string> { "Dash Grind" }
			},
			{
				"Vampire Gnat",
				new HashSet<string> { "Charge" }
			},
			{
				"Flower Queen Boss",
				new HashSet<string> { "Leap" }
			},
			{
				"Coral Conch Driller Giant Solo",
				new HashSet<string> { "Emerge", "Fly", "Impact" }
			},
			{
				"Driller B",
				new HashSet<string> { "Emerge", "Fly", "Impact" }
			},
			{
				"Driller A",
				new HashSet<string> { "Emerge", "Fly", "Impact" }
			},
			{
				"Skull King",
				new HashSet<string> { "Charge", "Rewake Drop", "Stomp Jump", "Jump Air" }
			},
			{
				"Trobbio",
				new HashSet<string> { "Tornado" }
			},
			{
				"Tormented Trobbio",
				new HashSet<string> { "Tornado" }
			},
			{
				"Seth",
				new HashSet<string> { "Jump Dive" }
			},
			{
				"Song Reed Grand",
				new HashSet<string> { "Stomp", "Cast" }
			},
			{
				"Slab Fly Large",
				new HashSet<string> { "Stomp", "Grab Air", "Roll" }
			},
			{
				"Spinner Boss",
				new HashSet<string> { "Charge" }
			},
			{
				"Giant Flea",
				new HashSet<string> { "Dashing" }
			},
			{
				"Dock Guard Thrower",
				new HashSet<string> { "Stomp" }
			},
			{
				"Bone Hunter Fly",
				new HashSet<string> { "Dthrust" }
			},
			{
				"Bone Hunter Fly Chief",
				new HashSet<string> { "Dthrust" }
			},
			{
				"Bone Flyer Smn",
				new HashSet<string> { "Fire" }
			},
			{
				"Bone Flyer",
				new HashSet<string> { "Fire" }
			},
			{
				"Dancer A",
				new HashSet<string> { "Stomp" }
			},
			{
				"Dancer B",
				new HashSet<string> { "Stomp" }
			},
			{
				"MossBone Fly",
				new HashSet<string> { "Drill" }
			},
			{
				"Bone Roller",
				new HashSet<string> { "CCW", "CW" }
			},
			{
				"Bone Goomba Large",
				new HashSet<string> { "Charge" }
			},
			{
				"Pilgrim 01",
				new HashSet<string> { "Attack" }
			},
			{
				"Pilgrim 03",
				new HashSet<string> { "Attack" }
			},
			{
				"Pilgrim Fly",
				new HashSet<string> { "Charge" }
			},
			{
				"Aspid Collector",
				new HashSet<string> { "Chomp" }
			},
			{
				"Bone Circler",
				new HashSet<string> { "Chase" }
			},
			{
				"Rosary Thief",
				new HashSet<string> { "Dash Air" }
			},
			{
				"Bone Thumper",
				new HashSet<string> { "Roll" }
			},
			{
				"Shellwood Goomba Flyer",
				new HashSet<string> { "Chase" }
			},
			{
				"Bloom Puncher",
				new HashSet<string> { "Punch" }
			},
			{
				"Bone Crawler",
				new HashSet<string> { "Spike" }
			},
			{
				"Garmond Fighter",
				new HashSet<string> { "Charge", "Stomp" }
			},
			{
				"Garmond Black Threaded Fighter",
				new HashSet<string> { "Stomp" }
			}
		};

		private static readonly HashSet<string> whitelist = new HashSet<string>
		{
			"Tornado Event Sender", "Tormented Trobbio Tornado", "Drill Multihitter", "Conch Projectile Heavy", "lightning_rod_explode", "Ward Corpse Projectile", "Cloverstag White Sickle", "Slab Fly Glob", "Pollen Shot", "Stomp Blast",
			"Stomp Colliders", "Collider Slam", "DashCollider", "Crawfather Attack Chain"
		};

		private static readonly HashSet<string> blacklist = new HashSet<string> { "Spike Collider", "Splinter Queen Spike", "Splinter Queen Gate Spike", "Coral Crust Tree Plat", "Battle Gate Coral", "Head Collider" };

		private static readonly HashSet<string> fragileList = new HashSet<string> { "Shellwood Gnat", "Shellwood Goomba", "Bone Goomba", "Slab Fly Small Fresh", "MossBone Cocoon", "MossBone Crawler" };

		private static readonly HashSet<string> tuffList = new HashSet<string> { "Bone Goomba Large", "MossBone Crawler Fat" };

		public static bool CheckList(Collider2D other, int listId)
		{
			GameObject gameObject = ((Component)other).gameObject;
			Transform parent = gameObject.transform.parent;
			Transform root = gameObject.transform.root;
			if (1 == 0)
			{
			}
			HashSet<string> hashSet = listId switch
			{
				0 => blacklist, 
				1 => whitelist, 
				2 => fragileList, 
				_ => tuffList, 
			};
			if (1 == 0)
			{
			}
			foreach (string item in hashSet)
			{
				if ((Object)(object)gameObject != (Object)null && ((Object)gameObject).name.StartsWith(item))
				{
					return true;
				}
				if ((Object)(object)parent != (Object)null && ((Object)parent).name.StartsWith(item))
				{
					return true;
				}
				if ((Object)(object)root != (Object)null && ((Object)root).name.StartsWith(item))
				{
					return true;
				}
			}
			return false;
		}

		public static float HandleAdditionalIframes(GameObject gameObject)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return 0f;
			}
			string name = ((Object)gameObject).name;
			string text = (((Object)(object)gameObject.transform.parent != (Object)null) ? ((Object)gameObject.transform.parent).name : "");
			string text2 = (((Object)(object)gameObject.transform.root != (Object)null) ? ((Object)gameObject.transform.root).name : "");
			if (name.StartsWith("Dash Hit"))
			{
				return 0.25f;
			}
			if (text.StartsWith("Dragoon Blast") || text.StartsWith("Dragoon Down") || name.StartsWith("Dragoon Down"))
			{
				return 0.25f;
			}
			if (text2.StartsWith("Spinner_vertical_slash"))
			{
				return 0.35f;
			}
			if (text2.StartsWith("Bone_Boulder SK"))
			{
				return 0.35f;
			}
			if (name.StartsWith("Coral Conch Driller Roar"))
			{
				return 0.35f;
			}
			if (name.StartsWith("SlashHit") && text.StartsWith("DashSlash Effect"))
			{
				return 0.3f;
			}
			if ((name.StartsWith("Spear") || name.StartsWith("Body")) && text.StartsWith("Stomp Colliders"))
			{
				return 0.3f;
			}
			if (text.StartsWith("sand_burst_effect_uppercut"))
			{
				return 0.3f;
			}
			if (name.StartsWith("Swamp Shaman Fireball"))
			{
				return 0.3f;
			}
			if (name.StartsWith("Abyss Bullet"))
			{
				return 0.3f;
			}
			if ((name.StartsWith("damager") && text.StartsWith("Lost_Lace_Wake_Tendrils")) || (name.StartsWith("Charge Hit") && text.StartsWith("Lost Lace Boss")))
			{
				return 0.2f;
			}
			return 0f;
		}

		public static bool IsValidActiveState(string bossName, string stateName)
		{
			if (!parryableStates.TryGetValue(bossName, out HashSet<string> value))
			{
				return false;
			}
			HashSet<string> value2;
			bool flag = unparryableStates.TryGetValue(bossName, out value2) && value2.Contains(stateName);
			foreach (string item in value)
			{
				if (stateName.StartsWith(item) && !flag)
				{
					return true;
				}
			}
			return false;
		}

		public static string[] getGameObjectParentRootNames(GameObject gameObject)
		{
			return new string[3]
			{
				((Object)(object)gameObject == (Object)null) ? "NULLGAMEOBJECT" : ((Object)gameObject).name,
				((Object)(object)gameObject.transform.parent == (Object)null) ? "NULLPARENT" : ((Object)gameObject.transform.parent).name,
				((Object)(object)gameObject.transform.root == (Object)null) ? "NULLROOT" : ((Object)gameObject.transform.root).name
			};
		}
	}
}