using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using ChaosSuite.Core; using ChaosSuite.Relocator.NetcodePatcher; using ChaosSuite.Runtime; using GameNetcodeStuff; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; [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("ChaosSuite.Relocator")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a3464fa3098fa6be253d588a5b7ca9ba01bef4dd")] [assembly: AssemblyProduct("ChaosSuite.Relocator")] [assembly: AssemblyTitle("ChaosSuite.Relocator")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] 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 ChaosSuite.Quagmire { [BepInPlugin("com.chaossuite.relocator", "Relocator", "0.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class RelocatorPlugin : BaseUnityPlugin { public const string PluginGuid = "com.chaossuite.relocator"; public const string PluginName = "Relocator"; public const string PluginVersion = "0.2.0"; private static bool netcodeInitialized; internal static GameObject? VisualPrefab { get; private set; } internal static AudioClip? Giggity { get; private set; } internal static AudioClip? Release { get; private set; } private void Awake() { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) InitializeGeneratedNetcode(); ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; AssetBundleRegistry val = ((instance != null) ? instance.Assets : null); AssetBundle val2 = default(AssetBundle); if (val != null && val.TryLoadModuleBundle("Relocator", typeof(RelocatorPlugin).Assembly, ref val2)) { string text = ChaosAssetPaths.BundleName("Relocator"); GameObject visualPrefab = default(GameObject); val.TryLoadAsset(text, ChaosAssetPaths.VisualPrefab("Relocator"), ref visualPrefab); VisualPrefab = visualPrefab; AudioClip giggity = default(AudioClip); val.TryLoadAsset(text, ChaosAssetPaths.AudioClip("Relocator", "giggity.wav"), ref giggity); Giggity = giggity; AudioClip release = default(AudioClip); val.TryLoadAsset(text, ChaosAssetPaths.AudioClip("Relocator", "release.wav"), ref release); Release = release; } ChaosSuiteRuntimePlugin instance2 = ChaosSuiteRuntimePlugin.Instance; if (instance2 != null) { instance2.RegisterFeatureContent("Relocator", typeof(RelocatorPlugin).Assembly); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Relocator gameplay adapter loaded; a registered network prefab and original voice clips are required."); } private static void InitializeGeneratedNetcode() { if (netcodeInitialized) { return; } netcodeInitialized = true; Type[] types = typeof(RelocatorPlugin).Assembly.GetTypes(); for (int i = 0; i < types.Length; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { methodInfo.Invoke(null, null); } } } } } public enum RelocatorPhase : byte { Wander, Telegraph, Grabbing, Dragging, Releasing, Fleeing, Stunned, Dead } public enum ReleaseReason : byte { HostileNearby, DoorBlocked, Stunned, PathInvalid, Timeout, Arrived, VictimDied, VictimDisconnected, RoundEnded } public readonly record struct DragState(EntityId Victim, EntityId Destination, RelocatorPhase Phase, double EndsAt, uint Revision); public static class RelocatorRules { public static int DirectDamageInvariant => 0; public static bool MayGrab(EntityId victim, double now, IReadOnlyDictionary immunity) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (((EntityId)(ref victim)).IsValid) { if (immunity.TryGetValue(victim, out var value)) { return now >= value; } return true; } return false; } public static DragState Release(DragState state) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) return state with { Victim = EntityId.None, Destination = EntityId.None, Phase = RelocatorPhase.Releasing, Revision = state.Revision + 1 }; } public static bool ShouldEndFlee(double now, double endsAt, float distanceSquared, bool pathUsable) { if (!(now >= endsAt) && !(distanceSquared <= 2.25f)) { return !pathUsable; } return true; } } public sealed class RelocatorEnemyAI : EnemyAI { private const int MaximumNodesConsidered = 64; private const float PullAcceleration = 34f; private const float MaximumPullDistance = 8f; private static readonly Collider[] DangerBuffer = (Collider[])(object)new Collider[16]; private readonly NetworkVariable phase = new NetworkVariable((byte)0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable victimId = new NetworkVariable(0uL, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable pullPoint = new NetworkVariable(default(Vector3), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly Dictionary immunityUntil = new Dictionary(); private readonly NavMeshPath destinationPath = new NavMeshPath(); private readonly Vector3[] routeCorners = (Vector3[])(object)new Vector3[32]; private PlayerControllerB? victim; private Vector3 dragDestination; private Vector3 releaseThreatPosition; private Vector3 fleeDestination; private double phaseEndsAt; private double nextPullPublish; private double nextNoiseAt; private double nextProgressCheck; private Vector3 lastProgressPosition; private byte stalledChecks; private bool localMovementWasDisabled; private bool localMovementPrior; private PlayerControllerB? localDraggedPlayer; private GameObject? visualInstance; private readonly NetworkVariable voiceRevision = new NetworkVariable(0u, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable releaseRevision = new NetworkVariable(0u, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private ulong cleanupAffectedOwner = ulong.MaxValue; protected override void __initializeVariables() { ((NetworkVariableBase)phase).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)phase, "phase"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)phase); ((NetworkVariableBase)victimId).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)victimId, "victimId"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)victimId); ((NetworkVariableBase)pullPoint).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)pullPoint, "pullPoint"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)pullPoint); ((NetworkVariableBase)voiceRevision).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)voiceRevision, "voiceRevision"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)voiceRevision); ((NetworkVariableBase)releaseRevision).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)releaseRevision, "releaseRevision"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)releaseRevision); ((EnemyAI)this).__initializeVariables(); } public override void Start() { ((EnemyAI)this).Start(); if ((Object)(object)((Component)this).GetComponentInChildren(true) == (Object)null) { GameObject visualPrefab = RelocatorPlugin.VisualPrefab; if (visualPrefab != null && Object.op_Implicit((Object)(object)visualPrefab)) { visualInstance = Object.Instantiate(visualPrefab, ((Component)this).transform, false); } } if (Object.op_Implicit((Object)(object)base.agent)) { base.agent.speed = 3f; } } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); RegisterPersistentCleanup(); NetworkVariable obj = phase; obj.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnPhaseChanged)); NetworkVariable obj2 = voiceRevision; obj2.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Combine((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnVoiceRevision)); NetworkVariable obj3 = releaseRevision; obj3.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Combine((Delegate?)(object)obj3.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnReleaseRevision)); } public override void Update() { //IL_00a2: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00f2: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).Update(); if (victimId.Value == 0L) { RestoreLocalVictim(); return; } PlayerControllerB val = FindPlayer(victimId.Value - 1); if (val == null || !Object.op_Implicit((Object)(object)val) || !((NetworkBehaviour)val).IsOwner || val.isPlayerDead) { RestoreLocalVictim(); return; } if ((Object)(object)localDraggedPlayer != (Object)null && (Object)(object)localDraggedPlayer != (Object)(object)val) { RestoreLocalVictim(); } if (!localMovementWasDisabled) { localMovementPrior = val.disableMoveInput; } localDraggedPlayer = val; val.disableMoveInput = true; localMovementWasDisabled = true; Vector3 val2 = pullPoint.Value - ((Component)val).transform.position; if (!(((Vector3)(ref val2)).sqrMagnitude <= 0.04f)) { val.externalForces += Vector3.ClampMagnitude(val2 * 7f, 34f) * Time.deltaTime; } } public override void DoAIInterval() { //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: 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) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).DoAIInterval(); if (!((NetworkBehaviour)this).IsServer || base.isEnemyDead) { return; } double timeAsDouble = Time.timeAsDouble; if (RoundEnding()) { immunityUntil.Clear(); Release(ReleaseReason.RoundEnded); return; } PlayerControllerB val = victim; if (val != null && (!val.isPlayerControlled || val.disconnectedMidGame || val.isPlayerDead || val.teleportedLastFrame || val.isInHangarShipRoom)) { Release(val.isPlayerDead ? ReleaseReason.VictimDied : ReleaseReason.VictimDisconnected); return; } switch ((RelocatorPhase)phase.Value) { case RelocatorPhase.Wander: { PlayerControllerB val4 = ChooseIsolatedTarget(timeAsDouble); if (!((Object)(object)val4 == (Object)null)) { victim = val4; SetPhase(RelocatorPhase.Telegraph, timeAsDouble + 0.8); NetworkVariable obj2 = voiceRevision; uint value = obj2.Value; obj2.Value = value + 1; } break; } case RelocatorPhase.Telegraph: { if (timeAsDouble < phaseEndsAt) { break; } PlayerControllerB val2 = victim; if (val2 == null || !Object.op_Implicit((Object)(object)val2) || Vector3.SqrMagnitude(((Component)val2).transform.position - ((Component)this).transform.position) > 9f || !TryChooseDestination(out dragDestination)) { victim = null; SetPhase(RelocatorPhase.Wander, 0.0); break; } ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance == null || !instance.ThreatBudget.TryAcquire(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)0)) { victim = null; SetPhase(RelocatorPhase.Wander, timeAsDouble + 1.5); break; } if (Object.op_Implicit((Object)(object)val2.currentlyHeldObjectServer) && val2.currentlyHeldObjectServer.itemProperties.twoHanded) { val2.DropAllHeldItemsAndSyncNonexact(); } SetCleanupAffectedOwner(((NetworkBehaviour)val2).OwnerClientId); victimId.Value = val2.playerClientId + 1; pullPoint.Value = ((Component)this).transform.position + ((Component)this).transform.forward * 0.4f; ((EnemyAI)this).SetDestinationToPosition(dragDestination, true); lastProgressPosition = ((Component)this).transform.position; nextProgressCheck = timeAsDouble + 0.5; stalledChecks = 0; SetPhase(RelocatorPhase.Dragging, timeAsDouble + 8.0); break; } case RelocatorPhase.Dragging: { PlayerControllerB val3 = victim; if (val3 == null || !Object.op_Implicit((Object)(object)val3)) { Release(ReleaseReason.VictimDisconnected); break; } if (!base.agent.hasPath || base.agent.isPathStale || (int)base.agent.pathStatus != 0) { Release(ReleaseReason.PathInvalid); break; } if (Vector3.SqrMagnitude(((Component)val3).transform.position - pullPoint.Value) > 64f) { Release(ReleaseReason.PathInvalid); break; } if (HostileNearby()) { Release(ReleaseReason.HostileNearby); break; } if (timeAsDouble >= phaseEndsAt) { Release(ReleaseReason.Timeout); break; } if (Vector3.SqrMagnitude(((Component)this).transform.position - dragDestination) <= 4f) { Release(ReleaseReason.Arrived); break; } if (timeAsDouble >= nextProgressCheck) { stalledChecks = (byte)((Vector3.SqrMagnitude(((Component)this).transform.position - lastProgressPosition) < 0.0625f) ? ((byte)(stalledChecks + 1)) : 0); lastProgressPosition = ((Component)this).transform.position; nextProgressCheck = timeAsDouble + 0.5; if (!ValidateCurrentRoute()) { Release(ReleaseReason.PathInvalid); break; } if (stalledChecks >= 2) { Release(ReleaseReason.DoorBlocked); break; } } if (timeAsDouble >= nextPullPublish) { pullPoint.Value = ((Component)this).transform.position + ((Component)this).transform.forward * 0.4f; nextPullPublish = timeAsDouble + 0.2; } if (timeAsDouble >= nextNoiseAt) { ChaosSuiteRuntimePlugin instance2 = ChaosSuiteRuntimePlugin.Instance; if (instance2 != null) { instance2.Noise.TryEmit(new EntityId(((NetworkBehaviour)this).NetworkObjectId), ((Component)this).transform.position, 32f, 0.8f, 9941, timeAsDouble, 1.0, false); } NetworkVariable obj = voiceRevision; uint value = obj.Value; obj.Value = value + 1; nextNoiseAt = timeAsDouble + 1.4; } break; } case RelocatorPhase.Releasing: if (timeAsDouble >= phaseEndsAt) { if (TryChooseFleeDestination(releaseThreatPosition, out fleeDestination)) { ((EnemyAI)this).SetDestinationToPosition(fleeDestination, true); } SetPhase(RelocatorPhase.Fleeing, timeAsDouble + 2.2); } break; case RelocatorPhase.Fleeing: if (RelocatorRules.ShouldEndFlee(timeAsDouble, phaseEndsAt, Vector3.SqrMagnitude(((Component)this).transform.position - fleeDestination), (Object)(object)base.agent != (Object)null && base.agent.hasPath && !base.agent.isPathStale)) { SetPhase(RelocatorPhase.Wander, 0.0); } break; case RelocatorPhase.Stunned: if (timeAsDouble >= phaseEndsAt) { SetPhase(RelocatorPhase.Wander, 0.0); } break; case RelocatorPhase.Grabbing: break; } } public override void SetEnemyStunned(bool setToStunned, float setToStunTime = 1f, PlayerControllerB? setStunnedByPlayer = null) { ((EnemyAI)this).SetEnemyStunned(setToStunned, setToStunTime, setStunnedByPlayer); if (((NetworkBehaviour)this).IsServer && setToStunned) { Release(ReleaseReason.Stunned); SetPhase(RelocatorPhase.Stunned, Time.timeAsDouble + (double)Mathf.Max(0.5f, setToStunTime)); } } public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { ((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID); if (((NetworkBehaviour)this).IsServer && force > 0) { Release(ReleaseReason.Stunned); } } public override void KillEnemy(bool destroy) { if (((NetworkBehaviour)this).IsServer) { Release(ReleaseReason.RoundEnded); phase.Value = 7; } ((EnemyAI)this).KillEnemy(destroy); } public override void OnNetworkDespawn() { NetworkVariable obj = phase; obj.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Remove((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnPhaseChanged)); NetworkVariable obj2 = voiceRevision; obj2.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Remove((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnVoiceRevision)); NetworkVariable obj3 = releaseRevision; obj3.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Remove((Delegate?)(object)obj3.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnReleaseRevision)); if (((NetworkBehaviour)this).IsServer) { Release(ReleaseReason.RoundEnded); } immunityUntil.Clear(); RestoreLocalVictim(); GameObject val = visualInstance; if (val != null && Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } ((NetworkBehaviour)this).OnNetworkDespawn(); } private void OnDisable() { RestoreLocalVictim(); } private void OnVoiceRevision(uint prior, uint current) { if (current != prior && Object.op_Implicit((Object)(object)RelocatorPlugin.Giggity) && Object.op_Implicit((Object)(object)base.creatureVoice)) { base.creatureVoice.PlayOneShot(RelocatorPlugin.Giggity); } } private void OnPhaseChanged(byte prior, byte current) { bool flag = current != prior; if (flag) { RelocatorPhase relocatorPhase = (RelocatorPhase)current; bool flag2 = ((relocatorPhase == RelocatorPhase.Telegraph || relocatorPhase == RelocatorPhase.Dragging) ? true : false); flag = flag2; } if (flag) { ChaosPresentation.TriggerAction((Component)(object)this); } } private void OnReleaseRevision(uint prior, uint current) { if (current != prior) { ChaosPresentation.TriggerAction((Component)(object)this); if (Object.op_Implicit((Object)(object)RelocatorPlugin.Release) && Object.op_Implicit((Object)(object)base.creatureVoice)) { base.creatureVoice.PlayOneShot(RelocatorPlugin.Release); } } } private bool TryChooseDestination(out Vector3 chosen) { //IL_0001: 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_005b: 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_0068: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) chosen = default(Vector3); if (Object.op_Implicit((Object)(object)RoundManager.Instance)) { GameObject[] insideAINodes = RoundManager.Instance.insideAINodes; if (insideAINodes != null && insideAINodes.Length > 0) { float num = 0f; int num2 = Math.Min(insideAINodes.Length, 64); for (int i = 0; i < num2; i++) { GameObject val = insideAINodes[i]; if (Object.op_Implicit((Object)(object)val)) { Vector3 position = val.transform.position; float num3 = Vector3.Distance(((Component)this).transform.position, position); if (!(num3 < 18f) && !(num3 <= num) && StandingPointIsSafe(position) && NavMesh.CalculatePath(((Component)this).transform.position, position, -1, destinationPath) && (int)destinationPath.status == 0 && ValidatePath(destinationPath)) { num = num3; chosen = position; } } } return num > 0f; } } return false; } private bool TryChooseFleeDestination(Vector3 threatPosition, out Vector3 chosen) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) chosen = ((Component)this).transform.position; if (Object.op_Implicit((Object)(object)RoundManager.Instance)) { GameObject[] insideAINodes = RoundManager.Instance.insideAINodes; if (insideAINodes != null && insideAINodes.Length > 0) { float num = Vector3.SqrMagnitude(((Component)this).transform.position - threatPosition); int num2 = Math.Min(insideAINodes.Length, 64); for (int i = 0; i < num2; i++) { GameObject val = insideAINodes[i]; if (Object.op_Implicit((Object)(object)val)) { Vector3 position = val.transform.position; float num3 = Vector3.SqrMagnitude(position - ((Component)this).transform.position); float num4 = Vector3.SqrMagnitude(position - threatPosition); if (!(num3 < 25f) && !(num3 > 576f) && !(num4 <= num) && StandingPointIsSafe(position) && NavMesh.CalculatePath(((Component)this).transform.position, position, -1, destinationPath) && (int)destinationPath.status == 0 && ValidatePath(destinationPath)) { num = num4; chosen = position; } } } return Vector3.SqrMagnitude(chosen - ((Component)this).transform.position) >= 25f; } } return false; } private bool IsDangerous(Vector3 candidate) { //IL_0000: 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_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_003c: Unknown result type (might be due to invalid IL or missing references) if (!(candidate.y < -50f)) { if (Object.op_Implicit((Object)(object)StartOfRound.Instance) && Object.op_Implicit((Object)(object)StartOfRound.Instance.shipBounds)) { Bounds bounds = StartOfRound.Instance.shipBounds.bounds; if (((Bounds)(ref bounds)).Contains(candidate)) { goto IL_0044; } } int num = Physics.OverlapSphereNonAlloc(candidate, 4f, DangerBuffer, -1, (QueryTriggerInteraction)2); for (int i = 0; i < num; i++) { if (Object.op_Implicit((Object)(object)((Component)DangerBuffer[i]).GetComponentInParent()) || Object.op_Implicit((Object)(object)((Component)DangerBuffer[i]).GetComponentInParent())) { return true; } } return false; } goto IL_0044; IL_0044: return true; } private bool StandingPointIsSafe(Vector3 candidate) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (IsDangerous(candidate) || (Object)(object)StartOfRound.Instance == (Object)null) { return false; } int collidersAndRoomMaskAndDefault = StartOfRound.Instance.collidersAndRoomMaskAndDefault; return Physics.Raycast(candidate + Vector3.up * 0.8f, Vector3.down, 2.5f, collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1); } private bool ValidateCurrentRoute() { if ((Object)(object)base.agent != (Object)null && base.agent.hasPath) { return ValidatePath(base.agent.path); } return false; } private bool ValidatePath(NavMeshPath path) { //IL_002d: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_009a: Unknown result type (might be due to invalid IL or missing references) int cornersNonAlloc = path.GetCornersNonAlloc(routeCorners); if (cornersNonAlloc < 2 || cornersNonAlloc > routeCorners.Length) { return false; } for (int i = 0; i < cornersNonAlloc; i++) { if (!StandingPointIsSafe(routeCorners[i])) { return false; } if (i == 0) { continue; } Vector3 val = routeCorners[i - 1]; Vector3 val2 = routeCorners[i] - val; int num = Math.Min(8, Math.Max(1, Mathf.CeilToInt(((Vector3)(ref val2)).magnitude / 3f))); for (int j = 1; j < num; j++) { if (!StandingPointIsSafe(Vector3.Lerp(val, routeCorners[i], (float)j / (float)num))) { return false; } } } return true; } private PlayerControllerB? ChooseIsolatedTarget(double now) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return null; } PlayerControllerB result = null; float num = -1f; int num2 = Math.Min(array.Length, 16); for (int i = 0; i < num2; i++) { PlayerControllerB val = array[i]; if ((Object)(object)val == (Object)null || !MayGrab(val, now) || Vector3.SqrMagnitude(((Component)val).transform.position - ((Component)this).transform.position) > 36f || !HasLineOfSight(val)) { continue; } float num3 = float.PositiveInfinity; for (int j = 0; j < num2; j++) { PlayerControllerB val2 = array[j]; if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)val) && MayGrab(val2, now)) { num3 = Mathf.Min(num3, Vector3.SqrMagnitude(((Component)val2).transform.position - ((Component)val).transform.position)); } } if (!(num3 <= num)) { num = num3; result = val; } } return result; } private bool HasLineOfSight(PlayerControllerB target) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.position + Vector3.up; Vector3 val2 = ((Component)target).transform.position + Vector3.up; RaycastHit val3 = default(RaycastHit); if (Physics.Linecast(val, val2, ref val3, -1, (QueryTriggerInteraction)1)) { return (Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() == (Object)(object)target; } return true; } private bool HostileNearby() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapSphereNonAlloc(((Component)this).transform.position, 5f, DangerBuffer, -1, (QueryTriggerInteraction)2); for (int i = 0; i < num; i++) { EnemyAI componentInParent = ((Component)DangerBuffer[i]).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent) && (Object)(object)componentInParent != (Object)(object)this && !componentInParent.isEnemyDead) { return true; } } return false; } private bool MayGrab(PlayerControllerB candidate, double now) { if (candidate.isPlayerControlled && !candidate.isPlayerDead && !candidate.disconnectedMidGame && candidate.isInsideFactory && !candidate.isInHangarShipRoom) { if (immunityUntil.TryGetValue(candidate.playerClientId, out var value)) { return now >= value; } return true; } return false; } private void Release(ReleaseReason reason) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //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_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_00d5: 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_0068: 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) if (!((NetworkBehaviour)this).IsServer || (victimId.Value == 0L && !Object.op_Implicit((Object)(object)victim))) { return; } PlayerControllerB val = victim; if (val != null) { releaseThreatPosition = ((Component)val).transform.position; if (reason != ReleaseReason.RoundEnded) { immunityUntil[val.playerClientId] = Time.timeAsDouble + 25.0; } if (reason == ReleaseReason.Arrived && StandingPointIsSafe(dragDestination)) { SafeReleaseClientRpc(((NetworkBehaviour)val).OwnerClientId, dragDestination); } } else { releaseThreatPosition = ((Component)this).transform.position - ((Component)this).transform.forward * 2f; } SetCleanupAffectedOwner(ulong.MaxValue); victim = null; victimId.Value = 0uL; pullPoint.Value = Vector3.zero; fleeDestination = ((Component)this).transform.position; NetworkVariable obj = releaseRevision; uint value = obj.Value; obj.Value = value + 1; ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.ThreatBudget.Release(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)0, $"relocator release: {reason}"); } SetPhase((reason == ReleaseReason.Stunned) ? RelocatorPhase.Stunned : RelocatorPhase.Releasing, Time.timeAsDouble + 0.7); } private void RegisterPersistentCleanup() { if (((NetworkBehaviour)this).IsServer && !((Object)(object)((NetworkBehaviour)this).NetworkObject == (Object)null) && ((NetworkBehaviour)this).NetworkObject.IsSpawned) { ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.Cleanup.Register(((NetworkBehaviour)this).NetworkObject, (Action)CleanupPersistentEffect); } } } private void CleanupPersistentEffect() { Release(ReleaseReason.RoundEnded); } private void SetCleanupAffectedOwner(ulong nextOwner) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsServer && cleanupAffectedOwner != nextOwner) { ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; EffectCleanupRegistry val = ((instance != null) ? instance.Cleanup : null); EntityId val2 = default(EntityId); ((EntityId)(ref val2))..ctor(((NetworkBehaviour)this).NetworkObjectId); if (cleanupAffectedOwner != ulong.MaxValue && val != null) { val.DisassociateAffectedOwner(val2, cleanupAffectedOwner); } cleanupAffectedOwner = nextOwner; if (cleanupAffectedOwner != ulong.MaxValue && val != null) { val.AssociateAffectedOwner(val2, cleanupAffectedOwner); } } } [ClientRpc] private void SafeReleaseClientRpc(ulong targetClient, Vector3 destination) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: 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_006d: 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_0096: 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_00e7: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2161501617u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, targetClient); ((FastBufferWriter)(ref val)).WriteValueSafe(ref destination); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2161501617u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; Vector3 destination2 = destination; NetworkManager singleton = NetworkManager.Singleton; if (singleton == null || singleton.LocalClientId != targetClient) { return; } PlayerControllerB local = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)local != (Object)null && !local.isPlayerDead) { TeleportCleanupGuard.RunWithoutCleanup((Action)delegate { //IL_0007: Unknown result type (might be due to invalid IL or missing references) local.TeleportPlayer(destination2, false, 0f, false, true); }); } } private PlayerControllerB? FindPlayer(ulong clientId) { if (!Object.op_Implicit((Object)(object)StartOfRound.Instance)) { return null; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; for (int i = 0; i < allPlayerScripts.Length; i++) { if (Object.op_Implicit((Object)(object)allPlayerScripts[i]) && allPlayerScripts[i].playerClientId == clientId) { return allPlayerScripts[i]; } } return null; } private void RestoreLocalVictim() { if (localMovementWasDisabled) { PlayerControllerB val = localDraggedPlayer; if ((Object)(object)val == (Object)null || !Object.op_Implicit((Object)(object)val)) { val = GameNetworkManager.Instance?.localPlayerController; } if ((Object)(object)val != (Object)null && Object.op_Implicit((Object)(object)val)) { val.disableMoveInput = localMovementPrior; } localDraggedPlayer = null; localMovementWasDisabled = false; } } private void SetPhase(RelocatorPhase next, double deadline) { phase.Value = (byte)next; phaseEndsAt = deadline; if (Object.op_Implicit((Object)(object)base.agent)) { base.agent.speed = next switch { RelocatorPhase.Wander => 3f, RelocatorPhase.Fleeing => 7f, RelocatorPhase.Dragging => 6.5f, _ => 0f, }; } } private static bool RoundEnding() { if (Object.op_Implicit((Object)(object)StartOfRound.Instance) && !StartOfRound.Instance.shipIsLeaving) { return StartOfRound.Instance.inShipPhase; } return true; } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(2161501617u, new RpcReceiveHandler(__rpc_handler_2161501617), "SafeReleaseClientRpc"); ((EnemyAI)this).__initializeRpcs(); } private static void __rpc_handler_2161501617(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong targetClient = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref targetClient); Vector3 destination = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref destination); target.__rpc_exec_stage = (__RpcExecStage)1; ((RelocatorEnemyAI)(object)target).SafeReleaseClientRpc(targetClient, destination); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "RelocatorEnemyAI"; } } } namespace System.Runtime.CompilerServices { internal static class IsExternalInit { } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); } } } namespace ChaosSuite.Relocator.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }