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 SCP3199 v1.0.3
BepInEx/plugins/ProjectSCP.SCP3199.dll
Decompiled a month agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using LethalLib.Modules; using Microsoft.CodeAnalysis; using ProjectSCP.SCP3199.NetcodePatcher; using SCP3199.SCP3199; 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("ProjectSCP.SCP3199")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.3.0")] [assembly: AssemblyInformationalVersion("1.0.3+eb631559e0787775f8ae3fdad2d6f58545631c5d")] [assembly: AssemblyProduct("SCP3199")] [assembly: AssemblyTitle("ProjectSCP.SCP3199")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 SCP3199 { public class ModEnemyAI : EnemyAI { public abstract class AIBehaviorState { public Vector2 RandomRange = new Vector2(0f, 0f); public int MyRandomInt; public SCP3199AI self; public NavMeshAgent agent; public Random enemyRandom; public abstract List<AIStateTransition> Transitions { get; set; } public abstract void OnStateEntered(Animator creatureAnimator); public virtual void UpdateBehavior(Animator creatureAnimator) { } public virtual void AIInterval(Animator creatureAnimator) { } public abstract void OnStateExit(Animator creatureAnimator); } public abstract class AIStateTransition { public SCP3199AI self; public abstract bool CanTransitionBeTaken(); public abstract AIBehaviorState NextState(); } public enum PlayerState { Dead, Outside, Inside, Ship } internal AIBehaviorState InitialState; internal AIBehaviorState ActiveState; internal Random enemyRandom; internal float AITimer; internal bool PrintDebugs; internal PlayerState MyValidState = PlayerState.Inside; internal AIStateTransition nextTransition; internal List<AIStateTransition> GlobalTransitions = new List<AIStateTransition>(); internal List<AIStateTransition> AllTransitions = new List<AIStateTransition>(); internal SCP3199AI self; [NonSerialized] private NetworkVariable<NetworkBehaviourReference> _playerNetVar = new NetworkVariable<NetworkBehaviourReference>(default(NetworkBehaviourReference), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public PlayerControllerB SynchronisedTargetPlayer { get { //IL_0006: 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_0016: Expected O, but got Unknown return (PlayerControllerB)NetworkBehaviourReference.op_Implicit(_playerNetVar.Value); } set { //IL_0022: 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) if ((Object)(object)value == (Object)null) { _playerNetVar.Value = NetworkBehaviourReference.op_Implicit((NetworkBehaviour)null); } else { _playerNetVar.Value = new NetworkBehaviourReference((NetworkBehaviour)(object)value); } } } public override void DoAIInterval() { ((EnemyAI)this).DoAIInterval(); ActiveState.AIInterval(base.creatureAnimator); } public override void Start() { ((EnemyAI)this).Start(); ActiveState = InitialState; enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex); if (base.enemyType.isOutsideEnemy) { MyValidState = PlayerState.Outside; } else { MyValidState = PlayerState.Inside; } if (!base.agent.isOnNavMesh && ((NetworkBehaviour)this).IsOwner) { LogDebug("CREATURE " + ((NetworkBehaviour)this).__getTypeName() + " WAS NOT PLACED ON NAVMESH, DESTROYING..."); ((EnemyAI)this).KillEnemyOnOwnerClient(false); } base.creatureAnimator.Rebind(); ActiveState.self = self; ActiveState.agent = base.agent; ActiveState.enemyRandom = enemyRandom; ActiveState.OnStateEntered(base.creatureAnimator); } public override void Update() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (base.isEnemyDead) { return; } ((EnemyAI)this).Update(); AITimer += Time.deltaTime; bool flag = true; AllTransitions.Clear(); AllTransitions.AddRange(GlobalTransitions); AllTransitions.AddRange(ActiveState.Transitions); foreach (AIStateTransition allTransition in AllTransitions) { allTransition.self = self; if (allTransition.CanTransitionBeTaken() && ((NetworkBehaviour)this).IsOwner) { flag = false; nextTransition = allTransition; TransitionStateServerRpc(nextTransition.ToString(), GenerateNextRandomInt(nextTransition.NextState().RandomRange)); return; } } if (flag) { ActiveState.UpdateBehavior(base.creatureAnimator); } } internal void LogDebug(object data) { if (PrintDebugs) { P.Log(data); } } internal bool PlayerCanBeTargeted(PlayerControllerB myPlayer) { return GetPlayerState(myPlayer) == MyValidState; } internal PlayerState GetPlayerState(PlayerControllerB myPlayer) { if (myPlayer.isPlayerDead) { return PlayerState.Dead; } if (myPlayer.isInsideFactory) { return PlayerState.Inside; } if (myPlayer.isInHangarShipRoom) { return PlayerState.Ship; } return PlayerState.Outside; } internal void MoveTimerValue(ref float Timer, bool ShouldRaise = false) { if (ShouldRaise) { Timer += Time.deltaTime; } else if (!(Timer <= 0f)) { Timer -= Time.deltaTime; } } internal void OverrideState(AIBehaviorState state) { if (!base.isEnemyDead) { ActiveState = state; ActiveState.self = self; ActiveState.agent = base.agent; ActiveState.enemyRandom = enemyRandom; ActiveState.OnStateEntered(base.creatureAnimator); } } public PlayerControllerB? IsAnyPlayerWithinLOS(int range = 45, float width = 60f, int proximityAwareness = -1, bool DoLinecast = true, bool PrintResults = false, bool SortByDistance = false) { //IL_004c: 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) float num = range; PlayerControllerB result = null; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!val.isPlayerDead && val.isPlayerControlled && IsTargetPlayerWithinLOS(val, range, width, proximityAwareness, DoLinecast, PrintResults)) { if (!SortByDistance) { return val; } float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position); if (num2 < num) { num = num2; result = val; } } } return result; } public bool IsTargetPlayerWithinLOS(PlayerControllerB player, int range = 45, float width = 60f, int proximityAwareness = -1, bool DoLinecast = true, bool PrintResults = false) { //IL_0006: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_007e: 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) float num = Vector3.Distance(((Component)this).transform.position, ((Component)player.gameplayCamera).transform.position); bool flag = num < (float)range; float num2 = Vector3.Angle(((Component)base.eye).transform.forward, ((Component)player.gameplayCamera).transform.position - ((Component)base.eye).transform.position); bool flag2 = num2 < width; bool flag3 = num < (float)proximityAwareness; bool flag4 = DoLinecast && Physics.Linecast(((Component)base.eye).transform.position, ((Component)player).transform.position, StartOfRound.Instance.collidersRoomDefaultAndFoliage, (QueryTriggerInteraction)1); if (PrintResults) { LogDebug($"Target in Distance: {flag} ({num})" + $"Target within view cone: {flag2} ({num2})" + $"LOSBlocked: {flag4}"); } if (!(flag && flag2)) { if (flag3) { return !flag4; } return false; } return true; } public bool IsTargetPlayerWithinLOS(int range = 45, float width = 60f, int proximityAwareness = -1, bool DoLinecast = true, bool PrintResults = false) { if ((Object)(object)base.targetPlayer == (Object)null) { LogDebug(((NetworkBehaviour)this).__getTypeName() + " called Target Player LOS check called with null target player; returning false!"); return false; } return IsTargetPlayerWithinLOS(base.targetPlayer, range, width, proximityAwareness, DoLinecast, PrintResults); } public PlayerControllerB FindNearestPlayer(bool ValidateNav = false) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = null; float num = 20000f; for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { PlayerControllerB val2 = StartOfRound.Instance.allPlayerScripts[i]; if (!ValidateNav || base.agent.CalculatePath(((Component)val2).transform.position, base.path1)) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val2).transform.position); if (num2 < num) { val = val2; num = num2; } } } if ((Object)(object)val == (Object)null) { LogDebug("There is somehow no closest player. get fucked"); return null; } return val; } internal bool IsPlayerReachable() { if ((Object)(object)base.targetPlayer == (Object)null) { P.LogError("Player Reach Test has no target player or passed in argument!"); return false; } return IsPlayerReachable(base.targetPlayer); } internal bool IsPlayerReachable(PlayerControllerB PlayerToCheck) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Invalid comparison between Unknown and I4 Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(((Component)base.targetPlayer).transform.position, RoundManager.Instance.navHit, 2.7f, -1); if (!RoundManager.Instance.GotNavMeshPositionResult) { LogDebug("Player Reach Test: No NavMesh position"); return false; } base.agent.CalculatePath(navMeshPosition, base.agent.path); bool flag = (int)base.agent.path.status == 0; LogDebug($"Player Reach Test: {flag}"); return flag; } internal float PlayerDistanceFromShip(PlayerControllerB? PlayerToCheck = null) { //IL_003a: 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) if ((Object)(object)PlayerToCheck == (Object)null) { if ((Object)(object)base.targetPlayer == (Object)null) { P.LogError("PlayerNearShip check has no target player or passed in argument!"); return -1f; } PlayerToCheck = base.targetPlayer; } float num = Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)StartOfRound.Instance.shipBounds).transform.position); LogDebug($"PlayerNearShip check: {num}"); return num; } internal bool PlayerWithinRange(float Range, bool IncludeYAxis = true) { LogDebug($"Distance from target player: {DistanceFromTargetPlayer(IncludeYAxis)}"); return DistanceFromTargetPlayer(IncludeYAxis) <= Range; } internal bool PlayerWithinRange(PlayerControllerB player, float Range, bool IncludeYAxis = true) { return DistanceFromTargetPlayer(player, IncludeYAxis) <= Range; } private float DistanceFromTargetPlayer(bool IncludeYAxis) { //IL_0055: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_0032: 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) if ((Object)(object)base.targetPlayer == (Object)null) { P.LogError($"{this} attempted DistanceFromTargetPlayer with null target; returning -1!"); return -1f; } if (IncludeYAxis) { return Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)this).transform.position); } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(((Component)base.targetPlayer).transform.position.x, ((Component)base.targetPlayer).transform.position.z); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(((Component)this).transform.position.x, ((Component)this).transform.position.z); return Vector2.Distance(val, val2); } private float DistanceFromTargetPlayer(PlayerControllerB player, bool IncludeYAxis) { //IL_002c: 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_0058: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (IncludeYAxis) { return Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position); } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(((Component)base.targetPlayer).transform.position.x, ((Component)base.targetPlayer).transform.position.z); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(((Component)this).transform.position.x, ((Component)this).transform.position.z); return Vector2.Distance(val, val2); } internal bool AnimationIsFinished(string AnimName) { //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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) AnimatorStateInfo currentAnimatorStateInfo = base.creatureAnimator.GetCurrentAnimatorStateInfo(0); if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName(AnimName)) { LogDebug(((NetworkBehaviour)this).__getTypeName() + ": Checking for animation " + AnimName + ", but current animation is " + ((Object)((AnimatorClipInfo)(ref base.creatureAnimator.GetCurrentAnimatorClipInfo(0)[0])).clip).name); return true; } currentAnimatorStateInfo = base.creatureAnimator.GetCurrentAnimatorStateInfo(0); return ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime >= 1f; } internal int GenerateNextRandomInt(Vector2 Range) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Range = nextTransition.NextState().RandomRange; return enemyRandom.Next((int)Range.x, (int)Range.y); } [ServerRpc(RequireOwnership = false)] internal void SetAnimTriggerOnServerRpc(string name) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_0088: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1315480153u, val, (RpcDelivery)0); bool flag = name != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(name, false); } ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1315480153u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (((NetworkBehaviour)this).IsServer) { base.creatureAnimator.SetTrigger(name); } } } [ServerRpc(RequireOwnership = false)] internal void SetAnimBoolOnServerRpc(string name, bool state) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_0088: 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_011a: 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_00c1: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1359580853u, val, (RpcDelivery)0); bool flag = name != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(name, false); } ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref state, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1359580853u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (((NetworkBehaviour)this).IsServer) { base.creatureAnimator.SetBool(name, state); } } } [ServerRpc] internal void TransitionStateServerRpc(string StateName, int RandomInt) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Invalid comparison between Unknown and I4 //IL_0152: 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_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) //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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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.IsClient || networkManager.IsHost)) { if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } return; } ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1389778152u, val, (RpcDelivery)0); bool flag = StateName != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(StateName, false); } BytePacker.WriteValueBitPacked(val2, RandomInt); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1389778152u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; TransitionStateClientRpc(StateName, RandomInt); } } [ClientRpc] internal void TransitionStateClientRpc(string StateName, int RandomInt) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_0088: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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 val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1087195443u, val, (RpcDelivery)0); bool flag = StateName != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(StateName, false); } BytePacker.WriteValueBitPacked(val2, RandomInt); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1087195443u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; TransitionState(StateName, RandomInt); } } internal void TransitionState(string StateName, int RandomInt) { Type type = Type.GetType(StateName); AIStateTransition aIStateTransition = (AIStateTransition)Activator.CreateInstance(type); aIStateTransition.self = self; if (!(aIStateTransition.NextState().GetType() == ActiveState.GetType())) { LogDebug($"{((NetworkBehaviour)this).__getTypeName()} #{self} is Exiting: {ActiveState}"); ActiveState.OnStateExit(base.creatureAnimator); LogDebug($"{((NetworkBehaviour)this).__getTypeName()} #{self} is Transitioning via: {aIStateTransition}"); ActiveState = aIStateTransition.NextState(); ActiveState.MyRandomInt = RandomInt; ActiveState.self = self; ActiveState.agent = base.agent; ActiveState.enemyRandom = enemyRandom; LogDebug($"{((NetworkBehaviour)this).__getTypeName()} #{self} is Entering: {ActiveState}"); ActiveState.OnStateEntered(base.creatureAnimator); StartOfRound.Instance.ClientPlayerList.TryGetValue(NetworkManager.Singleton.LocalClientId, out var value); LogDebug($"CREATURE: {((Object)base.enemyType).name} #{self} STATE: {ActiveState} ON PLAYER: #{value} ({StartOfRound.Instance.allPlayerScripts[value].playerUsername})"); } } [ServerRpc] internal void SetTargetServerRpc(int PlayerID) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Invalid comparison between Unknown and I4 //IL_0114: 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_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) //IL_00b7: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } return; } ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3004598514u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, PlayerID); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3004598514u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; SetTargetClientRpc(PlayerID); } } [ClientRpc] internal void SetTargetClientRpc(int PlayerID) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_0089: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(293878140u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, PlayerID); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 293878140u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (PlayerID == -1) { base.targetPlayer = null; LogDebug($"Clearing target on {this}"); } else if ((Object)(object)StartOfRound.Instance.allPlayerScripts[PlayerID] == (Object)null) { LogDebug($"Index invalid! {this}"); } else { base.targetPlayer = StartOfRound.Instance.allPlayerScripts[PlayerID]; LogDebug($"{this} setting target to: {base.targetPlayer.playerUsername}"); } } } protected override void __initializeVariables() { if (_playerNetVar == null) { throw new Exception("ModEnemyAI._playerNetVar cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_playerNetVar).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_playerNetVar, "_playerNetVar"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_playerNetVar); ((EnemyAI)this).__initializeVariables(); } 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 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(1315480153u, new RpcReceiveHandler(__rpc_handler_1315480153), "SetAnimTriggerOnServerRpc"); ((NetworkBehaviour)this).__registerRpc(1359580853u, new RpcReceiveHandler(__rpc_handler_1359580853), "SetAnimBoolOnServerRpc"); ((NetworkBehaviour)this).__registerRpc(1389778152u, new RpcReceiveHandler(__rpc_handler_1389778152), "TransitionStateServerRpc"); ((NetworkBehaviour)this).__registerRpc(1087195443u, new RpcReceiveHandler(__rpc_handler_1087195443), "TransitionStateClientRpc"); ((NetworkBehaviour)this).__registerRpc(3004598514u, new RpcReceiveHandler(__rpc_handler_3004598514), "SetTargetServerRpc"); ((NetworkBehaviour)this).__registerRpc(293878140u, new RpcReceiveHandler(__rpc_handler_293878140), "SetTargetClientRpc"); ((EnemyAI)this).__initializeRpcs(); } private static void __rpc_handler_1315480153(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_0061: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string animTriggerOnServerRpc = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref animTriggerOnServerRpc, false); } target.__rpc_exec_stage = (__RpcExecStage)1; ((ModEnemyAI)(object)target).SetAnimTriggerOnServerRpc(animTriggerOnServerRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1359580853(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_0067: 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_007c: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string name = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref name, false); } bool state = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref state, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((ModEnemyAI)(object)target).SetAnimBoolOnServerRpc(name, state); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1389778152(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 //IL_00a8: 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_00d9: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } return; } bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string stateName = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref stateName, false); } int randomInt = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref randomInt); target.__rpc_exec_stage = (__RpcExecStage)1; ((ModEnemyAI)(object)target).TransitionStateServerRpc(stateName, randomInt); target.__rpc_exec_stage = (__RpcExecStage)0; } private static void __rpc_handler_1087195443(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string stateName = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref stateName, false); } int randomInt = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref randomInt); target.__rpc_exec_stage = (__RpcExecStage)1; ((ModEnemyAI)(object)target).TransitionStateClientRpc(stateName, randomInt); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3004598514(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 NetworkManager networkManager = target.NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } } else { int targetServerRpc = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref targetServerRpc); target.__rpc_exec_stage = (__RpcExecStage)1; ((ModEnemyAI)(object)target).SetTargetServerRpc(targetServerRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_293878140(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int targetClientRpc = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref targetClientRpc); target.__rpc_exec_stage = (__RpcExecStage)1; ((ModEnemyAI)(object)target).SetTargetClientRpc(targetClientRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "ModEnemyAI"; } } [BepInPlugin("ProjectSCP.SCP3199", "SCP3199", "1.0.3")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; public static AssetBundle? ModAssets; private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; InitializeNetworkBehaviours(); string path = "scp3199modassets"; ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path)); if ((Object)(object)ModAssets == (Object)null) { Logger.LogError((object)"Failed to load custom assets."); return; } EnemyType val = ModAssets.LoadAsset<EnemyType>("Scp3199"); TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("SCP3199TN"); TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("SCP3199TK"); NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab); Enemies.RegisterEnemy(val, 40, (LevelTypes)(-1), val2, val3); Logger.LogInfo((object)"Plugin ProjectSCP.SCP3199 is loaded!"); } private static void InitializeNetworkBehaviours() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } } } internal static class P { internal static void Log(object data) { Plugin.Logger.LogInfo(data); } internal static void LogError(object data) { Plugin.Logger.LogError(data); } } public static class PluginInfo { public const string PLUGIN_GUID = "ProjectSCP.SCP3199"; public const string PLUGIN_NAME = "SCP3199"; public const string PLUGIN_VERSION = "1.0.3"; } } namespace SCP3199.SCP3199 { public class AnimationBridge : MonoBehaviour { public SCP3199AI mainScript; public void FootPrintsAnimationHandle() { ((EnemyAI)mainScript.self).creatureSFX.PlayOneShot(mainScript.self.footStepSound[Random.RandomRangeInt(0, 2)]); } public void ThrowUpAnimationHandle() { //IL_0077: 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) if (Object.FindObjectsOfType<SCP3199AI>().Length <= 30) { List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>(); list.AddRange(RoundManager.Instance.currentLevel.Enemies); list.AddRange(RoundManager.Instance.currentLevel.OutsideEnemies); SpawnableEnemyWithRarity val = list.Find((SpawnableEnemyWithRarity x) => x.enemyType.enemyName.Equals("scp3199")); RoundManager.Instance.SpawnEnemyGameObject(mainScript.self.mouthEggTransform.position, 0f, RoundManager.Instance.currentLevel.OutsideEnemies.IndexOf(val), val.enemyType); } } public void FinishThrowingEggAnimationHandle() { mainScript.switchOffLayingEgg = true; } public void MakeEggVisibleAnimationHandle() { mainScript.MakeEggMouthVisible(visible: true); } public void MakeEggInvisibleAnimationHandle() { mainScript.MakeEggMouthVisible(visible: false); } public void AttackAnimationHandle() { mainScript.self.SwingAttackHitClientRpc(); } public void EndAttackAnimationHandle() { mainScript.canAttack = true; } public void FallDownDeathAnimationHandle() { ((EnemyAI)mainScript.self).creatureVoice.PlayOneShot(mainScript.self.attackPreSound); } } public class SCP3199AI : ModEnemyAI { public enum Speed { Walking = 4, Running = 6 } private static class Anim { internal const string doKillEnemy = "KillEnemy"; internal const string isWalking = "isWalking"; internal const string isRunning = "isRunning"; internal const string doHurtEnemy = "doHurtEnemy"; internal const string doLayEgg = "doLayEgg"; internal const string doAttack = "doAttack"; } private class InEgg : AIBehaviorState { internal class FinishedEgg : AIStateTransition { public override bool CanTransitionBeTaken() { if (self.finishedEggPhase) { return true; } return false; } public override AIBehaviorState NextState() { return new WanderState(); } } public override List<AIStateTransition> Transitions { get; set; } = new List<AIStateTransition>(1) { new FinishedEgg() }; public override void OnStateEntered(Animator creatureAnimator) { } public override void AIInterval(Animator creatureAnimator) { } public override void OnStateExit(Animator creatureAnimator) { ((Renderer)self.mainEgg.GetComponent<MeshRenderer>()).enabled = false; self.spawningParticles.Play(); } } private class WanderState : AIBehaviorState { internal class ArrivedAtDestination : AIStateTransition { public override bool CanTransitionBeTaken() { //IL_000b: 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) if (Vector3.Distance(((EnemyAI)self).agent.destination, ((Component)self).transform.position) < 1f) { return true; } return false; } public override AIBehaviorState NextState() { if (Random.RandomRangeInt(0, 3) == 0 && self.stageOfGrowth == 2f) { return new LayingEgg(); } self.OverrideState(new WanderState()); return new WanderState(); } } internal class SawPlayer : AIStateTransition { public override bool CanTransitionBeTaken() { if (Object.op_Implicit((Object)(object)((EnemyAI)self).CheckLineOfSightForPlayer(45f, 60, -1))) { return true; } return false; } public override AIBehaviorState NextState() { return new Chase(); } } public override List<AIStateTransition> Transitions { get; set; } = new List<AIStateTransition>(2) { new ArrivedAtDestination(), new SawPlayer() }; public override void OnStateEntered(Animator creatureAnimator) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) creatureAnimator.SetBool("isWalking", true); ((EnemyAI)self).SetDestinationToPosition(RoundManager.Instance.outsideAINodes[RandomNumberGenerator.GetInt32(RoundManager.Instance.outsideAINodes.Length)].transform.position, false); ((EnemyAI)self).agent.autoBraking = true; } public override void AIInterval(Animator creatureAnimator) { } public override void OnStateExit(Animator creatureAnimator) { agent.ResetPath(); ((EnemyAI)self).agent.autoBraking = false; creatureAnimator.SetBool("isWalking", false); } } private class LayingEgg : AIBehaviorState { internal class FinishedLaying : AIStateTransition { public override bool CanTransitionBeTaken() { if (self.switchOffLayingEgg) { return true; } return false; } public override AIBehaviorState NextState() { return new WanderState(); } } public override List<AIStateTransition> Transitions { get; set; } = new List<AIStateTransition>(1) { new FinishedLaying() }; public override void OnStateEntered(Animator creatureAnimator) { agent.ResetPath(); agent.isStopped = true; self.PlayAnimationClientRpc("doLayEgg"); } public override void OnStateExit(Animator creatureAnimator) { self.switchOffLayingEgg = false; agent.ResetPath(); agent.isStopped = false; } } private class Chase : AIBehaviorState { public class DontSeePlayer : AIStateTransition { private int timeWithoutSeeing = 200; private int time = 200; public DontSeePlayer() { timeWithoutSeeing = 200; time = 200; } public override bool CanTransitionBeTaken() { if (!Object.op_Implicit((Object)(object)((EnemyAI)self).CheckLineOfSightForPlayer(45f, 60, -1))) { if (timeWithoutSeeing == 0) { return true; } timeWithoutSeeing--; } else { timeWithoutSeeing = time; } return false; } public override AIBehaviorState NextState() { return new WanderState(); } } public override List<AIStateTransition> Transitions { get; set; } = new List<AIStateTransition>(1) { new DontSeePlayer() }; public override void OnStateEntered(Animator creatureAnimator) { creatureAnimator.SetBool("isRunning", true); ((EnemyAI)self).agent.ResetPath(); ((EnemyAI)self).agent.speed = 6f; ((EnemyAI)self).agent.autoBraking = false; ((EnemyAI)self).targetPlayer = ((EnemyAI)self).CheckLineOfSightForPlayer(45f, 60, -1); ((EnemyAI)self).creatureVoice.PlayOneShot(self.growlSound[Random.RandomRangeInt(0, self.growlSound.Length)]); } public override void AIInterval(Animator creatureAnimator) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((EnemyAI)self).targetPlayer == (Object)null) { ((EnemyAI)self).targetPlayer = ((EnemyAI)self).CheckLineOfSightForPlayer(45f, 60, -1); if ((Object)(object)((EnemyAI)self).targetPlayer == (Object)null) { self.OverrideState(new WanderState()); } return; } if (Vector3.Distance(((Component)((EnemyAI)self).targetPlayer).transform.position, ((Component)self).transform.position) < 2f && self.canAttack) { self.canAttack = false; self.PlayAnimationClientRpc("doAttack"); } ((EnemyAI)self).SetDestinationToPosition(((Component)((EnemyAI)self).targetPlayer).transform.position, false); } public override void OnStateExit(Animator creatureAnimator) { self.PlayAnimationClientRpc("isRunning", value: false); ((EnemyAI)self).agent.speed = 4f; } } [CompilerGenerated] private sealed class <DamagePlayerCoroutine>d__32 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayerControllerB playerControllerB; public SCP3199AI <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DamagePlayerCoroutine>d__32(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; SCP3199AI sCP3199AI = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; case 1: <>1__state = -1; playerControllerB.DamagePlayer((sCP3199AI.self.stageOfGrowth == 2f) ? 40 : 20, true, true, (CauseOfDeath)0, 0, false, default(Vector3)); ((MonoBehaviour)sCP3199AI).StopCoroutine(sCP3199AI.self.AttackCoroutine); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private List<Transform> usedNodes = new List<Transform>(); internal static List<GameObject> SCP682Objects = new List<GameObject>(); internal bool finishedEggPhase; internal float stageOfGrowth; internal bool canAttack = true; [SerializeField] internal MeshRenderer eggRendererMouth; [SerializeField] internal GameObject mainEgg; [SerializeField] internal Transform mouthEggTransform; [SerializeField] internal MeshRenderer mainEggRenderer; [SerializeField] internal bool switchOffLayingEgg; [SerializeField] internal Transform AttackArea; internal Coroutine AttackCoroutine; [SerializeField] internal ParticleSystem spawningParticles; [Header("Audio")] [SerializeField] internal AudioClip _hatchingSound; [SerializeField] internal AudioClip huntScream; [SerializeField] internal AudioClip gettingHit; [SerializeField] internal AudioClip attackPreSound; [SerializeField] internal AudioClip layingEgg; [SerializeField] internal AudioClip[] footStepSound; [SerializeField] internal AudioClip[] growlSound; public Transform GetNode(Vector3 currentPosition) { //IL_0046: 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) GameObject[] outsideAINodes = RoundManager.Instance.outsideAINodes; if (outsideAINodes.Length < 3) { Debug.LogError((object)"Not enough nodes to choose from."); return null; } List<(Transform, float)> list = new List<(Transform, float)>(); GameObject[] array = outsideAINodes; foreach (GameObject val in array) { if (!usedNodes.Contains(val.transform)) { float item = Vector3.Distance(currentPosition, val.transform.position); list.Add((val.transform, item)); } } list.Sort(((Transform node, float distance) a, (Transform node, float distance) b) => a.distance.CompareTo(b.distance)); if (list.Count < 3) { Debug.LogError((object)"Not enough unused nodes to choose from."); return null; } int index = list.Count / 2; Transform item2 = list[index].Item1; usedNodes.Add(item2); return item2; } public void MakeEggMouthVisible(bool visible) { ((Renderer)self.eggRendererMouth).enabled = visible; } public override void Start() { self = this; InitialState = new InEgg(); self.finishedEggPhase = false; MakeEggMouthVisible(visible: false); SCP682Objects.Add(((Component)this).gameObject); ((Component)this).gameObject.tag = "treat"; base.Start(); GameObject[] array = GameObject.FindGameObjectsWithTag("treat"); } [ClientRpc] public void ExitEggPhaseClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_007c: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3775835604u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3775835604u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; self.stageOfGrowth = 1f; self.spawningParticles.Play(); self.finishedEggPhase = true; ((Renderer)self.mainEggRenderer).enabled = false; } } } public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { if (self.stageOfGrowth < 1f) { return; } ((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID); if (!((EnemyAI)this).isEnemyDead) { ((EnemyAI)this).enemyHP = ((EnemyAI)this).enemyHP - force; if (((EnemyAI)this).enemyHP <= 0 && !((EnemyAI)this).isEnemyDead) { ((EnemyAI)this).KillEnemyOnOwnerClient(false); } if (!(ActiveState is Chase)) { OverrideState(new Chase()); } } } [ClientRpc] public void SwingAttackHitClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_007c: 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_00d3: 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_00e3: 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 val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1683486650u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1683486650u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; int num = 8; Collider[] array = Physics.OverlapBox(self.AttackArea.position, AttackArea.localScale, Quaternion.identity, num); if (array.Length == 0) { return; } Collider[] array2 = array; foreach (Collider val3 in array2) { PlayerControllerB component = ((Component)val3).GetComponent<PlayerControllerB>(); if ((Object)(object)component == (Object)null || (Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController || (component.isPlayerDead && component.isPlayerControlled && (Object)(object)component.inAnimationWithEnemy == (Object)null && component.sinkingValue < 0.73f)) { break; } if ((Object)(object)component != (Object)null) { self.AttackCoroutine = ((MonoBehaviour)this).StartCoroutine(DamagePlayerCoroutine(component)); } } } [IteratorStateMachine(typeof(<DamagePlayerCoroutine>d__32))] private IEnumerator DamagePlayerCoroutine(PlayerControllerB playerControllerB) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DamagePlayerCoroutine>d__32(0) { <>4__this = this, playerControllerB = playerControllerB }; } [ClientRpc] public void PlayAnimationClientRpc(string animationName, bool value) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_0088: 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_011a: 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_00c1: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3558819380u, val, (RpcDelivery)0); bool flag = animationName != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false); } ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref value, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3558819380u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ((EnemyAI)this).creatureAnimator.SetBool(animationName, value); } } [ClientRpc] public void PlayAnimationClientRpc(string animationName) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_0088: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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 val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(495243024u, val, (RpcDelivery)0); bool flag = animationName != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 495243024u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ((EnemyAI)this).creatureAnimator.SetTrigger(animationName); } } protected override void __initializeVariables() { base.__initializeVariables(); } 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 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(3775835604u, new RpcReceiveHandler(__rpc_handler_3775835604), "ExitEggPhaseClientRpc"); ((NetworkBehaviour)this).__registerRpc(1683486650u, new RpcReceiveHandler(__rpc_handler_1683486650), "SwingAttackHitClientRpc"); ((NetworkBehaviour)this).__registerRpc(3558819380u, new RpcReceiveHandler(__rpc_handler_3558819380), "PlayAnimationClientRpc"); ((NetworkBehaviour)this).__registerRpc(495243024u, new RpcReceiveHandler(__rpc_handler_495243024), "PlayAnimationClientRpc"); base.__initializeRpcs(); } private static void __rpc_handler_3775835604(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((SCP3199AI)(object)target).ExitEggPhaseClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1683486650(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((SCP3199AI)(object)target).SwingAttackHitClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3558819380(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_0067: 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_007c: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string animationName = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false); } bool value = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref value, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((SCP3199AI)(object)target).PlayAnimationClientRpc(animationName, value); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_495243024(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_0061: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string animationName = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false); } target.__rpc_exec_stage = (__RpcExecStage)1; ((SCP3199AI)(object)target).PlayAnimationClientRpc(animationName); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "SCP3199AI"; } } public class GrowthScript : MonoBehaviour { [CompilerGenerated] private sealed class <GrowEgg>d__9 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GrowthScript <>4__this; private float <elapsedTime>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <GrowEgg>d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0125: 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_00cf: 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) int num = <>1__state; GrowthScript growthScript = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <elapsedTime>5__2 = 0f; break; case 1: <>1__state = -1; break; } if (<elapsedTime>5__2 < growthScript.growthDuration1) { float num2 = <elapsedTime>5__2 / growthScript.growthDuration1; if (<elapsedTime>5__2 >= 30f && growthScript.mainScript.stageOfGrowth == 0f) { growthScript.mainScript.ExitEggPhaseClientRpc(); } if (<elapsedTime>5__2 >= 70f && growthScript.mainScript.stageOfGrowth == 1f) { growthScript.mainScript.stageOfGrowth = 2f; } ((EnemyAI)growthScript.mainScript.self).creatureAnimator.speed = Mathf.Lerp(2.3f, 1.3f, num2); growthScript.eggGameObject.transform.localScale = Vector3.Lerp(growthScript.initialScale1, growthScript.targetScale1, num2); <elapsedTime>5__2 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } growthScript.eggGameObject.transform.localScale = growthScript.targetScale1; growthScript.mainScript.stageOfGrowth = 1f; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public SCP3199AI mainScript; public GameObject eggGameObject; private Vector3 initialScale1 = new Vector3(0.1f, 0.1f, 0.1f); private Vector3 targetScale1 = new Vector3(1.464502f, 1.464502f, 1.464502f); private float growthDuration1 = 100f; private Vector3 initialScale2; private Vector3 targetScale2 = new Vector3(1.5f, 1.5f, 1.9f); private float growthDuration2 = 60f; private void Start() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) ((MonoBehaviour)this).StartCoroutine(GrowEgg()); eggGameObject.transform.localScale = initialScale1; } [IteratorStateMachine(typeof(<GrowEgg>d__9))] private IEnumerator GrowEgg() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <GrowEgg>d__9(0) { <>4__this = this }; } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedINetworkSerializable<NetworkBehaviourReference>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<NetworkBehaviourReference>(); } } } namespace ProjectSCP.SCP3199.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }