using System.Collections; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using GameNetcodeStuff; using LethalLib.Modules; 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("TheFogMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TheFogMod")] [assembly: AssemblyTitle("TheFogMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace TheFogMod; [BepInPlugin("com.danila.thefog", "The Fog Monster", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public static AssetBundle ModAssetBundle; private void Awake() { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "thefogbundle"); if (!File.Exists(text)) { ((BaseUnityPlugin)this).Logger.LogError((object)("[The Fog] Критическая ошибка: файл " + text + " не найден!")); return; } ModAssetBundle = AssetBundle.LoadFromFile(text); EnemyType val = ModAssetBundle.LoadAsset("TheFogEnemyType"); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"[The Fog] Не удалось загрузить TheFogEnemyType!"); return; } GameObject enemyPrefab = val.enemyPrefab; TheFogAI theFogAI = enemyPrefab.AddComponent(); ((EnemyAI)theFogAI).enemyType = val; Transform obj = enemyPrefab.transform.Find("GlobalSound"); theFogAI.globalAudio = ((obj != null) ? ((Component)obj).GetComponent() : null); Transform obj2 = enemyPrefab.transform.Find("LocalSound"); theFogAI.localAudio = ((obj2 != null) ? ((Component)obj2).GetComponent() : null); theFogAI.huntTheme = ModAssetBundle.LoadAsset("Fog_Stalk"); theFogAI.stareTheme = ModAssetBundle.LoadAsset("Fog_Jumpscare"); NetworkPrefabs.RegisterNetworkPrefab(enemyPrefab); Enemies.RegisterEnemy(val, 30, (LevelTypes)(-1), (SpawnType)0, (TerminalNode)null, (TerminalKeyword)null); Enemies.RegisterEnemy(val, 40, (LevelTypes)(-1), (SpawnType)2, (TerminalNode)null, (TerminalKeyword)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Фог полностью собран через код и готов к тестам!"); } } public class TheFogAI : EnemyAI { [Header("Fog Config")] public float huntDuration = 60f; public float flyingSpeed = 12f; public float killDelay = 5f; public float flyHeight = 1.8f; [Header("Audio Setup")] public AudioSource globalAudio; public AudioSource localAudio; public AudioClip huntTheme; public AudioClip stareTheme; private float currentHuntTimer; private bool isHunting; private bool isStaring; private CharacterController cc; private bool audioInitialized; private Vector3 customServerPosition; public override void Start() { base.agent = ((Component)this).GetComponent(); if ((Object)(object)base.agent != (Object)null) { ((Behaviour)base.agent).enabled = false; } ((EnemyAI)this).Start(); cc = ((Component)this).GetComponent(); if ((Object)(object)cc != (Object)null) { ((Collider)cc).enabled = false; } Rigidbody component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null) { component.isKinematic = true; component.useGravity = false; } InitializeAudio(); } private void InitializeAudio() { if (!audioInitialized) { if ((Object)(object)globalAudio == (Object)null) { Transform obj = ((Component)this).transform.Find("GlobalSound"); globalAudio = ((obj != null) ? ((Component)obj).GetComponent() : null); } if ((Object)(object)localAudio == (Object)null) { Transform obj2 = ((Component)this).transform.Find("LocalSound"); localAudio = ((obj2 != null) ? ((Component)obj2).GetComponent() : null); } if ((Object)(object)globalAudio != (Object)null && (Object)(object)huntTheme == (Object)null) { huntTheme = globalAudio.clip; } if ((Object)(object)localAudio != (Object)null && (Object)(object)stareTheme == (Object)null) { stareTheme = localAudio.clip; } if ((Object)(object)globalAudio != (Object)null) { globalAudio.spatialize = false; globalAudio.spatialBlend = 0f; } if ((Object)(object)localAudio != (Object)null) { localAudio.spatialize = false; localAudio.spatialBlend = 0f; } audioInitialized = true; } } public override void OnNetworkSpawn() { //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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) ((NetworkBehaviour)this).OnNetworkSpawn(); InitializeAudio(); if (((NetworkBehaviour)this).IsServer) { customServerPosition = ((Component)this).transform.position; base.serverPosition = ((Component)this).transform.position; } BeginHunt(); } public override void Update() { //IL_000f: 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 (!((NetworkBehaviour)this).IsServer) { base.serverPosition = ((Component)this).transform.position; } ((EnemyAI)this).Update(); if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = false; } if ((Object)(object)cc != (Object)null && ((Collider)cc).enabled) { ((Collider)cc).enabled = false; } if ((Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayerScripts == null) { return; } FindTarget(); if (((NetworkBehaviour)this).IsServer && isHunting && !isStaring) { currentHuntTimer -= Time.deltaTime; if (currentHuntTimer <= 0f) { EndHuntServerRpc(); } } } private void LateUpdate() { //IL_000f: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if (isStaring) { ((Component)this).transform.position = customServerPosition; } else { if (!isHunting || !((Object)(object)base.targetPlayer != (Object)null)) { return; } Vector3 val = ((Component)base.targetPlayer).transform.position + Vector3.up * flyHeight; ((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, val, flyingSpeed * Time.deltaTime); ((Component)this).transform.LookAt(val); float num = Vector3.Distance(((Component)this).transform.position, val); if (((NetworkBehaviour)this).IsServer) { customServerPosition = ((Component)this).transform.position; base.serverPosition = ((Component)this).transform.position; if (num <= 2.2f && !isStaring && !base.targetPlayer.isInHangarShipRoom) { TriggerStareFromServer(base.targetPlayer); } } else if ((Object)(object)base.targetPlayer == (Object)(object)StartOfRound.Instance.localPlayerController && num <= 1.8f && !isStaring) { TriggerStareServerRpc(StartOfRound.Instance.localPlayerController.playerClientId); } } } [ServerRpc(RequireOwnership = false)] private void TriggerStareServerRpc(ulong victimId) { if (isStaring || !isHunting) { return; } PlayerControllerB val = null; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if ((Object)(object)val2 != (Object)null && val2.playerClientId == victimId) { val = val2; break; } } if ((Object)(object)val != (Object)null && !val.isPlayerDead && !val.isInHangarShipRoom) { base.targetPlayer = val; TriggerStareFromServer(val); } } private void TriggerStareFromServer(PlayerControllerB victim) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) isStaring = true; customServerPosition = ((Component)this).transform.position; base.serverPosition = ((Component)this).transform.position; SyncStaringStateClientRpc(staring: true, ((Component)this).transform.position); ((MonoBehaviour)this).StartCoroutine(ExecuteStareAndKill(victim)); LockClientCameraClientRpc(victim.playerClientId); } private void FindTarget() { //IL_0083: 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) PlayerControllerB targetPlayer = null; float num = float.MaxValue; if ((Object)(object)base.targetPlayer != (Object)null && (base.targetPlayer.isInHangarShipRoom || base.targetPlayer.isPlayerDead || !base.targetPlayer.isPlayerControlled)) { base.targetPlayer = null; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && val.isPlayerControlled && !val.isPlayerDead && !val.isInHangarShipRoom) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position); if (num2 < num) { num = num2; targetPlayer = val; } } } base.targetPlayer = targetPlayer; } public void BeginHunt() { isHunting = true; isStaring = false; currentHuntTimer = huntDuration; if ((Object)(object)globalAudio != (Object)null && (Object)(object)huntTheme != (Object)null) { globalAudio.clip = huntTheme; globalAudio.Play(); } } private IEnumerator ExecuteStareAndKill(PlayerControllerB victim) { if ((Object)(object)globalAudio != (Object)null) { globalAudio.Stop(); } float timer = 0f; while (timer < killDelay) { if (victim.isPlayerDead || !victim.isPlayerControlled) { ResetPlayerInputClientRpc(victim.playerClientId); SyncStaringStateClientRpc(staring: false, ((Component)this).transform.position); yield break; } timer += Time.deltaTime; yield return null; } victim.KillPlayer(Vector3.up * 3f, true, (CauseOfDeath)0, 0, Vector3.zero, false); ResetPlayerInputClientRpc(victim.playerClientId); SyncStaringStateClientRpc(staring: false, ((Component)this).transform.position); } [ClientRpc] private void SyncStaringStateClientRpc(bool staring, Vector3 freezePosition) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_001c: Unknown result type (might be due to invalid IL or missing references) isStaring = staring; ((Component)this).transform.position = freezePosition; customServerPosition = freezePosition; base.serverPosition = freezePosition; } [ClientRpc] private void LockClientCameraClientRpc(ulong targetPlayerId) { PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; if (localPlayerController.playerClientId == targetPlayerId) { localPlayerController.disableLookInput = true; localPlayerController.disableMoveInput = true; if ((Object)(object)localAudio != (Object)null && (Object)(object)stareTheme != (Object)null) { localAudio.clip = stareTheme; localAudio.Play(); } ((MonoBehaviour)this).StartCoroutine(LocalCameraLockRoutine(localPlayerController)); } } private IEnumerator LocalCameraLockRoutine(PlayerControllerB localPlayer) { while (localPlayer.disableLookInput && !localPlayer.isPlayerDead) { if ((Object)(object)localPlayer.gameplayCamera != (Object)null) { Vector3 val = ((Component)this).transform.position - ((Component)localPlayer.gameplayCamera).transform.position; Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized); ((Component)localPlayer.gameplayCamera).transform.rotation = Quaternion.Slerp(((Component)localPlayer.gameplayCamera).transform.rotation, val2, 10f * Time.deltaTime); } yield return null; } } [ClientRpc] private void ResetPlayerInputClientRpc(ulong targetPlayerId) { PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; if (localPlayerController.playerClientId == targetPlayerId) { localPlayerController.disableLookInput = false; localPlayerController.disableMoveInput = false; } } [ServerRpc(RequireOwnership = false)] private void EndHuntServerRpc() { isHunting = false; if ((Object)(object)globalAudio != (Object)null) { globalAudio.Stop(); } if ((Object)(object)localAudio != (Object)null) { localAudio.Stop(); } if ((Object)(object)((NetworkBehaviour)this).NetworkObject != (Object)null && ((NetworkBehaviour)this).NetworkObject.IsSpawned) { ((NetworkBehaviour)this).NetworkObject.Despawn(true); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } } }