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 ChipDouglas v0.3.1
ChipDouglas/ChipDouglas.dll
Decompiled 12 hours 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.Reflection; using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; 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; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace ChipDouglas; internal static class Bestiary { public const string CreatureName = "Chip Douglas"; public static int FileId = -1; private const string Text = "CHIP DOUGLAS\n\nSigurd's danger level: 70%\n\nScientific name: Funiculus amicus\n\nA lanky, relentlessly friendly humanoid in a blue work jumpsuit who appears to believe he is your cable installer. He is always on time. Nobody remembers booking him.\n\nAt first he wanders the halls humming to himself. He sees in every direction at once; if you can see him, he has seen you. Once he has, he will introduce himself and refuse to leave your side, stepping in front of you wherever you go. He is harmless like this, and you should keep it that way. Do not run from him. Do not leave the building without him. Do not walk out during one of his little performances.\n\nHe is capable of real friendship. Crew who put up with him long enough, or who give him a piece of scrap, report receiving a present and being left alone for the rest of the day. Their crewmates are rarely so lucky.\n\nA rejected Chip disappears, then turns up later running at a crouch with a cordless drill. He knocks before he breaks a door down. He has been seen in docked ships using terminals, televisions and translators, and leaving with the crew's property.\n\nSigurd's note: he ordered something on our account, then sat down and watched TV with the new guy for twenty minutes. The new guy says he's \"actually kind of nice.\" The new guy doesn't get a vote anymore.\n\n"; public static void Register(Terminal t) { //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Expected O, but got Unknown try { if ((Object)(object)t == (Object)null || (Object)(object)t.terminalNodes == (Object)null || t.terminalNodes.allKeywords == null || t.enemyFiles == null) { return; } TerminalNode val = null; for (int i = 0; i < t.enemyFiles.Count; i++) { if ((Object)(object)t.enemyFiles[i] != (Object)null && t.enemyFiles[i].creatureName == "Chip Douglas") { val = t.enemyFiles[i]; FileId = i; } } if ((Object)(object)val == (Object)null) { val = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val).name = "ChipDouglasFile"; ((Object)val).hideFlags = (HideFlags)61; val.creatureName = "Chip Douglas"; val.displayText = "CHIP DOUGLAS\n\nSigurd's danger level: 70%\n\nScientific name: Funiculus amicus\n\nA lanky, relentlessly friendly humanoid in a blue work jumpsuit who appears to believe he is your cable installer. He is always on time. Nobody remembers booking him.\n\nAt first he wanders the halls humming to himself. He sees in every direction at once; if you can see him, he has seen you. Once he has, he will introduce himself and refuse to leave your side, stepping in front of you wherever you go. He is harmless like this, and you should keep it that way. Do not run from him. Do not leave the building without him. Do not walk out during one of his little performances.\n\nHe is capable of real friendship. Crew who put up with him long enough, or who give him a piece of scrap, report receiving a present and being left alone for the rest of the day. Their crewmates are rarely so lucky.\n\nA rejected Chip disappears, then turns up later running at a crouch with a cordless drill. He knocks before he breaks a door down. He has been seen in docked ships using terminals, televisions and translators, and leaving with the crew's property.\n\nSigurd's note: he ordered something on our account, then sat down and watched TV with the new guy for twenty minutes. The new guy says he's \"actually kind of nice.\" The new guy doesn't get a vote anymore.\n\n"; val.clearPreviousText = true; val.maxCharactersToType = 35; FileId = t.enemyFiles.Count; val.creatureFileID = FileId; t.enemyFiles.Add(val); } TerminalKeyword val2 = null; TerminalKeyword val3 = null; TerminalKeyword[] allKeywords = t.terminalNodes.allKeywords; foreach (TerminalKeyword val4 in allKeywords) { if (!((Object)(object)val4 == (Object)null)) { if (val4.word == "info") { val2 = val4; } else if (val4.word == "chip") { val3 = val4; } } } if ((Object)(object)val3 == (Object)null) { val3 = ScriptableObject.CreateInstance<TerminalKeyword>(); ((Object)val3).name = "ChipDouglasKeyword"; ((Object)val3).hideFlags = (HideFlags)61; val3.word = "chip"; val3.isVerb = false; List<TerminalKeyword> list = new List<TerminalKeyword>(t.terminalNodes.allKeywords) { val3 }; t.terminalNodes.allKeywords = list.ToArray(); } val3.defaultVerb = val2; if ((Object)(object)val2 != (Object)null) { List<CompatibleNoun> list2 = new List<CompatibleNoun>((IEnumerable<CompatibleNoun>)(((object)val2.compatibleNouns) ?? ((object)new CompatibleNoun[0]))); list2.RemoveAll((CompatibleNoun n) => n == null || (Object)(object)n.noun == (Object)null || n.noun.word == "chip"); list2.Add(new CompatibleNoun(val3, val)); val2.compatibleNouns = list2.ToArray(); } ScanNodeProperties val5 = (((Object)(object)ChipAssets.Prefab != (Object)null) ? ChipAssets.Prefab.GetComponentInChildren<ScanNodeProperties>(true) : null); if ((Object)(object)val5 != (Object)null) { val5.creatureScanID = FileId; } foreach (ChipAI item in ChipAI.All) { ScanNodeProperties val6 = (((Object)(object)item != (Object)null) ? ((Component)item).GetComponentInChildren<ScanNodeProperties>(true) : null); if ((Object)(object)val6 != (Object)null) { val6.creatureScanID = FileId; } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Bestiary entry failed: " + ex.Message)); } } } public class CableBoxProp : PhysicsProp { private struct Pending { public int value; public int flags; public Vector3 from; public Vector3 to; } public const int OnShip = 1; public const int InFactory = 2; private static readonly Dictionary<ulong, Pending> pending = new Dictionary<ulong, Pending>(); private bool hasPlacement; private bool elevatorDone; private bool started; private int pValue; private int pFlags; private Vector3 pFrom; private Vector3 pTo; public override void Start() { //IL_0048: 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) ((GrabbableObject)this).Start(); started = true; if (((NetworkBehaviour)this).IsSpawned && pending.TryGetValue(((NetworkBehaviour)this).NetworkObjectId, out var value)) { pending.Remove(((NetworkBehaviour)this).NetworkObjectId); Place(value.value, value.flags, value.from, value.to); } else if (hasPlacement) { ApplyPlacement(); } } internal static void ServerSpawn(Vector3 from, Vector3 to, int value, int flags) { //IL_0034: 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) //IL_0076: 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_0086: 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) if ((Object)(object)ChipAssets.CableBoxPrefab == (Object)null) { return; } try { Transform val = (((flags & 1) == 0 && (Object)(object)RoundManager.Instance != (Object)null) ? RoundManager.Instance.spawnedScrapContainer : null); GameObject obj = Object.Instantiate<GameObject>(ChipAssets.CableBoxPrefab, from, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), val); obj.SetActive(true); CableBoxProp component = obj.GetComponent<CableBoxProp>(); NetworkObject component2 = obj.GetComponent<NetworkObject>(); component2.Spawn(false); component.Place(value, flags, from, to); ChipNet.ToAll(component2.NetworkObjectId, 21, value, flags, from, to); } catch (Exception ex) { Plugin.Log.LogError((object)("Could not spawn the Cable Box: " + ex)); } } internal static void ApplyFromServer(ulong id, int value, int flags, Vector3 from, Vector3 to) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.SpawnManager != null && singleton.SpawnManager.SpawnedObjects.TryGetValue(id, out var value2) && (Object)(object)value2 != (Object)null) { CableBoxProp component = ((Component)value2).GetComponent<CableBoxProp>(); if ((Object)(object)component != (Object)null) { component.Place(value, flags, from, to); return; } } pending[id] = new Pending { value = value, flags = flags, from = from, to = to }; } private void Place(int value, int flags, Vector3 from, Vector3 to) { //IL_0016: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) hasPlacement = true; pValue = value; pFlags = flags; pFrom = from; pTo = to; if (started || ((NetworkBehaviour)this).IsSpawned) { ApplyPlacement(); } } private void ApplyPlacement() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_00d9: 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_00fd: 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_0102: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) int scrapValue = pValue; int num = pFlags; Vector3 val = pFrom; Vector3 val2 = pTo; ((GrabbableObject)this).SetScrapValue(scrapValue); bool flag = (num & 1) != 0; ((GrabbableObject)this).isInFactory = (num & 2) != 0; StartOfRound instance = StartOfRound.Instance; if (flag && (Object)(object)instance != (Object)null && (Object)(object)instance.elevatorTransform != (Object)null) { ((Component)this).transform.SetParent(instance.elevatorTransform, true); if (!elevatorDone) { elevatorDone = true; EnemyAI.SetItemInElevatorNonPlayer(true, true, (GrabbableObject)(object)this); } } else if (!flag && (Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.spawnedScrapContainer != (Object)null && (Object)(object)((Component)this).transform.parent == (Object)null) { ((Component)this).transform.SetParent(RoundManager.Instance.spawnedScrapContainer, true); } ((Component)this).transform.position = val; Transform parent = ((Component)this).transform.parent; ((GrabbableObject)this).startFallingPosition = (((Object)(object)parent != (Object)null) ? parent.InverseTransformPoint(val) : val); ((GrabbableObject)this).targetFloorPosition = (((Object)(object)parent != (Object)null) ? parent.InverseTransformPoint(val2) : val2); ((GrabbableObject)this).fallTime = 0f; ((GrabbableObject)this).hasHitGround = false; ((GrabbableObject)this).reachedFloorTarget = false; ((GrabbableObject)this).floorYRot = -1; } } public class ChipAI : EnemyAI { public const int Roam = 0; public const int Cling = 1; public const int Chase = 2; public const int Wander = 3; public const int Visit = 4; public const int Linger = 5; public const int DoorBreak = 6; public const int Dead = 7; public const int Snap = 8; private static readonly string[] StateNames = new string[9] { "Roaming", "Clingy", "Chasing", "Wandering", "ShipVisit", "Lingering", "BreakingDoor", "Dead", "Snapping" }; private const int VArrive = 0; private const int VAlert = 1; private const int VRush = 2; private const int VBang = 3; private const int VGoPrank = 4; private const int VDoPrank = 5; private const int VWave = 6; private const int VLeave = 7; private const int PBuy = 0; private const int PLights = 1; private const int PTeleport = 2; private const int PDoors = 3; private const int PLever = 4; private const int PCable = 5; private const int PTv = 6; private const int PTranslator = 7; private const int PLockout = 9; private const int PGift = 10; internal static readonly List<ChipAI> All = new List<ChipAI>(); private static ChipClip[] clipByIndex; private int chipState; private int targetId = -1; private bool drillOut; private int loco; private ChipAnimator anim; private AudioSource voice; private AudioSource sfx; private AudioSource drillSrc; private AudioSource bangSrc; private AudioSource stepSrc; private Collider blocker; private bool refsReady; private float voiceBusyUntil; private float stepTimer; private float lastDrillTick; private bool wasStunned; private float hurtQuietUntil; private PlayerControllerB lastStunner; private PlayerControllerB target; private AISearchRoutine search; private float stateStart; private float sinceSeen; private float runAwayTimer; private float voiceTimer; private float heartbeat; private float doorCheck; private float shipRollTimer; private float lastShipVisit = -9999f; private float lingerUntil; private Vector3 lingerPos; private DoorLock breakingDoor; private bool doorRipped; private bool drawing; private float lastAttackYell = -100f; private float lastTaunt = -100f; private float drawStart; private float drillFarTimer; private Vector3 lastTargetPos; private Vector3 targetVel; private bool everAngry; private bool leftHim; private bool leftBuilding; private float snapLineUntil; private float snapVanishAt; private float greetUntil; private const float GreetLength = 3.45f; private int visitStep; private float visitStepStart; private int prank = -1; private Vector3 prankSpot; private Vector3 prankLook; private Vector3 rushPoint; private float alertLength = 1.9f; private float nextPrankTick; private int prankTicks; private PlayerControllerB teleportVictim; private bool prankDone; private int breakStep; private float breakStepStart; private Vector3 breakDoorPos; private Vector3 breakBackPos; private Vector3 chargeDir; private const float StanceLength = 7.6f; private float breakWait = 1f; private readonly HashSet<int> friends = new HashSet<int>(); private GrabbableObject localHeld; private Transform holdPoint; private GrabbableObject heldItem; private readonly Dictionary<int, float> friendship = new Dictionary<int, float>(); private readonly HashSet<int> halfwayTipped = new HashSet<int>(); private readonly Dictionary<int, float> lastFriendGreet = new Dictionary<int, float>(); private GrabbableObject lastTargetHeld; private bool befriending; private float befriendUntil; private float befriendWaveUntil; private PlayerControllerB waveFriend; private float friendWaveUntil; private float attackYellReady; private const int ErrNone = 0; private const int ErrStash = 1; private const int ErrPower = 2; private int errand; private int errandStep; private Vector3 errandSpot; private Vector3 errandLook; private float errandStart; private float errandStepStart; private float nextFlip; private int flips; private int flipWant; private float powerRoll = 30f; private float lastPowerCut = -9999f; private float walkieTimer = 25f; private TVScript tvTarget; private int msgsSent; private const int KnockStep = 10; private float knockSayAt; private float knockEndAt; private bool knockSaid; private int Mask => StartOfRound.Instance.collidersAndRoomMaskAndDefault; private float Age => Time.time - stateStart; private float VisitAge => Time.time - visitStepStart; private float ChaseSpeed { get { float num = (((Object)(object)target != (Object)null) ? target.movementSpeed : 4.6f); if (num < 1f) { num = 4.6f; } return num * 2.25f * Mathf.Clamp(Plugin.ChaseSpeedFraction.Value, 0.2f, 1.5f); } } private bool Greeting { get { if (chipState == 1) { return Time.time < greetUntil; } return false; } } private float BreakAge => Time.time - breakStepStart; private bool ClingBusy => befriending; private bool OnErrand => errand != 0; public static EnemyBehaviourState[] MakeStates() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown EnemyBehaviourState[] array = (EnemyBehaviourState[])(object)new EnemyBehaviourState[StateNames.Length]; for (int i = 0; i < array.Length; i++) { array[i] = new EnemyBehaviourState { name = StateNames[i] }; } return array; } internal static ChipAI Find(ulong id) { for (int i = 0; i < All.Count; i++) { if ((Object)(object)All[i] != (Object)null && ((NetworkBehaviour)All[i]).IsSpawned && ((NetworkBehaviour)All[i]).NetworkObjectId == id) { return All[i]; } } return null; } private static ChipClip ClipAt(int index) { if (clipByIndex == null && Plugin.Clips != null) { clipByIndex = new ChipClip[Plugin.Clips.Count]; foreach (ChipClip value in Plugin.Clips.Values) { if (value.Index >= 0 && value.Index < clipByIndex.Length) { clipByIndex[value.Index] = value; } } } if (clipByIndex == null || index < 0 || index >= clipByIndex.Length) { return null; } return clipByIndex[index]; } private static int ClipIndex(string name) { if (Plugin.Clips == null || !Plugin.Clips.TryGetValue(name, out var value)) { return -1; } return value.Index; } private AudioSource Src(string child) { Transform val = ((Component)this).transform.Find(child); if (!((Object)(object)val != (Object)null)) { return null; } return ((Component)val).GetComponent<AudioSource>(); } private void EnsureRefs() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown if (refsReady) { return; } refsReady = true; if ((Object)(object)base.enemyType == (Object)null) { base.enemyType = ChipAssets.Type; } if (base.enemyBehaviourStates == null || base.enemyBehaviourStates.Length < StateNames.Length) { base.enemyBehaviourStates = MakeStates(); } if (base.currentSearch == null) { base.currentSearch = new AISearchRoutine(); } if ((Object)(object)base.agent == (Object)null) { base.agent = ((Component)this).GetComponent<NavMeshAgent>(); } if ((Object)(object)base.eye == (Object)null) { base.eye = ((Component)this).transform.Find("Eye"); } Transform val = ((Component)this).transform.Find("Blocker"); blocker = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Collider>() : null); voice = Src("Voice"); sfx = Src("SFX"); drillSrc = Src("Drill"); bangSrc = Src("Bang"); stepSrc = Src("Steps"); if ((Object)(object)base.creatureVoice == (Object)null) { base.creatureVoice = voice; } if ((Object)(object)base.creatureSFX == (Object)null) { base.creatureSFX = sfx; } anim = ((Component)this).GetComponent<ChipAnimator>() ?? ((Component)this).gameObject.AddComponent<ChipAnimator>(); EnemyAICollisionDetect[] componentsInChildren = ((Component)this).GetComponentsInChildren<EnemyAICollisionDetect>(true); foreach (EnemyAICollisionDetect val2 in componentsInChildren) { if ((Object)(object)val2.mainScript == (Object)null) { val2.mainScript = (EnemyAI)(object)this; } } base.enemyHP = Mathf.Max(1, Plugin.Health.Value); base.currentBehaviourStateIndex = 0; base.currentBehaviourState = base.enemyBehaviourStates[0]; try { AudioMixerGroup[] array = SoundManager.Instance.diageticMixer.FindMatchingGroups("Master"); if (array != null && array.Length != 0) { AudioSource[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<AudioSource>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].outputAudioMixerGroup = array[0]; } } } catch (Exception) { } base.dieSFX = ChipSounds.Get(15, 0); } public override void Start() { //IL_0093: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown EnsureRefs(); ((EnemyAI)this).Start(); if (!All.Contains(this)) { All.Add(this); } ChipNet.Register(); ChipSounds.EnsurePlaceholders(); if ((Object)(object)base.enemyType != (Object)null) { if ((Object)(object)base.enemyType.stunSFX == (Object)null) { base.enemyType.stunSFX = ChipSounds.Get(16, 0); } base.enemyType.hitBodySFX = null; } if ((Object)(object)base.dieSFX == (Object)null) { base.dieSFX = ChipSounds.Get(15, 0); } if (((NetworkBehaviour)this).IsServer) { search = new AISearchRoutine { randomized = true, searchPrecision = 6f }; EnterRoam(); } } public override void OnDestroy() { All.Remove(this); ((EnemyAI)this).OnDestroy(); } public override void Update() { ((EnemyAI)this).Update(); if (!refsReady) { return; } float deltaTime = Time.deltaTime; UpdateLocal(deltaTime); if (!((NetworkBehaviour)this).IsServer || base.isEnemyDead || !base.ventAnimationFinished || (Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayersDead || (Object)(object)base.agent == (Object)null || !((Behaviour)base.agent).enabled) { return; } heartbeat -= deltaTime; if (heartbeat <= 0f) { heartbeat = 2f; SendState(); } if (base.stunNormalizedTimer > 0f) { base.agent.speed = 0f; if (!wasStunned) { wasStunned = true; lastStunner = base.stunnedByPlayer; NetAction("stunned", hold: false); } return; } if (wasStunned) { wasStunned = false; NetStopAction(); if (chipState == 0 || chipState == 1) { EnterChaseOrWander(lastStunner); } } CheckHeld(); switch (chipState) { case 0: UpdateRoam(deltaTime); break; case 1: UpdateCling(deltaTime); break; case 2: UpdateChase(deltaTime); break; case 3: UpdateWander(deltaTime); break; case 4: UpdateVisit(deltaTime); break; case 5: UpdateLinger(deltaTime); break; case 6: UpdateDoorBreak(deltaTime); break; case 8: UpdateSnap(deltaTime); break; case 7: break; } } public override void DoAIInterval() { if (base.isEnemyDead || !((NetworkBehaviour)this).IsServer || !refsReady || (Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayersDead || base.stunNormalizedTimer > 0f) { ((EnemyAI)this).DoAIInterval(); return; } try { switch (chipState) { case 0: ThinkRoam(); break; case 1: ThinkCling(); break; case 3: ThinkWander(); break; case 5: ThinkLinger(); break; case 2: case 4: break; } } catch (Exception ex) { Plugin.Log.LogError((object)("AI error: " + ex)); } ((EnemyAI)this).DoAIInterval(); } private void UpdateLocal(float dt) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)StartOfRound.Instance == (Object)null) { return; } if ((Object)(object)blocker != (Object)null) { blocker.enabled = chipState == 1 && !base.isEnemyDead && base.stunNormalizedTimer <= 0f; } base.isInsidePlayerShip = base.isOutside && Ship.InShip(((Component)this).transform.position); if ((Object)(object)anim != (Object)null) { anim.DrillOut = drillOut && !base.isEnemyDead; anim.Locomotion = (ChipAnimator.Loco)Mathf.Clamp(loco, 0, 5); PlayerControllerB val = ((targetId >= 0 && targetId < StartOfRound.Instance.allPlayerScripts.Length) ? StartOfRound.Instance.allPlayerScripts[targetId] : null); anim.LookTarget = (((Object)(object)val != (Object)null && val.isPlayerControlled && !val.isPlayerDead) ? ((Component)val.gameplayCamera).transform : null); anim.DrillSpin = Mathf.MoveTowards(anim.DrillSpin, (drillOut && !base.isEnemyDead) ? 1f : 0f, dt * 2f); } if ((Object)(object)drillSrc != (Object)null) { bool flag = drillOut && !base.isEnemyDead; if (flag && !drillSrc.isPlaying) { drillSrc.clip = ChipSounds.Get(7, 0); if ((Object)(object)drillSrc.clip != (Object)null) { drillSrc.volume = 0f; drillSrc.Play(); } } drillSrc.volume = Mathf.MoveTowards(drillSrc.volume, flag ? (0.75f * Plugin.SfxVolume.Value) : 0f, dt * 2.5f); if (!flag && drillSrc.isPlaying && drillSrc.volume <= 0.001f) { drillSrc.Stop(); } if (drillSrc.isPlaying) { drillSrc.pitch = 0.92f + 0.12f * Mathf.PerlinNoise(Time.time * 1.7f, 0.3f); } } if (!((Object)(object)anim != (Object)null) || !((Object)(object)stepSrc != (Object)null) || base.isEnemyDead || chipState == 6) { return; } float speed = anim.Speed; if (!(speed > 0.6f)) { return; } stepTimer -= dt * speed; if (stepTimer <= 0f) { stepTimer = ((speed > 6f) ? 1.55f : 0.95f); AudioClip val2 = ChipSounds.Get(14, Random.Range(0, 64)); if ((Object)(object)val2 != (Object)null) { stepSrc.pitch = Random.Range(0.9f, 1.1f); stepSrc.PlayOneShot(val2, ((speed > 6f) ? 0.9f : 0.55f) * Plugin.SfxVolume.Value); } } } private bool Clear(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !Physics.Linecast(a, b, Mask, (QueryTriggerInteraction)1); } private static Vector3 Cam(PlayerControllerB p) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return ((Component)p.gameplayCamera).transform.position; } private bool Valid(PlayerControllerB p) { if ((Object)(object)p != (Object)null && p.isPlayerControlled) { return !p.isPlayerDead; } return false; } private bool CanSee(PlayerControllerB p, float range) { //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_002c: 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_003c: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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) if (!Valid(p) || !((EnemyAI)this).PlayerIsTargetable(p, false, false, true) || IsFriend(p)) { return false; } Vector3 position = base.eye.position; if (Vector3.Distance(position, Cam(p)) <= range) { if (!Clear(position, Cam(p))) { return Clear(position, ((Component)p).transform.position + Vector3.up * 1f); } return true; } return false; } private PlayerControllerB SeeAround(float range) { //IL_002d: 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 result = null; float num = float.MaxValue; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (CanSee(val, range)) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position); if (num2 < num) { num = num2; result = val; } } } return result; } private PlayerControllerB SeeCone(float range, float angle, float proximity) { //IL_0045: 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_005a: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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 (Valid(val) && ((EnemyAI)this).PlayerIsTargetable(val, false, false, true) && !IsFriend(val)) { Vector3 val2 = Cam(val) - base.eye.position; float magnitude = ((Vector3)(ref val2)).magnitude; if (!(magnitude > range) && (!(magnitude > proximity) || !(Vector3.Angle(((Component)this).transform.forward, val2) > angle * 0.5f)) && Clear(base.eye.position, Cam(val)) && magnitude < num) { num = magnitude; result = val; } } } return result; } private void SetState(int s) { chipState = s; stateStart = Time.time; if (base.currentBehaviourStateIndex != s) { ((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(s); } if (Plugin.LogStates.Value) { Plugin.Log.LogInfo((object)("Chip -> " + StateNames[s] + (((Object)(object)target != (Object)null) ? (" (target " + target.playerUsername + ")") : ""))); } SendState(); } private void SetTarget(PlayerControllerB p) { //IL_0030: 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_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) target = p; targetId = (((Object)(object)p != (Object)null) ? ((int)p.playerClientId) : (-1)); if ((Object)(object)p != (Object)null) { lastTargetPos = ((Component)p).transform.position; targetVel = Vector3.zero; } } private void SetLoco(ChipAnimator.Loco l) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (loco != (int)l) { loco = (int)l; ChipNet.ToAll(((NetworkBehaviour)this).NetworkObjectId, 14, loco); } } private void SetDrill(bool on) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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) if (drillOut != on) { drillOut = on; ChipNet.ToAll(((NetworkBehaviour)this).NetworkObjectId, 7, on ? 1 : 0); } } private void SendState() { //IL_0042: 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_004f: Unknown result type (might be due to invalid IL or missing references) ChipNet.ToAll(((NetworkBehaviour)this).NetworkObjectId, 1, chipState, targetId, new Vector3(drillOut ? 1f : 0f, (float)loco, base.isOutside ? 1f : 0f)); } private void NetAction(string clip, bool hold) { //IL_0044: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) int num = ClipIndex(clip); if (num >= 0) { ApplyCommand(new ChipNet.Cmd { cmd = 2, a = num, b = (hold ? 1 : 0) }); ChipNet.ToAll(((NetworkBehaviour)this).NetworkObjectId, 2, num, hold ? 1 : 0); } } private void NetStopAction() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) ApplyCommand(new ChipNet.Cmd { cmd = 3 }); ChipNet.ToAll(((NetworkBehaviour)this).NetworkObjectId, 3); } private void NetOverlay(string clip, bool loop) { //IL_0044: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) int num = ClipIndex(clip); if (num >= 0) { ApplyCommand(new ChipNet.Cmd { cmd = 4, a = num, b = (loop ? 1 : 0) }); ChipNet.ToAll(((NetworkBehaviour)this).NetworkObjectId, 4, num, loop ? 1 : 0); } } private void NetStopOverlay() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) ApplyCommand(new ChipNet.Cmd { cmd = 5 }); ChipNet.ToAll(((NetworkBehaviour)this).NetworkObjectId, 5); } private float NetSfx(int cat, int source = 0) { //IL_0044: 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_0069: 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_0076: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(1, ChipSounds.Size(cat)); int num2 = Random.Range(0, num); ApplyCommand(new ChipNet.Cmd { cmd = 6, a = cat, b = num2, p = new Vector3((float)source, 0f, 0f) }); ChipNet.ToAll(((NetworkBehaviour)this).NetworkObjectId, 6, cat, num2, new Vector3((float)source, 0f, 0f)); AudioClip val = ChipSounds.Get(cat, num2); if (!((Object)(object)val != (Object)null)) { return 0f; } return val.length; } private float SayNow(int cat) { float num = NetSfx(cat, 4); if (num <= 0f) { num = 1.4f; } voiceBusyUntil = Time.time + num + 0.5f; return num; } private void SnapLine(bool firstAnger, bool announce) { bool num = firstAnger && leftHim; leftHim = false; if (num) { SayNow(3); snapLineUntil = voiceBusyUntil - 0.5f; } else if (announce || firstAnger) { voiceBusyUntil = 0f; Say(4); } } private void SayAngryLine() { if (!(Time.time < voiceBusyUntil)) { bool flag = ChipSounds.Size(21) > 0 && Time.time - lastTaunt > 14f && Random.value < Plugin.TauntChance.Value; if (flag) { lastTaunt = Time.time; } Say(flag ? 21 : 4); } } private void Say(int cat, float minGap = 0.5f) { if (!(Time.time < voiceBusyUntil)) { float num = NetSfx(cat); voiceBusyUntil = Time.time + ((num > 0f) ? num : 1f) + minGap; } } private void Face(Vector3 point, float degPerSec) { //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_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_0051: 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.0004f)) { ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, Quaternion.LookRotation(((Vector3)(ref val)).normalized), degPerSec * Time.deltaTime); } } private void StopMoving() { //IL_0053: 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_0037: Unknown result type (might be due to invalid IL or missing references) base.movingTowardsTargetPlayer = false; base.agent.speed = 0f; if (((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.velocity = Vector3.zero; base.agent.ResetPath(); } base.destination = ((Component)this).transform.position; base.moveTowardsDestination = false; } private void GoTo(Vector3 p, float speed) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) base.agent.speed = speed; base.movingTowardsTargetPlayer = false; ((EnemyAI)this).SetDestinationToPosition(p, false); } private void TrackTarget(float dt) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_007c: 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_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_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) if (!((Object)(object)target == (Object)null)) { Vector3 position = ((Component)target).transform.position; Vector3 val = (position - lastTargetPos) / Mathf.Max(dt, 0.001f); val.y = 0f; if (((Vector3)(ref val)).magnitude < 40f) { targetVel = Vector3.Lerp(targetVel, val, 1f - Mathf.Exp(-6f * dt)); } lastTargetPos = position; } } private void StopSearching() { if (base.currentSearch != null && base.currentSearch.inProgress) { ((EnemyAI)this).StopSearch(base.currentSearch, true); } if (search != null && search.inProgress) { ((EnemyAI)this).StopSearch(search, true); } } private void StartSearching() { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (search == null) { search = new AISearchRoutine { randomized = true, searchPrecision = 6f }; } if (!search.inProgress) { ((EnemyAI)this).StartSearch(((Component)this).transform.position, search); } } private void EnterRoam() { ResetClingExtras(); SetTarget(null); base.agent.updateRotation = true; base.agent.speed = Plugin.RoamSpeed.Value; base.agent.acceleration = 14f; base.openDoorSpeedMultiplier = base.enemyType.doorSpeedMultiplier; SetLoco(ChipAnimator.Loco.Normal); voiceTimer = Random.Range(6f, 14f); SetState(0); StartSearching(); } private void UpdateRoam(float dt) { if (!FriendWave()) { base.agent.speed = Plugin.RoamSpeed.Value; voiceTimer -= dt; if (voiceTimer <= 0f) { voiceTimer = Random.Range(10f, 22f); Say(0); } } } private void ThinkRoam() { if (!((Object)(object)waveFriend != (Object)null)) { StartSearching(); PlayerControllerB val = SeeAround(Plugin.RoamSightRange.Value); if ((Object)(object)val != (Object)null) { waveFriend = null; EnterCling(val); } else { TryGreetFriend(); } } } private void EnterCling(PlayerControllerB p) { ResetClingExtras(); StopSearching(); SetTarget(p); runAwayTimer = 0f; sinceSeen = 0f; base.agent.updateRotation = false; base.agent.acceleration = 26f; base.agent.speed = Plugin.ClingSpeed.Value; SetLoco(ChipAnimator.Loco.Normal); SetState(1); greetUntil = Time.time + 3.45f; voiceBusyUntil = 0f; Say(1); NetOverlay("greet", loop: false); voiceTimer = 3.45f + Random.Range(5f, 10f); } private void UpdateCling(float dt) { //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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) if (!Valid(target)) { SetTarget(null); base.agent.updateRotation = true; base.agent.speed = Plugin.RoamSpeed.Value; StartSearching(); return; } if (!target.isInsideFactory) { leftHim = true; leftBuilding = true; EnterChaseOrWander(null); return; } TrackTarget(dt); float num = Vector3.Distance(((Component)this).transform.position, ((Component)target).transform.position); Face(((Component)target).transform.position, 540f); if (greetUntil > 0f && Time.time >= greetUntil) { greetUntil = 0f; NetOverlay(((Object)(object)heldItem != (Object)null) ? "carry" : "block", loop: true); } if (ClingExtras(dt, num)) { return; } Vector3 val = ((Component)target).transform.position - ((Component)this).transform.position; val.y = 0f; bool flag = ((Vector3)(ref targetVel)).magnitude > 6.2f && Vector3.Dot(targetVel, val) > 0f; if (num > Plugin.RunAwayDistance.Value && flag) { runAwayTimer += dt; } else { runAwayTimer = Mathf.Max(0f, runAwayTimer - dt * 0.5f); } if (runAwayTimer > Plugin.RunAwayTime.Value) { leftHim = true; EnterChaseOrWander(target); return; } if (CanSee(target, 70f)) { sinceSeen = 0f; } else { sinceSeen += dt; if (sinceSeen > Plugin.ClingLoseSightTime.Value) { leftHim = true; EnterChaseOrWander(null); return; } } voiceTimer -= dt; if (voiceTimer <= 0f) { voiceTimer = Random.Range(6f, 13f); Say(2); } } private void ThinkCling() { //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_0122: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target == (Object)null) { PlayerControllerB val = SeeAround(Plugin.RoamSightRange.Value); if ((Object)(object)val != (Object)null) { EnterCling(val); } return; } if (ClingBusy) { StopMoving(); return; } WatchForGifts(); if (ClingBusy) { StopMoving(); } else if (Greeting) { if (Time.time < greetUntil - 3.45f + 0.75f && Vector3.Distance(((Component)this).transform.position, ((Component)target).transform.position) > 3f) { GoTo(((Component)target).transform.position, 2.6f); } else { StopMoving(); } } else { Vector3 val2 = ((((Vector3)(ref targetVel)).magnitude > 1.2f) ? ((Vector3)(ref targetVel)).normalized : Flat(((Component)target).transform.forward)); Vector3 val3 = ((Component)target).transform.position + val2 * Plugin.ClingDistance.Value; Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(val3, RoundManager.Instance.navHit, 2.5f, base.agentMask); float speed = Mathf.Lerp(3f, Plugin.ClingSpeed.Value, Mathf.Clamp01(Vector3.Distance(((Component)this).transform.position, navMeshPosition) / 6f)); GoTo(navMeshPosition, speed); } } private static Vector3 Flat(Vector3 v) { //IL_0022: 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) v.y = 0f; if (!(((Vector3)(ref v)).sqrMagnitude > 0.0001f)) { return Vector3.forward; } return ((Vector3)(ref v)).normalized; } private void EnterSnap(PlayerControllerB p) { ResetClingExtras(); everAngry = true; greetUntil = 0f; StopSearching(); StopMoving(); drawing = false; SetDrill(on: false); NetStopOverlay(); if ((Object)(object)p != (Object)null && Valid(p)) { SetTarget(p); } base.agent.updateRotation = false; SetLoco(ChipAnimator.Loco.Still); SetState(8); float num; if (leftHim) { num = SayNow(3); } else { voiceBusyUntil = 0f; Say(4); num = 1.2f; } leftHim = false; NetAction("alert", hold: false); snapVanishAt = Time.time + Mathf.Clamp(num, 0.8f, 6f) + 0.25f; } private void UpdateSnap(float dt) { //IL_0033: 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) StopMoving(); if (Valid(target) && target.isInsideFactory != base.isOutside) { Face(((Component)target).transform.position, 360f); } if (Time.time < snapVanishAt) { return; } NetStopAction(); bool num = leftBuilding; leftBuilding = false; if (num && Plugin.FollowYouOut.Value && CanVisitShip(ignoreCooldown: true)) { base.agent.updateRotation = true; EnterVisit(); return; } if (PickHideSpot(out var spot)) { TeleportTo(spot, outside: false, viaEntrance: false); } base.agent.updateRotation = true; EnterWander(announce: false); } private bool PickHideSpot(out Vector3 spot) { //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_0041: 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_0092: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_029d: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) spot = ((Component)this).transform.position; GameObject[] array = (((Object)(object)RoundManager.Instance != (Object)null) ? RoundManager.Instance.insideAINodes : null); if (array == null || array.Length == 0) { return false; } List<Vector3> list = new List<Vector3> { ((Component)this).transform.position }; List<Vector3> list2 = new List<Vector3>(); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (Valid(val) && val.isInsideFactory) { list.Add(((Component)val).transform.position); list2.Add(Cam(val)); } } float num = Mathf.Max(10f, Plugin.SnapTeleportDistance.Value); List<KeyValuePair<float, Vector3>> list3 = new List<KeyValuePair<float, Vector3>>(); List<KeyValuePair<float, Vector3>> list4 = new List<KeyValuePair<float, Vector3>>(); GameObject[] array2 = array; foreach (GameObject val2 in array2) { if ((Object)(object)val2 == (Object)null) { continue; } Vector3 position = val2.transform.position; float num2 = float.MaxValue; foreach (Vector3 item in list) { num2 = Mathf.Min(num2, Vector3.Distance(item, position)); } bool flag = false; foreach (Vector3 item2 in list2) { if (Vector3.Distance(item2, position) < 70f && Clear(item2, position + Vector3.up * 1.6f)) { flag = true; break; } } if (!flag) { ((num2 >= num) ? list3 : list4).Add(new KeyValuePair<float, Vector3>(num2, position)); } } List<KeyValuePair<float, Vector3>> list5 = list3; if (list5.Count == 0) { list4.Sort((KeyValuePair<float, Vector3> x, KeyValuePair<float, Vector3> y) => y.Key.CompareTo(x.Key)); list5 = list4.GetRange(0, Mathf.Min(4, list4.Count)); } NavMeshPath val3 = new NavMeshPath(); for (int num3 = 0; num3 < 12; num3++) { if (list5.Count <= 0) { break; } int index = Random.Range(0, list5.Count); Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(list5[index].Value, RoundManager.Instance.navHit, 3f, -1); list5.RemoveAt(index); if (NavMesh.CalculatePath(navMeshPosition, ((Component)this).transform.position, base.agent.areaMask, val3) && (int)val3.status == 0) { spot = navMeshPosition; return true; } } return false; } private void EnterChaseOrWander(PlayerControllerB p) { if (!everAngry && Plugin.SnapTeleport.Value) { EnterSnap(p); } else if (leftBuilding && Plugin.FollowYouOut.Value && CanVisitShip(ignoreCooldown: true)) { leftBuilding = false; leftHim = false; everAngry = true; EnterVisit(); } else { leftBuilding = false; if ((Object)(object)p != (Object)null && Valid(p) && p.isInsideFactory != base.isOutside && ((EnemyAI)this).PlayerIsTargetable(p, false, false, true)) { EnterChase(p, announce: true); } else { EnterWander(announce: true); } } } private void EnterChase(PlayerControllerB p, bool announce) { ResetClingExtras(); AbortErrand(); DropHeld(); greetUntil = 0f; StopSearching(); NetStopOverlay(); NetStopAction(); bool firstAnger = !everAngry; everAngry = true; SetTarget(p); sinceSeen = 0f; doorCheck = 0f; drillFarTimer = 0f; base.agent.updateRotation = true; base.agent.acceleration = 40f; base.agent.angularSpeed = 900f; base.agent.speed = ChaseSpeed; base.openDoorSpeedMultiplier = (Plugin.BreakDoors.Value ? 0f : base.enemyType.doorSpeedMultiplier); SetLoco(ChipAnimator.Loco.Run); SetState(2); SnapLine(firstAnger, announce); if (drillOut) { NetOverlay("drill_aim", loop: true); } } private void UpdateChase(float dt) { //IL_0046: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target != (Object)null && target.isPlayerDead) { Vector3 body = (((Object)(object)target.deadBody != (Object)null) ? ((Component)target.deadBody).transform.position : lastTargetPos); EnterLinger(body); return; } if (Valid(target) && target.isInsideFactory == base.isOutside && !base.isOutside && Plugin.FollowYouOut.Value && CanVisitShip(ignoreCooldown: false, 0.5f)) { EnterVisit(); return; } if (!Valid(target) || target.isInsideFactory == base.isOutside) { PlayerControllerB val = SeeCone(Plugin.SightRange.Value, Plugin.SightAngle.Value, 4f); if (!((Object)(object)val != (Object)null)) { EnterWander(announce: false); return; } SetTarget(val); SendState(); } TrackTarget(dt); base.agent.speed = ChaseSpeed; base.moveTowardsDestination = true; ((EnemyAI)this).SetMovingTowardsTargetPlayer(target); if (CanSee(target, Plugin.SightRange.Value * 1.6f)) { sinceSeen = 0f; } else { sinceSeen += dt; if (sinceSeen > Plugin.LoseSightTime.Value) { PlayerControllerB val2 = SeeCone(Plugin.SightRange.Value, Plugin.SightAngle.Value, 4f); if (!((Object)(object)val2 != (Object)null) || !((Object)(object)val2 != (Object)(object)target)) { EnterWander(announce: false); return; } SetTarget(val2); sinceSeen = 0f; SendState(); } } float num = Vector3.Distance(((Component)this).transform.position, ((Component)target).transform.position); if (!drillOut && !drawing && num < Plugin.DrillRange.Value) { drawing = true; drawStart = Time.time; NetOverlay("drill_draw", loop: false); if (Time.time - lastAttackYell > 3f && Time.time >= snapLineUntil) { lastAttackYell = Time.time; attackYellReady = Time.time + SayNow(20) + 0.5f; } } if (drawing && Time.time - drawStart > 0.33f && !drillOut) { SetDrill(on: true); NetSfx(6, 1); } if (drawing && Time.time - drawStart > 0.85f) { drawing = false; NetOverlay("drill_aim", loop: true); } if (drillOut && num > Plugin.DrillRange.Value * 3f) { drillFarTimer += dt; } else { drillFarTimer = 0f; } if (drillOut && drillFarTimer > 6f) { SetDrill(on: false); NetStopOverlay(); drillFarTimer = 0f; } if (Plugin.BreakDoors.Value) { doorCheck -= dt; if (doorCheck <= 0f) { doorCheck = 0.15f; Vector3 desiredVelocity = base.agent.desiredVelocity; Vector3 dir = ((((Vector3)(ref desiredVelocity)).sqrMagnitude > 0.5f) ? base.agent.desiredVelocity : ((Component)this).transform.forward); DoorLock val3 = Doors.ClosedDoorAhead(((Component)this).transform.position, dir, 2.3f); if ((Object)(object)val3 != (Object)null) { EnterDoorBreak(val3); return; } } } voiceTimer -= dt; if (voiceTimer <= 0f) { voiceTimer = Random.Range(8f, 16f); SayAngryLine(); } } private void SetBreakStep(int s) { breakStep = s; breakStepStart = Time.time; if (Plugin.LogStates.Value) { Plugin.Log.LogInfo((object)("Chip door step " + s)); } } private void EnterDoorBreak(DoorLock d) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_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) breakingDoor = d; doorRipped = false; drawing = false; SetDrill(on: false); Vector3 val = Doors.LeafCenter(d); breakDoorPos = new Vector3(val.x, ((Component)this).transform.position.y, val.z); StopMoving(); SetLoco(ChipAnimator.Loco.Still); NetStopOverlay(); NetStopAction(); base.openDoorSpeedMultiplier = 0f; SetState(6); if (Plugin.KnockFirst.Value) { SetBreakStep(10); StartKnock(); } else { SetBreakStep(0); } } private Vector3 PickBackOffSpot() { //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_0045: 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_004a: 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_006e: 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_0075: 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_0081: 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_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_0141: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Invalid comparison between Unknown and I4 //IL_0110: 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_0115: 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_011a: 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) Vector3 val = ((Component)this).transform.position - breakDoorPos; val.y = 0f; val = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : (-((Component)this).transform.forward)); float[] array = new float[3] { 7.5f, 5.5f, 3.5f }; foreach (float num in array) { Vector3 val2 = breakDoorPos + val * num; Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(val2, RoundManager.Instance.navHit, 2.5f, base.agentMask); if (!RoundManager.Instance.GotNavMeshPositionResult) { continue; } if (base.path1 == null) { base.path1 = new NavMeshPath(); } if (base.agent.CalculatePath(navMeshPosition, base.path1) && (int)base.path1.status != 2) { Vector3 val3 = ((base.path1.corners.Length != 0) ? base.path1.corners[base.path1.corners.Length - 1] : navMeshPosition); if (Vector3.Distance(val3, breakDoorPos) > 2.8f) { return val3; } } } return ((Component)this).transform.position; } private void UpdateDoorBreak(float dt) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_01da: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: 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_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_017a: 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_024c: Unknown result type (might be due to invalid IL or missing references) //IL_023f: 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_0251: Unknown result type (might be due to invalid IL or missing references) Vector3 velocity; Vector3 val; int num; bool flag; switch (breakStep) { case 10: if (!UpdateKnock() && chipState == 6) { SetBreakStep(0); } break; case 0: base.agent.speed = 0f; Face(breakDoorPos, 360f); if (BreakAge > 0.8f) { breakBackPos = PickBackOffSpot(); base.agent.updateRotation = true; base.agent.acceleration = 14f; SetLoco(ChipAnimator.Loco.Normal); NetSfx(17, 3); SetBreakStep(1); } break; case 1: { GoTo(breakBackPos, 3.4f); if (!(Vector3.Distance(((Component)this).transform.position, breakBackPos) < 1f) && !(BreakAge > 5.5f)) { if (!(BreakAge > 1f)) { break; } velocity = base.agent.velocity; if (!(((Vector3)(ref velocity)).sqrMagnitude < 0.05f) || base.agent.pathPending) { break; } } StopMoving(); base.agent.updateRotation = false; SetLoco(ChipAnimator.Loco.Still); float num2 = NetSfx(18); if (num2 <= 0f) { num2 = 1.5f; } float num3 = Vector3.Distance(((Component)this).transform.position, breakDoorPos) / Mathf.Max(1f, ChaseSpeed * 1.1f) + 0.35f; breakWait = Mathf.Clamp(num2 - num3, 1f, 4.5f); SetBreakStep(2); break; } case 2: base.agent.speed = 0f; Face(breakDoorPos, 260f); if (BreakAge > breakWait) { chargeDir = breakDoorPos - ((Component)this).transform.position; chargeDir.y = 0f; chargeDir = ((((Vector3)(ref chargeDir)).sqrMagnitude > 0.01f) ? ((Vector3)(ref chargeDir)).normalized : ((Component)this).transform.forward); base.agent.updateRotation = true; base.agent.acceleration = 60f; base.agent.angularSpeed = 900f; SetLoco(ChipAnimator.Loco.Charge); SetBreakStep(3); } break; case 3: GoTo(breakDoorPos, ChaseSpeed * 1.1f); val = breakDoorPos - ((Component)this).transform.position; val.y = 0f; if (BreakAge > 0.7f) { velocity = base.agent.velocity; if (((Vector3)(ref velocity)).sqrMagnitude < 1f) { num = ((((Vector3)(ref val)).magnitude < 3f) ? 1 : 0); goto IL_0305; } } num = 0; goto IL_0305; case 4: if (BreakAge < 0.8f) { GoTo(breakDoorPos + chargeDir * 0.35f, 2.5f); } else { base.agent.speed = 0f; } if (BreakAge > 7.5499997f) { NetStopAction(); breakingDoor = null; if (Valid(target) && target.isInsideFactory != base.isOutside) { EnterChase(target, announce: false); } else { EnterWander(announce: false); } } break; case 5: case 6: case 7: case 8: case 9: break; IL_0305: flag = (byte)num != 0; if (((Vector3)(ref val)).magnitude < 1.5f || flag || BreakAge > 6f) { Slam(); } break; } } private void Slam() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) StopMoving(); SetLoco(ChipAnimator.Loco.Still); if (!doorRipped && (Object)(object)breakingDoor != (Object)null) { doorRipped = true; Doors.ServerBreakAndThrow(breakingDoor, chargeDir); } NetAction("door_stance", hold: false); NetSfx(19, 1); voiceBusyUntil = 0f; Say(10); SetBreakStep(4); } private void EnterWander(bool announce) { ResetClingExtras(); AbortErrand(); greetUntil = 0f; bool firstAnger = !everAngry; everAngry = true; SetTarget(null); drawing = false; SetDrill(on: false); NetStopOverlay(); NetStopAction(); base.agent.updateRotation = true; base.agent.acceleration = 14f; base.agent.angularSpeed = 300f; base.agent.speed = Plugin.CreepSpeed.Value; base.openDoorSpeedMultiplier = base.enemyType.doorSpeedMultiplier; SetLoco(ChipAnimator.Loco.Creep); SetState(3); StartSearching(); shipRollTimer = Plugin.ShipVisitInterval.Value; voiceTimer = Random.Range(8f, 16f); SnapLine(firstAnger, announce); } private void UpdateWander(float dt) { if (FriendWave()) { return; } base.agent.speed = Plugin.CreepSpeed.Value; voiceTimer -= dt; if (voiceTimer <= 0f) { voiceTimer = Random.Range(10f, 20f); SayAngryLine(); } if (WanderExtras(dt) || !Plugin.ShipVisits.Value || base.isOutside) { return; } shipRollTimer -= dt; if (shipRollTimer > 0f) { return; } shipRollTimer = Mathf.Max(3f, Plugin.ShipVisitInterval.Value); if (!CanVisitShip(ignoreCooldown: false)) { return; } bool flag = NobodyInside(); if (Ship.AnyoneAtShip() || flag) { float num = Plugin.ShipVisitChance.Value; if (flag) { num = Mathf.Max(num * 2f, 0.75f); } if (!(Random.value > num)) { EnterVisit(); } } } private void ThinkWander() { if (OnErrand) { PlayerControllerB val = SeeCone(Plugin.SightRange.Value, Plugin.SightAngle.Value, 4f); if ((Object)(object)val != (Object)null) { EnterChase(val, announce: true); } return; } PlayerControllerB val2 = SeeCone(Plugin.SightRange.Value, Plugin.SightAngle.Value, 4f); if ((Object)(object)val2 != (Object)null) { waveFriend = null; EnterChase(val2, announce: true); } else if (!((Object)(object)waveFriend != (Object)null)) { StartSearching(); TryGreetFriend(); } } private void EnterLinger(Vector3 body) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) lingerPos = body; StopSearching(); SetTarget(null); drawing = false; NetStopOverlay(); StopMoving(); SetLoco(ChipAnimator.Loco.Still); float num = Mathf.Min(Plugin.LingerMin.Value, Plugin.LingerMax.Value); float num2 = Mathf.Max(Plugin.LingerMin.Value, Plugin.LingerMax.Value); lingerUntil = Time.time + Random.Range(num, num2); SetState(5); NetAction("tweak", hold: false); voiceBusyUntil = 0f; Say(4); } private void UpdateLinger(float dt) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) base.agent.speed = 0f; Face(lingerPos, 120f); if (Time.time > lingerUntil) { NetStopAction(); EnterWander(announce: false); } } private void ThinkLinger() { PlayerControllerB val = SeeCone(Plugin.SightRange.Value * 0.8f, Plugin.SightAngle.Value, 5f); if ((Object)(object)val != (Object)null) { NetStopAction(); EnterChase(val, announce: true); } } private bool CanVisitShip(bool ignoreCooldown, float cooldownScale = 1f) { if (!Plugin.ShipVisits.Value || base.isOutside || !Ship.RoundActive()) { return false; } if (!ignoreCooldown) { return Time.time - lastShipVisit >= Plugin.ShipVisitCooldown.Value * cooldownScale; } return true; } private bool NobodyInside() { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (Valid(val) && val.isInsideFactory) { return false; } } return true; } internal void DebugForceShipVisit() { if (((NetworkBehaviour)this).IsServer && !base.isEnemyDead && chipState != 4) { everAngry = true; if (!base.isOutside) { EnterVisit(); } } } private void EnterVisit() { //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_0062: Unknown result type (might be due to invalid IL or missing references) lastShipVisit = Time.time; StopSearching(); SetTarget(null); drawing = false; SetDrill(on: false); NetStopOverlay(); NetStopAction(); AbortErrand(); DropHeld(); prank = -1; prankDone = false; teleportVictim = null; tvTarget = null; Vector3 pos = PickArrivalSpot(); TeleportTo(pos, outside: true, viaEntrance: false); base.agent.updateRotation = true; base.agent.acceleration = 18f; SetLoco(ChipAnimator.Loco.Normal); base.openDoorSpeedMultiplier = base.enemyType.doorSpeedMultiplier; SetState(4); SetVisitStep(0); } private void SetVisitStep(int s) { visitStep = s; visitStepStart = Time.time; if (Plugin.LogStates.Value) { Plugin.Log.LogInfo((object)("Chip ship visit step " + s)); } } private Vector3 PickArrivalSpot() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: 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_009a: 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_00d4: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_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) Vector3 val = Ship.ShipCenter(); float num = Mathf.Max(30f, Plugin.ShipTeleportRadius.Value); List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); try { RoundManager.Instance.GetOutsideAINodes(true); } catch (Exception) { } GameObject[] outsideAINodes = RoundManager.Instance.outsideAINodes; if (outsideAINodes != null) { GameObject[] array = outsideAINodes; foreach (GameObject val2 in array) { if ((Object)(object)val2 == (Object)null) { continue; } float num2 = Vector3.Distance(val2.transform.position, val); if (num2 > num || num2 < 25f) { continue; } list2.Add(val2.transform.position); bool flag = false; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val3 in allPlayerScripts) { if (Valid(val3) && !val3.isInsideFactory && Vector3.Distance(Cam(val3), val2.transform.position) < 60f && Clear(Cam(val3), val2.transform.position + Vector3.up * 2f)) { flag = true; break; } } if (!flag) { list.Add(val2.transform.position); } } } Vector3 val4 = ((list.Count > 0) ? list[Random.Range(0, list.Count)] : ((list2.Count <= 0) ? RoundManager.Instance.GetRandomNavMeshPositionInRadius(val, Mathf.Min(num, 60f), RoundManager.Instance.navHit) : list2[Random.Range(0, list2.Count)])); return RoundManager.Instance.GetNavMeshPosition(val4, RoundManager.Instance.navHit, 6f, -1); } private void TeleportTo(Vector3 pos, bool outside, bool viaEntrance) { //IL_0007: 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) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) StopSearching(); ApplyTeleport(pos, outside, viaEntrance); ChipNet.ToAll(((NetworkBehaviour)this).NetworkObjectId, 8, outside ? 1 : 0, viaEntrance ? 1 : 0, pos); } private void ApplyTeleport(Vector3 pos, bool outside, bool viaEntrance) { //IL_005c: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsOwner && (Object)(object)base.agent != (Object)null) { ((Behaviour)base.agent).enabled = false; ((Component)this).transform.position = pos; ((Behaviour)base.agent).enabled = true; if (base.agent.isOnNavMesh) { base.agent.Warp(pos); } } else { ((Component)this).transform.position = pos; } base.serverPosition = pos; ((EnemyAI)this).SetEnemyOutside(outside); if (!viaEntrance) { return; } try { EntranceTeleport val = RoundManager.FindMainEntranceScript(outside); if ((Object)(object)val != (Object)null && val.doorAudios != null && val.doorAudios.Length != 0) { val.entrancePointAudio.PlayOneShot(val.doorAudios[0]); WalkieTalkie.TransmitOneShotAudio(val.entrancePointAudio, val.doorAudios[0], 1f); } } catch (Exception) { } } private bool Arrived(Vector3 spot, float within) { //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_0069: 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) Vector3 val = spot - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).magnitude < within) { return true; } if (((Behaviour)base.agent).enabled && base.agent.isOnNavMesh && !base.agent.pathPending && base.agent.remainingDistance < 0.4f) { Vector3 velocity = base.agent.velocity; if (((Vector3)(ref velocity)).sqrMagnitude < 0.05f) { return Age > 1f; } } return false; } private void UpdateVisit(float dt) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Unknown result type (might be due to invalid IL or missing references) //IL_04fa: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Ship.DoorOutside(); StartOfRound instance = StartOfRound.Instance; Vector3 q; switch (visitStep) { case 0: GoTo(val, Plugin.ShipWalkSpeed.Value); SetLoco(ChipAnimator.Loco.Normal); if (Vector3.Distance(((Component)this).transform.position, val) < 22f || Ship.NearShip(((Component)this).transform.position, 20f)) { StopMoving(); SetVisitStep(1); NetAction("alert", hold: false); alertLength = Mathf.Max(1.9f, SayNow(5) + 0.35f); } else if (VisitAge > 70f) { BeginRush(); } break; case 1: base.agent.speed = 0f; Face(val, 300f); if (VisitAge > alertLength) { NetStopAction(); BeginRush(); } break; case 2: SetLoco(ChipAnimator.Loco.Run); if (Ship.InShip(((Component)this).transform.position)) { if (prank < 0 || !PrankStillPossible(prank)) { ChoosePrank(); } if (prank < 0) { StopMoving(); SetLoco(ChipAnimator.Loco.Normal); BeginWave(); } else { SetVisitStep(4); } break; } if (instance.hangarDoorsClosed) { if (Vector3.Distance(((Component)this).transform.position, val) < 7f) { goto IL_01c8; } if (Ship.NearShip(((Component)this).transform.position, 12f)) { q = base.agent.velocity; if (((Vector3)(ref q)).sqrMagnitude < 0.3f && VisitAge > 2f) { goto IL_01c8; } } } GoTo(instance.hangarDoorsClosed ? val : ((prank >= 0) ? prankSpot : rushPoint), ChaseSpeed); if (VisitAge > 35f) { LeaveShip(); } break; case 3: base.agent.speed = 0f; Face(Ship.ShipCenter(), 300f); if (!instance.hangarDoorsClosed) { NetStopAction(); SetVisitStep(2); break; } if (Time.time >= nextPrankTick) { nextPrankTick = Time.time + 0.35f; NetSfx(9, 2); float num = Mathf.Max(0f, Plugin.DoorBangDrain.Value); Ship.DrainDoorLocal(num); ulong networkObjectId = ((NetworkBehaviour)this).NetworkObjectId; Vector3 p = new Vector3(num, 0f, 0f); q = default(Vector3); ChipNet.ToAll(networkObjectId, 11, 0, 0, p, q); } if (VisitAge > 45f) { NetStopAction(); LeaveShip(); } break; case 4: { bool flag = prank == 4; SetLoco(flag ? ChipAnimator.Loco.Run : ChipAnimator.Loco.Normal); GoTo(prankSpot, flag ? ChaseSpeed : 4.5f); if (!Arrived(prankSpot, 0.6f) && !(VisitAge > 14f)) { break; } StopMoving(); SetLoco(ChipAnimator.Loco.Normal); if (!PrankStillPossible(prank)) { ChoosePrank(); if (prank < 0) { BeginWave(); } else { SetVisitStep(4); } } else { StartPrank(); } break; } case 5: base.agent.speed = 0f; Face(prankLook, 420f); DoPrank(); break; case 6: { base.agent.speed = 0f; PlayerControllerB val4 = NearestPlayer(25f); if ((Object)(object)val4 != (Object)null) { Face(((Component)val4).transform.position, 240f); if (targetId != (int)val4.playerClientId) { SetTarget(val4); SendState(); } } if (VisitAge > 2.8f) { NetStopOverlay(); LeaveShip(); } break; } case 7: { if (Ship.InShip(((Component)this).transform.position) && instance.hangarDoorsClosed && VisitAge > 0.8f) { VanishIntoFacility(); break; } Vector3 val2 = RoundManager.FindMainEntrancePosition(true, true); if (val2 != Vector3.zero) { GoTo(val2, Plugin.ShipWalkSpeed.Value); } SetLoco(ChipAnimator.Loco.Normal); if (!(val2 == Vector3.zero) && !(Vector3.Distance(((Component)this).transform.position, val2) < 2.2f) && !(VisitAge > 90f)) { break; } Vector3 val3 = RoundManager.FindMainEntrancePosition(true, false); if (val3 == Vector3.zero) { GameObject[] array = GameObject.FindGameObjectsWithTag("AINode"); if (array != null && array.Length != 0) { val3 = array[Random.Range(0, array.Length)].transform.position; } } val3 = RoundManager.Instance.GetNavMeshPosition(val3, RoundManager.Instance.navHit, 5f, -1); TeleportTo(val3, outside: false, viaEntrance: true); EnterWander(announce: false); break; } IL_01c8: StopMoving(); SetVisitStep(3); NetAction("bang", hold: false); nextPrankTick = Time.time + 0.2f; break; } } private PlayerControllerB NearestPlayer(float range) { //IL_0029: 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) PlayerControllerB result = null; float num = range; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (Valid(val)) { float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position); if (num2 < num) { num = num2; result = val; } } } return result; } private void LeaveShip() { StopMoving(); SetTarget(null); SendState(); SetVisitStep(7); } private unsafe void ChoosePrank() { //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) List<int> opts = new List<int>(); List<int> w = new List<int>(); Add(0, Plugin.WeightBuy.Value, Ship.CanBuy()); Add(1, Plugin.WeightLights.Value, (Object)(object)StartOfRound.Instance.shipRoomLights != (Object)null); Add(2, Plugin.WeightTeleport.Value, Ship.CanTeleport()); Add(3, Plugin.WeightFacilityDoors.Value, Ship.BigDoors().Count > 0); Add(4, Plugin.WeightLever.Value, Ship.CanPullLever()); Add(5, Plugin.WeightFreeCable.Value, (Object)(object)Ship.Monitors() != (Object)null); Add(6, Plugin.WeightTV.Value, (Object)(object)Ship.TV() != (Object)null); Add(7, Plugin.WeightTranslator.Value, Ship.HasTranslator()); Add(9, Plugin.WeightLockout.Value, Ship.CanLockOut()); Add(10, Plugin.WeightGift.Value, (Object)(object)ChipAssets.CableBoxPrefab != (Object)null); if (opts.Count == 0) { prank = -1; return; } int num = 0; foreach (int item in w) { num += item; } int num2 = Random.Range(0, num); prank = opts[opts.Count - 1]; for (int i = 0; i < opts.Count; i++) { if (num2 < w[i]) { prank = opts[i]; break; } num2 -= w[i]; } ResolvePrankSpot(); if (Plugin.LogStates.Value) { ManualLogSource log = Plugin.Log; string[] obj = new string[6] { "Chip prank: ", prank.ToString(), " stand ", null, null, null }; Vector3 val = prankSpot; obj[3] = ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString(); obj[4] = " look "; val = prankLook; obj[5] = ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString(); log.LogInfo((object)string.Concat(obj)); } void Add(int p, int weight, bool can) { if (can && weight > 0) { opts.Add(p); w.Add(weight); } } } private bool PrankStillPossible(int p) { return p switch { 0 => Ship.CanBuy(), 1 => (Object)(object)StartOfRound.Instance.shipRoomLights != (Object)null, 2 => Ship.CanTeleport(), 3 => Ship.BigDoors().Count > 0, 4 => Ship.CanPullLever(), _ => ExtraPrankPossible(p), }; } private void BeginRush() { //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) ChoosePrank(); rushPoint = Ship.InsidePoint(); SetVisitStep(2); } private Vector3 StandSpot(Vector3 obj, Transform node, bool shipOnly = true) { //IL_005d: 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_000a: 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_0030: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_021d: 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_00b8: 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_00c4: 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_00cd: 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_00fe: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014f: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if ((Object)(object)node != (Object)null && NavMesh.SamplePosition(node.position, ref val, 1.5f, base.agent.areaMask)) { Vector3 val2 = ((NavMeshHit)(ref val)).position - node.position; val2.y = 0f; if (((Vector3)(ref val2)).magnitude < 0.8f) { return ((NavMeshHit)(ref val)).position; } } Vector3 result = Vector3.zero; float num = float.MaxValue; float[] array = new float[6] { 0.55f, 0.8f, 1.05f, 1.35f, 1.7f, 2.1f }; RaycastHit val5 = default(RaycastHit); foreach (float num2 in array) { for (int j = 0; j < 16; j++) { float num3 = (float)j * (float)Math.PI / 8f; Vector3 val3 = obj + new Vector3(Mathf.Cos(num3), 0f, Mathf.Sin(num3)) * num2; val3.y = obj.y - 0.8f; if (!NavMesh.SamplePosition(val3, ref val, 2.2f, base.agent.areaMask)) { continue; } Vector3 position = ((NavMeshHit)(ref val)).position; Vector3 val4 = position - obj; val4.y = 0f; float magnitude = ((Vector3)(ref val4)).magnitude; if (!(magnitude > 2.4f) && !(obj.y - position.y > 2.6f) && !(position.y - obj.y > 0.8f) && (!shipOnly || Ship.InShip(position + Vector3.up * 0.6f)) && (!Physics.Linecast(position + Vector3.up * 1.5f, obj, ref val5, Mask, (QueryTriggerInteraction)1) || !(Vector3.Distance(((RaycastHit)(ref val5)).point, obj) > 0.6f))) { float num4 = magnitude + Mathf.Abs(position.y + 1.1f - obj.y) * 0.3f; if (num4 < num) { num = num4; result = position; } } } if (num < num2 + 0.3f) { break; } } if (num < float.MaxValue) { return result; } return RoundManager.Instance.GetNavMeshPosition(obj, RoundManager.Instance.navHit, 2.5f, -1); } private int PrankLine(int p) { int num = p switch { 4 => 13, 10 => 26, 6 => 22, 9 => 29, 5 => 30, _ => -1, }; if (num < 0 || !ChipSounds.IsReal(num)) { return 12; } return num; } private void StartPrank() { prankTicks = 0; prankDone = false; nextPrankTick = Time.time; SetVisitStep(5); SayNow(PrankLine(prank)); switch (prank) { case 0: case 3: NetAction("type", hold: false); break; case 2: teleportVictim = Ship.TeleportVictim(); if ((Object)(object)teleportVictim != (Object)null) { Ship.AimRadarAt(teleportVictim); } break; case 4: NetAction("lever", hold: true); break; default: StartExtraPrank(); break; case 1: break; } } private void DoPrank() { float visitAge = VisitAge; switch (prank) { case 0: if (!prankDone && visitAge > 3f) { prankDone = true; Ship.BuyRandomItem(); } if (visitAge > 3.8f) { NetStopAction(); BeginWave(); } break; case 3: if (!prankDone && visitAge > 2.6f) { prankDone = true; Ship.ToggleFacilityDoors(); } if (visitAge > 3.4f) { NetStopAction(); BeginWave(); } break; case 1: if (Time.time >= nextPrankTick && visitAge < 5.5f) { nextPrankTick = Time.time + Random.Range(0.3f, 0.65f); if (prankTicks % 3 == 0) { NetOverlay("press", loop: false); } prankTicks++; Ship.SetLights(!Ship.LightsOn()); } if (visitAge >= 5.5f && !prankDone) { prankDone = true; Ship.SetLights(Random.value < 0.7f); } if (visitAge > 6f) { BeginWave(); } break; case 2: if (prankTicks == 0 && visitAge > 0.9f) { prankTicks = 1; NetOverlay("press", loop: false); } if (!prankDone && visitAge > 1.35f) { prankDone = true; if ((Object)(object)teleportVictim != (Object)null && Valid(teleportVictim) && (Object)(object)Ship.Teleporter() != (Object)null) { Ship.PressTeleporter(); } } if (visitAge > 3f) { BeginWave(); } break; case 4: { if (prankTicks == 0 && visitAge > 0.6f) { prankTicks = 1; } PlayerControllerB v