using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using RoR2;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
namespace Prototype;
[BepInPlugin("prototype.rex.hurtbox", "AlignRexHurtbox", "0.1.0")]
public class AlignRexHurtbox : BaseUnityPlugin
{
public const string identifier = "prototype.rex.hurtbox";
public const string version = "0.1.0";
public void Awake()
{
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
{
Harmony.CreateAndPatchAll(((object)this).GetType(), (string)null);
});
}
[HarmonyPatch(typeof(SprintEffectController), "FixedUpdate")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Patch(IEnumerable<CodeInstruction> code)
{
bool found = false;
BodyIndex index = SurvivorCatalog.GetBodyIndexFromSurvivorIndex(Survivors.Treebot.survivorIndex);
foreach (CodeInstruction instruction in code)
{
if (instruction.opcode == OpCodes.Ret)
{
if (found)
{
yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null);
yield return Transpilers.EmitDelegate<Action<SprintEffectController>>((Action<SprintEffectController>)delegate(SprintEffectController controller)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
center(controller, Vector3.zero);
});
}
else
{
found = true;
yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null);
yield return Transpilers.EmitDelegate<Action<SprintEffectController>>((Action<SprintEffectController>)delegate(SprintEffectController controller)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
center(controller, Vector3.down / 1.5f);
});
}
}
yield return instruction;
}
void center(SprintEffectController controller, Vector3 offset)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
CharacterBody characterBody = controller.characterBody;
if (characterBody.bodyIndex == index)
{
Collider collider = characterBody.mainHurtBox.collider;
CapsuleCollider val = (CapsuleCollider)(object)((collider is CapsuleCollider) ? collider : null);
if (val != null)
{
val.center = val.height * offset;
}
}
}
}
}