using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using InControl;
using Microsoft.CodeAnalysis;
[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("ParryCounterEnhance")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d25889dddb19cc015f07f9d96606657a5d268746")]
[assembly: AssemblyProduct("ParryCounterEnhance")]
[assembly: AssemblyTitle("ParryCounterEnhance")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
}
}
}
namespace ParryCounterEnhance
{
[BepInPlugin("Reits.ParryCounterEnhance", "ParryCounterEnhance", "1.0.2")]
[HarmonyPatch]
public class ParryCounterEnhance : BaseUnityPlugin
{
public const string Name = "ParryCounterEnhance";
public const string Guid = "Reits.ParryCounterEnhance";
public const string Version = "1.0.2";
public static ConfigEntry<bool> AirMultipleCounter;
public static ConfigEntry<bool> FallWhenCounterAtAir;
public static ConfigEntry<bool> JumpOrDashBreakCounter;
public static ConfigEntry<bool> EnterCounterPrepareEarler;
public void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
new Harmony("Reits.ParryCounterEnhance").PatchAll();
string text = "General";
AirMultipleCounter = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "AirMultipleCounter", true, "Allow Parry Counter in air");
FallWhenCounterAtAir = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "FallWhenCounterAtAir", true, "Apply normal gravity after an aerial Parry Counter instead of being launched upward");
JumpOrDashBreakCounter = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "JumpOrDashBreakCounter", true, "Cancel Parry Counter recovery frames with jump or dash");
EnterCounterPrepareEarler = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "EnterCounterPrepareEarler", true, "Enter Parry Counter prepara state earlier during various animation recovery frames");
}
[HarmonyPatch(typeof(ParryCounterDefenseState), "Parried")]
[HarmonyTranspiler]
private static List<CodeInstruction> ImmuneLiftYForce(IEnumerable<CodeInstruction> codes)
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
List<CodeInstruction> list = codes.ToList();
for (int i = 0; i < list.Count; i++)
{
CodeInstruction val = list[i];
if (!(val.opcode != OpCodes.Ldc_I4_S) && int.TryParse(val.operand.ToString(), out var result) && result == 34)
{
list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ParryCounterEnhance), "AllowAirCounter", (Type[])null, (Type[])null)));
break;
}
}
return list;
}
[HarmonyPatch(typeof(ParryCounterDefenseState), "OnStateUpdate")]
[HarmonyPostfix]
private static void CanMove(Player ___player)
{
if (JumpOrDashBreakCounter.Value && !___player.DodgeCheck() && !___player.JumpCheck())
{
}
}
[HarmonyPatch(typeof(ParryCounterDefenseState), "AnimationEvent")]
[HarmonyPostfix]
private static void FastCounterAtCounteDefense(PlayerAnimationEventTag tag, Player ___player)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Invalid comparison between Unknown and I4
if (EnterCounterPrepareEarler.Value)
{
if ((int)tag == 4)
{
SimpleCounterCheck(___player);
}
}
}
[HarmonyPatch(typeof(PlayerCounterAttackState), "OnStateUpdate")]
[HarmonyPostfix]
private static void OnStateUpdate(Player ___player, bool ___canMove)
{
if (___canMove)
{
if (EnterCounterPrepareEarler.Value)
{
___player.ParryCounterCheck();
}
}
else if (FallWhenCounterAtAir.Value)
{
___player.Fall(false);
}
}
[HarmonyPatch(typeof(PlayerParriedState), "AnimationEvent")]
[HarmonyPostfix]
public static void FastCounterAtParried(PlayerAnimationEventTag tag, Player ___player)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
if (EnterCounterPrepareEarler.Value)
{
if ((int)tag == 0 || (int)tag == 4)
{
SimpleCounterCheck(___player);
}
}
}
[HarmonyPatch(typeof(PlayerCounterAttackState), "AnimationEvent")]
[HarmonyPostfix]
public static void FastCounterAtCounterAttack(PlayerAnimationEventTag tag, Player ___player)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (EnterCounterPrepareEarler.Value)
{
if ((int)tag == 0)
{
SimpleCounterCheck(___player);
}
}
}
private static bool SimpleCounterCheck(Player p)
{
if (((Actor)p).IsAirBorne)
{
return false;
}
float trueTimer = p.parryIsPressCondition.TrueTimer;
if (((OneAxisInputControl)p.actions.Parry).IsPressed && trueTimer > 0.33333f && trueTimer < 1.4f)
{
p.ChangeState((PlayerStateType)47, false);
return true;
}
return false;
}
private static PlayerStateType AllowAirCounter(int state)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
return (PlayerStateType)(AirMultipleCounter.Value ? 59 : state);
}
}
}