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 EntityStates;
using IL.RoR2;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
[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("RevertStunBuff")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RevertStunBuff")]
[assembly: AssemblyTitle("RevertStunBuff")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace RevertStunBuff;
[BepInPlugin("com.Viliger.RevertStunBuff", "RevertStunBuff", "1.0.0")]
public class RevertStunBuffPlugin : BaseUnityPlugin
{
public const string Author = "Viliger";
public const string ModName = "RevertStunBuff";
public const string Version = "1.0.0";
public const string GUID = "com.Viliger.RevertStunBuff";
private void Awake()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
SetStateOnHurt.SetStunInternal += new Manipulator(SetStateOnHurt_SetStunInternal);
}
private void SetStateOnHurt_SetStunInternal(ILContext il)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_0103: 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_0141: Unknown result type (might be due to invalid IL or missing references)
ILLabel test1 = null;
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref test1)
}))
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"Failed to IL hook RoR2::SetStateOnHurt::SetStunInternal: couldn't get jump index.");
}
val = new ILCursor(il);
int num2 = default(int);
int num = default(int);
if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[5]
{
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, ref num2),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<SetStateOnHurt>(x, "targetStateMachine"),
(Instruction x) => ILPatternMatchingExt.MatchCallvirt<EntityStateMachine>(x, "get_state"),
(Instruction x) => ILPatternMatchingExt.MatchIsinst<StunState>(x),
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, ref num)
}))
{
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldarg_1);
val.EmitDelegate<Action<SetStateOnHurt, float>>((Action<SetStateOnHurt, float>)delegate(SetStateOnHurt self, float stunDuration)
{
EntityState state = self.targetStateMachine.state;
StunState val2 = (StunState)(object)((state is StunState) ? state : null);
if (val2.timeRemaining < stunDuration)
{
val2.ExtendStun(stunDuration - val2.timeRemaining);
}
});
val.Emit(OpCodes.Br_S, (object)test1);
}
else
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"Failed to IL hook RoR2::SetStateOnHurt::SetStunInternal: couldn't apply stun mod.");
}
}
}