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 EliteEnemyVariants v4.0.0
EliteEnemyVariants.dll
Decompiled 5 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.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.SceneManagement; using UnityEngine.UI; [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("REPOJP")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("4.0.0.0")] [assembly: AssemblyInformationalVersion("4.0.0")] [assembly: AssemblyProduct("EliteEnemyVariants")] [assembly: AssemblyTitle("EliteEnemyVariants")] [assembly: AssemblyVersion("4.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 REPOJP.EliteEnemyVariants { internal static class AdapterPatchValidator { internal static void Validate(EliteArchetype archetype) { switch (archetype) { case EliteArchetype.Animal: Fields(typeof(EnemyAnimal), "currentState", "stateTimer", "havocTimer", "playerTarget"); Methods(typeof(EnemyAnimal), "UpdateState"); break; case EliteArchetype.BirthdayBoy: Fields(typeof(EnemyBirthdayBoy), "currentState", "stateTimer", "secondStateTimer", "photonView", "balloons"); Methods(typeof(EnemyBirthdayBoy), "CheckForPoppedBalloons", "UpdatePlayerTarget", "UpdateState"); break; case EliteArchetype.CleanupCrew: Fields(typeof(EnemyBombThrower), "currentState", "stateTimer", "headCooldown", "headAttackCooldown", "meleeCooldown", "playerTarget"); Methods(typeof(EnemyBombThrower), "UpdateState"); break; case EliteArchetype.Bowtie: Fields(typeof(EnemyBowtie), "currentState", "stateTimer", "attacks"); Methods(typeof(EnemyBowtie), "UpdateState"); break; case EliteArchetype.Peeper: Fields(typeof(EnemyCeilingEye), "currentState", "eyeDamageWaitTimer", "eyeDamageTimer", "targetPlayer", "photonView"); Methods(typeof(EnemyCeilingEye), "UpdateState", "TargetPlayerRPC"); break; case EliteArchetype.ApexPredator: Fields(typeof(EnemyDuck), "currentState", "stateTimer", "chaseTimer", "playerTarget"); Methods(typeof(EnemyDuck), "UpdateState"); break; case EliteArchetype.Elsa: Fields(typeof(EnemyElsa), "currentState", "stateTimer", "angryTimer", "chaseTimer", "playerTarget", "photonView"); Methods(typeof(EnemyElsa), "UpdateState", "UpdatePlayerTargetRPC"); break; case EliteArchetype.Mentalist: Fields(typeof(EnemyFloater), "currentState", "stateTimer", "attackCount"); Methods(typeof(EnemyFloater), "UpdateState"); break; case EliteArchetype.Headman: Fields(typeof(Enemy), "CurrentState", "DisableChaseTimer"); Fields(typeof(EnemyStateChase), "StateTimer"); break; case EliteArchetype.Headgrab: Fields(typeof(EnemyHeadGrabber), "currentState", "stateTimer", "attackCooldown", "headTargetCooldown", "attacksInRow", "headTargetActive"); break; case EliteArchetype.HeartHugger: Fields(typeof(EnemyHeartHugger), "currentState", "stateTimer", "attacksInARow"); Methods(typeof(EnemyHeartHugger), "StateSet", "LeaveStart"); break; case EliteArchetype.Hidden: Fields(typeof(EnemyHidden), "currentState", "stateTimer", "maxMoveTimer", "agentDestination"); break; case EliteArchetype.Oogly: Fields(typeof(EnemyOogly), "currentState", "stateTimer", "attackCooldownTimer", "targetPlayer", "roamDestination", "currentRoamTarget", "headWorldTargetRotation"); Methods(typeof(EnemyOogly), "StateSet", "InitializeFlightSystem", "SetHeadTargetRotation"); break; case EliteArchetype.Robe: Fields(typeof(EnemyRobe), "currentState", "idleBreakTimer", "chaseTime", "targetPlayer", "isOnScreen"); Methods(typeof(EnemyRobe), "UpdateState", "MoveTowardPlayer"); break; case EliteArchetype.Reaper: Fields(typeof(EnemyRunner), "currentState", "stateTimer", "targetPlayer", "stateImpulse", "targetPosition", "agentSpeedCurrent"); Methods(typeof(EnemyRunner), "UpdateState", "StateAttackPlayer", "OnVision", "RotationLogic"); break; case EliteArchetype.Loom: Fields(typeof(EnemyShadow), "currentState", "stateTimer", "playerTarget"); Methods(typeof(EnemyShadow), "UpdatePlayerTarget", "StateChooseTarget"); break; case EliteArchetype.Spewer: Fields(typeof(EnemySlowMouth), "currentState", "stateTimer", "idlePukeCooldown", "possessCooldown", "attachedTimer"); Methods(typeof(EnemySlowMouth), "OnVision", "UpdatePlayerTarget"); break; case EliteArchetype.Trudge: Fields(typeof(EnemySlowWalker), "currentState", "stateTimer", "targetPlayer"); Methods(typeof(EnemySlowWalker), "UpdateState"); break; case EliteArchetype.Tick: Fields(typeof(EnemyTick), "currentState", "stateTimer", "suckTimer"); break; case EliteArchetype.Bella: Fields(typeof(EnemyTricycle), "currentState", "stateTimer", "attackCooldown"); Methods(typeof(EnemyTricycle), "SetState"); break; case EliteArchetype.Chef: Fields(typeof(EnemyTumbler), "currentState", "stateTimer", "roamWaitTimer", "targetPlayer"); Methods(typeof(EnemyTumbler), "UpdateState"); break; case EliteArchetype.Upscream: Fields(typeof(EnemyUpscream), "currentState", "stateTimer", "roamWaitTimer", "attacks", "targetPlayer"); Methods(typeof(EnemyUpscream), "UpdateState"); break; case EliteArchetype.Rugrat: Fields(typeof(EnemyValuableThrower), "currentState", "stateTimer", "attacks", "playerTarget", "valuableTarget"); Methods(typeof(EnemyValuableThrower), "UpdateState", "StateGetValuable", "StateGoToTarget"); Methods(typeof(EnemyJump), "StuckTrigger"); Methods(typeof(SemiFunc), "EnemyCartJump"); break; case EliteArchetype.Clown: Fields(typeof(EnemyBeamer), "aimHorizontalTarget", "aimHorizontalResult", "laserRange", "aimVerticalTarget"); Methods(typeof(EnemyBeamer), "RotationLogic", "VerticalAimLogic"); break; case EliteArchetype.ShadowChild: Fields(typeof(EnemyThinMan), "enemy", "playerTarget", "teleportPosition"); Methods(typeof(EnemyThinMan), "UpdateState", "SetTarget"); break; case EliteArchetype.Huntsman: Fields(typeof(EnemyHunter), "investigatePoint", "investigateAimHorizontal", "investigateAimVertical"); Methods(typeof(EnemyHunter), "AimLogic", "ShootRPC"); Methods(typeof(EnemyDirector), "SetInvestigate"); break; case EliteArchetype.Gambit: Fields(typeof(EnemySpinny), "reachedPoint"); Methods(typeof(EnemySpinny), "UpdateState", "JumpIfStuck", "RouletteGoingOn"); Methods(typeof(EnemyStateStunned), "Set"); break; case EliteArchetype.Banger: Methods(typeof(EnemyBang), "FuseLogic", "UpdateState", "ExplodeRPC"); break; case EliteArchetype.Gnome: Fields(typeof(EnemyGnome), "attackAngle"); Fields(typeof(EnemyGnomeDirector), "stateImpulse", "playerTarget", "valuableTarget"); Methods(typeof(EnemyGnome), "UpdateState", "StateNoticeDelay", "AttackPositionLogic", "StateAttackDone"); Methods(typeof(EnemyGnomeDirector), "UpdateState", "CanAttack", "StateAttackSet"); break; } Type type = archetype switch { EliteArchetype.Animal => typeof(EnemyAnimal), EliteArchetype.BirthdayBoy => typeof(EnemyBirthdayBoy), EliteArchetype.CleanupCrew => typeof(EnemyBombThrower), EliteArchetype.Bowtie => typeof(EnemyBowtie), EliteArchetype.Peeper => typeof(EnemyCeilingEye), EliteArchetype.ApexPredator => typeof(EnemyDuck), EliteArchetype.Elsa => typeof(EnemyElsa), EliteArchetype.Mentalist => typeof(EnemyFloater), EliteArchetype.Headman => typeof(Enemy), EliteArchetype.Headgrab => typeof(EnemyHeadGrabber), EliteArchetype.HeartHugger => typeof(EnemyHeartHugger), EliteArchetype.Hidden => typeof(EnemyHidden), EliteArchetype.Oogly => typeof(EnemyOogly), EliteArchetype.Robe => typeof(EnemyRobe), EliteArchetype.Reaper => typeof(EnemyRunner), EliteArchetype.Loom => typeof(EnemyShadow), EliteArchetype.Spewer => typeof(EnemySlowMouth), EliteArchetype.Trudge => typeof(EnemySlowWalker), EliteArchetype.Tick => typeof(EnemyTick), EliteArchetype.Bella => typeof(EnemyTricycle), EliteArchetype.Chef => typeof(EnemyTumbler), EliteArchetype.Upscream => typeof(EnemyUpscream), EliteArchetype.Rugrat => typeof(EnemyValuableThrower), _ => null, }; if (type != null) { Methods(type, "Update"); } } private static void Fields(Type type, params string[] names) { foreach (string text in names) { if (AccessTools.Field(type, text) == null) { throw new MissingFieldException(type.FullName, text); } } } private static void Methods(Type type, params string[] names) { foreach (string text in names) { if (AccessTools.Method(type, text, (Type[])null, (Type[])null) == null) { throw new MissingMethodException(type.FullName, text); } } } } [HarmonyPatch] internal static class BangerElitePatches { private static readonly Action<EnemyBang, State> UpdateState = AccessTools.MethodDelegate<Action<EnemyBang, State>>(AccessTools.Method(typeof(EnemyBang), "UpdateState", (Type[])null, (Type[])null), (object)null, true); internal static void OnSpawn(EliteState state) { state.AdapterState = new BangerRuntimeState(); } internal static void Tick(EliteState state) { } [HarmonyPrefix] [HarmonyPatch(typeof(EnemyBang), "FuseLogic")] private static bool FuseLogicPrefix(EnemyBang __instance) { //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) if (!EliteRegistry.TryGet((Component?)(object)__instance, out EliteState state)) { return true; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { return true; } if (!GameFieldAccess.BangFuseActive(__instance)) { GetRuntime(state).PreviousFuseActive = false; return false; } EliteEnemyConfig settings = EliteEnemyVariantsPlugin.Instance.Settings; BangerRuntimeState runtime = GetRuntime(state); if (!runtime.PreviousFuseActive) { runtime.PreviousFuseActive = true; runtime.FuseStartedAt = Time.time; runtime.LastSyncAt = float.NegativeInfinity; } if (!EnemyBangDirector.instance.debugNoFuseProgress) { float num = Mathf.Max(0.5f, settings.BangerFuseSeconds.Value); if (HasNearVisibleTarget(state, settings.BangerNearTargetDistance.Value)) { num = Mathf.Min(num, Mathf.Max(0.5f, settings.BangerNearTargetFuseSeconds.Value)); } GameFieldAccess.SetBangFuseLerp(__instance, GameFieldAccess.BangFuseLerp(__instance) + Time.deltaTime / num); } GameFieldAccess.SetBangFuseLerp(__instance, Mathf.Clamp01(GameFieldAccess.BangFuseLerp(__instance))); if (GameManager.Multiplayer() && Time.time >= runtime.LastSyncAt + settings.BangerFuseSyncIntervalSeconds.Value) { runtime.LastSyncAt = Time.time; GameFieldAccess.BangPhotonView(__instance).RPC("FuseRPC", (RpcTarget)1, new object[2] { true, GameFieldAccess.BangFuseLerp(__instance) }); } if (GameFieldAccess.BangFuseLerp(__instance) < 1f) { return false; } if (GameManager.Multiplayer()) { GameFieldAccess.BangPhotonView(__instance).RPC("ExplodeRPC", (RpcTarget)0, Array.Empty<object>()); } else { AccessTools.Method(typeof(EnemyBang), "ExplodeRPC", (Type[])null, (Type[])null).Invoke(__instance, new object[1] { (object)default(PhotonMessageInfo) }); } UpdateState(__instance, (State)11); GameFieldAccess.Parent(GameFieldAccess.BangEnemy(__instance)).Despawn(); runtime.PreviousFuseActive = false; return false; } private static bool HasNearVisibleTarget(EliteState state, float maxDistance) { //IL_00c9: 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_0063: 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_00e4: 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) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar val = GameFieldAccess.TargetPlayer(state.Enemy); if ((Object)(object)val == (Object)null || GameFieldAccess.PlayerDisabled(val)) { float num = float.MaxValue; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (!((Object)(object)item == (Object)null) && !GameFieldAccess.PlayerDisabled(item)) { float num2 = Vector3.Distance(state.Enemy.CenterTransform.position, ((Component)item).transform.position); if (num2 < num) { num = num2; val = item; } } } } if ((Object)(object)val == (Object)null) { return false; } PlayerVisionTarget playerVisionTarget = val.PlayerVisionTarget; Vector3? obj; if (playerVisionTarget == null) { obj = null; } else { Transform visionTransform = playerVisionTarget.VisionTransform; obj = ((visionTransform != null) ? new Vector3?(visionTransform.position) : ((Vector3?)null)); } Vector3 val2 = (Vector3)(((??)obj) ?? ((Component)val).transform.position) - state.Enemy.CenterTransform.position; if (((Vector3)(ref val2)).magnitude > maxDistance) { return false; } return !Physics.Raycast(state.Enemy.CenterTransform.position, ((Vector3)(ref val2)).normalized, ((Vector3)(ref val2)).magnitude, LayerMask.op_Implicit(GameFieldAccess.VisionMask(state.Enemy)), (QueryTriggerInteraction)1); } private static BangerRuntimeState GetRuntime(EliteState state) { BangerRuntimeState bangerRuntimeState = state.AdapterState as BangerRuntimeState; if (bangerRuntimeState == null) { bangerRuntimeState = (BangerRuntimeState)(state.AdapterState = new BangerRuntimeState()); } return bangerRuntimeState; } } [HarmonyPatch] internal static class ClownElitePatches { private static readonly FieldRef<EnemyBeamer, Quaternion> AimHorizontalTarget = AccessTools.FieldRefAccess<EnemyBeamer, Quaternion>("aimHorizontalTarget"); private static readonly FieldRef<EnemyBeamer, float> AimHorizontalResult = AccessTools.FieldRefAccess<EnemyBeamer, float>("aimHorizontalResult"); private static readonly FieldRef<EnemyBeamer, float> LaserRange = AccessTools.FieldRefAccess<EnemyBeamer, float>("laserRange"); private static readonly FieldRef<EnemyBeamer, Quaternion> AimVerticalTarget = AccessTools.FieldRefAccess<EnemyBeamer, Quaternion>("aimVerticalTarget"); internal static void OnSpawn(EliteState state) { state.AdapterState = new ClownRuntimeState(); } internal static void Tick(EliteState state) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Invalid comparison between Unknown and I4 //IL_00af: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Invalid comparison between Unknown and I4 //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Invalid comparison between Unknown and I4 //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Invalid comparison between Unknown and I4 //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) EnemyBeamer component = ((Component)state.Enemy).GetComponent<EnemyBeamer>(); if ((Object)(object)component == (Object)null) { return; } State currentState = component.currentState; bool flag = currentState - 4 <= 2; ClownRuntimeState runtime = GetRuntime(state); if (!flag) { runtime.AttackInitialized = false; runtime.TargetSwitched = false; runtime.SpinChecked = false; runtime.Spinning = false; return; } EliteEnemyConfig settings = EliteEnemyVariantsPlugin.Instance.Settings; LaserRange.Invoke(component) = settings.ClownBeamRange.Value; PlayerAvatar val = GameFieldAccess.BeamerTarget(component); if ((Object)(object)val != (Object)null) { runtime.LastTargetPosition = (((Object)(object)val.PlayerVisionTarget != (Object)null && (Object)(object)val.PlayerVisionTarget.VisionTransform != (Object)null) ? val.PlayerVisionTarget.VisionTransform.position : ((Component)val).transform.position); } if ((int)component.currentState == 5 && !runtime.AttackInitialized) { runtime.AttackInitialized = true; float value = settings.ClownBeamDurationMin.Value; float value2 = settings.ClownBeamDurationMax.Value; component.stateTimer = Mathf.Lerp(value, value2, StableUnit(state.Key, 17)); } if (settings.ClownWalkWhileAttacking.Value && (Object)(object)val != (Object)null) { EnemyNavMeshAgent val2 = GameFieldAccess.NavMeshAgent(state.Enemy); val2.Stop(0f); val2.SetDestination(((Component)val).transform.position); val2.OverrideAgent(GameFieldAccess.NavDefaultSpeed(val2), GameFieldAccess.NavDefaultAcceleration(val2), 0.1f); } if (settings.ClownTargetSwitch.Value && (int)component.currentState == 5 && !runtime.TargetSwitched && TryFindAlternateTarget(component, LaserRange.Invoke(component), out PlayerAvatar result)) { runtime.TargetSwitched = true; GameFieldAccess.SetBeamerTarget(component, result); state.Enemy.SetChaseTarget(result); if (GameManager.Multiplayer()) { GameFieldAccess.BeamerPhotonView(component).RPC("UpdatePlayerTargetRPC", (RpcTarget)1, new object[1] { result.photonView.ViewID }); } } if (!runtime.SpinChecked && (int)component.currentState == 5) { runtime.SpinChecked = true; float value3 = settings.ClownSpinChancePercent.Value; runtime.Spinning = StableUnit(state.Key, 41) * 100f < value3; runtime.SpinRemaining = (runtime.Spinning ? 180f : 0f); runtime.SpinYaw = ((Component)component).transform.eulerAngles.y; } if ((int)component.currentState == 5 && (Object)(object)GameFieldAccess.BeamerTarget(component) == (Object)null && runtime.LastTargetPosition != Vector3.zero && !runtime.Spinning) { runtime.Spinning = true; runtime.SpinRemaining = 180f; runtime.SpinYaw = ((Component)component).transform.eulerAngles.y; } } [HarmonyPrefix] [HarmonyPatch(typeof(EnemyBeamer), "RotationLogic")] private static void RotationLogicPrefix(EnemyBeamer __instance) { //IL_000c: 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: 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_0018: Invalid comparison between Unknown and I4 //IL_003f: 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_00aa: 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_0095: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) if (!EliteRegistry.TryGet((Component?)(object)__instance, out EliteState state)) { return; } State currentState = __instance.currentState; if (currentState - 4 > 2) { return; } ClownRuntimeState runtime = GetRuntime(state); PlayerAvatar val = GameFieldAccess.BeamerTarget(__instance); ? val2; if (!((Object)(object)val != (Object)null)) { val2 = runtime.LastTargetPosition; } else { PlayerVisionTarget playerVisionTarget = val.PlayerVisionTarget; Vector3? obj; if (playerVisionTarget == null) { obj = null; } else { Transform visionTransform = playerVisionTarget.VisionTransform; obj = ((visionTransform != null) ? new Vector3?(visionTransform.position) : ((Vector3?)null)); } val2 = ((??)obj) ?? ((Component)val).transform.position; } Vector3 val3 = (Vector3)val2 - __instance.bottomTransform.position; if (((Vector3)(ref val3)).sqrMagnitude > 0.001f && !runtime.Spinning) { Quaternion val4 = Quaternion.LookRotation(val3); AimHorizontalTarget.Invoke(__instance) = Quaternion.Euler(0f, ((Quaternion)(ref val4)).eulerAngles.y, 0f); AimHorizontalResult.Invoke(__instance) = 0f; } __instance.horizontalRotationSpring.speed = EliteEnemyVariantsPlugin.Instance.Settings.ClownTrackSpeed.Value; } [HarmonyPostfix] [HarmonyPatch(typeof(EnemyBeamer), "RotationLogic")] private static void RotationLogicPostfix(EnemyBeamer __instance) { //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0083: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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) if (!EliteRegistry.TryGet((Component?)(object)__instance, out EliteState state)) { return; } ClownRuntimeState runtime = GetRuntime(state); if (!runtime.Spinning || runtime.SpinRemaining <= 0f) { PlayerAvatar val = GameFieldAccess.BeamerTarget(__instance); if ((Object)(object)val != (Object)null) { PlayerVisionTarget playerVisionTarget = val.PlayerVisionTarget; Vector3? obj; if (playerVisionTarget == null) { obj = null; } else { Transform visionTransform = playerVisionTarget.VisionTransform; obj = ((visionTransform != null) ? new Vector3?(visionTransform.position) : ((Vector3?)null)); } Vector3 val2 = (Vector3)(((??)obj) ?? ((Component)val).transform.position) - ((Component)__instance).transform.position; if (((Vector3)(ref val2)).sqrMagnitude > 0.001f) { Quaternion val3 = Quaternion.LookRotation(val2); Quaternion val4 = Quaternion.Euler(0f, ((Quaternion)(ref val3)).eulerAngles.y, 0f); ((Component)__instance).transform.rotation = Quaternion.RotateTowards(((Component)__instance).transform.rotation, val4, EliteEnemyVariantsPlugin.Instance.Settings.ClownTrackSpeed.Value * Time.deltaTime); } } } else { float num = Mathf.Min(runtime.SpinRemaining, EliteEnemyVariantsPlugin.Instance.Settings.ClownSpinSpeedDegPerSec.Value * Time.deltaTime); runtime.SpinYaw = Mathf.Repeat(runtime.SpinYaw + num, 360f); runtime.SpinRemaining -= num; ((Component)__instance).transform.rotation = Quaternion.Euler(0f, runtime.SpinYaw, 0f); if (runtime.SpinRemaining <= 0f) { runtime.Spinning = false; } } } [HarmonyPostfix] [HarmonyPatch(typeof(EnemyBeamer), "VerticalAimLogic")] private static void VerticalAimLogicPostfix(EnemyBeamer __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_0029: 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_002e: Invalid comparison between Unknown and I4 //IL_006f: 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_008a: 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_00a3: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar val = GameFieldAccess.BeamerTarget(__instance); EliteState state; bool flag = !EliteRegistry.TryGet((Component?)(object)__instance, out state) || (Object)(object)val == (Object)null; if (!flag) { State currentState = __instance.currentState; bool flag2 = currentState - 4 <= 2; flag = !flag2; } if (!flag) { PlayerVisionTarget playerVisionTarget = val.PlayerVisionTarget; Vector3? obj; if (playerVisionTarget == null) { obj = null; } else { Transform visionTransform = playerVisionTarget.VisionTransform; obj = ((visionTransform != null) ? new Vector3?(visionTransform.position) : ((Vector3?)null)); } Vector3 val2 = (Vector3)(((??)obj) ?? ((Component)val).transform.position) - __instance.laserRayTransform.position; if (!(((Vector3)(ref val2)).sqrMagnitude <= 0.001f)) { Quaternion val3 = Quaternion.LookRotation(val2); Quaternion val4 = Quaternion.Inverse(((Object)(object)__instance.aimVerticalTransform.parent != (Object)null) ? __instance.aimVerticalTransform.parent.rotation : Quaternion.identity) * val3; val4 = Quaternion.Euler(((Quaternion)(ref val4)).eulerAngles.x, 0f, 0f); float value = EliteEnemyVariantsPlugin.Instance.Settings.ClownTrackSpeed.Value; AimVerticalTarget.Invoke(__instance) = Quaternion.RotateTowards(AimVerticalTarget.Invoke(__instance), val4, value * Time.deltaTime); __instance.aimVerticalTransform.localRotation = AimVerticalTarget.Invoke(__instance); __instance.laserRayTransform.localRotation = AimVerticalTarget.Invoke(__instance); } } } private static ClownRuntimeState GetRuntime(EliteState state) { ClownRuntimeState clownRuntimeState = state.AdapterState as ClownRuntimeState; if (clownRuntimeState == null) { clownRuntimeState = (ClownRuntimeState)(state.AdapterState = new ClownRuntimeState()); } return clownRuntimeState; } private static bool TryFindAlternateTarget(EnemyBeamer clown, float range, out PlayerAvatar result) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00a3: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00d8: Unknown result type (might be due to invalid IL or missing references) result = null; List<PlayerAvatar> list = new List<PlayerAvatar>(); foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (!((Object)(object)item == (Object)null) && !GameFieldAccess.PlayerDisabled(item) && !((Object)(object)item == (Object)(object)GameFieldAccess.BeamerTarget(clown))) { PlayerVisionTarget playerVisionTarget = item.PlayerVisionTarget; Vector3? obj; if (playerVisionTarget == null) { obj = null; } else { Transform visionTransform = playerVisionTarget.VisionTransform; obj = ((visionTransform != null) ? new Vector3?(visionTransform.position) : ((Vector3?)null)); } Vector3 val = (Vector3)(((??)obj) ?? ((Component)item).transform.position) - clown.bottomTransform.position; if (!(((Vector3)(ref val)).magnitude > range) && !Physics.Raycast(clown.bottomTransform.position, ((Vector3)(ref val)).normalized, ((Vector3)(ref val)).magnitude, LayerMask.op_Implicit(GameFieldAccess.VisionMask(GameFieldAccess.BeamerEnemy(clown))), (QueryTriggerInteraction)1)) { list.Add(item); } } } if (list.Count == 0) { return false; } int index = Mathf.Abs(((Object)clown).GetInstanceID()) % list.Count; result = list[index]; return true; } private static float StableUnit(int key, int salt) { int num = key * 1103515245 + salt * 12345; return (float)(uint)((num ^ (num >>> 16)) & 0xFFFFFF) / 16777216f; } } internal static class DedicatedBehaviorSupport { internal static void OnSpawn(EliteState state) { //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) state.AdapterState = new DedicatedEnemyRuntimeState { SpawnInitialized = true, LastPosition = ((Component)state.Enemy).transform.position }; } internal static DedicatedEnemyRuntimeState Runtime(EliteState state) { //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) DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = state.AdapterState as DedicatedEnemyRuntimeState; if (dedicatedEnemyRuntimeState == null) { dedicatedEnemyRuntimeState = (DedicatedEnemyRuntimeState)(state.AdapterState = new DedicatedEnemyRuntimeState { SpawnInitialized = true, LastPosition = ((Component)state.Enemy).transform.position }); } return dedicatedEnemyRuntimeState; } internal static bool IsValidTarget(PlayerAvatar? player) { if ((Object)(object)player != (Object)null) { return !GameFieldAccess.PlayerDisabled(player); } return false; } internal static bool TryFindNearestPlayer(Vector3 origin, float maxDistance, out PlayerAvatar result, PlayerAvatar? exclude = null, Enemy? lineOfSightEnemy = null) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_0088: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00bd: Unknown result type (might be due to invalid IL or missing references) result = null; float num = maxDistance; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (IsValidTarget(item) && !((Object)(object)item == (Object)(object)exclude)) { PlayerVisionTarget playerVisionTarget = item.PlayerVisionTarget; Vector3? obj; if (playerVisionTarget == null) { obj = null; } else { Transform visionTransform = playerVisionTarget.VisionTransform; obj = ((visionTransform != null) ? new Vector3?(visionTransform.position) : ((Vector3?)null)); } Vector3 val = (Vector3)(((??)obj) ?? ((Component)item).transform.position) - origin; float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude > num) && (!((Object)(object)lineOfSightEnemy != (Object)null) || !(magnitude > 0.01f) || !Physics.Raycast(origin, val / magnitude, magnitude, LayerMask.op_Implicit(GameFieldAccess.VisionMask(lineOfSightEnemy)), (QueryTriggerInteraction)1))) { num = magnitude; result = item; } } } return (Object)(object)result != (Object)null; } internal static void TrackState(DedicatedEnemyRuntimeState runtime, int currentState) { runtime.PreviousState = currentState; } internal static void Run<T>(T instance, EliteArchetype archetype, Action<EliteState, T> action) where T : Component { if (!SemiFunc.IsMasterClientOrSingleplayer() || !EliteRegistry.TryGet((Component?)(object)instance, out EliteState state) || state.Archetype != archetype || !state.Spawned || state.AdapterTickFaulted) { return; } try { action(state, instance); } catch (Exception arg) { state.AdapterTickFaulted = true; EliteEnemyVariantsPlugin.ModLogger.LogError((object)("Disabled dedicated behavior for " + EnemyDisplayNameResolver.Get(archetype) + " " + $"until its next spawn because its AI postfix failed: {arg}")); } } internal static float WindupRate(EliteState state) { return EliteEnemyVariantsPlugin.Instance.Settings.BehaviorWindupRate.Value; } internal static float CooldownRate(EliteState state) { return EliteEnemyVariantsPlugin.Instance.Settings.BehaviorCooldownRate.Value; } internal static float Retention(EliteState state) { return EliteEnemyVariantsPlugin.Instance.Settings.BehaviorChaseRetention.Value; } internal static void Countdown<T>(T instance, FieldRef<T, float> field, float rate) { float num = field.Invoke(instance); if (rate > 1f && num > 0f) { field.Invoke(instance) = Mathf.Max(0f, num - Time.deltaTime * (rate - 1f)); } } internal static void Countup<T>(T instance, FieldRef<T, float> field, float rate) { if (rate > 1f) { field.Invoke(instance) = field.Invoke(instance) + Time.deltaTime * (rate - 1f); } } internal static void RetainCountup<T>(T instance, FieldRef<T, float> field, float retention) { float num = field.Invoke(instance); if (retention > 0f && num > 0f) { field.Invoke(instance) = Mathf.Max(0f, num - Time.deltaTime * retention); } } internal static void RetainCountdown<T>(T instance, FieldRef<T, float> field, float retention) { float num = field.Invoke(instance); if (retention > 0f && num > 0f) { field.Invoke(instance) = num + Time.deltaTime * retention; } } } [HarmonyPatch] internal static class AnimalElitePatches { private static readonly Action<EnemyAnimal, State> UpdateState = AccessTools.MethodDelegate<Action<EnemyAnimal, State>>(AccessTools.Method(typeof(EnemyAnimal), "UpdateState", (Type[])null, (Type[])null), (object)null, true); private static readonly FieldRef<EnemyAnimal, float> StateTimer = AccessTools.FieldRefAccess<EnemyAnimal, float>("stateTimer"); private static readonly FieldRef<EnemyAnimal, float> HavocTimer = AccessTools.FieldRefAccess<EnemyAnimal, float>("havocTimer"); private static readonly FieldRef<EnemyAnimal, PlayerAvatar> PlayerTarget = AccessTools.FieldRefAccess<EnemyAnimal, PlayerAvatar>("playerTarget"); internal static void OnSpawn(EliteState state) { DedicatedBehaviorSupport.OnSpawn(state); } private static void Tick(EliteState state, EnemyAnimal animal) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected I4, but got Unknown DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = DedicatedBehaviorSupport.Runtime(state); if ((int)animal.currentState == 4) { DedicatedBehaviorSupport.Countdown<EnemyAnimal>(animal, StateTimer, DedicatedBehaviorSupport.WindupRate(state)); } else if ((int)animal.currentState == 6) { DedicatedBehaviorSupport.Countdown<EnemyAnimal>(animal, HavocTimer, DedicatedBehaviorSupport.CooldownRate(state)); } if (dedicatedEnemyRuntimeState.PreviousState == 6 && (int)animal.currentState == 7 && !dedicatedEnemyRuntimeState.ExtraActionUsed && DedicatedBehaviorSupport.IsValidTarget(PlayerTarget.Invoke(animal))) { dedicatedEnemyRuntimeState.ExtraActionUsed = true; UpdateState(animal, (State)5); } if ((int)animal.currentState == 4 && dedicatedEnemyRuntimeState.PreviousState != 4) { dedicatedEnemyRuntimeState.ExtraActionUsed = false; } DedicatedBehaviorSupport.TrackState(dedicatedEnemyRuntimeState, (int)animal.currentState); } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyAnimal), "Update")] private static void UpdatePostfix(EnemyAnimal __instance) { DedicatedBehaviorSupport.Run<EnemyAnimal>(__instance, EliteArchetype.Animal, (Action<EliteState, EnemyAnimal>)Tick); } } [HarmonyPatch] internal static class BirthdayBoyElitePatches { private static readonly FieldRef<EnemyBirthdayBoy, float> StateTimer = AccessTools.FieldRefAccess<EnemyBirthdayBoy, float>("stateTimer"); private static readonly FieldRef<EnemyBirthdayBoy, float> SecondStateTimer = AccessTools.FieldRefAccess<EnemyBirthdayBoy, float>("secondStateTimer"); private static readonly FieldRef<EnemyBirthdayBoy, PhotonView> PhotonViewRef = AccessTools.FieldRefAccess<EnemyBirthdayBoy, PhotonView>("photonView"); private static readonly Action<EnemyBirthdayBoy, PlayerAvatar> UpdatePlayerTarget = AccessTools.MethodDelegate<Action<EnemyBirthdayBoy, PlayerAvatar>>(AccessTools.Method(typeof(EnemyBirthdayBoy), "UpdatePlayerTarget", (Type[])null, (Type[])null), (object)null, true); private static readonly Action<EnemyBirthdayBoy, State> UpdateState = AccessTools.MethodDelegate<Action<EnemyBirthdayBoy, State>>(AccessTools.Method(typeof(EnemyBirthdayBoy), "UpdateState", (Type[])null, (Type[])null), (object)null, true); internal static void OnSpawn(EliteState state) { DedicatedBehaviorSupport.OnSpawn(state); } private static void Tick(EliteState state, EnemyBirthdayBoy enemy) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 if ((int)enemy.currentState == 8) { DedicatedBehaviorSupport.Countdown<EnemyBirthdayBoy>(enemy, SecondStateTimer, DedicatedBehaviorSupport.WindupRate(state)); } else if ((int)enemy.currentState == 13) { DedicatedBehaviorSupport.RetainCountdown<EnemyBirthdayBoy>(enemy, StateTimer, DedicatedBehaviorSupport.Retention(state)); } } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyBirthdayBoy), "Update")] private static void UpdatePostfix(EnemyBirthdayBoy __instance) { DedicatedBehaviorSupport.Run<EnemyBirthdayBoy>(__instance, EliteArchetype.BirthdayBoy, (Action<EliteState, EnemyBirthdayBoy>)Tick); } [HarmonyPrefix] [HarmonyPatch(typeof(EnemyBirthdayBoy), "CheckForPoppedBalloons")] private static void CheckForPoppedBalloonsPrefix(EnemyBirthdayBoy __instance, ref PlayerAvatar? __state) { __state = null; if (!SemiFunc.IsMasterClientOrSingleplayer() || !EliteRegistry.TryGet((Component?)(object)__instance, out EliteState _)) { return; } foreach (GameObject value in __instance.balloons.Values) { BirthdayBoyBalloon val = (((Object)(object)value != (Object)null) ? value.GetComponentInChildren<BirthdayBoyBalloon>() : null); if ((Object)(object)val != (Object)null && val.popped && DedicatedBehaviorSupport.IsValidTarget(val.popper)) { __state = val.popper; break; } } } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyBirthdayBoy), "CheckForPoppedBalloons")] private static void CheckForPoppedBalloonsPostfix(EnemyBirthdayBoy __instance, PlayerAvatar? __state) { if (SemiFunc.IsMasterClientOrSingleplayer() && !((Object)(object)__state == (Object)null) && EliteRegistry.TryGet((Component?)(object)__instance, out EliteState _)) { UpdatePlayerTarget(__instance, __state); if (GameManager.Multiplayer()) { PhotonViewRef.Invoke(__instance).RPC("UpdatePlayerTargetRPC", (RpcTarget)1, new object[1] { __state.photonView.ViewID }); } StateTimer.Invoke(__instance) = 20f; UpdateState(__instance, (State)13); } } } [HarmonyPatch] internal static class CleanupCrewElitePatches { private static readonly FieldRef<EnemyBombThrower, State> CurrentState = AccessTools.FieldRefAccess<EnemyBombThrower, State>("currentState"); private static readonly FieldRef<EnemyBombThrower, float> StateTimer = AccessTools.FieldRefAccess<EnemyBombThrower, float>("stateTimer"); private static readonly FieldRef<EnemyBombThrower, float> HeadCooldown = AccessTools.FieldRefAccess<EnemyBombThrower, float>("headCooldown"); private static readonly FieldRef<EnemyBombThrower, float> HeadAttackCooldown = AccessTools.FieldRefAccess<EnemyBombThrower, float>("headAttackCooldown"); private static readonly FieldRef<EnemyBombThrower, float> MeleeCooldown = AccessTools.FieldRefAccess<EnemyBombThrower, float>("meleeCooldown"); private static readonly FieldRef<EnemyBombThrower, PlayerAvatar> PlayerTarget = AccessTools.FieldRefAccess<EnemyBombThrower, PlayerAvatar>("playerTarget"); private static readonly Action<EnemyBombThrower, State> UpdateState = AccessTools.MethodDelegate<Action<EnemyBombThrower, State>>(AccessTools.Method(typeof(EnemyBombThrower), "UpdateState", (Type[])null, (Type[])null), (object)null, true); internal static void OnSpawn(EliteState state) { DedicatedBehaviorSupport.OnSpawn(state); } private static void Tick(EliteState state, EnemyBombThrower enemy) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = DedicatedBehaviorSupport.Runtime(state); if ((int)CurrentState.Invoke(enemy) == 4) { DedicatedBehaviorSupport.Countdown<EnemyBombThrower>(enemy, StateTimer, DedicatedBehaviorSupport.WindupRate(state)); } float rate = DedicatedBehaviorSupport.CooldownRate(state); DedicatedBehaviorSupport.Countdown<EnemyBombThrower>(enemy, HeadCooldown, rate); DedicatedBehaviorSupport.Countdown<EnemyBombThrower>(enemy, HeadAttackCooldown, rate); DedicatedBehaviorSupport.Countdown<EnemyBombThrower>(enemy, MeleeCooldown, rate); if (dedicatedEnemyRuntimeState.PreviousState == 8 && (int)CurrentState.Invoke(enemy) == 7 && !dedicatedEnemyRuntimeState.ExtraActionUsed && DedicatedBehaviorSupport.IsValidTarget(PlayerTarget.Invoke(enemy)) && Vector3.Distance(((Component)enemy).transform.position, ((Component)PlayerTarget.Invoke(enemy)).transform.position) <= 4f) { dedicatedEnemyRuntimeState.ExtraActionUsed = true; UpdateState(enemy, (State)9); } if ((int)CurrentState.Invoke(enemy) == 4 && dedicatedEnemyRuntimeState.PreviousState != 4) { dedicatedEnemyRuntimeState.ExtraActionUsed = false; } DedicatedBehaviorSupport.TrackState(dedicatedEnemyRuntimeState, (int)CurrentState.Invoke(enemy)); } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyBombThrower), "Update")] private static void UpdatePostfix(EnemyBombThrower __instance) { DedicatedBehaviorSupport.Run<EnemyBombThrower>(__instance, EliteArchetype.CleanupCrew, (Action<EliteState, EnemyBombThrower>)Tick); } } [HarmonyPatch] internal static class BowtieElitePatches { private static readonly FieldRef<EnemyBowtie, float> StateTimer = AccessTools.FieldRefAccess<EnemyBowtie, float>("stateTimer"); private static readonly Action<EnemyBowtie, State> UpdateState = AccessTools.MethodDelegate<Action<EnemyBowtie, State>>(AccessTools.Method(typeof(EnemyBowtie), "UpdateState", (Type[])null, (Type[])null), (object)null, true); internal static void OnSpawn(EliteState state) { DedicatedBehaviorSupport.OnSpawn(state); } private static void Tick(EliteState state, EnemyBowtie enemy) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_004b: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Invalid comparison between Unknown and I4 //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected I4, but got Unknown DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = DedicatedBehaviorSupport.Runtime(state); if ((int)enemy.currentState == 4) { DedicatedBehaviorSupport.Countdown<EnemyBowtie>(enemy, StateTimer, DedicatedBehaviorSupport.WindupRate(state)); } else if ((int)enemy.currentState == 6) { DedicatedBehaviorSupport.Countdown<EnemyBowtie>(enemy, StateTimer, DedicatedBehaviorSupport.CooldownRate(state)); } bool flag = dedicatedEnemyRuntimeState.PreviousState == 6; if (flag) { State currentState = enemy.currentState; bool flag2 = (((int)currentState == 1 || (int)currentState == 7) ? true : false); flag = flag2; } if (flag && !dedicatedEnemyRuntimeState.ExtraActionUsed) { dedicatedEnemyRuntimeState.ExtraActionUsed = true; UpdateState(enemy, (State)5); } if ((int)enemy.currentState == 4 && dedicatedEnemyRuntimeState.PreviousState != 4) { dedicatedEnemyRuntimeState.ExtraActionUsed = false; } DedicatedBehaviorSupport.TrackState(dedicatedEnemyRuntimeState, (int)enemy.currentState); } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyBowtie), "Update")] private static void UpdatePostfix(EnemyBowtie __instance) { DedicatedBehaviorSupport.Run<EnemyBowtie>(__instance, EliteArchetype.Bowtie, (Action<EliteState, EnemyBowtie>)Tick); } } [HarmonyPatch] internal static class PeeperElitePatches { private static readonly FieldRef<EnemyCeilingEye, float> DamageWaitTimer = AccessTools.FieldRefAccess<EnemyCeilingEye, float>("eyeDamageWaitTimer"); private static readonly FieldRef<EnemyCeilingEye, float> DamageTimer = AccessTools.FieldRefAccess<EnemyCeilingEye, float>("eyeDamageTimer"); private static readonly FieldRef<EnemyCeilingEye, PlayerAvatar> PlayerTarget = AccessTools.FieldRefAccess<EnemyCeilingEye, PlayerAvatar>("targetPlayer"); private static readonly FieldRef<EnemyCeilingEye, PhotonView> PhotonViewRef = AccessTools.FieldRefAccess<EnemyCeilingEye, PhotonView>("photonView"); private static readonly Action<EnemyCeilingEye, State> UpdateState = AccessTools.MethodDelegate<Action<EnemyCeilingEye, State>>(AccessTools.Method(typeof(EnemyCeilingEye), "UpdateState", (Type[])null, (Type[])null), (object)null, true); internal static void OnSpawn(EliteState state) { DedicatedBehaviorSupport.OnSpawn(state); } private static void Tick(EliteState state, EnemyCeilingEye enemy) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_00d8: 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_0045: Invalid comparison between Unknown and I4 //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected I4, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = DedicatedBehaviorSupport.Runtime(state); if ((int)enemy.currentState == 3) { DedicatedBehaviorSupport.Countdown<EnemyCeilingEye>(enemy, DamageWaitTimer, DedicatedBehaviorSupport.WindupRate(state)); DedicatedBehaviorSupport.Countdown<EnemyCeilingEye>(enemy, DamageTimer, DedicatedBehaviorSupport.CooldownRate(state)); } if (dedicatedEnemyRuntimeState.PreviousState == 3 && (int)enemy.currentState == 2 && !dedicatedEnemyRuntimeState.ExtraActionUsed && DedicatedBehaviorSupport.TryFindNearestPlayer(enemy.eyeTransform.position, 20f, out PlayerAvatar result, PlayerTarget.Invoke(enemy), state.Enemy)) { dedicatedEnemyRuntimeState.ExtraActionUsed = true; PlayerTarget.Invoke(enemy) = result; if (GameManager.Multiplayer()) { PhotonViewRef.Invoke(enemy).RPC("TargetPlayerRPC", (RpcTarget)1, new object[1] { result.photonView.ViewID }); } UpdateState(enemy, (State)3); } if ((int)enemy.currentState == 0) { dedicatedEnemyRuntimeState.ExtraActionUsed = false; } DedicatedBehaviorSupport.TrackState(dedicatedEnemyRuntimeState, (int)enemy.currentState); } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyCeilingEye), "Update")] private static void UpdatePostfix(EnemyCeilingEye __instance) { DedicatedBehaviorSupport.Run<EnemyCeilingEye>(__instance, EliteArchetype.Peeper, (Action<EliteState, EnemyCeilingEye>)Tick); } } [HarmonyPatch] internal static class ApexPredatorElitePatches { private static readonly FieldRef<EnemyDuck, float> StateTimer = AccessTools.FieldRefAccess<EnemyDuck, float>("stateTimer"); private static readonly FieldRef<EnemyDuck, float> ChaseTimer = AccessTools.FieldRefAccess<EnemyDuck, float>("chaseTimer"); private static readonly FieldRef<EnemyDuck, PlayerAvatar> PlayerTarget = AccessTools.FieldRefAccess<EnemyDuck, PlayerAvatar>("playerTarget"); private static readonly Action<EnemyDuck, State> UpdateState = AccessTools.MethodDelegate<Action<EnemyDuck, State>>(AccessTools.Method(typeof(EnemyDuck), "UpdateState", (Type[])null, (Type[])null), (object)null, true); internal static void OnSpawn(EliteState state) { DedicatedBehaviorSupport.OnSpawn(state); } private static void Tick(EliteState state, EnemyDuck enemy) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Invalid comparison between Unknown and I4 //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected I4, but got Unknown DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = DedicatedBehaviorSupport.Runtime(state); State currentState = enemy.currentState; if (((int)currentState == 4 || currentState - 11 <= 1) ? true : false) { DedicatedBehaviorSupport.Countdown<EnemyDuck>(enemy, StateTimer, DedicatedBehaviorSupport.WindupRate(state)); } currentState = enemy.currentState; if (currentState - 13 <= 2) { DedicatedBehaviorSupport.RetainCountup<EnemyDuck>(enemy, ChaseTimer, DedicatedBehaviorSupport.Retention(state)); } bool flag = (int)enemy.currentState == 16; if (flag) { int previousState = dedicatedEnemyRuntimeState.PreviousState; bool flag2 = (uint)(previousState - 13) <= 2u; flag = flag2; } if (flag && !dedicatedEnemyRuntimeState.ExtraActionUsed && DedicatedBehaviorSupport.IsValidTarget(PlayerTarget.Invoke(enemy))) { dedicatedEnemyRuntimeState.ExtraActionUsed = true; UpdateState(enemy, (State)11); } if ((int)enemy.currentState == 4 && dedicatedEnemyRuntimeState.PreviousState != 4) { dedicatedEnemyRuntimeState.ExtraActionUsed = false; } DedicatedBehaviorSupport.TrackState(dedicatedEnemyRuntimeState, (int)enemy.currentState); } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyDuck), "Update")] private static void UpdatePostfix(EnemyDuck __instance) { DedicatedBehaviorSupport.Run<EnemyDuck>(__instance, EliteArchetype.ApexPredator, (Action<EliteState, EnemyDuck>)Tick); } } [HarmonyPatch] internal static class ElsaElitePatches { private static readonly FieldRef<EnemyElsa, float> StateTimer = AccessTools.FieldRefAccess<EnemyElsa, float>("stateTimer"); private static readonly FieldRef<EnemyElsa, float> AngryTimer = AccessTools.FieldRefAccess<EnemyElsa, float>("angryTimer"); private static readonly FieldRef<EnemyElsa, float> ChaseTimer = AccessTools.FieldRefAccess<EnemyElsa, float>("chaseTimer"); private static readonly FieldRef<EnemyElsa, PlayerAvatar> PlayerTarget = AccessTools.FieldRefAccess<EnemyElsa, PlayerAvatar>("playerTarget"); private static readonly FieldRef<EnemyElsa, PhotonView> PhotonViewRef = AccessTools.FieldRefAccess<EnemyElsa, PhotonView>("photonView"); private static readonly Action<EnemyElsa, State> UpdateState = AccessTools.MethodDelegate<Action<EnemyElsa, State>>(AccessTools.Method(typeof(EnemyElsa), "UpdateState", (Type[])null, (Type[])null), (object)null, true); internal static void OnSpawn(EliteState state) { DedicatedBehaviorSupport.OnSpawn(state); } private static void Tick(EliteState state, EnemyElsa enemy) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //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_0028: 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_002c: Invalid comparison between Unknown and I4 //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0054: Invalid comparison between Unknown and I4 //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Invalid comparison between Unknown and I4 //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Invalid comparison between Unknown and I4 //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Invalid comparison between Unknown and I4 //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected I4, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = DedicatedBehaviorSupport.Runtime(state); if ((int)enemy.currentState == 5) { DedicatedBehaviorSupport.Countdown<EnemyElsa>(enemy, StateTimer, DedicatedBehaviorSupport.WindupRate(state)); } State currentState = enemy.currentState; if (currentState - 6 <= 2) { DedicatedBehaviorSupport.Countup<EnemyElsa>(enemy, AngryTimer, DedicatedBehaviorSupport.WindupRate(state)); } currentState = enemy.currentState; if ((currentState - 18 <= 1 || (int)currentState == 22) ? true : false) { DedicatedBehaviorSupport.RetainCountup<EnemyElsa>(enemy, ChaseTimer, DedicatedBehaviorSupport.Retention(state)); } if ((int)enemy.currentState == 25 && dedicatedEnemyRuntimeState.PreviousState != 25 && !dedicatedEnemyRuntimeState.ExtraActionUsed && DedicatedBehaviorSupport.TryFindNearestPlayer(((Component)enemy).transform.position, 15f, out PlayerAvatar result, PlayerTarget.Invoke(enemy), state.Enemy)) { dedicatedEnemyRuntimeState.ExtraActionUsed = true; PlayerTarget.Invoke(enemy) = result; GameFieldAccess.SetTargetPlayer(state.Enemy, result); GameFieldAccess.SetTargetPlayerViewId(state.Enemy, result.photonView.ViewID); if (GameManager.Multiplayer()) { PhotonViewRef.Invoke(enemy).RPC("UpdatePlayerTargetRPC", (RpcTarget)1, new object[1] { result.photonView.ViewID }); } ChaseTimer.Invoke(enemy) = 0f; UpdateState(enemy, (State)18); } if ((int)enemy.currentState == 5 && dedicatedEnemyRuntimeState.PreviousState != 5) { dedicatedEnemyRuntimeState.ExtraActionUsed = false; } DedicatedBehaviorSupport.TrackState(dedicatedEnemyRuntimeState, (int)enemy.currentState); } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyElsa), "Update")] private static void UpdatePostfix(EnemyElsa __instance) { DedicatedBehaviorSupport.Run<EnemyElsa>(__instance, EliteArchetype.Elsa, (Action<EliteState, EnemyElsa>)Tick); } } [HarmonyPatch] internal static class MentalistElitePatches { private static readonly FieldRef<EnemyFloater, float> StateTimer = AccessTools.FieldRefAccess<EnemyFloater, float>("stateTimer"); private static readonly Action<EnemyFloater, State> UpdateState = AccessTools.MethodDelegate<Action<EnemyFloater, State>>(AccessTools.Method(typeof(EnemyFloater), "UpdateState", (Type[])null, (Type[])null), (object)null, true); internal static void OnSpawn(EliteState state) { DedicatedBehaviorSupport.OnSpawn(state); } private static void Tick(EliteState state, EnemyFloater enemy) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0012: 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: Invalid comparison between Unknown and I4 //IL_0041: 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) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Invalid comparison between Unknown and I4 //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected I4, but got Unknown DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = DedicatedBehaviorSupport.Runtime(state); State currentState = enemy.currentState; if (((int)currentState == 4 || currentState - 7 <= 1) ? true : false) { DedicatedBehaviorSupport.Countdown<EnemyFloater>(enemy, StateTimer, DedicatedBehaviorSupport.WindupRate(state)); } bool flag = dedicatedEnemyRuntimeState.PreviousState == 9; if (flag) { currentState = enemy.currentState; bool flag2 = (((int)currentState == 1 || (int)currentState == 11) ? true : false); flag = flag2; } if (flag && !dedicatedEnemyRuntimeState.ExtraActionUsed) { dedicatedEnemyRuntimeState.ExtraActionUsed = true; UpdateState(enemy, (State)8); } if ((int)enemy.currentState == 4 && dedicatedEnemyRuntimeState.PreviousState != 4) { dedicatedEnemyRuntimeState.ExtraActionUsed = false; } DedicatedBehaviorSupport.TrackState(dedicatedEnemyRuntimeState, (int)enemy.currentState); } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyFloater), "Update")] private static void UpdatePostfix(EnemyFloater __instance) { DedicatedBehaviorSupport.Run<EnemyFloater>(__instance, EliteArchetype.Mentalist, (Action<EliteState, EnemyFloater>)Tick); } } [HarmonyPatch] internal static class HeadmanElitePatches { private static readonly FieldRef<Enemy, float> DisableChaseTimer = AccessTools.FieldRefAccess<Enemy, float>("DisableChaseTimer"); private static readonly FieldRef<EnemyStateChase, float> ChaseStateTimer = AccessTools.FieldRefAccess<EnemyStateChase, float>("StateTimer"); internal static void OnSpawn(EliteState state) { DedicatedBehaviorSupport.OnSpawn(state); } private static void Tick(EliteState state, Enemy enemy) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Invalid comparison between Unknown and I4 //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Invalid comparison between Unknown and I4 //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Invalid comparison between Unknown and I4 //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected I4, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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) DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = DedicatedBehaviorSupport.Runtime(state); if ((int)enemy.CurrentState == 8) { enemy.CurrentState = (EnemyState)3; } else if ((int)enemy.CurrentState == 4 && dedicatedEnemyRuntimeState.PreviousState != 4 && (Object)(object)GameFieldAccess.StateChase(enemy) != (Object)null) { EnemyStateChase val = GameFieldAccess.StateChase(enemy); ChaseStateTimer.Invoke(val) = Mathf.Max(ChaseStateTimer.Invoke(val), 10f); } else if (dedicatedEnemyRuntimeState.PreviousState == 4 && (int)enemy.CurrentState == 5 && !dedicatedEnemyRuntimeState.ExtraActionUsed) { PlayerAvatar val2 = GameFieldAccess.TargetPlayer(enemy); if (DedicatedBehaviorSupport.IsValidTarget(val2) && Vector3.Distance(((Component)enemy).transform.position, ((Component)val2).transform.position) <= 30f) { dedicatedEnemyRuntimeState.ExtraActionUsed = true; enemy.CurrentState = (EnemyState)3; } } EnemyState currentState = enemy.CurrentState; if (((int)currentState == 2 || (int)currentState == 7) ? true : false) { dedicatedEnemyRuntimeState.ExtraActionUsed = false; } DedicatedBehaviorSupport.Countdown<Enemy>(enemy, DisableChaseTimer, DedicatedBehaviorSupport.CooldownRate(state)); DedicatedBehaviorSupport.TrackState(dedicatedEnemyRuntimeState, (int)enemy.CurrentState); } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(Enemy), "Update")] private static void UpdatePostfix(Enemy __instance) { DedicatedBehaviorSupport.Run<Enemy>(__instance, EliteArchetype.Headman, (Action<EliteState, Enemy>)Tick); } } [HarmonyPatch] internal static class HeadgrabElitePatches { private static readonly FieldRef<EnemyHeadGrabber, float> StateTimer = AccessTools.FieldRefAccess<EnemyHeadGrabber, float>("stateTimer"); private static readonly FieldRef<EnemyHeadGrabber, float> AttackCooldown = AccessTools.FieldRefAccess<EnemyHeadGrabber, float>("attackCooldown"); private static readonly FieldRef<EnemyHeadGrabber, float> HeadTargetCooldown = AccessTools.FieldRefAccess<EnemyHeadGrabber, float>("headTargetCooldown"); private static readonly FieldRef<EnemyHeadGrabber, int> AttacksInRow = AccessTools.FieldRefAccess<EnemyHeadGrabber, int>("attacksInRow"); private static readonly FieldRef<EnemyHeadGrabber, bool> HeadTargetActive = AccessTools.FieldRefAccess<EnemyHeadGrabber, bool>("headTargetActive"); internal static void OnSpawn(EliteState state) { DedicatedBehaviorSupport.OnSpawn(state); } private static void Tick(EliteState state, EnemyHeadGrabber enemy) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Invalid comparison between Unknown and I4 //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected I4, but got Unknown DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = DedicatedBehaviorSupport.Runtime(state); if ((int)enemy.currentState == 7) { DedicatedBehaviorSupport.Countdown<EnemyHeadGrabber>(enemy, StateTimer, DedicatedBehaviorSupport.WindupRate(state)); } float rate = DedicatedBehaviorSupport.CooldownRate(state); DedicatedBehaviorSupport.Countdown<EnemyHeadGrabber>(enemy, AttackCooldown, rate); DedicatedBehaviorSupport.Countdown<EnemyHeadGrabber>(enemy, HeadTargetCooldown, rate); if ((int)enemy.currentState == 8 && !HeadTargetActive.Invoke(enemy) && AttacksInRow.Invoke(enemy) > 3 && StateTimer.Invoke(enemy) <= Time.deltaTime * 2f && !dedicatedEnemyRuntimeState.ExtraActionUsed) { dedicatedEnemyRuntimeState.ExtraActionUsed = true; AttacksInRow.Invoke(enemy) = 3; } if ((int)enemy.currentState == 7 && dedicatedEnemyRuntimeState.PreviousState != 7) { dedicatedEnemyRuntimeState.ExtraActionUsed = false; } DedicatedBehaviorSupport.TrackState(dedicatedEnemyRuntimeState, (int)enemy.currentState); } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyHeadGrabber), "Update")] private static void UpdatePostfix(EnemyHeadGrabber __instance) { DedicatedBehaviorSupport.Run<EnemyHeadGrabber>(__instance, EliteArchetype.Headgrab, (Action<EliteState, EnemyHeadGrabber>)Tick); } } [HarmonyPatch] internal static class HeartHuggerElitePatches { private static readonly FieldRef<EnemyHeartHugger, float> StateTimer = AccessTools.FieldRefAccess<EnemyHeartHugger, float>("stateTimer"); private static readonly FieldRef<EnemyHeartHugger, int> AttacksInRow = AccessTools.FieldRefAccess<EnemyHeartHugger, int>("attacksInARow"); private static readonly Action<EnemyHeartHugger, State> StateSet = AccessTools.MethodDelegate<Action<EnemyHeartHugger, State>>(AccessTools.Method(typeof(EnemyHeartHugger), "StateSet", (Type[])null, (Type[])null), (object)null, true); internal static void OnSpawn(EliteState state) { DedicatedBehaviorSupport.OnSpawn(state); } private static void Tick(EliteState state, EnemyHeartHugger enemy) { //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_0009: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 State currentState = enemy.currentState; if (((int)currentState == 4 || (int)currentState == 6 || (int)currentState == 9) ? true : false) { DedicatedBehaviorSupport.Countup<EnemyHeartHugger>(enemy, StateTimer, DedicatedBehaviorSupport.WindupRate(state)); } } [HarmonyPrefix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyHeartHugger), "LeaveStart")] private static bool LeaveStartPrefix(EnemyHeartHugger __instance) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 if (!SemiFunc.IsMasterClientOrSingleplayer() || !EliteRegistry.TryGet((Component?)(object)__instance, out EliteState state)) { return true; } DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = DedicatedBehaviorSupport.Runtime(state); if ((int)__instance.currentState != 10 || dedicatedEnemyRuntimeState.ExtraActionUsed) { return true; } dedicatedEnemyRuntimeState.ExtraActionUsed = true; AttacksInRow.Invoke(__instance) = 0; StateSet(__instance, (State)5); return false; } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyHeartHugger), "Update")] private static void UpdatePostfix(EnemyHeartHugger __instance) { DedicatedBehaviorSupport.Run<EnemyHeartHugger>(__instance, EliteArchetype.HeartHugger, (Action<EliteState, EnemyHeartHugger>)Tick); } } [HarmonyPatch] internal static class HiddenElitePatches { private static readonly FieldRef<EnemyHidden, float> StateTimer = AccessTools.FieldRefAccess<EnemyHidden, float>("stateTimer"); private static readonly FieldRef<EnemyHidden, float> MaxMoveTimer = AccessTools.FieldRefAccess<EnemyHidden, float>("maxMoveTimer"); private static readonly FieldRef<EnemyHidden, Vector3> AgentDestination = AccessTools.FieldRefAccess<EnemyHidden, Vector3>("agentDestination"); internal static void OnSpawn(EliteState state) { DedicatedBehaviorSupport.OnSpawn(state); } private static void Tick(EliteState state, EnemyHidden enemy) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Invalid comparison between Unknown and I4 //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected I4, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = DedicatedBehaviorSupport.Runtime(state); State currentState = enemy.currentState; if (((int)currentState == 4 || (int)currentState == 6 || (int)currentState == 9) ? true : false) { DedicatedBehaviorSupport.Countdown<EnemyHidden>(enemy, StateTimer, DedicatedBehaviorSupport.WindupRate(state)); } if ((int)enemy.currentState == 7) { DedicatedBehaviorSupport.RetainCountdown<EnemyHidden>(enemy, MaxMoveTimer, DedicatedBehaviorSupport.Retention(state)); float num = Vector3.Distance(dedicatedEnemyRuntimeState.LastPosition, ((Component)enemy).transform.position); dedicatedEnemyRuntimeState.StuckTimer = ((num < 0.05f) ? (dedicatedEnemyRuntimeState.StuckTimer + Time.deltaTime) : 0f); dedicatedEnemyRuntimeState.LastPosition = ((Component)enemy).transform.position; if (dedicatedEnemyRuntimeState.StuckTimer >= 1.5f && !dedicatedEnemyRuntimeState.ExtraActionUsed) { LevelPoint val = SemiFunc.LevelPointGetPlayerDistance(((Component)enemy).transform.position, 20f, 80f, false); NavMeshHit val2 = default(NavMeshHit); if ((Object)(object)val != (Object)null && NavMesh.SamplePosition(((Component)val).transform.position, ref val2, 5f, -1)) { AgentDestination.Invoke(enemy) = ((NavMeshHit)(ref val2)).position; GameFieldAccess.NavMeshAgent(state.Enemy).SetDestination(((NavMeshHit)(ref val2)).position); dedicatedEnemyRuntimeState.ExtraActionUsed = true; } dedicatedEnemyRuntimeState.StuckTimer = 0f; } } else { dedicatedEnemyRuntimeState.StuckTimer = 0f; dedicatedEnemyRuntimeState.LastPosition = ((Component)enemy).transform.position; } if ((int)enemy.currentState == 4 && dedicatedEnemyRuntimeState.PreviousState != 4) { dedicatedEnemyRuntimeState.ExtraActionUsed = false; } DedicatedBehaviorSupport.TrackState(dedicatedEnemyRuntimeState, (int)enemy.currentState); } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyHidden), "Update")] private static void UpdatePostfix(EnemyHidden __instance) { DedicatedBehaviorSupport.Run<EnemyHidden>(__instance, EliteArchetype.Hidden, (Action<EliteState, EnemyHidden>)Tick); } } [HarmonyPatch] internal static class OoglyElitePatches { private static readonly FieldRef<EnemyOogly, float> StateTimer = AccessTools.FieldRefAccess<EnemyOogly, float>("stateTimer"); private static readonly FieldRef<EnemyOogly, float> AttackCooldown = AccessTools.FieldRefAccess<EnemyOogly, float>("attackCooldownTimer"); private static readonly FieldRef<EnemyOogly, PlayerAvatar> PlayerTarget = AccessTools.FieldRefAccess<EnemyOogly, PlayerAvatar>("targetPlayer"); private static readonly Action<EnemyOogly, State> StateSet = AccessTools.MethodDelegate<Action<EnemyOogly, State>>(AccessTools.Method(typeof(EnemyOogly), "StateSet", (Type[])null, (Type[])null), (object)null, true); private static readonly Action<EnemyOogly> InitializeFlightSystem = AccessTools.MethodDelegate<Action<EnemyOogly>>(AccessTools.Method(typeof(EnemyOogly), "InitializeFlightSystem", (Type[])null, (Type[])null), (object)null, true); private static readonly FieldRef<EnemyOogly, Vector3> RoamDestination = AccessTools.FieldRefAccess<EnemyOogly, Vector3>("roamDestination"); private static readonly FieldRef<EnemyOogly, Vector3> CurrentRoamTarget = AccessTools.FieldRefAccess<EnemyOogly, Vector3>("currentRoamTarget"); private static readonly FieldRef<EnemyOogly, Quaternion> HeadWorldTargetRotation = AccessTools.FieldRefAccess<EnemyOogly, Quaternion>("headWorldTargetRotation"); internal static void OnSpawn(EliteState state) { DedicatedBehaviorSupport.OnSpawn(state); EnemyOogly component = ((Component)state.Enemy).GetComponent<EnemyOogly>(); if (!((Object)(object)component == (Object)null)) { component.minFlightHeight = 0.75f; component.preferredHeight = 2f; component.maxFlightHeight = 8f; InitializeFlightSystem(component); DedicatedBehaviorSupport.Runtime(state).NextActionAt = Time.time + EliteEnemyVariantsPlugin.Instance.Settings.OoglyLowPatrolIntervalSeconds.Value; } } private static void Tick(EliteState state, EnemyOogly enemy) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Invalid comparison between Unknown and I4 //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected I4, but got Unknown DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = DedicatedBehaviorSupport.Runtime(state); DedicatedBehaviorSupport.Countdown<EnemyOogly>(enemy, AttackCooldown, DedicatedBehaviorSupport.CooldownRate(state)); if ((int)enemy.currentState == 5) { DedicatedBehaviorSupport.Countup<EnemyOogly>(enemy, StateTimer, DedicatedBehaviorSupport.WindupRate(state)); } if (dedicatedEnemyRuntimeState.PreviousState == 6 && (int)enemy.currentState == 3 && !dedicatedEnemyRuntimeState.ExtraActionUsed && DedicatedBehaviorSupport.IsValidTarget(PlayerTarget.Invoke(enemy))) { dedicatedEnemyRuntimeState.ExtraActionUsed = true; StateSet(enemy, (State)5); } if ((int)enemy.currentState == 5) { int previousState = dedicatedEnemyRuntimeState.PreviousState; if (previousState != 6 && previousState != 3) { dedicatedEnemyRuntimeState.ExtraActionUsed = false; } } TickLowPatrol(state, enemy, dedicatedEnemyRuntimeState); DedicatedBehaviorSupport.TrackState(dedicatedEnemyRuntimeState, (int)enemy.currentState); } private static void TickLowPatrol(EliteState state, EnemyOogly enemy, DedicatedEnemyRuntimeState runtime) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_00bb: Unknown result type (might be due to invalid IL or missing references) Vector3 result; if ((int)enemy.currentState != 4) { runtime.AlternateMode = false; runtime.StuckTimer = 0f; } else if (runtime.AlternateMode) { runtime.StuckTimer += Time.deltaTime; if (Vector3.Distance(enemy.rb.position, CurrentRoamTarget.Invoke(enemy)) <= 1.25f || runtime.StuckTimer >= 8f) { runtime.AlternateMode = false; runtime.StuckTimer = 0f; runtime.NextActionAt = Time.time + EliteEnemyVariantsPlugin.Instance.Settings.OoglyLowPatrolIntervalSeconds.Value; } else { RoamDestination.Invoke(enemy) = CurrentRoamTarget.Invoke(enemy); } } else if (!(Time.time < runtime.NextActionAt) && TryChooseLowPatrolPoint(enemy, out result)) { CurrentRoamTarget.Invoke(enemy) = result; RoamDestination.Invoke(enemy) = result; runtime.AlternateMode = true; runtime.StuckTimer = 0f; } } private static bool TryChooseLowPatrolPoint(EnemyOogly enemy, out Vector3 result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_0147: 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_015c: Unknown result type (might be due to invalid IL or missing references) result = default(Vector3); PlayerAvatar val = null; float num = 30f; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (DedicatedBehaviorSupport.IsValidTarget(item)) { float num2 = Vector3.Distance(enemy.rb.position, ((Component)item).transform.position); if (num2 < num) { num = num2; val = item; } } } List<LevelPoint> list = SemiFunc.LevelPointGetWithinDistance(((Object)(object)val != (Object)null) ? ((Component)val).transform.position : enemy.rb.position, 2f, 16f); if (list == null) { return false; } float value = EliteEnemyVariantsPlugin.Instance.Settings.OoglyLowPatrolHeight.Value; RaycastHit val2 = default(RaycastHit); foreach (LevelPoint item2 in list) { if (!((Object)(object)item2 == (Object)null) && Physics.Raycast(((Component)item2).transform.position + Vector3.up * 3f, Vector3.down, ref val2, 6f, LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1)) { Vector3 val3 = ((RaycastHit)(ref val2)).point + Vector3.up * value; if (!Physics.CheckSphere(val3, 0.4f, LayerMask.op_Implicit(enemy.environmentMask), (QueryTriggerInteraction)1)) { result = val3; return true; } } } return false; } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyOogly), "Update")] private static void UpdatePostfix(EnemyOogly __instance) { DedicatedBehaviorSupport.Run<EnemyOogly>(__instance, EliteArchetype.Oogly, (Action<EliteState, EnemyOogly>)Tick); } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyOogly), "SetHeadTargetRotation")] private static void SetHeadTargetRotationPostfix(EnemyOogly __instance) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_0041: 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) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer() && EliteRegistry.TryGet((Component?)(object)__instance, out EliteState state) && (int)__instance.currentState == 4 && DedicatedBehaviorSupport.Runtime(state).AlternateMode && !((Object)(object)__instance.headTransform == (Object)null)) { Vector3 val = CurrentRoamTarget.Invoke(__instance) - __instance.headTransform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = ((Component)__instance).transform.forward; val.y = 0f; } if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { HeadWorldTargetRotation.Invoke(__instance) = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); } } } } [HarmonyPatch] internal static class RobeElitePatches { private static readonly FieldRef<EnemyRobe, float> ChaseTime = AccessTools.FieldRefAccess<EnemyRobe, float>("chaseTime"); private static readonly FieldRef<EnemyRobe, float> IdleBreakTimer = AccessTools.FieldRefAccess<EnemyRobe, float>("idleBreakTimer"); private static readonly FieldRef<EnemyRobe, PlayerAvatar> PlayerTarget = AccessTools.FieldRefAccess<EnemyRobe, PlayerAvatar>("targetPlayer"); private static readonly FieldRef<EnemyRobe, bool> IsOnScreen = AccessTools.FieldRefAccess<EnemyRobe, bool>("isOnScreen"); private static readonly Action<EnemyRobe, State> UpdateState = AccessTools.MethodDelegate<Action<EnemyRobe, State>>(AccessTools.Method(typeof(EnemyRobe), "UpdateState", (Type[])null, (Type[])null), (object)null, true); internal static void OnSpawn(EliteState state) { DedicatedBehaviorSupport.OnSpawn(state); } private static void Tick(EliteState state, EnemyRobe enemy) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected I4, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = DedicatedBehaviorSupport.Runtime(state); DedicatedBehaviorSupport.Countdown<EnemyRobe>(enemy, IdleBreakTimer, DedicatedBehaviorSupport.CooldownRate(state)); if ((int)enemy.currentState == 4) { DedicatedBehaviorSupport.RetainCountup<EnemyRobe>(enemy, ChaseTime, DedicatedBehaviorSupport.Retention(state)); } PlayerAvatar val = PlayerTarget.Invoke(enemy); bool flag = dedicatedEnemyRuntimeState.PreviousState == 4; if (flag) { State currentState = enemy.currentState; bool flag2 = (((int)currentState == 9 || (int)currentState == 13) ? true : false); flag = flag2; } if (flag && !dedicatedEnemyRuntimeState.ExtraActionUsed && DedicatedBehaviorSupport.IsValidTarget(val) && GameFieldAccess.OnScreen(state.Enemy).GetOnScreen(val)) { dedicatedEnemyRuntimeState.ExtraActionUsed = true; UpdateState(enemy, (State)4); } DedicatedBehaviorSupport.TrackState(dedicatedEnemyRuntimeState, (int)enemy.currentState); } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyRobe), "Update")] private static void UpdatePostfix(EnemyRobe __instance) { DedicatedBehaviorSupport.Run<EnemyRobe>(__instance, EliteArchetype.Robe, (Action<EliteState, EnemyRobe>)Tick); } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyRobe), "MoveTowardPlayer")] private static void MoveTowardPlayerPostfix(EnemyRobe __instance) { if (SemiFunc.IsMasterClientOrSingleplayer() && !IsOnScreen.Invoke(__instance) && EliteRegistry.TryGet((Component?)(object)__instance, out EliteState state)) { float value = EliteEnemyVariantsPlugin.Instance.Settings.RobeUnseenMoveSpeed.Value; EnemyNavMeshAgent val = GameFieldAccess.NavMeshAgent(state.Enemy); val.OverrideAgent(value, GameFieldAccess.NavDefaultAcceleration(val), 0.2f); GameFieldAccess.Rigidbody(state.Enemy).OverrideFollowPosition(1f, value, -1f); } } } [HarmonyPatch] internal static class ReaperElitePatches { private static readonly FieldRef<EnemyRunner, float> StateTimer = AccessTools.FieldRefAccess<EnemyRunner, float>("stateTimer"); private static readonly FieldRef<EnemyRunner, PlayerAvatar> PlayerTarget = AccessTools.FieldRefAccess<EnemyRunner, PlayerAvatar>("targetPlayer"); private static readonly FieldRef<EnemyRunner, bool> StateImpulse = AccessTools.FieldRefAccess<EnemyRunner, bool>("stateImpulse"); private static readonly FieldRef<EnemyRunner, Vector3> TargetPosition = AccessTools.FieldRefAccess<EnemyRunner, Vector3>("targetPosition"); private static readonly FieldRef<EnemyRunner, float> AgentSpeedCurrent = AccessTools.FieldRefAccess<EnemyRunner, float>("agentSpeedCurrent"); private static readonly Action<EnemyRunner, State> UpdateState = AccessTools.MethodDelegate<Action<EnemyRunner, State>>(AccessTools.Method(typeof(EnemyRunner), "UpdateState", (Type[])null, (Type[])null), (object)null, true); internal static void OnSpawn(EliteState state) { DedicatedBehaviorSupport.OnSpawn(state); } private static void Tick(EliteState state, EnemyRunner enemy) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Invalid comparison between Unknown and I4 //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected I4, but got Unknown DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = DedicatedBehaviorSupport.Runtime(state); State currentState = enemy.currentState; if (((int)currentState == 6 || (int)currentState == 10) ? true : false) { DedicatedBehaviorSupport.Countdown<EnemyRunner>(enemy, StateTimer, DedicatedBehaviorSupport.WindupRate(state)); } else if ((int)enemy.currentState == 7 && !dedicatedEnemyRuntimeState.AlternateMode) { DedicatedBehaviorSupport.RetainCountdown<EnemyRunner>(enemy, StateTimer, DedicatedBehaviorSupport.Retention(state)); } if (dedicatedEnemyRuntimeState.PreviousState == 7 && (int)enemy.currentState == 4 && !dedicatedEnemyRuntimeState.ExtraActionUsed && dedicatedEnemyRuntimeState.LastTargetViewId != 0) { dedicatedEnemyRuntimeState.ExtraActionUsed = true; dedicatedEnemyRuntimeState.AlternateMode = true; dedicatedEnemyRuntimeState.NextActionAt = Time.time + 4f; UpdateState(enemy, (State)7); } bool flag = (int)enemy.currentState == 6; if (flag) { int previousState = dedicatedEnemyRuntimeState.PreviousState; bool flag2 = (uint)(previousState - 1) <= 4u; flag = flag2; } if (flag) { dedicatedEnemyRuntimeState.ExtraActionUsed = false; dedicatedEnemyRuntimeState.AlternateMode = false; } DedicatedBehaviorSupport.TrackState(dedicatedEnemyRuntimeState, (int)enemy.currentState); } [HarmonyPostfix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyRunner), "OnVision")] private static void OnVisionPostfix(EnemyRunner __instance) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || !EliteRegistry.TryGet((Component?)(object)__instance, out EliteState state)) { return; } PlayerAvatar val = PlayerTarget.Invoke(__instance); if (DedicatedBehaviorSupport.IsValidTarget(val)) { DedicatedEnemyRuntimeState dedicatedEnemyRuntimeState = DedicatedBehaviorSupport.Runtime(state); dedicatedEnemyRuntimeState.LastPosition = ((Component)val).transform.position; dedicatedEnemyRuntimeState.LastTargetViewId = val.photonView.ViewID; if (dedicatedEnemyRuntimeState.AlternateMode) { dedicatedEnemyRuntimeState.AlternateMode = false; dedicatedEnemyRuntimeState.ExtraActionUsed = false; StateTimer.Invoke(__instance) = Mathf.Max(StateTimer.Invoke(__instance), 2f); } } } [HarmonyPrefix] [HarmonyAfter(new string[] { "REPOJP.StagePhysicsEvents", "REPOJP.RoleShuffle" })] [HarmonyPatch(typeof(EnemyRunner), "StateAttackPlayer")] private static bool StateAttackPlayerPrefix(EnemyRunner __instance) { //IL_008e: 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_009f: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_0072: Unknow