Decompiled source of AcolyteInputFix v1.0.0

plugins/AcolyteInputFix.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using EntityStates;
using EntityStates.Acolyte;
using EntityStates.Acolyte.Weapon;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using RoR2;
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("AcolyteInputFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AcolyteInputFix")]
[assembly: AssemblyTitle("AcolyteInputFix")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AcolyteInputFix;

[BepInPlugin("com.tsuyoikenko.AcolyteInputFix", "AcolyteInputFix", "1.0.0")]
public class AcolyteInputFixPlugin : BaseUnityPlugin
{
	public const string PluginGUID = "com.tsuyoikenko.AcolyteInputFix";

	public const string PluginName = "AcolyteInputFix";

	public const string PluginVersion = "1.0.0";

	private ILHook gatherInputsHook;

	private void Awake()
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		MethodInfo method = typeof(AcolyteCharacterMain).GetMethod("GatherInputs", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		gatherInputsHook = new ILHook((MethodBase)method, new Manipulator(AcolyteCharacterMain_GatherInputs));
	}

	private void OnDestroy()
	{
		ILHook obj = gatherInputsHook;
		if (obj != null)
		{
			obj.Dispose();
		}
	}

	private void AcolyteCharacterMain_GatherInputs(ILContext il)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		ILCursor val = new ILCursor(il);
		int comboLoc = -1;
		ILLabel skipLabel = null;
		if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4]
		{
			(Instruction x) => ILPatternMatchingExt.MatchIsinst<BaseBladeCombo>(x),
			(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref comboLoc),
			(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, comboLoc),
			(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref skipLabel)
		}))
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Failed to find BaseBladeCombo check in AcolyteCharacterMain.GatherInputs. Hook not applied.");
			return;
		}
		val.Emit(OpCodes.Ldloc, comboLoc);
		val.EmitDelegate<Func<BaseBladeCombo, bool>>((Func<BaseBladeCombo, bool>)HasPrimaryStock);
		val.Emit(OpCodes.Brfalse, (object)skipLabel);
	}

	private static bool HasPrimaryStock(BaseBladeCombo combo)
	{
		SkillLocator val = (Object.op_Implicit((Object)(object)((EntityState)combo).outer) ? ((EntityState)combo).outer.commonComponents.skillLocator : null);
		if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.primary))
		{
			return val.primary.stock > 0;
		}
		return false;
	}
}