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 LethalFazbear v1.0.6
LethalFazbear.dll
Decompiled 4 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using DunGen; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using Unity.AI.Navigation; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.SceneManagement; using UnityEngine.UI; [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("LethalFazbear")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LethalFazbear")] [assembly: AssemblyTitle("LethalFazbear")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] 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 LethalFazbear { internal class AnimatronicAI : EnemyAI { public const int SDormant = 0; public const int SRoam = 1; public const int SChase = 2; public const int SSpecial1 = 3; public const int SSpecial2 = 4; public const int SSpecial3 = 5; public const int SHidden = 6; public const int SAppear = 7; public const int SReturn = 8; public const byte SndMoan = 0; public const byte SndLaugh = 1; public const byte SndCurtain = 2; public const byte SndStatic = 3; public const byte SndScream = 4; public const byte SndRunBang = 5; public const byte SndPowerOff = 6; public const byte SndShutdown = 7; public const byte SndBoot = 8; public const byte SndVent = 9; public const int SOffline = 5; public CharacterId character; public Rig rig; public AudioSource loopSource; public AudioSource stepSource; public Collider touchCollider; public Collider scanCollider; private CharacterDef def; private Vector3 homePos; private float homeYaw; private bool onStage; private bool serverInitDone; private float activateAt; private float stateTimer; private float lastSawTarget; private Vector3 lastSeenPos; private bool hasRoamDest; private bool roamToKitchen; private Vector3 roamDest; private float nextGlitch; private float nextLaugh; private float musicCooldownUntil; private bool wasFrozen; private float foxyMeter; private float nextAppear; private int appearTarget = -1; private float specialUntil; private float nextVent; private float jumpscareUntil; private float offlineUntil; private float offlineImmuneUntil; private int stateBeforeOffline; public float localHideUntil; private int lastLoopState = -1; private AudioClip loopPick; private float nextClang; private float stareTime; private float lookAwayTime; private bool sentDismiss; private bool visibleState = true; private float fearTick; private static readonly List<AnimatronicAI> active = new List<AnimatronicAI>(); private readonly HashSet<int> met = new HashSet<int>(); private float crossSince = -1f; private float upstairsSince; private int zigLegs; private int zigSide = 1; private int bangs; private float nextBang; private readonly Dictionary<string, AudioSource> ventVoices = new Dictionary<string, AudioSource>(); private Vector3 lastAnimPos; private float animSpeed; private float offlineAnimStart; private float bootAnimUntil; private int prevAnimState = -1; private bool lastScaring; private Vector3 lastFreddyPos; private float freddyStillTime; public static IReadOnlyList<AnimatronicAI> Active => active; private float Agg => Mathf.Clamp(Plugin.Aggression.Value * (((Object)(object)FazbearMoon.Level != (Object)null && (Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.currentLevel == (Object)(object)FazbearMoon.Level) ? FiveNights.Factor : 1f), 0.25f, 4f); private PlayerControllerB[] Players => StartOfRound.Instance.allPlayerScripts; private Vector3 HeadPos => ((Component)this).transform.position + Vector3.up * 1.9f * def.height; private bool NightActive { get { if (character != CharacterId.YellowBear && character != CharacterId.Springtrap) { return FazbearClock.IsNight; } return true; } } private float WalkSpeed => character switch { CharacterId.Freddy => 2.3f, CharacterId.Bonnie => 3.7f, CharacterId.Chica => 2.7f, CharacterId.Foxy => 3.2f, CharacterId.Springtrap => 2.6f, _ => 0f, }; private float ChaseSpeed => character switch { CharacterId.Freddy => 4.4f, CharacterId.Bonnie => 6.4f, CharacterId.Chica => 5f, CharacterId.Foxy => 11.5f, CharacterId.Springtrap => 5.8f, _ => 0f, }; public override void Start() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_006f: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).Start(); def = CharacterDef.Get(character); homePos = ((Component)this).transform.position; homeYaw = ((Component)this).transform.eulerAngles.y; base.isOutside = ((Component)this).transform.position.y > -80f; ((EnemyAI)this).GetAINodes(); onStage = PizzeriaBuilder.Current != null && PizzeriaBuilder.Current.IsStageSpot(homePos); active.Add(this); AudioMixerGroup mixerGroup = Registry.MixerGroup; AudioSource[] array = (AudioSource[])(object)new AudioSource[4] { base.creatureVoice, base.creatureSFX, loopSource, stepSource }; foreach (AudioSource val in array) { if ((Object)(object)val != (Object)null && (Object)(object)mixerGroup != (Object)null) { val.outputAudioMixerGroup = mixerGroup; } } if ((Object)(object)stepSource != (Object)null) { rig.stepSource = stepSource; rig.stepVolume = Plugin.Volume.Value; } if (((NetworkBehaviour)this).IsServer && !serverInitDone) { ServerInit(PizzeriaBuilder.Current != null && base.isOutside); } if (character == CharacterId.YellowBear) { ApplyVisibility(base.currentBehaviourStateIndex != 6); } } public void ServerInit(bool fazbearShow) { serverInitDone = true; float num = Mathf.Max(0.05f, Plugin.ActivationDelay.Value) / Mathf.Sqrt(Agg); float time = Time.time; switch (character) { case CharacterId.Bonnie: activateAt = time + (fazbearShow ? (Random.Range(25f, 70f) * num) : Random.Range(3f, 6f)); break; case CharacterId.Chica: activateAt = time + (fazbearShow ? (Random.Range(45f, 100f) * num) : Random.Range(3f, 6f)); break; case CharacterId.Freddy: activateAt = time + (fazbearShow ? (Random.Range(100f, 180f) * num) : Random.Range(4f, 8f)); break; case CharacterId.Foxy: activateAt = time + (fazbearShow ? (Random.Range(20f, 45f) * num) : Random.Range(2f, 4f)); break; case CharacterId.Springtrap: activateAt = time + Random.Range(30f, 60f) * num; nextVent = time + Random.Range(60f, 100f) / Agg; break; case CharacterId.YellowBear: activateAt = time; nextAppear = time + Random.Range(40f, 80f) / Agg; if (!fazbearShow) { ((EnemyAI)this).SwitchToBehaviourState(6); } break; } } public void DevActivate() { if (((NetworkBehaviour)this).IsServer) { activateAt = Time.time; if (character == CharacterId.Foxy) { foxyMeter = 61f; } if (character == CharacterId.YellowBear) { nextAppear = Time.time; } if (character == CharacterId.Springtrap) { nextVent = Time.time + 20f; } } } public override void OnDestroy() { active.Remove(this); ((EnemyAI)this).OnDestroy(); } private bool Alive(PlayerControllerB p) { if ((Object)(object)p != (Object)null && p.isPlayerControlled) { return !p.isPlayerDead; } return false; } private bool ObservedByAnyone(float range = 35f) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB[] players = Players; foreach (PlayerControllerB val in players) { if (Alive(val) && val.isInsideFactory != base.isOutside && !(Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position) > range)) { if (val.HasLineOfSightToPosition(HeadPos, 50f, (int)range, -1f, -1)) { return true; } if (val.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 1f, 50f, (int)range, -1f, -1)) { return true; } } } return false; } private bool PlayerSees(PlayerControllerB p, Vector3 point, float width, float range) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (Alive(p)) { return p.HasLineOfSightToPosition(point, width, (int)range, -1f, -1); } return false; } private PlayerControllerB SpotPlayer(float range, float fov, float proximity = 2.5f) { //IL_002c: 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) //IL_005a: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB result = null; float num = float.MaxValue; PlayerControllerB[] players = Players; foreach (PlayerControllerB val in players) { if (((EnemyAI)this).PlayerIsTargetable(val, false, false, true)) { float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position); if (!(num2 > range) && !(num2 > num) && ((EnemyAI)this).CheckLineOfSightForPosition(((Component)val.gameplayCamera).transform.position, fov, (int)range, proximity, (Transform)null)) { result = val; num = num2; } } } return result; } private PlayerControllerB ClosestTargetable(float maxDist = 999f) { //IL_0028: 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) PlayerControllerB result = null; float num = maxDist; PlayerControllerB[] players = Players; foreach (PlayerControllerB val in players) { if (((EnemyAI)this).PlayerIsTargetable(val, false, false, true)) { float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position); if (num2 < num) { result = val; num = num2; } } } return result; } private List<Vector3> RoamPoints(bool kitchen = false) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) PizzeriaBuilder current = PizzeriaBuilder.Current; if (base.isOutside && current != null) { if (!kitchen) { return current.RoamPoints; } return current.KitchenPoints; } List<Vector3> list = new List<Vector3>(); if (base.allAINodes != null) { GameObject[] allAINodes = base.allAINodes; foreach (GameObject val in allAINodes) { if ((Object)(object)val != (Object)null) { list.Add(val.transform.position); } } } return list; } private void PickRoamDestination(bool preferKitchen = false, bool stalk = false) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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) List<Vector3> list = RoamPoints(preferKitchen); if (list.Count == 0) { hasRoamDest = false; } else { hasRoamDest = ((EnemyAI)this).SetDestinationToPosition(roamDest = list[Random.Range(0, list.Count)], true); } } private void SendSound(byte s) { FazNet.Send(new NetEvent { kind = NetKind.Sound, enemy = ((NetworkBehaviour)this).NetworkObjectId, sound = s }); } private void StartChase(PlayerControllerB p) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) base.targetPlayer = p; lastSawTarget = Time.time; lastSeenPos = ((Component)p).transform.position; ((EnemyAI)this).SwitchToBehaviourState(2); SendSound(0); } private void Follow(PlayerControllerB p) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) base.moveTowardsDestination = true; if ((Object)(object)p == (Object)(object)base.targetPlayer && Time.time - lastSawTarget > 0.75f) { base.movingTowardsTargetPlayer = false; ((EnemyAI)this).SetDestinationToPosition(lastSeenPos, false); } else { ((EnemyAI)this).SetMovingTowardsTargetPlayer(p); } } private void StopMoving() { base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; if (((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.ResetPath(); } base.agent.speed = 0f; } private float Scaled(float v, float k = 0.5f) { return v * Mathf.Lerp(1f, Agg, k); } private PlayerControllerB Detect() { return (PlayerControllerB)(character switch { CharacterId.Bonnie => SpotPlayer(20f, 70f, 4f), CharacterId.Chica => SpotPlayer(16f, 90f, 3.5f), CharacterId.Freddy => SpotPlayer(14f, 60f, 3.5f), CharacterId.Foxy => SpotPlayer(28f, 100f, 5f), CharacterId.Springtrap => SpotPlayer(22f, 80f, 4f), _ => null, }); } private float NightDelay() { float num = Mathf.Max(0.05f, Plugin.ActivationDelay.Value) / Mathf.Sqrt(Agg); return character switch { CharacterId.Bonnie => Random.Range(4f, 20f) * num, CharacterId.Chica => Random.Range(20f, 50f) * num, CharacterId.Freddy => Random.Range(60f, 120f) * num, CharacterId.Foxy => Random.Range(5f, 15f) * num, _ => 0f, }; } public override void DoAIInterval() { if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead) { ((EnemyAI)this).DoAIInterval(); return; } if (Time.time < jumpscareUntil) { StopMoving(); ((EnemyAI)this).DoAIInterval(); return; } if (base.stunNormalizedTimer > 0f) { base.agent.speed = 0f; ((EnemyAI)this).DoAIInterval(); return; } if (base.currentBehaviourStateIndex == 5) { StopMoving(); if (Time.time >= offlineUntil) { offlineImmuneUntil = Time.time + 3f; SendSound(8); int num = ((character == CharacterId.Foxy) ? 8 : (NightActive ? 1 : 0)); if (stateBeforeOffline == 0 && character != CharacterId.Foxy) { num = 0; } ((EnemyAI)this).SwitchToBehaviourState(num); hasRoamDest = false; } ((EnemyAI)this).DoAIInterval(); return; } if (!NightActive) { if (base.currentBehaviourStateIndex != 0 && base.currentBehaviourStateIndex != 8) { ((EnemyAI)this).SwitchToBehaviourState(0); } base.targetPlayer = null; StopMoving(); activateAt = Time.time + NightDelay(); foxyMeter = 0f; ((EnemyAI)this).DoAIInterval(); return; } switch (character) { case CharacterId.Bonnie: BonnieChicaAI(chica: false); break; case CharacterId.Chica: BonnieChicaAI(chica: true); break; case CharacterId.Freddy: FreddyAI(); break; case CharacterId.Foxy: FoxyAI(); break; case CharacterId.YellowBear: YellowBearAI(); break; case CharacterId.Springtrap: SpringtrapAI(); break; } ((EnemyAI)this).DoAIInterval(); } private void Roam(bool kitchenBias) { //IL_002a: 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) base.agent.speed = Scaled(WalkSpeed); if (!hasRoamDest || Vector3.Distance(((Component)this).transform.position, roamDest) < 1.5f || (!base.agent.hasPath && Random.value < 0.05f)) { roamToKitchen = kitchenBias && base.isOutside && PizzeriaBuilder.Current != null && Random.value < 0.5f; PickRoamDestination(roamToKitchen); } } private bool KeepChasing(float memory) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.targetPlayer == (Object)null || !((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true)) { return false; } if (((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer.gameplayCamera).transform.position, 120f, 40, 4f, (Transform)null)) { lastSawTarget = Time.time; lastSeenPos = ((Component)base.targetPlayer).transform.position; } if (Time.time - lastSawTarget > 1.5f && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 20f) { return false; } if (Time.time - lastSawTarget > 2f && Vector3.Distance(((Component)this).transform.position, lastSeenPos) < 1.5f) { return false; } return Time.time - lastSawTarget <= memory; } private void GiveUpChase() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) base.targetPlayer = null; base.movingTowardsTargetPlayer = false; ((EnemyAI)this).SwitchToBehaviourState(1); roamToKitchen = false; roamDest = lastSeenPos; hasRoamDest = ((EnemyAI)this).SetDestinationToPosition(lastSeenPos, true); } private void BonnieChicaAI(bool chica) { //IL_0092: 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) float memory = (chica ? 12f : 6f) * Agg; switch (base.currentBehaviourStateIndex) { case 0: StopMoving(); if (Time.time >= activateAt) { ((EnemyAI)this).SwitchToBehaviourState(1); hasRoamDest = false; nextGlitch = Time.time + Random.Range(6f, 12f); } break; case 1: { if (chica && hasRoamDest && roamToKitchen && Vector3.Distance(((Component)this).transform.position, roamDest) < 1.5f && Random.value < 0.7f) { ((EnemyAI)this).SwitchToBehaviourState(3); specialUntil = Time.time + Random.Range(8f, 16f); StopMoving(); break; } Roam(chica); PlayerControllerB val2 = Detect(); if ((Object)(object)val2 != (Object)null) { StartChase(val2); } else if (!chica) { TryGlitchForward(); } break; } case 3: { StopMoving(); PlayerControllerB val = Detect(); if ((Object)(object)val != (Object)null) { StartChase(val); } else if (Time.time > specialUntil) { ((EnemyAI)this).SwitchToBehaviourState(1); roamToKitchen = false; PickRoamDestination(); } break; } case 2: if (!KeepChasing(memory)) { GiveUpChase(); break; } base.agent.speed = Scaled(ChaseSpeed, 0.6f); Follow(base.targetPlayer); if (!chica) { TryGlitchForward(); } break; default: ((EnemyAI)this).SwitchToBehaviourState(1); break; } } private void TryGlitchForward() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (Time.time < nextGlitch || !((Behaviour)base.agent).enabled || !base.agent.hasPath) { return; } nextGlitch = Time.time + Random.Range(5f, 12f) / Agg; if (!ObservedByAnyone(40f)) { Vector3 steeringTarget = base.agent.steeringTarget; NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(Vector3.MoveTowards(((Component)this).transform.position, steeringTarget, Random.Range(2f, 3.5f)), ref val, 1.5f, base.agent.areaMask)) { base.agent.Warp(((NavMeshHit)(ref val)).position); ((EnemyAI)this).SyncPositionToClients(); } } } private void FreddyAI() { //IL_00a5: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) switch (base.currentBehaviourStateIndex) { case 0: StopMoving(); if (Time.time >= activateAt) { ((EnemyAI)this).SwitchToBehaviourState(1); SendSound(1); nextLaugh = Time.time + 10f; hasRoamDest = false; } break; case 1: case 3: { bool num = ObservedByAnyone(); if ((Object)(object)base.targetPlayer == (Object)null) { PlayerControllerB val = Detect(); if ((Object)(object)val != (Object)null) { base.targetPlayer = val; lastSawTarget = Time.time; lastSeenPos = ((Component)val).transform.position; SendSound(0); } } if ((Object)(object)base.targetPlayer != (Object)null && !KeepChasing(10f * Agg)) { base.targetPlayer = null; base.movingTowardsTargetPlayer = false; if (base.currentBehaviourStateIndex == 3) { ((EnemyAI)this).SwitchToBehaviourState(1); } roamDest = lastSeenPos; hasRoamDest = ((EnemyAI)this).SetDestinationToPosition(lastSeenPos, true); } if (num) { StopMoving(); wasFrozen = true; } else { if ((Object)(object)base.targetPlayer != (Object)null) { base.agent.speed = Scaled(ChaseSpeed, 0.6f); Follow(base.targetPlayer); } else { base.moveTowardsDestination = true; Roam(kitchenBias: false); } if (wasFrozen && Time.time > nextLaugh) { SendSound(1); nextLaugh = Time.time + Random.Range(9f, 16f); } wasFrozen = false; } if ((Object)(object)base.targetPlayer == (Object)null) { break; } float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position); if (base.currentBehaviourStateIndex == 1 && num2 < 12f && Time.time > musicCooldownUntil) { ((EnemyAI)this).SwitchToBehaviourState(3); SendSound(6); specialUntil = Time.time + 7.5f / Mathf.Sqrt(Agg); } else if (base.currentBehaviourStateIndex == 3 && Time.time > specialUntil) { if (num2 < 20f) { ((EnemyAI)this).SwitchToBehaviourState(4); specialUntil = Time.time + 3.5f; SendSound(0); } else { ((EnemyAI)this).SwitchToBehaviourState(1); } musicCooldownUntil = Time.time + 25f / Agg; } break; } case 4: if ((Object)(object)base.targetPlayer == (Object)null || !((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true) || Time.time > specialUntil) { ((EnemyAI)this).SwitchToBehaviourState(1); break; } base.agent.speed = Scaled(7.5f); Follow(base.targetPlayer); break; default: ((EnemyAI)this).SwitchToBehaviourState(1); break; } } private void FoxyAI() { //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_037e: 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_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) switch (base.currentBehaviourStateIndex) { case 0: case 3: case 4: { StopMoving(); if (Time.time < activateAt) { break; } bool num = ObservedByAnyone(30f); float aIIntervalTime = base.AIIntervalTime; if (num) { foxyMeter = Mathf.Max(0f, foxyMeter - aIIntervalTime * 0.6f); } else { foxyMeter += aIIntervalTime * Agg; } int num2 = ((foxyMeter > 62f) ? 3 : ((foxyMeter > 42f) ? 2 : ((foxyMeter > 20f) ? 1 : 0))) switch { 2 => 4, 1 => 3, 0 => 0, _ => 2, }; if (num2 == 2) { base.targetPlayer = Detect(); zigLegs = 0; zigSide = ((Random.value < 0.5f) ? 1 : (-1)); if ((Object)(object)base.targetPlayer == (Object)null) { NextZig(); } ((EnemyAI)this).SwitchToBehaviourState(2); SendSound(4); specialUntil = Time.time + 16f; } else if (num2 != base.currentBehaviourStateIndex) { if (num2 > base.currentBehaviourStateIndex || num2 == 0) { SendSound(2); } ((EnemyAI)this).SwitchToBehaviourState(num2); } break; } case 2: { OfficeDoor officeDoor = OfficeDoor.ClosedNear(((Component)this).transform.position, 3.2f); if ((Object)(object)officeDoor != (Object)null) { StopMoving(); if (Time.time > nextBang) { nextBang = Time.time + 0.8f; SendSound(5); if (++bangs >= 5) { officeDoor.ForceOpen(); bangs = 0; nextBang = Time.time + 1.2f; } } break; } base.agent.speed = Scaled(ChaseSpeed, 0.35f); base.agent.acceleration = 60f; if ((Object)(object)base.targetPlayer == (Object)null) { base.targetPlayer = Detect(); if ((Object)(object)base.targetPlayer != (Object)null) { lastSawTarget = Time.time; } } bool flag = Time.time > specialUntil; if ((Object)(object)base.targetPlayer != (Object)null) { if (!KeepChasing(3f)) { base.targetPlayer = null; base.movingTowardsTargetPlayer = false; NextZig(); } else { Follow(base.targetPlayer); } } else if (!hasRoamDest || Vector3.Distance(((Component)this).transform.position, roamDest) < 2.5f) { if (zigLegs >= 6) { flag = true; } else { NextZig(); } } if (flag) { base.targetPlayer = null; base.movingTowardsTargetPlayer = false; ((EnemyAI)this).SwitchToBehaviourState(8); ((EnemyAI)this).SetDestinationToPosition(homePos, false); } break; } case 8: base.agent.speed = Scaled(WalkSpeed, 0.2f); base.agent.acceleration = 30f; ((EnemyAI)this).SetDestinationToPosition(homePos, false); if (Vector3.Distance(((Component)this).transform.position, homePos) < 1f) { base.agent.Warp(homePos); ((Component)this).transform.rotation = Quaternion.Euler(0f, homeYaw, 0f); StopMoving(); foxyMeter = 0f; ((EnemyAI)this).SwitchToBehaviourState(0); SendSound(2); } break; default: ((EnemyAI)this).SwitchToBehaviourState(8); break; } } private void SpringtrapAI() { //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: 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) if (SpringtrapCrossing()) { return; } switch (base.currentBehaviourStateIndex) { case 0: { StopMoving(); PlayerControllerB val = ClosestTargetable(3.5f); if ((Object)(object)val != (Object)null) { StartChase(val); } else if (Time.time >= activateAt) { ((EnemyAI)this).SwitchToBehaviourState(1); hasRoamDest = false; SendSound(8); } break; } case 1: { PlayerControllerB val2 = ((base.isOutside && Time.time - lastSawTarget < 30f) ? NearestMet(mySide: true) : null); if ((Object)(object)val2 != (Object)null) { base.agent.speed = Scaled(WalkSpeed) * 1.3f; ((EnemyAI)this).SetDestinationToPosition(((Component)val2).transform.position, true); } else { Roam(kitchenBias: false); } PlayerControllerB val3 = Detect(); if ((Object)(object)val3 != (Object)null) { StartChase(val3); } else if (!base.isOutside && Time.time > nextVent && !ObservedByAnyone(40f)) { SendSound(9); StopMoving(); ((EnemyAI)this).SwitchToBehaviourState(6); specialUntil = Time.time + Random.Range(7f, 14f) / Mathf.Sqrt(Agg); nextVent = Time.time + Random.Range(70f, 130f) / Agg; } break; } case 2: if (!KeepChasing(10f * Agg)) { GiveUpChase(); } else if (!base.isOutside && Mathf.Abs(((Component)base.targetPlayer).transform.position.y - ((Component)this).transform.position.y) > 4f && !FrightLift.AnyoneInside && !ObservedByAnyone(30f)) { SendSound(9); StopMoving(); ((EnemyAI)this).SwitchToBehaviourState(6); specialUntil = Time.time + Random.Range(4f, 7f); } else { base.agent.speed = Scaled(ChaseSpeed, 0.6f); Follow(base.targetPlayer); } break; case 6: StopMoving(); if (!(Time.time < specialUntil) && !FrightLift.AnyoneInside) { VentOutNearSomeone(); ((EnemyAI)this).SwitchToBehaviourState(1); hasRoamDest = false; SendSound(9); } break; default: ((EnemyAI)this).SwitchToBehaviourState(1); break; } } private bool OnMySide(PlayerControllerB p) { if (p.isInsideFactory != base.isOutside) { if (base.isOutside) { return !p.isInHangarShipRoom; } return true; } return false; } private PlayerControllerB NearestMet(bool mySide) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB result = null; float num = float.MaxValue; PlayerControllerB[] players = Players; foreach (PlayerControllerB val in players) { if (Alive(val) && met.Contains((int)val.playerClientId) && OnMySide(val) == mySide && (mySide || val.isInsideFactory || !val.isInHangarShipRoom)) { float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position); if (num2 < num) { result = val; num = num2; } } } return result; } private bool SpringtrapCrossing() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB[] players = Players; foreach (PlayerControllerB val in players) { if (Alive(val) && OnMySide(val) && !met.Contains((int)val.playerClientId)) { float num = Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position); if (!(num > 25f) && ((Object)(object)base.targetPlayer == (Object)(object)val || num < 4f || val.HasLineOfSightToPosition(HeadPos, 45f, 25, -1f, -1))) { met.Add((int)val.playerClientId); } } } int currentBehaviourStateIndex = base.currentBehaviourStateIndex; bool flag = base.isOutside && currentBehaviourStateIndex != 2 && (Time.time - lastSawTarget > 30f || Time.time - upstairsSince > 120f); if (currentBehaviourStateIndex == 0 || currentBehaviourStateIndex == 2 || currentBehaviourStateIndex == 5 || !(((Object)(object)NearestMet(mySide: true) == (Object)null && (base.isOutside || (Object)(object)NearestMet(mySide: false) != (Object)null)) || flag)) { crossSince = -1f; return false; } EntranceTeleport val2 = null; EntranceTeleport val3 = null; EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>(); foreach (EntranceTeleport val4 in array) { if (val4.entranceId == 0) { if (val4.isEntranceToBuilding == base.isOutside) { val2 = val4; } else { val3 = val4; } } } if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null) { crossSince = -1f; return false; } if (crossSince < 0f) { crossSince = Time.time; StopMoving(); if (currentBehaviourStateIndex != 6) { SendSound(9); ((EnemyAI)this).SwitchToBehaviourState(6); } } StopMoving(); if (Time.time - crossSince > 6f) { Vector3 val5 = (((Object)(object)val3.entrancePoint != (Object)null) ? val3.entrancePoint.position : ((Component)val3).transform.position); NavMeshHit val6 = default(NavMeshHit); if (NavMesh.SamplePosition(val5, ref val6, 4f, -1)) { val5 = ((NavMeshHit)(ref val6)).position; } base.agent.Warp(val5); base.isOutside = val5.y > -80f; ((EnemyAI)this).GetAINodes(); hasRoamDest = false; crossSince = -1f; base.targetPlayer = null; if (base.isOutside) { upstairsSince = Time.time; lastSawTarget = Time.time; } else { met.Clear(); } ((EnemyAI)this).SwitchToBehaviourState(1); SendSound(9); ((EnemyAI)this).SyncPositionToClients(); Plugin.Log.LogInfo((object)("Springtrap followed someone " + (base.isOutside ? "up into the pizzeria" : "back down into Fazbear's Fright") + ".")); } return true; } private void VentOutNearSomeone() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = RoamPoints(); if (list.Count == 0) { return; } List<PlayerControllerB> list2 = new List<PlayerControllerB>(); PlayerControllerB[] players = Players; foreach (PlayerControllerB val in players) { if (((EnemyAI)this).PlayerIsTargetable(val, false, false, true) && val.isInsideFactory) { list2.Add(val); } } Vector3 val2 = list[Random.Range(0, list.Count)]; if (list2.Count > 0) { PlayerControllerB val3 = (((Object)(object)base.targetPlayer != (Object)null && list2.Contains(base.targetPlayer)) ? base.targetPlayer : list2[Random.Range(0, list2.Count)]); for (int j = 0; j < 30; j++) { Vector3 val4 = list[Random.Range(0, list.Count)]; float num = Vector3.Distance(val4, ((Component)val3).transform.position); if (!(num < 8f) && !(num > 20f) && !val3.HasLineOfSightToPosition(val4 + Vector3.up * 1.2f, 70f, 25, -1f, -1)) { val2 = val4; break; } } } NavMeshHit val5 = default(NavMeshHit); if (NavMesh.SamplePosition(val2, ref val5, 2f, base.agent.areaMask)) { val2 = ((NavMeshHit)(ref val5)).position; } base.agent.Warp(val2); ((EnemyAI)this).SyncPositionToClients(); } private void NextZig() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_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_0079: 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_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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_012f: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = RoamPoints(); if (list.Count == 0) { hasRoamDest = false; return; } Vector3 velocity = base.agent.velocity; Vector3 val; if (!(((Vector3)(ref velocity)).sqrMagnitude > 0.5f)) { val = ((Component)this).transform.forward; } else { velocity = base.agent.velocity; val = ((Vector3)(ref velocity)).normalized; } Vector3 val2 = val; val2.y = 0f; Vector3 val3 = Vector3.Cross(Vector3.up, ((Vector3)(ref val2)).normalized) * (float)zigSide; Vector3 val4 = list[Random.Range(0, list.Count)]; float num = float.MinValue; for (int i = 0; i < 16; i++) { Vector3 val5 = list[Random.Range(0, list.Count)]; Vector3 val6 = val5 - ((Component)this).transform.position; val6.y = 0f; float magnitude = ((Vector3)(ref val6)).magnitude; if (!(magnitude < 8f) && !(magnitude > 22f)) { float num2 = Vector3.Dot(val6 / magnitude, val3) * 2f + Vector3.Dot(val6 / magnitude, val2) + Random.value * 0.5f; if (num2 > num) { num = num2; val4 = val5; } } } zigSide = -zigSide; zigLegs++; roamDest = val4; hasRoamDest = ((EnemyAI)this).SetDestinationToPosition(val4, true); } private void YellowBearAI() { StopMoving(); switch (base.currentBehaviourStateIndex) { case 6: if (!(Time.time < nextAppear)) { nextAppear = Time.time + Random.Range(35f, 80f) / Agg; TryAppearBehindSomeone(); } break; case 7: if (Time.time > specialUntil || appearTarget < 0 || !Alive(Players[appearTarget])) { ((EnemyAI)this).SwitchToBehaviourState(6); } break; default: ((EnemyAI)this).SwitchToBehaviourState(6); break; case 0: break; } } private void TryAppearBehindSomeone() { //IL_006c: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) List<PlayerControllerB> list = new List<PlayerControllerB>(); PlayerControllerB[] players = Players; foreach (PlayerControllerB val in players) { if (Alive(val) && !val.isInHangarShipRoom) { list.Add(val); } } if (list.Count == 0) { return; } PlayerControllerB val2 = list[Random.Range(0, list.Count)]; Transform transform = ((Component)val2.gameplayCamera).transform; Vector3 val3 = new Vector3(transform.forward.x, 0f, transform.forward.z); Vector3 val4 = -((Vector3)(ref val3)).normalized; NavMeshHit val6 = default(NavMeshHit); for (int j = 0; j < 6; j++) { Vector3 val5 = Vector3.Cross(Vector3.up, val4) * Random.Range(-2.5f, 2.5f); if (NavMesh.SamplePosition(((Component)val2).transform.position + val4 * Random.Range(3f, 6f) + val5, ref val6, 2f, -1) && !Physics.Linecast(((Component)val2.gameplayCamera).transform.position, ((NavMeshHit)(ref val6)).position + Vector3.up * 0.8f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { Vector3 val7 = ((Component)val2).transform.position - ((NavMeshHit)(ref val6)).position; val7.y = 0f; Quaternion val8 = Quaternion.LookRotation(((Vector3)(ref val7)).normalized); float y = ((Quaternion)(ref val8)).eulerAngles.y; appearTarget = (int)val2.playerClientId; specialUntil = Time.time + 14f; FazNet.Send(new NetEvent { kind = NetKind.GoldenAppear, enemy = ((NetworkBehaviour)this).NetworkObjectId, player = appearTarget, pos = ((NavMeshHit)(ref val6)).position, yaw = y }); break; } } } public void OnNetEvent(NetEvent e) { //IL_0110: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) switch (e.kind) { case NetKind.Sound: PlayOneShot(e.sound); break; case NetKind.Jumpscare: { jumpscareUntil = Time.time + 1.5f; PlayerControllerB val = ((e.player >= 0 && e.player < Players.Length) ? Players[e.player] : null); if ((Object)(object)val != (Object)null) { Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude > 0.01f) { ((Component)this).transform.rotation = Quaternion.LookRotation(val2); } } if (((NetworkBehaviour)this).IsOwner) { StopMoving(); base.targetPlayer = null; } break; } case NetKind.GoldenAppear: ((Behaviour)base.agent).enabled = ((NetworkBehaviour)this).IsOwner; if (((NetworkBehaviour)this).IsOwner && base.agent.isOnNavMesh) { base.agent.Warp(e.pos); } ((Component)this).transform.position = e.pos; base.serverPosition = e.pos; ((Component)this).transform.rotation = Quaternion.Euler(0f, e.yaw, 0f); appearTarget = e.player; stareTime = 0f; sentDismiss = false; ((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(7); if (((NetworkBehaviour)this).IsOwner) { specialUntil = Time.time + 14f; } break; case NetKind.GoldenDismiss: PlayOneShot(3); ((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(6); if (((NetworkBehaviour)this).IsOwner) { nextAppear = Time.time + Random.Range(35f, 80f) / Agg; } break; } } private void PlayOneShot(byte s) { if ((Object)(object)base.creatureVoice == (Object)null) { return; } AudioClip val = null; float num = Plugin.Volume.Value; switch (s) { case 0: val = ((character != CharacterId.Springtrap || !((Object)(object)FnafAudio.Get("danger") != (Object)null)) ? (FnafAudio.Get((Random.value < 0.3f) ? "robotvoice" : "garble") ?? Sfx.Moan(def.screamSeed, def.moanPitch)) : FnafAudio.Get("danger")); break; case 1: { val = FnafAudio.Get("laugh") ?? Sfx.Laugh(); num *= 1.2f; AudioClip val3 = FnafAudio.Get("deepsteps"); if ((Object)(object)val3 != (Object)null) { AudioSource creatureSFX2 = base.creatureSFX; if (creatureSFX2 != null) { creatureSFX2.PlayOneShot(val3, Plugin.Volume.Value * 0.8f); } } break; } case 2: val = FnafAudio.Get("curtain") ?? Sfx.Curtain(); break; case 3: val = FnafAudio.Get("static") ?? Sfx.Static(); break; case 4: val = FnafAudio.Get("foxyrun") ?? Sfx.Scream(def.screamSeed, def.screamPitch); num *= (((Object)(object)FnafAudio.Get("foxyrun") != (Object)null) ? 1f : 0.7f); break; case 5: val = FnafAudio.Get("knock") ?? Sfx.RunBang(); break; case 6: val = FnafAudio.Get("poweroff"); break; case 7: val = FnafAudio.Get("shutdown") ?? Sfx.Shutdown(); break; case 9: val = FnafAudio.Get("vent") ?? FnafAudio.Get("knock") ?? Sfx.RunBang(); break; case 8: { val = FnafAudio.Get("boot") ?? Sfx.Boot(); AudioClip val2 = FnafAudio.Get("garble"); if ((Object)(object)val2 != (Object)null) { AudioSource creatureSFX = base.creatureSFX; if (creatureSFX != null) { creatureSFX.PlayOneShot(val2, Plugin.Volume.Value * 0.6f); } } break; } } if (!((Object)(object)val == (Object)null)) { if (((Object)val).name == "VentOpen1" || ((Object)val).name == "VentCrawl1") { ventVoice(((Object)val).name).PlayOneShot(val, Mathf.Clamp01(num)); return; } base.creatureVoice.PlayOneShot(val, Mathf.Clamp01(num)); WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, val, num); } } private AudioSource ventVoice(string objName) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) if (ventVoices.TryGetValue(objName, out var value) && (Object)(object)value != (Object)null) { return value; } GameObject val = new GameObject(objName); val.transform.SetParent(((Component)this).transform, false); value = val.AddComponent<AudioSource>(); value.spatialBlend = base.creatureVoice.spatialBlend; value.rolloffMode = base.creatureVoice.rolloffMode; value.minDistance = base.creatureVoice.minDistance; value.maxDistance = base.creatureVoice.maxDistance; value.outputAudioMixerGroup = base.creatureVoice.outputAudioMixerGroup; ventVoices[objName] = value; return value; } private bool CanKillOnTouch(PlayerControllerB p) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (Time.time < jumpscareUntil || !NightActive || base.currentBehaviourStateIndex == 5) { return false; } int currentBehaviourStateIndex = base.currentBehaviourStateIndex; switch (character) { case CharacterId.Bonnie: case CharacterId.Chica: switch (currentBehaviourStateIndex) { case 3: return character == CharacterId.Chica; default: return false; case 1: case 2: return true; } case CharacterId.Freddy: switch (currentBehaviourStateIndex) { case 4: return true; default: return false; case 1: case 3: return !p.HasLineOfSightToPosition(HeadPos, 45f, 40, -1f, -1); } case CharacterId.Foxy: return currentBehaviourStateIndex == 2; case CharacterId.Springtrap: if (currentBehaviourStateIndex != 1) { return currentBehaviourStateIndex == 2; } return true; default: return false; } } public override void OnCollideWithPlayer(Collider other) { ((EnemyAI)this).OnCollideWithPlayer(other); PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false); if (!((Object)(object)val == (Object)null) && CanKillOnTouch(val)) { Jumpscare.Begin(this, val); } } public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { ((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID); if ((Object)(object)base.creatureSFX != (Object)null) { base.creatureSFX.PlayOneShot(Sfx.Step(2), Plugin.Volume.Value); } if (!((NetworkBehaviour)this).IsOwner) { return; } if (character == CharacterId.YellowBear) { if (base.currentBehaviourStateIndex == 7 || base.currentBehaviourStateIndex == 0) { FazNet.Send(new NetEvent { kind = NetKind.GoldenDismiss, enemy = ((NetworkBehaviour)this).NetworkObjectId }); } } else if (!(Time.time < offlineImmuneUntil) && (base.currentBehaviourStateIndex != 5 || !(Time.time < offlineUntil - 2f))) { offlineUntil = Time.time + Mathf.Lerp(9f, 6f, Mathf.Clamp01(Agg - 0.5f)) + (float)Mathf.Max(0, force - 1) * 1.5f; if (base.currentBehaviourStateIndex != 5) { stateBeforeOffline = base.currentBehaviourStateIndex; ((EnemyAI)this).SwitchToBehaviourState(5); SendSound(7); } base.targetPlayer = null; StopMoving(); } } public override void Update() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).Update(); if (character == CharacterId.Springtrap) { base.isOutside = ((Component)this).transform.position.y > -80f; } if (!((Object)(object)rig == (Object)null) && def != null) { int currentBehaviourStateIndex = base.currentBehaviourStateIndex; bool flag = Time.time < jumpscareUntil; Pose pose = Pose.Stand; pose = character switch { CharacterId.Foxy => currentBehaviourStateIndex switch { 3 => Pose.Peek, 0 => Pose.Crouch, _ => Pose.Stand, }, CharacterId.YellowBear => Pose.Slumped, CharacterId.Springtrap => (currentBehaviourStateIndex == 0) ? Pose.Slumped : Pose.Stand, _ => (currentBehaviourStateIndex == 0 && onStage) ? Pose.Perform : ((currentBehaviourStateIndex == 3 && character == CharacterId.Chica) ? Pose.Perform : Pose.Stand), }; if (currentBehaviourStateIndex == 5) { pose = Pose.Offline; } if (flag) { pose = Pose.Lunge; } rig.pose = pose; if (!flag) { rig.jawTarget = 0f; } rig.singing = currentBehaviourStateIndex == 0 && onStage && character != CharacterId.Foxy && character != CharacterId.YellowBear; rig.frozen = character == CharacterId.Freddy && (currentBehaviourStateIndex == 1 || currentBehaviourStateIndex == 3) && !flag && FreddyLooksStopped(); rig.lookAt = LookTarget(); EyeMode eyes = EyeMode.Normal; switch (character) { case CharacterId.Bonnie: case CharacterId.Chica: eyes = ((currentBehaviourStateIndex != 0) ? EyeMode.Hollow : EyeMode.Normal); break; case CharacterId.Freddy: eyes = ((currentBehaviourStateIndex == 3 || currentBehaviourStateIndex == 4) ? EyeMode.Glow : EyeMode.Normal); break; case CharacterId.Foxy: eyes = currentBehaviourStateIndex switch { 0 => EyeMode.Normal, 2 => EyeMode.Glow, _ => EyeMode.Glow, }; break; case CharacterId.YellowBear: eyes = EyeMode.Hollow; break; case CharacterId.Springtrap: eyes = ((currentBehaviourStateIndex == 0) ? EyeMode.Hollow : EyeMode.Glow); break; } if (currentBehaviourStateIndex == 5) { eyes = EyeMode.Off; } rig.SetEyes(eyes); if (character == CharacterId.Bonnie) { rig.ShowProp(currentBehaviourStateIndex == 0); } Animate(currentBehaviourStateIndex, flag); UpdateLoopAudio(currentBehaviourStateIndex); if (character == CharacterId.YellowBear) { ApplyVisibility((currentBehaviourStateIndex == 0 || currentBehaviourStateIndex == 7 || flag) && Time.time >= localHideUntil); YellowBearLocal(currentBehaviourStateIndex); } else { ApplyVisibility(Time.time >= localHideUntil && (character != CharacterId.Springtrap || currentBehaviourStateIndex != 6)); } LocalFear(currentBehaviourStateIndex); } } private void Animate(int s, bool scaring) { //IL_002c: 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) //IL_003c: 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) SourceAnimator animator = rig.animator; if ((Object)(object)animator == (Object)null) { return; } float num = Mathf.Max(Time.deltaTime, 0.0001f); Vector3 val = ((Component)this).transform.position - lastAnimPos; val.y = 0f; lastAnimPos = ((Component)this).transform.position; float num2 = ((Vector3)(ref val)).magnitude / num; if (num2 > 25f) { num2 = 0f; } animSpeed = Mathf.Lerp(animSpeed, num2, 1f - Mathf.Exp((0f - num) * 6f)); if (s != prevAnimState) { if (s == 5) { offlineAnimStart = Time.time; } if (prevAnimState == 5) { bootAnimUntil = Time.time + 1.2f; } prevAnimState = s; } if (!string.IsNullOrEmpty(animator.devClip)) { animator.Play(animator.devClip); return; } if (scaring) { if (!lastScaring && !animator.PlayJumpscare(character)) { animator.Stop(); } lastScaring = true; return; } lastScaring = false; animator.frozen = rig.frozen; bool loopIt = true; float playSpeed = 1f; bool flag = false; string text; if (character == CharacterId.YellowBear) { text = "gsit"; loopIt = false; flag = animator.Current != "gsit"; } else if (s == 5) { text = ((Time.time - offlineAnimStart < 1.65f || !animator.Has("burnoutidle")) ? "burnout" : "burnoutidle"); loopIt = false; } else if (Time.time < bootAnimUntil && animator.Has("startingup")) { text = "startingup"; loopIt = false; } else if (character == CharacterId.Foxy) { switch (s) { case 0: text = "idlef2"; break; case 3: case 4: text = ((s == 3) ? "idlef1" : "idlef2"); break; default: text = ((animSpeed < 0.3f) ? "idlef1" : ((animSpeed < 4f) ? "walkf1" : "runf1")); break; } if (text == "walkf1") { playSpeed = Mathf.Clamp(animSpeed / 1.5f, 0.6f, 2.2f); } if (text == "runf1") { playSpeed = Mathf.Clamp(animSpeed / 6f, 0.8f, 2.4f); } } else if (s == 0) { if (character == CharacterId.Springtrap) { animator.Stop(); return; } text = (onStage ? "idle" : "burnoutidle"); loopIt = onStage; } else if (character == CharacterId.Chica && s == 3) { text = "knockingf2"; } else if (character == CharacterId.Springtrap && animator.Has("stalk") && !rig.frozen) { text = ((animSpeed < 0.25f) ? "idle" : "stalk"); if (text == "stalk") { playSpeed = Mathf.Clamp(animSpeed / 1.6f, 0.65f, 1.6f); } } else if (rig.frozen && animator.Current != null) { text = animator.Current; } else { text = ((animSpeed < 0.25f) ? "idle" : ((animSpeed < 3.4f) ? "walk" : "run")); if (text == "walk") { playSpeed = Mathf.Clamp(animSpeed / 1.4f, 0.6f, 2.2f); } if (text == "run") { playSpeed = Mathf.Clamp(animSpeed / 4f, 0.8f, 2.2f); } } if (!animator.Has(text)) { text = (animator.Has("idle") ? "idle" : (animator.Has("idlef1") ? "idlef1" : null)); } if (text == null) { animator.Stop(); return; } bool num3 = animator.Current != text; animator.Play(text, loopIt, playSpeed); if (num3 && flag) { animator.SeekEnd(); } } private bool FreddyLooksStopped() { //IL_0006: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.position - lastFreddyPos; float magnitude = ((Vector3)(ref val)).magnitude; lastFreddyPos = ((Component)this).transform.position; freddyStillTime = ((magnitude < 0.004f) ? (freddyStillTime + Time.deltaTime) : 0f); return freddyStillTime > 0.08f; } private Vector3? LookTarget() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0093: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.targetPlayer != (Object)null && Alive(base.targetPlayer)) { return ((Component)base.targetPlayer.gameplayCamera).transform.position; } float num = 16f; Vector3? result = null; PlayerControllerB[] players = Players; foreach (PlayerControllerB val in players) { if (Alive(val)) { float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position); if (num2 < num) { num = num2; result = ((Component)val.gameplayCamera).transform.position; } } } return result; } private void UpdateLoopAudio(int s) { if ((Object)(object)loopSource == (Object)null) { return; } AudioClip val = null; float num = Plugin.Volume.Value; AudioClip val2 = FnafAudio.Get("musicbox") ?? Sfx.MusicBox(); if (character == CharacterId.Freddy && s == 3) { val = val2; num *= 1f; } else if (character == CharacterId.Freddy && s == 0 && onStage) { val = val2; num *= 0.18f; } else if (character == CharacterId.Chica && s == 3) { AudioClip val3 = loopPick ?? (loopPick = FnafAudio.Get("pots")); if ((Object)(object)val3 == (Object)null && (Object)(object)FnafAudio.Get("clang") != (Object)null) { if (Time.time > nextClang) { nextClang = Time.time + Random.Range(0.25f, 0.9f); loopSource.PlayOneShot(FnafAudio.Get("clang"), Plugin.Volume.Value * Random.Range(0.6f, 1f)); } } else { val = val3 ?? Sfx.PotsAndPans(); num *= 0.9f; } } else if (character == CharacterId.YellowBear && s == 7) { val = FnafAudio.Get("whisper") ?? Sfx.Drone(); num *= 0.7f; } else if (character == CharacterId.Foxy && (s == 3 || s == 4)) { val = FnafAudio.Get("foxysong"); num *= 0.45f; } if ((Object)(object)val == (Object)null || s != lastLoopState) { loopPick = null; } if ((Object)(object)val == (Object)null) { if (loopSource.isPlaying) { loopSource.Stop(); } lastLoopState = s; return; } loopSource.volume = num; if (((Object)(object)loopSource.clip != (Object)(object)val || !loopSource.isPlaying || lastLoopState != s) && ((Object)(object)loopSource.clip != (Object)(object)val || !loopSource.isPlaying)) { loopSource.clip = val; loopSource.loop = true; loopSource.Play(); } lastLoopState = s; } private void ApplyVisibility(bool visible) { if (visible == visibleState) { return; } visibleState = visible; foreach (Renderer visual in rig.visuals) { if ((Object)(object)visual != (Object)null) { visual.enabled = visible; } } if ((Object)(object)touchCollider != (Object)null) { touchCollider.enabled = visible; } if ((Object)(object)scanCollider != (Object)null) { scanCollider.enabled = visible; } } private void YellowBearLocal(int s) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if (!Alive(val) || Jumpscare.Active || ((Object)(object)rig.animator != (Object)null && !string.IsNullOrEmpty(rig.animator.devClip))) { return; } if (s != 0 && s != 7) { stareTime = 0f; lookAwayTime = 0f; ItsMe.Hide((Object)(object)this); return; } Vector3 val2 = ((Component)this).transform.position + Vector3.up * 0.9f; if (val.HasLineOfSightToPosition(val2, 22f, 16, -1f, -1)) { stareTime += Time.deltaTime; lookAwayTime = 0f; if (stareTime > 0.35f) { ItsMe.Show((Object)(object)this, Mathf.Clamp01((stareTime - 0.35f) / 1.5f)); } } else if (stareTime > 0f) { lookAwayTime += Time.deltaTime; ItsMe.Hide((Object)(object)this); if (lookAwayTime > 0.25f && stareTime > 0.2f && !sentDismiss) { sentDismiss = true; val.JumpToFearLevel(0.7f, true); FazNet.Send(new NetEvent { kind = NetKind.GoldenDismiss, enemy = ((NetworkBehaviour)this).NetworkObjectId, player = (int)val.playerClientId }); } if (lookAwayTime > 0.25f) { stareTime = 0f; } } if (s == 0 && stareTime > 1.3f && !sentDismiss) { sentDismiss = true; ItsMe.Hide((Object)(object)this); val.JumpToFearLevel(0.9f, true); FazNet.Send(new NetEvent { kind = NetKind.GoldenDismiss, enemy = ((NetworkBehaviour)this).NetworkObjectId, player = (int)val.playerClientId }); } else if (s == 7 && stareTime > 2f) { ItsMe.Hide((Object)(object)this); Jumpscare.Begin(this, val); } } private void LocalFear(int s) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) fearTick -= Time.deltaTime; if (!(fearTick > 0f)) { fearTick = 0.5f; PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if (Alive(val) && (s == 2 || (character == CharacterId.Freddy && s == 4)) && Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position) < 15f && val.HasLineOfSightToPosition(HeadPos, 60f, 20, -1f, -1)) { val.JumpToFearLevel(0.55f, true); } } } public override void SetEnemyStunned(bool setToStunned, float setToStunTime = 1f, PlayerControllerB setStunnedByPlayer = null) { ((EnemyAI)this).SetEnemyStunned(setToStunned, setToStunTime, setStunnedByPlayer); } 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_0048: 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) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID); if (((NetworkBehaviour)this).IsOwner && !(noiseLoudness < 0.4f) && NightActive && (character == CharacterId.Bonnie || character == CharacterId.Chica || character == CharacterId.Springtrap) && base.currentBehaviourStateIndex == 1 && Vector3.Distance(noisePosition, ((Component)this).transform.position) < 25f) { roamDest = noisePosition; roamToKitchen = false; hasRoamDest = ((EnemyAI)this).SetDestinationToPosition(noisePosition, true); } } } internal enum CharacterId { Freddy, Bonnie, Chica, Foxy, YellowBear, Springtrap } internal class CharacterDef { public CharacterId id; public string name; public string scanSub; public Color body; public Color accent; public Color dark; public Color iris; public Color bowtie; public float walkSpeed; public float runSpeed; public int screamSeed; public float screamPitch; public float moanPitch; public float powerLevel; public float height = 1f; public static readonly CharacterDef[] All = new CharacterDef[6] { new CharacterDef { id = CharacterId.Freddy, name = "Freddy Fazbear", scanSub = "Only moves when nobody is looking.", body = new Color(0.36f, 0.22f, 0.11f), accent = new Color(0.62f, 0.45f, 0.27f), dark = new Color(0.04f, 0.04f, 0.04f), iris = new Color(0.25f, 0.55f, 1f), bowtie = new Color(0.03f, 0.03f, 0.03f), walkSpeed = 4.2f, runSpeed = 8.5f, screamSeed = 1, screamPitch = 330f, moanPitch = 70f, powerLevel = 2f, height = 1.57f }, new CharacterDef { id = CharacterId.Bonnie, name = "Bonnie", scanSub = "First to leave the stage. Jumpy.", body = new Color(0.3f, 0.3f, 0.62f), accent = new Color(0.55f, 0.52f, 0.78f), dark = new Color(0.05f, 0.05f, 0.08f), iris = new Color(1f, 0.15f, 0.35f), bowtie = new Color(0.7f, 0.05f, 0.08f), walkSpeed = 3.6f, runSpeed = 6.8f, screamSeed = 2, screamPitch = 420f, moanPitch = 92f, powerLevel = 2f, height = 1.5f }, new CharacterDef { id = CharacterId.Chica, name = "Chica", scanSub = "Hungry. Listen for the kitchen.", body = new Color(0.95f, 0.76f, 0.12f), accent = new Color(0.98f, 0.88f, 0.55f), dark = new Color(0.08f, 0.06f, 0.03f), iris = new Color(0.75f, 0.25f, 1f), bowtie = new Color(0.95f, 0.45f, 0.05f), walkSpeed = 3.2f, runSpeed = 6f, screamSeed = 3, screamPitch = 470f, moanPitch = 110f, powerLevel = 2f, height = 1.52f }, new CharacterDef { id = CharacterId.Foxy, name = "Foxy", scanSub = "Keep an eye on Pirate Cove.", body = new Color(0.58f, 0.12f, 0.08f), accent = new Color(0.78f, 0.55f, 0.42f), dark = new Color(0.05f, 0.03f, 0.03f), iris = new Color(1f, 0.85f, 0.15f), bowtie = new Color(0.35f, 0.2f, 0.1f), walkSpeed = 3.8f, runSpeed = 13.5f, screamSeed = 4, screamPitch = 380f, moanPitch = 85f, powerLevel = 2f, height = 1.55f }, new CharacterDef { id = CharacterId.YellowBear, name = "Yellow Bear", scanSub = "It's me.", body = new Color(0.78f, 0.58f, 0.1f), accent = new Color(0.88f, 0.72f, 0.3f), dark = new Color(0.02f, 0.02f, 0.03f), iris = new Color(1f, 1f, 1f), bowtie = new Color(0.05f, 0.12f, 0.25f), walkSpeed = 0f, runSpeed = 0f, screamSeed = 5, screamPitch = 260f, moanPitch = 55f, powerLevel = 1f, height = 1.57f }, new CharacterDef { id = CharacterId.Springtrap, name = "Springtrap", scanSub = "He always comes back.", body = new Color(0.4f, 0.42f, 0.2f), accent = new Color(0.52f, 0.49f, 0.3f), dark = new Color(0.06f, 0.05f, 0.03f), iris = new Color(0.92f, 0.92f, 0.85f), bowtie = new Color(0.1f, 0.09f, 0.05f), walkSpeed = 2.6f, runSpeed = 5.8f, screamSeed = 6, screamPitch = 300f, moanPitch = 62f, powerLevel = 3f, height = 1.4f } }; public static CharacterDef Get(CharacterId id) { return All[(int)id]; } public static float ModelHeight(CharacterId id) { return id switch { CharacterId.Freddy => 3.6f, CharacterId.Bonnie => 3.8f, CharacterId.Chica => 3.5f, CharacterId.Foxy => 3.6f, CharacterId.YellowBear => 3.6f, _ => 3.5f, }; } } [HarmonyPatch] internal static class DevMode { public static readonly bool On = File.Exists(Path.Combine(Paths.ConfigPath, "lethalfazbear.dev")); public static readonly bool Clean = File.Exists(Path.Combine(Paths.ConfigPath, "lethalfazbear.clean")); public static bool Invincible; public static bool ForceNight; private static bool hosted; private static bool launched; private static readonly FieldInfo camUp = AccessTools.Field(typeof(PlayerControllerB), "cameraUp"); [HarmonyPatch(typeof(PreInitSceneScript), "Start")] [HarmonyPostfix] private static void PreInit() { if (On) { SceneManager.LoadScene("InitSceneLANMode"); } } [HarmonyPatch(typeof(MenuManager), "Start")] [HarmonyPostfix] private static void Menu(MenuManager __instance) { if (On && !hosted && !__instance.isInitScene) { hosted = true; ((MonoBehaviour)__instance).StartCoroutine(Host()); } } private static IEnumerator Host() { yield return (object)new WaitForSeconds(2f); GameNetworkManager.Instance.currentSaveFileName = "LCFazbearDev"; GameNetworkManager.Instance.lobbyHostSettings = new HostSettings("FazbearDev", false, ""); Plugin.Log.LogInfo((object)"[dev] hosting LAN game on save LCFazbearDev"); GameNetworkManager.Instance.StartHost(); } [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] private static void Ship(StartOfRound __instance) { if (On && !launched) { launched = true; ((MonoBehaviour)__instance).StartCoroutine(Launch(__instance)); } } private static IEnumerator Launch(StartOfRound sor) { yield return (object)new WaitForSeconds(4f); if (((NetworkBehaviour)sor).IsServer && !((Object)(object)FazbearMoon.Level == (Object)null)) { Terminal val = Object.FindObjectOfType<Terminal>(); sor.ChangeLevelServerRpc(FazbearMoon.Level.levelID, ((Object)(object)val != (Object)null) ? val.groupCredits : 60); yield return (object)new WaitForSeconds(2f); Plugin.Log.LogInfo((object)"[dev] landing on 87-Fazbear"); sor.StartGame(); float t = 0f; while (!sor.shipHasLanded && t < 60f) { t += 0.5f; yield return (object)new WaitForSeconds(0.5f); } yield return (object)new WaitForSeconds(3f); if (File.Exists(Path.Combine(Paths.ConfigPath, "lethalfazbear.dumpaudio"))) { DumpAudio(); } LogSounds(); ScanStray(); if (File.Exists(Path.Combine(Paths.ConfigPath, "lethalfazbear.elevdump"))) { DumpElevator(); } if (File.Exists(Path.Combine(Paths.ConfigPath, "lethalfazbear.posters"))) { yield return PosterTour(); } else if (File.Exists(Path.Combine(Paths.ConfigPath, "lethalfazbear.rooms"))) { yield return Rooms(); } else if (File.Exists(Path.Combine(Paths.ConfigPath, "lethalfazbear.inspect"))) { yield return Inspect(); } else if (File.Exists(Path.Combine(Paths.ConfigPath, "lethalfazbear.follow"))) { yield return FollowTest(); } else if (File.Exists(Path.Combine(Paths.ConfigPath, "lethalfazbear.js"))) { yield return JumpscareGallery(); } else if (File.Exists(Path.Combine(Paths.ConfigPath, "lethalfazbear.anim"))) { yield return AnimGallery(); } else if (File.Exists(Path.Combine(Paths.ConfigPath, "lethalfazbear.frightlook"))) { yield return FrightLookTour(); } else if (File.Exists(Path.Combine(Paths.ConfigPath, "lethalfazbear.fright"))) { yield return FrightTour(); } else if (File.Exists(Path.Combine(Paths.ConfigPath, "lethalfazbear.tour"))) { yield return Tour(sor); } } } private static IEnumerator FShot(PlayerControllerB me, Vector3 pos, float yaw, float pitch, string name) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) p_Tp(me, pos, yaw); camUp?.SetValue(me, pitch); ((Component)me.gameplayCamera).transform.localEulerAngles = new Vector3(pitch, 0f, 0f); yield return (object)new WaitForSeconds(1.6f); camUp?.SetValue(me, pitch); ((Component)me.gameplayCamera).transform.localEulerAngles = new Vector3(pitch, 0f, 0f); yield return CaptureLater(0f, name); Plugin.Log.LogInfo((object)$"[dev] shot {name} at {pos}"); yield return (object)new WaitForSeconds(0.4f); } private static void ScanStray() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_0067: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) PizzeriaBuilder current = PizzeriaBuilder.Current; if (current == null) { return; } Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(current.Root.position, Vector3.zero); bool flag = false; MeshRenderer[] componentsInChildren = ((Component)current.Root).GetComponentsInChildren<MeshRenderer>(); foreach (MeshRenderer val in componentsInChildren) { if (((Object)((Component)val).gameObject).name.StartsWith("BSP")) { if (!flag) { bounds = ((Renderer)val).bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(((Renderer)val).bounds); } } } Plugin.Log.LogInfo((object)$"[dev] stray scan: pizzeria bounds {((Bounds)(ref bounds)).center} size {((Bounds)(ref bounds)).size}"); int num = 0; Renderer[] array = Object.FindObjectsOfType<Renderer>(); foreach (Renderer val2 in array) { if (!val2.enabled || !((Component)val2).gameObject.activeInHierarchy || val2 is ParticleSystemRenderer) { continue; } Bounds bounds2 = val2.bounds; if (!((Bounds)(ref bounds)).Intersects(bounds2)) { continue; } string text = ((Object)val2).name; Transform parent = ((Component)val2).transform.parent; while ((Object)(object)parent != (Object)null) { text = ((Object)parent).name + "/" + text; parent = parent.parent; } bool flag2 = ((Component)val2).transform.IsChildOf(current.Root); Vector3 size = ((Bounds)(ref bounds2)).size; float num2 = Mathf.Min(size.x, Mathf.Min(size.y, size.z)); float num3 = Mathf.Max(size.x, Mathf.Max(size.y, size.z)); bool flag3 = num2 < 0.05f && num3 > 1.5f; string text2 = (((Object)(object)val2.sharedMaterial != (Object)null) ? ((Object)val2.sharedMaterial).name : "-"); bool flag4 = (Object)(object)val2.sharedMaterial != (Object)null && val2.sharedMaterial.HasProperty("_EmissiveColor") && val2.sharedMaterial.GetColor("_EmissiveColor").r > 0.5f && val2.sharedMaterial.GetColor("_EmissiveColor").g < 0.3f; if ((!flag2 || (flag3 && !text.Contains("Poster") && !text.Contains("BSP")) || flag4) && !text.Contains("PlayerPhysicsBox") && (!text.Contains("Player") || !text.Contains("ScavengerModel"))) { Plugin.Log.LogInfo((object)string.Format("[dev] stray: {0} {1} mat {2} at {3} size {4}{5}", flag2 ? "ours" : "OTHER", text, text2, ((Bounds)(ref bounds2)).center, size, flag4 ? " RED" : "")); if (++num > 150) { break; } } } } private static IEnumerator Inspect() { PlayerControllerB me = GameNetworkManager.Instance.localPlayerController; Renderer[] array = Object.FindObjectsOfType<Renderer>(); Bounds bounds; foreach (Renderer val in array) { if (!val.enabled || !((Component)val).gameObject.activeInHierarchy || val is ParticleSystemRenderer) { continue; } string text = ((Object)val).name; Transform parent = ((Component)val).transform.parent; while ((Object)(object)parent != (Object)null) { text = ((Object)parent).name + "/" + text; parent = parent.parent; } bool flag = text.StartsWith("Environment/") || text.Contains("LightsContainer") || text.Contains("MapPropsContainer") || text.Contains("ItemShip"); bool flag2 = false; Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 == (Object)null) { continue; } if (((Object)val2).name.ToLowerInvariant().Contains("red")) { flag2 = true; } if (val2.HasProperty("_EmissiveColor")) { Color color = val2.GetColor("_EmissiveColor"); if (color.r > 0.3f && color.r > color.g * 2f && color.r > color.b * 2f) { flag2 = true; } } } if ((flag && !text.Contains("ScrapIconMap")) || flag2) { ManualLogSource log = Plugin.Log; object[] obj = new object[6] { flag2 ? "RED " : "", text, ((Component)val).gameObject.layer, ((Object)(object)val.sharedMaterial != (Object)null) ? ((Object)val.sharedMaterial).name : "-", null, null }; bounds = val.bounds; obj[4] = ((Bounds)(ref bounds)).center; bounds = val.bounds; obj[5] = ((Bounds)(ref bounds)).size; log.LogInfo((object)string.Format("[dev] look: {0}{1} layer {2} mat {3} at {4} size {5}", obj)); } } int i2 = 0; Renderer[] array2 = Object.FindObjectsOfType<Renderer>(); foreach (Renderer val3 in array2) { if (!val3.enabled || (Object)(object)((Component)val3).transform.parent == (Object)null || (Object)(object)((Component)val3).transform.parent.parent == (Object)null) { continue; } Transform root = ((Component)val3).transform.root; if (((Object)root).name.StartsWith("FancyDoorMapModelGlass") && !(((Object)val3).name != "DoorMesh")) { bounds = val3.bounds; Vector3 c = ((Bounds)(ref bounds)).center; bounds = val3.bounds; Vector3 size = ((Bounds)(ref bounds)).size; Vector3 n = ((size.x < size.z) ? Vector3.right : Vector3.forward); float[] array3 = new float[2] { 1f, -1f }; foreach (float num in array3) { Vector3 pos = new Vector3(c.x, root.position.y, c.z) + n * num * 3f; Quaternion val4 = Quaternion.LookRotation(-n * num); Tp(me, pos, ((Quaternion)(ref val4)).eulerAngles.y); yield return CaptureLater(1f, string.Format("g_{0}_{1}", i2, (num > 0f) ? "a" : "b")); } Plugin.Log.LogInfo((object)$"[dev] glass door {i2} at {c}"); i2++; } } string path = Path.Combine(Paths.BepInExRootPath, "fazbear_shots"); string[] array4 = new string[24] { "Scream1", "PhoneScream", "LeapScreamV2", "PumaScreamingB", "MeteorScream1", "LongRoar1", "ShortRoar1", "Roar", "ScreamOutsideShip1", "KillPlayerSpring", "NutcrackerAngry", "BabyBirdScream2", "SandWormRoar", "FGiantEatPlayerSFX", "MaskLaugh1", "MaskLaugh2", "Laugh1", "Laugh2", "laugh", "SnowmanLaugh2", "growl", "BWGrowl", "CawScream1", "PumaGrowl1" }; foreach (string text2 in array4) { AudioClip val5 = FnafAudio.Lethal(text2); if ((Object)(object)val5 == (Object)null) { Plugin.Log.LogInfo((object)("[dev] wav " + text2 + ": missing")); continue; } try { WriteWav(Path.Combine(path, "lc_" + text2 + ".wav"), val5); Plugin.Log.LogInfo((object)$"[dev] wav {text2}: {val5.length:F2}s {val5.channels}ch {val5.frequency}Hz"); } catch (Exception ex) { Plugin.Log.LogInfo((object)("[dev] wav " + text2 + ": " + ex.Message)); } } Plugin.Log.LogInfo((object)"[dev] inspect done"); } private static IEnumerator Rooms() { PlayerControllerB me = GameNetworkManager.Instance.localPlayerController; GameObject lamp = new GameObject("dev lamp"); lamp.transform.SetParent(((Component)me.gameplayCamera).transform, false); HDAdditionalLightData obj = GameObjectExtension.AddHDLight(lamp, (HDLightTypeAndShape)0); obj.SetIntensity(25f, (LightUnit)1); obj.SetRange(30f); Vector3[] spots = (Vector3[])(object)new Vector3[6] { new Vector3(-86f, -1.3f, -45f), new Vector3(-80f, -1.3f, -38f), new Vector3(-112f, -1.3f, -41f), new Vector3(-100f, -1.3f, -38f), new Vector3(-122f, -1.3f, -32f), new Vector3(-47f, -1.3f, -21f) }; for (int i = 0; i < spots.Length; i++) { for (int y = 0; y < 360; y += 90) { Tp(me, spots[i], y); camUp?.SetValue(me, -8f); yield return CaptureLater(0.8f, $"r_{i}_{y:000}"); } } PizzeriaBuilder pzr = PizzeriaBuilder.Current; Vector3 dir; Quaternion val4; if (pzr != null && (Object)(object)pzr.MapRoot != (Object)null) { MeshRenderer[] componentsInChildren = ((Component)pzr.MapRoot).GetComponentsInChildren<MeshRenderer>(); Bounds bounds; foreach (MeshRenderer val in componentsInChildren) { if (((Object)val).name.ToUpperInvariant().Contains("POSTER") || ((Object)val).name.ToUpperInvariant().Contains("RULES")) { ManualLogSource log = Plugin.Log; object[] obj2 = new object[7] { ((Object)val).name, ((Renderer)val).enabled, null, null, null, null, null }; bounds = ((Renderer)val).bounds; obj2[2] = ((Bounds)(ref bounds)).center; bounds = ((Renderer)val).bounds; obj2[3] = ((Bounds)(ref bounds)).size; obj2[4] = ((Component)val).GetComponent<MeshFilter>().sharedMesh.vertexCount; Material sharedMaterial = ((Renderer)val).sharedMaterial; object obj3; if (sharedMaterial == null) { obj3 = null; } else { Shader shader = sharedMaterial.shader; obj3 = ((shader != null) ? ((Object)shader).name : null); } obj2[5] = obj3; obj2[6] = (((Object)(object)((Renderer)val).sharedMaterial != (Object)null && ((Renderer)val).sharedMaterial.HasProperty("_AlphaCutoff")) ? ((Renderer)val).sharedMaterial.GetFloat("_AlphaCutoff") : (-1f)); log.LogInfo((object)string.Format("[dev] poster mesh {0} enabled {1} bounds {2} {3} verts {4} mat {5} cut {6}", obj2)); } } Transform val2 = pzr.MapRoot.Find("Props"); if ((Object)(object)val2 != (Object)null) { for (int k = 0; k < val2.childCount; k++) { Transform child = val2.GetChild(k); if (((Object)child).name.StartsWith("pizza_")) { Renderer componentInChildren = ((Component)child).GetComponentInChildren<Renderer>(); ManualLogSource log2 = Plugin.Log; object[] obj4 = new object[6] { ((Object)child).name, child.position, child.eulerAngles, child.up, child.forward, null }; object obj5; if (!((Object)(object)componentInChildren != (Object)null)) { obj5 = "-"; } else { bounds = componentInChildren.bounds; string? text = ((object)((Bounds)(ref bounds)).center/*cast due to .constrained prefix*/).ToString(); bounds = componentInChildren.bounds; obj5 = text + " " + ((object)((Bounds)(ref bounds)).size/*cast due to .constrained prefix*/).ToString(); } obj4[5] = obj5; log2.LogInfo((object)string.Format("[dev] pizza {0} at {1} rot {2} up {3} fwd {4} bounds {5}", obj4)); } } } Look(new Vector3(-1250f, 620f, 4f), new Vector3(-1119f, 620f, 4f), out var at, out var yaw); Tp(me, at, yaw); camUp?.SetValue(me, 0f); yield return CaptureLater(0.8f, "pizzas"); Look(new Vector3(-1150f, 1440f, 4f), new Vector3(-1150f, 1553f, 4f), out var at2, out var yaw2); Tp(me, at2, yaw2); camUp?.SetValue(me, 0f); yield return CaptureLater(0.8f, "pizzas2"); Look(new Vector3(-382f, 1690f, 4f), new Vector3(-382f, 1792f, 4f), out var at3, out var yaw3); Tp(me, at3, yaw3); camUp?.SetValue(me, 0f); yield return CaptureLater(0.8f, "poster1"); Look(new Vector3(-23f, 1420f, 4f), new Vector3(-23f, 1520f, 4f), out var at4, out var yaw4); Tp(me, at4, yaw4); camUp?.SetValue(me, 0f); yield return CaptureLater(0.8f, "poster2"); Vector3 door = pzr.MapW(new Vector3(413f, 8f, 4f)); Vector3 val3 = pzr.MapW(new Vector3(413f, 200f, 4f)); dir = val3 - door; dir.y = 0f; ((Vector3)(ref dir)).Normalize(); Vector3 pos = door + dir * 4f; val4 = Quaternion.LookRotation(-dir); Tp(me, pos, ((Quaternion)(ref val4)).eulerAngles.y); yield return CaptureLater(0.8f, "front_in"); Vector3 pos2 = door - dir * 4f; val4 = Quaternion.LookRotation(dir); Tp(me, pos2, ((Quaternion)(ref val4)).eulerAngles.y); yield return CaptureLater(0.8f, "front_out"); dir = default(Vector3); } foreach (AnimatronicAI a in AnimatronicAI.Active) { if (a.character == CharacterId.YellowBear) { dir = ((Component)a).transform.forward; dir.y = 0f; ((Vector3)(ref dir)).Normalize(); Vector3 door = Vector3.Cross(Vector3.up, dir); Vector3 pos3 = ((Component)a).transform.position + dir * 3.5f; val4 = Quaternion.LookRotation(-dir); Tp(me, pos3, ((Quaternion)(ref val4)).eulerAngles.y); yield return CaptureLater(0.8f, "gold_front"); Vector3 pos4 = ((Component)a).transform.position + dir * 2f + door * 3f; val4 = Quaternion.LookRotation(-(dir * 2f + door * 3f)); Tp(me, pos4, ((Quaternion)(ref val4)).eulerAngles.y); yield return CaptureLater(0.8f, "gold_side"); Plugin.Log.LogInfo((object)$"[dev] golden at {((Component)a).transform.position}"); dir = default(Vector3); } } FrightLift lift = FrightLift.Current; if ((Object)(object)lift != (Object)null && !File.Exists(Path.Combine(Paths.ConfigPath, "lethalfazbear.nolift"))) { _ = FrightInterior.Current; ((Component)((Component)lift).transform).GetComponentInChildren<Renderer>(); Vector3 door = lift.CarCenter; Vector3 pos5 = door + lift.DoorDir * 4f; val4 = Quaternion.LookRotation(-lift.DoorDir); Tp(me, pos5, ((Quaternion)(ref val4)).eulerAngles.y); me.isInsideFactory = true; yield return CaptureLater(1f, "lift_0_outside"); Vector3 pos6 = door - lift.DoorDir * 0.3f; val4 = Quaternion.LookRotation(lift.DoorDir); Tp(me, pos6, ((Quaternion)(ref val4)).eulerAngles.y); yield return CaptureLater(1f, "lift_1_inside"); lift.DevReport(me); camUp?.SetValue(me, 0f); lift.DevPressCar(me); for (int i = 0; i < 24; i++) { yield return (object)new WaitForSeconds(0.5f); Plugin.Log.LogInfo((object)$"[dev] ride t={(float)i * 0.5f:F1}: me {((Component)me).transform.position} car {lift.CarCenter} inCar {lift.InCar(((Component)me).transform.position)} grounded {me.thisController.isGrounded}"); } yield return (object)new WaitForSeconds(0f); Plugin.Log.LogInfo((object)$"[dev] lift mid: me {((Component)me).transform.position} car {lift.CarCenter} inCar {lift.InCar(((Component)me).transform.position)}"); yield return CaptureLater(0f, "lift_2_mid"); Plugin.Log.LogInfo((object)$"[dev] lift bottom: me {((Component)me).transform.position} car {lift.CarCenter} inCar {lift.InCar(((Component)me).transform.position)}"); yield return CaptureLater(0.5f, "lift_3_bottom"); Vector3 position = ((Component)me).transform.position; val4 = Quaternion.LookRotation(-lift.DoorDir); Tp(me, position, ((Quaternion)(ref val4)).eulerAngles.y); yield return CaptureLater(0.5f, "lift_4_back"); lift.DevPressCall(0, me); yield return (object)new WaitForSeconds(11f); Plugin.Log.LogInfo((object)$"[dev] lift after call from top: car {lift.CarCenter}"); } else { Plugin.Log.LogInfo((object)"[dev] no LC lift"); } Object.Destroy((Object)(object)lamp); Plugin.Log.LogInfo((object)"[dev] rooms done"); void Look(Vector3 fromSrc, Vector3 atSrc, out Vector3 reference, out float reference2) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) reference = pzr.MapW(fromSrc); Vector3 val5 = pzr.MapW(atSrc) - reference; val5.y = 0f; Quaternion val6 = Quaternion.LookRotation(((Vector3)(ref val5)).normalized); reference2 = ((Quaternion)(ref val6)).eulerAngles.y; RaycastHit val7 = default(RaycastHit); if (Physics.Raycast(reference + Vector3.up, Vector3.down, ref val7, 5f, 256, (QueryTriggerInteraction)1)) { reference = ((RaycastHit)(ref val7)).point; } } } private static void WriteWav(string file, AudioClip c) { float[] array = new float[c.samples * c.channels]; if (!c.GetData(array, 0)) { throw new Exception("no data"); } using BinaryWriter binaryWriter = new BinaryWriter(File.Create(file)); int num = array.Length * 2; binaryWriter.Write(Encoding.ASCII.GetBytes("RIFF")); binaryWriter.Write(36 + num); binaryWriter.Write(Encoding.ASCII.GetBytes("WAVEfmt ")); binaryWriter.Write(16); binaryWriter.Write((short)1); binaryWriter.Write((short)c.channels); binaryWriter.Write(c.frequency); binaryWriter.Write(c.frequency * c.channels * 2); binaryWriter.Write((short)(c.channels * 2)); binaryWriter.Write((short)16); binaryWriter.Write(Encoding.ASCII.GetBytes("data")); binaryWriter.Write(num); float[] array2 = array; foreach (float num2 in array2) { binaryWriter.Write((short)(Mathf.Clamp(num2, -1f, 1f) * 32767f)); } } private static void DumpElevator() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //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) Type type = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); int i; for (i = 0; i < assemblies.Length; i++) { type = assemblies[i].GetType("MineshaftElevatorController"); if (type != null) { break; } } if (type == null) { Plugin.Log.LogInfo((object)"[dev] elev: no MineshaftElevatorController type"); return; } Object[] array = Resources.FindObjectsOfTypeAll(type); Plugin.Log.LogInfo((object)$"[dev] elev: {array.Length} controllers"); Object[] array2 = array; i = 0; if (i < array2.Length) { Component val = (Component)array2[i]; _ = val.transform; ManualLogSource log = Plugin.Log; string[] obj = new string[7] { "[dev] elev controller on ", ((Object)val).name, " (root ", ((Object)val.transform.root).name, ", scene '", null, null }; Scene scene = val.gameObject.scene; obj[5] = ((Scene)(ref scene)).name; obj[6] = "')"; log.LogInfo((object)string.Concat(obj)); FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { object value = fieldInfo.GetValue(val); Object val2 = (Object)((value is Object) ? value : null); string te