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 Evil Tim v1.0.0
BepInEx/plugins/EvilTim/EvilTim.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; 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 System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using EvilTim.NetcodePatcher; using GameNetcodeStuff; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.Rendering; [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("EvilTim")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EvilTim")] [assembly: AssemblyTitle("EvilTim")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace EvilTim { public class EvilTimAI : EnemyAI { public const int StateNormal = 0; public const int StateAwareness = 1; public const int StateAggressive = 2; public const int StateMaxFreak = 3; public const byte ActNone = 0; public const byte ActLookAround = 1; public const byte ActVomit = 2; public const float VomitWindup = 0.35f; public const float VomitTail = 0.3f; private const byte HurtFlail = 0; private const byte HurtVomit = 1; public TimVisual visual; public ScanNodeProperties scanNode; [NonSerialized] public MeshRenderer mapDot; [NonSerialized] public byte act; [NonSerialized] public float actStartTime; [NonSerialized] public float actDuration; [NonSerialized] public int watchedPlayerId = -1; [NonSerialized] public float awarenessDuration = 10f; private float _nextVisibilityCheckAt; private int _deathClip = -1; private bool _deathPresented; private AISearchRoutine _roam; private float _walkSpeed = 4.6f; private bool _hostReady; private bool _investigating; private Vector3 _investigatePosition; private float _investigateUntil; private float _nextPauseAt; private float _ignorePlayersUntil; private float _seenFor; private float _lastSeenAt; private Vector3 _lastKnownPosition; private float _aggressiveSince; private float _nextVomitAt; private float _nextVomitTickAt; private float _nextJukeAt; private Vector3 _jukeOffset; private float _jukeSpeed = 1f; private float _noTargetSince = -1f; private float _lastContactAt; private float _nextVoiceAt; private int _lastVoiceClip = -1; private float _nextFlailCheckAt; private float[] _lastHurtAt = new float[0]; private bool[] _wasDead = new bool[0]; private int[] _normalClips; private int[] _awareClips; private int[] _aggressiveClips; private int[] _freakClips; private int[] _vomitClips; private static TimConfig Cfg => Plugin.Cfg; public override void Awake() { TimContent.EnsureStates(this); try { ((EnemyAI)this).Awake(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("EnemyAI.Awake threw: " + ex.Message)); } } public override void Start() { TimContent.EnsureStates(this); ((EnemyAI)this).Start(); TimAssets.EnsureRuntime(); if ((Object)(object)visual != (Object)null) { visual.ApplyMaterials(); } mapDot = TimContent.CreateMapDot(((Component)this).transform); SetupAudio(); ChooseNavigationNodes(); if ((Object)(object)scanNode != (Object)null && (Object)(object)TimContent.InfoNode != (Object)null && TimContent.InfoNode.creatureFileID >= 0) { scanNode.creatureScanID = TimContent.InfoNode.creatureFileID; } int value = Cfg.Health.Value; base.enemyHP = ((value <= 0) ? 1 : value); TimContent.Track(this); if (((NetworkBehaviour)this).IsServer) { HostInit(); } } public override void OnDestroy() { TimContent.Untrack(this); ((EnemyAI)this).OnDestroy(); } private void SetupAudio() { float volume = TimConfig.Clamp(Cfg.Volume.Value, 0f, 1f); float maxDistance = TimConfig.Clamp(Cfg.AudioRange.Value, 5f, 150f); AudioMixerGroup val = null; try { if ((Object)(object)SoundManager.Instance != (Object)null && (Object)(object)SoundManager.Instance.diageticMixer != (Object)null) { AudioMixerGroup[] array = SoundManager.Instance.diageticMixer.FindMatchingGroups("SFX"); if (array == null || array.Length == 0) { array = SoundManager.Instance.diageticMixer.FindMatchingGroups("Master"); } if (array != null && array.Length != 0) { val = array[0]; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not find the game's SFX mixer group: " + ex.Message)); } AudioSource[] array2 = (AudioSource[])(object)new AudioSource[2] { base.creatureVoice, base.creatureSFX }; foreach (AudioSource val2 in array2) { if (!((Object)(object)val2 == (Object)null)) { val2.volume = volume; val2.maxDistance = maxDistance; if ((Object)(object)val != (Object)null) { val2.outputAudioMixerGroup = val; } } } int[] array3 = TimAssets.ResolveClips(Cfg.DeathSound.Value, "Death sound"); _deathClip = ((array3.Length != 0) ? array3[0] : (-1)); base.dieSFX = TimAssets.SilentClip; } private void ChooseNavigationNodes() { //IL_0115: 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) GameObject[] array = null; GameObject[] array2 = null; if ((Object)(object)RoundManager.Instance != (Object)null) { array = RoundManager.Instance.insideAINodes; array2 = RoundManager.Instance.outsideAINodes; } if (array == null || array.Length == 0) { array = GameObject.FindGameObjectsWithTag("AINode"); } if (array2 == null || array2.Length == 0) { array2 = GameObject.FindGameObjectsWithTag("OutsideAINode"); } float num = NearestNodeDistance(array); float num2 = NearestNodeDistance(array2); bool flag = ((!float.IsPositiveInfinity(num) || !float.IsPositiveInfinity(num2)) ? (num2 < num) : ((Object)(object)base.enemyType != (Object)null && base.enemyType.isOutsideEnemy)); try { ((EnemyAI)this).SetEnemyOutside(flag); } catch (Exception ex) { Plugin.Log.LogWarning((object)("EnemyAI.SetEnemyOutside threw: " + ex.Message)); } GameObject[] array3 = (flag ? array2 : array); if (array3 != null && array3.Length != 0) { base.allAINodes = array3; } base.isOutside = flag; Plugin.Log.LogInfo((object)("Evil Tim spawned " + (flag ? "outside" : "inside") + " at " + ((object)((Component)this).transform.position/*cast due to .constrained prefix*/).ToString() + " (nearest indoor node " + num.ToString("0.0") + " m, outdoor " + num2.ToString("0.0") + " m).")); } private float NearestNodeDistance(GameObject[] nodes) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0037: Unknown result type (might be due to invalid IL or missing references) float num = float.PositiveInfinity; if (nodes == null) { return num; } for (int i = 0; i < nodes.Length; i++) { if (!((Object)(object)nodes[i] == (Object)null)) { Vector3 val = nodes[i].transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; } } } if (!float.IsPositiveInfinity(num)) { return Mathf.Sqrt(num); } return num; } private void KeepVisible() { if (Time.time < _nextVisibilityCheckAt || (Object)(object)visual == (Object)null || visual.bodyRenderers == null) { return; } _nextVisibilityCheckAt = Time.time + 0.5f; if ((Object)(object)GameNetworkManager.Instance == (Object)null) { return; } PlayerControllerB val = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)val == (Object)null) { return; } if (val.isPlayerDead && (Object)(object)val.spectatedPlayerScript != (Object)null) { val = val.spectatedPlayerScript; } if (val.isInsideFactory == base.isOutside) { return; } MeshRenderer[] bodyRenderers = visual.bodyRenderers; foreach (MeshRenderer val2 in bodyRenderers) { if (!((Object)(object)val2 == (Object)null)) { if (((Component)val2).gameObject.layer != TimContent.EnemiesLayer) { ((Component)val2).gameObject.layer = TimContent.EnemiesLayer; } if (!((Renderer)val2).enabled) { ((Renderer)val2).enabled = true; } } } } private void HostInit() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown _roam = new AISearchRoutine(); if (_roam.unsearchedNodes == null) { _roam.unsearchedNodes = new List<GameObject>(); } _roam.searchWidth = 200f; _roam.searchPrecision = 5f; _roam.loopSearch = true; _roam.randomized = true; PlayerControllerB[] array = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.allPlayerScripts : null); int num = ((array != null) ? array.Length : 0); _lastHurtAt = new float[num]; _wasDead = new bool[num]; for (int i = 0; i < num; i++) { _lastHurtAt[i] = -100f; _wasDead[i] = (Object)(object)array[i] == (Object)null || array[i].isPlayerDead; if ((Object)(object)array[i] != (Object)null && array[i].movementSpeed > 1f) { _walkSpeed = Mathf.Clamp(array[i].movementSpeed, 3f, 8f); } } _normalClips = TimAssets.ResolveClips(Cfg.NormalLines.Value, "Wandering voice lines"); _awareClips = TimAssets.ResolveClips(Cfg.AwarenessLines.Value, "Awareness voice lines"); _aggressiveClips = TimAssets.ResolveClips(Cfg.AggressiveLines.Value, "Aggressive voice lines"); _freakClips = TimAssets.ResolveClips(Cfg.MaxFreakLines.Value, "Maximum Freak voice lines"); _vomitClips = TimAssets.ResolveClips(Cfg.VomitSounds.Value, "Vomiting sounds"); float time = Time.time; _nextVoiceAt = time + Random.Range(5f, 12f); _nextPauseAt = time + Random.Range(10f, 22f); _hostReady = true; ApplyMotionForState(0); } public override void Update() { //IL_00db: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).Update(); KeepVisible(); if (!((NetworkBehaviour)this).IsServer || !_hostReady || base.isEnemyDead) { return; } float time = Time.time; if (act != 0 && time >= actStartTime + actDuration) { SetAct(0, 0f, -1); } WatchForKills(time); if (!base.isEnemyDead && !(base.stunNormalizedTimer > 0f)) { if (act == 2) { VomitTick(time); } else if (base.currentBehaviourStateIndex >= 2) { FlailTick(time); } if ((Object)(object)base.agent != (Object)null && base.agent.speed < 0.05f && (Object)(object)base.targetPlayer != (Object)null && (base.currentBehaviourStateIndex == 1 || act == 2)) { TurnTowards(((Component)base.targetPlayer).transform.position, (act == 2) ? 110f : 240f); } } } private void TurnTowards(Vector3 point, float degreesPerSecond) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = point - ((Component)this).transform.position; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f)) { ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, Quaternion.LookRotation(val), degreesPerSecond * Time.deltaTime); } } public override void DoAIInterval() { ((EnemyAI)this).DoAIInterval(); if (!((NetworkBehaviour)this).IsServer || !_hostReady || base.isEnemyDead || (Object)(object)base.agent == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null) { return; } float time = Time.time; if (StartOfRound.Instance.allPlayersDead) { if (base.currentBehaviourStateIndex != 0) { CalmDown(time, afterKill: false); } return; } if (base.stunNormalizedTimer > 0f) { base.agent.speed = 0f; return; } switch (base.currentBehaviourStateIndex) { case 0: NormalTick(time); break; case 1: AwarenessTick(time); break; case 2: AggressiveTick(time); break; case 3: MaxFreakTick(time); break; } VoiceTick(time); } private void NormalTick(float now) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) bool flag = act == 1; base.agent.speed = (flag ? 0f : (_walkSpeed * Cfg.NormalSpeed.Value)); if (now >= _ignorePlayersUntil) { PlayerControllerB val = FindVisiblePlayer(Cfg.SightAngle.Value, Cfg.SightRange.Value); if ((Object)(object)val != (Object)null) { EnterAwareness(val, now); return; } } if (_investigating) { Vector3 val2 = _investigatePosition - ((Component)this).transform.position; float num = Mathf.Abs(val2.y); val2.y = 0f; bool flag2 = ((Vector3)(ref val2)).magnitude < 2.5f && num < 4f; bool flag3 = base.agent.isOnNavMesh && !base.agent.pathPending && base.agent.remainingDistance < 1f; if (flag2 || flag3 || now >= _investigateUntil) { _investigating = false; SetAct(1, 3.2f, -1); _nextPauseAt = now + Random.Range(14f, 26f); } } else if (!flag) { if (!base.currentSearch.inProgress && base.allAINodes != null && base.allAINodes.Length != 0) { ((EnemyAI)this).StartSearch(((Component)this).transform.position, _roam); } if (now >= _nextPauseAt) { SetAct(1, Random.Range(2.6f, 4.6f), -1); _nextPauseAt = now + Random.Range(12f, 26f); } } } public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID); if (!((NetworkBehaviour)this).IsServer || !_hostReady || base.isEnemyDead || base.stunNormalizedTimer > 0f || base.currentBehaviourStateIndex != 0) { return; } float time = Time.time; if (!(time < _ignorePlayersUntil) && !(Vector3.Distance(((Component)this).transform.position, noisePosition) > Cfg.HearingDistance.Value) && NoiseCameFromPlayer(noisePosition)) { _investigating = true; _investigatePosition = noisePosition; _investigateUntil = time + 25f; if (act == 1) { SetAct(0, 0f, -1); } if (base.currentSearch != null && base.currentSearch.inProgress) { ((EnemyAI)this).StopSearch(base.currentSearch, true); } GoTo(noisePosition); } } private bool NoiseCameFromPlayer(Vector3 noisePosition) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && ((EnemyAI)this).PlayerIsTargetable(val, false, false, true)) { Vector3 val2 = ((Component)val).transform.position - noisePosition; if (((Vector3)(ref val2)).sqrMagnitude < 36f) { return true; } } } return false; } private void EnterNormal(float now, bool investigateLastKnown) { //IL_005b: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) base.targetPlayer = null; base.movingTowardsTargetPlayer = false; SetWatchedPlayer(-1); if (act != 0) { SetAct(0, 0f, -1); } SetState(0); ApplyMotionForState(0); _nextPauseAt = now + Random.Range(10f, 22f); if (investigateLastKnown) { _investigating = true; _investigatePosition = _lastKnownPosition; _investigateUntil = now + 20f; if (base.currentSearch != null && base.currentSearch.inProgress) { ((EnemyAI)this).StopSearch(base.currentSearch, true); } GoTo(_lastKnownPosition); } else { _investigating = false; if (base.allAINodes != null && base.allAINodes.Length != 0) { ((EnemyAI)this).StartSearch(((Component)this).transform.position, _roam); } } } private void EnterAwareness(PlayerControllerB player, float now) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (base.currentSearch != null && base.currentSearch.inProgress) { ((EnemyAI)this).StopSearch(base.currentSearch, true); } _investigating = false; base.targetPlayer = player; _seenFor = 0f; _lastSeenAt = now; _lastKnownPosition = ((Component)player).transform.position; if (act != 0) { SetAct(0, 0f, -1); } SetWatchedPlayer((int)player.playerClientId); SetState(1); ApplyMotionForState(1); _nextVoiceAt = now + 0.5f; } private void AwarenessTick(float now) { //IL_008c: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB targetPlayer = base.targetPlayer; bool flag = (Object)(object)targetPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(targetPlayer, false, false, true); if (flag && CanSee(targetPlayer, 180f, Mathf.Max(Cfg.SightRange.Value, 10f) + 10f)) { _seenFor += now - Mathf.Max(_lastSeenAt, now - base.AIIntervalTime * 2f); _lastSeenAt = now; _lastKnownPosition = ((Component)targetPlayer).transform.position; if (_seenFor >= Cfg.AwarenessDuration.Value) { EnterAggressive(now); return; } float num = FlatDistance(((Component)targetPlayer).transform.position); if (num > 3.2f) { base.agent.speed = _walkSpeed * Cfg.AwarenessSpeed.Value; GoTo(((Component)targetPlayer).transform.position); } else { base.agent.speed = 0f; } } else if (!flag || now - _lastSeenAt > 0.8f) { EnterNormal(now, flag || _lastKnownPosition != Vector3.zero); } } private void EnterAggressive(float now) { if (base.currentSearch != null && base.currentSearch.inProgress) { ((EnemyAI)this).StopSearch(base.currentSearch, true); } _investigating = false; if (act != 0) { SetAct(0, 0f, -1); } _aggressiveSince = now; _nextVomitAt = now + 1.2f; _nextJukeAt = 0f; _noTargetSince = -1f; SetWatchedPlayer(-1); SetState(2); ApplyMotionForState(2); _nextVoiceAt = now; } private void AggressiveTick(float now) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) if (act == 2) { base.agent.speed = 0f; return; } if (now - _aggressiveSince >= Cfg.AggressiveDuration.Value) { EnterMaxFreak(now); return; } PlayerControllerB val = NearestTargetablePlayer(); if ((Object)(object)val == (Object)null) { base.agent.speed = 0f; if (_noTargetSince < 0f) { _noTargetSince = now; } else if (now - _noTargetSince > 3f) { CalmDown(now, afterKill: false); } return; } _noTargetSince = -1f; base.targetPlayer = val; float num = FlatDistance(((Component)val).transform.position); if (now >= _nextVomitAt && num <= Cfg.VomitRange.Value && num > 1.2f && CanSee(val, 180f, Cfg.VomitRange.Value + 2f)) { StartVomit(now); return; } if (now >= _nextJukeAt) { Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; val2.y = 0f; Vector3 val3 = Vector3.Cross(Vector3.up, ((Vector3)(ref val2)).normalized); float num2 = Mathf.Clamp(num / 5f, 0.15f, 1f); _jukeOffset = val3 * Random.Range(-4f, 4f) * num2; _jukeSpeed = Random.Range(0.7f, 1.35f); _nextJukeAt = now + Random.Range(0.45f, 1.1f); } base.agent.speed = _walkSpeed * Cfg.AggressiveSpeed.Value * _jukeSpeed; GoTo(((Component)val).transform.position + _jukeOffset); } private void StartVomit(float now) { int num = PickClip(_vomitClips, -1); float num2 = ((num >= 0) ? TimAssets.ClipLength(num) : 2.2f); float num3 = Mathf.Clamp(num2, 1.6f, 3.4f); base.agent.speed = 0f; SetAct(2, num3, num); _nextVomitTickAt = now + 0.35f + 0.1f; _nextVomitAt = now + num3 + Random.Range(2f, 3.5f); } private void VomitTick(float now) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (now < _nextVomitTickAt || now > actStartTime + actDuration - 0.3f) { return; } _nextVomitTickAt = now + 0.5f; int value = Cfg.VomitDamage.Value; if (value <= 0) { return; } float value2 = Cfg.VomitRange.Value; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; for (int i = 0; i < allPlayerScripts.Length; i++) { PlayerControllerB val = allPlayerScripts[i]; if ((Object)(object)val == (Object)null || !((EnemyAI)this).PlayerIsTargetable(val, false, false, true)) { continue; } Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; if (!(Mathf.Abs(val2.y) > 3f)) { val2.y = 0f; float magnitude = ((Vector3)(ref val2)).magnitude; if (!(magnitude > value2) && (!(magnitude > 1f) || !(Vector3.Angle(((Component)this).transform.forward, val2) > 28f)) && ClearLineTo(val)) { Hurt(i, value, ((Vector3)(ref val2)).normalized * 3f, 1, now); } } } } private void EnterMaxFreak(float now) { if (act != 0) { SetAct(0, 0f, -1); } _lastContactAt = now; SetState(3); ApplyMotionForState(3); _nextVoiceAt = now; } private void MaxFreakTick(float now) { //IL_003f: 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) PlayerControllerB val = NearestTargetablePlayer(); if ((Object)(object)val != (Object)null) { base.targetPlayer = val; base.agent.speed = _walkSpeed * Cfg.MaxFreakSpeed.Value; GoTo(((Component)val).transform.position); if (FlatDistance(((Component)val).transform.position) < 8f || CanSee(val, 180f, 60f)) { _lastContactAt = now; } } else { base.agent.speed = 0f; } if (now - _lastContactAt > Cfg.LoseTargetTimeout.Value) { CalmDown(now, afterKill: false); } } private void FlailTick(float now) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) if (now < _nextFlailCheckAt) { return; } _nextFlailCheckAt = now + 0.1f; bool flag = base.currentBehaviourStateIndex == 3; int num = Cfg.AttackDamage.Value; if (flag) { num = Mathf.RoundToInt((float)num * Cfg.MaxFreakDamageMultiplier.Value); } if (num <= 0) { return; } float value = Cfg.FlailRange.Value; float num2 = (flag ? 0.7f : 1f); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; for (int i = 0; i < allPlayerScripts.Length && i < _lastHurtAt.Length; i++) { if (now - _lastHurtAt[i] < num2) { continue; } PlayerControllerB val = allPlayerScripts[i]; if ((Object)(object)val == (Object)null || !((EnemyAI)this).PlayerIsTargetable(val, false, false, true)) { continue; } Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; if (!(Mathf.Abs(val2.y) > 2.5f)) { val2.y = 0f; if (!(((Vector3)(ref val2)).magnitude > value) && ClearLineTo(val)) { Vector3 val3 = ((((Vector3)(ref val2)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val2)).normalized : ((Component)this).transform.forward); Hurt(i, num, val3 * (flag ? 16f : 10f) + Vector3.up * 2f, 0, now); } } } } private void Hurt(int playerId, int damage, Vector3 push, byte kind, float now) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (playerId >= 0 && playerId < _lastHurtAt.Length) { _lastHurtAt[playerId] = now; HurtPlayerClientRpc(playerId, damage, push, kind); } } private void WatchForKills(float now) { if ((Object)(object)StartOfRound.Instance == (Object)null) { return; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; bool flag = false; for (int i = 0; i < allPlayerScripts.Length && i < _wasDead.Length; i++) { bool flag2 = (Object)(object)allPlayerScripts[i] == (Object)null || allPlayerScripts[i].isPlayerDead; if (flag2 && !_wasDead[i] && now - _lastHurtAt[i] < 5f) { flag = true; } _wasDead[i] = flag2; } if (flag && base.currentBehaviourStateIndex != 0) { CalmDown(now, afterKill: true); } } private void CalmDown(float now, bool afterKill) { act = 0; CalmDownClientRpc(); if (afterKill) { _ignorePlayersUntil = now + Cfg.CalmAfterKill.Value; } EnterNormal(now, investigateLastKnown: false); _nextVoiceAt = now + (afterKill ? 2.5f : Random.Range(4f, 9f)); } private void ApplyMotionForState(int state) { if (!((Object)(object)base.agent == (Object)null)) { switch (state) { case 0: base.agent.speed = _walkSpeed * Cfg.NormalSpeed.Value; base.agent.acceleration = 10f; base.agent.angularSpeed = 200f; base.openDoorSpeedMultiplier = 1f; break; case 1: base.agent.speed = _walkSpeed * Cfg.AwarenessSpeed.Value; base.agent.acceleration = 14f; base.agent.angularSpeed = 280f; base.openDoorSpeedMultiplier = 1.2f; break; case 2: base.agent.speed = _walkSpeed * Cfg.AggressiveSpeed.Value; base.agent.acceleration = 30f; base.agent.angularSpeed = 500f; base.openDoorSpeedMultiplier = 2f; break; default: base.agent.speed = _walkSpeed * Cfg.MaxFreakSpeed.Value; base.agent.acceleration = 45f; base.agent.angularSpeed = 600f; base.openDoorSpeedMultiplier = 3.5f; break; } } } private void GoTo(Vector3 position) { //IL_0001: 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) ((EnemyAI)this).SetDestinationToPosition(position, false); if (((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.SetDestination(base.destination); } } private float FlatDistance(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) Vector3 val = position - ((Component)this).transform.position; val.y = 0f; return ((Vector3)(ref val)).magnitude; } private PlayerControllerB NearestTargetablePlayer() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_004f: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB result = null; float num = float.MaxValue; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && ((EnemyAI)this).PlayerIsTargetable(val, false, false, true)) { Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val; } } } return result; } private PlayerControllerB FindVisiblePlayer(float halfAngle, float range) { //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) PlayerControllerB result = null; float num = float.MaxValue; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && ((EnemyAI)this).PlayerIsTargetable(val, false, false, true) && CanSee(val, halfAngle, range)) { Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val; } } } return result; } private bool CanSee(PlayerControllerB player, float halfAngle, float range) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0076: 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_0060: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.eye == (Object)null || (Object)(object)player.gameplayCamera == (Object)null) { return false; } Vector3 position = ((Component)player.gameplayCamera).transform.position; Vector3 val = position - base.eye.position; if (((Vector3)(ref val)).magnitude > range) { return false; } if (halfAngle < 179f && Vector3.Angle(base.eye.forward, val) > halfAngle) { return false; } return !Physics.Linecast(base.eye.position, position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1); } private bool ClearLineTo(PlayerControllerB player) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.eye == (Object)null || (Object)(object)player.gameplayCamera == (Object)null) { return true; } return !Physics.Linecast(base.eye.position, ((Component)player.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1); } private void VoiceTick(float now) { if (!(now < _nextVoiceAt) && act != 2) { int[] pool; float num; switch (base.currentBehaviourStateIndex) { case 0: { pool = _normalClips; float value = Cfg.NormalVoiceMinGap.Value; float num2 = Mathf.Max(Cfg.NormalVoiceMaxGap.Value, value); num = Random.Range(value, num2); break; } case 1: pool = _awareClips; num = Random.Range(1.4f, 3.2f); break; case 2: pool = _aggressiveClips; num = Random.Range(0.4f, 1.2f); break; default: pool = _freakClips; num = Random.Range(0.15f, 0.6f); break; } int num3 = PickClip(pool, _lastVoiceClip); if (num3 < 0) { _nextVoiceAt = now + 5f; return; } _lastVoiceClip = num3; _nextVoiceAt = now + TimAssets.ClipLength(num3) + num; PlayVoiceClientRpc(num3); } } private static int PickClip(int[] pool, int avoid) { if (pool == null || pool.Length == 0) { return -1; } if (pool.Length == 1) { return pool[0]; } for (int i = 0; i < 6; i++) { int num = pool[Random.Range(0, pool.Length)]; if (num != avoid) { return num; } } return pool[0]; } private void SetState(int state) { if (base.currentBehaviourStateIndex != state) { ApplyState(state); SetStateClientRpc(state); } } private void ApplyState(int state) { if (base.currentBehaviourStateIndex != state) { base.previousBehaviourStateIndex = base.currentBehaviourStateIndex; base.currentBehaviourStateIndex = state; if (base.enemyBehaviourStates != null && state >= 0 && state < base.enemyBehaviourStates.Length) { base.currentBehaviourState = base.enemyBehaviourStates[state]; } } } private void SetAct(byte newAct, float duration, int clip) { act = newAct; actStartTime = Time.time; actDuration = duration; SetActClientRpc(newAct, duration, clip); } private void SetWatchedPlayer(int playerId) { if (watchedPlayerId != playerId || !Mathf.Approximately(awarenessDuration, Cfg.AwarenessDuration.Value)) { SetWatchedPlayerClientRpc(playerId, Cfg.AwarenessDuration.Value); } } [ClientRpc] public void SetStateClientRpc(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) //IL_00ce: 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 val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2333058124u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, state); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2333058124u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ApplyState(Mathf.Clamp(state, 0, 3)); } } } [ClientRpc] public void PlayVoiceClientRpc(int clipIndex) { //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 val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2992539019u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, clipIndex); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2992539019u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; AudioClip clip = TimAssets.GetClip(clipIndex); if (!((Object)(object)clip == (Object)null) && !((Object)(object)base.creatureVoice == (Object)null) && !base.isEnemyDead) { float num = TimConfig.Clamp(Cfg.Volume.Value, 0f, 1f); base.creatureVoice.Stop(); base.creatureVoice.volume = num; base.creatureVoice.clip = clip; base.creatureVoice.Play(); WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, clip, num); } } } [ClientRpc] public void SetActClientRpc(byte newAct, float duration, int clipIndex) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_007d: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1733041673u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref newAct, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref duration, default(ForPrimitives)); BytePacker.WriteValueBitPacked(val, clipIndex); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1733041673u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; act = newAct; actStartTime = Time.time; actDuration = duration; if (!((Object)(object)base.creatureSFX == (Object)null) && newAct == 2) { AudioClip clip = TimAssets.GetClip(clipIndex); if ((Object)(object)base.creatureVoice != (Object)null) { base.creatureVoice.Stop(); } if ((Object)(object)clip != (Object)null) { float num = TimConfig.Clamp(Cfg.Volume.Value, 0f, 1f); base.creatureSFX.Stop(); base.creatureSFX.volume = num; base.creatureSFX.clip = clip; base.creatureSFX.Play(); WalkieTalkie.TransmitOneShotAudio(base.creatureSFX, clip, num); } } } [ClientRpc] public void SetWatchedPlayerClientRpc(int playerId, float awarenessSeconds) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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 val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(632576235u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, playerId); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref awarenessSeconds, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 632576235u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; watchedPlayerId = playerId; awarenessDuration = awarenessSeconds; } } } [ClientRpc] public void CalmDownClientRpc() { //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) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(396700198u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 396700198u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; act = 0; watchedPlayerId = -1; if ((Object)(object)base.creatureVoice != (Object)null) { base.creatureVoice.Stop(); } if ((Object)(object)base.creatureSFX != (Object)null) { base.creatureSFX.Stop(); } if ((Object)(object)visual != (Object)null) { visual.SnapToCalm(); } } } [ClientRpc] public void HurtPlayerClientRpc(int playerId, int damage, Vector3 push, byte kind) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(955685747u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, playerId); BytePacker.WriteValueBitPacked(val, damage); ((FastBufferWriter)(ref val)).WriteValueSafe(ref push); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref kind, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 955685747u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance == (Object)null) { return; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; if (playerId < 0 || playerId >= allPlayerScripts.Length) { return; } PlayerControllerB val3 = allPlayerScripts[playerId]; if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val3 != (Object)(object)GameNetworkManager.Instance.localPlayerController) && !val3.isPlayerDead && val3.isPlayerControlled) { CauseOfDeath val4 = (CauseOfDeath)((kind != 1) ? 1 : 5); val3.DamagePlayer(damage, true, true, val4, 0, false, push); if (!val3.isPlayerDead) { val3.externalForceAutoFade += push; val3.JumpToFearLevel((kind == 1) ? 0.6f : 1f, true); } } } 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; } if ((Object)(object)base.enemyType != (Object)null && base.enemyType.canDie && Cfg.Health.Value > 0) { base.enemyHP -= force; if (base.enemyHP <= 0) { if (((NetworkBehaviour)this).IsOwner) { ((EnemyAI)this).KillEnemyOnOwnerClient(false); } return; } } if (((NetworkBehaviour)this).IsServer && _hostReady && base.currentBehaviourStateIndex < 2) { _ignorePlayersUntil = 0f; if ((Object)(object)playerWhoHit != (Object)null) { base.targetPlayer = playerWhoHit; } EnterAggressive(Time.time); } } public override void KillEnemy(bool destroy = false) { bool flag = !_deathPresented; if (flag && !destroy) { if ((Object)(object)base.creatureVoice != (Object)null) { base.creatureVoice.Stop(); } if ((Object)(object)base.creatureSFX != (Object)null) { base.creatureSFX.Stop(); } act = 0; } ((EnemyAI)this).KillEnemy(destroy); if (destroy || !flag) { return; } _deathPresented = true; if ((Object)(object)base.creatureVoice != (Object)null && _deathClip >= 0) { AudioClip clip = TimAssets.GetClip(_deathClip); if ((Object)(object)clip != (Object)null) { float volume = TimConfig.Clamp(Cfg.Volume.Value, 0f, 1f); base.creatureVoice.volume = volume; base.creatureVoice.clip = clip; base.creatureVoice.Play(); } } if ((Object)(object)visual != (Object)null) { visual.SnapToCalm(); } if ((Object)(object)mapDot != (Object)null) { ((Renderer)mapDot).enabled = false; } } protected override void __initializeVariables() { ((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(2333058124u, new RpcReceiveHandler(__rpc_handler_2333058124), "SetStateClientRpc"); ((NetworkBehaviour)this).__registerRpc(2992539019u, new RpcReceiveHandler(__rpc_handler_2992539019), "PlayVoiceClientRpc"); ((NetworkBehaviour)this).__registerRpc(1733041673u, new RpcReceiveHandler(__rpc_handler_1733041673), "SetActClientRpc"); ((NetworkBehaviour)this).__registerRpc(632576235u, new RpcReceiveHandler(__rpc_handler_632576235), "SetWatchedPlayerClientRpc"); ((NetworkBehaviour)this).__registerRpc(396700198u, new RpcReceiveHandler(__rpc_handler_396700198), "CalmDownClientRpc"); ((NetworkBehaviour)this).__registerRpc(955685747u, new RpcReceiveHandler(__rpc_handler_955685747), "HurtPlayerClientRpc"); ((EnemyAI)this).__initializeRpcs(); } private static void __rpc_handler_2333058124(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 stateClientRpc = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref stateClientRpc); target.__rpc_exec_stage = (__RpcExecStage)1; ((EvilTimAI)(object)target).SetStateClientRpc(stateClientRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2992539019(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 clipIndex = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref clipIndex); target.__rpc_exec_stage = (__RpcExecStage)1; ((EvilTimAI)(object)target).PlayVoiceClientRpc(clipIndex); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1733041673(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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_008e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { byte newAct = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref newAct, default(ForPrimitives)); float duration = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref duration, default(ForPrimitives)); int clipIndex = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref clipIndex); target.__rpc_exec_stage = (__RpcExecStage)1; ((EvilTimAI)(object)target).SetActClientRpc(newAct, duration, clipIndex); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_632576235(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_006f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int playerId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref playerId); float awarenessSeconds = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref awarenessSeconds, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((EvilTimAI)(object)target).SetWatchedPlayerClientRpc(playerId, awarenessSeconds); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_396700198(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; ((EvilTimAI)(object)target).CalmDownClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_955685747(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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0091: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int playerId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref playerId); int damage = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref damage); Vector3 push = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref push); byte kind = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref kind, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((EvilTimAI)(object)target).HurtPlayerClientRpc(playerId, damage, push, kind); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "EvilTimAI"; } } [BepInPlugin("EvilTim", "Evil Tim", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "EvilTim"; public const string Name = "Evil Tim"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static TimConfig Cfg; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; try { TimAssets.LoadEmbedded(); Cfg = new TimConfig(((BaseUnityPlugin)this).Config); InitNetcodeRpcs(); TimContent.Register(); Log.LogInfo((object)("Evil Tim 1.0.0 loaded: " + TimAssets.ClipCount + " voice clips, indoor rarity " + Cfg.IndoorRarity.Value + ", outdoor rarity " + Cfg.OutdoorRarity.Value + ".")); } catch (Exception ex) { Log.LogError((object)("Evil Tim failed to load and is disabled: " + ex)); } } private static void InitNetcodeRpcs() { Type[] types; try { types = Assembly.GetExecutingAssembly().GetTypes(); } catch (ReflectionTypeLoadException ex) { types = ex.Types; } Type[] array = types; foreach (Type type in array) { if (type == null) { continue; } MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } } } internal static class TimAssets { public sealed class PartData { public string Name; public int Parent; public Vector3 Pivot; public Mesh Mesh; } public static readonly List<PartData> Parts = new List<PartData>(); public static Mesh BlobMesh; public static Mesh DotMesh; public static string[] ClipNames = new string[0]; private static readonly List<WavData> Wavs = new List<WavData>(); private static AudioClip[] _clips; private static byte[] _texBytes; private static int _texW; private static int _texH; private static Texture2D _texture; private static Material _bodyMaterial; private static Material _dotMaterial; private static bool _runtimeReady; public static AudioClip SilentClip { get; private set; } public static Material BodyMaterial => _bodyMaterial; public static Material DotMaterial => _dotMaterial; public static int ClipCount => Wavs.Count; public static void LoadEmbedded() { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string[] manifestResourceNames = executingAssembly.GetManifestResourceNames(); Array.Sort(manifestResourceNames, (IComparer<string>?)StringComparer.Ordinal); string[] array = manifestResourceNames; foreach (string text in array) { if (text.EndsWith("tim.bin", StringComparison.OrdinalIgnoreCase)) { ParseModel(ReadAll(executingAssembly, text)); } else if (text.EndsWith("tim_tex.bin", StringComparison.OrdinalIgnoreCase)) { ParseTexture(ReadAll(executingAssembly, text)); } else if (text.EndsWith(".wav", StringComparison.OrdinalIgnoreCase)) { string text2 = text.Substring(0, text.Length - 4); int num = text2.LastIndexOf('.'); string text3 = ((num >= 0) ? text2.Substring(num + 1) : text2).ToLowerInvariant(); try { WavData wavData = WavData.Parse(ReadAll(executingAssembly, text)); wavData.Name = text3; Wavs.Add(wavData); } catch (Exception ex) { Plugin.Log.LogError((object)("Could not read voice clip '" + text3 + "': " + ex.Message)); } } } Wavs.Sort((WavData a, WavData b) => string.CompareOrdinal(a.Name, b.Name)); ClipNames = new string[Wavs.Count]; for (int num2 = 0; num2 < Wavs.Count; num2++) { ClipNames[num2] = Wavs[num2].Name; } if (Parts.Count == 0) { throw new InvalidOperationException("embedded model tim.bin is missing"); } if (_texBytes == null) { throw new InvalidOperationException("embedded texture tim_tex.bin is missing"); } } private static byte[] ReadAll(Assembly asm, string name) { using Stream stream = asm.GetManifestResourceStream(name); using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } private static void ParseModel(byte[] d) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) using BinaryReader binaryReader = new BinaryReader(new MemoryStream(d)); if (binaryReader.ReadByte() != 69 || binaryReader.ReadByte() != 84 || binaryReader.ReadByte() != 73 || binaryReader.ReadByte() != 77) { throw new InvalidDataException("tim.bin: bad header"); } binaryReader.ReadUInt16(); int num = binaryReader.ReadUInt16(); Vector3 pivot = default(Vector3); for (int i = 0; i < num; i++) { int count = binaryReader.ReadByte(); string text = Encoding.ASCII.GetString(binaryReader.ReadBytes(count)); int parent = binaryReader.ReadInt16(); ((Vector3)(ref pivot))..ctor(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); int num2 = (int)binaryReader.ReadUInt32(); int num3 = (int)binaryReader.ReadUInt32(); Vector3[] array = (Vector3[])(object)new Vector3[num2]; Vector3[] array2 = (Vector3[])(object)new Vector3[num2]; Vector2[] array3 = (Vector2[])(object)new Vector2[num2]; for (int j = 0; j < num2; j++) { array[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array2[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[j] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } int[] array4 = new int[num3]; for (int k = 0; k < num3; k++) { array4[k] = binaryReader.ReadUInt16(); } Mesh val = new Mesh(); ((Object)val).name = "EvilTim_" + text; ((Object)val).hideFlags = (HideFlags)61; val.vertices = array; val.normals = array2; val.uv = array3; val.triangles = array4; val.RecalculateBounds(); if (text == "Blob") { BlobMesh = val; } else if (text == "Dot") { DotMesh = val; } Parts.Add(new PartData { Name = text, Parent = parent, Pivot = pivot, Mesh = val }); } } private static void ParseTexture(byte[] d) { _texW = d[0] | (d[1] << 8); _texH = d[2] | (d[3] << 8); if (d.Length != 4 + _texW * _texH * 4) { throw new InvalidDataException("tim_tex.bin: size mismatch"); } _texBytes = new byte[d.Length - 4]; Buffer.BlockCopy(d, 4, _texBytes, 0, _texBytes.Length); } public static float ClipLength(int index) { if (index < 0 || index >= Wavs.Count) { return 0f; } return Wavs[index].Length; } public static AudioClip GetClip(int index) { EnsureRuntime(); if (_clips == null || index < 0 || index >= _clips.Length) { return null; } return _clips[index]; } public static int[] ResolveClips(string list, string settingName) { List<int> list2 = new List<int>(); if (!string.IsNullOrEmpty(list)) { string[] array = list.Split(','); foreach (string text in array) { string text2 = text.Trim().ToLowerInvariant(); if (text2.Length != 0) { if (text2.EndsWith(".mp3") || text2.EndsWith(".wav")) { text2 = text2.Substring(0, text2.Length - 4); } int num = Array.IndexOf(ClipNames, text2); if (num >= 0) { list2.Add(num); continue; } Plugin.Log.LogWarning((object)("Config '" + settingName + "': there is no clip named '" + text2 + "'. Available: " + string.Join(", ", ClipNames))); } } } return list2.ToArray(); } public static void EnsureRuntime() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_0178: Unknown result type (might be due to invalid IL or missing references) if (_runtimeReady) { return; } _runtimeReady = true; try { _texture = new Texture2D(_texW, _texH, (TextureFormat)4, true, false); ((Object)_texture).name = "EvilTim_Atlas"; ((Object)_texture).hideFlags = (HideFlags)61; _texture.SetPixelData<byte>(_texBytes, 0, 0); ((Texture)_texture).filterMode = (FilterMode)1; ((Texture)_texture).wrapMode = (TextureWrapMode)1; _texture.Apply(true, false); Shader val = FindShader("HDRP/Lit"); if ((Object)(object)val != (Object)null) { _bodyMaterial = new Material(val); ((Object)_bodyMaterial).name = "EvilTim_Body"; ((Object)_bodyMaterial).hideFlags = (HideFlags)61; _bodyMaterial.SetTexture("_BaseColorMap", (Texture)(object)_texture); _bodyMaterial.SetTexture("_MainTex", (Texture)(object)_texture); _bodyMaterial.SetColor("_BaseColor", Color.white); _bodyMaterial.SetFloat("_Smoothness", 0.12f); _bodyMaterial.SetFloat("_Metallic", 0f); } else { Plugin.Log.LogError((object)"Could not find the HDRP/Lit shader; Evil Tim will be drawn without a material."); } Shader val2 = FindShader("HDRP/Unlit"); if ((Object)(object)val2 != (Object)null) { _dotMaterial = new Material(val2); ((Object)_dotMaterial).name = "EvilTim_RadarDot"; ((Object)_dotMaterial).hideFlags = (HideFlags)61; _dotMaterial.SetColor("_UnlitColor", new Color(0.85f, 0.05f, 0.05f)); } } catch (Exception ex) { Plugin.Log.LogError((object)("Creating Evil Tim's materials failed: " + ex)); } try { SilentClip = AudioClip.Create("EvilTim_Silence", 441, 1, 44100, false); ((Object)SilentClip).hideFlags = (HideFlags)61; SilentClip.SetData(new float[441], 0); _clips = (AudioClip[])(object)new AudioClip[Wavs.Count]; for (int i = 0; i < Wavs.Count; i++) { WavData wavData = Wavs[i]; AudioClip val3 = AudioClip.Create("EvilTim_" + wavData.Name, wavData.Samples.Length / wavData.Channels, wavData.Channels, wavData.Rate, false); ((Object)val3).hideFlags = (HideFlags)61; val3.SetData(wavData.Samples, 0); _clips[i] = val3; } } catch (Exception ex2) { Plugin.Log.LogError((object)("Creating Evil Tim's audio clips failed: " + ex2)); } try { TimContent.AssignTypeAudio(); } catch (Exception ex3) { Plugin.Log.LogError((object)("Assigning Evil Tim's hurt sound failed: " + ex3)); } } private static Shader FindShader(string name) { Shader val = Shader.Find(name); if ((Object)(object)val != (Object)null) { return val; } Renderer[] array = Object.FindObjectsOfType<Renderer>(); foreach (Renderer val2 in array) { Material sharedMaterial = val2.sharedMaterial; if ((Object)(object)sharedMaterial != (Object)null && (Object)(object)sharedMaterial.shader != (Object)null && ((Object)sharedMaterial.shader).name == name) { return sharedMaterial.shader; } } return null; } } public sealed class TimConfig { public readonly ConfigEntry<int> IndoorRarity; public readonly ConfigEntry<int> OutdoorRarity; public readonly ConfigEntry<int> MaxCount; public readonly ConfigEntry<float> PowerLevel; public readonly ConfigEntry<float> HearingDistance; public readonly ConfigEntry<float> SightRange; public readonly ConfigEntry<float> SightAngle; public readonly ConfigEntry<float> AwarenessDuration; public readonly ConfigEntry<float> AggressiveDuration; public readonly ConfigEntry<float> LoseTargetTimeout; public readonly ConfigEntry<float> CalmAfterKill; public readonly ConfigEntry<float> NormalSpeed; public readonly ConfigEntry<float> AwarenessSpeed; public readonly ConfigEntry<float> AggressiveSpeed; public readonly ConfigEntry<float> MaxFreakSpeed; public readonly ConfigEntry<int> AttackDamage; public readonly ConfigEntry<float> MaxFreakDamageMultiplier; public readonly ConfigEntry<int> VomitDamage; public readonly ConfigEntry<float> FlailRange; public readonly ConfigEntry<float> VomitRange; public readonly ConfigEntry<int> Health; public readonly ConfigEntry<float> Volume; public readonly ConfigEntry<float> AudioRange; public readonly ConfigEntry<float> NormalVoiceMinGap; public readonly ConfigEntry<float> NormalVoiceMaxGap; public readonly ConfigEntry<string> NormalLines; public readonly ConfigEntry<string> AwarenessLines; public readonly ConfigEntry<string> AggressiveLines; public readonly ConfigEntry<string> MaxFreakLines; public readonly ConfigEntry<string> VomitSounds; public readonly ConfigEntry<string> DeathSound; public readonly ConfigEntry<string> HurtSound; public readonly ConfigEntry<float> ModelScale; public TimConfig(ConfigFile cfg) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Expected O, but got Unknown //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Expected O, but got Unknown //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Expected O, but got Unknown //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Expected O, but got Unknown //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Expected O, but got Unknown //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Expected O, but got Unknown //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Expected O, but got Unknown //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Expected O, but got Unknown //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Expected O, but got Unknown //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Expected O, but got Unknown //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Expected O, but got Unknown //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Expected O, but got Unknown //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Expected O, but got Unknown //IL_0520: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Expected O, but got Unknown //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Expected O, but got Unknown //IL_06bb: Unknown result type (might be due to invalid IL or missing references) //IL_06c5: Expected O, but got Unknown IndoorRarity = cfg.Bind<int>("Spawning", "Indoor spawn rarity", 30, new ConfigDescription("Spawn weight inside facilities on every moon. 0 = never spawns indoors. For comparison, common vanilla enemies sit around 30-80 and rare ones below 10.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())); OutdoorRarity = cfg.Bind<int>("Spawning", "Outdoor spawn rarity", 15, new ConfigDescription("Spawn weight outside on the moon surface. 0 = never spawns outdoors.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())); MaxCount = cfg.Bind<int>("Spawning", "Maximum Evil Tims", 1, new ConfigDescription("Most Evil Tims that can spawn in one round, indoors and outdoors combined.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), Array.Empty<object>())); PowerLevel = cfg.Bind<float>("Spawning", "Power level", 2f, new ConfigDescription("How much of a moon's enemy power budget one Evil Tim uses.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); HearingDistance = cfg.Bind<float>("Senses", "Hearing distance", 20f, new ConfigDescription("Metres. Player noises (footsteps, voice, dropped items) closer than this make him walk over to investigate. Hearing never makes him aggressive. The game itself limits how far each noise carries (walking about 17 m, sprinting about 22 m).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); SightRange = cfg.Bind<float>("Senses", "Sight range", 30f, new ConfigDescription("Metres. How far away he can spot a player in a clear line of sight.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 150f), Array.Empty<object>())); SightAngle = cfg.Bind<float>("Senses", "Sight angle", 70f, new ConfigDescription("Degrees to either side of where he faces in which he can first spot a player.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 180f), Array.Empty<object>())); AwarenessDuration = cfg.Bind<float>("Behaviour", "Awareness duration", 10f, new ConfigDescription("Seconds he must keep a player in sight before he turns aggressive.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 120f), Array.Empty<object>())); AggressiveDuration = cfg.Bind<float>("Behaviour", "Aggressive duration", 7f, new ConfigDescription("Seconds of flailing and vomiting before he enters Maximum Freak.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 120f), Array.Empty<object>())); LoseTargetTimeout = cfg.Bind<float>("Behaviour", "Maximum Freak lose-target timeout", 12f, new ConfigDescription("Seconds without seeing or being near any player before Maximum Freak ends and he calms down.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 300f), Array.Empty<object>())); CalmAfterKill = cfg.Bind<float>("Behaviour", "Calm period after a kill", 8f, new ConfigDescription("Seconds after a kill during which he ignores everyone and just strolls off. Hitting him still provokes him.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 120f), Array.Empty<object>())); NormalSpeed = cfg.Bind<float>("Speed", "Normal speed multiplier", 0.6f, new ConfigDescription("Multiple of the player's walking speed while wandering.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 5f), Array.Empty<object>())); AwarenessSpeed = cfg.Bind<float>("Speed", "Awareness speed multiplier", 0.8f, new ConfigDescription("Multiple of the player's walking speed while approaching a player he can see.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 5f), Array.Empty<object>())); AggressiveSpeed = cfg.Bind<float>("Speed", "Aggressive speed multiplier", 1f, new ConfigDescription("Multiple of the player's walking speed while flailing and vomiting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 5f), Array.Empty<object>())); MaxFreakSpeed = cfg.Bind<float>("Speed", "Maximum Freak speed multiplier", 1.9f, new ConfigDescription("Multiple of the player's walking speed while running you down. Players sprint at about 2.25.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 6f), Array.Empty<object>())); AttackDamage = cfg.Bind<int>("Combat", "Attack damage", 20, new ConfigDescription("Damage of one arm-flail hit in the aggressive state. Players have 100 health.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())); MaxFreakDamageMultiplier = cfg.Bind<float>("Combat", "Maximum Freak damage multiplier", 2f, new ConfigDescription("Arm-flail damage is multiplied by this during Maximum Freak.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>())); VomitDamage = cfg.Bind<int>("Combat", "Vomit damage", 10, new ConfigDescription("Damage each time the vomit stream catches a player (about twice a second while it lasts).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())); FlailRange = cfg.Bind<float>("Combat", "Arm flail range", 2.6f, new ConfigDescription("Metres. How close a player must be to get hit by the flailing arms.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>())); VomitRange = cfg.Bind<float>("Combat", "Vomit range", 6f, new ConfigDescription("Metres. Reach of the vomit attack.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>())); Health = cfg.Bind<int>("Combat", "Health", 8, new ConfigDescription("Shovel hits needed to kill him. 0 = cannot be killed.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())); Volume = cfg.Bind<float>("Audio", "Volume", 1f, new ConfigDescription("Volume of his voice and vomiting sounds on your own game (0-1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); AudioRange = cfg.Bind<float>("Audio", "Audible range", 30f, new ConfigDescription("Metres at which his voice fades out completely.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 150f), Array.Empty<object>())); NormalVoiceMinGap = cfg.Bind<float>("Audio", "Wandering line minimum gap", 12f, new ConfigDescription("Shortest pause in seconds between voice lines while he wanders.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 600f), Array.Empty<object>())); NormalVoiceMaxGap = cfg.Bind<float>("Audio", "Wandering line maximum gap", 28f, new ConfigDescription("Longest pause in seconds between voice lines while he wanders.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 600f), Array.Empty<object>())); string text = "Available clips: " + string.Join(", ", TimAssets.ClipNames) + ". Comma-separated; leave empty for none."; NormalLines = cfg.Bind<string>("Audio", "Wandering voice lines", "yeahbaby", "Voice lines used while wandering. " + text); AwarenessLines = cfg.Bind<string>("Audio", "Awareness voice lines", "whatthehell, ohmygod", "Threats used while he stares at a player. " + text); AggressiveLines = cfg.Bind<string>("Audio", "Aggressive voice lines", "time_to_die, whatthehell", "Voice lines used while flailing. " + text); MaxFreakLines = cfg.Bind<string>("Audio", "Maximum Freak voice lines", "timdeathscream, time_to_die", "Screams and threats used during Maximum Freak. " + text); VomitSounds = cfg.Bind<string>("Audio", "Vomiting sounds", "barf", "Sounds used for the vomit attack. " + text); DeathSound = cfg.Bind<string>("Audio", "Death sound", "timdeathscream", "Played when he is killed. " + text); HurtSound = cfg.Bind<string>("Audio", "Hurt sound", "ohmygod", "Played when he is hit. " + text); ModelScale = cfg.Bind<float>("Visual", "Model scale", 1.45f, new ConfigDescription("Size of the model on your own game. 1.0 is a 1.95 m man; the default makes him tower over players.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), Array.Empty<object>())); } public static float Clamp(float v, float min, float max) { if (float.IsNaN(v)) { return min; } return Math.Max(min, Math.Min(max, v)); } } internal static class TimContent { public static int EnemiesLayer = 19; public static int MapRadarLayer = 14; public static int ScanNodeLayer = 22; public const float ModelHeight = 1.95f; public static EnemyType InsideType; public static EnemyType OutsideType; public static TerminalNode InfoNode; private static readonly List<EvilTimAI> Live = new List<EvilTimAI>(); public static void Register() { TimConfig cfg = Plugin.Cfg; EnemiesLayer = LayerOr("Enemies", EnemiesLayer); MapRadarLayer = LayerOr("MapRadar", MapRadarLayer); ScanNodeLayer = LayerOr("ScanNode", ScanNodeLayer); InfoNode = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)InfoNode).name = "EvilTimFile"; ((Object)InfoNode).hideFlags = (HideFlags)61; InfoNode.creatureName = "Evil Tim"; InfoNode.creatureFileID = -1; InfoNode.clearPreviousText = true; InfoNode.maxCharactersToType = 35; InfoNode.displayText = "EVIL TIM\n\nSigurd's danger level: 70%, then 0%, then 70% again\n\nScientific name: Homo longibrachius\n\nA tall Dutch man in a green shirt whose arms reach his knees. Most of the time he strolls around minding his own business and muttering to himself. He will walk over to check out a noise, and that is all he does about it.\n\nDo not let him LOOK at you. If he keeps you in sight for about ten seconds his arms start twitching, then he loses it completely: flailing, vomiting, and finally sprinting at whoever is closest with his arms above his head. Break line of sight early and he forgets about you.\n\nOnce he has killed somebody he calms down on the spot and walks off as if nothing happened.\n\ni asked him what scran means. he looked at me for nine seconds. i left -Sigurd\n\n"; InsideType = CreateType("EvilTim", outside: false); OutsideType = CreateType("EvilTimOutside", outside: true); RefreshMaxCounts(); Enemies.RegisterEnemy(InsideType, cfg.IndoorRarity.Value, (LevelTypes)(-1), (SpawnType)0, InfoNode, (TerminalKeyword)null); Enemies.RegisterEnemy(OutsideType, cfg.OutdoorRarity.Value, (LevelTypes)(-1), (SpawnType)2, InfoNode, (TerminalKeyword)null); } private static EnemyType CreateType(string name, bool outside) { TimConfig cfg = Plugin.Cfg; EnemyType val = ScriptableObject.CreateInstance<EnemyType>(); ((Object)val).name = name; ((Object)val).hideFlags = (HideFlags)61; val.enemyName = "Evil Tim"; val.isOutsideEnemy = outside; val.isDaytimeEnemy = false; val.probabilityCurve = AnimationCurve.Constant(0f, 1f, 1f); val.numberSpawnedFalloff = AnimationCurve.Constant(0f, 1f, 1f); val.useNumberSpawnedFalloff = false; val.spawnInGroupsOf = 1; val.increasedChanceInterior = -1; val.PowerLevel = cfg.PowerLevel.Value; val.MaxCount = Mathf.Max(0, cfg.MaxCount.Value); val.normalizedTimeInDayToLeave = 1f; val.stunTimeMultiplier = 1f; val.doorSpeedMultiplier = 1f; val.stunGameDifficultyMultiplier = 0f; val.canBeStunned = true; val.canDie = cfg.Health.Value > 0; val.canBeDestroyed = true; val.destroyOnDeath = false; val.canSeeThroughFog = false; val.pushPlayerForce = 0f; val.pushPlayerDistance = 0f; val.loudnessMultiplier = 1f; val.miscAnimations = (MiscAnimation[])(object)new MiscAnimation[0]; val.audioClips = (AudioClip[])(object)new AudioClip[0]; val.enemyPrefab = BuildPrefab(name, val); return val; } public static void AssignTypeAudio() { int[] array = TimAssets.ResolveClips(Plugin.Cfg.HurtSound.Value, "Hurt sound"); AudioClip hitEnemyVoiceSFX = ((array.Length != 0) ? TimAssets.GetClip(array[0]) : null); if ((Object)(object)InsideType != (Object)null) { InsideType.hitEnemyVoiceSFX = hitEnemyVoiceSFX; } if ((Object)(object)OutsideType != (Object)null) { OutsideType.hitEnemyVoiceSFX = hitEnemyVoiceSFX; } } private static GameObject BuildPrefab(string name, EnemyType type) { //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Expected O, but got Unknown //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Expected O, but got Unknown //IL_042c: Unknown result type (might be due to invalid IL or missing references) float num = TimConfig.Clamp(Plugin.Cfg.ModelScale.Value, 0.5f, 3f); float num2 = 1.95f * num; GameObject val = NetworkPrefabs.CreateNetworkPrefab(name); val.layer = EnemiesLayer; TrySetTag(val, "Enemy"); Rigidbody val2 = val.AddComponent<Rigidbody>(); val2.isKinematic = true; val2.useGravity = false; NavMeshAgent val3 = val.AddComponent<NavMeshAgent>(); val3.radius = 0.45f; val3.height = num2; val3.baseOffset = 0f; val3.speed = 2.8f; val3.angularSpeed = 220f; val3.acceleration = 12f; val3.stoppingDistance = 0f; val3.autoBraking = true; EvilTimAI evilTimAI = val.AddComponent<EvilTimAI>(); ((EnemyAI)evilTimAI).enemyType = type; ((EnemyAI)evilTimAI).agent = val3; ((EnemyAI)evilTimAI).thisNetworkObject = val.GetComponent<NetworkObject>(); ((EnemyAI)evilTimAI).AIIntervalTime = 0.2f; ((EnemyAI)evilTimAI).updatePositionThreshold = 0.3f; ((EnemyAI)evilTimAI).syncMovementSpeed = 0.2f; ((EnemyAI)evilTimAI).exitVentAnimationTime = 1f; ((EnemyAI)evilTimAI).enemyHP = Mathf.Max(1, Plugin.Cfg.Health.Value); ((EnemyAI)evilTimAI).openDoorSpeedMultiplier = 1f; ((EnemyAI)evilTimAI).enemyBehaviourStates = NewStates(); ((EnemyAI)evilTimAI).currentSearch = new AISearchRoutine(); GameObject val4 = Child(val, "Collision", EnemiesLayer); TrySetTag(val4, "Enemy"); CapsuleCollider val5 = val4.AddComponent<CapsuleCollider>(); ((Collider)val5).isTrigger = true; val5.direction = 1; val5.radius = 0.5f; val5.height = num2; val5.center = new Vector3(0f, num2 * 0.5f, 0f); EnemyAICollisionDetect val6 = val4.AddComponent<EnemyAICollisionDetect>(); val6.mainScript = (EnemyAI)(object)evilTimAI; GameObject val7 = Child(val, "Eye", EnemiesLayer); val7.transform.localPosition = new Vector3(0f, 1.6f * num, 0.2f * num); ((EnemyAI)evilTimAI).eye = val7.transform; ((EnemyAI)evilTimAI).creatureVoice = NewAudioSource(Child(val, "Voice", EnemiesLayer), 1.75f * num); ((EnemyAI)evilTimAI).creatureSFX = NewAudioSource(Child(val, "SFX", EnemiesLayer), 1.6f * num); GameObject val8 = Child(val, "ScanNode", ScanNodeLayer); val8.transform.localPosition = new Vector3(0f, num2 * 0.62f, 0f); BoxCollider val9 = val8.AddComponent<BoxCollider>(); ((Collider)val9).isTrigger = true; val9.size = new Vector3(0.9f, 1.6f, 0.9f); ScanNodeProperties val10 = val8.AddComponent<ScanNodeProperties>(); val10.headerText = "Evil Tim"; val10.subText = "Do not let him look at you"; val10.nodeType = 1; val10.minRange = 1; val10.maxRange = 14; val10.requiresLineOfSight = true; val10.creatureScanID = -1; evilTimAI.scanNode = val10; GameObject val11 = Child(val, "Model", EnemiesLayer); val11.transform.localScale = Vector3.one * num; GameObject val12 = Child(val11, "PoseRoot", EnemiesLayer); TimVisual timVisual = val.AddComponent<TimVisual>(); timVisual.ai = evilTimAI; timVisual.poseRoot = val12.transform; timVisual.joints = (Transform[])(object)new Transform[18]; List<MeshRenderer> list = new List<MeshRenderer>(); Transform[] array = (Transform[])(object)new Transform[TimAssets.Parts.Count]; for (int i = 0; i < TimAssets.Parts.Count; i++) { TimAssets.PartData partData = TimAssets.Parts[i]; if (!(partData.Name == "Blob") && !(partData.Name == "Dot")) { Transform val13 = ((partData.Parent >= 0 && (Object)(object)array[partData.Parent] != (Object)null) ? array[partData.Parent] : val12.transform); GameObject val14 = new GameObject(partData.Name); val14.layer = EnemiesLayer; val14.transform.SetParent(val13, false); val14.transform.localPosition = partData.Pivot; val14.AddComponent<MeshFilter>().sharedMesh = partData.Mesh; list.Add(val14.AddComponent<MeshRenderer>()); array[i] = val14.transform; if (Enum.TryParse<Joint>(partData.Name, out var result) && result != Joint.Count) { timVisual.joints[(int)result] = val14.transform; } } } timVisual.bodyRenderers = list.ToArray(); Transform val15 = timVisual.joints[2]; GameObject val16 = new GameObject("Mouth"); val16.layer = EnemiesLayer; val16.transform.SetParent(((Object)(object)val15 != (Object)null) ? val15 : val12.transform, false); val16.transform.localPosition = new Vector3(0f, 0.066f, 0.105f); timVisual.mouth = val16.transform; evilTimAI.visual = timVisual; return val; } private static EnemyBehaviourState[] NewStates() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown string[] array = new string[4] { "Normal", "Awareness", "Aggressive", "MaxFreak" }; EnemyBehaviourState[] array2 = (EnemyBehaviourState[])(object)new EnemyBehaviourState[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = new EnemyBehaviourState(); array2[i].name = array[i]; } return array2; } public static void EnsureStates(EvilTimAI ai) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown if (((EnemyAI)ai).enemyBehaviourStates == null || ((EnemyAI)ai).enemyBehaviourStates.Length < 4) { ((EnemyAI)ai).enemyBehaviourStates = NewStates(); } for (int i = 0; i < ((EnemyAI)ai).enemyBehaviourStates.Length; i++) { if (((EnemyAI)ai).enemyBehaviourStates[i] == null) { ((EnemyAI)ai).enemyBehaviourStates[i] = new EnemyBehaviourState(); } } if (((EnemyAI)ai).currentSearch == null) { ((EnemyAI)ai).currentSearch = new AISearchRoutine(); } if (((EnemyAI)ai).currentSearch.unsearchedNodes == null) { ((EnemyAI)ai).currentSearch.unsearchedNodes = new List<GameObject>(); } } private static int LayerOr(string name, int fallback) { int num = LayerMask.NameToLayer(name); if (num < 0) { return fallback; } return num; } public static MeshRenderer CreateMapDot(Transform parent) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)TimAssets.DotMesh == (Object)null || (Object)(object)TimAssets.DotMaterial == (Object)null) { return null; } GameObject val = new GameObject("MapDot"); val.layer = MapRadarLayer; val.transform.SetParent(parent, false); val.transform.localPosition = new Vector3(0f, 1f, 0f); val.transform.localScale = new Vector3(0.75f, 0.2f, 0.75f); val.AddComponent<MeshFilter>().sharedMesh = TimAssets.DotMesh; MeshRenderer val2 = val.AddComponent<MeshRenderer>(); ((Renderer)val2).sharedMaterial = TimAssets.DotMaterial; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; return val2; } private static GameObject Child(GameObject parent, string name, int layer) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown GameObject val = new GameObject(name); val.layer = layer; val.transform.SetParent(parent.transform, false); return val; } private static AudioSource NewAudioSource(GameObject go, float height) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) go.transform.localPosition = new Vector3(0f, height, 0f); AudioSource val = go.AddComponent<AudioSource>(); val.playOnAwake = false; val.loop = false; val.spatialBlend = 1f; val.dopplerLevel = 0.2f; val.rolloffMode = (AudioRolloffMode)1; val.minDistance = 3f; val.maxDistance = TimConfig.Clamp(Plugin.Cfg.AudioRange.