Decompiled source of FS Arena Fix v1.0.0

FS_Arena_Fix.dll

Decompiled 4 days 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.Logging;
using EntityStates;
using EntityStates.FalseSonBoss;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using MonoMod.Utils;
using On.EntityStates.FalseSonBoss;
using RoR2;

[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("FS_Arena_Fix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FS_Arena_Fix")]
[assembly: AssemblyTitle("FS_Arena_Fix")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace FS_Arena_Fix
{
	[BepInPlugin("Onyx.FS_Arena_Fix", "FS_Arena_Fix", "1.0.0")]
	public class FS_Arena_Fix : BaseUnityPlugin
	{
		public const string PluginGUID = "Onyx.FS_Arena_Fix";

		public const string PluginAuthor = "Onyx";

		public const string PluginName = "FS_Arena_Fix";

		public const string PluginVersion = "1.0.0";

		public void Awake()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			MethodInfo methodInfo = AccessTools.Method(typeof(MeridianEventTriggerInteraction), "RotateHead", (Type[])null, (Type[])null);
			new ILHook((MethodBase)Extensions.GetStateMachineTarget(methodInfo), new Manipulator(RotateHead));
			LunarGazeLeap.GetMinimumInterruptPriority += new hook_GetMinimumInterruptPriority(LunarGazeLeap_GetMinimumInterruptPriority);
		}

		private InterruptPriority LunarGazeLeap_GetMinimumInterruptPriority(orig_GetMinimumInterruptPriority orig, LunarGazeLeap self)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			return (InterruptPriority)5;
		}

		private void RotateHead(ILContext il)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			MethodInfo methodInfo = AccessTools.Method(typeof(MeridianEventTriggerInteraction), "OuterRingFalling", (Type[])null, (Type[])null);
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(MeridianEventTriggerInteraction), "colossusHeadDuration"),
				(Instruction x) => ILPatternMatchingExt.MatchDiv(x)
			}))
			{
				val.Emit(OpCodes.Dup);
				val.EmitDelegate<Action<float>>((Action<float>)fixAnimationDuration);
			}
			else
			{
				Log.Error(((MemberReference)il.Method).Name + " IL Hook failed!");
			}
		}

		private void fixAnimationDuration(float timeElapsed)
		{
			if (timeElapsed > 10f)
			{
				MeridianEventTriggerInteraction instance = MeridianEventTriggerInteraction.instance;
				instance.colossusHeadDuration = timeElapsed;
				instance.ringFallOffTime = 1000f;
			}
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}