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 Pontso v1.1.0
plugins/K00PE-Pontsomod/K00PE.Pontso.dll
Decompiled 2 years 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.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using K00PE.Pontso.NetcodePatcher; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Pontso.Configuration; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [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("K00PE.Pontso")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0")] [assembly: AssemblyProduct("Pontso mod")] [assembly: AssemblyTitle("K00PE.Pontso")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 Pontso { public class PontsoAI : EnemyAI, INoiseListener { private enum VoiceClip { alert, chase, chatter, death, escape, hurt, lost, mock, panic, stun, victory } public enum AnimationState { Idle, Walk, Stun, Hurt, Attack, LookAround, Dead, Dancing } public enum LogicState { Chatting, Dancing, Roaming, Listening, Chasing, CatchingUp, Investigating, Panic } public Transform attackArea; private const float shakeRange = 8f; private const float killLaunchSpeed = 1.5f; private const float verticalKillLaunch = 0.5f; private float lastTouch; private const int touchDamage = 20; private const float touchCooldown = 0.5f; private const float touchSlowdown = 2f; private const float touchDuration = 1f; private float lastBonked; private const float bonkRecovery = 2f; private int bonkState; private bool ignorePlayers; private PlayerControllerB losPlayer; private Vector3? lastTargetPosition; private int lookAroundCount; private float timeSinceHeardNoise; private const float maxHearingRange = 20f; private const float minNoiseLoudness = 0.25f; private const float alertCooldown = 1.5f; private const float noiseCooldown = 0.5f; private float lastSpottedLocalPlayer; private float lastSpottedPlayer; private float lastSpottedMonster; private bool stingerPlayed; private bool playingAmnesia; private readonly float amnesiaFadeout = 20f; private readonly float stingerCooldown = 5f; private readonly float amnesiaMaxVolume = 0.75f; private float lastVoiceline; private const float voiceCooldown = 0.3f; public AudioSource SFX; public AudioSource AmnesiaSFX; public AudioSource MemeSFX; public AudioSource Voice; public AudioClip[] alertSound; public AudioClip[] chaseSound; public AudioClip[] chatterSound; public AudioClip[] deathSound; public AudioClip[] escapeSound; public AudioClip[] hurtSound; public AudioClip[] lostSound; public AudioClip[] mockSound; public AudioClip[] panicSound; public AudioClip[] stunSound; public AudioClip[] victorySound; public AudioClip[] stepSound; public AudioClip[] attackSound; public AudioClip[] memeSound; private LogicState _logicState; private PlayerControllerB localPlayer => GameNetworkManager.Instance.localPlayerController; public AnimationState animState { get { return (AnimationState)base.creatureAnimator.GetInteger("state"); } set { if (animState == AnimationState.Dead) { return; } if (((NetworkBehaviour)this).IsServer) { if (value != AnimationState.Walk) { base.agent.speed = 0f; } SyncAnimClientRpc((int)value); } else if (value == AnimationState.Idle) { base.creatureAnimator.SetInteger("state", (int)value); } } } public LogicState logicState { get { return _logicState; } set { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsServer) { return; } switch (value) { case LogicState.Panic: if (animState == AnimationState.Idle || animState == AnimationState.LookAround || animState == AnimationState.Dancing) { animState = AnimationState.Walk; } if (logicState != LogicState.Panic) { PlayVoiceServerRpc(8); } break; case LogicState.Chasing: if (animState != AnimationState.Attack && animState != AnimationState.Hurt && animState != AnimationState.Stun) { animState = AnimationState.Walk; } lastTargetPosition = ((Component)base.targetPlayer).transform.position; break; case LogicState.CatchingUp: if (animState == AnimationState.Idle || animState == AnimationState.LookAround) { animState = AnimationState.Walk; } if (logicState != LogicState.CatchingUp) { ((MonoBehaviour)this).StartCoroutine(BreakRoutine(LogicState.CatchingUp)); } break; case LogicState.Investigating: if (animState == AnimationState.Idle || animState == AnimationState.LookAround) { animState = AnimationState.Walk; } if (logicState != LogicState.Investigating) { ((MonoBehaviour)this).StartCoroutine(BreakRoutine(LogicState.Investigating)); } break; case LogicState.Listening: if (animState == AnimationState.Idle || animState == AnimationState.Walk) { animState = AnimationState.LookAround; } if (logicState != LogicState.Listening) { lookAroundCount = 3; if (Time.time - lastSpottedPlayer > 1.5f) { PlayVoiceServerRpc(6); } } break; case LogicState.Chatting: if (animState == AnimationState.Idle || animState == AnimationState.Walk || animState == AnimationState.Dancing) { animState = AnimationState.LookAround; } if (logicState != 0) { lookAroundCount = 3; PlayVoiceServerRpc(2); } break; case LogicState.Dancing: if (animState == AnimationState.Idle || animState == AnimationState.Walk || animState == AnimationState.LookAround) { animState = AnimationState.Dancing; } break; case LogicState.Roaming: if (animState == AnimationState.Idle || animState == AnimationState.LookAround || animState == AnimationState.Dancing) { animState = AnimationState.Walk; } if (logicState != LogicState.Roaming) { ((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null); ((MonoBehaviour)this).StartCoroutine(BreakRoutine(LogicState.Roaming)); } break; } _logicState = value; } } private AudioClip[] SelectVoice(VoiceClip v) { return v switch { VoiceClip.alert => alertSound, VoiceClip.chase => chaseSound, VoiceClip.chatter => chatterSound, VoiceClip.death => deathSound, VoiceClip.escape => escapeSound, VoiceClip.hurt => hurtSound, VoiceClip.lost => lostSound, VoiceClip.mock => mockSound, VoiceClip.panic => panicSound, VoiceClip.stun => stunSound, VoiceClip.victory => victorySound, _ => chatterSound, }; } [ServerRpc(RequireOwnership = false)] private void PlayVoiceServerRpc(int voiceID) { //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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1479079518u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, voiceID); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1479079518u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && !(Time.time - lastVoiceline <= 0.3f)) { lastVoiceline = Time.time; AudioClip[] array = SelectVoice((VoiceClip)voiceID); int clipID = Random.RandomRangeInt(0, array.Length); PlayVoiceClientRpc(voiceID, clipID); } } } [ClientRpc] private void PlayVoiceClientRpc(int voiceID, int clipID) { //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_007e: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2345384742u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, voiceID); BytePacker.WriteValueBitPacked(val2, clipID); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2345384742u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { Voice.Stop(); Voice.clip = SelectVoice((VoiceClip)voiceID)[clipID]; Voice.Play(); } } } [ServerRpc(RequireOwnership = false)] private void PlaySoundServerRpc(int clipID) { //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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2651187818u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, clipID); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2651187818u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { PlaySoundClientRpc(clipID); } } } [ClientRpc] private void PlaySoundClientRpc(int clipID) { //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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1581556669u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, clipID); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1581556669u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { SFX.PlayOneShot(memeSound[clipID]); } } } [ServerRpc(RequireOwnership = false)] private void PlayMemeSoundServerRpc(int clipID) { //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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4146826447u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, clipID); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4146826447u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { PlayMemeSoundClientRpc(clipID); } } } [ClientRpc] private void PlayMemeSoundClientRpc(int clipID) { //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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2498101435u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, clipID); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2498101435u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { MemeSFX.PlayOneShot(memeSound[clipID]); } } } private void PlayRandomSFX(AudioClip[] sound) { SFX.PlayOneShot(sound[Random.RandomRangeInt(0, sound.Length)]); } [ClientRpc] public void SyncAnimClientRpc(int state) { //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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4046748191u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, state); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4046748191u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { base.creatureAnimator.SetInteger("state", state); } } } public void WalkStartEvent() { if (((NetworkBehaviour)this).IsServer) { base.agent.speed = ((logicState == LogicState.Panic) ? 8f : 5f); base.agent.angularSpeed = 360f; base.agent.acceleration = 30f; } } public void TakeStepEvent() { PlayRandomSFX(stepSound); } public void LookEndEvent() { if (((NetworkBehaviour)this).IsServer) { if (lookAroundCount == 3 && animState == AnimationState.LookAround) { PlaySoundClientRpc(6); } lookAroundCount--; if (lookAroundCount <= 0) { PlayVoiceServerRpc(2); logicState = LogicState.Roaming; } } } public void DanceEndEvent() { if (((NetworkBehaviour)this).IsServer) { logicState = LogicState.Chatting; } } private LogicState DecideLogic() { //IL_004d: 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) if (base.enemyHP < 4) { return LogicState.Panic; } if ((Object)(object)base.targetPlayer != (Object)null) { return LogicState.Chasing; } if (logicState == LogicState.Chasing) { return LogicState.CatchingUp; } if (logicState == LogicState.Investigating || logicState == LogicState.CatchingUp) { if (!lastTargetPosition.HasValue) { return LogicState.Listening; } if (Vector3.Distance(lastTargetPosition.Value, ((Component)this).transform.position) < 2.5f) { return LogicState.Listening; } return logicState; } if (logicState == LogicState.Listening) { return LogicState.Listening; } if (logicState == LogicState.Dancing) { return LogicState.Dancing; } if (logicState == LogicState.Chatting) { return LogicState.Chatting; } return LogicState.Roaming; } private IEnumerator BreakRoutine(LogicState oldState) { yield return (object)new WaitForSeconds((float)Random.Range(10, 35)); if (logicState == oldState) { logicState = LogicState.Chatting; } } private void Log(object log) { try { PontsoModPlugin.LogInfo("\n\n-----------------------------\n" + log.ToString() + "\n-----------------------------\n\n"); } catch (Exception) { Debug.Log(log); } } public override void Start() { ((EnemyAI)this).Start(); Log("Pontso spawned"); logicState = LogicState.Roaming; } public override void Update() { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).Update(); if (playingAmnesia) { AmnesiaSFX.volume = amnesiaMaxVolume * (amnesiaFadeout + lastSpottedLocalPlayer - Time.time) / amnesiaFadeout; } if (playingAmnesia && Time.time - lastSpottedLocalPlayer > amnesiaFadeout) { AmnesiaSFX.Stop(); playingAmnesia = false; } if (base.isEnemyDead) { return; } if (((ButtonControl)Keyboard.current.lKey).wasPressedThisFrame && ((NetworkBehaviour)this).IsServer) { ignorePlayers = !ignorePlayers; } if (localPlayer.HasLineOfSightToPosition(base.eye.position, 50f, 60, -1f)) { lastSpottedMonster = Time.time; localPlayer.IncreaseFearLevelOverTime(1f, 1f); if (!stingerPlayed) { MemeSFX.PlayOneShot(memeSound[3]); stingerPlayed = true; } } if (stingerPlayed && Time.time - lastSpottedMonster > stingerCooldown) { stingerPlayed = false; } if (((NetworkBehaviour)this).IsServer && !ignorePlayers && animState != AnimationState.Dancing && logicState == LogicState.Chasing && Time.time - lastSpottedPlayer > 1.5f) { PlayVoiceServerRpc(1); } if (((NetworkBehaviour)this).IsServer && !ignorePlayers && animState != AnimationState.Dancing && (Object)(object)losPlayer != (Object)null) { lastSpottedPlayer = Time.time; } if (!ignorePlayers && animState != AnimationState.Dancing && (Object)(object)losPlayer != (Object)null && (Object)(object)losPlayer == (Object)(object)localPlayer) { lastSpottedLocalPlayer = Time.time; localPlayer.IncreaseFearLevelOverTime(1f, 1f); if (!playingAmnesia) { AmnesiaSFX.volume = amnesiaMaxVolume; AmnesiaSFX.loop = true; AmnesiaSFX.clip = memeSound[1]; AmnesiaSFX.Play(); playingAmnesia = true; } } } public void FixedUpdate() { //IL_00a1: 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_014e: Unknown result type (might be due to invalid IL or missing references) if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead || base.stunNormalizedTimer > 0f) { return; } losPlayer = ((ignorePlayers || animState == AnimationState.Dancing) ? null : ((EnemyAI)this).CheckLineOfSightForPlayer(130f, 60, 4)); if (((NetworkBehaviour)this).IsServer) { if (base.stunNormalizedTimer <= 0f && animState == AnimationState.Stun) { animState = AnimationState.Idle; } if (logicState == LogicState.Panic) { ((EnemyAI)this).StopSearch(base.currentSearch, true); base.targetPlayer = ((EnemyAI)this).GetClosestPlayer(true, false, false); Transform val = ((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)base.targetPlayer).transform.position, true, 0, false); ((EnemyAI)this).SetDestinationToPosition(val.position, false); } base.targetPlayer = losPlayer; if (logicState == LogicState.Panic && (Object)(object)base.targetPlayer != (Object)null && Time.time - lastVoiceline > 1.5f) { PlayVoiceServerRpc(8); } logicState = DecideLogic(); if (logicState == LogicState.Chasing) { ((EnemyAI)this).StopSearch(base.currentSearch, true); ((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer); } if (logicState == LogicState.Investigating || logicState == LogicState.CatchingUp) { ((EnemyAI)this).StopSearch(base.currentSearch, true); ((EnemyAI)this).SetDestinationToPosition(lastTargetPosition.Value, false); } } } public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesNoisePlayedInOneSpot = 0, int noiseID = 0) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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) ((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesNoisePlayedInOneSpot, noiseID); if (!((NetworkBehaviour)this).IsServer || base.isEnemyDead || base.stunNormalizedTimer > 0f || noiseID == 7 || noiseID == 546 || timesNoisePlayedInOneSpot > 15 || logicState == LogicState.Chasing || logicState == LogicState.Panic || logicState == LogicState.CatchingUp) { return; } float num = Vector3.Distance(((Component)this).transform.position, noisePosition); if (Physics.Linecast(((Component)this).transform.position, noisePosition, 256)) { num *= 2f; } if (noiseLoudness < 0.25f || num > 20f || Time.time - timeSinceHeardNoise <= 0.5f) { return; } if (Time.time - timeSinceHeardNoise > 1.5f && Time.time - lastSpottedPlayer > 1.5f) { PlayVoiceServerRpc(0); } timeSinceHeardNoise = Time.time; ((EnemyAI)this).StopSearch(base.currentSearch, true); lastTargetPosition = noisePosition; if (num < 3f && ((EnemyAI)this).CheckLineOfSightForPosition(noisePosition, 130f, 60, 3f, (Transform)null)) { if (noiseID == 5) { logicState = LogicState.Dancing; } } else { logicState = LogicState.Investigating; ((EnemyAI)this).SetDestinationToPosition(noisePosition, false); } } public override void OnCollideWithPlayer(Collider other) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).OnCollideWithPlayer(other); PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false); if ((Object)(object)val != (Object)null && Time.time - lastTouch > 0.5f) { lastTouch = Time.time; val.DamagePlayer(20, true, true, (CauseOfDeath)0, 0, false, default(Vector3)); ((MonoBehaviour)this).StartCoroutine(ApplySlowdown(val)); } } private IEnumerator ApplySlowdown(PlayerControllerB player) { player.isMovementHindered++; player.hinderedMultiplier *= 2f; yield return (object)new WaitForSeconds(1f); if ((Object)(object)player != (Object)null && player.isMovementHindered > 0 && player.hinderedMultiplier >= 2f) { player.isMovementHindered = Mathf.Clamp(player.isMovementHindered - 1, 0, 1000); player.hinderedMultiplier /= 2f; } } public void SwingAtPlayer() { if (!base.isEnemyDead && !(base.stunNormalizedTimer > 0f) && ((NetworkBehaviour)this).IsServer && animState != AnimationState.Attack && animState != AnimationState.Hurt) { animState = AnimationState.Attack; } } public void AttackEvent() { //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) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_00ac: 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_00bc: 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_00c3: 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_00d6: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_0122: Unknown result type (might be due to invalid IL or missing references) if (base.isEnemyDead || base.stunNormalizedTimer > 0f) { return; } PlayRandomSFX(attackSound); if (Vector3.Distance(((Component)localPlayer.gameplayCamera).transform.position, base.eye.position) < 8f) { HUDManager.Instance.ShakeCamera((ScreenShakeType)1); } int num = 8; Collider[] array = Physics.OverlapBox(attackArea.position, attackArea.localScale, Quaternion.identity, num); foreach (Collider val in array) { PlayerControllerB val2 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(val, false, false); if ((Object)(object)val2 != (Object)null) { Vector3 val3 = ((Component)val2.gameplayCamera).transform.position - attackArea.position; Vector3 val4 = new Vector3(val3.x, val3.y, 0f); Vector3 normalized = ((Vector3)(ref val4)).normalized; val4 = new Vector3(normalized.x, 0.5f, normalized.z); Vector3 val5 = ((Vector3)(ref val4)).normalized * 1.5f; val4 = default(Vector3); val2.KillPlayer(val5, true, (CauseOfDeath)1, 0, val4); PlaySoundServerRpc(5); PlayMemeSoundServerRpc(0); PlayVoiceServerRpc(10); } } } private bool PontsoGetsBonked() { int num = (int)((Time.time - lastBonked) / 2f); bonkState -= num; if (bonkState < 0) { bonkState = 0; } int num2 = ((bonkState == 0) ? 1 : bonkState); bool num3 = Random.Range(0f, 1f) <= 1f / (float)num2; if (num3) { bonkState++; lastBonked = Time.time; } return num3; } public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { ((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID); if (base.isEnemyDead) { return; } base.enemyHP -= force; PlayVoiceServerRpc(5); if (!((NetworkBehaviour)this).IsServer) { return; } if (animState == AnimationState.Attack) { if (PontsoGetsBonked()) { animState = AnimationState.Hurt; } } else { animState = AnimationState.Hurt; } if (base.enemyHP <= 0 && !base.isEnemyDead) { ((MonoBehaviour)this).StopCoroutine(base.searchCoroutine); ((EnemyAI)this).KillEnemyOnOwnerClient(false); } } public override void SetEnemyStunned(bool setToStunned, float setToStunTime = 1f, PlayerControllerB setStunnedByPlayer = null) { ((EnemyAI)this).SetEnemyStunned(setToStunned, setToStunTime, setStunnedByPlayer); animState = AnimationState.Stun; PlayVoiceServerRpc(9); } public override void KillEnemy(bool destroy = false) { ((EnemyAI)this).KillEnemy(destroy); animState = AnimationState.Dead; PlayVoiceServerRpc(3); PlaySoundServerRpc(2); } public void DyingEndEvent() { base.creatureAnimator.speed = 0f; } protected override void __initializeVariables() { ((EnemyAI)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_PontsoAI() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(1479079518u, new RpcReceiveHandler(__rpc_handler_1479079518)); NetworkManager.__rpc_func_table.Add(2345384742u, new RpcReceiveHandler(__rpc_handler_2345384742)); NetworkManager.__rpc_func_table.Add(2651187818u, new RpcReceiveHandler(__rpc_handler_2651187818)); NetworkManager.__rpc_func_table.Add(1581556669u, new RpcReceiveHandler(__rpc_handler_1581556669)); NetworkManager.__rpc_func_table.Add(4146826447u, new RpcReceiveHandler(__rpc_handler_4146826447)); NetworkManager.__rpc_func_table.Add(2498101435u, new RpcReceiveHandler(__rpc_handler_2498101435)); NetworkManager.__rpc_func_table.Add(4046748191u, new RpcReceiveHandler(__rpc_handler_4046748191)); } private static void __rpc_handler_1479079518(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 voiceID = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref voiceID); target.__rpc_exec_stage = (__RpcExecStage)1; ((PontsoAI)(object)target).PlayVoiceServerRpc(voiceID); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2345384742(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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) { int voiceID = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref voiceID); int clipID = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref clipID); target.__rpc_exec_stage = (__RpcExecStage)2; ((PontsoAI)(object)target).PlayVoiceClientRpc(voiceID, clipID); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2651187818(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 clipID = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref clipID); target.__rpc_exec_stage = (__RpcExecStage)1; ((PontsoAI)(object)target).PlaySoundServerRpc(clipID); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1581556669(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 clipID = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref clipID); target.__rpc_exec_stage = (__RpcExecStage)2; ((PontsoAI)(object)target).PlaySoundClientRpc(clipID); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_4146826447(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 clipID = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref clipID); target.__rpc_exec_stage = (__RpcExecStage)1; ((PontsoAI)(object)target).PlayMemeSoundServerRpc(clipID); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2498101435(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 clipID = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref clipID); target.__rpc_exec_stage = (__RpcExecStage)2; ((PontsoAI)(object)target).PlayMemeSoundClientRpc(clipID); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_4046748191(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 state = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref state); target.__rpc_exec_stage = (__RpcExecStage)2; ((PontsoAI)(object)target).SyncAnimClientRpc(state); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "PontsoAI"; } } public class PontsoAnimEvents : MonoBehaviour { public PontsoAI pontsoAI; public void AttackEvent() { pontsoAI.AttackEvent(); } public void AttackEndEvent() { if (pontsoAI.animState == PontsoAI.AnimationState.Attack) { pontsoAI.animState = PontsoAI.AnimationState.Idle; } } public void HurtEndEvent() { if (pontsoAI.animState == PontsoAI.AnimationState.Hurt) { pontsoAI.animState = PontsoAI.AnimationState.Idle; } } public void DyingEndEvent() { pontsoAI.DyingEndEvent(); } public void WalkStartEvent() { if (pontsoAI.animState == PontsoAI.AnimationState.Walk) { pontsoAI.WalkStartEvent(); } } public void TakeStepEvent() { pontsoAI.TakeStepEvent(); } public void LookEndEvent() { pontsoAI.LookEndEvent(); } public void DanceEndEvent() { pontsoAI.DanceEndEvent(); } } public class PontsoAttackCollider : MonoBehaviour { public PontsoAI pontsoAI; private void OnTriggerStay(Collider other) { if (((Component)other).CompareTag("Player")) { pontsoAI.SwingAtPlayer(); } } } [BepInPlugin("com.koope.lethalcompany.pontsomod", "Pontso Mod", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class PontsoModPlugin : BaseUnityPlugin { public const string VERSION = "1.0.0"; public const string NAME = "Pontso Mod"; public const string GUID = "com.koope.lethalcompany.pontsomod"; public PluginConfig modConfig; public static PontsoModPlugin Instance; private void Awake() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) Instance = this; LogInfo("\n\n------ Initializing Pontso Mod ------\n"); modConfig = new PluginConfig(((BaseUnityPlugin)this).Config); InitializeNetworkBehaviours(); LoadAssets(); LogInfo("Applying patches..."); new Harmony("com.koope.lethalcompany.pontsomod").PatchAll(); LogInfo("Patches applied!"); LogInfo("\n------ Pontso mod configured ------\n\n"); } public static void LoadAssets() { LogInfo("Loading assets..."); string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "pontsomod"); AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { LogError("Failed to load assets from path: " + text); return; } int num = 200; EnemyType val2 = val.LoadAsset<EnemyType>("pontsoenemytype.asset"); TerminalNode val3 = val.LoadAsset<TerminalNode>("pontsoenemytn.asset"); TerminalKeyword val4 = val.LoadAsset<TerminalKeyword>("pontsoenemytk.asset"); NetworkPrefabs.RegisterNetworkPrefab(val2.enemyPrefab); Enemies.RegisterEnemy(val2, num, (LevelTypes)(-1), val3, val4); LogInfo("Assets loaded"); } internal static void LogDebug(string message) { Instance.Log(message, (LogLevel)32); } internal static void LogInfo(string message) { Instance.Log(message, (LogLevel)16); } internal static void LogWarning(string message) { Instance.Log(message, (LogLevel)4); } internal static void LogError(string message) { Instance.Log(message, (LogLevel)2); } internal static void LogError(Exception ex) { Instance.Log(ex.Message + "\n" + ex.StackTrace, (LogLevel)2); } private void Log(string message, LogLevel logLevel) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((BaseUnityPlugin)this).Logger.Log(logLevel, (object)message); } private static void InitializeNetworkBehaviours() { Type[] types = Assembly.GetExecutingAssembly().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 static class PluginInfo { public const string PLUGIN_GUID = "K00PE.Pontso"; public const string PLUGIN_NAME = "Pontso mod"; public const string PLUGIN_VERSION = "1.1.0"; } } namespace Pontso.Configuration { public class PluginConfig { public readonly ConfigEntry<int> spawnWeight; public PluginConfig(ConfigFile cfg) { cfg.SaveOnConfigSet = false; spawnWeight = cfg.Bind<int>("General", "Spawn weight", 40, "The spawn chance weight for Pontso, relative to other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common."); ClearUnusedEntries(cfg); cfg.SaveOnConfigSet = true; } private void ClearUnusedEntries(ConfigFile cfg) { ((Dictionary<ConfigDefinition, string>)((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(cfg, null)).Clear(); cfg.Save(); } } } namespace K00PE.Pontso.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }