Decompiled source of NoRoarStun v1.0.0

NoRoarStun.dll

Decompiled 2 months ago
using System;
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.Configuration;
using HarmonyLib;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
using Microsoft.CodeAnalysis;
using Silksong.FsmUtil;
using UnityEngine;
using UnityEngine.SceneManagement;

[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("NoRoarStun")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+9823141aca6f3b8caca78317ae80d30fe2dd96e7")]
[assembly: AssemblyProduct("NoRoarStun")]
[assembly: AssemblyTitle("NoRoarStun")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
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")]
	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")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace NoRoarStun
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("io.github.vitaxses.noroarstun", "NoRoarStun", "1.0.0")]
	public class NoRoarStunPlugin : BaseUnityPlugin
	{
		public enum GauntletType
		{
			NoStun,
			SkipScream
		}

		[HarmonyPatch("OnEnter")]
		public static class StartRoarEmitterPatch
		{
			[HarmonyPatch(typeof(StartRoarEmitter))]
			[HarmonyPrefix]
			private static void StartRoarEmitter_Prefix_OnEnter(StartRoarEmitter __instance)
			{
				__instance.stunHero.Value = false;
			}

			[HarmonyPatch(typeof(StartRoarEmitterV2))]
			[HarmonyPrefix]
			private static void StartRoarEmitterV2_Prefix_OnEnter(StartRoarEmitterV2 __instance)
			{
				__instance.stunHero.Value = false;
			}
		}

		[HarmonyPatch(typeof(PlayMakerFSM), "Awake")]
		public static class FsmPatch
		{
			[HarmonyPostfix]
			private static void Postfix_OnEnter(PlayMakerFSM __instance)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				Scene scene = ((Component)__instance).gameObject.scene;
				string baseSceneName = GameManager.GetBaseSceneName(((Scene)(ref scene)).name);
				if (__instance != null && __instance.FsmName == "Control" && ((Object)__instance).name == "Start Range" && baseSceneName == "Hang_04")
				{
					if (GauntletSkipType.Value == GauntletType.SkipScream)
					{
						FsmUtil.ChangeTransition(__instance, "State", "UNWOKEN", "Woken");
						return;
					}
					FsmUtil.ChangeTransition(__instance, "Pull Quake", FsmEvent.Finished.Name, "Wake");
					SendEventByName lastActionOfType = FsmUtil.GetLastActionOfType<SendEventByName>(__instance, "Roar Lock");
					if (lastActionOfType != null)
					{
						((FsmStateAction)lastActionOfType).enabled = false;
					}
				}
				else if (baseSceneName == "Library_02" && __instance.FsmName == "Control" && ((Object)__instance).name.StartsWith("Schola"))
				{
					if (GauntletSkipType.Value == GauntletType.SkipScream)
					{
						FsmUtil.DisableActions(__instance, "Roar", new int[5] { 1, 4, 5, 6, 7 });
						PlayerDataBoolTest firstActionOfType = FsmUtil.GetFirstActionOfType<PlayerDataBoolTest>(__instance, "Wake Threads");
						if (firstActionOfType != null)
						{
							firstActionOfType.isFalse = FsmEvent.GetFsmEvent("REFIGHT");
						}
					}
					else
					{
						SendEventByName lastActionOfType2 = FsmUtil.GetLastActionOfType<SendEventByName>(__instance, "Roar");
						if (lastActionOfType2 != null)
						{
							((FsmStateAction)lastActionOfType2).enabled = false;
						}
					}
				}
				else
				{
					if (!(baseSceneName == "Song_04") || __instance == null || !(__instance.FsmName == "Control") || !(((Object)__instance).name == "Wake Scene"))
					{
						return;
					}
					if (GauntletSkipType.Value == GauntletType.SkipScream)
					{
						FsmUtil.ChangeTransition(__instance, "State", "UNWOKEN", "Woken");
						return;
					}
					SendEventByName lastActionOfType3 = FsmUtil.GetLastActionOfType<SendEventByName>(__instance, "Roar Lock");
					if (lastActionOfType3 != null)
					{
						((FsmStateAction)lastActionOfType3).enabled = false;
					}
				}
			}
		}

		public static ConfigEntry<GauntletType> GauntletSkipType;

		public const string Id = "io.github.vitaxses.noroarstun";

		public static string Name => "NoRoarStun";

		public static string Version => "1.0.0";

		private void Awake()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin " + Name + " (io.github.vitaxses.noroarstun) has loaded!"));
			new Harmony("io.github.vitaxses.noroarstun").PatchAll();
			GauntletSkipType = ((BaseUnityPlugin)this).Config.Bind<GauntletType>("General", "Enemy Gauntlet Mode", GauntletType.NoStun, "");
		}
	}
}