Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Class Roles v0.7.34
plugins/RepoClassMod.dll
Decompiled 4 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using Unity.Collections; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Utilities; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [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("RepoClassMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RepoClassMod")] [assembly: AssemblyTitle("RepoClassMod")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } [CompilerGenerated] [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 RepoClassMod { [BepInPlugin("local.repoclassmod", "레포 직업 모드", "0.7.34")] [BepInProcess("REPO.exe")] public sealed class ClassModPlugin : BaseUnityPlugin, IOnEventCallback, IInRoomCallbacks { [HarmonyPatch] private static class BarrierAttackAiming { private static readonly MethodInfo GetTransform = AccessTools.PropertyGetter(typeof(Component), "transform"); private static readonly MethodInfo GetPosition = AccessTools.PropertyGetter(typeof(Transform), "position"); private static readonly FieldInfo? PlayerVision = AccessTools.Field(typeof(PlayerAvatar), "PlayerVisionTarget"); private static readonly FieldInfo? VisionTransform = ((PlayerVision == null) ? null : AccessTools.Field(PlayerVision.FieldType, "VisionTransform")); private static readonly Dictionary<MethodBase, (FieldInfo Enemy, FieldInfo Target)> AimMethods = FindAimMethods(); private static Dictionary<MethodBase, (FieldInfo Enemy, FieldInfo Target)> FindAimMethods() { Dictionary<MethodBase, (FieldInfo, FieldInfo)> dictionary = new Dictionary<MethodBase, (FieldInfo, FieldInfo)>(); (string, string, string[])[] array = new(string, string, string[])[11] { ("EnemyAnimal", "playerTarget", new string[1] { "StateGoToPlayer" }), ("EnemyBeamer", "playerTarget", new string[2] { "StateAttackStart", "VerticalAimLogic" }), ("EnemyBirthdayBoy", "playerTarget", new string[2] { "StateGoToPlayerAngry", "StateAttack" }), ("EnemyBowtie", "playerTarget", new string[1] { "HorizontalRotationLogic" }), ("EnemyFloater", "targetPlayer", new string[3] { "StateGoToPlayer", "StateSneak", "RotationLogic" }), ("EnemyRobe", "targetPlayer", new string[2] { "MoveTowardPlayer", "StateTargetPlayer" }), ("EnemyRunner", "targetPlayer", new string[3] { "StateSneak", "StateAttackPlayer", "StateAttackPlayerOver" }), ("EnemySlowWalker", "targetPlayer", new string[3] { "StateGoToPlayer", "StateSneak", "RotationLogic" }), ("EnemyTumbler", "targetPlayer", new string[2] { "StateMoveToPlayer", "StateTumble" }), ("EnemyUpscream", "targetPlayer", new string[2] { "StateGoToPlayer", "StateAttack" }), ("EnemyVirus", "targetPlayer", new string[3] { "StateGoToPlayer", "StateSneak", "RotationLogic" }) }; for (int i = 0; i < array.Length; i++) { (string, string, string[]) tuple = array[i]; Type type = typeof(Enemy).Assembly.GetType(tuple.Item1); if (type == null) { continue; } FieldInfo fieldInfo = AccessTools.Field(type, "enemy"); if ((object)fieldInfo == null || fieldInfo.FieldType != typeof(Enemy)) { continue; } FieldInfo fieldInfo2 = AccessTools.Field(type, tuple.Item2); if ((object)fieldInfo2 == null || fieldInfo2.FieldType != typeof(PlayerAvatar)) { continue; } string[] item = tuple.Item3; foreach (string text in item) { MethodInfo methodInfo = AccessTools.DeclaredMethod(type, text, Type.EmptyTypes, (Type[])null); if ((object)methodInfo != null && !methodInfo.IsStatic) { dictionary.Add(methodInfo, (fieldInfo, fieldInfo2)); } } } return dictionary; } private static bool Prepare() { return AimMethods.Count != 0; } private static IEnumerable<MethodBase> TargetMethods() { return AimMethods.Keys; } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase original) { List<CodeInstruction> code = instructions.ToList(); (FieldInfo, FieldInfo) tuple = AimMethods[original]; FieldInfo enemy = tuple.Item1; FieldInfo target = tuple.Item2; string name = original.Name; bool flag = ((name == "RotationLogic" || name == "VerticalAimLogic") ? true : false); string aim = (flag ? "BarrierStrikeLook" : "BarrierAttackAim"); for (int i = 0; i < code.Count; i++) { CodeInstruction instruction = code[i]; yield return instruction; if (CodeInstructionExtensions.Calls(instruction, GetPosition) && ReadsTargetPosition(code, i, target)) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Ldfld, (object)enemy); yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Ldfld, (object)target); yield return CodeInstruction.Call(typeof(ClassModPlugin), aim, (Type[])null, (Type[])null); } } } private static bool ReadsTargetPosition(List<CodeInstruction> code, int position, FieldInfo target) { if (position < 3 || !(code[position - 3].opcode == OpCodes.Ldarg_0) || !CodeInstructionExtensions.LoadsField(code[position - 2], target, false) || !CodeInstructionExtensions.Calls(code[position - 1], GetTransform)) { if (position >= 4 && PlayerVision != null && VisionTransform != null && code[position - 4].opcode == OpCodes.Ldarg_0 && CodeInstructionExtensions.LoadsField(code[position - 3], target, false) && CodeInstructionExtensions.LoadsField(code[position - 2], PlayerVision, false)) { return CodeInstructionExtensions.LoadsField(code[position - 1], VisionTransform, false); } return false; } return true; } } [HarmonyPatch(typeof(SemiFunc), "EnemyGetNearestPhysObject")] private static class BarrierObstacleTarget { private static void Postfix(Enemy __0, ref Vector3 __result) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) ClassModPlugin active = Active; if (active != null && active.TryAimBarrierObstacle(__0, __result, out BarrierMonsterTrace chosen)) { __result = chosen.ObstructionPoint; } } } private sealed class BangBarrierBlast { internal readonly Enemy Source; internal readonly RoomVolume? SourceRoom; internal readonly HashSet<RoomVolume> ProtectedRooms; internal bool HitBarrier; public BangBarrierBlast(Enemy source, Vector3 origin) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) Source = source; SourceRoom = RoomAt(origin); ProtectedRooms = new HashSet<RoomVolume>(); base..ctor(); } } [HarmonyPatch] private static class TrackBangBarrierBlast { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(EnemyBang), "ExplodeRPC", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemyBang), "OnDeath", (Type[])null, (Type[])null); } private static void Prefix(ParticlePrefabExplosion? ___explosionScript, out ParticlePrefabExplosion? __state) { __state = ___explosionScript; } private static void Postfix(Enemy ___enemy, ParticlePrefabExplosion? ___explosionScript, ParticlePrefabExplosion? __state) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)___enemy) || !Object.op_Implicit((Object)(object)___explosionScript) || (Object)(object)___explosionScript == (Object)(object)__state || !Object.op_Implicit((Object)(object)___explosionScript.HurtCollider)) { return; } BangBarrierBlast bangBarrierBlast = new BangBarrierBlast(___enemy, ((Component)___explosionScript).transform.position); ClassModPlugin active = Active; if (active != null) { foreach (var item2 in active.ActiveBarriers()) { CombatState item = item2.Shield; bangBarrierBlast.ProtectedRooms.Add(item.Barrier); } } BangBarrierBlasts.Remove(___explosionScript.HurtCollider); BangBarrierBlasts.Add(___explosionScript.HurtCollider, bangBarrierBlast); } } private sealed class BeamerBeam { internal Enemy Enemy; internal Vector3 Origin; internal CombatState? StopShield; internal RoomVolume? StopRoom; internal BarrierWall[]? StopWalls; internal Vector3 SyncedEndpoint; internal void RememberContact(CombatState shield, Vector3 endpoint) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) StopShield = shield; StopRoom = shield.Barrier; StopWalls = shield.BarrierWalls; SyncedEndpoint = endpoint; } internal void ClearContact() { StopShield = null; StopRoom = null; StopWalls = null; } internal bool TryStopAt(Vector3 target, out Vector3 point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) point = default(Vector3); BarrierWall[] stopWalls = StopWalls; if (stopWalls == null) { return false; } Vector3 val = target - Origin; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.0001f) { return false; } val /= magnitude; float num = magnitude + 0.006f; bool flag = false; BarrierWall[] array = stopWalls; foreach (BarrierWall barrierWall in array) { if (barrierWall.RayIntersection(Origin, val, out var distance) && !(distance >= num)) { num = distance; flag = true; } } if (flag) { point = Origin + val * num; } return flag; } } [HarmonyPatch] private static class BeamerMeleeBarrierAim { private static readonly FieldInfo PlayerTarget = AccessTools.Field(typeof(EnemyBeamer), "playerTarget"); private static readonly FieldInfo LaserCooldown = AccessTools.Field(typeof(EnemyBeamer), "laserCooldown"); private static readonly MethodInfo GetTransform = AccessTools.PropertyGetter(typeof(Component), "transform"); private static readonly MethodInfo GetPosition = AccessTools.PropertyGetter(typeof(Transform), "position"); private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.DeclaredMethod(typeof(EnemyBeamer), "OnVision", (Type[])null, (Type[])null); yield return AccessTools.DeclaredMethod(typeof(EnemyBeamer), "StateMeleeStart", (Type[])null, (Type[])null); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> code = new List<CodeInstruction>(instructions); bool melee = true; for (int i = 0; i < code.Count; i++) { CodeInstruction instruction = code[i]; yield return instruction; if (CodeInstructionExtensions.LoadsField(instruction, LaserCooldown, false)) { melee = false; } if (melee && i >= 2 && CodeInstructionExtensions.Calls(instruction, GetPosition) && CodeInstructionExtensions.Calls(code[i - 1], GetTransform) && CodeInstructionExtensions.LoadsField(code[i - 2], PlayerTarget, false)) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return CodeInstruction.Call(typeof(BeamerMeleeBarrierAim), "Aim", (Type[])null, (Type[])null); } } } private static Vector3 Aim(Vector3 original, EnemyBeamer beamer) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) return BarrierStrikeTarget(original, BeamerEnemy.Invoke(beamer), BeamerPlayerTarget.Invoke(beamer), canStartStrike: true, ((Component)beamer).transform.position.y); } } [HarmonyPatch(typeof(EnemyBeamer), "LaserLogic")] private static class BeamerLaserBarrier { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { FieldInfo hitImpact = AccessTools.Field(typeof(EnemyBeamer), "hitPositionImpact"); MethodInfo laserActive = AccessTools.Method(typeof(SemiLaser), "LaserActive", (Type[])null, (Type[])null); foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.StoresField(instruction, hitImpact)) { yield return CodeInstructionExtensions.MoveBlocksFrom(CodeInstructionExtensions.MoveLabelsFrom(CodeInstruction.Call(typeof(BeamerLaserBarrier), "RecordRaySample", (Type[])null, (Type[])null), instruction), instruction); } else if (CodeInstructionExtensions.Calls(instruction, laserActive)) { yield return CodeInstructionExtensions.MoveBlocksFrom(CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Ldarg_0, (object)null), instruction), instruction); yield return CodeInstruction.Call(typeof(BeamerLaserBarrier), "ActivateLaser", (Type[])null, (Type[])null); } else { yield return instruction; } } } private static void RecordRaySample(EnemyBeamer beamer, bool impact) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) BeamerHitImpact.Invoke(beamer) = impact; Transform val = BeamerLaserStart.Invoke(beamer); ClassModPlugin active = Active; if (active == null || !active.IsAuthority || !Object.op_Implicit((Object)(object)val)) { return; } SemiLaser val2 = BeamerLaser.Invoke(beamer); HurtCollider val3 = (Object.op_Implicit((Object)(object)val2) ? BeamHurtCollider.Invoke(val2) : null); Enemy val4 = BeamerEnemy.Invoke(beamer); BeamerBeam beamerBeam = ((Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val4)) ? TrackBeam(val3, val4, val.position) : null); if (!active.TryBarrierSegment(val.position, BeamerHitPosition.Invoke(beamer), out (int, CombatState) barrier, out Vector3 point)) { beamerBeam?.ClearContact(); return; } BeamerHitPosition.Invoke(beamer) = point; BeamerHitImpact.Invoke(beamer) = true; beamerBeam?.RememberContact(barrier.Item2, point); if (!Object.op_Implicit((Object)(object)val4) || (Object)(object)val3 == (Object)null || !((Behaviour)val3).isActiveAndEnabled || !val3.playerLogic) { return; } PlayerAvatar val5 = BeamerPlayerTarget.Invoke(beamer); int num = ((val3.playerKill && Alive(val5)) ? Health.Invoke(val5.playerHealth) : val3.playerDamage); if (num <= 0) { return; } BarrierRuntime barrierRuntime = barrier.Item2.BarrierRuntime; if (barrierRuntime != null) { double now = active.Now; HitCycle orCreateValue = active.barrierHits.GetOrCreateValue(val3); if (!(now < orCreateValue.Next) && !(now < barrierRuntime.Attackers.GetOrCreateValue(val4).Next)) { orCreateValue.Next = ((val3.playerDamageCooldown > 0f) ? (now + (double)val3.playerDamageCooldown) : double.PositiveInfinity); active.TryApplyBarrierStrike(barrier, val4, num, point); } } } private static void ActivateLaser(SemiLaser laser, Vector3 start, Vector3 end, bool impact, float shake, float initialShake, float sustain, EnemyBeamer beamer) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) HurtCollider val = BeamHurtCollider.Invoke(laser); BeamerBeam beamerBeam = (Object.op_Implicit((Object)(object)val) ? TrackBeam(val, BeamerEnemy.Invoke(beamer), start) : null); Vector3 val2 = BeamerHitPosition.Invoke(beamer); CombatState combatState = beamerBeam?.StopShield; if (combatState != null && beamerBeam.SyncedEndpoint == val2 && !IsActiveBarrier(combatState) && beamerBeam.TryStopAt(end, out var point)) { end = point; impact = true; } ClassModPlugin active = Active; if (active != null && active.TryBarrierSegment(start, end, out (int, CombatState) barrier, out Vector3 point2)) { end = point2; impact = true; beamerBeam?.RememberContact(barrier.Item2, val2); } else if (beamerBeam != null && beamerBeam.SyncedEndpoint != val2) { ClassModPlugin active2 = Active; if (active2 != null && active2.TryBarrierSegment(start, val2, out (int, CombatState) barrier2, out Vector3 _)) { beamerBeam.RememberContact(barrier2.Item2, val2); } else { beamerBeam.ClearContact(); } } laser.LaserActive(start, end, impact, shake, initialShake, sustain); } private static BeamerBeam TrackBeam(HurtCollider attack, Enemy enemy, Vector3 start) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) BeamerBeam value = BeamerBeams.GetValue(attack, (HurtCollider _) => new BeamerBeam()); value.Enemy = enemy; value.Origin = start; return value; } } [HarmonyPatch(typeof(HurtCollider), "PlayerHurt")] private static class BeamerLaserPlayerProtection { [HarmonyPriority(600)] private static bool Prefix(HurtCollider __instance, PlayerAvatar __0) { return !BeamerLaserCrossesBarrier(__instance, __0); } } [HarmonyPatch(typeof(HurtCollider), "PhysObjectHurt")] private static class BeamerLaserTumbleProtection { private static bool Prefix(HurtCollider __instance, PhysGrabObject __0) { PlayerTumble val = default(PlayerTumble); if (Object.op_Implicit((Object)(object)__0) && ((Component)__0).TryGetComponent<PlayerTumble>(ref val)) { return !BeamerLaserCrossesBarrier(__instance, TumblePlayer.Invoke(val)); } return true; } } private sealed class BombHeadMotion(Vector3 root, Bounds bounds, Collider[] colliders) { internal Vector3 Root = root; internal Bounds Bounds = bounds; internal readonly Collider[] Colliders = colliders; } [HarmonyPatch] private static class BombHeadBarrierMovement { private static readonly ConditionalWeakTable<EnemyBombThrowerHead, BombHeadMotion> Motion = new ConditionalWeakTable<EnemyBombThrowerHead, BombHeadMotion>(); private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.DeclaredMethod(typeof(EnemyBombThrowerHead), "StateMachine", (Type[])null, (Type[])null); yield return AccessTools.DeclaredMethod(typeof(EnemyBombThrowerHead), "AnimationEventExplode", (Type[])null, (Type[])null); } private static void Prefix(EnemyBombThrowerHead __instance, State ___currentState, bool ___stateImpulse, PhysGrabObject ___physGrabObject, out bool __state) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_007c: Unknown result type (might be due to invalid IL or missing references) __state = (int)___currentState == 1 && ___stateImpulse; ClassModPlugin active = Active; BombHeadMotion value; Bounds bounds; if ((active == null || !active.CombatAvailable || !active.IsAuthority || (int)___currentState == 0) | __state) { Motion.Remove(__instance); } else if (Object.op_Implicit((Object)(object)___physGrabObject) && Object.op_Implicit((Object)(object)___physGrabObject.rb) && Motion.TryGetValue(__instance, out value) && TryGetBounds(___physGrabObject.rb, value.colliders, out bounds)) { active.StopBombHeadAtBarriers(___physGrabObject.rb, bounds, value); } } private static void Postfix(EnemyBombThrowerHead __instance, State ___currentState, PhysGrabObject ___physGrabObject, bool __state) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) ClassModPlugin active = Active; if (active != null && active.CombatAvailable && active.IsAuthority && (int)___currentState != 0 && !Motion.TryGetValue(__instance, out BombHeadMotion _) && Object.op_Implicit((Object)(object)___physGrabObject) && Object.op_Implicit((Object)(object)___physGrabObject.rb)) { Rigidbody rb = ___physGrabObject.rb; Collider[] componentsInChildren = ((Component)___physGrabObject).GetComponentsInChildren<Collider>(true); if (TryGetBounds(rb, componentsInChildren, out var bounds)) { Vector3 val = ((__state && Object.op_Implicit((Object)(object)__instance.controller)) ? ((Component)__instance.controller).transform.position : rb.position); Bounds bounds2 = bounds; ((Bounds)(ref bounds2)).center = ((Bounds)(ref bounds2)).center + (val - rb.position); BombHeadMotion bombHeadMotion = new BombHeadMotion(val, bounds2, componentsInChildren); active.StopBombHeadAtBarriers(rb, bounds, bombHeadMotion); Motion.Add(__instance, bombHeadMotion); } } } private static bool TryGetBounds(Rigidbody body, Collider[] colliders, out Bounds bounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); bool flag = false; foreach (Collider val in colliders) { if (Object.op_Implicit((Object)(object)val) && val.enabled && !val.isTrigger && !((Object)(object)val.attachedRigidbody != (Object)(object)body) && ((Component)val).gameObject.activeInHierarchy) { if (flag) { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } else { bounds = val.bounds; } flag = true; } } if (flag) { ((Bounds)(ref bounds)).center = ((Bounds)(ref bounds)).center + (body.position - ((Component)body).transform.position); } return flag; } } [HarmonyPatch] private static class BombThrowerBarrierMelee { private static readonly FieldInfo PlayerTarget = AccessTools.Field(typeof(EnemyBombThrower), "playerTarget"); private static readonly FieldRef<EnemyBombThrower, PlayerAvatar> Target = AccessTools.FieldRefAccess<EnemyBombThrower, PlayerAvatar>("playerTarget"); private static readonly FieldRef<EnemyBombThrower, Enemy> Enemy = AccessTools.FieldRefAccess<EnemyBombThrower, Enemy>("enemy"); private static readonly FieldRef<EnemyBombThrower, State> State = AccessTools.FieldRefAccess<EnemyBombThrower, State>("currentState"); private static readonly MethodInfo GetTransform = AccessTools.PropertyGetter(typeof(Component), "transform"); private static readonly MethodInfo GetPosition = AccessTools.PropertyGetter(typeof(Transform), "position"); private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.DeclaredMethod(typeof(EnemyBombThrower), "MeleeLogic", (Type[])null, (Type[])null); yield return AccessTools.DeclaredMethod(typeof(EnemyBombThrower), "RotationStateSet", (Type[])null, (Type[])null); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase original) { List<CodeInstruction> code = instructions.ToList(); bool checkingReach = original.Name == "MeleeLogic"; for (int i = 0; i < code.Count; i++) { CodeInstruction instruction = code[i]; yield return instruction; if (i >= 2 && CodeInstructionExtensions.Calls(instruction, GetPosition) && CodeInstructionExtensions.Calls(code[i - 1], GetTransform) && CodeInstructionExtensions.LoadsField(code[i - 2], PlayerTarget, false)) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(checkingReach ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_0, (object)null); yield return CodeInstruction.Call(typeof(BombThrowerBarrierMelee), "Redirect", (Type[])null, (Type[])null); } } } private static Vector3 Redirect(Vector3 original, EnemyBombThrower thrower, bool checkingReach) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if ((int)State.Invoke(thrower) != (checkingReach ? 5 : 9)) { return original; } PlayerAvatar val = Target.Invoke(thrower); if (!Object.op_Implicit((Object)(object)val)) { return original; } return BarrierStrikeTarget(original, Enemy.Invoke(thrower), val, checkingReach, checkingReach ? new float?(((Component)thrower).transform.position.y) : ((float?)null)); } } private sealed class TrudgeHit { internal Enemy Enemy; internal bool Mace; } private sealed class HitCycle { internal double Next; } [HarmonyPatch(typeof(HurtCollider), "PlayerHurt")] private static class MonsterImpactProtection { [HarmonyPriority(600)] private static bool Prefix(HurtCollider __instance, PlayerAvatar __0) { ClassModPlugin active = Active; if ((Object)(object)active == (Object)null || !active.BlocksMonsterCollider(__instance, __0)) { return true; } active.CheckBarrierHit(__instance, __0); return false; } } [HarmonyPatch(typeof(HurtCollider), "PhysObjectHurt")] private static class MonsterTumbledPlayerProtection { private static bool Prefix(HurtCollider __instance, PhysGrabObject __0) { PlayerTumble val = default(PlayerTumble); if (Object.op_Implicit((Object)(object)__0) && ((Component)__0).TryGetComponent<PlayerTumble>(ref val)) { ClassModPlugin? active = Active; if (active == null) { return true; } return !active.BlocksMonsterCollider(__instance, TumblePlayer.Invoke(val)); } return true; } } [HarmonyPatch(typeof(SlowWalkerAttack), "SuckInListPlayerUpdate")] private static class TrudgeVacuumTargets { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { MethodInfo method = AccessTools.Method(typeof(SemiFunc), "PlayerGetAllPlayerAvatarWithinRange", (Type[])null, (Type[])null); bool patched = false; foreach (CodeInstruction instruction in instructions) { yield return instruction; if (CodeInstructionExtensions.Calls(instruction, method)) { patched = true; yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return CodeInstruction.Call(typeof(TrudgeVacuumTargets), "Filter", (Type[])null, (Type[])null); } } if (!patched) { throw new InvalidOperationException("Could not locate the Trudge suction target query."); } } private static List<PlayerAvatar> Filter(List<PlayerAvatar> players, SlowWalkerAttack attack) { ClassModPlugin mod = Active; if (mod != null && Object.op_Implicit((Object)(object)attack.enemy)) { players.RemoveAll((PlayerAvatar player) => mod.SeparatedByBarrier(attack.enemy, player) || mod.BlockProtectedHit(player, sustained: true)); } return players; } } [HarmonyPatch(typeof(SlowWalkerAttack), "StateImplosion")] private static class TrudgeVacuumForces { private static void Prefix(SlowWalkerAttack __instance, List<PlayerTumble> ___playerTumbles, List<PhysGrabObject> ___physGrabObjects) { ClassModPlugin mod = Active; if (mod == null || !Object.op_Implicit((Object)(object)__instance.enemy)) { return; } ___playerTumbles.RemoveAll((PlayerTumble body) => Object.op_Implicit((Object)(object)body) && (mod.SeparatedByBarrier(__instance.enemy, TumblePlayer.Invoke(body)) || mod.BlockProtectedHit(TumblePlayer.Invoke(body), sustained: true))); ___physGrabObjects.RemoveAll(delegate(PhysGrabObject item) { if (Object.op_Implicit((Object)(object)item)) { PlayerTumble componentInParent = ((Component)item).GetComponentInParent<PlayerTumble>(); if (componentInParent != null && Object.op_Implicit((Object)(object)componentInParent)) { if (!mod.SeparatedByBarrier(__instance.enemy, TumblePlayer.Invoke(componentInParent))) { return mod.BlockProtectedHit(TumblePlayer.Invoke(componentInParent), sustained: true); } return true; } } return false; }); } } [HarmonyPatch(typeof(HurtCollider), "Update")] private static class BarrierDamagePatch { private static void Postfix(HurtCollider __instance) { Active?.CheckBarrierHit(__instance); } } [HarmonyPatch(typeof(HurtCollider), "OnEnable")] private static class BarrierHitEnablePatch { private static void Postfix(HurtCollider __instance) { Active?.barrierHits.Remove(__instance); } } [HarmonyPatch(typeof(SlowWalkerAttack), "ActiveHurtColliderFirstHit")] private static class TrudgeMacePatch { private static void Prefix(SlowWalkerAttack __instance) { MarkTrudgeHit(__instance, __instance.hurtColliderFirstHit, mace: true); } } [HarmonyPatch(typeof(SlowWalkerAttack), "ActivateAttackHurtColliders")] private static class TrudgeImpactPatch { private static void Prefix(SlowWalkerAttack __instance) { MarkTrudgeHit(__instance, __instance.attackImpactHurtColliders, mace: false); } } [HarmonyPatch(typeof(SlowWalkerAttack), "ActivateImplosionHurtColliders")] private static class TrudgeImplosionPatch { private static void Prefix(SlowWalkerAttack __instance) { MarkTrudgeHit(__instance, __instance.attackVacuumHurtCollider, mace: false); } } [HarmonyPatch] private static class BarrierSpawnedTimer { private static MethodBase TargetMethod() { return AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(EnemyParent), "Logic", (Type[])null, (Type[])null)); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Expected O, but got Unknown //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); FieldInfo spawned = AccessTools.Field(typeof(EnemyParent), "Spawned"); FieldInfo timer = AccessTools.Field(typeof(EnemyParent), "SpawnedTimer"); MethodInfo despawn = AccessTools.Method(typeof(EnemyParent), "Despawn", (Type[])null, (Type[])null); int num = list.FindIndex((CodeInstruction instruction) => CodeInstructionExtensions.Calls(instruction, despawn)); int num2 = list.FindIndex((CodeInstruction instruction) => CodeInstructionExtensions.LoadsField(instruction, spawned, false)); int num3 = list.FindIndex((CodeInstruction instruction) => CodeInstructionExtensions.StoresField(instruction, timer)); if (num < 0 || num >= num2 || num2 + 2 >= list.Count || num3 <= num2 + 1 || num3 + 1 >= list.Count || (list[num2 + 1].opcode != OpCodes.Brfalse && list[num2 + 1].opcode != OpCodes.Brfalse_S) || (list[num3 + 1].opcode != OpCodes.Br && list[num3 + 1].opcode != OpCodes.Br_S) || !(list[num3 + 1].operand is Label label)) { throw new InvalidOperationException("Could not locate the spawned enemy's despawn timer."); } list[num].opcode = OpCodes.Call; list[num].operand = AccessTools.Method(typeof(ClassModPlugin), "DespawnOutsideBarrierRule", (Type[])null, (Type[])null); list[num2 + 1].opcode = OpCodes.Brfalse; CodeInstruction val = list[num2 - 1]; list.InsertRange(num2 + 2, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[3] { new CodeInstruction(val.opcode, val.operand), CodeInstruction.Call(typeof(ClassModPlugin), "BarrierKeepsMonsterSpawned", (Type[])null, (Type[])null), new CodeInstruction(OpCodes.Brtrue, (object)label) }); return list; } } [HarmonyPatch] private static class BarrierSpawnedTimerWrites { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(EnemyParent), "SpawnedTimerSet", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemyParent), "SpawnedTimerReset", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemyParent), "Despawn", (Type[])null, (Type[])null); } private static bool Prefix(EnemyParent __instance) { return !BarrierKeepsMonsterSpawned(__instance); } } [HarmonyPatch] private static class BarrierEnemyDespawnState { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(EnemyStateDespawn), "ChaseDespawnLogic", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemyStateDespawn), "StuckDespawnLogic", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemyStateDespawn), "Despawn", (Type[])null, (Type[])null); } private static bool Prefix(Enemy ___Enemy) { return !BarrierKeepsEnemySpawned(___Enemy); } } [HarmonyPatch(typeof(SemiFunc), "EnemyForceLeave")] private static class BarrierEnemyForceLeave { private static bool Prefix(Enemy __0, ref bool __result) { if (!BarrierKeepsEnemySpawned(__0)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(EnemySnatcher), "StuckDespawn")] private static class BarrierSnatcherDespawn { private static bool Prefix(Enemy ___enemy) { return !BarrierKeepsEnemySpawned(___enemy); } } [HarmonyPatch(typeof(EnemyParent), "SpawnRPC")] private static class BarrierEnemySpawnSetup { private static void Prefix(EnemyParent __instance, out EnemyParent? __state) { __state = barrierDespawnBypass; barrierDespawnBypass = __instance; instantEnemyDeaths.Remove(__instance); } private static void Finalizer(EnemyParent? __state) { barrierDespawnBypass = __state; } } [HarmonyPatch] private static class BarrierImmediateEnemyDeaths { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(EnemyBang), "FuseLogic", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(PhysGrabObjectImpactDetector), "DestroyObject", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(SemiAffectExploding), "TargetResolve", (Type[])null, (Type[])null); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { MethodInfo despawn = AccessTools.Method(typeof(EnemyParent), "Despawn", (Type[])null, (Type[])null); MethodInfo bypass = AccessTools.Method(typeof(ClassModPlugin), "DespawnOutsideBarrierRule", (Type[])null, (Type[])null); foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.Calls(instruction, despawn)) { instruction.opcode = OpCodes.Call; instruction.operand = bypass; } yield return instruction; } } } [HarmonyPatch(typeof(HurtCollider), "EnemyHurt")] private static class BarrierEnemyInstantKill { private static void Postfix(HurtCollider __instance, Enemy __0, bool __result) { if (!__result || !__instance.enemyKill || !Object.op_Implicit((Object)(object)__0) || Object.op_Implicit((Object)(object)MonsterHealth.Invoke(__0)) || (int)ChaseState.Invoke(__0) != 11) { return; } EnemyParent val = HearingEnemyParent.Invoke(__0); if (val != null && Object.op_Implicit((Object)(object)val)) { instantEnemyDeaths.GetValue(val, (EnemyParent _) => InstantEnemyDeath); } } } [HarmonyPatch] private static class BarrierEnemyExitAnimation { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(EnemyHidden), "StateDespawn", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemyOogly), "StateDespawn", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemyOogly), "AnimatedDespawn", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemySlowMouth), "StateDespawn", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemySnatcher), "StateDespawn", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemyTricycle), "StateDespawn", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemyTricycle), "StateTeleportOut", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemyTricycle), "AnimatedDespawn", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemyHeartHugger), "DespawnStart", (Type[])null, (Type[])null); } private static bool Prefix(Enemy ___enemy) { return !BarrierKeepsEnemySpawned(___enemy); } } [HarmonyPatch(typeof(EnemyOogly), "StateTeleportOut")] private static class BarrierOoglyExitAnimation { private static bool Prefix(Enemy ___enemy, bool ___isAnimatedDespawn) { if (___isAnimatedDespawn) { return !BarrierKeepsEnemySpawned(___enemy); } return true; } } [HarmonyPatch(typeof(EnemyHeartHugger), "StateDegrow")] private static class BarrierHeartHuggerExitAnimation { private static bool Prefix(Enemy ___enemy, bool ___doDespawn) { if (___doDespawn) { return !BarrierKeepsEnemySpawned(___enemy); } return true; } } [HarmonyPatch(typeof(EnemyTricycle), "SetState")] private static class BarrierTricycleDespawn { private static bool Prefix(Enemy ___enemy, State __0) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if (((int)__0 == 18 || (int)__0 == 20) ? true : false) { return !BarrierKeepsEnemySpawned(___enemy); } return true; } } [HarmonyPatch(typeof(EnemyTick), "UpdateState")] private static class BarrierTickDespawn { private static bool Prefix(Enemy ___enemy, State __0) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)__0 == 13) { return !BarrierKeepsEnemySpawned(___enemy); } return true; } } [HarmonyPatch(typeof(EnemyTickAnim), "Update")] private static class BarrierTickExitAnimation { private static bool Prefix(Enemy ___enemy, EnemyTick ___controller) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)___controller) && (int)___controller.currentState == 13) { return !BarrierKeepsEnemySpawned(___enemy); } return true; } } [HarmonyPatch] private static class DuckBarrierAim { private static readonly FieldInfo PlayerTarget = AccessTools.Field(typeof(EnemyDuck), "playerTarget"); private static readonly FieldRef<EnemyDuck, PlayerAvatar> Target = AccessTools.FieldRefAccess<EnemyDuck, PlayerAvatar>("playerTarget"); private static readonly MethodInfo GetTransform = AccessTools.PropertyGetter(typeof(Component), "transform"); private static readonly MethodInfo GetPosition = AccessTools.PropertyGetter(typeof(Transform), "position"); private static readonly MethodInfo Add = AccessTools.Method(typeof(Vector3), "op_Addition", new Type[2] { typeof(Vector3), typeof(Vector3) }, (Type[])null); private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.DeclaredMethod(typeof(EnemyDuck), "StateChaseNavmesh", (Type[])null, (Type[])null); yield return AccessTools.DeclaredMethod(typeof(EnemyDuck), "StateChaseTowards", (Type[])null, (Type[])null); yield return AccessTools.DeclaredMethod(typeof(EnemyDuck), "RotationLogic", (Type[])null, (Type[])null); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase original) { List<CodeInstruction> code = instructions.ToList(); bool lunging = original.Name == "StateChaseTowards"; bool facing = original.Name == "RotationLogic"; for (int i = 0; i < code.Count; i++) { CodeInstruction instruction = code[i]; yield return instruction; if (lunging ? CodeInstructionExtensions.Calls(instruction, Add) : (i >= 2 && CodeInstructionExtensions.Calls(instruction, GetPosition) && CodeInstructionExtensions.Calls(code[i - 1], GetTransform) && CodeInstructionExtensions.LoadsField(code[i - 2], PlayerTarget, false))) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(facing ? OpCodes.Ldc_I4_0 : OpCodes.Ldc_I4_1, (object)null); yield return CodeInstruction.Call(typeof(DuckBarrierAim), "Redirect", (Type[])null, (Type[])null); } } } private static Vector3 Redirect(Vector3 original, EnemyDuck duck, bool canStart) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_000c: Invalid comparison between Unknown and I4 //IL_0017: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) State currentState = duck.currentState; if (currentState - 13 > 1) { return original; } PlayerAvatar val = Target.Invoke(duck); if (!Object.op_Implicit((Object)(object)val)) { return original; } return BarrierStrikeTarget(original, duck.enemy, val, canStart); } } [HarmonyPatch(typeof(EnemyElsa), "RotationLogic")] private static class ElsaBarrierAim { private static readonly FieldRef<EnemyElsa, PlayerAvatar> PlayerTarget = AccessTools.FieldRefAccess<EnemyElsa, PlayerAvatar>("playerTarget"); private static readonly MethodInfo ControllerRotation = AccessTools.DeclaredMethod(typeof(EnemyElsa), "FollowControllerRotation", (Type[])null, (Type[])null); private static readonly MethodInfo TargetRotation = AccessTools.DeclaredMethod(typeof(EnemyElsa), "FollowTargetRotation", (Type[])null, (Type[])null); private static readonly Action<EnemyElsa> FollowController = AccessTools.MethodDelegate<Action<EnemyElsa>>(ControllerRotation, (object)null, true); private static readonly Action<EnemyElsa, Vector3> FollowTarget = AccessTools.MethodDelegate<Action<EnemyElsa, Vector3>>(TargetRotation, (object)null, true); private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.Calls(instruction, ControllerRotation)) { yield return CodeInstructionExtensions.MoveBlocksFrom(CodeInstructionExtensions.MoveLabelsFrom(CodeInstruction.Call(typeof(ElsaBarrierAim), "FaceControllerOrWall", (Type[])null, (Type[])null), instruction), instruction); } else if (CodeInstructionExtensions.Calls(instruction, TargetRotation)) { yield return CodeInstructionExtensions.MoveBlocksFrom(CodeInstructionExtensions.MoveLabelsFrom(CodeInstruction.Call(typeof(ElsaBarrierAim), "FaceTargetOrWall", (Type[])null, (Type[])null), instruction), instruction); } else { yield return instruction; } } } private static bool PursuingInBigForm(EnemyElsa elsa) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_000c: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 State currentState = elsa.currentState; if (currentState - 18 <= 1 || currentState - 21 <= 1) { return true; } return false; } private static void FaceControllerOrWall(EnemyElsa elsa) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar val = PlayerTarget.Invoke(elsa); if (PursuingInBigForm(elsa) && Object.op_Implicit((Object)(object)val)) { Vector3 position = ((Component)val).transform.position; Vector3 val2 = BarrierAttackAim(position, elsa.enemy, val); if (val2 != position) { FollowTarget(elsa, val2); return; } } FollowController(elsa); } private static void FaceTargetOrWall(EnemyElsa elsa, Vector3 original) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar val = PlayerTarget.Invoke(elsa); Vector3 arg = ((PursuingInBigForm(elsa) && Object.op_Implicit((Object)(object)val)) ? BarrierAttackAim(original, elsa.enemy, val) : original); FollowTarget(elsa, arg); } } [HarmonyPatch] private static class GnomeBarrierAim { private static readonly FieldInfo AttackPosition = AccessTools.Field(typeof(EnemyGnomeDirector), "attackPosition"); private static readonly FieldInfo AttackVisionPosition = AccessTools.Field(typeof(EnemyGnomeDirector), "attackVisionPosition"); private static readonly FieldInfo ValuableOverlap = AccessTools.Field(typeof(EnemyGnome), "overlapCheckPrevious"); private static readonly FieldRef<EnemyGnomeDirector, PhysGrabObject> ValuableTarget = AccessTools.FieldRefAccess<EnemyGnomeDirector, PhysGrabObject>("valuableTarget"); private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.DeclaredMethod(typeof(EnemyGnomeDirector), "CanAttack", (Type[])null, (Type[])null); yield return AccessTools.DeclaredMethod(typeof(EnemyGnome), "RotationLogic", (Type[])null, (Type[])null); yield return AccessTools.DeclaredMethod(typeof(EnemyGnome), "AttackVisionPosition", (Type[])null, (Type[])null); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase original) { bool canStart = original.DeclaringType == typeof(EnemyGnomeDirector); foreach (CodeInstruction instruction in instructions) { yield return instruction; if (CodeInstructionExtensions.LoadsField(instruction, AttackPosition, false) || CodeInstructionExtensions.LoadsField(instruction, AttackVisionPosition, false)) { yield return new CodeInstruction(canStart ? OpCodes.Ldarg_1 : OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(canStart ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_0, (object)null); yield return CodeInstruction.Call(typeof(GnomeBarrierAim), "Redirect", (Type[])null, (Type[])null); } else if (canStart && CodeInstructionExtensions.LoadsField(instruction, ValuableOverlap, false)) { yield return new CodeInstruction(OpCodes.Ldarg_1, (object)null); yield return CodeInstruction.Call(typeof(GnomeBarrierAim), "AttackBlockedValuable", (Type[])null, (Type[])null); } } } private static Vector3 Redirect(Vector3 original, EnemyGnome gnome, bool canStart) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Invalid comparison between Unknown and I4 //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Invalid comparison between Unknown and I4 //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) EnemyGnomeDirector instance = EnemyGnomeDirector.instance; Enemy enemy = gnome.enemy; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)enemy)) { return original; } if ((int)instance.currentState == 6) { PhysGrabObject val = ValuableTarget.Invoke(instance); if (Object.op_Implicit((Object)(object)val)) { ClassModPlugin active = Active; if (active != null && active.TryGetRetainedBarrierStrike(enemy, null, out (int, CombatState) chosenShield, out BarrierMonsterTrace chosenTrace) && chosenTrace.Inside != InsideBarrier(chosenShield.Item2, ((Component)val).transform.position)) { return BarrierStrikePosition(chosenTrace, original.y); } } return original; } if ((int)instance.currentState != 5 && (canStart || (int)gnome.currentState != 9)) { return original; } PlayerAvatar val2 = GnomeChaseTarget.Invoke(instance); if (!Object.op_Implicit((Object)(object)val2)) { return original; } EnemyRigidbody val3 = (canStart ? MonsterBody.Invoke(enemy) : null); float? strikeHeight = (Object.op_Implicit((Object)(object)val3) ? new float?(((Component)val3).transform.position.y) : ((float?)null)); return BarrierStrikeTarget(original, enemy, val2, canStart, strikeHeight); } private static bool AttackBlockedValuable(bool overlapsValuable, EnemyGnome gnome) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) EnemyGnomeDirector instance = EnemyGnomeDirector.instance; if (Object.op_Implicit((Object)(object)instance) && (int)instance.currentState == 6) { ClassModPlugin active = Active; if (active != null) { PhysGrabObject val = ValuableTarget.Invoke(instance); if (!Object.op_Implicit((Object)(object)val)) { return overlapsValuable; } Vector3 position = ((Component)val).transform.position; Enemy enemy = gnome.enemy; Vector3? blockedTarget = position; if (!active.TryAimBarrierObstacle(enemy, position, out BarrierMonsterTrace chosen, null, 0f, blockedTarget)) { return overlapsValuable; } AimBarrierStrike(chosen, null, Time.unscaledTime); return true; } } return overlapsValuable; } } [HarmonyPatch(typeof(EnemyAttackStuckPhysObject), "Check")] private static class BarrierHeadObstacleBite { private static void Postfix(EnemyAttackStuckPhysObject __instance, Enemy ___Enemy, bool ___Active, bool __result) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (!__result || ___Active || !Object.op_Implicit((Object)(object)___Enemy)) { return; } ClassModPlugin active = Active; if (active != null && active.IsAuthority) { EnemyHeadController componentInChildren = ((Component)___Enemy).GetComponentInChildren<EnemyHeadController>(); EnemyVision val = StealthVision.Invoke(___Enemy); if (Object.op_Implicit((Object)(object)componentInChildren) && Object.op_Implicit((Object)(object)componentInChildren.AnimationSystem) && !HeadIdleBite.Invoke(componentInChildren.AnimationSystem) && Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.VisionTransform) && active.TryAimBarrierObstacle(___Enemy, Vector3.zero, out BarrierMonsterTrace chosen, val.VisionTransform.position, __instance.Range)) { AimBarrierStrike(chosen, null, Time.unscaledTime); componentInChildren.AnimationSystem.AttackStuckPhysObject(); } } } } [HarmonyPatch(typeof(EnemyHeadController), "Update")] private static class BarrierHeadLook { private static void Postfix(EnemyHeadController __instance, Enemy ___Enemy) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) ClassModPlugin active = Active; if (active == null || !active.IsAuthority || !Object.op_Implicit((Object)(object)___Enemy) || !Object.op_Implicit((Object)(object)__instance.LookAtTransform)) { return; } EnemyAttackStuckPhysObject val = HeadObstacleCheck.Invoke(___Enemy); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)HeadObstacleTarget.Invoke(val))) { Vector3 aim; PlayerAvatar player; if (Object.op_Implicit((Object)(object)__instance.AnimationSystem) && HeadIdleBite.Invoke(__instance.AnimationSystem) && active.TryGetRetainedBarrierStrike(___Enemy, null, out (int, CombatState) _, out BarrierMonsterTrace chosenTrace)) { aim = chosenTrace.AttackPoint; } else if (!TryHeadBarrierPursuit(___Enemy, out player, out aim)) { return; } Vector3 val2 = aim - __instance.LookAtTransform.position; if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f) { __instance.LookAtTransform.LookAt(aim); } } } } [HarmonyPatch(typeof(EnemyHeadAnimationSystem), "Update")] private static class BarrierHeadPursuitBite { private static void Prefix(EnemyHeadAnimationSystem __instance) { ClassModPlugin active = Active; if (active != null && active.IsAuthority && Object.op_Implicit((Object)(object)__instance.EnemyTriggerAttack) && !HeadIdleBite.Invoke(__instance) && TryHeadBarrierPursuit(__instance.Enemy, out PlayerAvatar player, out Vector3 aim) && active.TryGetRetainedBarrierStrike(__instance.Enemy, player, out (int, CombatState) chosenShield, out BarrierMonsterTrace _)) { Collider component = ((Component)__instance.EnemyTriggerAttack).GetComponent<Collider>(); if (Object.op_Implicit((Object)(object)component) && component.enabled && active.TryBarrierStrikePoint(chosenShield.Item2, __instance.Enemy, component, out aim, out PlayerAvatar target) && (Object)(object)target == (Object)(object)player) { HeadChaseBite.Invoke(__instance.EnemyTriggerAttack) = true; } } } } [HarmonyPatch] private static class HeadGrabberBarrierAim { private static readonly FieldRef<EnemyHeadGrabber, Enemy> HeadGrabberEnemy = AccessTools.FieldRefAccess<EnemyHeadGrabber, Enemy>("enemy"); private static readonly FieldRef<EnemyHeadGrabber, PlayerAvatar> HeadGrabberTarget = AccessTools.FieldRefAccess<EnemyHeadGrabber, PlayerAvatar>("playerTarget"); private static readonly FieldInfo TargetVelocity = AccessTools.Field(typeof(PlayerAvatar), "rbVelocityRaw"); private static readonly MethodInfo AddPosition = AccessTools.Method(typeof(Vector3), "op_Addition", new Type[2] { typeof(Vector3), typeof(Vector3) }, (Type[])null); private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.DeclaredMethod(typeof(EnemyHeadGrabber), "AttackSet", new Type[1] { typeof(Vector3) }, (Type[])null); yield return AccessTools.DeclaredMethod(typeof(EnemyHeadGrabber), "RotationLogic", (Type[])null, (Type[])null); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase original) { List<CodeInstruction> code = new List<CodeInstruction>(instructions); bool canStart = original.Name == "AttackSet"; for (int i = 0; i < code.Count; i++) { CodeInstruction instruction = code[i]; yield return instruction; bool num = canStart && instruction.opcode == OpCodes.Ldarg_1; bool flag = !canStart && i >= 3 && CodeInstructionExtensions.Calls(instruction, AddPosition) && CodeInstructionExtensions.LoadsField(code[i - 3], TargetVelocity, false); if (num || flag) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(canStart ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_0, (object)null); yield return CodeInstruction.Call(typeof(HeadGrabberBarrierAim), "Aim", (Type[])null, (Type[])null); } } } private static Vector3 Aim(Vector3 original, EnemyHeadGrabber grabber, bool canStart) { //IL_0008: 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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) bool flag = canStart; if (flag) { State currentState = grabber.currentState; bool flag2 = currentState - 10 <= 1; flag = !flag2; } if (flag) { return original; } Enemy val = HeadGrabberEnemy.Invoke(grabber); PlayerAvatar val2 = HeadGrabberTarget.Invoke(grabber); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2)) { return original; } EnemyRigidbody val3 = MonsterBody.Invoke(val); float? strikeHeight = (Object.op_Implicit((Object)(object)val3) ? new float?(((Component)val3).transform.position.y) : ((float?)null)); return BarrierStrikeTarget(original, val, val2, canStart, strikeHeight); } } [HarmonyPatch] private static class HunterBarrierShot { private static readonly MethodInfo Subtract = AccessTools.Method(typeof(Vector3), "op_Subtraction", new Type[2] { typeof(Vector3), typeof(Vector3) }, (Type[])null); private static readonly MethodInfo IsMultiplayer = AccessTools.Method(typeof(SemiFunc), "IsMultiplayer", (Type[])null, (Type[])null); private static readonly MethodInfo SetActive = AccessTools.Method(typeof(GameObject), "SetActive", (Type[])null, (Type[])null); private static readonly FieldInfo ShotCollider = AccessTools.Field(typeof(EnemyHunter), "hurtCollider"); private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.DeclaredMethod(typeof(EnemyHunter), "StateShoot", (Type[])null, (Type[])null); yield return AccessTools.DeclaredMethod(typeof(EnemyHunter), "ShootRPC", (Type[])null, (Type[])null); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase original) { List<CodeInstruction> code = instructions.ToList(); bool shooting = original.Name == "StateShoot"; for (int i = 0; i < code.Count; i++) { CodeInstruction val = code[i]; if (shooting && i + 2 < code.Count && CodeInstructionExtensions.Calls(val, Subtract) && code[i + 1].opcode == OpCodes.Stloc_0 && CodeInstructionExtensions.Calls(code[i + 2], IsMultiplayer)) { yield return CodeInstructionExtensions.MoveBlocksFrom(CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Ldarg_0, (object)null), val), val); yield return CodeInstruction.Call(typeof(HunterBarrierShot), "ShotEndpoint", (Type[])null, (Type[])null); } else if (!shooting && i >= 3 && CodeInstructionExtensions.Calls(val, SetActive) && CodeInstructionExtensions.LoadsField(code[i - 3], ShotCollider, false)) { yield return CodeInstructionExtensions.MoveBlocksFrom(CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Ldarg_0, (object)null), val), val); yield return new CodeInstruction(OpCodes.Ldarg_1, (object)null); yield return CodeInstruction.Call(typeof(HunterBarrierShot), "ActivateShotCollider", (Type[])null, (Type[])null); } else { yield return val; } } } private static Vector3 ShotEndpoint(Vector3 impact, Vector3 hitboxOffset, EnemyHunter hunter) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) ClassModPlugin active = Active; if (active != null && active.IsAuthority && TryHunterShotBarrier(active, hunter, impact, out (int, CombatState) _, out Vector3 edge)) { return edge; } return impact - hitboxOffset; } private static void ActivateShotCollider(GameObject hitbox, bool enabled, EnemyHunter hunter, Vector3 impact) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (enabled) { ClassModPlugin active = Active; if (active != null && TryHunterShotBarrier(active, hunter, impact, out (int, CombatState) barrier, out Vector3 edge)) { hitbox.SetActive(false); active.TryApplyBarrierStrike(barrier, hunter.enemy, hunter.hurtCollider.playerDamage, edge); return; } } hitbox.SetActive(enabled); } private static bool TryHunterShotBarrier(ClassModPlugin mod, EnemyHunter hunter, Vector3 impact, out (int Actor, CombatState Shield) barrier, out Vector3 edge) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) barrier = default((int, CombatState)); edge = default(Vector3); if (!Object.op_Implicit((Object)(object)hunter.gunAimTransform)) { return false; } Vector3 position = hunter.gunAimTransform.position; Enemy enemy = hunter.enemy; if (!Object.op_Implicit((Object)(object)enemy) || !Object.op_Implicit((Object)(object)enemy.CenterTransform) || !mod.TryBarrierSegment(enemy.CenterTransform.position, position, out barrier, out edge)) { return mod.TryBarrierSegment(position, impact, out barrier, out edge); } return true; } } [HarmonyPatch(typeof(EnemyOogly), "FindPlayerToAttack")] private static class OoglyLightTargets { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { MethodInfo query = AccessTools.Method(typeof(SemiFunc), "PlayerGetAllPlayerAvatarWithinRangeAndVision", new Type[3] { typeof(float), typeof(Vector3), typeof(PhysGrabObject) }, (Type[])null); foreach (CodeInstruction instruction in instructions) { yield return instruction; if (CodeInstructionExtensions.Calls(instruction, query)) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(EnemyOogly), "enemy")); yield return CodeInstruction.Call(typeof(OoglyLightTargets), "Filter", (Type[])null, (Type[])null); } } } private static List<PlayerAvatar> Filter(List<PlayerAvatar> players, Enemy enemy) { ClassModPlugin mod = Active; if ((Object)(object)mod != (Object)null) { players.RemoveAll((PlayerAvatar player) => mod.Cloaked(player) || mod.SeparatedByBarrier(enemy, player)); } return players; } } [HarmonyPatch] private static class MonsterDirectDamageProtection { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(EnemyCeilingEye), "StateHasTarget", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemyTick), "Suck", (Type[])null, (Type[])null); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase original) { MethodInfo hurt = AccessTools.Method(typeof(PlayerHealth), "HurtOther", (Type[])null, (Type[])null); FieldInfo enemy = AccessTools.Field(original.DeclaringType, "enemy"); foreach (CodeInstruction instruction in instructions) { if (!CodeInstructionExtensions.Calls(instruction, hurt)) { yield return instruction; continue; } yield return CodeInstructionExtensions.MoveBlocksFrom(CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Ldarg_0, (object)null), instruction), instruction); yield return new CodeInstruction(OpCodes.Ldfld, (object)enemy); yield return CodeInstruction.Call(typeof(MonsterDirectDamageProtection), "Hurt", (Type[])null, (Type[])null); } } private static void Hurt(PlayerHealth health, int damage, Vector3 point, bool savingGrace, int enemyIndex, bool ignoreInvincibility, Enemy enemy) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!BarrierBlocks(enemy, HealthOwner.Invoke(health))) { health.HurtOther(damage, point, savingGrace, enemyIndex, ignoreInvincibility); } } } [HarmonyPatch] private static class MonsterTargetEffectsProtection { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(EnemyThinMan), "StateDamageFixed", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemySpinny), "Update", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemySnatcher), "PlayerTumbleForce", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnemySnatcher), "PlayerReleaseImpulseApply", (Type[])null, (Type[])null); } private static bool Prefix(Enemy ___enemy, PlayerAvatar ___playerTarget) { return !BarrierBlocks(___enemy, ___playerTarget); } } [HarmonyPatch(typeof(EnemyUpscreamAnim), "AttackImpulse")] private static class MonsterScreamProtection { private static readonly FieldRef<EnemyUpscream, PlayerAvatar> Target = AccessTools.FieldRefAccess<EnemyUpscream, PlayerAvatar>("targetPlayer"); private static bool Prefix(EnemyUpscreamAnim __instance) { if (Object.op_Implicit((Object)(object)__instance.controller)) { ClassModPlugin active = Active; if (active != null) { PlayerAvatar player = Target.Invoke(__instance.controller); if (!active.SeparatedByBarrier(__instance.enemy, player)) { return true; } active.HitBarrierWithScream(__instance.enemy, player); return false; } } return true; } } [HarmonyPatch] private static class MonsterLiftProtection { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(FloaterAttackLogic), "StateLevitate", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(FloaterAttackLogic), "StateLevitateFixed", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(FloaterAttackLogic), "StateStop", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(FloaterAttackLogic), "StateStopFixed", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(FloaterAttackLogic), "StateSmash", (Type[])null, (Type[])null); } private static void Prefix(FloaterAttackLogic __instance, List<PlayerAvatar> ___capturedPlayerAvatars, List<PhysGrabObject> ___capturedPhysGrabObjects) { ClassModPlugin mod = Active; if (mod != null && Object.op_Implicit((Object)(object)__instance.controller) && mod.HasActiveBarrier()) { Enemy enemy = __instance.controller.enemy; ___capturedPlayerAvatars.RemoveAll((PlayerAvatar player) => mod.SeparatedByBarrier(enemy, player)); PlayerTumble val = default(PlayerTumble); ___capturedPhysGrabObjects.RemoveAll((PhysGrabObject item) => Object.op_Implicit((Object)(object)item) && ((Component)item).TryGetComponent<PlayerTumble>(ref val) && mod.SeparatedByBarrier(enemy, TumblePlayer.Invoke(val))); } } } [HarmonyPatch(typeof(EnemyHeartHugger), "PlayerIsOnCooldown")] private static class MonsterGasContactProtection { private static void Postfix(Enemy ___enemy, PlayerAvatar __0, ref bool __result) { __result |= BarrierBlocks(___enemy, __0) || IsStealthTarget(__0); } } [HarmonyPatch(typeof(EnemyHeartHugger), "PlayerInGas")] private static class MonsterGasStatusProtection { private static bool Prefix(Enemy ___enemy, PlayerAvatar __0) { if (!BarrierBlocks(___enemy, __0)) { return !IsStealthTarget(__0); } return false; } } [HarmonyPatch(typeof(EnemyHeartHuggerGasGuider), "Update")] private static class MonsterGasReleaseProtection { private static bool Prefix(EnemyHeartHuggerGasGuider __instance, EnemyHeartHugger ___enemyHeartHugger, PlayerAvatar ___player) { if (!Object.op_Implicit((Object)(object)___enemyHeartHugger) || !BarrierBlocks(GasEnemy.Invoke(___enemyHeartHugger), ___player)) { return true; } ClassModPlugin? active = Active; if (active != null && active.IsAuthority) { ___enemyHeartHugger.RemovePlayerFromGas(___player); Object.Destroy((Object)(object)((Component)__instance).gameObject); } return false; } } private readonly struct BarrierWall { private readonly Vector3 center; private readonly Vector3 across; private readonly Vector3 up; private readonly Vector3 normal; private readonly float halfWidth; private readonly float halfHeight; internal BarrierWall(Vector3 bottomLeft, Vector3 bottomRight, Vector3 topLeft) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) Vector3 val = bottomRight - bottomLeft; Vector3 val2 = topLeft - bottomLeft; across = ((Vector3)(ref val)).normalized; up = ((Vector3)(ref val2)).normalized; Vector3 val3 = Vector3.Cross(across, up); normal = ((Vector3)(ref val3)).normalized; halfWidth = ((Vector3)(ref val)).magnitude * 0.5f; halfHeight = ((Vector3)(ref val2)).magnitude * 0.5f; center = bottomLeft + (val + val2) * 0.5f; } internal bool Sweep(Vector3 previous, Vector3 previousRoot, Vector3 current, Vector3 extents, out float time, out Vector3 push, out Vector3 point, float clearance = 0.12f) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) time = 0f; push = (point = default(Vector3)); Vector3 val = previous - center; Vector3 val2 = current - previous; float num = Vector3.Dot(val, normal); float num2 = Vector3.Dot(val2, normal); float num3 = ProjectExtents(extents, normal) + clearance; float num4 = ((((Mathf.Abs(num) < num3) ? Vector3.Dot(previousRoot - center, normal) : num) >= 0f) ? 1f : (-1f)); float num5 = num3 - (num + num2) * num4; if (num5 <= 0f) { return false; } float end = 1f; if (!ClipBarrierInterval(num, num2, num3, ref time, ref end) || !ClipBarrierInterval(Vector3.Dot(val, across), Vector3.Dot(val2, across), halfWidth + ProjectExtents(extents, across), ref time, ref end) || !ClipBarrierInterval(Vector3.Dot(val, up), Vector3.Dot(val2, up), halfHeight + ProjectExtents(extents, up), ref time, ref end)) { return false; } point = ClosestPoint(previous + val2 * time); push = normal * (num4 * (num5 + 0.006f)); return true; } internal Vector3 ClosestPoint(Vector3 point) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = point - center; return center + across * Mathf.Clamp(Vector3.Dot(val, across), 0f - halfWidth, halfWidth) + up * Mathf.Clamp(Vector3.Dot(val, up), 0f - halfHeight, halfHeight); } internal bool RayIntersection(Vector3 origin, Vector3 direction, out float distance) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) distance = 0f; float num = Vector3.Dot(direction, normal); if (Mathf.Abs(num) < 1E-05f) { return false; } distance = Vector3.Dot(center - origin, normal) / num; if (distance < 0f) { return false; } Vector3 val = origin + direction * distance - center; if (Mathf.Abs(Vector3.Dot(val, across)) <= halfWidth + 0.006f) { return Mathf.Abs(Vector3.Dot(val, up)) <= halfHeight + 0.006f; } return false; } private static float ProjectExtents(Vector3 extents, Vector3 axis) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) return extents.x * Mathf.Abs(axis.x) + extents.y * Mathf.Abs(axis.y) + extents.z * Mathf.Abs(axis.z); } } private sealed class BarrierMonsterTrace { internal readonly Collider[] Colliders; internal Vector3 Root; internal Vector3 Body; internal Vector3 Center; internal Vector3 Size; internal bool Inside; internal bool Ready; internal float LastBlocked = float.NegativeInfinity; internal float LastObstruction = float.NegativeInfinity; internal BarrierWall ObstructionWall; internal Vector3 ObstructionPoint; internal BarrierWall AttackWall; internal Vector3 AttackPoint; internal PlayerAvatar? AttackPlayer; internal float AttackUntil; internal BarrierMonsterTrace(Enemy enemy) { Colliders = ((Component)enemy).GetComponentsInChildren<Collider>(true); } } private sealed class BarrierRuntime { internal readonly Dictionary<Enemy, BarrierMonsterTrace> Monsters = new Dictionary<Enemy, BarrierMonsterTrace>(); internal readonly ConditionalWeakTable<Enemy, HitCycle> Attackers = new ConditionalWeakTable<Enemy, HitCycle>(); internal float NextContact; } private static class SnatcherBarrierPunch { private sealed class Strike { internal readonly (int Actor, CombatState Shield) Barrier; internal readonly BarrierMonsterTrace Trace; internal readonly PlayerAvatar Target; internal Vector3? Contact; internal bool Hit; internal Strike((int Actor, CombatState Shield) barrier, BarrierMonsterTrace trace, PlayerAvatar target) { Barrier = barrier; Trace = trace; Target = target; } } [HarmonyPatch(typeof(EnemySnatcher), "FrontPunchTry")] private static class Start { private static void Prefix(EnemySnatcher __instance, out bool __state) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 __state = (int)__instance.currentState == 6; } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> code = new List<CodeInstruction>(instructions); for (int i = 0; i < code.Count; i++) { CodeInstruction instruction = code[i]; yield return instruction; if (CodeInstructionExtensions.Calls(instruction, PlayerVisible)) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return CodeInstruction.Call(typeof(SnatcherBarrierPunch), "PunchCanSee", (Type[])null, (Type[])null); } else if (CodeInstructionExtensions.Calls(instruction, TargetPosition) || CodeInstructionExtensions.LoadsField(instruction, NavmeshPosition, false) || ReadsTargetPosition(code, i)) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return CodeInstruction.Call(typeof(SnatcherBarrierPunch), "AimDuringCheck", (Type[])null, (Type[])null); } } } private static void Postfix(EnemySnatcher __instance, bool __result, bool __state) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 if (!__result || (int)__instance.currentState != 44) { return; } Strikes.Remove(__instance); PlayerAvatar val = Target.Invoke(__instance); if (__state && Alive(val)) { ClassModPlugin active = Active; if (active != null && !active.Cloaked(val) && active.TryGetRetainedBarrierStrike(__instance.enemy, val, out (int, CombatState) chosenShield, out BarrierMonsterTrace chosenTrace)) { Strikes.Add(__instance, new Strike(chosenShield, chosenTrace, val)); } } } } [HarmonyPatch] private static class Aim { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.DeclaredMethod(typeof(EnemySnatcher), "RotationTrackPlayer", (Type[])null, (Type[])null); yield return AccessTools.DeclaredMethod(typeof(EnemySnatcher), "StateFrontPunch", (Type[])null, (Type[])null); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase original) { List<CodeInstruction> code = new List<CodeInstruction>(instructions); bool rotation = original.Name == "RotationTrackPlayer"; for (int i = 0; i < code.Count; i++) { CodeInstruction instruction = code[i]; yield return instruction; if (!(rotation ? (!ReadsTargetPosition(code, i)) : (!CodeInstructionExtensions.Calls(instruction, TargetPosition)))) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return CodeInstruction.Call(typeof(SnatcherBarrierPunch), "AimDuringPunch", (Type[])null, (Type[])null); } } } } [HarmonyPatch(typeof(EnemySnatcher), "FrontPunchHurtTick")] private static class Contact { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { string replacement = (CodeInstructionExtensions.Calls(instruction, Overlap) ? "ObserveSweep" : (CodeInstructionExtensions.Calls(instruction, AlreadyHit) ? "SkipVictim" : null)); if (replacement == null) { yield return instruction; continue; } yield return CodeInstructionExtensions.MoveBlocksFrom(CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Ldarg_0, (object)null), instruction), instruction); yield return CodeInstruction.Call(typeof(SnatcherBarrierPunch), replacement, (Type[])null, (Type[])null); } } private static void Postfix(EnemySnatcher __instance) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if (!Strikes.TryGetValue(__instance, out Strike value)) { return; } Vector3? contact = value.Contact; if (!contact.HasValue) { return; } Vector3 valueOrDefault = contact.GetValueOrDefault(); value.Contact = null; ClassModPlugin active = Active; if (active == null || !active.IsAuthority || !IsActiveBarrier(value.Barrier.Shield)) { return; } BarrierRuntime barrierRuntime = value.Barrier.Shield.BarrierRuntime; if (barrierRuntime != null && __instance.frontPunchDamage > 0) { HitCycle orCreateValue = barrierRuntime.Attackers.GetOrCreateValue(__instance.enemy); double now = active.Now; if (!(now < orCreateValue.Next)) { value.Hit = true; active.ApplyBarrierStrike(value.Barrier.Actor, value.Barrier.Shield, orCreateValue, __instance.frontPunchDamage, exempt: false, valueOrDefault, now); } } } } private static readonly ConditionalWeakTable<EnemySnatcher, Strike> Strikes = new ConditionalWeakTable<EnemySnatcher, Strike>(); private static readonly FieldRef<EnemySnatcher, PlayerAvatar> Target = AccessTools.FieldRefAccess<EnemySnatcher, PlayerAvatar>("playerTarget"); private static readonly FieldInfo TargetField = AccessTools.DeclaredField(typeof(EnemySnatcher), "playerTarget"); private static readonly FieldInfo NavmeshPosition = AccessTools.Field(typeof(PlayerAvatar), "LastNavmeshPosition"); private static readonly MethodInfo PlayerVisible = AccessTools.DeclaredMethod(typeof(EnemySnatcher), "PlayerVisible", (Type[])null, (Type[])null); private static readonly MethodInfo TargetPosition = AccessTools.DeclaredMethod(typeof(EnemySnatcher), "PlayerTargetPosition", (Type[])null, (Type[])null); private static readonly MethodInfo GetTransform = AccessTools.PropertyGetter(typeof(Component), "transform"); private static readonly MethodInfo GetPosition = AccessTools.PropertyGetter(typeof(Transform), "position"); private static readonly MethodInfo Overlap = AccessTools.Method(typeof(Physics), "OverlapCapsuleNonAlloc", new Type[6] { typeof(Vector3), typeof(Vector3), typeof(float), typeof(Collider[]), typeof(int), typeof(QueryTriggerInteraction) }, (Type[])null); private static readonly MethodInfo AlreadyHit = AccessTools.Method(typeof(HashSet<PlayerAvatar>), "Contains", (Type[])null, (Type[])null); private static bool ReadsTargetPosition(List<CodeInstruction> code, int i) { if (i >= 3 && CodeInstructionExtensions.Calls(code[i], GetPosition) && CodeInstructionExtensions.Calls(code[i - 1], GetTransform)) { return CodeInstructionExtensions.LoadsField(code[i - 2], TargetField, false); } return false; } private static bool PunchCanSee(bool playerVisible, EnemySnatcher snatcher) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (!playerVisible && (int)snatcher.currentState == 6) { ClassModPlugin active = Active; if (active != null) {