using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using Photon.Voice; using Photon.Voice.Unity; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.LowLevel; using UnityEngine.PlayerLoop; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TheUncatalogued")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.0.1.0")] [assembly: AssemblyInformationalVersion("0.0.1")] [assembly: AssemblyProduct("TheUncatalogued")] [assembly: AssemblyTitle("TheUncatalogued")] [assembly: AssemblyVersion("0.0.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TheCarousel { internal sealed class AnatomistController : MonoBehaviour, IModEnemyTumbleReceiver { private enum BehaviourState { Planting, Waiting, Attacking, Relocating, Dead } private const float AttackWindupSeconds = 0.56f; private const float AttackLiftSeconds = 1.08f; private const float AttackLiftEndSeconds = 1.6400001f; private const float AttackFinishSeconds = 2.04f; private readonly List _body = new List(); private readonly List _heads = new List(); private SpawnedAnatomistPart _cable; private SpawnedAnatomistPart _palm; private PlayerAvatar _victim; private PlayerTumble _victimTumble; private PhysGrabObject _victimPhys; private Rigidbody _victimBody; private BehaviourState _state; private Vector3 _floorPoint; private Vector3 _ceilingPoint; private Vector3 _attackDropPoint; private Quaternion _handRotation = Quaternion.identity; private float _stateTimer; private float _headTimer; private float _carrySyncTimer; private float _lastClaimedWeaponHitTime = -999f; private float _rewardTimer; private float _soundTimer; private int _health; private int _cableCount; private bool _headCreatedThisCycle; private bool _crushApplied; private bool _victimDropped; private bool _initialized; private bool _cleaning; private bool _rewardDropped; private bool _firstHeadLogged; private bool _firstAttackLogged; private bool _firstDescentLogged; private bool _relocationEndsWaiting; private bool _relocatedDuringTransition; private float _postRelocationHeadDelayScale = 1f; private static readonly FieldInfo PlayerTumbleField = typeof(PlayerAvatar).GetField("tumble", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo GrabbedPhysObjectField = typeof(PhysGrabber).GetField("grabbedPhysGrabObject", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly float[] FingerPhase = new float[5] { 0.18f, 1.43f, 2.72f, 4.31f, 5.66f }; private static readonly float[] FingerCharacter = new float[5] { -0.16f, 0.09f, -0.05f, 0.18f, -0.11f }; private static readonly float[] FingerCloseDelay = new float[5] { 0.02f, 0.11f, 0.06f, 0.15f, 0.08f }; public bool CanReceiveTumbleAttack { get { if (_initialized) { return _state != BehaviourState.Dead; } return false; } } internal bool Initialize(Vector3 position) { //IL_0006: 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_007b: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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) ((Component)this).transform.position = position; _health = Mathf.Max(1, Plugin.Settings.AnatomistHealth.Value); if (!TrySetStation(position)) { return false; } _cableCount = Mathf.Clamp(Mathf.CeilToInt((_ceilingPoint.y - _floorPoint.y) / 1.05f), 7, 26); for (int i = 0; i < _cableCount; i++) { SpawnedAnatomistPart spawnedAnatomistPart = SpawnBody(AnatomistSpawner.CableResourcePath, new Vector3(0.05f, 0.155f, 0.05f), (AnatomistPartRole)i); if (i == 0) { _cable = spawnedAnatomistPart; } if (spawnedAnatomistPart == null) { Cleanup(); return false; } } _palm = SpawnBody(AnatomistSpawner.PalmResourcePath, new Vector3(0.82f, 0.56f, 0.68f), AnatomistPartRole.Palm); if (_palm == null) { Cleanup(); return false; } for (int j = 0; j < 5; j++) { if (SpawnBody(AnatomistSpawner.FingerResourcePath, new Vector3(0.42f, 0.42f, 0.16f), (AnatomistPartRole)(27 + j)) == null) { Cleanup(); return false; } } IgnoreSelfCollisions(); ((Component)this).gameObject.AddComponent().Initialize(this, _body); for (int k = 0; k < _body.Count; k++) { ((Component)_body[k].Phys).gameObject.AddComponent().Initialize(this, k); } _state = BehaviourState.Planting; _stateTimer = 0f; _headTimer = Mathf.Clamp(Plugin.Settings.AnatomistHeadInterval.Value, 4f, 40f) * 0.35f; _soundTimer = Random.Range(0.7f, 1.15f); _handRotation = ResolveDesiredHandRotation(); _initialized = true; PoseArm(0f, clutch: false); Plugin.Log.LogInfo((object)$"The Anatomist assembled a {_cableCount}-segment high-ceiling arm and five syringe fingers with {_health} HP."); return true; } private SpawnedAnatomistPart SpawnBody(string resource, Vector3 scale, AnatomistPartRole role) { //IL_0002: 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) SpawnedAnatomistPart spawnedAnatomistPart = AnatomistSpawner.SpawnBodyPart(resource, _ceilingPoint, scale, role); if (spawnedAnatomistPart != null) { _body.Add(spawnedAnatomistPart); } return spawnedAnatomistPart; } private void Update() { if (!_initialized || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (_state == BehaviourState.Dead) { UpdateDeath(); return; } RemoveDestroyedHeads(); SyncHeadCompanions(); if (TryFindHeadHolder(out var heldHead, out var holder) && StartAttack(holder)) { AnatomistSpawner.Destroy(heldHead); _heads.Remove(heldHead); } switch (_state) { case BehaviourState.Attacking: UpdateAttack(); break; case BehaviourState.Relocating: UpdateRelocating(); break; case BehaviourState.Waiting: PoseArm(0f, clutch: false); break; default: UpdatePlanting(); break; } UpdateSound(); } private void UpdatePlanting() { _headTimer -= Time.deltaTime; if (_headTimer > 0f) { PoseArm(0f, clutch: false); return; } _stateTimer += Time.deltaTime; float num = ((_stateTimer < 1.5f) ? Mathf.SmoothStep(0f, 1f, _stateTimer / 1.5f) : ((!(_stateTimer < 2.05f)) ? (1f - Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((_stateTimer - 2.05f) / 1.4f))) : 1f)); PoseArm(num, clutch: false); if (!_firstDescentLogged && num >= 0.35f) { _firstDescentLogged = true; Plugin.Log.LogInfo((object)"The Anatomist began its first visibly interpolated ceiling-to-floor descent."); } if (!_headCreatedThisCycle && _stateTimer >= 1.76f) { _headCreatedThisCycle = true; SpawnHead(); } if (!(_stateTimer < 3.45f)) { _stateTimer = 0f; _headCreatedThisCycle = false; int num2 = Mathf.Clamp(Plugin.Settings.AnatomistMaximumHeads.Value, 1, 6); if (_heads.Count >= num2) { BeginRelocation(endsWaiting: true, 1f); } else { BeginRelocation(endsWaiting: false, 1f); } } } private void SpawnHead() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) SpawnedAnatomistPart spawnedAnatomistPart = AnatomistSpawner.SpawnDummyHead(_floorPoint + Vector3.up * 0.035f); if (spawnedAnatomistPart != null) { _heads.Add(spawnedAnatomistPart); if (!_firstHeadLogged) { _firstHeadLogged = true; Plugin.Log.LogInfo((object)"The Anatomist dropped its first grabbable networked dummy head."); } } } private bool TryFindHeadHolder(out SpawnedAnatomistPart heldHead, out PlayerAvatar holder) { heldHead = null; holder = null; foreach (SpawnedAnatomistPart head in _heads) { if ((Object)(object)head?.Phys == (Object)null || !head.Alive) { continue; } foreach (PhysGrabber item in head.Phys.playerGrabbing) { if ((Object)(object)item?.playerAvatar != (Object)null && GunAccess.IsLiving(item.playerAvatar)) { heldHead = head; holder = item.playerAvatar; return true; } } } if (Time.frameCount % 4 != 0 || GrabbedPhysObjectField == null) { return false; } PhysGrabber[] array = Object.FindObjectsOfType(); foreach (PhysGrabber val in array) { if ((Object)(object)val?.playerAvatar == (Object)null || !GunAccess.IsLiving(val.playerAvatar)) { continue; } object? value = GrabbedPhysObjectField.GetValue(val); PhysGrabObject val2 = (PhysGrabObject)((value is PhysGrabObject) ? value : null); if ((Object)(object)val2 == (Object)null) { continue; } foreach (SpawnedAnatomistPart head2 in _heads) { if (!((Object)(object)head2?.Phys == (Object)null) && head2.Alive && ((Object)(object)val2 == (Object)(object)head2.Phys || ((Component)val2).transform.IsChildOf(head2.Root.transform) || ((Component)head2.Phys).transform.IsChildOf(((Component)val2).transform))) { heldHead = head2; holder = val.playerAvatar; ManualLogSource log = Plugin.Log; PhotonView photonView = holder.photonView; log.LogInfo((object)$"The Anatomist detected a dummy-head grab through the vanilla grabber link for player view {((photonView != null) ? photonView.ViewID : (-1))}."); return true; } } } return false; } private bool StartAttack(PlayerAvatar holder) { //IL_0027: 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_013f: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(holder)) { return false; } Vector3 position = ((Component)holder).transform.position; if (!TrySetStation(position)) { return false; } _victim = holder; ref PlayerTumble victimTumble = ref _victimTumble; object? obj = PlayerTumbleField?.GetValue(holder); victimTumble = (PlayerTumble)((obj is PlayerTumble) ? obj : null); if ((Object)(object)_victimTumble == (Object)null) { _victimTumble = ((IEnumerable)Object.FindObjectsOfType()).FirstOrDefault((Func)((PlayerTumble tumble) => (Object)(object)tumble != (Object)null && (Object)(object)tumble.playerAvatar == (Object)(object)holder)); } _victimPhys = (((Object)(object)_victimTumble != (Object)null) ? ((Component)_victimTumble).GetComponent() : null); object obj2 = _victimPhys?.rb; if (obj2 == null) { PlayerTumble victimTumble2 = _victimTumble; obj2 = ((victimTumble2 != null) ? ((Component)victimTumble2).GetComponent() : null); } _victimBody = (Rigidbody)obj2; _state = BehaviourState.Attacking; _stateTimer = 0f; _carrySyncTimer = 0f; _crushApplied = false; _victimDropped = false; PlayerTumble victimTumble3 = _victimTumble; if (victimTumble3 != null) { victimTumble3.TumbleSet(true, false); } PlayerTumble victimTumble4 = _victimTumble; if (victimTumble4 != null) { victimTumble4.TumbleOverrideTime(2.4f); } TryFindDropPoint(((Component)holder).transform.position, out _attackDropPoint); return true; } private void UpdateAttack() { //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_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0198: 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_00b6: 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_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(_victim)) { FinishAttack(); return; } _stateTimer += Time.deltaTime; if (_stateTimer < 0.56f) { float extension = Mathf.SmoothStep(0f, 1f, _stateTimer / 0.56f); _floorPoint = ((Component)_victim).transform.position; PoseArm(extension, clutch: true); return; } if (!_crushApplied) { _crushApplied = true; PlayerHealth playerHealth = _victim.playerHealth; if (playerHealth != null) { playerHealth.HurtOther(Mathf.Max(1, Plugin.Settings.AnatomistCrushDamage.Value), ((Component)_victim).transform.position, false, -1, false); } PlayerTumble victimTumble = _victimTumble; if (victimTumble != null) { victimTumble.TumbleSet(true, false); } EmitImpact("ImpactHeavyRPC", 100f, ((Component)_victim).transform.position); if (!_firstAttackLogged) { _firstAttackLogged = true; Plugin.Log.LogInfo((object)$"The Anatomist crushed and abducted its first dummy-head holder for {Plugin.Settings.AnatomistCrushDamage.Value} damage."); } } if (_stateTimer < 1.6400001f) { float num = Mathf.SmoothStep(0f, 1f, (_stateTimer - 0.56f) / 1.08f); PoseArm(1f - num * 0.88f, clutch: true); Vector3 val = Vector3.Lerp(((Component)_victim).transform.position, _ceilingPoint - Vector3.up * 0.92f, Mathf.Clamp01(num + 0.16f)); if ((Object)(object)_victimBody != (Object)null && !_victimBody.isKinematic) { Vector3 val2 = (val - _victimBody.position) * 12f; _victimBody.velocity = Vector3.Lerp(_victimBody.velocity, Vector3.ClampMagnitude(val2, 18f), 1f - Mathf.Exp(-15f * Time.deltaTime)); Rigidbody victimBody = _victimBody; victimBody.angularVelocity *= Mathf.Exp(-10f * Time.deltaTime); } _carrySyncTimer -= Time.deltaTime; if (_carrySyncTimer <= 0f && (Object)(object)_victimPhys != (Object)null) { _carrySyncTimer = 0.2f; _victimPhys.Teleport(val, ((Component)_victim).transform.rotation); } return; } if (!_victimDropped) { _victimDropped = true; if ((Object)(object)_victimPhys != (Object)null) { _victimPhys.Teleport(_attackDropPoint + Vector3.up * 0.7f, Quaternion.identity); _victimTumble.TumbleForce(Vector3.down * 2.5f + Random.insideUnitSphere * 1.2f); } } PoseArm(0f, clutch: true); if (_stateTimer >= 2.04f) { FinishAttack(); } } private void FinishAttack() { _victim = null; _victimTumble = null; _victimPhys = null; _victimBody = null; _stateTimer = 0f; _headCreatedThisCycle = false; BeginRelocation(endsWaiting: false, 0.55f); } private void BeginRelocation(bool endsWaiting, float nextHeadDelayScale) { _state = BehaviourState.Relocating; _stateTimer = 0f; _relocationEndsWaiting = endsWaiting; _relocatedDuringTransition = false; _postRelocationHeadDelayScale = Mathf.Max(0.05f, nextHeadDelayScale); } private void UpdateRelocating() { _stateTimer += Time.deltaTime; if (_stateTimer < 0.72f) { float ceilingHide = Mathf.SmoothStep(0f, 1f, _stateTimer / 0.72f); PoseArm(0f, clutch: false, ceilingHide); return; } PoseArm(0f, clutch: false, 1f); if (!_relocatedDuringTransition && _stateTimer >= 0.94f) { TryRelocate(_relocationEndsWaiting); _relocatedDuringTransition = true; } if (_stateTimer < 1.16f) { return; } float num = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((_stateTimer - 1.16f) / 0.72f)); PoseArm(0f, clutch: false, 1f - num); if (!(_stateTimer < 1.88f)) { _stateTimer = 0f; _state = (_relocationEndsWaiting ? BehaviourState.Waiting : BehaviourState.Planting); if (!_relocationEndsWaiting) { _headTimer = Mathf.Clamp(Plugin.Settings.AnatomistHeadInterval.Value, 4f, 40f) * _postRelocationHeadDelayScale; } PoseArm(0f, clutch: false); } } private void PoseArm(float extension, bool clutch, float ceilingHide = 0f) { //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_0020: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_019a: 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_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0193: 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_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) extension = Mathf.Clamp01(extension); ceilingHide = Mathf.Clamp01(ceilingHide); Vector3 val = Vector3.Lerp(_ceilingPoint - Vector3.up * 0.22f + Vector3.up * (1.1f * ceilingHide), _floorPoint + Vector3.up * (clutch ? 1.25f : 0.92f), extension) - Vector3.up * 0.1f; Quaternion val2 = ResolveDesiredHandRotation(); float num = 1f - Mathf.Exp((0f - Mathf.Max(0.001f, Time.deltaTime)) * 5.5f); _handRotation = Quaternion.Slerp(_handRotation, val2, num); Vector3 val3 = _handRotation * Vector3.right; Vector3 val4 = _handRotation * Vector3.up; Vector3 val5 = _handRotation * Vector3.forward; Vector3 visualCenter = val - val4 * 0.045f; Vector3 val6 = val + Vector3.up * 0.015f; Vector3 val9; for (int i = 0; i < _cableCount; i++) { float num2 = (float)i / (float)_cableCount; float num3 = ((float)i + 1f) / (float)_cableCount; Vector3 val7 = Vector3.Lerp(_ceilingPoint, val6, num2); Vector3 val8 = Vector3.Lerp(_ceilingPoint, val6, num3); val9 = val8 - val7; Vector3 val10 = ((Vector3)(ref val9)).normalized * 0.035f; PoseSegment(FindRole((AnatomistPartRole)i), (i == 0) ? val7 : (val7 - val10), (i == _cableCount - 1) ? val8 : (val8 + val10)); } PosePoint(_palm, visualCenter, _handRotation); for (int j = 0; j < 5; j++) { float num4 = ((float)j - 2f) / 2f; float num5 = FingerCharacter[j]; float num6 = Mathf.Clamp01((extension - FingerCloseDelay[j]) / Mathf.Max(0.05f, 1f - FingerCloseDelay[j])); float num7 = (clutch ? Mathf.SmoothStep(0f, 1f, num6) : Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.44f, 1f, num6))); num7 *= 0.9f + num5 * 0.22f; float num8 = Mathf.Sin(Time.time * ((clutch ? 4f : 2.35f) + (float)j * 0.17f) + FingerPhase[j]); float num9 = Mathf.Sin(Time.time * (1.35f + (float)j * 0.11f) + FingerPhase[j] * 1.73f); float num10 = Mathf.Lerp(24f + num5 * 5f, 13f + num5 * 4f, num7); Vector3 val11 = Quaternion.AngleAxis(num4 * num10 + num8 * Mathf.Lerp(10.5f, 3.8f, num7) + num9 * 3f, val5) * -val4; float num11 = Mathf.Lerp(num5 * 0.008f, 0.06f + num5 * 0.018f, num7) + num8 * 0.008f; val9 = val11 + val5 * num11; Vector3 normalized = ((Vector3)(ref val9)).normalized; Vector3 val12 = val + val3 * (num4 * 0.055f) - val4 * (0.034f - num5 * 0.006f) + val5 * 0.01f; if (clutch) { Vector3 val13 = _floorPoint + Vector3.up * 0.88f - val12; val9 = Vector3.Slerp(normalized, ((Vector3)(ref val13)).normalized, 0.66f + num7 * 0.2f); normalized = ((Vector3)(ref val9)).normalized; } float num12 = Mathf.Lerp(0.5f, 0.43f, Mathf.Abs(num4)) * (1f + num5 * 0.11f + num9 * 0.045f); Vector3 end = val12 + normalized * num12; PoseSegment(FindRole((AnatomistPartRole)(27 + j)), val12, end, val5); } } private Quaternion ResolveDesiredHandRotation() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00bb: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar val = null; float num = float.MaxValue; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { Vector3 val2 = ((Component)item).transform.position - _floorPoint; val2.y = 0f; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val = item; } } } if ((Object)(object)val == (Object)null) { return _handRotation; } Vector3 val3 = ((Component)val).transform.position - _floorPoint; val3.y = 0f; if (!(((Vector3)(ref val3)).sqrMagnitude > 0.001f)) { return _handRotation; } return Quaternion.LookRotation(((Vector3)(ref val3)).normalized, Vector3.up); } private SpawnedAnatomistPart FindRole(AnatomistPartRole role) { return _body.FirstOrDefault((SpawnedAnatomistPart part) => part.Role == role); } private static void PoseSegment(SpawnedAnatomistPart part, Vector3 start, Vector3 end, Vector3? preferredFacing = null) { //IL_0015: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_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_0059: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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)part?.Phys == (Object)null)) { Vector3 val = end - start; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.down * 0.01f; } Vector3 normalized = ((Vector3)(ref val)).normalized; Quaternion rotation = StableSegmentRotation(part, normalized, (Vector3)(((??)preferredFacing) ?? Vector3.forward)); PosePoint(part, (start + end) * 0.5f, rotation); } } private static Quaternion StableSegmentRotation(SpawnedAnatomistPart part, Vector3 direction, Vector3 preferredFacing) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_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_0035: 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_003a: 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_003c: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_004a: 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_0050: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_0097: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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) Quaternion val = Quaternion.FromToRotation(part.LongAxisLocal, direction); Vector3 val2 = ((Mathf.Abs(Vector3.Dot(((Vector3)(ref part.LongAxisLocal)).normalized, Vector3.forward)) < 0.92f) ? Vector3.forward : Vector3.right); Vector3 val3 = Vector3.ProjectOnPlane(val * val2, direction); Vector3 val4 = Vector3.ProjectOnPlane(preferredFacing, direction); if (((Vector3)(ref val4)).sqrMagnitude < 0.0001f) { val4 = Vector3.ProjectOnPlane(Vector3.right, direction); } if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f || ((Vector3)(ref val4)).sqrMagnitude < 0.0001f) { return val; } return Quaternion.AngleAxis(Vector3.SignedAngle(((Vector3)(ref val3)).normalized, ((Vector3)(ref val4)).normalized, direction), direction) * val; } private static void PosePoint(SpawnedAnatomistPart part, Vector3 visualCenter, Quaternion rotation) { //IL_0133: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: 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_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)part?.Phys == (Object)null) { return; } if (part.GeometryCalibrationFrames > 0) { AnatomistSpawner.RefreshGeometry(part, refreshLongAxis: false); part.GeometryCalibrationFrames--; if (part.GeometryCalibrationFrames == 0 && !part.GeometryLogged) { part.GeometryLogged = true; Plugin.Log.LogInfo((object)$"Anatomist geometry {part.Role}: resource={part.ResourcePath}, rendered={part.VisualSize}, centerOffset={part.VisualCenterOffset}, axis={part.LongAxisLocal}."); } } part.ImpactDetector.destroyDisable = true; part.Phys.OverrideIndestructible(0.3f); part.Phys.OverrideGrabDisable(0.3f); part.Phys.OverrideKinematic(0.3f); if (!part.PoseInitialized) { part.SmoothedVisualCenter = visualCenter; part.SmoothedRotation = rotation; part.PoseInitialized = true; } else { float num = 1f - Mathf.Exp(-9f * Time.deltaTime); float num2 = 1f - Mathf.Exp(-7f * Time.deltaTime); part.SmoothedVisualCenter = Vector3.Lerp(part.SmoothedVisualCenter, visualCenter, num); part.SmoothedRotation = Quaternion.Slerp(part.SmoothedRotation, rotation, num2); } Vector3 val = part.SmoothedVisualCenter - part.SmoothedRotation * part.VisualCenterOffset; Vector3 val2 = ((Component)part.Phys).transform.position - val; if (!(((Vector3)(ref val2)).sqrMagnitude > 1E-06f) && !(Quaternion.Angle(((Component)part.Phys).transform.rotation, part.SmoothedRotation) > 0.05f)) { return; } part.Phys.SetPositionLogic(val, part.SmoothedRotation); ((Component)part.Phys).transform.SetPositionAndRotation(val, part.SmoothedRotation); if ((Object)(object)part.Phys.rb != (Object)null) { part.Phys.rb.position = val; part.Phys.rb.rotation = part.SmoothedRotation; if (!part.Phys.rb.isKinematic) { part.Phys.rb.velocity = Vector3.zero; part.Phys.rb.angularVelocity = Vector3.zero; } } } private void SyncHeadCompanions() { //IL_0142: 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) foreach (SpawnedAnatomistPart head in _heads) { if ((Object)(object)head?.Phys == (Object)null || !head.Alive) { continue; } head.ImpactDetector.destroyDisable = true; head.Phys.OverrideIndestructible(0.4f); UpdateHeadDiscovery(head); if (head.HeadActivationRepeats <= 0) { continue; } head.HeadActivationTimer -= Time.deltaTime; if (head.HeadActivationTimer > 0f) { continue; } head.HeadActivationTimer = 0.5f; head.HeadActivationRepeats--; Collider[] array = head.Colliders ?? Array.Empty(); foreach (Collider val in array) { if ((Object)(object)val != (Object)null) { val.enabled = true; } } if (!head.HeadActivated) { head.HeadActivated = true; head.Phys.clientNonKinematic = true; if ((Object)(object)head.Phys.rb != (Object)null) { head.Phys.rb.isKinematic = false; head.Phys.rb.collisionDetectionMode = (CollisionDetectionMode)2; head.Phys.rb.interpolation = (RigidbodyInterpolation)1; } head.Phys.Teleport(head.HeadSpawnPosition, head.HeadSpawnRotation); } if (GameManager.Multiplayer() && (Object)(object)head.View != (Object)null) { head.View.RPC("OverrideSpectatedRPC", (RpcTarget)1, new object[1] { false }); if (!head.HeadColorSent) { head.HeadColorSent = true; head.View.RPC("SetupColorsAllRPC", (RpcTarget)4, new object[1] { head.HeadColorIndex }); } } } } private void UpdateHeadDiscovery(SpawnedAnatomistPart head) { if ((Object)(object)head?.DeathHead == (Object)null || (Object)(object)head.Phys == (Object)null) { return; } if (!head.HeadDiscovered) { MapCustom mapCustom = head.DeathHead.mapCustom; if (mapCustom != null) { mapCustom.Hide(); } } bool flag = IsHeadSeenByLocalPlayer(head); if (!head.HeadDiscovered && (flag || IsHeadSeenByRemotePlayer(head))) { head.HeadDiscovered = true; if (GameManager.Multiplayer() && (Object)(object)head.View != (Object)null) { head.View.RPC("SeenSetRPC", (RpcTarget)3, new object[1] { true }); } else { Traverse.Create((object)head.DeathHead).Field("serverSeen").SetValue((object)true); } Plugin.Log.LogInfo((object)"The Anatomist's first dummy head was identified and published as a vanilla red death-head map marker."); } if (flag && !head.HeadHostDiscoverGraphicShown && (Object)(object)ValuableDiscover.instance != (Object)null) { head.HeadHostDiscoverGraphicShown = true; ValuableDiscover.instance.New(head.Phys, (State)2, (ValuableDiscoverCustom)null); } } private static bool IsHeadSeenByLocalPlayer(SpawnedAnatomistPart head) { //IL_0059: 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) if ((Object)(object)PlayerController.instance == (Object)null || (Object)(object)PlayerController.instance.playerAvatarScript == (Object)null || !GunAccess.IsLiving(PlayerController.instance.playerAvatarScript)) { return false; } PlayerLocalCamera localCamera = PlayerController.instance.playerAvatarScript.localCamera; Transform val = ((localCamera != null) ? localCamera.GetOverrideTransform() : null); if ((Object)(object)val != (Object)null) { return IsHeadVisibleFrom(head, val.position, val.forward, requireLocalOnScreen: true); } return false; } private static bool IsHeadSeenByRemotePlayer(SpawnedAnatomistPart head) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0082: Unknown result type (might be due to invalid IL or missing references) if (!GameManager.Multiplayer() || (Object)(object)GameDirector.instance == (Object)null) { return false; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!((Object)(object)player == (Object)null) && !((Object)(object)player == (Object)(object)PlayerController.instance?.playerAvatarScript) && GunAccess.IsLiving(player)) { Vector3 eye = ((Component)player).transform.position + Vector3.up * 1.35f; if (IsHeadVisibleFrom(head, eye, ((Component)player).transform.forward, requireLocalOnScreen: false)) { return true; } } } return false; } private static bool IsHeadVisibleFrom(SpawnedAnatomistPart head, Vector3 eye, Vector3 forward, bool requireLocalOnScreen) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_000d: 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_0013: 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_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_0038: 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_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_004f: Unknown result type (might be due to invalid IL or missing references) Vector3 centerPoint = head.Phys.centerPoint; Vector3 val = centerPoint - eye; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude > 10f || magnitude < 0.05f) { return false; } Vector3 val2 = val / magnitude; if (Vector3.Dot(((Vector3)(ref forward)).normalized, val2) < 0.63f) { return false; } if (requireLocalOnScreen && !SemiFunc.OnScreen(centerPoint, -0.15f, -0.15f)) { return false; } return !Physics.Raycast(eye, val2, magnitude, LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1); } private void UpdateSound() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) _soundTimer -= Time.deltaTime; if (!(_soundTimer > 0f) && !((Object)(object)_palm?.ImpactDetector == (Object)null) && !((Object)(object)_palm.Phys == (Object)null)) { _soundTimer = Random.Range(0.75f, 1.25f); _palm.ImpactDetector.ImpactLight(82f, _palm.Phys.centerPoint); } } private bool TrySetStation(Vector3 candidate) { //IL_0000: 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_0027: 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) NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(candidate, ref val, 6f, -1)) { return false; } if (!TryFindRealCeiling(((NavMeshHit)(ref val)).position, out var ceiling)) { return false; } SetStation(((NavMeshHit)(ref val)).position, ceiling); return true; } private static bool TryFindRealCeiling(Vector3 floor, out Vector3 ceiling) { //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) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) foreach (RaycastHit item in from candidate in Physics.RaycastAll(floor + Vector3.up * 0.25f, Vector3.up, 28.5f, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1) orderby ((RaycastHit)(ref candidate)).distance descending select candidate) { RaycastHit current = item; float num = ((RaycastHit)(ref current)).point.y - floor.y; if (!(num < 1.65f) && !(num > 28f) && !(((RaycastHit)(ref current)).normal.y > -0.2f)) { ceiling = ((RaycastHit)(ref current)).point - Vector3.up * 0.1f; return true; } } ceiling = Vector3.zero; return false; } private void SetStation(Vector3 floor, Vector3 ceiling) { //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) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) _floorPoint = floor; _ceilingPoint = ceiling; ((Component)this).transform.position = floor; foreach (SpawnedAnatomistPart item in _body) { if (item != null) { item.PoseInitialized = false; } } } private bool TryRelocate(bool hidden) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_000a: 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) Vector3 floorPoint = _floorPoint; LevelPoint val = (hidden ? SemiFunc.LevelPointGetFurthestFromPlayer(floorPoint, 8f) : SemiFunc.LevelPointGetPlayerDistance(floorPoint, 10f, 55f, false)); if ((Object)(object)val == (Object)null) { return false; } return TrySetStation(((Component)val).transform.position); } private static bool TryFindDropPoint(Vector3 origin, out Vector3 point) { //IL_0000: 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_0047: 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_002b: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) LevelPoint val = SemiFunc.LevelPointGetPlayerDistance(origin, 10f, 45f, false) ?? SemiFunc.LevelPointGetFurthestFromPlayer(origin, 6f); Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : (origin + Random.onUnitSphere * 10f)); val2.y = origin.y; NavMeshHit val3 = default(NavMeshHit); if (NavMesh.SamplePosition(val2, ref val3, 7f, -1)) { point = ((NavMeshHit)(ref val3)).position; return true; } point = origin; return false; } private void IgnoreSelfCollisions() { for (int i = 0; i < _body.Count; i++) { for (int j = i + 1; j < _body.Count; j++) { Collider[] array = _body[i].Colliders ?? Array.Empty(); foreach (Collider val in array) { Collider[] array2 = _body[j].Colliders ?? Array.Empty(); foreach (Collider val2 in array2) { if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { Physics.IgnoreCollision(val, val2, true); } } } } } } private void RemoveDestroyedHeads() { for (int num = _heads.Count - 1; num >= 0; num--) { SpawnedAnatomistPart spawnedAnatomistPart = _heads[num]; if (spawnedAnatomistPart == null || !spawnedAnatomistPart.Alive || (Object)(object)spawnedAnatomistPart.Root == (Object)null || (Object)(object)spawnedAnatomistPart.Phys == (Object)null || spawnedAnatomistPart.Phys.dead) { _heads.RemoveAt(num); } } if (_state == BehaviourState.Waiting && _heads.Count < Mathf.Clamp(Plugin.Settings.AnatomistMaximumHeads.Value, 1, 6)) { BeginRelocation(endsWaiting: false, 0.5f); } } internal bool TryClaimWeaponHit(int sourceId) { if (_state == BehaviourState.Dead || !ModEnemyWeaponDamage.TryClaim((Object)(object)this, sourceId) || Time.time - _lastClaimedWeaponHitTime < 0.06f) { return false; } _lastClaimedWeaponHitTime = Time.time; return true; } internal void ReceiveWeaponHit(Vector3 hitPosition, int damage) { //IL_000e: 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) if (_state != BehaviourState.Dead && damage > 0) { damage = ParasiteEffectRegistry.ModifyEnemyDamageAt(hitPosition, damage); _health -= damage; ModEnemyFeedback.DamageHit(_palm?.ImpactDetector, _palm?.Phys, hitPosition, 90f); if (_health <= 0) { Die(); } } } public void ReceiveTumbleAttack(int partIndex, int damage, Vector3 hitPosition, Vector3 direction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ReceiveWeaponHit(hitPosition, Mathf.Max(1, damage)); } internal void ExecuteForLab() { if (_state != BehaviourState.Dead) { _health = 0; Die(); } } private void Die() { if (_state == BehaviourState.Dead) { return; } _state = BehaviourState.Dead; foreach (SpawnedAnatomistPart item in _body) { if (item.Alive) { item.Alive = false; item.ImpactDetector.destroyDisable = false; item.ImpactDetector.DestroyObject(true); } } foreach (SpawnedAnatomistPart item2 in _heads.ToList()) { AnatomistSpawner.Destroy(item2); } _heads.Clear(); _rewardTimer = 0.08f; } private void UpdateDeath() { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_00bd: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (_rewardDropped) { return; } _rewardTimer -= Time.deltaTime; if (_rewardTimer > 0f) { return; } _rewardDropped = true; if (!Plugin.Settings.AnatomistDropEnemyValuable.Value || (Object)(object)AssetManager.instance == (Object)null) { return; } GameObject val = (GameObject)(Mathf.Clamp(Plugin.Settings.AnatomistRewardTier.Value, 1, 3) switch { 2 => AssetManager.instance.enemyValuableMedium, 1 => AssetManager.instance.enemyValuableSmall, _ => AssetManager.instance.enemyValuableBig, }); if (!((Object)(object)val == (Object)null)) { if (GameManager.Multiplayer()) { PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)val).name, ((Component)this).transform.position + Vector3.up * 0.45f, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate(val, ((Component)this).transform.position + Vector3.up * 0.45f, Quaternion.identity); } } } private void EmitImpact(string rpcName, float force, Vector3 position) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) PhotonView val = _palm?.View; if ((Object)(object)val != (Object)null && GameManager.Multiplayer()) { val.RPC(rpcName, (RpcTarget)0, new object[2] { force, position }); } else if ((Object)(object)_palm?.ImpactDetector != (Object)null) { _palm.ImpactDetector.ImpactHeavy(force, position); } } private void OnDestroy() { if (_initialized && !_cleaning && SemiFunc.IsMasterClientOrSingleplayer()) { Cleanup(); } } private void Cleanup() { if (_cleaning) { return; } _cleaning = true; foreach (SpawnedAnatomistPart item in _body) { if (item.Alive) { AnatomistSpawner.Destroy(item); } } foreach (SpawnedAnatomistPart head in _heads) { if (head.Alive) { AnatomistSpawner.Destroy(head); } } } } internal sealed class AnatomistHitProxy : MonoBehaviour { private AnatomistController _controller; private Renderer[] _renderers = Array.Empty(); private PhysGrabObjectImpactDetector[] _detectors = Array.Empty(); private readonly Dictionary _previous = new Dictionary(); private readonly HashSet _current = new HashSet(); private float _cooldown; private static int _bulletFrame = -1; private static ItemGunBullet[] _bullets = Array.Empty(); internal void Initialize(AnatomistController controller, IEnumerable parts) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown _controller = controller; List list = new List(); List list2 = new List(); foreach (SpawnedAnatomistPart part in parts) { if (part?.Renderers != null) { list.AddRange(part.Renderers); } if ((Object)(object)part?.ImpactDetector != (Object)null) { list2.Add(part.ImpactDetector); UnityEvent onHurtColliderHit = part.ImpactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.AddListener(new UnityAction(OnHurtColliderHit)); } } } _renderers = list.ToArray(); _detectors = list2.ToArray(); } private void Update() { _cooldown = Mathf.Max(0f, _cooldown - Time.deltaTime); if (_cooldown <= 0f && SemiFunc.IsMasterClientOrSingleplayer()) { DetectExpandedBulletHit(); } } private void OnDestroy() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown PhysGrabObjectImpactDetector[] detectors = _detectors; foreach (PhysGrabObjectImpactDetector obj in detectors) { if (obj != null) { UnityEvent onHurtColliderHit = obj.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.RemoveListener(new UnityAction(OnHurtColliderHit)); } } } } private void OnHurtColliderHit() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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) if ((Object)(object)_controller == (Object)null || _cooldown > 0f || !SemiFunc.IsMasterClientOrSingleplayer() || !_controller.TryClaimWeaponHit(ModEnemyWeaponDamage.CurrentClaimId)) { return; } _cooldown = 0.16f; Vector3 val = ClosestPoint(((Component)this).transform.position); if (EnemyLabBridge.IsExecutionHitNear(val)) { _controller.ExecuteForLab(); return; } int num = ModEnemyWeaponDamage.CurrentOrFallback(Plugin.Settings.AnatomistDamagePerHit.Value); if (num > 0) { _controller.ReceiveWeaponHit(val, num); } } private void DetectExpandedBulletHit() { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_controller == (Object)null) { return; } if (_bulletFrame != Time.frameCount) { _bulletFrame = Time.frameCount; _bullets = Object.FindObjectsOfType(); } _current.Clear(); ItemGunBullet[] bullets = _bullets; foreach (ItemGunBullet val in bullets) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent() != (Object)null || (Object)(object)val.hurtCollider == (Object)null || !((Component)val.hurtCollider).gameObject.activeInHierarchy) { continue; } int instanceID = ((Object)val).GetInstanceID(); _current.Add(instanceID); Vector3 position = ((Component)val.hurtCollider).transform.position; Vector3 value; bool num = _previous.TryGetValue(instanceID, out value); _previous[instanceID] = position; if (!(num ? SegmentIntersects(value, position) : Within(position)) || !_controller.TryClaimWeaponHit(instanceID)) { continue; } _cooldown = 0.22f; if (EnemyLabBridge.IsExecutionHitNear(position)) { _controller.ExecuteForLab(); return; } int num2 = ModEnemyWeaponDamage.Resolve(val.hurtCollider, Plugin.Settings.AnatomistDamagePerHit.Value); if (num2 > 0) { _controller.ReceiveWeaponHit(position, num2); } return; } if (_previous.Count <= _current.Count) { return; } List list = null; foreach (int key in _previous.Keys) { if (!_current.Contains(key)) { if (list == null) { list = new List(); } list.Add(key); } } foreach (int item in list ?? new List()) { _previous.Remove(item); } } private bool Within(Vector3 point) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Settings.AnatomistHitDetectionPadding.Value, 0.12f, 0.8f); float num2 = num * num; Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if ((Object)(object)val != (Object)null && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; if (((Bounds)(ref bounds)).SqrDistance(point) <= num2) { return true; } } } return false; } private bool SegmentIntersects(Vector3 start, Vector3 end) { //IL_004d: 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_0062: 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) float num = Mathf.Clamp(Plugin.Settings.AnatomistHitDetectionPadding.Value, 0.12f, 0.8f); Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if (!((Object)(object)val == (Object)null) && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; ((Bounds)(ref bounds)).Expand(num * 2f); if (SegmentIntersectsBounds(start, end, bounds)) { return true; } } } return false; } private Vector3 ClosestPoint(Vector3 origin) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_004b: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) Vector3 result = ((Component)this).transform.position; float num = float.PositiveInfinity; Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if (!((Object)(object)val == (Object)null) && val.enabled) { Bounds bounds = val.bounds; Vector3 val2 = ((Bounds)(ref bounds)).ClosestPoint(origin); Vector3 val3 = val2 - origin; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val2; } } } return result; } private static bool SegmentIntersectsBounds(Vector3 start, Vector3 end, Bounds bounds) { //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) //IL_0002: 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_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float num = 0f; float num2 = 1f; for (int i = 0; i < 3; i++) { float num3 = ((Vector3)(ref start))[i]; float num4 = ((Vector3)(ref val))[i]; Vector3 val2; if (Mathf.Abs(num4) < 1E-05f) { val2 = ((Bounds)(ref bounds)).min; if (!(num3 < ((Vector3)(ref val2))[i])) { val2 = ((Bounds)(ref bounds)).max; if (!(num3 > ((Vector3)(ref val2))[i])) { continue; } } return false; } float num5 = 1f / num4; val2 = ((Bounds)(ref bounds)).min; float num6 = (((Vector3)(ref val2))[i] - num3) * num5; val2 = ((Bounds)(ref bounds)).max; float num7 = (((Vector3)(ref val2))[i] - num3) * num5; if (num6 > num7) { float num8 = num7; num7 = num6; num6 = num8; } num = Mathf.Max(num, num6); num2 = Mathf.Min(num2, num7); if (num > num2) { return false; } } return true; } } internal sealed class AnatomistManager : MonoBehaviour { private int _levelId; private float _spawnTimer; private bool _attemptFinished; private bool _probed; private bool _available; private AnatomistController _encounter; internal void Tick() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (!IsHostReady()) { return; } Probe(); int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } if (!ModEnemyLevelRules.IsPlayableLevel()) { DestroyCurrent(); return; } LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null || !instance.Generated || _attemptFinished) { return; } _spawnTimer -= Time.deltaTime; if (!(_spawnTimer > 0f)) { _attemptFinished = true; if (Random.value <= Mathf.Clamp01(Plugin.Settings.AnatomistSpawnChance.Value) && TryFindSpawn(out var position)) { Create(position, "automatic"); } } } private void ResetForLevel(int levelId) { DestroyCurrent(); _levelId = levelId; _spawnTimer = Mathf.Max(0f, Plugin.Settings.AnatomistSpawnDelay.Value); _attemptFinished = false; } private bool Create(Vector3 position, string source) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (!_available && !AnatomistSpawner.PrefabsAvailable()) { Plugin.Log.LogWarning((object)"The Anatomist could not resolve its vanilla syringe-arm resources."); return false; } DestroyCurrent(); GameObject val = new GameObject("The Anatomist Encounter (Host Logic)"); val.SetActive(false); val.transform.position = position; AnatomistController anatomistController = val.AddComponent(); if (!anatomistController.Initialize(position)) { Object.Destroy((Object)(object)val); return false; } val.SetActive(true); _encounter = anatomistController; Plugin.Log.LogInfo((object)$"The Anatomist descended at {position} ({source}); all visible arm and dummy-head pieces are vanilla network objects."); return true; } internal bool DebugSpawnAt(Vector3 requestedPosition) { //IL_0039: 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) if (!IsHostReady() || (!ModEnemySpawnCoordinator.IsDirectorRequestActive && (Object)(object)PlayerAvatar.instance == (Object)null) || !ModEnemyLevelRules.IsPlayableLevel()) { Plugin.Log.LogWarning((object)"Enemy Lab rejected The Anatomist because no playable host level is active."); return false; } Probe(); NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requestedPosition, ref val, 12f, -1)) { return false; } _attemptFinished = true; return Create(((NavMeshHit)(ref val)).position, ModEnemySpawnCoordinator.CurrentSpawnSource); } internal void MarkAutomaticAttemptFinished() { int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } _attemptFinished = true; } internal void DebugDespawn() { if (IsHostReady()) { _attemptFinished = true; DestroyCurrent(); } } private void DestroyCurrent() { if ((Object)(object)_encounter != (Object)null) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); _encounter = null; } } private void Probe() { if (!_probed && !((Object)(object)RunManager.instance == (Object)null)) { _probed = true; _available = AnatomistSpawner.PrefabsAvailable(); Plugin.Log.LogInfo((object)$"The Anatomist prefab probe: available={_available}."); } } private static bool TryFindSpawn(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; PlayerAvatar val = null; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { val = item; break; } } Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(val2, 20f, 65f, false) ?? SemiFunc.LevelPointGetFurthestFromPlayer(val2, 8f); return ModEnemyNavigation.TryFindClearSpawn(((Object)(object)val3 != (Object)null) ? ((Component)val3).transform.position : (val2 + Vector3.forward * 20f), 8f, out position); } private static bool IsHostReady() { try { return (Object)(object)GameManager.instance != (Object)null && (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient); } catch { return false; } } } internal enum AnatomistPartRole { Cable, Cable1, Cable2, Cable3, Cable4, Cable5, Cable6, Cable7, Cable8, Cable9, Cable10, Cable11, Cable12, Cable13, Cable14, Cable15, Cable16, Cable17, Cable18, Cable19, Cable20, Cable21, Cable22, Cable23, Cable24, Cable25, Palm, FingerBarrel0, FingerBarrel1, FingerBarrel2, FingerBarrel3, FingerBarrel4, Needle0, Needle1, Needle2, Needle3, Needle4, DummyHead } internal sealed class SpawnedAnatomistPart { internal string ResourcePath; internal GameObject Root; internal PhysGrabObject Phys; internal PhysGrabObjectImpactDetector ImpactDetector; internal ItemAttributes Attributes; internal PhotonView View; internal Renderer[] Renderers; internal Collider[] Colliders; internal AnatomistPartRole Role; internal Vector3 VisualCenterOffset; internal Vector3 VisualSize; internal Vector3 LongAxisLocal = Vector3.up; internal int GeometryCalibrationFrames = 16; internal Vector3 SmoothedVisualCenter; internal Quaternion SmoothedRotation = Quaternion.identity; internal bool PoseInitialized; internal PlayerDeathHead DeathHead; internal Vector3 HeadSpawnPosition; internal Quaternion HeadSpawnRotation = Quaternion.identity; internal float HeadActivationTimer; internal int HeadActivationRepeats; internal bool HeadActivated; internal int HeadColorIndex = -1; internal bool HeadColorSent; internal bool HeadDiscovered; internal bool HeadHostDiscoverGraphicShown; internal bool GeometryLogged; internal bool Alive = true; } internal static class AnatomistSpawner { private static readonly string[] SizeFolders = new string[7] { "01 Tiny", "02 Small", "03 Medium", "04 Big", "05 Wide", "06 Tall", "07 Very Tall" }; private static string _palmPath; private static string _fingerPath; internal static string CableResourcePath => "Valuables/07 Very Tall/Valuable Wizard Broom"; internal static string PalmResourcePath { get { object obj = _palmPath; if (obj == null) { obj = FindValuable("Valuable Arctic HDD") ?? FindValuable("Valuable Arctic Phone") ?? FindValuable("Valuable Arctic Pills") ?? "Valuables/07 Very Tall/Valuable Wizard Broom"; _palmPath = (string)obj; } return (string)obj; } } internal static string FingerResourcePath { get { object obj = _fingerPath; if (obj == null) { obj = FindValuable("Valuable Arctic Icepick") ?? FindValuable("Valuable Arctic Ice Pick") ?? FindValuable("Valuable Icepick") ?? FindValuable("Valuable Ice Pick") ?? FindValuable("Valuable Wizard Unicorn Horn") ?? "Valuables/07 Very Tall/Valuable Wizard Broom"; _fingerPath = (string)obj; } return (string)obj; } } internal static bool PrefabsAvailable() { if ((Object)(object)Resources.Load(CableResourcePath) != (Object)null && (Object)(object)Resources.Load(PalmResourcePath) != (Object)null) { return (Object)(object)Resources.Load(FingerResourcePath) != (Object)null; } return false; } private static string FindValuable(string name) { string[] sizeFolders = SizeFolders; foreach (string text in sizeFolders) { string text2 = "Valuables/" + text + "/" + name; if ((Object)(object)Resources.Load(text2) != (Object)null) { return text2; } } return null; } internal static SpawnedAnatomistPart SpawnBodyPart(string resourcePath, Vector3 position, Vector3 scale, AnatomistPartRole role) { //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) SpawnedAnatomistPart spawnedAnatomistPart = Spawn(resourcePath, position, scale, role); if (spawnedAnatomistPart == null) { return null; } EncounterValuableNeutralizer.Apply(spawnedAnatomistPart.Root); ItemAttributes attributes = spawnedAnatomistPart.Attributes; if (attributes != null) { attributes.DisableUI(true); } spawnedAnatomistPart.ImpactDetector.destroyDisable = true; spawnedAnatomistPart.ImpactDetector.playerHurtDisable = true; spawnedAnatomistPart.Phys.OverrideIndestructible(1f); spawnedAnatomistPart.Phys.OverrideGrabDisable(1f); spawnedAnatomistPart.Phys.OverrideKinematic(1f); MapIconSuppressor.Attach(spawnedAnatomistPart.Root); return spawnedAnatomistPart; } internal static SpawnedAnatomistPart SpawnDummyHead(Vector3 position) { //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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) GameObject val = LevelGenerator.Instance?.PlayerDeathHeadPrefab; if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"The Anatomist could not find the vanilla PlayerDeathHead prefab."); return null; } try { Quaternion val2 = Quaternion.Euler(Random.Range(-24f, 24f), Random.Range(0f, 360f), Random.Range(-18f, 18f)); GameObject val3 = (GameManager.Multiplayer() ? PhotonNetwork.Instantiate(((Object)val).name, position, val2, (byte)0, (object[])null) : Object.Instantiate(val, position, val2)); if ((Object)(object)val3 == (Object)null) { return null; } PlayerDeathHead component = val3.GetComponent(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; Traverse.Create((object)component).Field("setup").SetValue((object)true); } SpawnedAnatomistPart spawnedAnatomistPart = new SpawnedAnatomistPart { ResourcePath = ((Object)val).name, Root = val3, Phys = val3.GetComponentInChildren(true), ImpactDetector = val3.GetComponentInChildren(true), View = val3.GetComponentInChildren(true), Renderers = val3.GetComponentsInChildren(true), Colliders = val3.GetComponentsInChildren(true), Role = AnatomistPartRole.DummyHead, DeathHead = component, HeadSpawnPosition = position, HeadSpawnRotation = val2, HeadActivationTimer = 0.45f, HeadActivationRepeats = 4, HeadColorIndex = ((MetaManager.instance?.colors != null && MetaManager.instance.colors.Count > 0) ? Random.Range(0, MetaManager.instance.colors.Count) : 0) }; if ((Object)(object)spawnedAnatomistPart.Phys == (Object)null || (Object)(object)spawnedAnatomistPart.ImpactDetector == (Object)null) { Destroy(spawnedAnatomistPart); return null; } spawnedAnatomistPart.ImpactDetector.destroyDisable = true; spawnedAnatomistPart.ImpactDetector.playerHurtDisable = true; spawnedAnatomistPart.Phys.clientNonKinematic = true; spawnedAnatomistPart.Phys.OverrideMass(1.1f, 1f); PlayerCosmetics[] componentsInChildren = val3.GetComponentsInChildren(true); foreach (PlayerCosmetics val4 in componentsInChildren) { if (!((Object)(object)val4 == (Object)null)) { TryApplyHostDummyColour(val4, component, spawnedAnatomistPart.Phys, spawnedAnatomistPart.HeadColorIndex); Traverse.Create((object)val4).Field("firstSetup").SetValue((object)false); ((Behaviour)val4).enabled = false; } } return spawnedAnatomistPart; } catch (Exception arg) { Plugin.Log.LogError((object)$"The Anatomist could not spawn a vanilla player head: {arg}"); return null; } } private static void TryApplyHostDummyColour(PlayerCosmetics cosmetics, PlayerDeathHead deathHead, PhysGrabObject phys, int colour) { if ((Object)(object)cosmetics == (Object)null || (Object)(object)deathHead == (Object)null || (Object)(object)phys == (Object)null || MetaManager.instance?.colors == null || MetaManager.instance.colors.Count == 0) { return; } try { Traverse.Create((object)deathHead).Field("physGrabObject").SetValue((object)phys); Traverse.Create((object)cosmetics).Method("PlayerMaterialSetup", Array.Empty()).GetValue(); colour = Mathf.Clamp(colour, 0, MetaManager.instance.colors.Count - 1); Traverse.Create((object)cosmetics).Method("SetupColorsAllLogic", new object[1] { colour }).GetValue(); } catch (Exception ex) { Plugin.Log.LogDebug((object)("The Anatomist kept the host dummy head's default colour: " + ex.Message)); } } private static SpawnedAnatomistPart Spawn(string resourcePath, Vector3 position, Vector3 scale, AnatomistPartRole role) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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) GameObject val = Resources.Load(resourcePath); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("The Anatomist could not load vanilla resource '" + resourcePath + "'.")); return null; } ((Vector3)(ref scale))..ctor(Mathf.Clamp(scale.x, 0.025f, 1.5f), Mathf.Clamp(scale.y, 0.025f, 1.5f), Mathf.Clamp(scale.z, 0.025f, 1.5f)); Vector3 val2 = Vector3.Scale(val.transform.localScale, scale); object[] array = new object[3] { val2.x, val2.y, val2.z }; GameObject val3; try { val3 = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject(resourcePath, position, Quaternion.identity, (byte)0, array) : Object.Instantiate(val, position, Quaternion.identity)); } catch (Exception arg) { Plugin.Log.LogError((object)$"The Anatomist failed to network-spawn '{resourcePath}': {arg}"); return null; } if ((Object)(object)val3 == (Object)null) { return null; } val3.transform.localScale = val2; SpawnedAnatomistPart spawnedAnatomistPart = new SpawnedAnatomistPart { ResourcePath = resourcePath, Root = val3, Phys = val3.GetComponentInChildren(true), ImpactDetector = val3.GetComponentInChildren(true), Attributes = val3.GetComponentInChildren(true), View = val3.GetComponentInChildren(true), Renderers = val3.GetComponentsInChildren(true), Colliders = val3.GetComponentsInChildren(true), Role = role }; if ((Object)(object)spawnedAnatomistPart.Phys == (Object)null || (Object)(object)spawnedAnatomistPart.ImpactDetector == (Object)null) { Plugin.Log.LogError((object)("The Anatomist resource '" + resourcePath + "' lacks vanilla physical components.")); Destroy(spawnedAnatomistPart); return null; } RefreshGeometry(spawnedAnatomistPart); return spawnedAnatomistPart; } internal static void RefreshGeometry(SpawnedAnatomistPart part, bool refreshLongAxis = true) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0182: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)part?.Phys == (Object)null || part.Renderers == null) { return; } bool flag = false; Bounds val = default(Bounds); Renderer[] renderers = part.Renderers; foreach (Renderer val2 in renderers) { if ((Object)(object)val2 == (Object)null || !val2.enabled || (!(val2 is MeshRenderer) && !(val2 is SkinnedMeshRenderer))) { continue; } Bounds bounds = val2.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!(((Vector3)(ref size)).sqrMagnitude < 1E-06f) && !(((Bounds)(ref bounds)).size.x > 10f) && !(((Bounds)(ref bounds)).size.y > 10f) && !(((Bounds)(ref bounds)).size.z > 10f)) { if (!flag) { val = bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(bounds); } } } if (flag) { part.VisualCenterOffset = Quaternion.Inverse(((Component)part.Phys).transform.rotation) * (((Bounds)(ref val)).center - ((Component)part.Phys).transform.position); part.VisualSize = ((Bounds)(ref val)).size; if (refreshLongAxis) { Vector3 val3 = ((Component)part.Phys).transform.InverseTransformDirection(Vector3.right); Vector3 val4 = ((Component)part.Phys).transform.InverseTransformDirection(Vector3.up); Vector3 val5 = ((Component)part.Phys).transform.InverseTransformDirection(Vector3.forward); part.LongAxisLocal = ((((Bounds)(ref val)).size.x >= ((Bounds)(ref val)).size.y && ((Bounds)(ref val)).size.x >= ((Bounds)(ref val)).size.z) ? val3 : ((((Bounds)(ref val)).size.y >= ((Bounds)(ref val)).size.z) ? val4 : val5)); } } } internal static void Destroy(SpawnedAnatomistPart part) { if (part == null) { return; } if ((Object)(object)part.Root == (Object)null) { part.Alive = false; return; } if (GameManager.Multiplayer()) { PhotonNetwork.Destroy(part.Root); } else { Object.Destroy((Object)(object)part.Root); } part.Alive = false; } } internal sealed class AuditorController : MonoBehaviour, IModEnemyTumbleReceiver { private sealed class UpgradeDefinition { internal readonly string CommandName; internal readonly string ResourcePath; internal readonly Func> Levels; internal UpgradeDefinition(string commandName, string resourcePath, Func> levels) { CommandName = commandName; ResourcePath = resourcePath; Levels = levels; } } private static readonly UpgradeDefinition[] UpgradeDefinitions = new UpgradeDefinition[13] { new UpgradeDefinition("CrouchRest", "Items/Item Upgrade Player Crouch Rest", (StatsManager stats) => stats.playerUpgradeCrouchRest), new UpgradeDefinition("DeathHeadBattery", "Items/Item Upgrade Death Head Battery", (StatsManager stats) => stats.playerUpgradeDeathHeadBattery), new UpgradeDefinition("ExtraJump", "Items/Item Upgrade Player Extra Jump", (StatsManager stats) => stats.playerUpgradeExtraJump), new UpgradeDefinition("Health", "Items/Item Upgrade Player Health", (StatsManager stats) => stats.playerUpgradeHealth), new UpgradeDefinition("Launch", "Items/Item Upgrade Player Tumble Launch", (StatsManager stats) => stats.playerUpgradeLaunch), new UpgradeDefinition("MapPlayerCount", "Items/Item Upgrade Map Player Count", (StatsManager stats) => stats.playerUpgradeMapPlayerCount), new UpgradeDefinition("Range", "Items/Item Upgrade Player Grab Range", (StatsManager stats) => stats.playerUpgradeRange), new UpgradeDefinition("Speed", "Items/Item Upgrade Player Sprint Speed", (StatsManager stats) => stats.playerUpgradeSpeed), new UpgradeDefinition("Stamina", "Items/Item Upgrade Player Energy", (StatsManager stats) => stats.playerUpgradeStamina), new UpgradeDefinition("Strength", "Items/Item Upgrade Player Grab Strength", (StatsManager stats) => stats.playerUpgradeStrength), new UpgradeDefinition("Throw", "Items/Item Upgrade Player Grab Throw", (StatsManager stats) => stats.playerUpgradeThrow), new UpgradeDefinition("TumbleClimb", "Items/Item Upgrade Player Tumble Climb", (StatsManager stats) => stats.playerUpgradeTumbleClimb), new UpgradeDefinition("TumbleWings", "Items/Item Upgrade Player Tumble Wings", (StatsManager stats) => stats.playerUpgradeTumbleWings) }; private readonly List _parts = new List(); private SpawnedAuditorPart _body; private SpawnedAuditorPart _stolenVisual; private NavMeshAgent _agent; private PlayerAvatar _target; private UpgradeDefinition _stolenUpgrade; private string _stolenFromSteamId; private int _health; private float _scanTimer; private float _destinationTimer; private float _soundTimer; private float _flinchTimer; private float _damageCooldown; private float _retaliationTimer; private float _rewardTimer; private float _lastClaimedHit = -999f; private Quaternion _bodyRotation = Quaternion.identity; private bool _dead; private bool _initialized; private bool _cleaning; private bool _rewardDropped; private bool _upgradeDropped; public bool CanReceiveTumbleAttack { get { if (_initialized) { return !_dead; } return false; } } internal bool Initialize(Vector3 position) { //IL_0006: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; _health = Mathf.Max(1, Plugin.Settings.AuditorHealth.Value); _agent = ((Component)this).gameObject.AddComponent(); ((Behaviour)_agent).enabled = false; _agent.speed = Mathf.Max(1f, Plugin.Settings.AuditorChargeSpeed.Value); _agent.acceleration = 44f; _agent.angularSpeed = 720f; _agent.radius = 0.28f; _agent.height = 1.1f; _agent.stoppingDistance = 0.28f; _body = SpawnPart("Items/Item Upgrade Player Grab Range", position + Vector3.up * 0.7f, new Vector3(1.08f, 1.18f, 1.02f), AuditorPartRole.Body); SpawnedAuditorPart spawnedAuditorPart = SpawnPart("Valuables/07 Very Tall/Valuable Wizard Broom", position + Vector3.up * 0.2f, new Vector3(0.1f, 0.11f, 0.1f), AuditorPartRole.LegLeft); SpawnedAuditorPart spawnedAuditorPart2 = SpawnPart("Valuables/07 Very Tall/Valuable Wizard Broom", position + Vector3.up * 0.2f, new Vector3(0.1f, 0.11f, 0.1f), AuditorPartRole.LegRight); if (_body == null || spawnedAuditorPart == null || spawnedAuditorPart2 == null) { Cleanup(); return false; } for (int i = 0; i < _parts.Count; i++) { SpawnedAuditorPart spawnedAuditorPart3 = _parts[i]; ((Component)spawnedAuditorPart3.Phys).gameObject.AddComponent().Initialize(this, spawnedAuditorPart3); ((Component)spawnedAuditorPart3.Phys).gameObject.AddComponent().Initialize(this, i); } IgnoreSelfCollisions(); _scanTimer = 0.1f; _soundTimer = Random.Range(0.55f, 0.9f); _bodyRotation = Quaternion.identity; _initialized = true; PinParts(immediate: true); Plugin.Log.LogInfo((object)$"The Auditor assembled a three-part networked upgrade-box runner with {_health} HP."); return true; } private SpawnedAuditorPart SpawnPart(string resource, Vector3 position, Vector3 scale, AuditorPartRole role) { //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) SpawnedAuditorPart spawnedAuditorPart = AuditorSpawner.SpawnEnemyPart(resource, position, scale, role); if (spawnedAuditorPart != null) { _parts.Add(spawnedAuditorPart); } return spawnedAuditorPart; } internal bool ActivateNavigation(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; return ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform, 6f); } private void Update() { //IL_0135: Unknown result type (might be due to invalid IL or missing references) if (!_initialized || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (_dead) { UpdateDeath(); return; } _scanTimer -= Time.deltaTime; _destinationTimer -= Time.deltaTime; _soundTimer -= Time.deltaTime; _flinchTimer = Mathf.Max(0f, _flinchTimer - Time.deltaTime); _damageCooldown = Mathf.Max(0f, _damageCooldown - Time.deltaTime); _retaliationTimer = Mathf.Max(0f, _retaliationTimer - Time.deltaTime); if (_stolenUpgrade != null) { UpdateFlee(); } else { UpdateHunt(); } PinParts(immediate: false); if (!(_soundTimer <= 0f)) { return; } _soundTimer = ((_stolenUpgrade != null) ? Random.Range(0.34f, 0.55f) : Random.Range(0.55f, 0.86f)); SpawnedAuditorPart body = _body; if (body != null) { PhysGrabObjectImpactDetector impactDetector = body.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactLight((_stolenUpgrade != null) ? 96f : 74f, _body.Phys.centerPoint); } } } private void UpdateHunt() { //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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) bool flag = _retaliationTimer > 0f && GunAccess.IsLiving(_target); if ((Object)(object)_target == (Object)null || !GunAccess.IsLiving(_target) || (!flag && !HasAnyUpgrade(_target))) { _target = null; _retaliationTimer = 0f; } if (_scanTimer <= 0f) { _scanTimer = 0.35f; if (!flag) { _target = FindTarget(); } } if (_flinchTimer > 0f || (Object)(object)_target == (Object)null) { if ((Object)(object)_target == (Object)null && _destinationTimer <= 0f) { _destinationTimer = 2f; Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(3f, 8f); ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, ((Component)this).transform.position + new Vector3(val.x, 0f, val.y), 4f); } if (_flinchTimer > 0f) { StopAgent(); } return; } _agent.speed = Mathf.Max(1f, Plugin.Settings.AuditorChargeSpeed.Value); if (_destinationTimer <= 0f) { _destinationTimer = 0.16f; ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, ((Component)_target).transform.position, 3.5f); } Vector3 val2 = ((Component)_target).transform.position - ((Component)this).transform.position; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude <= 2.4964f && HasLineOfSight(_target)) { if (_retaliationTimer > 0f && !HasAnyUpgrade(_target)) { ApplyContactAttack(_target); _retaliationTimer = 0f; _target = null; _destinationTimer = 0f; } else { TrySteal(_target); } } } private void UpdateFlee() { //IL_008d: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_013b: Unknown result type (might be due to invalid IL or missing references) if (_flinchTimer > 0f) { StopAgent(); return; } _agent.speed = Mathf.Max(Plugin.Settings.AuditorChargeSpeed.Value, Plugin.Settings.AuditorFleeSpeed.Value); if (!(_destinationTimer > 0f) || !_agent.hasPath || (!_agent.pathPending && !(_agent.remainingDistance > 1.2f))) { _destinationTimer = 0.58f; LevelPoint val = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 7f); if ((Object)(object)val != (Object)null) { ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, ((Component)val).transform.position, 5f); return; } PlayerAvatar val2 = FindClosestLivingPlayer(); Vector3 val3 = (((Object)(object)val2 != (Object)null) ? (((Component)this).transform.position - ((Component)val2).transform.position) : (-((Component)this).transform.forward)); val3.y = 0f; ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, ((Component)this).transform.position + ((Vector3)(ref val3)).normalized * 10f, 5f); } } private bool TrySteal(PlayerAvatar player) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) string text = SemiFunc.PlayerGetSteamID(player); List list = AvailableUpgrades(text); if (list.Count == 0) { _target = null; return false; } UpgradeDefinition upgradeDefinition = list[Random.Range(0, list.Count)]; if (!ApplyUpgradeDelta(text, upgradeDefinition.CommandName, -1)) { return false; } SpawnedAuditorPart spawnedAuditorPart = AuditorSpawner.SpawnCarriedUpgrade(upgradeDefinition.ResourcePath, ((Component)this).transform.position + Vector3.up * 0.9f); if (spawnedAuditorPart == null) { ApplyUpgradeDelta(text, upgradeDefinition.CommandName, 1); return false; } _stolenUpgrade = upgradeDefinition; _stolenFromSteamId = text; _stolenVisual = spawnedAuditorPart; _target = null; _destinationTimer = 0f; SpawnedAuditorPart body = _body; if (body != null) { PhysGrabObjectImpactDetector impactDetector = body.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactHeavy(100f, _body.Phys.centerPoint); } } ApplyContactAttack(player); ShowLocalStatsIfVictim(text); AnnounceTheft(player, upgradeDefinition.CommandName); Plugin.Log.LogInfo((object)("The Auditor stole one " + upgradeDefinition.CommandName + " upgrade from " + text + " and began fleeing with its matching vanilla box.")); return true; } private void ApplyContactAttack(PlayerAvatar player) { //IL_002a: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) if (GunAccess.IsLiving(player)) { player.playerHealth.HurtOther(Mathf.Max(1, Plugin.Settings.AuditorContactDamage.Value), ((Component)player).transform.position + Vector3.up * 0.55f, false, -1, false); Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = ((Component)this).transform.forward; } PlayerTumble val2 = FindPlayerTumble(player); if ((Object)(object)val2 != (Object)null) { val2.TumbleRequest(true, false); val2.TumbleForce(((Vector3)(ref val)).normalized * Mathf.Max(1f, Plugin.Settings.AuditorKnockbackForce.Value) + Vector3.up * 3.4f); } } } private static void ShowLocalStatsIfVictim(string steamId) { PlayerAvatar obj = SemiFunc.PlayerAvatarGetFromSteamID(steamId); PhotonView val = ((obj != null) ? ((Component)obj).GetComponent() : null); if (!((Object)(object)StatsUI.instance == (Object)null) && !((Object)(object)val == (Object)null) && val.IsMine) { StatsUI.instance.Fetch(); StatsUI.instance.ShowStats(); } } private static void AnnounceTheft(PlayerAvatar victim, string upgradeName) { if ((Object)(object)victim == (Object)null || string.IsNullOrEmpty(upgradeName)) { return; } string text = "My " + upgradeName + " Upgrade Was Stolen"; try { if (GameManager.Multiplayer()) { victim.photonView.RPC("ChatMessageSendRPC", (RpcTarget)0, new object[2] { text, false }); } else { victim.ChatMessageSend(text); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("The Auditor theft announcement failed: " + ex.Message)); } } private static PlayerTumble FindPlayerTumble(PlayerAvatar player) { if ((Object)(object)player == (Object)null) { return null; } PlayerTumble[] array = Object.FindObjectsOfType(); foreach (PlayerTumble val in array) { if ((Object)(object)val != (Object)null && (Object)(object)val.playerAvatar == (Object)(object)player) { return val; } } return null; } private static List AvailableUpgrades(string steamId) { List list = new List(); StatsManager instance = StatsManager.instance; if ((Object)(object)instance == (Object)null || string.IsNullOrEmpty(steamId)) { return list; } UpgradeDefinition[] upgradeDefinitions = UpgradeDefinitions; foreach (UpgradeDefinition upgradeDefinition in upgradeDefinitions) { Dictionary dictionary = upgradeDefinition.Levels(instance); if (dictionary != null && dictionary.TryGetValue(steamId, out var value) && value > 0 && (Object)(object)Resources.Load(upgradeDefinition.ResourcePath) != (Object)null) { list.Add(upgradeDefinition); } } return list; } private static bool HasAnyUpgrade(PlayerAvatar player) { if ((Object)(object)player != (Object)null) { return AvailableUpgrades(SemiFunc.PlayerGetSteamID(player)).Count > 0; } return false; } private static bool ApplyUpgradeDelta(string steamId, string commandName, int delta) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)PunManager.instance == (Object)null || string.IsNullOrEmpty(steamId)) { return false; } try { if (GameManager.Multiplayer()) { PhotonView component = ((Component)PunManager.instance).GetComponent(); if ((Object)(object)component == (Object)null) { return false; } component.RPC("TesterUpgradeCommandRPC", (RpcTarget)0, new object[3] { steamId, commandName, delta }); } else { PunManager.instance.TesterUpgradeCommandRPC(steamId, commandName, delta, default(PhotonMessageInfo)); } return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)$"The Auditor could not apply {commandName} {delta:+#;-#;0}: {ex.Message}"); return false; } } private PlayerAvatar FindTarget() { //IL_0056: 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) //IL_006b: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar result = null; float num = float.MaxValue; float num2 = Mathf.Clamp(Plugin.Settings.AuditorSearchRange.Value, 5f, 45f); foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item) && HasAnyUpgrade(item)) { Vector3 val = ((Component)item).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num && sqrMagnitude <= num2 * num2) { result = item; num = sqrMagnitude; } } } return result; } private PlayerAvatar FindClosestLivingPlayer() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_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) PlayerAvatar result = null; float num = float.MaxValue; Vector3 position = ((Component)this).transform.position; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { Vector3 val = ((Component)item).transform.position - position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { result = item; num = sqrMagnitude; } } } return result; } private bool HasLineOfSight(PlayerAvatar player) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_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_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_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_003f: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.position + Vector3.up * 0.72f; Vector3 val2 = ((Component)player).transform.position + Vector3.up * 0.75f - val; float magnitude = ((Vector3)(ref val2)).magnitude; RaycastHit[] array = Physics.RaycastAll(val, val2 / Mathf.Max(0.01f, magnitude), magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val3 = array[i]; if (!IsOwnCollider(((RaycastHit)(ref val3)).collider) && !((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() == (Object)(object)player)) { return false; } } return true; } private bool IsOwnCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } foreach (SpawnedAuditorPart part in _parts) { if ((Object)(object)part?.Root != (Object)null && ((Component)collider).transform.IsChildOf(part.Root.transform)) { return true; } } if ((Object)(object)_stolenVisual?.Root != (Object)null) { return ((Component)collider).transform.IsChildOf(_stolenVisual.Root.transform); } return false; } private void PinParts(bool immediate) { //IL_0028: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_00da: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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_01cf: 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_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) ? _agent.velocity : Vector3.zero); val.y = 0f; Quaternion val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.05f) ? Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up) : ((Component)this).transform.rotation); _bodyRotation = (immediate ? val2 : Quaternion.RotateTowards(_bodyRotation, val2, 520f * Time.deltaTime)); float num = ((_stolenUpgrade != null) ? 12f : 9f); float num2 = ((((Vector3)(ref val)).sqrMagnitude > 0.12f) ? Mathf.Sin(Time.time * num) : 0f); PoseVisualCenter(_body, ((Component)this).transform.position + Vector3.up * 0.51f, _bodyRotation, immediate); Vector3 start = ((Component)this).transform.position + _bodyRotation * new Vector3(-0.065f, 0.33f, 0f); Vector3 start2 = ((Component)this).transform.position + _bodyRotation * new Vector3(0.065f, 0.33f, 0f); Vector3 end = ((Component)this).transform.position + _bodyRotation * new Vector3(-0.075f, 0.07f, num2 * 0.15f); Vector3 end2 = ((Component)this).transform.position + _bodyRotation * new Vector3(0.075f, 0.07f, (0f - num2) * 0.15f); PoseSegment(FindRole(AuditorPartRole.LegLeft), start, end, immediate); PoseSegment(FindRole(AuditorPartRole.LegRight), start2, end2, immediate); if (_stolenVisual != null && _stolenVisual.Alive) { AuditorSpawner.EnforceCarriedUpgradeDisabled(_stolenVisual); float num3 = Mathf.Abs(num2) * 0.055f; PoseVisualCenter(_stolenVisual, ((Component)this).transform.position + _bodyRotation * new Vector3(0f, 0.73f + num3, -0.19f), _bodyRotation * Quaternion.Euler(-12f, 0f, 0f), immediate); } } private SpawnedAuditorPart FindRole(AuditorPartRole role) { foreach (SpawnedAuditorPart part in _parts) { if (part != null && part.Role == role) { return part; } } return null; } private static void PoseSegment(SpawnedAuditorPart part, Vector3 start, Vector3 end, bool immediate) { //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) //IL_0002: 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_001d: 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_0029: 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_002e: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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) Vector3 val = end - start; Quaternion rotation = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? Quaternion.FromToRotation(Vector3.up, ((Vector3)(ref val)).normalized) : Quaternion.identity); PoseVisualCenter(part, (start + end) * 0.5f, rotation, immediate); } private static void PoseVisualCenter(SpawnedAuditorPart part, Vector3 visualCenter, Quaternion rotation, bool immediate) { //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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00f0: 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_00f8: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)part?.Phys == (Object)null) && part.Alive) { if (part.GeometryFrames > 0) { AuditorSpawner.RefreshGeometry(part); part.GeometryFrames--; } part.ImpactDetector.destroyDisable = true; part.Phys.OverrideGrabDisable(0.3f); part.Phys.OverrideKinematic(0.3f); part.Phys.OverrideIndestructible(0.3f); Vector3 val = visualCenter - rotation * part.VisualCenterOffset; Vector3 val2 = (immediate ? val : Vector3.Lerp(((Component)part.Phys).transform.position, val, 1f - Mathf.Exp((0f - Time.deltaTime) * 18f))); Quaternion val3 = (immediate ? rotation : Quaternion.Slerp(((Component)part.Phys).transform.rotation, rotation, 1f - Mathf.Exp((0f - Time.deltaTime) * 16f))); part.Phys.SetPositionLogic(val2, val3); } } private void IgnoreSelfCollisions() { List list = new List(); foreach (SpawnedAuditorPart part in _parts) { if (part?.Colliders != null) { list.AddRange(part.Colliders); } } for (int i = 0; i < list.Count; i++) { for (int j = i + 1; j < list.Count; j++) { if ((Object)(object)list[i] != (Object)null && (Object)(object)list[j] != (Object)null) { Physics.IgnoreCollision(list[i], list[j], true); } } } } private void StopAgent() { if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } } internal bool TryClaimWeaponHit(int sourceId) { if (_dead || !ModEnemyWeaponDamage.TryClaim((Object)(object)this, sourceId) || Time.time - _lastClaimedHit < 0.06f) { return false; } _lastClaimedHit = Time.time; return true; } internal void ReceiveWeaponHit(Vector3 point, int damage) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if (_dead || damage <= 0) { return; } _health -= Mathf.Max(1, damage); if (_stolenUpgrade == null) { PlayerAvatar val = FindClosestLivingPlayer(); if ((Object)(object)val != (Object)null) { Vector3 val2 = ((Component)val).transform.position - point; if (((Vector3)(ref val2)).sqrMagnitude <= 324f) { _target = val; _retaliationTimer = 6f; _destinationTimer = 0f; _scanTimer = 0.35f; } } } if (_damageCooldown <= 0f) { _damageCooldown = 0.08f; ModEnemyFeedback.DamageHit(_body?.ImpactDetector, _body?.Phys, point, 92f); } if (_health <= 0) { Die(); } } public void ReceiveTumbleAttack(int partIndex, int damage, Vector3 hitPosition, Vector3 direction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ReceiveWeaponHit(hitPosition, Mathf.Max(1, damage)); if (!_dead) { _flinchTimer = 0.34f; StopAgent(); } } internal void ExecuteForLab() { if (!_dead) { _health = 0; Die(); } } private void Die() { if (_dead) { return; } _dead = true; StopAgent(); DropStolenUpgrade(); foreach (SpawnedAuditorPart part in _parts) { if (part != null && part.Alive) { part.Alive = false; part.ImpactDetector.destroyDisable = false; part.ImpactDetector.DestroyObject(true); } } _rewardTimer = 0.08f; } private void DropStolenUpgrade() { //IL_0043: 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_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_005d: Unknown result type (might be due to invalid IL or missing references) if (!_upgradeDropped && _stolenUpgrade != null) { _upgradeDropped = true; if (_stolenVisual != null) { AuditorSpawner.Destroy(_stolenVisual); _stolenVisual = null; } if ((Object)(object)AuditorSpawner.SpawnRealUpgrade(_stolenUpgrade.ResourcePath, ((Component)this).transform.position + Vector3.up * 0.55f, _bodyRotation) == (Object)null) { ApplyUpgradeDelta(_stolenFromSteamId, _stolenUpgrade.CommandName, 1); } } } private void UpdateDeath() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (_rewardDropped) { return; } _rewardTimer -= Time.deltaTime; if (_rewardTimer > 0f) { return; } _rewardDropped = true; if (Plugin.Settings.AuditorDropEnemyValuable.Value && !((Object)(object)AssetManager.instance?.enemyValuableSmall == (Object)null)) { GameObject enemyValuableSmall = AssetManager.instance.enemyValuableSmall; if (GameManager.Multiplayer()) { PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)enemyValuableSmall).name, ((Component)this).transform.position + Vector3.up * 0.42f, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate(enemyValuableSmall, ((Component)this).transform.position + Vector3.up * 0.42f, Quaternion.identity); } } } private void OnDestroy() { if (_initialized && !_cleaning && SemiFunc.IsMasterClientOrSingleplayer()) { _cleaning = true; if (!_dead && _stolenUpgrade != null) { ApplyUpgradeDelta(_stolenFromSteamId, _stolenUpgrade.CommandName, 1); } if (_stolenVisual != null && _stolenVisual.Alive) { AuditorSpawner.Destroy(_stolenVisual); } Cleanup(); } } private void Cleanup() { foreach (SpawnedAuditorPart part in _parts) { if (part != null && part.Alive) { AuditorSpawner.Destroy(part); } } _parts.Clear(); } } internal sealed class AuditorHitProxy : MonoBehaviour { private AuditorController _controller; private SpawnedAuditorPart _part; private float _cooldown; private readonly Dictionary _previous = new Dictionary(); private readonly HashSet _current = new HashSet(); private static int _bulletFrame = -1; private static ItemGunBullet[] _bullets = Array.Empty(); internal void Initialize(AuditorController controller, SpawnedAuditorPart part) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown _controller = controller; _part = part; SpawnedAuditorPart part2 = _part; if (part2 == null) { return; } PhysGrabObjectImpactDetector impactDetector = part2.ImpactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.AddListener(new UnityAction(OnHurtColliderHit)); } } } private void Update() { _cooldown = Mathf.Max(0f, _cooldown - Time.deltaTime); if (_cooldown <= 0f && SemiFunc.IsMasterClientOrSingleplayer()) { DetectExpandedBulletHit(); } } private void OnDestroy() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown SpawnedAuditorPart part = _part; if (part == null) { return; } PhysGrabObjectImpactDetector impactDetector = part.ImpactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.RemoveListener(new UnityAction(OnHurtColliderHit)); } } } private void OnHurtColliderHit() { //IL_0072: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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)_controller == (Object)null || _cooldown > 0f || !SemiFunc.IsMasterClientOrSingleplayer() || !_controller.TryClaimWeaponHit(ModEnemyWeaponDamage.CurrentClaimId)) { return; } _cooldown = 0.16f; Vector3 val = (((Object)(object)_part?.Phys != (Object)null) ? _part.Phys.centerPoint : ((Component)this).transform.position); if (EnemyLabBridge.IsExecutionHitNear(val)) { _controller.ExecuteForLab(); return; } int num = ModEnemyWeaponDamage.CurrentOrFallback(Plugin.Settings.AuditorDamagePerHit.Value); if (num > 0) { _controller.ReceiveWeaponHit(val, num); } } private void DetectExpandedBulletHit() { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0156: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_controller == (Object)null || _part?.Renderers == null) { return; } if (_bulletFrame != Time.frameCount) { _bulletFrame = Time.frameCount; _bullets = Object.FindObjectsOfType(); } _current.Clear(); ItemGunBullet[] bullets = _bullets; foreach (ItemGunBullet val in bullets) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent() != (Object)null || (Object)(object)val.hurtCollider == (Object)null || !((Component)val.hurtCollider).gameObject.activeInHierarchy) { continue; } int instanceID = ((Object)val).GetInstanceID(); _current.Add(instanceID); Vector3 position = ((Component)val.hurtCollider).transform.position; Vector3 value; bool num = _previous.TryGetValue(instanceID, out value); _previous[instanceID] = position; if (!(num ? SegmentIntersects(value, position) : Within(position)) || !_controller.TryClaimWeaponHit(instanceID)) { continue; } _cooldown = 0.22f; if (EnemyLabBridge.IsExecutionHitNear(position)) { _controller.ExecuteForLab(); return; } int num2 = ModEnemyWeaponDamage.Resolve(val.hurtCollider, Plugin.Settings.AuditorDamagePerHit.Value); if (num2 > 0) { _controller.ReceiveWeaponHit(position, num2); } return; } if (_previous.Count <= _current.Count) { return; } List list = null; foreach (int key in _previous.Keys) { if (!_current.Contains(key)) { if (list == null) { list = new List(); } list.Add(key); } } foreach (int item in list ?? new List()) { _previous.Remove(item); } } private bool Within(Vector3 point) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Settings.AuditorHitDetectionPadding.Value, 0.12f, 0.8f); float num2 = num * num; Renderer[] renderers = _part.Renderers; foreach (Renderer val in renderers) { if ((Object)(object)val != (Object)null && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; if (((Bounds)(ref bounds)).SqrDistance(point) <= num2) { return true; } } } return false; } private bool SegmentIntersects(Vector3 start, Vector3 end) { //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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Settings.AuditorHitDetectionPadding.Value, 0.12f, 0.8f); Renderer[] renderers = _part.Renderers; foreach (Renderer val in renderers) { if (!((Object)(object)val == (Object)null) && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; ((Bounds)(ref bounds)).Expand(num * 2f); if (SegmentBounds(start, end, bounds)) { return true; } } } return false; } private static bool SegmentBounds(Vector3 start, Vector3 end, Bounds bounds) { //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) //IL_0002: 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_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float num = 0f; float num2 = 1f; for (int i = 0; i < 3; i++) { float num3 = ((Vector3)(ref start))[i]; float num4 = ((Vector3)(ref val))[i]; Vector3 val2; if (Mathf.Abs(num4) < 1E-05f) { val2 = ((Bounds)(ref bounds)).min; if (!(num3 < ((Vector3)(ref val2))[i])) { val2 = ((Bounds)(ref bounds)).max; if (!(num3 > ((Vector3)(ref val2))[i])) { continue; } } return false; } float num5 = 1f / num4; val2 = ((Bounds)(ref bounds)).min; float num6 = (((Vector3)(ref val2))[i] - num3) * num5; val2 = ((Bounds)(ref bounds)).max; float num7 = (((Vector3)(ref val2))[i] - num3) * num5; if (num6 > num7) { float num8 = num7; num7 = num6; num6 = num8; } num = Mathf.Max(num, num6); num2 = Mathf.Min(num2, num7); if (num > num2) { return false; } } return true; } } internal sealed class AuditorManager : MonoBehaviour { private int _levelId; private float _spawnTimer; private bool _attemptFinished; private bool _probed; private bool _available; private AuditorController _encounter; internal void Tick() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (!IsHostReady()) { return; } Probe(); int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } if (!ModEnemyLevelRules.IsPlayableLevel()) { DestroyCurrent(); return; } LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null || !instance.Generated || _attemptFinished) { return; } _spawnTimer -= Time.deltaTime; if (!(_spawnTimer > 0f)) { _attemptFinished = true; if (Random.value <= Mathf.Clamp01(Plugin.Settings.AuditorSpawnChance.Value) && TryFindSpawn(out var position)) { Create(position, "automatic"); } } } private void ResetForLevel(int levelId) { DestroyCurrent(); _levelId = levelId; _spawnTimer = Mathf.Max(0f, Plugin.Settings.AuditorSpawnDelay.Value); _attemptFinished = false; } private bool Create(Vector3 position, string source) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0085: Unknown result type (might be due to invalid IL or missing references) if (!_available && !AuditorSpawner.PrefabsAvailable()) { Plugin.Log.LogWarning((object)"The Auditor could not resolve its upgrade-box body or broom legs."); return false; } DestroyCurrent(); GameObject val = new GameObject("The Auditor Encounter (Host Logic)"); val.SetActive(false); val.transform.position = position; AuditorController auditorController = val.AddComponent(); if (!auditorController.Initialize(position)) { Object.Destroy((Object)(object)val); return false; } val.SetActive(true); if (!auditorController.ActivateNavigation(position)) { Object.Destroy((Object)(object)val); return false; } _encounter = auditorController; Plugin.Log.LogInfo((object)$"The Auditor spawned at {position} ({source}); every visible piece and stolen upgrade box is a vanilla network object."); return true; } internal bool DebugSpawnAt(Vector3 requestedPosition) { //IL_0039: 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) if (!IsHostReady() || (!ModEnemySpawnCoordinator.IsDirectorRequestActive && (Object)(object)PlayerAvatar.instance == (Object)null) || !ModEnemyLevelRules.IsPlayableLevel()) { Plugin.Log.LogWarning((object)"Enemy Lab rejected The Auditor because no playable host level is active."); return false; } Probe(); NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requestedPosition, ref val, 12f, -1)) { return false; } _attemptFinished = true; return Create(((NavMeshHit)(ref val)).position, ModEnemySpawnCoordinator.CurrentSpawnSource); } internal void MarkAutomaticAttemptFinished() { int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } _attemptFinished = true; } internal void DebugDespawn() { if (IsHostReady()) { _attemptFinished = true; DestroyCurrent(); } } private void DestroyCurrent() { if ((Object)(object)_encounter != (Object)null) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); _encounter = null; } } private void Probe() { if (!_probed && !((Object)(object)RunManager.instance == (Object)null)) { _probed = true; _available = AuditorSpawner.PrefabsAvailable(); Plugin.Log.LogInfo((object)$"The Auditor prefab probe: available={_available}."); } } private static bool TryFindSpawn(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; PlayerAvatar val = null; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { val = item; break; } } Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(val2, 14f, 52f, false) ?? SemiFunc.LevelPointGetFurthestFromPlayer(val2, 7f); return ModEnemyNavigation.TryFindClearSpawn(((Object)(object)val3 != (Object)null) ? ((Component)val3).transform.position : (val2 + Vector3.forward * 14f), 7f, out position); } private static bool IsHostReady() { try { return (Object)(object)GameManager.instance != (Object)null && (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient); } catch { return false; } } } internal enum AuditorPartRole { Body, LegLeft, LegRight, StolenUpgrade } internal sealed class SpawnedAuditorPart { internal string ResourcePath; internal GameObject Root; internal PhysGrabObject Phys; internal PhysGrabObjectImpactDetector ImpactDetector; internal ItemAttributes Attributes; internal PhotonView View; internal Renderer[] Renderers; internal Collider[] Colliders; internal AuditorPartRole Role; internal Vector3 VisualCenterOffset; internal Vector3 VisualSize; internal int GeometryFrames = 14; internal bool NetworkInteractionDisabled; internal bool Alive = true; } internal static class AuditorSpawner { internal const string BodyResourcePath = "Items/Item Upgrade Player Grab Range"; internal const string LegResourcePath = "Valuables/07 Very Tall/Valuable Wizard Broom"; internal static bool PrefabsAvailable() { if ((Object)(object)Resources.Load("Items/Item Upgrade Player Grab Range") != (Object)null) { return (Object)(object)Resources.Load("Valuables/07 Very Tall/Valuable Wizard Broom") != (Object)null; } return false; } internal static SpawnedAuditorPart SpawnEnemyPart(string resourcePath, Vector3 position, Vector3 scaleMultiplier, AuditorPartRole role) { //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) //IL_0007: Unknown result type (might be due to invalid IL or missing references) SpawnedAuditorPart spawnedAuditorPart = Spawn(resourcePath, position, Quaternion.identity, scaleMultiplier, role); if (spawnedAuditorPart == null) { return null; } EncounterValuableNeutralizer.Apply(spawnedAuditorPart.Root); DisableUpgradeBehaviour(spawnedAuditorPart.Root, role == AuditorPartRole.StolenUpgrade); ItemAttributes attributes = spawnedAuditorPart.Attributes; if (attributes != null) { attributes.DisableUI(true); } spawnedAuditorPart.ImpactDetector.destroyDisable = true; spawnedAuditorPart.ImpactDetector.playerHurtDisable = true; spawnedAuditorPart.Phys.OverrideIndestructible(1f); spawnedAuditorPart.Phys.OverrideGrabDisable(1f); spawnedAuditorPart.Phys.OverrideKinematic(1f); spawnedAuditorPart.Phys.clientNonKinematic = false; MapIconSuppressor.Attach(spawnedAuditorPart.Root); return spawnedAuditorPart; } internal static SpawnedAuditorPart SpawnCarriedUpgrade(string resourcePath, Vector3 position) { //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) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return SpawnEnemyPart(resourcePath, position, Vector3.one * 0.82f, AuditorPartRole.StolenUpgrade); } internal static GameObject SpawnRealUpgrade(string resourcePath, Vector3 position, Quaternion rotation) { //IL_003f: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) GameObject val = Resources.Load(resourcePath); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("The Auditor could not return missing upgrade resource '" + resourcePath + "'.")); return null; } try { return GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject(resourcePath, position, rotation, (byte)0, (object[])null) : Object.Instantiate(val, position, rotation); } catch (Exception arg) { Plugin.Log.LogError((object)$"The Auditor could not drop '{resourcePath}': {arg}"); return null; } } private static SpawnedAuditorPart Spawn(string resourcePath, Vector3 position, Quaternion rotation, Vector3 scaleMultiplier, AuditorPartRole role) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00a8: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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) GameObject val = Resources.Load(resourcePath); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("The Auditor could not load vanilla resource '" + resourcePath + "'.")); return null; } ((Vector3)(ref scaleMultiplier))..ctor(Mathf.Clamp(scaleMultiplier.x, 0.04f, 1.6f), Mathf.Clamp(scaleMultiplier.y, 0.04f, 1.6f), Mathf.Clamp(scaleMultiplier.z, 0.04f, 1.6f)); Vector3 val2 = Vector3.Scale(val.transform.localScale, scaleMultiplier); object[] array = new object[3] { val2.x, val2.y, val2.z }; GameObject val3; try { val3 = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject(resourcePath, position, rotation, (byte)0, array) : Object.Instantiate(val, position, rotation)); } catch (Exception arg) { Plugin.Log.LogError((object)$"The Auditor failed to network-spawn '{resourcePath}': {arg}"); return null; } if ((Object)(object)val3 == (Object)null) { return null; } val3.transform.localScale = val2; SpawnedAuditorPart spawnedAuditorPart = new SpawnedAuditorPart { ResourcePath = resourcePath, Root = val3, Phys = val3.GetComponentInChildren(true), ImpactDetector = val3.GetComponentInChildren(true), Attributes = val3.GetComponentInChildren(true), View = val3.GetComponentInChildren(true), Renderers = val3.GetComponentsInChildren(true), Colliders = val3.GetComponentsInChildren(true), Role = role }; if ((Object)(object)spawnedAuditorPart.Phys == (Object)null || (Object)(object)spawnedAuditorPart.ImpactDetector == (Object)null) { Destroy(spawnedAuditorPart); return null; } RefreshGeometry(spawnedAuditorPart); return spawnedAuditorPart; } internal static void RefreshGeometry(SpawnedAuditorPart part) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)part?.Phys == (Object)null || part.Renderers == null) { return; } bool flag = false; Bounds val = default(Bounds); Renderer[] renderers = part.Renderers; foreach (Renderer val2 in renderers) { if ((Object)(object)val2 == (Object)null || !val2.enabled || (!(val2 is MeshRenderer) && !(val2 is SkinnedMeshRenderer))) { continue; } Bounds bounds = val2.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!(((Vector3)(ref size)).sqrMagnitude < 1E-06f) && !(((Bounds)(ref bounds)).size.x > 8f) && !(((Bounds)(ref bounds)).size.y > 8f) && !(((Bounds)(ref bounds)).size.z > 8f)) { if (!flag) { val = bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(bounds); } } } if (flag) { part.VisualCenterOffset = Quaternion.Inverse(((Component)part.Phys).transform.rotation) * (((Bounds)(ref val)).center - ((Component)part.Phys).transform.position); part.VisualSize = ((Bounds)(ref val)).size; } } private static void DisableUpgradeBehaviour(GameObject root, bool preserveToggleForNetworkLock = false) { MonoBehaviour[] componentsInChildren = root.GetComponentsInChildren(true); foreach (MonoBehaviour val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { string name = ((object)val).GetType().Name; if ((!preserveToggleForNetworkLock && val is ItemToggle) || name.StartsWith("ItemUpgrade", StringComparison.Ordinal)) { ((Behaviour)val).enabled = false; } } } } internal static bool EnforceCarriedUpgradeDisabled(SpawnedAuditorPart part) { if ((Object)(object)part?.Root == (Object)null || !part.Alive) { return false; } if (part.NetworkInteractionDisabled) { return true; } ItemToggle componentInChildren = part.Root.GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { part.NetworkInteractionDisabled = true; return true; } PhotonView componentInChildren2 = part.Root.GetComponentInChildren(true); if (GameManager.Multiplayer() && ((Object)(object)componentInChildren2 == (Object)null || componentInChildren2.ViewID == 0)) { return false; } try { if (componentInChildren.toggleState) { componentInChildren.ToggleItem(false, -1); } componentInChildren.ToggleDisable(true); ((Behaviour)componentInChildren).enabled = false; part.NetworkInteractionDisabled = true; return true; } catch (Exception ex) { Plugin.Log.LogDebug((object)("The Auditor is waiting to network-lock its carried box: " + ex.GetBaseException().Message)); return false; } } internal static void Destroy(SpawnedAuditorPart part) { if (!((Object)(object)part?.Root == (Object)null) && part.Alive) { part.Alive = false; if (GameManager.Multiplayer()) { PhotonNetwork.Destroy(part.Root); } else { Object.Destroy((Object)(object)part.Root); } } } } internal sealed class BellhopController : MonoBehaviour, IBellhopDamageReceiver, IModEnemyTumbleReceiver { private enum BehaviourState { Waiting, Retreating, SeekingValuable, Returning, Windup, Volley, ProjectileActive, Dead } private sealed class CargoLoad { internal ValuableObject Valuable; internal PhysGrabObject Phys; internal PhysGrabObjectImpactDetector Impact; internal BellhopLowGravityCargo Flight; internal int InstanceId; internal bool InFlight; internal bool Resolved; internal float FlightDeadline; internal float ArmedAt; internal UnityAction ImpactListener; } private readonly List _parts = new List(); private readonly HashSet _claimedWeaponBullets = new HashSet(); private NavMeshAgent _agent; private PlayerAvatar _target; private SpawnedBellhopPart _body; private SpawnedBellhopPart _head; private readonly List _cargoLoads = new List(); private CargoLoad _selectedCargo; private BehaviourState _state; private int _health; private float _targetTimer; private float _destinationTimer; private float _stateTimer; private float _valuableScanTimer; private float _windupElapsed; private float _volleyTimer; private float _seesawImpulse; private float _movementSoundTimer; private float _lastClaimedWeaponHitTime = -999f; private float _rewardTimer; private float _tumbleFlinchTimer; private float _damagePulseTimer; private float _damageFeedbackCooldown; private float _stuckTimer; private Vector3 _stuckCheckPosition; private int _ignoredCargoId = -1; private float _ignoreCargoUntil; private bool _rewardDropped; private int _cargoCapacity; private int _nextVolleyIndex; private bool _initialized; private bool _cleaningUp; private bool _firstThrowLogged; private bool _firstCatchLogged; private bool _firstMissLogged; private bool _firstHitLogged; private const float RetreatSeconds = 1.45f; private const float WindupSeconds = 1.15f; private static readonly FieldInfo GrabDisableTimerField = AccessTools.Field(typeof(PhysGrabObject), "grabDisableTimer"); private static readonly FieldInfo CurrentCartField = AccessTools.Field(typeof(PhysGrabObjectImpactDetector), "currentCart"); private static readonly FieldInfo CurrentCartPrevField = AccessTools.Field(typeof(PhysGrabObjectImpactDetector), "currentCartPrev"); private static readonly FieldInfo TimerInCartField = AccessTools.Field(typeof(PhysGrabObjectImpactDetector), "timerInCart"); public bool CanReceiveTumbleAttack { get { if (_initialized) { return _state != BehaviourState.Dead; } return false; } } internal bool Initialize(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; _health = Mathf.Max(1, Plugin.Settings.BellhopHealth.Value); _state = BehaviourState.Waiting; _agent = ((Component)this).gameObject.AddComponent(); ((Behaviour)_agent).enabled = false; _agent.speed = Mathf.Max(1f, Plugin.Settings.BellhopMoveSpeed.Value); _agent.acceleration = 32f; _agent.angularSpeed = 620f; _agent.radius = 0.48f; _agent.height = 1.15f; _agent.stoppingDistance = 0.55f; _agent.autoBraking = true; _body = BellhopSpawner.Spawn(BellhopSpawner.CartResourcePath, position, Quaternion.identity, new Vector3(0.9f, 0.72f, 0.72f), BellhopPartRole.Body); if (_body == null) { return false; } _parts.Add(_body); _head = _body; IgnoreSelfCollisions(); for (int i = 0; i < _parts.Count; i++) { ((Component)_parts[i].Phys).gameObject.AddComponent().Initialize(this, i); } ((Component)this).gameObject.AddComponent().Initialize(this, _parts); _movementSoundTimer = Random.Range(0.45f, 0.75f); _stuckCheckPosition = position; _initialized = true; PinParts(force: true); Plugin.Log.LogInfo((object)$"The Bellhop assembled one networked vanilla Hauler body with {_health} HP."); return true; } internal bool ActivateNavigation(Vector3 requestedPosition) { //IL_000e: 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_0053: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if ((Object)(object)_agent == (Object)null || !NavMesh.SamplePosition(requestedPosition, ref val, 5f, -1)) { return false; } ((Component)this).transform.position = ((NavMeshHit)(ref val)).position; ((Behaviour)_agent).enabled = true; if (!_agent.isOnNavMesh && !_agent.Warp(((NavMeshHit)(ref val)).position)) { return false; } return _agent.isOnNavMesh; } private void Update() { if (!_initialized || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (_state == BehaviourState.Dead) { UpdateDeath(); return; } _damagePulseTimer = Mathf.Max(0f, _damagePulseTimer - Time.deltaTime); _damageFeedbackCooldown = Mathf.Max(0f, _damageFeedbackCooldown - Time.deltaTime); _seesawImpulse = Mathf.MoveTowards(_seesawImpulse, 0f, Time.deltaTime * 3.8f); if (_tumbleFlinchTimer > 0f) { _tumbleFlinchTimer = Mathf.Max(0f, _tumbleFlinchTimer - Time.deltaTime); StopAgent(); PinLoadedCargo(); PinParts(force: false); UpdateNearMusic(); return; } UpdateTarget(); switch (_state) { case BehaviourState.Waiting: UpdateWaiting(); break; case BehaviourState.Retreating: UpdateRetreating(); break; case BehaviourState.SeekingValuable: UpdateSeekingValuable(); break; case BehaviourState.Returning: UpdateReturning(); break; case BehaviourState.Windup: UpdateWindup(); break; case BehaviourState.Volley: UpdateVolley(); break; case BehaviourState.ProjectileActive: UpdateProjectile(); break; } RecoverIfStuck(); PinLoadedCargo(); PinParts(force: false); UpdateMovementSound(); UpdateNearMusic(); } private void UpdateTarget() { //IL_0045: 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) _targetTimer -= Time.deltaTime; if (!(_targetTimer > 0f) || !GunAccess.IsLiving(_target)) { _targetTimer = 0.25f; PlayerAvatar target = _target; _target = FindNearestLivingPlayer(((Component)this).transform.position, Mathf.Clamp(Plugin.Settings.BellhopVisionRange.Value, 8f, 50f)); if ((Object)(object)target == (Object)null && (Object)(object)_target != (Object)null && _state == BehaviourState.Waiting && HasClearPath(_target, TrayPoint())) { BeginRetreat(); } } } private void UpdateWaiting() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) StopAgent(); if (GunAccess.IsLiving(_target) && HasClearPath(_target, TrayPoint())) { BeginRetreat(); } } private void BeginRetreat() { ReleaseAllCargo(); _cargoCapacity = 3; _state = BehaviourState.Retreating; _stateTimer = 1.45f; _destinationTimer = 0f; SetRetreatDestination(); } private void UpdateRetreating() { if (!GunAccess.IsLiving(_target)) { _state = BehaviourState.Waiting; StopAgent(); return; } _stateTimer -= Time.deltaTime; _destinationTimer -= Time.deltaTime; if (_destinationTimer <= 0f || ((Object)(object)_agent != (Object)null && _agent.isOnNavMesh && !_agent.pathPending && _agent.remainingDistance < 0.8f)) { SetRetreatDestination(); } if (_stateTimer <= 0f) { _valuableScanTimer = 0f; _state = BehaviourState.SeekingValuable; } } private void SetRetreatDestination() { //IL_002c: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_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 (GunAccess.IsLiving(_target) && ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform)) { Vector3 val = ((Component)this).transform.position - ((Component)_target).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.05f) { val = Random.insideUnitSphere; val.y = 0f; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(Vector3.up, val) * Random.Range(-0.55f, 0.55f); Vector3 position = ((Component)this).transform.position; Vector3 val3 = val + val2; Vector3 requested = position + ((Vector3)(ref val3)).normalized * 9f; _agent.speed = Mathf.Clamp(Plugin.Settings.BellhopRetreatSpeed.Value, 2f, 11f); ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, requested, 6f); _destinationTimer = 0.65f; } } private void UpdateSeekingValuable() { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_01ad: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(_target)) { ReleaseAllCargo(); _state = BehaviourState.Waiting; StopAgent(); return; } RemoveUnavailableLoadedCargo(); if (!CargoIsAvailable(_selectedCargo)) { ReleaseSelectedCargo(); _valuableScanTimer -= Time.deltaTime; if (_valuableScanTimer <= 0f) { _valuableScanTimer = 0.45f; SelectCargo(); } } if (!CargoIsAvailable(_selectedCargo)) { SetRetreatDestination(); } else { if (!ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform)) { return; } Vector3 val = _selectedCargo.Phys.centerPoint - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude <= 1.8225001f) { _selectedCargo.Impact.destroyDisable = true; SecureLoadedCargo(_selectedCargo); _cargoLoads.Add(_selectedCargo); _selectedCargo = null; _valuableScanTimer = 0f; if (_cargoLoads.Count >= _cargoCapacity) { _state = BehaviourState.Returning; _destinationTimer = 0f; } } else { _agent.speed = Mathf.Clamp(Plugin.Settings.BellhopMoveSpeed.Value, 1.5f, 8f); _agent.isStopped = false; _destinationTimer -= Time.deltaTime; if (_destinationTimer <= 0f) { _destinationTimer = 0.2f; ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, _selectedCargo.Phys.centerPoint, 2.5f); } } } } private void SelectCargo() { //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) ValuableObject val = null; float num = Mathf.Pow(Mathf.Clamp(Plugin.Settings.BellhopValuableSearchRange.Value, 4f, 25f), 2f); ValuableObject[] array = Object.FindObjectsOfType(); foreach (ValuableObject valuable in array) { if ((Object)(object)valuable == (Object)null || MapIconSuppressor.OwnsValuable(valuable) || (Time.time < _ignoreCargoUntil && ((Object)valuable).GetInstanceID() == _ignoredCargoId) || _cargoLoads.Any((CargoLoad load) => load.InstanceId == ((Object)valuable).GetInstanceID())) { continue; } PhysGrabObject val2 = ((Component)valuable).GetComponent() ?? ((Component)valuable).GetComponentInParent(); PhysGrabObjectImpactDetector val3 = ((val2 != null) ? ((Component)val2).GetComponent() : null); if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || val2.dead || val3.inCart || val2.grabbed || val2.grabbedLocal || val2.playerGrabbing.Count > 0 || !((Component)val2).gameObject.activeInHierarchy) { continue; } Renderer componentInChildren = ((Component)valuable).GetComponentInChildren(); Vector3 val4; if ((Object)(object)componentInChildren != (Object)null) { Bounds bounds = componentInChildren.bounds; val4 = ((Bounds)(ref bounds)).size; if (((Vector3)(ref val4)).magnitude > 2.4f) { continue; } } val4 = val2.centerPoint - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val = valuable; } } if (!((Object)(object)val == (Object)null)) { PhysGrabObject val5 = ((Component)val).GetComponent() ?? ((Component)val).GetComponentInParent(); _selectedCargo = new CargoLoad { Valuable = val, Phys = val5, Impact = ((val5 != null) ? ((Component)val5).GetComponent() : null), InstanceId = ((Object)val).GetInstanceID() }; } } private static bool CargoIsAvailable(CargoLoad cargo) { if ((Object)(object)cargo?.Valuable != (Object)null && (Object)(object)cargo.Phys != (Object)null && (Object)(object)cargo.Impact != (Object)null && !cargo.Phys.dead && ((Component)cargo.Phys).gameObject.activeInHierarchy && !cargo.Phys.grabbed && !cargo.Phys.grabbedLocal) { return cargo.Phys.playerGrabbing.Count == 0; } return false; } private void UpdateReturning() { //IL_0048: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: 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_01de: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) RemoveUnavailableLoadedCargo(); if (_cargoLoads.Count < 2) { _state = BehaviourState.SeekingValuable; _valuableScanTimer = 0f; return; } if (!GunAccess.IsLiving(_target)) { ReleaseAllCargo(); _state = BehaviourState.Waiting; return; } float num = Vector3.Distance(((Component)this).transform.position, ((Component)_target).transform.position); if (num <= 6.5f && num >= 2.2f && HasClearPath(_target, TrayPoint())) { _state = BehaviourState.Windup; _stateTimer = 1.15f; _windupElapsed = 0f; StopAgent(); PhysGrabObjectImpactDetector impactDetector = _body.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactMedium(100f, _body.Phys.centerPoint); } PhysGrabObjectImpactDetector impactDetector2 = _head.ImpactDetector; if (impactDetector2 != null) { impactDetector2.ImpactLight(96f, _head.Phys.centerPoint); } } else if (ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform)) { _agent.speed = Mathf.Clamp(Plugin.Settings.BellhopMoveSpeed.Value, 1.5f, 8f); _agent.isStopped = false; _destinationTimer -= Time.deltaTime; if (_destinationTimer <= 0f) { _destinationTimer = 0.14f; Vector3 val = ((Component)this).transform.position - ((Component)_target).transform.position; val.y = 0f; Vector3 requested = ((Component)_target).transform.position + ((Vector3)(ref val)).normalized * 4.8f; ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, requested); } } } private void UpdateWindup() { StopAgent(); FaceTarget(240f); RemoveUnavailableLoadedCargo(); if (_cargoLoads.Count < 2 || !GunAccess.IsLiving(_target)) { BeginRetreat(); return; } _stateTimer -= Time.deltaTime; _windupElapsed += Time.deltaTime; if (_stateTimer <= 0f) { _state = BehaviourState.Volley; _nextVolleyIndex = 0; _volleyTimer = 0f; } } private void UpdateVolley() { StopAgent(); FaceTarget(240f); if (!GunAccess.IsLiving(_target)) { ReleaseAllCargo(); _state = BehaviourState.Waiting; return; } UpdateActiveCargo(); _volleyTimer -= Time.deltaTime; if (!(_volleyTimer > 0f)) { while (_nextVolleyIndex < _cargoLoads.Count && _cargoLoads[_nextVolleyIndex].Resolved) { _nextVolleyIndex++; } if (_nextVolleyIndex < _cargoLoads.Count) { LaunchCargo(_cargoLoads[_nextVolleyIndex]); _nextVolleyIndex++; _volleyTimer = 0.5f; _seesawImpulse = 1f; } else { _state = BehaviourState.ProjectileActive; _destinationTimer = 0f; SetRetreatDestination(); } } } private void PinLoadedCargo() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _cargoLoads.Count; i++) { CargoLoad cargoLoad = _cargoLoads[i]; if (!CargoIsAvailable(cargoLoad) || cargoLoad.InFlight || cargoLoad.Resolved) { continue; } float num = (float)(_cargoLoads.Count - 1) * 0.5f; Vector3 val = TrayPoint() + ((Component)this).transform.right * (((float)i - num) * 0.29f) + ((Component)this).transform.up * 0.13f; Quaternion rotation = ((Component)this).transform.rotation; Vector3 val2 = ((Component)cargoLoad.Phys).transform.position + (val - cargoLoad.Phys.centerPoint); ClearNativeCartState(cargoLoad); cargoLoad.Impact.destroyDisable = true; cargoLoad.Phys.OverrideIndestructible(0.35f); cargoLoad.Phys.OverrideKinematic(0.35f); cargoLoad.Phys.OverrideGrabDisable(0.35f); Rigidbody rb = cargoLoad.Phys.rb; if ((Object)(object)rb != (Object)null) { if (!rb.isKinematic) { rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; } rb.useGravity = false; rb.isKinematic = true; rb.position = val2; rb.rotation = rotation; } cargoLoad.Phys.SetPositionLogic(val2, rotation); } } private static void SecureLoadedCargo(CargoLoad cargo) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) ClearNativeCartState(cargo); Rigidbody val = cargo?.Phys?.rb; if (!((Object)(object)val == (Object)null)) { if (!val.isKinematic) { val.velocity = Vector3.zero; val.angularVelocity = Vector3.zero; } val.useGravity = false; val.isKinematic = true; cargo.Phys.OverrideKinematic(0.35f); cargo.Phys.OverrideGrabDisable(0.35f); } } private static void ClearNativeCartState(CargoLoad cargo) { if (!((Object)(object)cargo?.Impact == (Object)null)) { cargo.Impact.inCart = false; CurrentCartField?.SetValue(cargo.Impact, null); CurrentCartPrevField?.SetValue(cargo.Impact, null); TimerInCartField?.SetValue(cargo.Impact, 0f); } } private void LaunchCargo(CargoLoad cargo) { //IL_0074: 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_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0110: 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_011f: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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) if (!CargoIsAvailable(cargo)) { cargo.Resolved = true; return; } ClearGrabDisable(cargo.Phys); Rigidbody rb = cargo.Phys.rb; if ((Object)(object)rb != (Object)null) { rb.isKinematic = false; rb.useGravity = false; Vector3 centerPoint = cargo.Phys.centerPoint; Transform val = _target.PlayerVisionTarget?.VisionTransform; Vector3 val2 = (((Object)(object)val != (Object)null) ? val.position : (((Component)_target).transform.position + Vector3.up * 0.8f)); val2 += ((Component)this).transform.right * Random.Range(-0.12f, 0.12f); float num = Mathf.Clamp(Vector3.Distance(centerPoint, val2) / 6.25f, 0.86f, 1.55f); Vector3 val3 = Physics.gravity * 0.12f; Vector3 val4 = (val2 - centerPoint) / num - val3 * (0.5f * num); rb.velocity = Vector3.ClampMagnitude(val4, 9f); rb.angularVelocity = Random.onUnitSphere * 2.2f; rb.WakeUp(); } cargo.InFlight = true; cargo.FlightDeadline = Time.time + 7f; cargo.ArmedAt = Time.time + 0.22f; cargo.Flight = ((Component)cargo.Phys).gameObject.GetComponent() ?? ((Component)cargo.Phys).gameObject.AddComponent(); cargo.Flight.Activate(cargo.Phys, 0.2f, OnCargoEnvironmentHit); cargo.Phys.DeathPitEffectCreate(); if ((Object)(object)cargo.Impact != (Object)null) { cargo.ImpactListener = (UnityAction)delegate { OnCargoImpact(cargo); }; cargo.Impact.onAllImpacts.AddListener(cargo.ImpactListener); } PhysGrabObjectImpactDetector impactDetector = _head.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactLight(96f, _head.Phys.centerPoint); } if (!_firstThrowLogged) { _firstThrowLogged = true; Plugin.Log.LogInfo((object)$"The Bellhop launched its first {_cargoLoads.Count}-valuable low-gravity volley; only grabbed cargo is safe."); } } private void UpdateProjectile() { UpdateActiveCargo(); if (_cargoLoads.All((CargoLoad cargo) => cargo.Resolved)) { FinishProjectileCycle(); return; } _destinationTimer -= Time.deltaTime; if (_destinationTimer <= 0f) { SetRetreatDestination(); } } private void UpdateActiveCargo() { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) CargoLoad[] array = _cargoLoads.ToArray(); foreach (CargoLoad cargoLoad in array) { if (!cargoLoad.InFlight || cargoLoad.Resolved) { continue; } if ((Object)(object)cargoLoad.Phys == (Object)null || cargoLoad.Phys.dead || !((Component)cargoLoad.Phys).gameObject.activeInHierarchy) { cargoLoad.Resolved = true; cargoLoad.InFlight = false; continue; } if (cargoLoad.Phys.playerGrabbing.Count > 0) { PhysGrabber val = cargoLoad.Phys.playerGrabbing[0]; PlayerAvatar val2 = (((Object)(object)val != (Object)null) ? val.playerAvatar : null); if ((Object)(object)val2 != (Object)null) { CompleteCatch(cargoLoad, val2); continue; } } if (Time.time >= cargoLoad.FlightDeadline) { ExplodeCargo(cargoLoad, cargoLoad.Phys.centerPoint); } } } private void OnCargoEnvironmentHit(BellhopLowGravityCargo flight, Collider environment) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_008f: 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) CargoLoad cargoLoad = _cargoLoads.FirstOrDefault((CargoLoad load) => (Object)(object)load.Flight == (Object)(object)flight); if (cargoLoad != null && !cargoLoad.Resolved && cargoLoad.InFlight && (!((Object)(object)cargoLoad.Phys != (Object)null) || cargoLoad.Phys.playerGrabbing.Count <= 0)) { Vector3 val; if (!((Object)(object)cargoLoad.Phys != (Object)null)) { Bounds bounds = environment.bounds; val = ((Bounds)(ref bounds)).ClosestPoint(((Component)this).transform.position); } else { val = cargoLoad.Phys.centerPoint; } Vector3 position = val; ExplodeCargo(cargoLoad, position); } } private void OnCargoImpact(CargoLoad cargo) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) if (cargo == null || cargo.Resolved || !cargo.InFlight || Time.time < cargo.ArmedAt || (Object)(object)cargo.Phys == (Object)null || cargo.Phys.playerGrabbing.Count > 0) { return; } float num = 0.28f; Collider componentInChildren = ((Component)cargo.Phys).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { Bounds bounds = componentInChildren.bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; num = Mathf.Clamp(((Vector3)(ref extents)).magnitude * 0.75f, 0.18f, 0.65f); } Collider[] array = Physics.OverlapSphere(cargo.Phys.centerPoint, num, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); foreach (Collider val in array) { if (!((Object)(object)val == (Object)null) && !((Component)val).transform.IsChildOf(((Component)cargo.Phys).transform) && !((Object)(object)((Component)val).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)val).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)val).GetComponentInParent() != (Object)null)) { ExplodeCargo(cargo, cargo.Phys.centerPoint); break; } } } private void CompleteCatch(CargoLoad cargo, PlayerAvatar catcher) { cargo.InFlight = false; cargo.Resolved = true; cargo.Flight?.Deactivate(restoreGravity: true); DetachImpactListener(cargo); cargo.Impact.destroyDisable = false; ClearGrabDisable(cargo.Phys); string[] array = new string[3] { "nice", "great", "excellent" }; string text = array[Random.Range(0, array.Length)]; try { if (GameManager.Multiplayer()) { catcher.photonView.RPC("ChatMessageSendRPC", (RpcTarget)0, new object[2] { text, false }); } else { catcher.ChatMessageSend(text); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("The Bellhop catch phrase RPC failed: " + ex.Message)); } if (!_firstCatchLogged) { _firstCatchLogged = true; Plugin.Log.LogInfo((object)("The Bellhop's first airborne valuable was caught; " + SemiFunc.PlayerGetName(catcher) + " said '" + text + "'.")); } } private void ExplodeCargo(CargoLoad cargo, Vector3 position) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: 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_01e0: Unknown result type (might be due to invalid IL or missing references) if (cargo == null || !cargo.InFlight || cargo.Resolved) { return; } cargo.InFlight = false; cargo.Resolved = true; cargo.Flight?.Deactivate(restoreGravity: false); DetachImpactListener(cargo); int num = Mathf.Clamp(Plugin.Settings.BellhopExplosionDamage.Value, 55, 100); float num2 = Mathf.Clamp(Plugin.Settings.BellhopExplosionRadius.Value, 4.8f, 8f); bool num3 = QueueVanillaExplosion(position); PhysGrabObjectImpactDetector impact = cargo.Impact; if (impact != null) { impact.ImpactHeavy(1000f, position); } if (!num3) { foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (!GunAccess.IsLiving(item)) { continue; } float num4 = Vector3.Distance(position, ((Component)item).transform.position); if (num4 <= num2 && HasExplosionPath(position, item)) { int num5 = Mathf.Max(1, Mathf.RoundToInt((float)num * (1f - num4 / (num2 * 1.35f)))); PlayerHealth playerHealth = item.playerHealth; if (playerHealth != null) { playerHealth.HurtOther(num5, position, false, -1, false); } } } } PhysGrabObject[] array = Object.FindObjectsOfType(); foreach (PhysGrabObject phys in array) { if (!((Object)(object)phys == (Object)null) && !_cargoLoads.Any((CargoLoad load) => (Object)(object)load.Phys == (Object)(object)phys) && !((Object)(object)phys.rb == (Object)null) && !phys.dead && !(Vector3.Distance(position, phys.centerPoint) > num2)) { phys.rb.AddExplosionForce(420f, position, num2, 0.35f, (ForceMode)1); PhysGrabObjectImpactDetector component = ((Component)phys).GetComponent(); if (component != null) { component.BreakMedium(phys.centerPoint, false); } } } if ((Object)(object)cargo.Impact != (Object)null) { cargo.Impact.destroyDisable = false; cargo.Impact.DestroyObject(true); } if (!_firstMissLogged) { _firstMissLogged = true; Plugin.Log.LogInfo((object)$"The Bellhop's first uncaught valuable triggered a vanilla large explosion (fallback {num} damage/{num2:F1}m)."); } } private bool QueueVanillaExplosion(Vector3 position) { //IL_0023: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject("Items/Item Grenade Explosive", position, Quaternion.identity, (byte)0, (object[])null) : Object.Instantiate(Resources.Load("Items/Item Grenade Explosive"), position, Quaternion.identity)); if ((Object)(object)val == (Object)null) { return false; } EncounterValuableNeutralizer.Apply(val); MapIconSuppressor.Attach(val); ((MonoBehaviour)this).StartCoroutine(DetonateVanillaGrenade(val)); return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("The Bellhop could not create its vanilla explosion effect: " + ex.Message)); return false; } } private static IEnumerator DetonateVanillaGrenade(GameObject grenade) { yield return null; yield return null; if ((Object)(object)grenade == (Object)null) { yield break; } if (GameManager.Multiplayer()) { PhotonView component = grenade.GetComponent(); if (component != null) { component.RPC("TickEndRPC", (RpcTarget)0, Array.Empty()); } yield break; } ItemGrenadeExplosive component2 = grenade.GetComponent(); if (component2 != null) { component2.Explosion(); } PhysGrabObjectImpactDetector component3 = grenade.GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.destroyDisable = false; component3.DestroyObject(true); } } private static void DetachImpactListener(CargoLoad cargo) { if ((Object)(object)cargo?.Impact != (Object)null && cargo.ImpactListener != null) { cargo.Impact.onAllImpacts.RemoveListener(cargo.ImpactListener); cargo.ImpactListener = null; } } private bool HasExplosionPath(Vector3 origin, PlayerAvatar player) { //IL_0044: 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_002d: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) Transform val = player?.PlayerVisionTarget?.VisionTransform; Vector3 val2 = (((Object)(object)val != (Object)null) ? val.position : (((Component)player).transform.position + Vector3.up * 0.8f)) - origin; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude <= 0.1f) { return true; } RaycastHit[] array = Physics.RaycastAll(origin, val2 / magnitude, magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val3 = array2[num]; if (!((Object)(object)ResolveHitPlayer(((RaycastHit)(ref val3)).collider) == (Object)(object)player) && !IsOwnCollider(((RaycastHit)(ref val3)).collider) && !IsCargoCollider(((RaycastHit)(ref val3)).collider) && !((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() != (Object)null)) { return false; } } return true; } private void FinishProjectileCycle() { if (_state != BehaviourState.Dead) { _cargoLoads.Clear(); _selectedCargo = null; _state = BehaviourState.Retreating; _stateTimer = 1.45f; _cargoCapacity = 3; _destinationTimer = 0f; SetRetreatDestination(); } } private void ReleaseSelectedCargo() { if ((Object)(object)_selectedCargo?.Impact != (Object)null) { _selectedCargo.Impact.destroyDisable = false; } if ((Object)(object)_selectedCargo?.Phys?.rb != (Object)null && !_selectedCargo.Phys.dead) { _selectedCargo.Phys.rb.isKinematic = false; _selectedCargo.Phys.rb.useGravity = true; ClearGrabDisable(_selectedCargo.Phys); } _selectedCargo = null; } private void ReleaseAllCargo() { ReleaseSelectedCargo(); foreach (CargoLoad cargoLoad in _cargoLoads) { cargoLoad.Flight?.Deactivate(restoreGravity: true); DetachImpactListener(cargoLoad); if ((Object)(object)cargoLoad.Impact != (Object)null) { cargoLoad.Impact.destroyDisable = false; } if ((Object)(object)cargoLoad.Phys?.rb != (Object)null && !cargoLoad.Phys.dead) { cargoLoad.Phys.rb.isKinematic = false; cargoLoad.Phys.rb.useGravity = true; ClearGrabDisable(cargoLoad.Phys); } } _cargoLoads.Clear(); } private void RemoveUnavailableLoadedCargo() { for (int num = _cargoLoads.Count - 1; num >= 0; num--) { CargoLoad cargoLoad = _cargoLoads[num]; if (!cargoLoad.InFlight && !cargoLoad.Resolved && !CargoIsAvailable(cargoLoad)) { if ((Object)(object)cargoLoad.Impact != (Object)null) { cargoLoad.Impact.destroyDisable = false; } _cargoLoads.RemoveAt(num); } } } private static void ClearGrabDisable(PhysGrabObject phys) { if ((Object)(object)phys != (Object)null) { GrabDisableTimerField?.SetValue(phys, 0f); } } private Vector3 TrayPoint() { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00ef: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_004e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_body?.Phys == (Object)null) { return ((Component)this).transform.position + Vector3.up * 0.58f + ((Component)this).transform.forward * 0.18f; } float num = Mathf.Clamp(_body.VisualSize.y, 0.28f, 0.9f); float num2 = Mathf.Clamp(_body.VisualSize.z, 0.55f, 1.5f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, 0.04f + num * 0.78f, num2 * 0.08f); Vector3 val2 = CartPivotLocal(); val = val2 + Quaternion.AngleAxis(CurrentCartTilt(), Vector3.right) * (val - val2); return ((Component)this).transform.position + ((Component)this).transform.rotation * val; } private void RecoverIfStuck() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Invalid comparison between Unknown and I4 //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) if (_state != BehaviourState.Retreating && _state != BehaviourState.SeekingValuable && _state != BehaviourState.Returning && _state != BehaviourState.ProjectileActive) { _stuckTimer = 0f; _stuckCheckPosition = ((Component)this).transform.position; return; } if (!ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform)) { return; } Vector3 val = ((Component)this).transform.position - _stuckCheckPosition; val.y = 0f; bool flag = _agent.hasPath && !_agent.pathPending && (int)_agent.pathStatus > 0; int num; if (!_agent.pathPending) { Vector3 velocity = _agent.velocity; if (((Vector3)(ref velocity)).sqrMagnitude < 0.04f) { num = ((((Vector3)(ref val)).sqrMagnitude < 0.0036f) ? 1 : 0); goto IL_00e6; } } num = 0; goto IL_00e6; IL_00e6: bool flag2 = (byte)num != 0; _stuckTimer = ((flag || flag2) ? (_stuckTimer + Time.deltaTime) : 0f); _stuckCheckPosition = ((Component)this).transform.position; if (!(_stuckTimer < 0.8f)) { _stuckTimer = 0f; _agent.ResetPath(); _destinationTimer = 0f; if (_state == BehaviourState.SeekingValuable && _selectedCargo != null) { _ignoredCargoId = _selectedCargo.InstanceId; _ignoreCargoUntil = Time.time + 5f; ReleaseSelectedCargo(); _valuableScanTimer = 0.6f; _state = BehaviourState.Retreating; _stateTimer = 1.2f; } SetRetreatDestination(); Plugin.Log.LogDebug((object)"The Bellhop discarded a partial/stalled path and selected a new route."); } } private bool HasClearPath(PlayerAvatar player, Vector3 origin) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return false; } Transform val = player.PlayerVisionTarget?.VisionTransform; Vector3 val2 = (((Object)(object)val != (Object)null) ? val.position : (((Component)player).transform.position + Vector3.up)) - origin; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude <= 0.1f) { return true; } RaycastHit[] array = Physics.RaycastAll(origin, val2 / magnitude, magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val3 = array2[num]; if (!IsOwnCollider(((RaycastHit)(ref val3)).collider) && !((Object)(object)ResolveHitPlayer(((RaycastHit)(ref val3)).collider) == (Object)(object)player) && !((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() != (Object)null)) { return false; } } return true; } private void PinParts(bool force) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: 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_01a7: 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_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) int num; float num2; if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled) { Vector3 velocity = _agent.velocity; num = ((((Vector3)(ref velocity)).sqrMagnitude > 0.2f) ? 1 : 0); if (num != 0) { num2 = Mathf.Sin(Time.time * 12f) * 0.018f; goto IL_0059; } } else { num = 0; } num2 = 0f; goto IL_0059; IL_0059: float num3 = num2; float num4 = CurrentCartTilt(); Vector3 val = CartPivotLocal(); Quaternion val2 = Quaternion.AngleAxis(num4, Vector3.right); Quaternion val3 = Quaternion.AngleAxis((num != 0) ? (Mathf.Sin(Time.time * 6.2f) * 2.2f) : 0f, Vector3.forward); foreach (SpawnedBellhopPart part in _parts) { if (!part.Alive || (Object)(object)part.Phys == (Object)null) { continue; } part.ImpactDetector.destroyDisable = true; part.Phys.OverrideIndestructible(0.35f); part.Phys.OverrideKinematic(0.35f); part.Phys.OverrideGrabDisable(0.35f); if (part.GeometryCalibrationFrames > 0) { BellhopSpawner.RefreshGeometry(part); part.GeometryCalibrationFrames--; if (part.GeometryCalibrationFrames == 0) { Plugin.Log.LogInfo((object)$"Bellhop geometry {part.Role}: rendered={part.VisualSize}, centerOffset={part.VisualCenterOffset}."); } } UpdatePartLayout(part); Vector3 val4 = val + val2 * (part.LocalOffset - val); val4.y += num3; Quaternion val5 = val3 * val2 * part.LocalRotation; if (part.Role == BellhopPartRole.Head && _damagePulseTimer > 0f) { float num5 = Mathf.Sin(Mathf.Clamp01(_damagePulseTimer / 0.24f) * MathF.PI); val5 = Quaternion.AngleAxis(Mathf.Sin(Time.time * 42f) * 13f * num5, Vector3.forward) * val5; } Vector3 val6 = ((Component)this).transform.position + ((Component)this).transform.rotation * val4; Quaternion val7 = ((Component)this).transform.rotation * val5; Vector3 val8 = val6 - val7 * part.VisualCenterOffset; if (force || Vector3.Distance(((Component)part.Phys).transform.position, val8) > 0.009f || Quaternion.Angle(((Component)part.Phys).transform.rotation, val7) > 0.45f) { part.Phys.SetPositionLogic(val8, val7); } } } private float CurrentCartTilt() { float num = ((_state == BehaviourState.Windup) ? Mathf.Clamp01(_windupElapsed / 1.15f) : 0f); return Mathf.SmoothStep(0f, 1f, num) * -18f + _seesawImpulse * 31f - ((_tumbleFlinchTimer > 0f) ? 12f : 0f) - ((_damagePulseTimer > 0f) ? (Mathf.Sin(Mathf.Clamp01(_damagePulseTimer / 0.24f) * MathF.PI) * 9f) : 0f); } private Vector3 CartPivotLocal() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) float num = ((_body != null) ? Mathf.Clamp(_body.VisualSize.z, 0.6f, 1.8f) : 1f); return new Vector3(0f, 0.05f, (0f - num) * 0.34f); } private void UpdatePartLayout(SpawnedBellhopPart part) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00ed: 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) float num = Mathf.Clamp(_body.VisualSize.y, 0.25f, 0.95f); float num2 = Mathf.Clamp(_body.VisualSize.z, 0.6f, 1.8f); Mathf.Clamp(_body.VisualSize.x, 0.6f, 1.7f); _body.LocalOffset = new Vector3(0f, 0.04f + num * 0.5f, 0f); _body.LocalRotation = Quaternion.identity; if (part.Role == BellhopPartRole.Head) { float num3 = Mathf.Clamp(part.VisualSize.y, 0.16f, 0.42f); part.LocalOffset = new Vector3(0f, 0.04f + num - num3 * 0.05f, (0f - num2) * 0.14f); part.LocalRotation = Quaternion.AngleAxis(90f, Vector3.right); } } private void UpdateMovementSound() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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) if ((Object)(object)_agent == (Object)null || !((Behaviour)_agent).enabled) { return; } Vector3 velocity = _agent.velocity; if (((Vector3)(ref velocity)).sqrMagnitude < 0.35f || (Object)(object)_body?.ImpactDetector == (Object)null || (Object)(object)_body.Phys == (Object)null) { return; } _movementSoundTimer -= Time.deltaTime; if (_movementSoundTimer > 0f) { return; } _movementSoundTimer = Random.Range(0.3f, 0.475f); _body.ImpactDetector.ImpactLight(100f, _body.Phys.centerPoint); SpawnedBellhopPart head = _head; if (head != null) { PhysGrabObjectImpactDetector impactDetector = head.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactLight(92f, _head.Phys.centerPoint); } } } private void FaceTarget(float degreesPerSecond) { //IL_0019: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (GunAccess.IsLiving(_target)) { Vector3 val = ((Component)_target).transform.position - ((Component)this).transform.position; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f)) { Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val2, Mathf.Max(30f, degreesPerSecond) * Time.deltaTime); } } } private void UpdateNearMusic() { //IL_0043: 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_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) if (!((Object)(object)MusicEnemyNear.instance == (Object)null) && GunAccess.IsLiving(PlayerAvatar.instance)) { float num = Mathf.Clamp(Plugin.Settings.BellhopNearMusicRange.Value, 3f, 35f); Vector3 val = ((Component)PlayerAvatar.instance).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude <= num * num) { MusicEnemyNear.instance.OverrideActive(0.35f); } } } private void StopAgent() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_agent == (Object)null) && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.velocity = Vector3.zero; } } private void IgnoreSelfCollisions() { for (int i = 0; i < _parts.Count; i++) { Collider[] colliders = _parts[i].Colliders; for (int j = i + 1; j < _parts.Count; j++) { Collider[] colliders2 = _parts[j].Colliders; Collider[] array = colliders ?? Array.Empty(); foreach (Collider val in array) { Collider[] array2 = colliders2 ?? Array.Empty(); foreach (Collider val2 in array2) { if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { Physics.IgnoreCollision(val, val2, true); } } } } } } private bool IsOwnCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } Transform hit = ((Component)collider).transform; return _parts.Any((SpawnedBellhopPart part) => (Object)(object)part.Root != (Object)null && ((Object)(object)hit == (Object)(object)part.Root.transform || hit.IsChildOf(part.Root.transform))); } private bool IsCargoCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } PhysGrabObject hit = ((Component)collider).GetComponentInParent(); if ((Object)(object)hit != (Object)null) { return _cargoLoads.Any((CargoLoad load) => (Object)(object)load.Phys == (Object)(object)hit); } return false; } private static PlayerAvatar ResolveHitPlayer(Collider collider) { object obj = ((collider != null) ? ((Component)collider).GetComponentInParent() : null)?.playerAvatarScript; if (obj == null) { if (collider == null) { return null; } obj = ((Component)collider).GetComponentInParent(); } return (PlayerAvatar)obj; } private static PlayerAvatar FindNearestLivingPlayer(Vector3 position, float maximumDistance) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar result = null; float num = maximumDistance * maximumDistance; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { Vector3 val = ((Component)item).transform.position - position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = item; } } } return result; } public bool TryClaimWeaponHit(int bulletInstanceId) { if (!ModEnemyWeaponDamage.TryClaim((Object)(object)this, bulletInstanceId)) { return false; } if (Time.time - _lastClaimedWeaponHitTime < 0.06f) { return false; } _lastClaimedWeaponHitTime = Time.time; return true; } public void ReceiveWeaponHit(Vector3 hitPosition, int damage) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0081: Unknown result type (might be due to invalid IL or missing references) if (_state == BehaviourState.Dead) { return; } damage = ParasiteEffectRegistry.ModifyEnemyDamageAt(hitPosition, Mathf.Max(0, damage)); if (damage != 0) { _health -= damage; SpawnedBellhopPart part = _parts.Where((SpawnedBellhopPart spawnedBellhopPart) => spawnedBellhopPart.Alive && (Object)(object)spawnedBellhopPart.Phys != (Object)null).OrderBy(delegate(SpawnedBellhopPart spawnedBellhopPart) { //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) Vector3 val = spawnedBellhopPart.Phys.centerPoint - hitPosition; return ((Vector3)(ref val)).sqrMagnitude; }).FirstOrDefault(); PlayDamageFeedback(part, hitPosition); if (!_firstHitLogged) { _firstHitLogged = true; Plugin.Log.LogInfo((object)$"The Bellhop accepted its first weapon hit; HP={Mathf.Max(0, _health)}/{Mathf.Max(1, Plugin.Settings.BellhopHealth.Value)}."); } if (_health <= 0) { Die(); } } } private void PlayDamageFeedback(SpawnedBellhopPart part, Vector3 hitPosition) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) _damagePulseTimer = 0.24f; if (!(_damageFeedbackCooldown > 0f) && !((Object)(object)part?.ImpactDetector == (Object)null)) { _damageFeedbackCooldown = 0.09f; PhysGrabObjectImpactDetector detector = _body?.ImpactDetector ?? part.ImpactDetector; PhysGrabObject phys = _body?.Phys ?? part.Phys; ModEnemyFeedback.DamageHit(detector, phys, hitPosition, 82f); if ((Object)(object)_head?.ImpactDetector != (Object)null && _head != part) { _head.ImpactDetector.ImpactLight(52f, _head.Phys.centerPoint); } } } public void ReceiveTumbleAttack(int partIndex, int damage, Vector3 hitPosition, Vector3 direction) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (_state != BehaviourState.Dead) { _health -= Mathf.Max(1, damage); SpawnedBellhopPart part = ((partIndex >= 0 && partIndex < _parts.Count) ? _parts[partIndex] : _body); PlayDamageFeedback(part, hitPosition); if (_health <= 0) { Die(); return; } _tumbleFlinchTimer = 0.34f; StopAgent(); } } public void ExecuteForLab() { if (_state != BehaviourState.Dead && SemiFunc.IsMasterClientOrSingleplayer()) { _health = 0; Die(); } } private void Die() { if (_state == BehaviourState.Dead) { return; } ReleaseAllCargo(); _state = BehaviourState.Dead; _target = null; StopAgent(); foreach (SpawnedBellhopPart part in _parts) { if (part.Alive) { part.Alive = false; if ((Object)(object)part.ImpactDetector != (Object)null) { part.ImpactDetector.destroyDisable = false; part.ImpactDetector.DestroyObject(true); } else { BellhopSpawner.Destroy(part); } } } _rewardTimer = 0.08f; } private void UpdateDeath() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if (_rewardDropped) { return; } _rewardTimer -= Time.deltaTime; if (_rewardTimer > 0f) { return; } _rewardDropped = true; if (!Plugin.Settings.BellhopDropEnemyValuable.Value || (Object)(object)AssetManager.instance == (Object)null) { return; } GameObject val = (GameObject)(Mathf.Clamp(Plugin.Settings.BellhopRewardTier.Value, 1, 3) switch { 2 => AssetManager.instance.enemyValuableMedium, 1 => AssetManager.instance.enemyValuableSmall, _ => AssetManager.instance.enemyValuableBig, }); if (!((Object)(object)val == (Object)null)) { Vector3 val2 = ((Component)this).transform.position + Vector3.up * 0.55f; if (GameManager.Multiplayer()) { PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)val).name, val2, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate(val, val2, Quaternion.identity); } } } private void OnDestroy() { if (!_cleaningUp) { ReleaseAllCargo(); CleanupParts(effects: false); } } private void CleanupParts(bool effects) { if (_cleaningUp) { return; } _cleaningUp = true; foreach (SpawnedBellhopPart part in _parts) { if (part.Alive) { if (effects && (Object)(object)part.ImpactDetector != (Object)null) { part.ImpactDetector.destroyDisable = false; part.ImpactDetector.DestroyObject(true); } else { BellhopSpawner.Destroy(part); } } } _parts.Clear(); } } internal sealed class BellhopHaulerShellMarker : MonoBehaviour { private float _rescanTimer; private int _startupFrames = 30; private void Awake() { SuppressNativeHauler(((Component)this).gameObject); } private void OnEnable() { SuppressNativeHauler(((Component)this).gameObject); } private void LateUpdate() { _rescanTimer -= Time.deltaTime; if (_startupFrames > 0 || _rescanTimer <= 0f) { _startupFrames--; _rescanTimer = 1.25f; SuppressNativeHauler(((Component)this).gameObject); } } internal static void SuppressNativeHauler(GameObject root) { if ((Object)(object)root == (Object)null) { return; } PhysGrabCart[] componentsInChildren = root.GetComponentsInChildren(true); foreach (PhysGrabCart val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { ((Behaviour)val).enabled = false; Object.Destroy((Object)(object)val); } } PhysGrabInCart[] componentsInChildren2 = root.GetComponentsInChildren(true); foreach (PhysGrabInCart val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)null)) { ((Behaviour)val2).enabled = false; Object.Destroy((Object)(object)val2); } } ItemVehicle[] componentsInChildren3 = root.GetComponentsInChildren(true); foreach (ItemVehicle val3 in componentsInChildren3) { if (!((Object)(object)val3 == (Object)null)) { ((Behaviour)val3).enabled = false; Object.Destroy((Object)(object)val3); } } Collider[] componentsInChildren4 = root.GetComponentsInChildren(true); foreach (Collider val4 in componentsInChildren4) { if ((Object)(object)val4 != (Object)null && ((Component)val4).CompareTag("Cart")) { val4.enabled = false; } } } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "OnTriggerStay")] internal static class BellhopHaulerIntakePatch { private static bool Prefix(Collider other) { if (!((Object)(object)other == (Object)null) && ((Component)other).CompareTag("Cart")) { return (Object)(object)((Component)other).GetComponentInParent() == (Object)null; } return true; } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "Update")] internal static class BellhopHaulerCachedCartPatch { private static void Postfix(PhysGrabObjectImpactDetector __instance, ref PhysGrabCart ___currentCart, ref PhysGrabCart ___currentCartPrev, ref float ___timerInCart) { bool flag = BelongsToBellhop(___currentCart); bool flag2 = BelongsToBellhop(___currentCartPrev); if (flag || flag2) { if (flag) { ___currentCart = null; } if (flag2) { ___currentCartPrev = null; } ___timerInCart = 0f; __instance.inCart = false; } } private static bool BelongsToBellhop(PhysGrabCart cart) { if ((Object)(object)cart != (Object)null) { return (Object)(object)((Component)cart).GetComponentInParent() != (Object)null; } return false; } } internal interface IBellhopDamageReceiver { bool TryClaimWeaponHit(int bulletInstanceId); void ReceiveWeaponHit(Vector3 hitPosition, int damage); void ExecuteForLab(); } internal sealed class BellhopHitProxy : MonoBehaviour { private IBellhopDamageReceiver _receiver; private Renderer[] _renderers = Array.Empty(); private PhysGrabObjectImpactDetector[] _detectors = Array.Empty(); private readonly Dictionary _previousBulletPositions = new Dictionary(); private readonly HashSet _currentBulletIds = new HashSet(); private float _cooldown; private static int _cachedBulletFrame = -1; private static ItemGunBullet[] _cachedBullets = Array.Empty(); internal void Initialize(IBellhopDamageReceiver receiver, IEnumerable parts) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown _receiver = receiver; List list = new List(); List list2 = new List(); foreach (SpawnedBellhopPart part in parts) { if (part?.Renderers != null) { list.AddRange(part.Renderers); } if ((Object)(object)part?.ImpactDetector != (Object)null) { list2.Add(part.ImpactDetector); UnityEvent onHurtColliderHit = part.ImpactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.AddListener(new UnityAction(OnHurtColliderHit)); } } } _renderers = list.ToArray(); _detectors = list2.ToArray(); } private void Update() { _cooldown = Mathf.Max(0f, _cooldown - Time.deltaTime); if (_cooldown <= 0f && SemiFunc.IsMasterClientOrSingleplayer()) { DetectExpandedBulletHit(); } } private void OnDestroy() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown PhysGrabObjectImpactDetector[] detectors = _detectors; foreach (PhysGrabObjectImpactDetector obj in detectors) { if (obj != null) { UnityEvent onHurtColliderHit = obj.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.RemoveListener(new UnityAction(OnHurtColliderHit)); } } } } private void OnHurtColliderHit() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (_receiver == null || _cooldown > 0f || !SemiFunc.IsMasterClientOrSingleplayer() || !_receiver.TryClaimWeaponHit(ModEnemyWeaponDamage.CurrentClaimId)) { return; } _cooldown = 0.16f; Vector3 val = ClosestVisualPoint(((Component)this).transform.position); if (EnemyLabBridge.IsExecutionHitNear(val)) { _receiver.ExecuteForLab(); return; } int num = ModEnemyWeaponDamage.CurrentOrFallback(Plugin.Settings.BellhopDamagePerHit.Value); if (num > 0) { _receiver.ReceiveWeaponHit(val, num); } } private void DetectExpandedBulletHit() { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) if (_receiver == null) { return; } if (_cachedBulletFrame != Time.frameCount) { _cachedBulletFrame = Time.frameCount; _cachedBullets = Object.FindObjectsOfType(); } _currentBulletIds.Clear(); ItemGunBullet[] cachedBullets = _cachedBullets; foreach (ItemGunBullet val in cachedBullets) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent() != (Object)null || (Object)(object)val.hurtCollider == (Object)null || !((Component)val.hurtCollider).gameObject.activeInHierarchy) { continue; } int instanceID = ((Object)val).GetInstanceID(); _currentBulletIds.Add(instanceID); Vector3 position = ((Component)val.hurtCollider).transform.position; Vector3 value; bool num = _previousBulletPositions.TryGetValue(instanceID, out value); _previousBulletPositions[instanceID] = position; if (!(num ? SegmentIntersectsVisuals(value, position) : WithinVisuals(position)) || !_receiver.TryClaimWeaponHit(instanceID)) { continue; } _cooldown = 0.22f; if (EnemyLabBridge.IsExecutionHitNear(position)) { _receiver.ExecuteForLab(); return; } int num2 = ModEnemyWeaponDamage.Resolve(val.hurtCollider, Plugin.Settings.BellhopDamagePerHit.Value); if (num2 > 0) { _receiver.ReceiveWeaponHit(position, num2); } return; } if (_previousBulletPositions.Count <= _currentBulletIds.Count) { return; } List list = null; foreach (int key in _previousBulletPositions.Keys) { if (!_currentBulletIds.Contains(key)) { if (list == null) { list = new List(); } list.Add(key); } } foreach (int item in list ?? new List()) { _previousBulletPositions.Remove(item); } } private bool WithinVisuals(Vector3 position) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_005d: 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) float num = Mathf.Clamp(Plugin.Settings.BellhopHitDetectionPadding.Value, 0.12f, 0.75f); float num2 = num * num; Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if ((Object)(object)val != (Object)null && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; if (((Bounds)(ref bounds)).SqrDistance(position) <= num2) { return true; } } } Vector3 val2 = ((Component)this).transform.position + Vector3.up * 0.85f; Vector3 val3 = position - val2; return ((Vector3)(ref val3)).sqrMagnitude <= Mathf.Pow(0.62f + num, 2f); } private bool SegmentIntersectsVisuals(Vector3 start, Vector3 end) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Settings.BellhopHitDetectionPadding.Value, 0.12f, 0.75f); Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if (!((Object)(object)val == (Object)null) && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; ((Bounds)(ref bounds)).Expand(num * 2f); if (SegmentIntersectsBounds(start, end, bounds)) { return true; } } } Vector3 point = ((Component)this).transform.position + Vector3.up * 0.85f; float num2 = 0.62f + num; return DistancePointToSegmentSquared(point, start, end) <= num2 * num2; } private Vector3 ClosestVisualPoint(Vector3 origin) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_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_0084: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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_005c: 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_005f: 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_0077: 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) Vector3 result = ((Component)this).transform.position + Vector3.up * 0.85f; float num = float.MaxValue; Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if (!((Object)(object)val == (Object)null) && val.enabled) { Bounds bounds = val.bounds; Vector3 val2 = ((Bounds)(ref bounds)).ClosestPoint(origin); Vector3 val3 = val2 - origin; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val2; } } } return result; } private static bool SegmentIntersectsBounds(Vector3 start, Vector3 end, Bounds bounds) { //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) //IL_0002: 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_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float num = 0f; float num2 = 1f; for (int i = 0; i < 3; i++) { float num3 = ((Vector3)(ref start))[i]; float num4 = ((Vector3)(ref val))[i]; Vector3 val2; if (Mathf.Abs(num4) < 1E-05f) { val2 = ((Bounds)(ref bounds)).min; if (!(num3 < ((Vector3)(ref val2))[i])) { val2 = ((Bounds)(ref bounds)).max; if (!(num3 > ((Vector3)(ref val2))[i])) { continue; } } return false; } float num5 = 1f / num4; val2 = ((Bounds)(ref bounds)).min; float num6 = (((Vector3)(ref val2))[i] - num3) * num5; val2 = ((Bounds)(ref bounds)).max; float num7 = (((Vector3)(ref val2))[i] - num3) * num5; if (num6 > num7) { float num8 = num7; num7 = num6; num6 = num8; } num = Mathf.Max(num, num6); num2 = Mathf.Min(num2, num7); if (num > num2) { return false; } } return true; } private static float DistancePointToSegmentSquared(Vector3 point, Vector3 start, Vector3 end) { //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) //IL_0002: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_002f: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; Vector3 val2; if (sqrMagnitude <= 1E-06f) { val2 = point - start; return ((Vector3)(ref val2)).sqrMagnitude; } float num = Mathf.Clamp01(Vector3.Dot(point - start, val) / sqrMagnitude); val2 = point - (start + val * num); return ((Vector3)(ref val2)).sqrMagnitude; } } internal sealed class BellhopLowGravityCargo : MonoBehaviour { private PhysGrabObject _phys; private Action _environmentHit; private float _armedAt; private bool _active; internal PhysGrabObject Phys => _phys; internal void Activate(PhysGrabObject phys, float armDelay, Action environmentHit) { _phys = phys; _environmentHit = environmentHit; _armedAt = Time.time + Mathf.Max(0.05f, armDelay); _active = true; if ((Object)(object)_phys?.rb != (Object)null) { _phys.rb.useGravity = false; } } internal void Deactivate(bool restoreGravity) { _active = false; _environmentHit = null; if (restoreGravity && (Object)(object)_phys?.rb != (Object)null) { _phys.rb.useGravity = true; } } private void FixedUpdate() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (_active && !((Object)(object)_phys?.rb == (Object)null) && !_phys.rb.isKinematic && _phys.playerGrabbing.Count == 0) { _phys.rb.AddForce(Physics.gravity * 0.12f, (ForceMode)5); } } private void OnCollisionEnter(Collision collision) { CheckEnvironment((collision != null) ? collision.collider : null); } private void OnCollisionStay(Collision collision) { CheckEnvironment((collision != null) ? collision.collider : null); } private void CheckEnvironment(Collider other) { if (_active && !(Time.time < _armedAt) && !((Object)(object)other == (Object)null) && !((Object)(object)_phys == (Object)null) && _phys.playerGrabbing.Count <= 0 && !((Object)(object)((Component)other).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)other).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)other).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)other).GetComponentInParent() != (Object)null)) { Action environmentHit = _environmentHit; _active = false; environmentHit?.Invoke(this, other); } } private void OnDestroy() { Deactivate(restoreGravity: false); } } internal sealed class BellhopManager : MonoBehaviour { private int _levelInstanceId; private float _spawnTimer; private bool _attemptFinished; private bool _prefabProbeFinished; private bool _prefabsAvailable; private bool _levelReadyLogged; private BellhopController _encounter; internal void Tick() { if (!IsHostOrSingleplayerReady()) { return; } ProbePrefabs(); LevelGenerator instance = LevelGenerator.Instance; int num = (((Object)(object)instance != (Object)null) ? ((Object)instance).GetInstanceID() : 0); if (num != _levelInstanceId) { ResetForLevel(num); } if (!IsPlayableLevel()) { DestroyCurrentEncounter(); } else if (!((Object)(object)instance == (Object)null) && instance.Generated && !_attemptFinished) { if (!_levelReadyLogged) { _levelReadyLogged = true; Plugin.Log.LogInfo((object)"The Bellhop detected a generated playable level; automatic spawn timer started."); } _spawnTimer -= Time.deltaTime; if (!(_spawnTimer > 0f)) { _attemptFinished = true; TryCreateEncounter(); } } } private void ResetForLevel(int levelId) { DestroyCurrentEncounter(); _levelInstanceId = levelId; _spawnTimer = Mathf.Max(0f, Plugin.Settings.BellhopSpawnDelay.Value); _attemptFinished = false; _levelReadyLogged = false; } private void TryCreateEncounter() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) Vector3 position; if (Random.value > Mathf.Clamp01(Plugin.Settings.BellhopSpawnChance.Value)) { Plugin.Log.LogInfo((object)"The Bellhop skipped this level by spawn chance."); } else if (!_prefabsAvailable && !BellhopSpawner.PrefabsAvailable()) { Plugin.Log.LogWarning((object)"The Bellhop could not find its vanilla delivery-cart and service-bell resources."); } else if (!TryFindSpawnPosition(out position)) { Plugin.Log.LogWarning((object)"Could not find a valid navigation point for The Bellhop."); } else { CreateEncounter(position, "automatic"); } } private bool CreateEncounter(Vector3 position, string source) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_001e: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) DestroyCurrentEncounter(); GameObject val = new GameObject("The Bellhop Encounter (Host Only)"); val.SetActive(false); val.transform.position = position; BellhopController bellhopController = val.AddComponent(); if (!bellhopController.Initialize(position)) { Object.Destroy((Object)(object)val); Plugin.Log.LogError((object)"The Bellhop failed to initialize."); return false; } val.SetActive(true); if (!bellhopController.ActivateNavigation(position)) { Object.Destroy((Object)(object)val); Plugin.Log.LogError((object)"The Bellhop failed to activate navigation."); return false; } _encounter = bellhopController; Plugin.Log.LogInfo((object)$"The Bellhop spawned at {position} ({source}); its cart, bell and 2-3 thrown valuables use vanilla networking."); return true; } internal bool DebugSpawnAt(Vector3 requestedPosition) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!IsHostOrSingleplayerReady() || (!ModEnemySpawnCoordinator.IsDirectorRequestActive && (Object)(object)PlayerAvatar.instance == (Object)null) || !IsPlayableLevel()) { Plugin.Log.LogWarning((object)"Enemy Lab rejected The Bellhop because no non-shop playable host level is active."); return false; } ProbePrefabs(); if (!_prefabsAvailable && !BellhopSpawner.PrefabsAvailable()) { Plugin.Log.LogWarning((object)"Enemy Lab could not load The Bellhop's vanilla resources."); return false; } NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requestedPosition, ref val, 12f, -1)) { Plugin.Log.LogWarning((object)$"Enemy Lab could not find NavMesh near {requestedPosition} for The Bellhop."); return false; } _attemptFinished = true; return CreateEncounter(((NavMeshHit)(ref val)).position, ModEnemySpawnCoordinator.CurrentSpawnSource); } internal void MarkAutomaticAttemptFinished() { int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelInstanceId) { ResetForLevel(num); } _attemptFinished = true; } internal void DebugDespawn() { if (IsHostOrSingleplayerReady()) { _attemptFinished = true; DestroyCurrentEncounter(); Plugin.Log.LogInfo((object)"The Bellhop despawned by Enemy Lab."); } } private void DestroyCurrentEncounter() { if (!((Object)(object)_encounter == (Object)null)) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); _encounter = null; } } private void ProbePrefabs() { if (!_prefabProbeFinished && !((Object)(object)RunManager.instance == (Object)null)) { _prefabProbeFinished = true; _prefabsAvailable = BellhopSpawner.PrefabsAvailable(); if (_prefabsAvailable) { Plugin.Log.LogInfo((object)("The Bellhop verified its vanilla Hauler resource: " + BellhopSpawner.CartResourcePath + ".")); } else { Plugin.Log.LogWarning((object)"The Bellhop's vanilla resources are unavailable."); } } } private static bool IsHostOrSingleplayerReady() { if ((Object)(object)GameManager.instance == (Object)null) { return false; } try { return !GameManager.Multiplayer() || PhotonNetwork.IsMasterClient; } catch { return false; } } private static bool IsPlayableLevel() { return ModEnemyLevelRules.IsPlayableLevel(); } private static bool TryFindSpawnPosition(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; PlayerAvatar val = null; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { val = item; break; } } Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(val2, 20f, 65f, false) ?? SemiFunc.LevelPointGetFurthestFromPlayer(val2, 7f); return ModEnemyNavigation.TryFindClearSpawn(((Object)(object)val3 != (Object)null) ? ((Component)val3).transform.position : (val2 + Vector3.forward * 20f), 8f, out position); } } internal enum BellhopPartRole { Body, Head, Tray } internal sealed class SpawnedBellhopPart { internal GameObject Root; internal PhysGrabObject Phys; internal PhysGrabObjectImpactDetector ImpactDetector; internal ItemAttributes Attributes; internal Renderer[] Renderers; internal Collider[] Colliders; internal BellhopPartRole Role; internal Vector3 VisualCenterOffset; internal Vector3 VisualSize; internal Vector3 LocalOffset; internal Quaternion LocalRotation = Quaternion.identity; internal int GeometryCalibrationFrames = 18; internal bool Alive = true; } internal static class BellhopSpawner { private static string _cartResourcePath; private static bool _resolved; internal static string CartResourcePath { get { ResolveResources(); return _cartResourcePath; } } internal static bool PrefabsAvailable() { ResolveResources(); return !string.IsNullOrEmpty(_cartResourcePath); } private static void ResolveResources() { if (!_resolved) { _resolved = true; _cartResourcePath = ResolveHaulerResource(); } } private static string ResolveHaulerResource() { try { if ((Object)(object)StatsManager.instance != (Object)null) { string[] array = new string[2] { "Hauler", "Item Vehicle Semiscooter" }; foreach (string key in array) { if (StatsManager.instance.itemDictionary.TryGetValue(key, out var value) && value?.prefab != null && !string.IsNullOrEmpty(((PrefabRef)(object)value.prefab).ResourcePath)) { return ((PrefabRef)(object)value.prefab).ResourcePath; } } } } catch { } if (!((Object)(object)Resources.Load("Items/Item Vehicle Semiscooter") != (Object)null)) { return null; } return "Items/Item Vehicle Semiscooter"; } internal static SpawnedBellhopPart Spawn(string resourcePath, Vector3 position, Quaternion rotation, Vector3 scaleMultiplier, BellhopPartRole role) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00a8: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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) GameObject val = Resources.Load(resourcePath); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("The Bellhop could not load vanilla resource '" + resourcePath + "'.")); return null; } ((Vector3)(ref scaleMultiplier))..ctor(Mathf.Clamp(scaleMultiplier.x, 0.035f, 2.6f), Mathf.Clamp(scaleMultiplier.y, 0.035f, 2.6f), Mathf.Clamp(scaleMultiplier.z, 0.035f, 2.6f)); Vector3 val2 = Vector3.Scale(val.transform.localScale, scaleMultiplier); object[] array = new object[3] { val2.x, val2.y, val2.z }; GameObject val3; try { val3 = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject(resourcePath, position, rotation, (byte)0, array) : Object.Instantiate(val, position, rotation)); } catch (Exception arg) { Plugin.Log.LogError((object)$"The Bellhop failed to network-spawn '{resourcePath}': {arg}"); return null; } if ((Object)(object)val3 == (Object)null) { return null; } val3.transform.localScale = val2; EncounterValuableNeutralizer.Apply(val3); if ((Object)(object)val3.GetComponent() == (Object)null) { val3.AddComponent(); } BellhopHaulerShellMarker.SuppressNativeHauler(val3); Trap[] componentsInChildren = val3.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Behaviour)componentsInChildren[i]).enabled = false; } MusicalValuableLogic[] componentsInChildren2 = val3.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { ((Behaviour)componentsInChildren2[i]).enabled = false; } PhysGrabCart[] componentsInChildren3 = val3.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { ((Behaviour)componentsInChildren3[i]).enabled = false; } PhysGrabInCart[] componentsInChildren4 = val3.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren4.Length; i++) { ((Behaviour)componentsInChildren4[i]).enabled = false; } ItemVehicle[] componentsInChildren5 = val3.GetComponentsInChildren(true); foreach (ItemVehicle val4 in componentsInChildren5) { ((Behaviour)val4).enabled = false; if ((Object)(object)val4.hurtColliderSmall != (Object)null) { ((Component)val4.hurtColliderSmall).gameObject.SetActive(false); } if ((Object)(object)val4.hurtColliderMedium != (Object)null) { ((Component)val4.hurtColliderMedium).gameObject.SetActive(false); } if ((Object)(object)val4.hurtColliderBig != (Object)null) { ((Component)val4.hurtColliderBig).gameObject.SetActive(false); } } Collider[] componentsInChildren6 = val3.GetComponentsInChildren(true); foreach (Collider val5 in componentsInChildren6) { if ((Object)(object)val5 != (Object)null && ((Component)val5).CompareTag("Cart")) { val5.enabled = false; } } SpawnedBellhopPart spawnedBellhopPart = new SpawnedBellhopPart { Root = val3, Phys = val3.GetComponentInChildren(true), ImpactDetector = val3.GetComponentInChildren(true), Attributes = val3.GetComponentInChildren(true), Renderers = val3.GetComponentsInChildren(true), Colliders = val3.GetComponentsInChildren(true), Role = role }; if ((Object)(object)spawnedBellhopPart.Phys == (Object)null || (Object)(object)spawnedBellhopPart.ImpactDetector == (Object)null) { Plugin.Log.LogError((object)("The Bellhop resource '" + resourcePath + "' lacks vanilla physical components.")); Destroy(spawnedBellhopPart); return null; } RefreshGeometry(spawnedBellhopPart); ItemAttributes attributes = spawnedBellhopPart.Attributes; if (attributes != null) { attributes.DisableUI(true); } spawnedBellhopPart.ImpactDetector.destroyDisable = true; spawnedBellhopPart.Phys.OverrideIndestructible(1f); spawnedBellhopPart.Phys.OverrideKinematic(1f); spawnedBellhopPart.Phys.OverrideGrabDisable(1f); MapIconSuppressor.Attach(val3); return spawnedBellhopPart; } internal static void RefreshGeometry(SpawnedBellhopPart part) { //IL_0021: 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_00f7: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)part?.Phys == (Object)null || part.Renderers == null) { return; } bool flag = false; Bounds val = default(Bounds); Renderer[] renderers = part.Renderers; foreach (Renderer val2 in renderers) { if ((Object)(object)val2 == (Object)null || !val2.enabled || (!(val2 is MeshRenderer) && !(val2 is SkinnedMeshRenderer))) { continue; } Bounds bounds = val2.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!(((Vector3)(ref size)).sqrMagnitude < 1E-06f) && !(((Bounds)(ref bounds)).size.x > 9f) && !(((Bounds)(ref bounds)).size.y > 9f) && !(((Bounds)(ref bounds)).size.z > 9f)) { if (!flag) { val = bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(bounds); } } } if (flag) { Transform transform = ((Component)part.Phys).transform; part.VisualCenterOffset = Quaternion.Inverse(transform.rotation) * (((Bounds)(ref val)).center - transform.position); part.VisualSize = ((Bounds)(ref val)).size; } } internal static void Destroy(SpawnedBellhopPart part) { if (!((Object)(object)part?.Root == (Object)null)) { if (GameManager.Multiplayer()) { PhotonNetwork.Destroy(part.Root); } else { Object.Destroy((Object)(object)part.Root); } part.Alive = false; } } } internal sealed class BrokerController : MonoBehaviour, IBrokerDamageReceiver, IModEnemyTumbleReceiver { private enum BehaviourState { Neutral, Digesting, Hostile, Dead } private const float HostileBiteInterval = 0.34f; private const float HostileAccelerationSeconds = 1.75f; private readonly List _parts = new List(); private readonly HashSet _claimedWeaponBullets = new HashSet(); private NavMeshAgent _agent; private PlayerAvatar _target; private PlayerAvatar _beggingPlayer; private SpawnedBrokerPart _body; private SpawnedBrokerPart _lid; private SpawnedBrokerPart _mouth; private ChompBookTrap _mouthTrap; private BrokerValuableMeal _meal; private BehaviourState _state; private int _health; private float _orbitAngle; private float _targetTimer; private float _destinationTimer; private float _mealScanTimer; private float _beggingGraceTimer; private Vector3 _beggingAnchor; private bool _beggingAnchorSet; private float _digestTimer; private float _digestSoundTimer; private float _attackTimer; private float _hostileWindupTimer; private float _hostileAccelerationTimer; private float _movementSoundTimer; private float _lastClaimedWeaponHitTime = -999f; private float _deathTimer; private float _tumbleFlinchTimer; private float _damagePulseTimer; private float _damageFeedbackCooldown; private float _smoothedLidAngle = -52f; private float _smoothedMouthChew; private int _movementLegCursor; private int _digestSoundBeat; private bool _mouthActivated; private bool _wasGrabbed; private bool _initialized; private bool _cleaningUp; private bool _firstHitLogged; private bool _firstAttackLogged; public bool CanReceiveTumbleAttack { get { if (_initialized) { return _state != BehaviourState.Dead; } return false; } } internal bool Initialize(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: 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_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: 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_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; _health = Mathf.Max(1, Plugin.Settings.BrokerHealth.Value); _state = BehaviourState.Neutral; _orbitAngle = Random.Range(0f, 360f); _agent = ((Component)this).gameObject.AddComponent(); ((Behaviour)_agent).enabled = false; _agent.speed = Mathf.Max(0.8f, Plugin.Settings.BrokerFollowSpeed.Value); _agent.acceleration = 28f; _agent.angularSpeed = 540f; _agent.radius = 0.4f; _agent.height = 0.9f; _agent.stoppingDistance = 0.55f; _agent.autoBraking = true; _body = BrokerSpawner.Spawn(BrokerSpawner.BodyResourcePath, position, Quaternion.identity, new Vector3(0.92f, 1.35f, 0.88f), BrokerPartRole.Body, grabbable: true); if (_body == null) { return false; } _body.LocalOffset = new Vector3(0f, 0.34f, 0f); _body.LocalRotation = Quaternion.identity; _parts.Add(_body); ((Component)_body.Phys).gameObject.AddComponent().Initialize(_body.Phys); _lid = BrokerSpawner.Spawn(BrokerSpawner.LidResourcePath, position, LidRotation(-55f), new Vector3(0.98f, 0.34f, 0.88f), BrokerPartRole.Lid, grabbable: false); if (_lid == null) { CleanupParts(effects: false); return false; } _lid.LocalOffset = new Vector3(0f, 0.57f, -0.12f); _lid.LocalRotation = LidRotation(-55f); _parts.Add(_lid); _mouth = BrokerSpawner.Spawn(BrokerSpawner.MouthResourcePath, position, Quaternion.AngleAxis(90f, Vector3.right), Vector3.one * 0.3f, BrokerPartRole.Mouth, grabbable: false); if (_mouth == null) { CleanupParts(effects: false); return false; } _mouth.LocalOffset = new Vector3(0f, 0.39f, 0.08f); _mouth.LocalRotation = Quaternion.AngleAxis(90f, Vector3.right); _parts.Add(_mouth); _mouthTrap = _mouth.Root.GetComponentInChildren(true); if ((Object)(object)_mouthTrap != (Object)null) { ((Behaviour)_mouthTrap).enabled = false; } Vector3[] array = (Vector3[])(object)new Vector3[4] { new Vector3(-0.14f, 0.19f, -0.11f), new Vector3(0.14f, 0.19f, -0.11f), new Vector3(-0.14f, 0.19f, 0.11f), new Vector3(0.14f, 0.19f, 0.11f) }; Vector3[] array2 = (Vector3[])(object)new Vector3[4] { new Vector3(-0.18f, 0.025f, -0.14f), new Vector3(0.18f, 0.025f, -0.14f), new Vector3(-0.18f, 0.025f, 0.14f), new Vector3(0.18f, 0.025f, 0.14f) }; for (int i = 0; i < array.Length; i++) { SpawnedBrokerPart spawnedBrokerPart = BrokerSpawner.Spawn("Valuables/07 Very Tall/Valuable Wizard Broom", position, Quaternion.identity, Vector3.one * 0.055f, BrokerPartRole.Leg, grabbable: false); if (spawnedBrokerPart == null) { CleanupParts(effects: false); return false; } spawnedBrokerPart.LocalOffset = (array[i] + array2[i]) * 0.5f; Vector3 longAxisLocal = spawnedBrokerPart.LongAxisLocal; Vector3 val = array2[i] - array[i]; spawnedBrokerPart.LocalRotation = Quaternion.FromToRotation(longAxisLocal, ((Vector3)(ref val)).normalized); float[] array3 = new float[4] { 0.03f, 0.54f, 0.78f, 0.29f }; spawnedBrokerPart.GaitPhase = array3[i]; spawnedBrokerPart.LegIndex = i; _parts.Add(spawnedBrokerPart); } IgnoreSelfCollisions(); for (int j = 0; j < _parts.Count; j++) { ((Component)_parts[j].Phys).gameObject.AddComponent().Initialize(this, j); } ((Component)this).gameObject.AddComponent().Initialize(this, _parts); _mealScanTimer = 0.25f; _movementSoundTimer = Random.Range(0.5f, 0.8f); _initialized = true; PinParts(force: true); Plugin.Log.LogInfo((object)$"The Broker assembled a grabbable {BrokerSpawner.BodyResourcePath} chest, an open {BrokerSpawner.LidResourcePath} lid, a recessed Chomp Book mouth and four legs with {_health} HP."); return true; } private void IgnoreSelfCollisions() { for (int i = 0; i < _parts.Count; i++) { Collider[] colliders = _parts[i].Colliders; if (colliders == null) { continue; } for (int j = i + 1; j < _parts.Count; j++) { Collider[] colliders2 = _parts[j].Colliders; if (colliders2 == null) { continue; } Collider[] array = colliders; foreach (Collider val in array) { if ((Object)(object)val == (Object)null) { continue; } Collider[] array2 = colliders2; foreach (Collider val2 in array2) { if ((Object)(object)val2 != (Object)null) { Physics.IgnoreCollision(val, val2, true); } } } } } } internal bool ActivateNavigation(Vector3 requestedPosition) { //IL_000e: 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_0053: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if ((Object)(object)_agent == (Object)null || !NavMesh.SamplePosition(requestedPosition, ref val, 5f, -1)) { return false; } ((Component)this).transform.position = ((NavMeshHit)(ref val)).position; ((Behaviour)_agent).enabled = true; if (!_agent.isOnNavMesh && !_agent.Warp(((NavMeshHit)(ref val)).position)) { return false; } return _agent.isOnNavMesh; } private void Update() { if (!_initialized || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (_state == BehaviourState.Dead) { _deathTimer -= Time.deltaTime; if (_deathTimer <= 0f) { Object.Destroy((Object)(object)((Component)this).gameObject); } return; } _damagePulseTimer = Mathf.Max(0f, _damagePulseTimer - Time.deltaTime); _beggingGraceTimer = Mathf.Max(0f, _beggingGraceTimer - Time.deltaTime); _damageFeedbackCooldown = Mathf.Max(0f, _damageFeedbackCooldown - Time.deltaTime); bool flag = IsBodyGrabbed(); if (_state != BehaviourState.Neutral || flag) { _beggingAnchorSet = false; } if (flag && _state != BehaviourState.Hostile) { BecomeHostile("it was grabbed"); } UpdateGrabbedAnchor(flag); if (_tumbleFlinchTimer > 0f && !flag) { _tumbleFlinchTimer = Mathf.Max(0f, _tumbleFlinchTimer - Time.deltaTime); StopAgent(); PinParts(force: false); UpdateNearMusic(); _wasGrabbed = flag; return; } UpdateTarget(); if (_state == BehaviourState.Digesting) { UpdateDigesting(); } else if (_state == BehaviourState.Hostile) { UpdateHostile(flag); } else { UpdateNeutral(flag); ScanForMeal(); } PinParts(force: false); UpdateMovementSound(); UpdateNearMusic(); _wasGrabbed = flag; } private bool IsBodyGrabbed() { if ((Object)(object)_body?.Phys != (Object)null) { if (!_body.Phys.grabbed && !_body.Phys.grabbedLocal) { return _body.Phys.playerGrabbing.Count > 0; } return true; } return false; } private void UpdateGrabbedAnchor(bool grabbed) { //IL_004d: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_008d: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_0110: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val2 = default(NavMeshHit); if (grabbed) { if ((Object)(object)_agent != (Object)null && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.velocity = Vector3.zero; } Quaternion rotation = ((Component)_body.Phys).transform.rotation; Vector3 val = ((Component)_body.Phys).transform.position + rotation * _body.VisualCenterOffset; ((Component)this).transform.position = val - rotation * _body.LocalOffset; ((Component)this).transform.rotation = rotation; } else if (_wasGrabbed && (Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && NavMesh.SamplePosition(((Component)_body.Phys).transform.position, ref val2, 5f, -1)) { _agent.Warp(((NavMeshHit)(ref val2)).position); ((Component)this).transform.position = ((NavMeshHit)(ref val2)).position; } } private void UpdateTarget() { //IL_008f: 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_009f: 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) if (_state == BehaviourState.Hostile) { return; } _targetTimer -= Time.deltaTime; if (_targetTimer > 0f && GunAccess.IsLiving(_target)) { return; } _targetTimer = 0.25f; PlayerAvatar val = null; float num = float.MaxValue; float num2 = Mathf.Clamp(Plugin.Settings.BrokerVisionRange.Value, 4f, 50f); foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { Vector3 val2 = ((Component)item).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (!(sqrMagnitude >= num) && !(sqrMagnitude > num2 * num2) && (_state == BehaviourState.Hostile || !((Object)(object)_target == (Object)null) || HasClearPath(item))) { val = item; num = sqrMagnitude; } } } if ((Object)(object)val != (Object)null) { _target = val; } } private void UpdateNeutral(bool grabbed) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) if (grabbed || (Object)(object)_agent == (Object)null || !_agent.isOnNavMesh) { return; } if (_beggingGraceTimer > 0f && GunAccess.IsLiving(_beggingPlayer)) { Vector3 val = ((Component)_beggingPlayer).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude <= 36f && HasClearPath(_beggingPlayer)) { LockBeggingPosition(); _destinationTimer = 0.18f; FacePlayer(_beggingPlayer, 300f); return; } } _beggingAnchorSet = false; _agent.speed = Mathf.Clamp(Plugin.Settings.BrokerFollowSpeed.Value, 0.8f, 5f); _agent.isStopped = false; _destinationTimer -= Time.deltaTime; if ((Object)(object)_target != (Object)null) { _orbitAngle += Time.deltaTime * 32f; if (_destinationTimer <= 0f) { _destinationTimer = 0.18f; float num = _orbitAngle * (MathF.PI / 180f); float num2 = Mathf.Clamp(Plugin.Settings.BrokerOrbitRadius.Value, 1.7f, 5f); NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(((Component)_target).transform.position + new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num)) * num2, ref val2, 3f, -1)) { _agent.SetDestination(((NavMeshHit)(ref val2)).position); } } } else if (_destinationTimer <= 0f) { _destinationTimer = Random.Range(1.4f, 2.4f); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(((Component)this).transform.position, 4f, 16f, false); NavMeshHit val4 = default(NavMeshHit); if ((Object)(object)val3 != (Object)null && NavMesh.SamplePosition(((Component)val3).transform.position, ref val4, 4f, -1)) { _agent.SetDestination(((NavMeshHit)(ref val4)).position); } } } private void ScanForMeal() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_00f7: Unknown result type (might be due to invalid IL or missing references) _mealScanTimer -= Time.deltaTime; if (_mealScanTimer > 0f || (Object)(object)_mouth?.Phys == (Object)null) { return; } _mealScanTimer = 0.06f; Vector3 val = MouthPoint(); ValuableObject val2 = null; PlayerAvatar val3 = null; float num = 36f; float num2 = 0.5184f; ValuableObject[] array = Object.FindObjectsOfType(); foreach (ValuableObject val4 in array) { if ((Object)(object)val4 == (Object)null || MapIconSuppressor.OwnsValuable(val4)) { continue; } PhysGrabObject val5 = ((Component)val4).GetComponent() ?? ((Component)val4).GetComponentInParent(); Vector3 val7; if ((Object)(object)val5 != (Object)null) { foreach (PhysGrabber item in val5.playerGrabbing) { PlayerAvatar val6 = item?.playerAvatar; if (GunAccess.IsLiving(val6)) { val7 = ((Component)val6).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val7)).sqrMagnitude; if (sqrMagnitude < num && HasClearPath(val6)) { num = sqrMagnitude; val3 = val6; } } } } if ((Object)(object)val5 == (Object)null || (Object)(object)val5.rb == (Object)null) { continue; } val7 = val5.rb.velocity; if (!(((Vector3)(ref val7)).sqrMagnitude < 0.16f)) { val7 = val5.centerPoint - val; float sqrMagnitude2 = ((Vector3)(ref val7)).sqrMagnitude; if (sqrMagnitude2 < num2) { num2 = sqrMagnitude2; val2 = val4; } } } if (GunAccess.IsLiving(val3)) { if ((Object)(object)_beggingPlayer != (Object)(object)val3 || !_beggingAnchorSet) { _beggingAnchor = ((Component)this).transform.position; _beggingAnchorSet = true; } _beggingPlayer = val3; _beggingGraceTimer = 1.45f; } else if (_beggingGraceTimer <= 0f) { _beggingPlayer = null; _beggingAnchorSet = false; } if (!((Object)(object)val2 == (Object)null) && BrokerValuableMeal.TryCapture(val2, Mathf.Clamp(Plugin.Settings.BrokerMaximumValuableSize.Value, 0.35f, 1.4f), out var meal)) { _meal = meal; _beggingAnchorSet = false; _state = BehaviourState.Digesting; _digestTimer = Mathf.Clamp(Plugin.Settings.BrokerDigestSeconds.Value, 0.6f, 4f); _digestSoundTimer = 0.12f; _digestSoundBeat = 0; StopAgent(); PhysGrabObjectImpactDetector impactDetector = _mouth.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactMedium(100f, _mouth.Phys.centerPoint); } Plugin.Log.LogInfo((object)$"The Broker swallowed a current-value ${meal.CapturedValue:F0} valuable for appraisal #{meal.PreviousSuccesses + 1}."); } } private void FacePlayer(PlayerAvatar player, float degreesPerSecond) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (GunAccess.IsLiving(player)) { Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f)) { ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up), Mathf.Max(30f, degreesPerSecond) * Time.deltaTime); } } } private void LockBeggingPosition() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_00e7: Unknown result type (might be due to invalid IL or missing references) if (!_beggingAnchorSet) { _beggingAnchor = ((Component)this).transform.position; _beggingAnchorSet = true; } StopAgent(); ((Component)this).transform.position = _beggingAnchor; if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.nextPosition = _beggingAnchor; _agent.velocity = Vector3.zero; } if ((Object)(object)_body?.Phys?.rb != (Object)null && !_body.Phys.rb.isKinematic) { _body.Phys.rb.velocity = Vector3.zero; _body.Phys.rb.angularVelocity = Vector3.zero; } } private void UpdateDigesting() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) StopAgent(); _meal?.ParkBelow(((Component)this).transform.position); UpdateDigestSound(); _digestTimer -= Time.deltaTime; if (_digestTimer > 0f || _meal == null) { return; } float num = Mathf.Clamp(Plugin.Settings.BrokerSuccessChance.Value, 0.1f, 1f); float num2 = Mathf.Max(0.1f, num - (float)_meal.PreviousSuccesses * 0.15f); float num3 = Mathf.Clamp(Plugin.Settings.BrokerValueMultiplier.Value, 1.001f, 2f); float num4 = Mathf.Clamp(num3 * num / num2, num3, 5f); if (Random.value < num2) { Vector3 val = ((Component)this).transform.forward; val.y = 0f; val = ((((Vector3)(ref val)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val)).normalized : Vector3.forward); Vector3 returnPosition = MouthPoint() + val * 0.7f + Vector3.up * 0.12f; float num5 = _meal.Succeed(returnPosition, val * 3f + Vector3.up * 1.15f, num4); PhysGrabObjectImpactDetector impactDetector = _mouth.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactLight(96f, _mouth.Phys.centerPoint); } Plugin.Log.LogInfo((object)$"The Broker succeeded ({num2:P0}, x{num4:F2}) and returned the valuable at ${num5:F0}; its next appraisal is riskier and more valuable."); _meal = null; _state = BehaviourState.Neutral; _destinationTimer = 0f; } else { float capturedValue = _meal.CapturedValue; _meal.FailAndDestroy(); _meal = null; Plugin.Log.LogInfo((object)$"The Broker failed ({1f - num2:P0}), permanently digested a ${capturedValue:F0} valuable and became hostile."); BecomeHostile("its appraisal failed"); } } private void BecomeHostile(string reason) { //IL_0023: 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_0038: 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_00ba: Unknown result type (might be due to invalid IL or missing references) if (_state != BehaviourState.Dead && _state != BehaviourState.Hostile) { if (_meal != null) { _meal.CancelAndRestore(MouthPoint() + ((Component)this).transform.forward * 0.65f); _meal = null; } _state = BehaviourState.Hostile; ActivateMouth(); _target = FindNearestLivingPlayer(); _targetTimer = 0f; _destinationTimer = 0f; _hostileWindupTimer = 0.7f; _hostileAccelerationTimer = 0f; StopAgent(); PhysGrabObjectImpactDetector impactDetector = _mouth.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactMedium(100f, _mouth.Phys.centerPoint); } Plugin.Log.LogInfo((object)("The Broker became hostile because " + reason + ".")); } } private void ActivateMouth() { if (!_mouthActivated && !((Object)(object)_mouth?.Root == (Object)null)) { _mouthActivated = true; if ((Object)(object)_mouthTrap != (Object)null) { ((Behaviour)_mouthTrap).enabled = false; } } } private void UpdateHostile(bool grabbed) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00e3: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) _attackTimer = Mathf.Max(0f, _attackTimer - Time.deltaTime); if (!GunAccess.IsLiving(_target)) { ReturnToNeutralPatrol(); return; } if ((Object)(object)_target == (Object)null) { StopAgent(); return; } if (_hostileWindupTimer > 0f) { _hostileWindupTimer = Mathf.Max(0f, _hostileWindupTimer - Time.deltaTime); StopAgent(); return; } _hostileAccelerationTimer += Time.deltaTime; float num = Mathf.Clamp(Plugin.Settings.BrokerAttackRange.Value, 0.7f, 2f); Vector3 val = MouthPoint(); Vector3 val2 = ((Component)_target).transform.position + Vector3.up * 0.55f; if (GunAccess.TryGetPlayerBounds(_target, out var bounds)) { val2 = ((Bounds)(ref bounds)).ClosestPoint(val); } Vector3 val3 = val2 - val; if (Mathf.Abs(val3.y) <= 0.55f && ((Vector3)(ref val3)).sqrMagnitude <= num * num && _attackTimer <= 0f && HasClearPath(_target)) { _attackTimer = 0.34f; int num2 = Mathf.Clamp(Plugin.Settings.BrokerAttackDamage.Value, 1, 100); PlayerHealth playerHealth = _target.playerHealth; if (playerHealth != null) { playerHealth.HurtOther(num2, ((Component)_target).transform.position, false, -1, false); } ModEnemyValuableDamage.BreakLightInCone(MouthPoint(), ((Component)this).transform.forward, num + 0.3f, -0.05f, IsOwnCollider); PhysGrabObjectImpactDetector impactDetector = _mouth.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactMedium(100f, _mouth.Phys.centerPoint); } if (!_firstAttackLogged) { _firstAttackLogged = true; Plugin.Log.LogInfo((object)$"The Broker landed its first hostile bite for {num2} damage."); } } if (!grabbed && !((Object)(object)_agent == (Object)null) && _agent.isOnNavMesh) { float num3 = Mathf.Clamp(Plugin.Settings.BrokerHostileSpeed.Value, 2f, 10f); float num4 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(_hostileAccelerationTimer / 1.75f)); _agent.speed = Mathf.Lerp(Mathf.Min(2.4f, num3), num3, num4); _agent.isStopped = false; _destinationTimer -= Time.deltaTime; if (_destinationTimer <= 0f) { _destinationTimer = 0.12f; _agent.SetDestination(((Component)_target).transform.position); } } } private void ReturnToNeutralPatrol() { _state = BehaviourState.Neutral; _target = null; _targetTimer = 0f; _destinationTimer = 0f; _hostileWindupTimer = 0f; _hostileAccelerationTimer = 0f; _attackTimer = 0f; _firstAttackLogged = false; StopAgent(); Plugin.Log.LogInfo((object)"The Broker finished punishing its grabber and returned to patrol."); } private void PinParts(bool force) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: 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_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_065b: Unknown result type (might be due to invalid IL or missing references) //IL_065c: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Unknown result type (might be due to invalid IL or missing references) //IL_065f: Unknown result type (might be due to invalid IL or missing references) //IL_0664: Unknown result type (might be due to invalid IL or missing references) //IL_0669: Unknown result type (might be due to invalid IL or missing references) //IL_066a: Unknown result type (might be due to invalid IL or missing references) //IL_066c: Unknown result type (might be due to invalid IL or missing references) //IL_0671: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_0677: Unknown result type (might be due to invalid IL or missing references) //IL_067c: Unknown result type (might be due to invalid IL or missing references) //IL_0681: Unknown result type (might be due to invalid IL or missing references) //IL_0686: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_06d2: Unknown result type (might be due to invalid IL or missing references) //IL_0697: Unknown result type (might be due to invalid IL or missing references) //IL_069c: Unknown result type (might be due to invalid IL or missing references) //IL_06b6: Unknown result type (might be due to invalid IL or missing references) //IL_06bb: Unknown result type (might be due to invalid IL or missing references) //IL_05d3: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: Unknown result type (might be due to invalid IL or missing references) //IL_05dc: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Unknown result type (might be due to invalid IL or missing references) //IL_0628: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Unknown result type (might be due to invalid IL or missing references) //IL_0634: Unknown result type (might be due to invalid IL or missing references) //IL_0639: Unknown result type (might be due to invalid IL or missing references) //IL_063d: Unknown result type (might be due to invalid IL or missing references) //IL_0642: Unknown result type (might be due to invalid IL or missing references) //IL_0644: Unknown result type (might be due to invalid IL or missing references) //IL_0646: Unknown result type (might be due to invalid IL or missing references) //IL_064b: Unknown result type (might be due to invalid IL or missing references) //IL_064f: Unknown result type (might be due to invalid IL or missing references) //IL_0654: Unknown result type (might be due to invalid IL or missing references) //IL_0659: Unknown result type (might be due to invalid IL or missing references) bool flag = IsBodyGrabbed(); Quaternion val = ((flag && (Object)(object)_body?.Phys != (Object)null) ? ((Component)_body.Phys).transform.rotation : ((Component)this).transform.rotation); Vector3 position = ((Component)this).transform.position; Vector3 val2; int num; if ((Object)(object)_agent != (Object)null) { val2 = _agent.velocity; if (((Vector3)(ref val2)).sqrMagnitude > 0.15f) { num = ((!flag) ? 1 : 0); goto IL_0083; } } num = 0; goto IL_0083; IL_0083: bool flag2 = (byte)num != 0; float num2 = ((_state == BehaviourState.Hostile) ? 20f : 12f); float num3 = (flag2 ? (Mathf.Sin(Time.time * num2) * 0.025f) : 0f); float num4 = ((_tumbleFlinchTimer > 0f) ? Mathf.Sin(Mathf.Clamp01(_tumbleFlinchTimer / 0.34f) * MathF.PI) : 0f); float num5 = ((_damagePulseTimer > 0f) ? Mathf.Sin(Mathf.Clamp01(_damagePulseTimer / 0.23f) * MathF.PI) : 0f); float num6 = -52f; float num7 = 0f; if (_state == BehaviourState.Digesting) { float num8 = (Mathf.Sin(Time.time * 7.5f) + 1f) * 0.5f; num6 = Mathf.Lerp(-34f, -70f, num8); num7 = num8; } else if (_state == BehaviourState.Hostile) { float num9 = (Mathf.Sin(Time.time * 20f) + 1f) * 0.5f; num6 = Mathf.Lerp(-10f, -84f, num9); num7 = num9; } float num10 = 1f - Mathf.Exp(-10f * Time.deltaTime); float num11 = 1f - Mathf.Exp(-12f * Time.deltaTime); _smoothedLidAngle = Mathf.Lerp(_smoothedLidAngle, num6, num10); _smoothedMouthChew = Mathf.Lerp(_smoothedMouthChew, num7, num11); foreach (SpawnedBrokerPart part in _parts) { if (!part.Alive || (Object)(object)part.Phys == (Object)null) { continue; } part.ImpactDetector.destroyDisable = true; part.Phys.OverrideIndestructible(0.35f); if (part.GeometryCalibrationFrames > 0) { BrokerSpawner.RefreshRenderedGeometry(part); part.GeometryCalibrationFrames--; if (part.GeometryCalibrationFrames == 0) { Plugin.Log.LogInfo((object)$"Broker geometry {part.Role}: scale={part.Root.transform.localScale}, rendered={part.VisualSize}, centerOffset={part.VisualCenterOffset}."); } } UpdatePartLayout(part); float num12 = ((_state == BehaviourState.Hostile) ? Mathf.Clamp(Plugin.Settings.BrokerHostileMass.Value, 1f, 20f) : Mathf.Clamp(Plugin.Settings.BrokerNeutralMass.Value, 0.5f, 12f)); if (part.Role == BrokerPartRole.Body) { part.Phys.OverrideMass(num12, 0.35f); if (flag) { if ((Object)(object)part.Phys.rb != (Object)null) { part.Phys.rb.isKinematic = false; } continue; } part.Phys.OverrideKinematic(0.08f); part.Phys.OverrideZeroGravity(0.35f); part.Phys.OverrideDrag(12f, 0.35f); part.Phys.OverrideAngularDrag(18f, 0.35f); } else { part.Phys.OverrideKinematic(0.35f); part.Phys.OverrideGrabDisable(0.35f); } Vector3 val3 = part.LocalOffset; Quaternion val4 = part.LocalRotation; if (part.Role == BrokerPartRole.Body) { val3.y += num3; val3.z -= num4 * 0.11f; val3.z -= num5 * 0.08f; val4 = Quaternion.AngleAxis(num4 * 12f + num5 * 8f, Vector3.right) * val4; } else if (part.Role == BrokerPartRole.Mouth) { val3.y += num3; val3.z += _smoothedMouthChew * 0.06f; val3.y -= _smoothedMouthChew * 0.03f; val4 = Quaternion.AngleAxis((0f - _smoothedMouthChew) * 26f, Vector3.right) * val4; } else if (part.Role == BrokerPartRole.Lid) { val4 = LidRotation(_smoothedLidAngle - num5 * 15f); val3 = LidVisualCenter(val4); val3.y += num3; } else if (flag2) { float num13 = Mathf.Repeat(Time.time * num2 / (MathF.PI * 2f) + part.GaitPhase, 1f); bool num14 = num13 < 0.31f; float num15 = (num14 ? Mathf.SmoothStep(0f, 1f, num13 / 0.31f) : ((num13 - 0.31f) / 0.69f)); float num16 = (num14 ? Mathf.Lerp(-0.085f, 0.105f, num15) : Mathf.Lerp(0.105f, -0.085f, num15)); float num17 = (num14 ? (Mathf.Sin(num15 * MathF.PI) * 0.09f) : 0f); float num18 = (((part.LegIndex & 1) != 0) ? 1f : (-1f)); Vector3 legStart = part.LegStart; Vector3 legEnd = part.LegEnd; legStart.y += num3 * 0.7f; legEnd.z += num16; legEnd.y += num17; legEnd.x += num18 * num17 * 0.16f; val3 = (legStart + legEnd) * 0.5f; Vector3 longAxisLocal = part.LongAxisLocal; val2 = legEnd - legStart; val4 = Quaternion.FromToRotation(longAxisLocal, ((Vector3)(ref val2)).normalized); } Vector3 val5 = position + val * val3; Quaternion val6 = val * val4; Vector3 val7 = val5 - val6 * part.VisualCenterOffset; if (force || Vector3.Distance(((Component)part.Phys).transform.position, val7) > 0.008f || Quaternion.Angle(((Component)part.Phys).transform.rotation, val6) > 0.4f) { part.Phys.SetPositionLogic(val7, val6); } } } private static Quaternion LidRotation(float openAngle) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_001a: Unknown result type (might be due to invalid IL or missing references) return Quaternion.AngleAxis(openAngle, Vector3.right) * Quaternion.AngleAxis(180f, Vector3.forward); } private void UpdatePartLayout(SpawnedBrokerPart part) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_0192: 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_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: 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_01c2: 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_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) if (_body == null) { return; } float num = Mathf.Clamp(_body.VisualSize.x, 0.34f, 0.68f); float num2 = Mathf.Clamp(_body.VisualSize.y, 0.18f, 0.52f); float num3 = Mathf.Clamp(_body.VisualSize.z, 0.3f, 0.68f); float num4 = 0.17f + num2 * 0.5f; _body.LocalOffset = new Vector3(0f, num4, 0f); if (part.Role != BrokerPartRole.Body) { if (part.Role == BrokerPartRole.Mouth) { part.LocalOffset = new Vector3(0f, num4 + num2 * 0.11f, num3 * 0.07f); part.LocalRotation = Quaternion.AngleAxis(90f, Vector3.right); } else if (part.Role == BrokerPartRole.Lid) { part.LocalOffset = LidVisualCenter(LidRotation(_smoothedLidAngle)); } else if (part.Role == BrokerPartRole.Leg && part.LegIndex >= 0) { bool num5 = (part.LegIndex & 1) != 0; bool flag = part.LegIndex >= 2; float num6 = (num5 ? 1f : (-1f)); float num7 = (flag ? 1f : (-1f)); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(num6 * num * 0.23f, 0.205f, num7 * num3 * 0.18f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(num6 * num * 0.31f, 0.025f, num7 * num3 * 0.3f); part.LegStart = val; part.LegEnd = val2; part.LocalOffset = (val + val2) * 0.5f; Vector3 longAxisLocal = part.LongAxisLocal; Vector3 val3 = val2 - val; part.LocalRotation = Quaternion.FromToRotation(longAxisLocal, ((Vector3)(ref val3)).normalized); } } } private Vector3 LidVisualCenter(Quaternion lidRotation) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(_body.VisualSize.y, 0.18f, 0.52f); float num2 = Mathf.Clamp(_body.VisualSize.z, 0.3f, 0.68f); Vector3 val = new Vector3(0f, 0.17f + num - 0.038f, (0f - num2) * 0.46f); float num3 = num2 * 0.76f; return val + lidRotation * new Vector3(0f, 0f, num3 * 0.5f); } private void UpdateMovementSound() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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 ((Object)(object)_agent == (Object)null) { return; } Vector3 velocity = _agent.velocity; if (((Vector3)(ref velocity)).sqrMagnitude < 0.3f || (Object)(object)_body?.ImpactDetector == (Object)null || (Object)(object)_body.Phys == (Object)null) { return; } _movementSoundTimer -= Time.deltaTime; if (_movementSoundTimer > 0f) { return; } _movementSoundTimer = ((_state == BehaviourState.Hostile) ? Random.Range(0.18f, 0.3f) : Random.Range(0.35f, 0.55f)); SpawnedBrokerPart spawnedBrokerPart = _parts.FirstOrDefault((SpawnedBrokerPart part) => part.Alive && part.Role == BrokerPartRole.Leg && part.LegIndex == (_movementLegCursor++ & 3)); if ((Object)(object)spawnedBrokerPart?.ImpactDetector != (Object)null && (Object)(object)spawnedBrokerPart.Phys != (Object)null) { spawnedBrokerPart.ImpactDetector.ImpactLight(96f, spawnedBrokerPart.Phys.centerPoint); if ((_movementLegCursor & 3) == 0 && (Object)(object)_mouth?.ImpactDetector != (Object)null) { _mouth.ImpactDetector.ImpactLight(100f, _mouth.Phys.centerPoint); } } else { _body.ImpactDetector.ImpactLight(100f, _body.Phys.centerPoint); } } private void UpdateDigestSound() { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) _digestSoundTimer -= Time.deltaTime; if (_digestSoundTimer > 0f) { return; } _digestSoundTimer = 0.11f; if ((_digestSoundBeat++ & 1) == 0) { SpawnedBrokerPart lid = _lid; if (lid != null) { PhysGrabObjectImpactDetector impactDetector = lid.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactLight(100f, _lid.Phys.centerPoint); } } return; } SpawnedBrokerPart mouth = _mouth; if (mouth != null) { PhysGrabObjectImpactDetector impactDetector2 = mouth.ImpactDetector; if (impactDetector2 != null) { impactDetector2.ImpactLight(100f, _mouth.Phys.centerPoint); } } SpawnedBrokerPart body = _body; if (body != null) { PhysGrabObjectImpactDetector impactDetector3 = body.ImpactDetector; if (impactDetector3 != null) { impactDetector3.ImpactLight(84f, _body.Phys.centerPoint); } } } private void UpdateNearMusic() { //IL_0043: 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_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) if (!((Object)(object)MusicEnemyNear.instance == (Object)null) && GunAccess.IsLiving(PlayerAvatar.instance)) { float num = Mathf.Clamp(Plugin.Settings.BrokerNearMusicRange.Value, 3f, 35f); Vector3 val = ((Component)PlayerAvatar.instance).transform.position - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude <= num * num) { MusicEnemyNear.instance.OverrideActive(0.35f); } } } private Vector3 MouthPoint() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_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_0050: 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_0025: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_mouth?.Phys != (Object)null) { return _mouth.Phys.centerPoint; } return ((Component)this).transform.position + Vector3.up * 0.48f + ((Component)this).transform.forward * 0.35f; } internal bool IsIntendedFoodDelivery(PhysGrabObject source) { //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) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (_state != BehaviourState.Neutral || (Object)(object)source == (Object)null || source.dead || !BrokerThrowEligibility.IsArmed(source)) { return false; } ValuableObject val = ((Component)source).GetComponent() ?? ((Component)source).GetComponentInChildren(true); if ((Object)(object)val == (Object)null || MapIconSuppressor.OwnsValuable(val)) { return false; } Vector3 val2 = source.centerPoint - MouthPoint(); if (((Vector3)(ref val2)).sqrMagnitude > 1.21f) { return false; } Vector3 val3 = val2; val3.y = 0f; if (!(((Vector3)(ref val3)).sqrMagnitude < 0.01f)) { return Vector3.Dot(((Component)this).transform.forward, ((Vector3)(ref val3)).normalized) >= -0.1f; } return true; } private PlayerAvatar FindNearestLivingPlayer() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar result = null; float num = float.MaxValue; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { Vector3 val = ((Component)item).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = item; } } } return result; } private bool HasClearPath(PlayerAvatar player) { //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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return false; } Vector3 val = MouthPoint(); Transform val2 = player.PlayerVisionTarget?.VisionTransform; Vector3 val3 = (((Object)(object)val2 != (Object)null) ? val2.position : (((Component)player).transform.position + Vector3.up)) - val; float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude <= 0.1f) { return true; } RaycastHit[] array = Physics.RaycastAll(val, val3 / magnitude, magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val4 = array2[num]; if (!IsOwnCollider(((RaycastHit)(ref val4)).collider) && !((Object)(object)ResolveHitPlayer(((RaycastHit)(ref val4)).collider) == (Object)(object)player) && !((Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent() != (Object)null)) { return false; } } return true; } private bool IsOwnCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } Transform hit = ((Component)collider).transform; return _parts.Any((SpawnedBrokerPart part) => (Object)(object)part.Root != (Object)null && ((Object)(object)hit == (Object)(object)part.Root.transform || hit.IsChildOf(part.Root.transform))); } private static PlayerAvatar ResolveHitPlayer(Collider collider) { object obj = ((collider != null) ? ((Component)collider).GetComponentInParent() : null)?.playerAvatarScript; if (obj == null) { if (collider == null) { return null; } obj = ((Component)collider).GetComponentInParent(); } return (PlayerAvatar)obj; } private void StopAgent() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_agent == (Object)null) && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.velocity = Vector3.zero; } } public bool TryClaimWeaponHit(int bulletInstanceId) { if (!ModEnemyWeaponDamage.TryClaim((Object)(object)this, bulletInstanceId)) { return false; } if (Time.time - _lastClaimedWeaponHitTime < 0.06f) { return false; } _lastClaimedWeaponHitTime = Time.time; return true; } public void ReceiveWeaponHit(Vector3 hitPosition, int damage) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0081: Unknown result type (might be due to invalid IL or missing references) if (_state == BehaviourState.Dead) { return; } damage = ParasiteEffectRegistry.ModifyEnemyDamageAt(hitPosition, Mathf.Max(0, damage)); if (damage != 0) { _health -= damage; SpawnedBrokerPart part = _parts.Where((SpawnedBrokerPart spawnedBrokerPart) => spawnedBrokerPart.Alive && (Object)(object)spawnedBrokerPart.Phys != (Object)null).OrderBy(delegate(SpawnedBrokerPart spawnedBrokerPart) { //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) Vector3 val = spawnedBrokerPart.Phys.centerPoint - hitPosition; return ((Vector3)(ref val)).sqrMagnitude; }).FirstOrDefault(); PlayDamageFeedback(part, hitPosition); if (!_firstHitLogged) { _firstHitLogged = true; Plugin.Log.LogInfo((object)$"The Broker accepted its first weapon hit; HP={Mathf.Max(0, _health)}/{Mathf.Max(1, Plugin.Settings.BrokerHealth.Value)}."); } if (_health <= 0) { Die(); } else { BecomeHostile("it was attacked"); } } } private void PlayDamageFeedback(SpawnedBrokerPart part, Vector3 hitPosition) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) _damagePulseTimer = 0.23f; if (!(_damageFeedbackCooldown > 0f) && !((Object)(object)part?.ImpactDetector == (Object)null)) { _damageFeedbackCooldown = 0.09f; PhysGrabObjectImpactDetector detector = _mouth?.ImpactDetector ?? _body?.ImpactDetector ?? part.ImpactDetector; PhysGrabObject phys = _mouth?.Phys ?? _body?.Phys ?? part.Phys; ModEnemyFeedback.DamageHit(detector, phys, hitPosition, 82f); } } public void ReceiveTumbleAttack(int partIndex, int damage, Vector3 hitPosition, Vector3 direction) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (_state != BehaviourState.Dead) { _health -= Mathf.Max(1, damage); SpawnedBrokerPart part = ((partIndex >= 0 && partIndex < _parts.Count) ? _parts[partIndex] : _body); PlayDamageFeedback(part, hitPosition); if (_health <= 0) { Die(); return; } BecomeHostile("it was struck by a deliberate physical/tumble attack"); _tumbleFlinchTimer = 0.34f; StopAgent(); } } public void ExecuteForLab() { if (_state != BehaviourState.Dead && SemiFunc.IsMasterClientOrSingleplayer()) { _health = 0; Die(); } } private void Die() { //IL_0017: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (_state == BehaviourState.Dead) { return; } _meal?.CancelAndRestore(MouthPoint() + ((Component)this).transform.forward * 0.7f); _meal = null; _state = BehaviourState.Dead; _target = null; StopAgent(); foreach (SpawnedBrokerPart part in _parts) { if (part.Alive) { part.Alive = false; if ((Object)(object)part.ImpactDetector != (Object)null) { part.ImpactDetector.destroyDisable = false; part.ImpactDetector.DestroyObject(true); } else { BrokerSpawner.Destroy(part); } } } _deathTimer = 0.2f; Plugin.Log.LogInfo((object)"The Broker was destroyed. It drops no enemy orb because successful appraisals are its reward economy."); } private void OnDestroy() { //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!_cleaningUp) { _meal?.CancelAndRestore(((Component)this).transform.position + Vector3.up * 0.2f); _meal = null; CleanupParts(effects: false); } } private void CleanupParts(bool effects) { if (_cleaningUp) { return; } _cleaningUp = true; foreach (SpawnedBrokerPart part in _parts) { if (part.Alive) { part.Alive = false; if (effects && (Object)(object)part.ImpactDetector != (Object)null) { part.ImpactDetector.destroyDisable = false; part.ImpactDetector.DestroyObject(true); } else { BrokerSpawner.Destroy(part); } } } _parts.Clear(); } } internal interface IBrokerDamageReceiver { bool TryClaimWeaponHit(int bulletInstanceId); void ReceiveWeaponHit(Vector3 hitPosition, int damage); void ExecuteForLab(); } internal sealed class BrokerHitProxy : MonoBehaviour { private IBrokerDamageReceiver _receiver; private Renderer[] _renderers = Array.Empty(); private PhysGrabObjectImpactDetector[] _detectors = Array.Empty(); private readonly Dictionary _previousBulletPositions = new Dictionary(); private readonly HashSet _currentBulletIds = new HashSet(); private float _cooldown; private static int _cachedBulletFrame = -1; private static ItemGunBullet[] _cachedBullets = Array.Empty(); internal void Initialize(IBrokerDamageReceiver receiver, IEnumerable parts) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown _receiver = receiver; List list = new List(); List list2 = new List(); foreach (SpawnedBrokerPart part in parts) { if (part?.Renderers != null) { list.AddRange(part.Renderers); } if ((Object)(object)part?.ImpactDetector != (Object)null) { list2.Add(part.ImpactDetector); UnityEvent onHurtColliderHit = part.ImpactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.AddListener(new UnityAction(OnHurtColliderHit)); } } } _renderers = list.ToArray(); _detectors = list2.ToArray(); } private void Update() { _cooldown = Mathf.Max(0f, _cooldown - Time.deltaTime); if (_cooldown <= 0f && SemiFunc.IsMasterClientOrSingleplayer()) { DetectExpandedBulletHit(); } } private void OnDestroy() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown PhysGrabObjectImpactDetector[] detectors = _detectors; foreach (PhysGrabObjectImpactDetector obj in detectors) { if (obj != null) { UnityEvent onHurtColliderHit = obj.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.RemoveListener(new UnityAction(OnHurtColliderHit)); } } } } private void OnHurtColliderHit() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (_receiver == null || _cooldown > 0f || !SemiFunc.IsMasterClientOrSingleplayer() || !_receiver.TryClaimWeaponHit(ModEnemyWeaponDamage.CurrentClaimId)) { return; } _cooldown = 0.16f; Vector3 val = ClosestVisualPoint(((Component)this).transform.position); if (EnemyLabBridge.IsExecutionHitNear(val)) { _receiver.ExecuteForLab(); return; } int num = ModEnemyWeaponDamage.CurrentOrFallback(Plugin.Settings.BrokerDamagePerHit.Value); if (num > 0) { _receiver.ReceiveWeaponHit(val, num); } } private void DetectExpandedBulletHit() { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) if (_receiver == null) { return; } if (_cachedBulletFrame != Time.frameCount) { _cachedBulletFrame = Time.frameCount; _cachedBullets = Object.FindObjectsOfType(); } _currentBulletIds.Clear(); ItemGunBullet[] cachedBullets = _cachedBullets; foreach (ItemGunBullet val in cachedBullets) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent() != (Object)null || (Object)(object)val.hurtCollider == (Object)null || !((Component)val.hurtCollider).gameObject.activeInHierarchy) { continue; } int instanceID = ((Object)val).GetInstanceID(); _currentBulletIds.Add(instanceID); Vector3 position = ((Component)val.hurtCollider).transform.position; Vector3 value; bool num = _previousBulletPositions.TryGetValue(instanceID, out value); _previousBulletPositions[instanceID] = position; if (!(num ? SegmentIntersectsVisuals(value, position) : WithinVisuals(position)) || !_receiver.TryClaimWeaponHit(instanceID)) { continue; } _cooldown = 0.22f; if (EnemyLabBridge.IsExecutionHitNear(position)) { _receiver.ExecuteForLab(); return; } int num2 = ModEnemyWeaponDamage.Resolve(val.hurtCollider, Plugin.Settings.BrokerDamagePerHit.Value); if (num2 > 0) { _receiver.ReceiveWeaponHit(position, num2); } return; } if (_previousBulletPositions.Count <= _currentBulletIds.Count) { return; } List list = null; foreach (int key in _previousBulletPositions.Keys) { if (!_currentBulletIds.Contains(key)) { if (list == null) { list = new List(); } list.Add(key); } } foreach (int item in list ?? new List()) { _previousBulletPositions.Remove(item); } } private bool WithinVisuals(Vector3 position) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_005d: 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) float num = Mathf.Clamp(Plugin.Settings.BrokerHitDetectionPadding.Value, 0.12f, 0.7f); float num2 = num * num; Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if ((Object)(object)val != (Object)null && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; if (((Bounds)(ref bounds)).SqrDistance(position) <= num2) { return true; } } } Vector3 val2 = ((Component)this).transform.position + Vector3.up * 0.48f; Vector3 val3 = position - val2; return ((Vector3)(ref val3)).sqrMagnitude <= Mathf.Pow(0.55f + num, 2f); } private bool SegmentIntersectsVisuals(Vector3 start, Vector3 end) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Settings.BrokerHitDetectionPadding.Value, 0.12f, 0.7f); Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if (!((Object)(object)val == (Object)null) && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; ((Bounds)(ref bounds)).Expand(num * 2f); if (SegmentIntersectsBounds(start, end, bounds)) { return true; } } } Vector3 point = ((Component)this).transform.position + Vector3.up * 0.48f; float num2 = 0.55f + num; return DistancePointToSegmentSquared(point, start, end) <= num2 * num2; } private Vector3 ClosestVisualPoint(Vector3 origin) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_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_0084: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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_005c: 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_005f: 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_0077: 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) Vector3 result = ((Component)this).transform.position + Vector3.up * 0.48f; float num = float.MaxValue; Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if (!((Object)(object)val == (Object)null) && val.enabled) { Bounds bounds = val.bounds; Vector3 val2 = ((Bounds)(ref bounds)).ClosestPoint(origin); Vector3 val3 = val2 - origin; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val2; } } } return result; } private static bool SegmentIntersectsBounds(Vector3 start, Vector3 end, Bounds bounds) { //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) //IL_0002: 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_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float num = 0f; float num2 = 1f; for (int i = 0; i < 3; i++) { float num3 = ((Vector3)(ref start))[i]; float num4 = ((Vector3)(ref val))[i]; Vector3 val2; if (Mathf.Abs(num4) < 1E-05f) { val2 = ((Bounds)(ref bounds)).min; if (!(num3 < ((Vector3)(ref val2))[i])) { val2 = ((Bounds)(ref bounds)).max; if (!(num3 > ((Vector3)(ref val2))[i])) { continue; } } return false; } float num5 = 1f / num4; val2 = ((Bounds)(ref bounds)).min; float num6 = (((Vector3)(ref val2))[i] - num3) * num5; val2 = ((Bounds)(ref bounds)).max; float num7 = (((Vector3)(ref val2))[i] - num3) * num5; if (num6 > num7) { float num8 = num7; num7 = num6; num6 = num8; } num = Mathf.Max(num, num6); num2 = Mathf.Min(num2, num7); if (num > num2) { return false; } } return true; } private static float DistancePointToSegmentSquared(Vector3 point, Vector3 start, Vector3 end) { //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) //IL_0002: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_002f: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; Vector3 val2; if (sqrMagnitude <= 1E-06f) { val2 = point - start; return ((Vector3)(ref val2)).sqrMagnitude; } float num = Mathf.Clamp01(Vector3.Dot(point - start, val) / sqrMagnitude); val2 = point - (start + val * num); return ((Vector3)(ref val2)).sqrMagnitude; } } internal sealed class BrokerManager : MonoBehaviour { private int _levelInstanceId; private float _spawnTimer; private bool _attemptFinished; private bool _prefabProbeFinished; private bool _prefabsAvailable; private bool _levelReadyLogged; private BrokerController _encounter; internal void Tick() { if (!IsHostOrSingleplayerReady()) { return; } ProbePrefabs(); LevelGenerator instance = LevelGenerator.Instance; int num = (((Object)(object)instance != (Object)null) ? ((Object)instance).GetInstanceID() : 0); if (num != _levelInstanceId) { ResetForLevel(num); } if (!IsPlayableLevel()) { DestroyCurrentEncounter(); } else if (!((Object)(object)instance == (Object)null) && instance.Generated && !_attemptFinished) { if (!_levelReadyLogged) { _levelReadyLogged = true; Plugin.Log.LogInfo((object)"The Broker detected a generated playable level; automatic spawn timer started."); } _spawnTimer -= Time.deltaTime; if (!(_spawnTimer > 0f)) { _attemptFinished = true; TryCreateEncounter(); } } } private void ResetForLevel(int levelId) { DestroyCurrentEncounter(); BrokerValuableMeal.ClearLevelHistory(); _levelInstanceId = levelId; _spawnTimer = Mathf.Max(0f, Plugin.Settings.BrokerSpawnDelay.Value); _attemptFinished = false; _levelReadyLogged = false; } private void TryCreateEncounter() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) Vector3 position; if (Random.value > Mathf.Clamp01(Plugin.Settings.BrokerSpawnChance.Value)) { Plugin.Log.LogInfo((object)"The Broker skipped this level by spawn chance."); } else if (!_prefabsAvailable && !BrokerSpawner.PrefabsAvailable()) { Plugin.Log.LogWarning((object)"The Broker could not find its vanilla MonkeyBox, Gem Box lid, Chomp Book and Broom resources."); } else if (!TryFindSpawnPosition(out position)) { Plugin.Log.LogWarning((object)"Could not find a valid navigation point for The Broker."); } else { CreateEncounter(position, "automatic"); } } private bool CreateEncounter(Vector3 position, string source) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_001e: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) DestroyCurrentEncounter(); GameObject val = new GameObject("The Broker Encounter (Host Only)"); val.SetActive(false); val.transform.position = position; BrokerController brokerController = val.AddComponent(); if (!brokerController.Initialize(position)) { Object.Destroy((Object)(object)val); Plugin.Log.LogError((object)"The Broker failed to initialize."); return false; } val.SetActive(true); if (!brokerController.ActivateNavigation(position)) { Object.Destroy((Object)(object)val); Plugin.Log.LogError((object)"The Broker failed to activate navigation."); return false; } _encounter = brokerController; Plugin.Log.LogInfo((object)$"The Broker spawned at {position} ({source}); its case, open lid, recessed mouth and legs are vanilla networked objects."); return true; } internal bool DebugSpawnAt(Vector3 requestedPosition) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!IsHostOrSingleplayerReady() || (!ModEnemySpawnCoordinator.IsDirectorRequestActive && (Object)(object)PlayerAvatar.instance == (Object)null) || !IsPlayableLevel()) { Plugin.Log.LogWarning((object)"Enemy Lab rejected The Broker because no non-shop playable host level is active."); return false; } ProbePrefabs(); if (!_prefabsAvailable && !BrokerSpawner.PrefabsAvailable()) { Plugin.Log.LogWarning((object)"Enemy Lab could not load the vanilla resources for The Broker."); return false; } NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requestedPosition, ref val, 12f, -1)) { Plugin.Log.LogWarning((object)$"Enemy Lab could not find NavMesh near {requestedPosition} for The Broker."); return false; } _attemptFinished = true; return CreateEncounter(((NavMeshHit)(ref val)).position, ModEnemySpawnCoordinator.CurrentSpawnSource); } internal void MarkAutomaticAttemptFinished() { int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelInstanceId) { ResetForLevel(num); } _attemptFinished = true; } internal void DebugDespawn() { if (IsHostOrSingleplayerReady()) { _attemptFinished = true; DestroyCurrentEncounter(); Plugin.Log.LogInfo((object)"The Broker despawned by Enemy Lab."); } } private void DestroyCurrentEncounter() { if (!((Object)(object)_encounter == (Object)null)) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); _encounter = null; } } private void ProbePrefabs() { if (!_prefabProbeFinished && !((Object)(object)RunManager.instance == (Object)null)) { _prefabProbeFinished = true; _prefabsAvailable = BrokerSpawner.PrefabsAvailable(); if (_prefabsAvailable) { Plugin.Log.LogInfo((object)("The Broker verified vanilla resources: " + BrokerSpawner.BodyResourcePath + ", " + BrokerSpawner.LidResourcePath + ", " + BrokerSpawner.MouthResourcePath + ", and four Valuables/07 Very Tall/Valuable Wizard Broom parts.")); } else { Plugin.Log.LogWarning((object)"The Broker's vanilla body, lid, mouth or leg resource is unavailable."); } } } private static bool IsHostOrSingleplayerReady() { if ((Object)(object)GameManager.instance == (Object)null) { return false; } try { return !GameManager.Multiplayer() || PhotonNetwork.IsMasterClient; } catch { return false; } } private static bool IsPlayableLevel() { return ModEnemyLevelRules.IsPlayableLevel(); } private static bool TryFindSpawnPosition(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; PlayerAvatar val = null; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { val = item; break; } } Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(val2, 18f, 60f, false); if ((Object)(object)val3 == (Object)null) { val3 = SemiFunc.LevelPointGetFurthestFromPlayer(val2, 7f); } return ModEnemyNavigation.TryFindClearSpawn(((Object)(object)val3 != (Object)null) ? ((Component)val3).transform.position : (val2 + Vector3.forward * 20f), 8f, out position); } } internal sealed class BrokerReturnedValuableSafety : MonoBehaviour { private PhysGrabObject _phys; private PhysGrabObjectImpactDetector _impact; private bool _originalDestroyDisable; private bool _protectionRestored; private bool _wasGrabbed; private float _protectionTimer; internal static void Arm(PhysGrabObject phys, PhysGrabObjectImpactDetector impact, bool originalDestroyDisable, float protectionSeconds) { if (!((Object)(object)phys == (Object)null)) { BrokerReturnedValuableSafety obj = ((Component)phys).GetComponent() ?? ((Component)phys).gameObject.AddComponent(); obj._phys = phys; obj._impact = impact; obj._originalDestroyDisable = originalDestroyDisable; obj._protectionRestored = false; obj._wasGrabbed = false; obj._protectionTimer = Mathf.Max(0.25f, protectionSeconds); obj.ApplyProtection(); } } internal static bool CanBrokerCapture(PhysGrabObject phys) { if ((Object)(object)phys == (Object)null) { return false; } return (Object)(object)((Component)phys).GetComponent() == (Object)null; } private void Update() { if ((Object)(object)_phys == (Object)null) { Object.Destroy((Object)(object)this); return; } _protectionTimer = Mathf.Max(0f, _protectionTimer - Time.deltaTime); if (_protectionTimer > 0f) { ApplyProtection(); } else if (!_protectionRestored) { RestoreProtectionState(); } if (_phys.grabbed || _phys.grabbedLocal || _phys.playerGrabbing.Count > 0) { _wasGrabbed = true; } else if (_wasGrabbed && _protectionRestored) { Object.Destroy((Object)(object)this); } } private void ApplyProtection() { if ((Object)(object)_impact != (Object)null) { _impact.destroyDisable = true; } _phys.OverrideIndestructible(0.35f); } private void RestoreProtectionState() { _protectionRestored = true; if ((Object)(object)_impact != (Object)null) { _impact.destroyDisable = _originalDestroyDisable; } _phys.ResetIndestructible(); } private void OnDestroy() { if (!_protectionRestored && (Object)(object)_phys != (Object)null) { RestoreProtectionState(); } } } internal enum BrokerPartRole { Body, Lid, Mouth, Leg } internal sealed class SpawnedBrokerPart { internal GameObject Root; internal PhysGrabObject Phys; internal PhysGrabObjectImpactDetector ImpactDetector; internal ItemAttributes Attributes; internal Renderer[] Renderers; internal Collider[] Colliders; internal BrokerPartRole Role; internal Vector3 VisualCenterOffset; internal Vector3 VisualSize; internal Vector3 LongAxisLocal = Vector3.up; internal bool LongAxisCalibrated; internal Vector3 LocalOffset; internal Quaternion LocalRotation; internal float GaitPhase; internal int LegIndex = -1; internal Vector3 LegStart; internal Vector3 LegEnd; internal int GeometryCalibrationFrames = 20; internal bool Alive = true; } internal static class BrokerSpawner { internal const string LegResourcePath = "Valuables/07 Very Tall/Valuable Wizard Broom"; private static readonly string[] SizeFolders = new string[7] { "02 Small", "03 Medium", "04 Big", "05 Wide", "01 Tiny", "06 Tall", "07 Very Tall" }; private static string _bodyResourcePath; private static string _lidResourcePath; private static string _mouthResourcePath; private static bool _resolved; internal static string BodyResourcePath { get { ResolveResources(); return _bodyResourcePath; } } internal static string MouthResourcePath { get { ResolveResources(); return _mouthResourcePath; } } internal static string LidResourcePath { get { ResolveResources(); return _lidResourcePath; } } internal static bool PrefabsAvailable() { ResolveResources(); if (!string.IsNullOrEmpty(_bodyResourcePath) && !string.IsNullOrEmpty(_lidResourcePath) && !string.IsNullOrEmpty(_mouthResourcePath)) { return (Object)(object)Resources.Load("Valuables/07 Very Tall/Valuable Wizard Broom") != (Object)null; } return false; } private static void ResolveResources() { if (!_resolved) { _resolved = true; _bodyResourcePath = FindValuable("Valuable Manor Music Box"); if (string.IsNullOrEmpty(_bodyResourcePath)) { _bodyResourcePath = FindValuable("Valuable Museum MonkeyBox"); } _lidResourcePath = FindValuable("Valuable Wizard Gem Box"); _mouthResourcePath = FindValuable("Valuable Wizard Chomp Book"); } } private static string FindValuable(string prefabName) { string[] sizeFolders = SizeFolders; foreach (string text in sizeFolders) { string text2 = "Valuables/" + text + "/" + prefabName; if ((Object)(object)Resources.Load(text2) != (Object)null) { return text2; } } return null; } internal static SpawnedBrokerPart Spawn(string resourcePath, Vector3 position, Quaternion rotation, Vector3 scaleMultiplier, BrokerPartRole role, bool grabbable) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00a8: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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) GameObject val = Resources.Load(resourcePath); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("The Broker could not load vanilla resource '" + resourcePath + "'.")); return null; } ((Vector3)(ref scaleMultiplier))..ctor(Mathf.Clamp(scaleMultiplier.x, 0.035f, 1.35f), Mathf.Clamp(scaleMultiplier.y, 0.035f, 1.35f), Mathf.Clamp(scaleMultiplier.z, 0.035f, 1.35f)); Vector3 val2 = Vector3.Scale(val.transform.localScale, scaleMultiplier); object[] array = new object[3] { val2.x, val2.y, val2.z }; GameObject val3; try { val3 = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject(resourcePath, position, rotation, (byte)0, array) : Object.Instantiate(val, position, rotation)); } catch (Exception arg) { Plugin.Log.LogError((object)$"The Broker failed to network-spawn '{resourcePath}': {arg}"); return null; } if ((Object)(object)val3 == (Object)null) { return null; } val3.transform.localScale = val2; EncounterValuableNeutralizer.Apply(val3); Trap[] componentsInChildren = val3.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Behaviour)componentsInChildren[i]).enabled = false; } MusicalValuableLogic[] componentsInChildren2 = val3.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { ((Behaviour)componentsInChildren2[i]).enabled = false; } SpawnedBrokerPart spawnedBrokerPart = new SpawnedBrokerPart { Root = val3, Phys = val3.GetComponentInChildren(true), ImpactDetector = val3.GetComponentInChildren(true), Attributes = val3.GetComponentInChildren(true), Renderers = val3.GetComponentsInChildren(true), Colliders = val3.GetComponentsInChildren(true), Role = role }; if ((Object)(object)spawnedBrokerPart.Phys == (Object)null || (Object)(object)spawnedBrokerPart.ImpactDetector == (Object)null) { Plugin.Log.LogError((object)("The Broker resource '" + resourcePath + "' lacks vanilla physical components.")); Destroy(spawnedBrokerPart); return null; } RefreshRenderedGeometry(spawnedBrokerPart); ItemAttributes attributes = spawnedBrokerPart.Attributes; if (attributes != null) { attributes.DisableUI(true); } spawnedBrokerPart.ImpactDetector.destroyDisable = true; spawnedBrokerPart.Phys.OverrideIndestructible(1f); if (!grabbable) { spawnedBrokerPart.Phys.OverrideGrabDisable(1f); spawnedBrokerPart.Phys.OverrideKinematic(1f); } else { spawnedBrokerPart.Phys.clientNonKinematic = true; } MapIconSuppressor.Attach(val3); return spawnedBrokerPart; } internal static void RefreshRenderedGeometry(SpawnedBrokerPart part) { //IL_0021: 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_00f7: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_018d: 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_0086: 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) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)part?.Phys == (Object)null || part.Renderers == null) { return; } bool flag = false; Bounds val = default(Bounds); Renderer[] renderers = part.Renderers; foreach (Renderer val2 in renderers) { if ((Object)(object)val2 == (Object)null || !val2.enabled || (!(val2 is MeshRenderer) && !(val2 is SkinnedMeshRenderer))) { continue; } Bounds bounds = val2.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!(((Vector3)(ref size)).sqrMagnitude < 1E-06f) && !(((Bounds)(ref bounds)).size.x > 8f) && !(((Bounds)(ref bounds)).size.y > 8f) && !(((Bounds)(ref bounds)).size.z > 8f)) { if (!flag) { val = bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(bounds); } } } if (flag) { Transform transform = ((Component)part.Phys).transform; part.VisualCenterOffset = Quaternion.Inverse(transform.rotation) * (((Bounds)(ref val)).center - transform.position); part.VisualSize = ((Bounds)(ref val)).size; if (!part.LongAxisCalibrated) { Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(Mathf.Abs(Vector3.Dot(((Bounds)(ref val)).size, transform.right)), Mathf.Abs(Vector3.Dot(((Bounds)(ref val)).size, transform.up)), Mathf.Abs(Vector3.Dot(((Bounds)(ref val)).size, transform.forward))); part.LongAxisLocal = ((val3.x >= val3.y && val3.x >= val3.z) ? Vector3.right : ((val3.y >= val3.z) ? Vector3.up : Vector3.forward)); part.LongAxisCalibrated = true; } } } internal static void Destroy(SpawnedBrokerPart part) { if (!((Object)(object)part?.Root == (Object)null)) { if (GameManager.Multiplayer()) { PhotonNetwork.Destroy(part.Root); } else { Object.Destroy((Object)(object)part.Root); } part.Alive = false; } } } internal static class BrokerThrowEligibility { private sealed class State { internal bool SawPlayerGrab; internal bool Held; internal float ArmedUntil; } private const float ThrowWindowSeconds = 8f; private static readonly Dictionary States = new Dictionary(); internal static void ClearLevelHistory() { States.Clear(); } internal static void MarkGrabbed(PhysGrabObject phys) { if (!((Object)(object)phys == (Object)null) && SemiFunc.IsMasterClientOrSingleplayer()) { int instanceID = ((Object)phys).GetInstanceID(); if (!States.TryGetValue(instanceID, out var value)) { value = new State(); States[instanceID] = value; } value.SawPlayerGrab = true; value.Held = true; value.ArmedUntil = 0f; } } internal static void MarkReleased(PhysGrabObject phys) { if (!((Object)(object)phys == (Object)null) && SemiFunc.IsMasterClientOrSingleplayer() && !phys.grabbedLocal && phys.playerGrabbing.Count <= 0) { int instanceID = ((Object)phys).GetInstanceID(); if (States.TryGetValue(instanceID, out var value) && value.SawPlayerGrab) { value.Held = false; value.ArmedUntil = Time.time + 8f; } } } internal static bool IsArmed(PhysGrabObject phys) { if ((Object)(object)phys == (Object)null || phys.grabbed || phys.grabbedLocal || phys.playerGrabbing.Count > 0 || !States.TryGetValue(((Object)phys).GetInstanceID(), out var value)) { return false; } if (value.SawPlayerGrab && !value.Held) { return Time.time <= value.ArmedUntil; } return false; } internal static void Consume(PhysGrabObject phys) { if ((Object)(object)phys != (Object)null && States.TryGetValue(((Object)phys).GetInstanceID(), out var value)) { value.ArmedUntil = 0f; } } } [HarmonyPatch(typeof(PhysGrabObject), "GrabStarted")] internal static class BrokerGrabStartedPatch { private static void Postfix(PhysGrabObject __instance) { BrokerThrowEligibility.MarkGrabbed(__instance); } } [HarmonyPatch(typeof(PhysGrabObject), "GrabEnded")] internal static class BrokerGrabEndedPatch { private static void Postfix(PhysGrabObject __instance) { BrokerThrowEligibility.MarkReleased(__instance); } } [HarmonyPatch(typeof(PhysGrabObject), "GrabPlayerAddRPC")] internal static class BrokerGrabPlayerAddRpcPatch { private static void Postfix(PhysGrabObject __instance) { BrokerThrowEligibility.MarkGrabbed(__instance); } } [HarmonyPatch(typeof(PhysGrabObject), "GrabPlayerRemoveRPC")] internal static class BrokerGrabPlayerRemoveRpcPatch { private static void Postfix(PhysGrabObject __instance) { BrokerThrowEligibility.MarkReleased(__instance); } } internal sealed class BrokerValuableMeal { private const BindingFlags InstanceFields = BindingFlags.Instance | BindingFlags.NonPublic; private static readonly HashSet Claimed = new HashSet(); private static readonly Dictionary SuccessfulAppraisals = new Dictionary(); private static readonly FieldInfo DollarValueCurrent = typeof(ValuableObject).GetField("dollarValueCurrent", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo ItemDisableUi = typeof(ItemAttributes).GetField("disableUI", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo RoundHaulGoalMax = typeof(RoundDirector).GetField("haulGoalMax", BindingFlags.Instance | BindingFlags.NonPublic); private readonly int _instanceId; private readonly Quaternion _originalRotation; private readonly bool _originalDestroyDisable; private readonly bool _originalUiDisabled; private bool _finished; internal ValuableObject Valuable { get; } internal PhysGrabObject Phys { get; } internal PhysGrabObjectImpactDetector ImpactDetector { get; } internal ItemAttributes Attributes { get; } internal float CapturedValue { get; } internal int PreviousSuccesses { get; } private BrokerValuableMeal(ValuableObject valuable, PhysGrabObject phys, PhysGrabObjectImpactDetector impactDetector, ItemAttributes attributes, float originalValue) { //IL_005c: 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) Valuable = valuable; Phys = phys; ImpactDetector = impactDetector; Attributes = attributes; CapturedValue = originalValue; _instanceId = ((Object)valuable).GetInstanceID(); PreviousSuccesses = (SuccessfulAppraisals.TryGetValue(_instanceId, out var value) ? value : 0); _originalRotation = ((Component)phys).transform.rotation; _originalDestroyDisable = (Object)(object)impactDetector != (Object)null && impactDetector.destroyDisable; bool flag = default(bool); int num; if ((Object)(object)attributes != (Object)null) { object obj = ItemDisableUi?.GetValue(attributes); if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } } else { num = 0; } _originalUiDisabled = (byte)((uint)num & (flag ? 1u : 0u)) != 0; } internal static void ClearLevelHistory() { Claimed.Clear(); SuccessfulAppraisals.Clear(); BrokerThrowEligibility.ClearLevelHistory(); } internal static bool TryCapture(ValuableObject valuable, float maximumSize, out BrokerValuableMeal meal) { meal = null; if ((Object)(object)valuable == (Object)null || MapIconSuppressor.OwnsValuable(valuable)) { return false; } int instanceID = ((Object)valuable).GetInstanceID(); if (Claimed.Contains(instanceID)) { return false; } PhysGrabObject val = ((Component)valuable).GetComponent() ?? ((Component)valuable).GetComponentInParent(); if ((Object)(object)val == (Object)null || val.dead || val.grabbed || val.grabbedLocal || val.playerGrabbing.Count > 0 || !((Component)val).gameObject.activeInHierarchy) { return false; } if (!BrokerReturnedValuableSafety.CanBrokerCapture(val)) { return false; } if (!BrokerThrowEligibility.IsArmed(val)) { return false; } float num = ((DollarValueCurrent?.GetValue(valuable) is float num2) ? num2 : 0f); if (num <= 0f || LargestRenderedDimension(((Component)val).gameObject) > maximumSize) { return false; } PhysGrabObjectImpactDetector component = ((Component)val).GetComponent(); meal = new BrokerValuableMeal(valuable, val, component, ((Component)val).GetComponent(), num); BrokerThrowEligibility.Consume(val); Claimed.Add(instanceID); return true; } private static float LargestRenderedDimension(GameObject root) { //IL_0004: 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_00e3: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) bool flag = false; Bounds val = default(Bounds); Renderer[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && val2.enabled && (val2 is MeshRenderer || val2 is SkinnedMeshRenderer)) { if (!flag) { val = val2.bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(val2.bounds); } } } if (!flag) { Collider[] componentsInChildren2 = root.GetComponentsInChildren(true); foreach (Collider val3 in componentsInChildren2) { if (!((Object)(object)val3 == (Object)null) && val3.enabled && !val3.isTrigger) { if (!flag) { val = val3.bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(val3.bounds); } } } } if (!flag) { return float.MaxValue; } return Mathf.Max(new float[3] { ((Bounds)(ref val)).size.x, ((Bounds)(ref val)).size.y, ((Bounds)(ref val)).size.z }); } internal void ParkBelow(Vector3 anchor) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0083: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if (!_finished && !((Object)(object)Phys == (Object)null)) { if ((Object)(object)ImpactDetector != (Object)null) { ImpactDetector.destroyDisable = true; } ItemAttributes attributes = Attributes; if (attributes != null) { attributes.DisableUI(true); } Phys.OverrideKinematic(0.35f); Phys.OverrideGrabDisable(0.35f); Phys.OverrideIndestructible(0.35f); Vector3 val = anchor + Vector3.down * 35f; Vector3 val2 = ((Component)Phys).transform.position - val; if (((Vector3)(ref val2)).sqrMagnitude > 0.01f) { Phys.SetPositionLogic(val, _originalRotation); } } } internal float Succeed(Vector3 returnPosition, Vector3 returnVelocity, float multiplier) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) if (_finished || (Object)(object)Phys == (Object)null || (Object)(object)Valuable == (Object)null) { return 0f; } _finished = true; Claimed.Remove(_instanceId); SuccessfulAppraisals[_instanceId] = PreviousSuccesses + 1; float num = Mathf.Max(1f, Mathf.Round(CapturedValue * multiplier)); PhotonView component = ((Component)Phys).GetComponent(); if (GameManager.Multiplayer() && (Object)(object)component != (Object)null) { component.RPC("DollarValueSetRPC", (RpcTarget)0, new object[1] { num }); } else { Valuable.DollarValueSetRPC(num, default(PhotonMessageInfo)); } if ((Object)(object)RoundDirector.instance != (Object)null && RoundHaulGoalMax?.GetValue(RoundDirector.instance) is int num2) { RoundHaulGoalMax.SetValue(RoundDirector.instance, num2 + Mathf.RoundToInt(num - CapturedValue)); } if ((Object)(object)ImpactDetector != (Object)null) { ImpactDetector.destroyDisable = _originalDestroyDisable; } ItemAttributes attributes = Attributes; if (attributes != null) { attributes.DisableUI(_originalUiDisabled); } Phys.ResetIndestructible(); Phys.SetPositionLogic(returnPosition, _originalRotation); if ((Object)(object)Phys.rb != (Object)null && !Phys.rb.isKinematic) { Phys.rb.isKinematic = false; Phys.rb.useGravity = true; Phys.rb.velocity = returnVelocity; Phys.rb.angularVelocity = Random.insideUnitSphere * 1.8f; Phys.rb.WakeUp(); } BrokerReturnedValuableSafety.Arm(Phys, ImpactDetector, _originalDestroyDisable, 2f); return num; } internal void FailAndDestroy() { if (_finished) { return; } _finished = true; Claimed.Remove(_instanceId); SuccessfulAppraisals.Remove(_instanceId); if ((Object)(object)ImpactDetector != (Object)null) { ImpactDetector.destroyDisable = false; ImpactDetector.DestroyObject(true); } else if ((Object)(object)Phys != (Object)null) { PhotonView component = ((Component)Phys).GetComponent(); if (GameManager.Multiplayer() && (Object)(object)component != (Object)null) { PhotonNetwork.Destroy(((Component)component).gameObject); } else { Object.Destroy((Object)(object)((Component)Phys).gameObject); } } } internal void CancelAndRestore(Vector3 returnPosition) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00dc: Unknown result type (might be due to invalid IL or missing references) if (_finished) { return; } _finished = true; Claimed.Remove(_instanceId); if (!((Object)(object)Phys == (Object)null)) { if ((Object)(object)ImpactDetector != (Object)null) { ImpactDetector.destroyDisable = _originalDestroyDisable; } ItemAttributes attributes = Attributes; if (attributes != null) { attributes.DisableUI(_originalUiDisabled); } Phys.ResetIndestructible(); Phys.SetPositionLogic(returnPosition + Vector3.up * 0.15f, _originalRotation); if ((Object)(object)Phys.rb != (Object)null && !Phys.rb.isKinematic) { Phys.rb.velocity = Vector3.zero; Phys.rb.angularVelocity = Vector3.zero; } } } } internal sealed class CarouselController : MonoBehaviour, IModEnemyTumbleReceiver { private sealed class OrbitGun { internal int Index; internal SpawnedGun Spawned; internal int Health; internal bool Alive; internal Quaternion MuzzleLocalRotation; internal float HitWobble; internal Vector3 ShotAimPoint; internal Vector3 ShotAimDirection; internal PlayerAvatar ShotTarget; internal bool PendingFire; internal float AimBlend; internal float AimHoldTimer; internal float WallRadius; internal float WallRadiusVelocity; internal bool WallRadiusInitialized; } private enum CombatState { Roaming, Warning, Bursting, Cooldown, Dead } private readonly List _guns = new List(); private NavMeshAgent _agent; private PlayerAvatar _target; private CombatState _combatState; private Vector3 _roamDestination; private float _roamTimer; private float _combatTimer; private float _shotTimer; private float _orbitAngle; private int _shotsRemaining; private int _nextGunIndex; private bool _initialized; private bool _cleaningUp; private bool _firstShotLogged; private bool _shootFailureLogged; private bool _firstDamageLogged; private bool _firstProjectileHitLogged; private bool _firstObjectDamageLogged; private bool _firstExpandedHitLogged; private readonly HashSet _claimedWeaponBullets = new HashSet(); private float _lastClaimedWeaponHitTime = -999f; private float _lastAcquireLogTime = -999f; private bool _rewardDropped; private bool _deathSequenceActive; private float _deathRewardTimer; private float _patrolSoundTimer; private float _patrolPulseTimer; private int _patrolPulsesRemaining; private int _patrolPulseCursor; private bool _firstPatrolSoundLogged; private Vector3 OrbitCenter => ((Component)this).transform.position + Vector3.up * 1.35f; private float SafeOrbitRadius => Mathf.Clamp(Plugin.Settings.OrbitRadius.Value, 0.1f, 0.42f); public bool CanReceiveTumbleAttack { get { if (_initialized) { return _combatState != CombatState.Dead; } return false; } } private int AliveGunCount => _guns.Count((OrbitGun gun) => gun.Alive && (Object)(object)gun.Spawned?.Phys != (Object)null); internal bool Initialize(Item tranqGunItem, Vector3 position) { //IL_0006: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_00f7: 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_00fe: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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_0199: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; _agent = ((Component)this).gameObject.AddComponent(); ((Behaviour)_agent).enabled = false; _agent.speed = Mathf.Max(0.5f, Plugin.Settings.RoamSpeed.Value); _agent.acceleration = 12f; _agent.angularSpeed = 720f; _agent.radius = 0.45f; _agent.height = 1.4f; _agent.stoppingDistance = 0.5f; _agent.autoBraking = true; for (int i = 0; i < 3; i++) { float num = (float)i * 120f * (MathF.PI / 180f); float safeOrbitRadius = SafeOrbitRadius; Vector3 position2 = OrbitCenter + (Vector3.right * Mathf.Cos(num) + Vector3.up * Mathf.Sin(num)) * safeOrbitRadius; SpawnedGun spawnedGun = VanillaGunSpawner.Spawn(tranqGunItem, position2, tranqGunItem.spawnRotationOffset, Plugin.Settings.GunVisualScale.Value); if (spawnedGun == null) { CleanupGuns(); return false; } OrbitGun item = new OrbitGun { Index = i, Spawned = spawnedGun, Health = Mathf.Max(1, Plugin.Settings.GunHealth.Value), Alive = true, WallRadius = safeOrbitRadius, WallRadiusInitialized = true, MuzzleLocalRotation = Quaternion.Inverse(((Component)spawnedGun.Phys).transform.rotation) * spawnedGun.Gun.gunMuzzle.rotation }; _guns.Add(item); spawnedGun.Gun.gunRandomSpread = Mathf.Max(spawnedGun.Gun.gunRandomSpread, Plugin.Settings.AimSpread.Value); ((Component)spawnedGun.Phys).gameObject.AddComponent().Initialize(this, i, spawnedGun.ImpactDetector, spawnedGun.Root.GetComponentsInChildren(true)); ((Component)spawnedGun.Phys).gameObject.AddComponent().Initialize(this, i); } _combatState = CombatState.Roaming; _roamTimer = 0f; _patrolSoundTimer = Random.Range(1.25f, 2.25f); _initialized = true; UpdateGunTransforms(); return true; } internal bool ActivateNavigation(Vector3 requestedPosition) { //IL_000e: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if ((Object)(object)_agent == (Object)null || !NavMesh.SamplePosition(requestedPosition, ref val, 4f, -1)) { Plugin.Log.LogError((object)"Host-side navigation could not find a NavMesh point during activation."); return false; } ((Component)this).transform.position = ((NavMeshHit)(ref val)).position; ((Behaviour)_agent).enabled = true; if (!_agent.isOnNavMesh && !_agent.Warp(((NavMeshHit)(ref val)).position)) { Plugin.Log.LogError((object)"Host-side NavMeshAgent could not be placed on the NavMesh."); return false; } if (!_agent.isOnNavMesh) { Plugin.Log.LogError((object)"Host-side NavMeshAgent remained outside the NavMesh after activation."); return false; } Plugin.Log.LogInfo((object)$"The Carousel navigation is active at {((NavMeshHit)(ref val)).position}."); return true; } private void Update() { if (_initialized && SemiFunc.IsMasterClientOrSingleplayer()) { UpdateNearMusic(); if (_combatState == CombatState.Dead) { UpdateDeathSequence(); return; } UpdateTarget(); UpdateNavigation(); UpdateCombat(); UpdatePatrolSound(); UpdateGunTransforms(); } } private void UpdatePatrolSound() { if (_patrolPulsesRemaining > 0) { _patrolPulseTimer -= Time.deltaTime; if (_patrolPulseTimer <= 0f) { EmitPatrolClink(); _patrolPulsesRemaining--; _patrolPulseTimer = 0.0525f; } return; } _patrolSoundTimer -= Time.deltaTime; if (!(_patrolSoundTimer > 0f)) { _patrolSoundTimer = Random.Range(1.6f, 2.75f); if (_combatState == CombatState.Roaming) { _patrolPulsesRemaining = Mathf.Min(3, AliveGunCount); _patrolPulseTimer = 0f; } } } private void EmitPatrolClink() { //IL_0077: 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_008c: Unknown result type (might be due to invalid IL or missing references) if (_combatState != CombatState.Roaming) { _patrolPulsesRemaining = 0; return; } List list = _guns.Where((OrbitGun gun) => gun.Alive && (Object)(object)gun.Spawned?.ImpactDetector != (Object)null && (Object)(object)gun.Spawned.Phys != (Object)null).ToList(); if (list.Count != 0) { OrbitGun orbitGun = list[_patrolPulseCursor++ % list.Count]; Vector3 position = ((Component)orbitGun.Spawned.Phys).transform.position; orbitGun.Spawned.ImpactDetector.ImpactLight(100f, position); if (!_firstPatrolSoundLogged) { _firstPatrolSoundLogged = true; Plugin.Log.LogInfo((object)"The Carousel emitted its first quiet networked patrol clink through a vanilla gun RPC."); } } } internal void HurtGun(int gunIndex, int damage) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) OrbitGun orbitGun = _guns.FirstOrDefault((OrbitGun candidate) => candidate.Index == gunIndex); if (orbitGun == null || !orbitGun.Alive || _combatState == CombatState.Dead) { return; } damage = ParasiteEffectRegistry.ModifyEnemyDamageAt(orbitGun.Spawned.Phys.centerPoint, damage); orbitGun.Health -= Mathf.Max(1, damage); orbitGun.HitWobble = 1f; Plugin.Log.LogDebug((object)$"Carousel gun {gunIndex + 1} hurt for {damage}; HP={Mathf.Max(0, orbitGun.Health)}."); if (orbitGun.Health > 0) { PlayGunHitEffect(orbitGun); return; } orbitGun.Alive = false; DestroyGunWithEffects(orbitGun); Plugin.Log.LogInfo((object)$"Carousel gun {gunIndex + 1} destroyed. {AliveGunCount} remain."); if (AliveGunCount == 0) { _combatState = CombatState.Dead; _target = null; if ((Object)(object)_agent != (Object)null && _agent.isOnNavMesh) { _agent.ResetPath(); _agent.isStopped = true; } _deathSequenceActive = true; _deathRewardTimer = 0.08f; Plugin.Log.LogInfo((object)"The Carousel is breaking apart; reward release is nearly immediate."); } } public void ReceiveTumbleAttack(int partIndex, int damage, Vector3 hitPosition, Vector3 direction) { HurtGun(partIndex, damage); } internal bool TryClaimWeaponHit(int bulletInstanceId) { if (!ModEnemyWeaponDamage.TryClaim((Object)(object)this, bulletInstanceId)) { return false; } if (Time.time - _lastClaimedWeaponHitTime < 0.06f) { return false; } _lastClaimedWeaponHitTime = Time.time; return true; } internal void ReportExpandedHit() { if (!_firstExpandedHitLogged) { _firstExpandedHitLogged = true; Plugin.Log.LogInfo((object)"The Carousel expanded visual-bounds hit detection accepted a nearby gun impact."); } } internal void ExecuteForLab() { if (_combatState == CombatState.Dead || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } Plugin.Log.LogInfo((object)"Enemy Lab execution round hit The Carousel; destroying all guns."); foreach (OrbitGun item in _guns.Where((OrbitGun candidate) => candidate.Alive).ToList()) { HurtGun(item.Index, Mathf.Max(1, item.Health)); } } private static void DestroyGunWithEffects(OrbitGun gun) { if ((Object)(object)gun?.Spawned?.ImpactDetector != (Object)null) { gun.Spawned.ImpactDetector.destroyDisable = false; gun.Spawned.ImpactDetector.DestroyObject(true); } else { if (gun == null) { return; } SpawnedGun spawned = gun.Spawned; if (spawned != null) { PhysGrabObject phys = spawned.Phys; if (phys != null) { phys.DestroyPhysGrabObject(); } } } } private static void PlayGunHitEffect(OrbitGun gun) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)gun?.Spawned?.ImpactDetector == (Object)null) && !((Object)(object)gun.Spawned.Phys == (Object)null)) { ModEnemyFeedback.DamageHit(gun.Spawned.ImpactDetector, gun.Spawned.Phys, gun.Spawned.Phys.centerPoint, 78f); } } private void UpdateDeathSequence() { if (_deathSequenceActive) { _deathRewardTimer -= Time.deltaTime; if (!(_deathRewardTimer > 0f)) { _deathSequenceActive = false; DropEnemyReward(); Plugin.Log.LogInfo((object)"The Carousel death effect finished and its reward was released."); } } } private float EffectiveShotInterval() { float num = Mathf.Clamp(Plugin.Settings.ShotInterval.Value, 0.35f, 4f); int num2 = Mathf.Max(0, _guns.Count - AliveGunCount); float num3 = 1f - (float)num2 * 0.15f; return Mathf.Max(0.35f, num * num3); } private void UpdateNearMusic() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (_combatState == CombatState.Dead || (Object)(object)MusicEnemyNear.instance == (Object)null) { return; } PlayerAvatar instance = PlayerAvatar.instance; if (GunAccess.IsLiving(instance)) { float num = Mathf.Max(3f, Plugin.Settings.NearMusicRange.Value); Vector3 val = ((Component)instance).transform.position - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude <= num * num) { MusicEnemyNear.instance.OverrideActive(0.35f); } } } private void DropEnemyReward() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00cc: 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) if (_rewardDropped || !Plugin.Settings.DropEnemyValuable.Value) { return; } _rewardDropped = true; AssetManager instance = AssetManager.instance; if ((Object)(object)instance == (Object)null) { Plugin.Log.LogWarning((object)"The Carousel could not drop an enemy orb because AssetManager was unavailable."); return; } int num = Mathf.Clamp(Plugin.Settings.RewardTier.Value, 1, 3); GameObject val = (GameObject)(num switch { 2 => instance.enemyValuableMedium, 1 => instance.enemyValuableSmall, _ => instance.enemyValuableBig, }); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)$"The Carousel enemy orb tier {num} prefab was unavailable."); return; } Vector3 val2 = OrbitCenter + Vector3.up * 0.25f; if (GameManager.Multiplayer()) { PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)val).name, val2, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate(val, val2, Quaternion.identity); } Plugin.Log.LogInfo((object)("The Carousel dropped one " + num switch { 2 => "medium", 1 => "small", _ => "big", } + " enemy orb.")); } private void UpdateTarget() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) if (_combatState == CombatState.Dead) { _target = null; } else { if (GunAccess.IsLiving(_target) && CanSee(_target)) { return; } PlayerAvatar target = _target; _target = null; float num = float.MaxValue; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item) && CanSee(item)) { Vector3 val = ((Component)item).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; _target = item; } } } if ((Object)(object)_target != (Object)null && (Object)(object)_target != (Object)(object)target && Time.time - _lastAcquireLogTime >= 5f) { _lastAcquireLogTime = Time.time; float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)_target).transform.position); Plugin.Log.LogInfo((object)$"The Carousel acquired a visible player at {num2:F1}m."); } } } private bool CanSee(PlayerAvatar player) { //IL_0001: 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_004d: 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_0054: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) Vector3 val = TargetPosition(player) - OrbitCenter; float num = Mathf.Max(5f, Plugin.Settings.VisionRange.Value); if (((Vector3)(ref val)).sqrMagnitude > num * num) { return false; } float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.1f) { return true; } RaycastHit[] array = Physics.RaycastAll(OrbitCenter, val / magnitude, magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val2 = array[i]; if (!IsCarouselCollider(((RaycastHit)(ref val2)).collider) && !((Object)(object)ResolveHitPlayer(((RaycastHit)(ref val2)).collider) == (Object)(object)player)) { return false; } } return true; } private void UpdateNavigation() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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_019d: 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) //IL_01b9: 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) if ((Object)(object)_agent == (Object)null || !_agent.isOnNavMesh || _combatState == CombatState.Dead) { return; } _agent.speed = Mathf.Max(0.5f, Plugin.Settings.RoamSpeed.Value); if (GunAccess.IsLiving(_target)) { Vector3 val = ((Component)this).transform.position - ((Component)_target).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.25f) { val = -((Component)_target).transform.forward; } NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(((Component)_target).transform.position + ((Vector3)(ref val)).normalized * 9f, ref val2, 5f, -1)) { _agent.isStopped = false; _agent.SetDestination(((NavMeshHit)(ref val2)).position); } return; } _roamTimer -= Time.deltaTime; if (!(_roamTimer > 0f) || !_agent.hasPath || !(_agent.remainingDistance > 1f)) { _roamTimer = Random.Range(3f, 6f); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(((Component)this).transform.position, 8f, 45f, false); if ((Object)(object)val3 == (Object)null) { val3 = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 5f); } NavMeshHit val4 = default(NavMeshHit); if ((Object)(object)val3 != (Object)null && NavMesh.SamplePosition(((Component)val3).transform.position, ref val4, 5f, -1)) { _roamDestination = ((NavMeshHit)(ref val4)).position; _agent.isStopped = false; _agent.SetDestination(_roamDestination); } } } private void UpdateCombat() { bool flag = GunAccess.IsLiving(_target) && CanSee(_target); switch (_combatState) { case CombatState.Roaming: if (flag) { _combatState = CombatState.Warning; _combatTimer = Mathf.Max(0.1f, Plugin.Settings.AlertDelay.Value); } break; case CombatState.Warning: if (!flag) { _combatState = CombatState.Roaming; break; } _combatTimer -= Time.deltaTime; if (_combatTimer <= 0f) { _combatState = CombatState.Bursting; _shotsRemaining = AliveGunCount; _shotTimer = 0f; } break; case CombatState.Bursting: if (!flag || AliveGunCount == 0) { BeginCooldown(); break; } _shotTimer -= Time.deltaTime; if (_shotTimer <= 0f) { FireNextGun(); _shotsRemaining--; _shotTimer = EffectiveShotInterval(); if (_shotsRemaining <= 0) { BeginCooldown(); } } break; case CombatState.Cooldown: _combatTimer -= Time.deltaTime; if (_combatTimer <= 0f) { _combatState = (flag ? CombatState.Warning : CombatState.Roaming); if (flag) { _combatTimer = Mathf.Max(0.1f, Plugin.Settings.AlertDelay.Value); } } break; } } private void BeginCooldown() { _combatState = CombatState.Cooldown; _combatTimer = Mathf.Clamp(Plugin.Settings.BurstCooldown.Value, 0.75f, 8f); } private void FireNextGun() { if (AliveGunCount == 0) { return; } for (int i = 0; i < _guns.Count; i++) { OrbitGun orbitGun = _guns[_nextGunIndex % _guns.Count]; _nextGunIndex = (_nextGunIndex + 1) % _guns.Count; if (orbitGun.Alive && !((Object)(object)orbitGun.Spawned?.Gun == (Object)null)) { QueueGunShot(orbitGun); break; } } } private void QueueGunShot(OrbitGun gun) { //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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0135: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) if (GunAccess.IsLiving(_target) && !((Object)(object)gun?.Spawned?.Gun?.gunMuzzle == (Object)null) && !((Object)(object)gun.Spawned.Phys == (Object)null)) { Vector3 val = TargetPosition(_target); Vector3 val2 = val - gun.Spawned.Gun.gunMuzzle.position; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = ((Component)this).transform.forward; } float num = Mathf.Max(0.1f, ((Vector3)(ref val2)).magnitude); ((Vector3)(ref val2)).Normalize(); float num2 = Mathf.Clamp(Plugin.Settings.FireAimError.Value, 0f, 35f); float num3 = Random.Range(0f - num2, num2); float num4 = Random.Range((0f - num2) * 0.65f, num2 * 0.65f); Vector3 val3 = Vector3.Cross(Vector3.up, val2); if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = ((Component)this).transform.right; } ((Vector3)(ref val3)).Normalize(); float num5 = Mathf.Tan(num3 * (MathF.PI / 180f)) * num; float num6 = Mathf.Tan(num4 * (MathF.PI / 180f)) * num; gun.ShotAimPoint = val + val3 * num5 + Vector3.up * num6; gun.ShotTarget = _target; RefreshShotAimDirection(gun); gun.PendingFire = true; gun.AimHoldTimer = 0f; } } private static bool RefreshShotAimDirection(OrbitGun gun) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gun?.Spawned?.Gun?.gunMuzzle == (Object)null) { return false; } Vector3 val = gun.ShotAimPoint - gun.Spawned.Gun.gunMuzzle.position; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return false; } gun.ShotAimDirection = ((Vector3)(ref val)).normalized; return true; } private void ExecuteGunShot(OrbitGun gun) { //IL_005c: 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_00b5: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)gun?.Spawned?.Gun == (Object)null) && gun.Alive && RefreshShotAimDirection(gun)) { GunAccess.Refill(gun.Spawned.Battery); Vector3 visualEndPosition; PhysGrabObjectImpactDetector objectImpact; Vector3 objectImpactPoint; float unobstructedDistance = ResolveShotPath(gun, out visualEndPosition, out objectImpact, out objectImpactPoint); bool flag = GunAccess.PlayHarmlessShot(gun.Spawned.Gun, gun.ShotAimDirection, visualEndPosition); if (flag && !_firstShotLogged) { _firstShotLogged = true; Plugin.Log.LogInfo((object)"The Carousel fired its first harmless visual burst after a slow smooth aim-in."); } else if (!flag && !_shootFailureLogged) { _shootFailureLogged = true; Plugin.Log.LogWarning((object)"A Carousel TRANQ GUN rejected its fire request."); } if (flag) { ApplyObjectShotDamage(objectImpact, objectImpactPoint); TryApplyPlayerDamage(gun, unobstructedDistance); } } } private float ResolveShotPath(OrbitGun firingGun, out Vector3 visualEndPosition, out PhysGrabObjectImpactDetector objectImpact, out Vector3 objectImpactPoint) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005f: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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) Transform gunMuzzle = firingGun.Spawned.Gun.gunMuzzle; Vector3 normalized = ((Vector3)(ref firingGun.ShotAimDirection)).normalized; float num = Mathf.Max(5f, firingGun.Spawned.Gun.gunRange); visualEndPosition = gunMuzzle.position + normalized * num; objectImpact = null; objectImpactPoint = Vector3.zero; int num2 = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) | LayerMask.op_Implicit(SemiFunc.LayerMaskGetPhysGrabObject()) | LayerMask.GetMask(new string[1] { "Enemy" }); RaycastHit[] array = Physics.RaycastAll(gunMuzzle.position, normalized, num, num2, (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int num3 = 0; num3 < array2.Length; num3++) { RaycastHit val = array2[num3]; if (IsCarouselCollider(((RaycastHit)(ref val)).collider)) { continue; } visualEndPosition = ((RaycastHit)(ref val)).point; PlayerAvatar player = ResolveHitPlayer(((RaycastHit)(ref val)).collider); if (!GunAccess.IsLiving(player)) { PhysGrabObjectImpactDetector componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && !componentInParent.isEnemy) { objectImpact = componentInParent; objectImpactPoint = ((RaycastHit)(ref val)).point; } } return Mathf.Clamp(((RaycastHit)(ref val)).distance + (GunAccess.IsLiving(player) ? 0.12f : 0f), 0f, num); } return num; } private void ApplyObjectShotDamage(PhysGrabObjectImpactDetector objectImpact, Vector3 impactPoint) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)objectImpact == (Object)null)) { objectImpact.BreakMedium(impactPoint, false); if (!_firstObjectDamageLogged) { _firstObjectDamageLogged = true; Plugin.Log.LogInfo((object)"The Carousel applied its first vanilla networked medium-break hit to a physical object."); } } } private void TryApplyPlayerDamage(OrbitGun firingGun, float unobstructedDistance) { //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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_011b: 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) int num = Mathf.Max(0, Plugin.Settings.PlayerDamagePerHit.Value); if (num <= 0 || (Object)(object)firingGun?.Spawned?.Gun?.gunMuzzle == (Object)null) { return; } Transform gunMuzzle = firingGun.Spawned.Gun.gunMuzzle; Vector3 shotAimDirection = firingGun.ShotAimDirection; if (((Vector3)(ref shotAimDirection)).sqrMagnitude < 0.01f) { return; } ((Vector3)(ref shotAimDirection)).Normalize(); float num2 = Mathf.Max(5f, firingGun.Spawned.Gun.gunRange); float num3 = Mathf.Clamp(unobstructedDistance, 0f, num2); if (num3 <= 0.01f) { return; } float num4 = Mathf.Clamp(Plugin.Settings.ProjectileHitRadius.Value, 0.01f, 0.15f); RaycastHit[] array = Physics.SphereCastAll(gunMuzzle.position, num4, shotAimDirection, num3, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int num5 = 0; num5 < array2.Length; num5++) { RaycastHit val = array2[num5]; if (IsCarouselCollider(((RaycastHit)(ref val)).collider)) { continue; } PlayerAvatar val2 = ResolveHitPlayer(((RaycastHit)(ref val)).collider); if (GunAccess.IsLiving(val2) && (Object)(object)val2.playerHealth != (Object)null) { if (!_firstProjectileHitLogged) { _firstProjectileHitLogged = true; Plugin.Log.LogInfo((object)$"The Carousel accepted its first thin-path projectile hit (radius {num4:F2}m)."); } ApplyPlayerDamage(val2, num, ((RaycastHit)(ref val)).point, "thin projectile path"); break; } } } private void ApplyPlayerDamage(PlayerAvatar player, int damage, Vector3 hitPoint, string hitKind) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) player.playerHealth.HurtOther(damage, hitPoint, true, -1, false); if (!_firstDamageLogged) { _firstDamageLogged = true; Plugin.Log.LogInfo((object)$"The Carousel applied its first {damage}-damage hit ({hitKind})."); } } private bool IsCarouselCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } Transform transform = ((Component)collider).transform; foreach (OrbitGun gun in _guns) { if (gun.Alive && (Object)(object)gun.Spawned?.Root != (Object)null && transform.IsChildOf(gun.Spawned.Root.transform)) { return true; } } return false; } private static PlayerAvatar ResolveHitPlayer(Collider collider) { if ((Object)(object)collider == (Object)null) { return null; } PlayerController componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.playerAvatarScript != (Object)null) { return componentInParent.playerAvatarScript; } PlayerAvatar componentInParent2 = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null) { return componentInParent2; } PlayerTumble componentInParent3 = ((Component)collider).GetComponentInParent(); if (!((Object)(object)componentInParent3 != (Object)null)) { return null; } return componentInParent3.playerAvatar; } private void UpdateGunTransforms() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) int aliveGunCount = AliveGunCount; if (aliveGunCount == 0) { return; } float num = Mathf.Max(1f, Plugin.Settings.OrbitSpeed.Value); if (_combatState == CombatState.Warning || _combatState == CombatState.Bursting) { num *= Mathf.Clamp(Plugin.Settings.AttackOrbitSpeedMultiplier.Value, 1f, 4f); } _orbitAngle = Mathf.Repeat(_orbitAngle + num * Time.deltaTime, 360f); float desiredRadius = SafeOrbitRadius * Mathf.Lerp(0.78f, 1f, (float)aliveGunCount / 3f); Vector3 right = ((Component)this).transform.right; right.y = 0f; if (((Vector3)(ref right)).sqrMagnitude < 0.01f) { right = Vector3.right; } ((Vector3)(ref right)).Normalize(); int num2 = 0; foreach (OrbitGun gun in _guns) { if (!gun.Alive || (Object)(object)gun.Spawned?.Phys == (Object)null) { continue; } float num3 = (_orbitAngle + (float)num2 * (360f / (float)aliveGunCount)) * (MathF.PI / 180f); Vector3 val = right * Mathf.Cos(num3) + Vector3.up * Mathf.Sin(num3); Vector3 val2 = -right * Mathf.Sin(num3) + Vector3.up * Mathf.Cos(num3); float wallLimitedRadius = GetWallLimitedRadius(OrbitCenter, val, desiredRadius); if (!gun.WallRadiusInitialized) { gun.WallRadius = wallLimitedRadius; gun.WallRadiusInitialized = true; } else { float num4 = ((wallLimitedRadius < gun.WallRadius) ? 0.14f : 0.28f); gun.WallRadius = Mathf.SmoothDamp(gun.WallRadius, wallLimitedRadius, ref gun.WallRadiusVelocity, num4, 3f, Time.deltaTime); } Vector3 position = OrbitCenter + val * gun.WallRadius; if (gun.AimHoldTimer > 0f) { gun.AimHoldTimer = Mathf.Max(0f, gun.AimHoldTimer - Time.deltaTime); } bool flag = gun.PendingFire || gun.AimHoldTimer > 0f; if (flag) { RefreshShotAimDirection(gun); } float num5 = Mathf.Clamp(Plugin.Settings.ShotAimTime.Value, 0.1f, 2f); float num6 = (flag ? (0.96f / num5) : 1.6f); gun.AimBlend = Mathf.MoveTowards(gun.AimBlend, flag ? 1f : 0f, num6 * Time.deltaTime); float num7 = gun.AimBlend * gun.AimBlend * (3f - 2f * gun.AimBlend); Quaternion val3 = Quaternion.LookRotation(val, val2); Quaternion val4 = val3; if (num7 > 0f && ((Vector3)(ref gun.ShotAimDirection)).sqrMagnitude >= 0.01f) { Vector3 normalized = ((Vector3)(ref gun.ShotAimDirection)).normalized; Quaternion val5 = AlignForwardWithoutRollFlip(val3, val, normalized, val2); val4 = Quaternion.Slerp(val3, val5, num7); } Quaternion val6 = val4 * Quaternion.Inverse(gun.MuzzleLocalRotation); if (gun.HitWobble > 0f) { gun.HitWobble = Mathf.MoveTowards(gun.HitWobble, 0f, 4f * Time.deltaTime); val6 *= Quaternion.Euler(Mathf.Sin(Time.time * 45f) * gun.HitWobble * 12f, 0f, Mathf.Cos(Time.time * 38f) * gun.HitWobble * 12f); } PinGun(gun, position, val6); if (gun.PendingFire && gun.AimBlend >= 0.96f) { PlayerAvatar shotTarget = gun.ShotTarget; gun.PendingFire = false; gun.ShotTarget = null; if (GunAccess.IsLiving(shotTarget) && CanSee(shotTarget)) { gun.AimHoldTimer = 0.18f; ExecuteGunShot(gun); } else { gun.AimHoldTimer = 0f; } } num2++; } } private static Quaternion AlignForwardWithoutRollFlip(Quaternion sourceRotation, Vector3 sourceForward, Vector3 targetForward, Vector3 fallbackAxis) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_001c: 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_001e: 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_0031: Unknown result type (might be due to invalid IL or missing references) ((Vector3)(ref sourceForward)).Normalize(); ((Vector3)(ref targetForward)).Normalize(); return ((Vector3.Dot(sourceForward, targetForward) < -0.9995f) ? Quaternion.AngleAxis(180f, fallbackAxis) : Quaternion.FromToRotation(sourceForward, targetForward)) * sourceRotation; } private static float GetWallLimitedRadius(Vector3 center, Vector3 radial, float desiredRadius) { //IL_0034: 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) if (((Vector3)(ref radial)).sqrMagnitude <= 0.01f || desiredRadius <= 0.01f) { return desiredRadius; } int mask = LayerMask.GetMask(new string[2] { "Default", "StaticGrabObject" }); RaycastHit val = default(RaycastHit); if (Physics.SphereCast(center, 0.25f, ((Vector3)(ref radial)).normalized, ref val, desiredRadius, mask, (QueryTriggerInteraction)1)) { return Mathf.Max(0.08f, ((RaycastHit)(ref val)).distance - 0.2f); } return desiredRadius; } private static void PinGun(OrbitGun gun, Vector3 position, Quaternion rotation) { //IL_005f: 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_009e: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) GunAccess.Refill(gun.Spawned.Battery); gun.Spawned.Phys.OverrideKinematic(0.3f); gun.Spawned.Phys.OverrideGrabDisable(0.3f); gun.Spawned.Phys.OverrideIndestructible(0.3f); if (Vector3.Distance(((Component)gun.Spawned.Phys).transform.position, position) > 0.01f || Quaternion.Angle(((Component)gun.Spawned.Phys).transform.rotation, rotation) > 0.5f) { gun.Spawned.Phys.SetPositionLogic(position, rotation); } } private static Vector3 TargetPosition(PlayerAvatar player) { //IL_00a3: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player != (Object)null) { PlayerController instance = PlayerController.instance; Bounds bounds; if ((Object)(object)instance != (Object)null && (Object)(object)instance.playerAvatarScript == (Object)(object)player && (Object)(object)instance.col != (Object)null) { bounds = instance.col.bounds; return ((Bounds)(ref bounds)).center; } PlayerAvatarCollision componentInChildren = ((Component)player).GetComponentInChildren(true); if ((Object)(object)componentInChildren?.Collider != (Object)null) { bounds = ((Collider)componentInChildren.Collider).bounds; return ((Bounds)(ref bounds)).center; } } if ((Object)(object)player?.PlayerVisionTarget?.VisionTransform != (Object)null) { return player.PlayerVisionTarget.VisionTransform.position; } if (!((Object)(object)player != (Object)null)) { return Vector3.zero; } return ((Component)player).transform.position + Vector3.up; } private void OnDestroy() { if (_initialized && !_cleaningUp && SemiFunc.IsMasterClientOrSingleplayer()) { CleanupGuns(); } } private void CleanupGuns() { if (_cleaningUp) { return; } _cleaningUp = true; foreach (OrbitGun gun in _guns) { if (gun.Alive && (Object)(object)gun.Spawned?.Phys != (Object)null) { gun.Spawned.Phys.DestroyPhysGrabObject(); gun.Alive = false; } } } } internal sealed class CarouselManager : MonoBehaviour { private int _levelInstanceId; private float _spawnTimer; private bool _attemptFinished; private CarouselController _encounter; private Item _tranqGunItem; private bool _prefabProbeFinished; private bool _levelReadyLogged; internal void Tick() { if (!IsHostOrSingleplayerReady()) { return; } ProbeTranqGunPrefab(); LevelGenerator instance = LevelGenerator.Instance; int num = (((Object)(object)instance != (Object)null) ? ((Object)instance).GetInstanceID() : 0); if (num != _levelInstanceId) { ResetForLevel(num); } if (!IsPlayableLevel()) { DestroyCurrentEncounter(); } else if (!((Object)(object)instance == (Object)null) && instance.Generated && !_attemptFinished) { if (!_levelReadyLogged) { _levelReadyLogged = true; Plugin.Log.LogInfo((object)"The Carousel detected a generated playable level; automatic spawn timer started."); } _spawnTimer -= Time.deltaTime; if (!(_spawnTimer > 0f)) { _attemptFinished = true; TryCreateEncounter(); } } } private void ResetForLevel(int levelId) { if ((Object)(object)_encounter != (Object)null) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); } _encounter = null; _levelInstanceId = levelId; _spawnTimer = Mathf.Max(0f, Plugin.Settings.SpawnDelay.Value); _attemptFinished = false; _levelReadyLogged = false; } private void TryCreateEncounter() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) if (Random.value > Mathf.Clamp01(Plugin.Settings.SpawnChance.Value)) { Plugin.Log.LogInfo((object)"The Carousel skipped this level by spawn chance."); return; } Item val = (((Object)(object)_tranqGunItem != (Object)null) ? _tranqGunItem : VanillaGunSpawner.FindTranqGunItem()); Vector3 position; if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"Could not find the vanilla TRANQ GUN item prefab."); } else if (!TryFindSpawnPosition(out position)) { Plugin.Log.LogWarning((object)"Could not find a valid navigation point for The Carousel."); } else { CreateEncounter(val, position, "automatic"); } } private bool CreateEncounter(Item tranqGun, Vector3 position, string source) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) DestroyCurrentEncounter(); GameObject val = new GameObject("The Carousel Encounter (Host Only)"); val.SetActive(false); val.transform.position = position; CarouselController carouselController = val.AddComponent(); if (!carouselController.Initialize(tranqGun, position)) { Object.Destroy((Object)(object)val); Plugin.Log.LogError((object)"The Carousel encounter failed to initialize."); return false; } val.SetActive(true); if (!carouselController.ActivateNavigation(position)) { Object.Destroy((Object)(object)val); Plugin.Log.LogError((object)"The Carousel encounter failed to activate navigation."); return false; } _encounter = carouselController; Plugin.Log.LogInfo((object)$"The Carousel spawned at {position} ({source}); only vanilla TRANQ GUN objects are networked."); return true; } internal bool DebugSpawnAt(Vector3 requestedPosition) { //IL_0080: 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_009a: Unknown result type (might be due to invalid IL or missing references) if (!IsHostOrSingleplayerReady()) { Plugin.Log.LogWarning((object)"Enemy Lab spawn rejected because this player is not the host."); return false; } if ((!ModEnemySpawnCoordinator.IsDirectorRequestActive && (Object)(object)PlayerAvatar.instance == (Object)null) || !IsPlayableLevel()) { Plugin.Log.LogWarning((object)"Enemy Lab spawn rejected because no playable host level is active."); return false; } ProbeTranqGunPrefab(); Item val = (((Object)(object)_tranqGunItem != (Object)null) ? _tranqGunItem : VanillaGunSpawner.FindTranqGunItem()); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"Enemy Lab could not find the vanilla TRANQ GUN item prefab."); return false; } NavMeshHit val2 = default(NavMeshHit); if (!NavMesh.SamplePosition(requestedPosition, ref val2, 12f, -1)) { Plugin.Log.LogWarning((object)$"Enemy Lab could not find NavMesh near requested point {requestedPosition}."); return false; } _attemptFinished = true; return CreateEncounter(val, ((NavMeshHit)(ref val2)).position, ModEnemySpawnCoordinator.CurrentSpawnSource); } internal void MarkAutomaticAttemptFinished() { int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelInstanceId) { ResetForLevel(num); } _attemptFinished = true; } internal void DebugDespawn() { if (IsHostOrSingleplayerReady()) { _attemptFinished = true; DestroyCurrentEncounter(); Plugin.Log.LogInfo((object)"The Carousel despawned by Enemy Lab."); } } private void DestroyCurrentEncounter() { if (!((Object)(object)_encounter == (Object)null)) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); _encounter = null; } } private void ProbeTranqGunPrefab() { if (!_prefabProbeFinished && !((Object)(object)RunManager.instance == (Object)null) && StatsManager.instance?.itemDictionary != null && StatsManager.instance.itemDictionary.Count != 0) { _prefabProbeFinished = true; _tranqGunItem = VanillaGunSpawner.FindTranqGunItem(); if ((Object)(object)_tranqGunItem != (Object)null) { Plugin.Log.LogInfo((object)("Vanilla TRANQ GUN verified: " + ((PrefabRef)(object)_tranqGunItem.prefab).ResourcePath)); } else { Plugin.Log.LogWarning((object)"Vanilla TRANQ GUN was not available during startup verification."); } } } private static bool IsHostOrSingleplayerReady() { if ((Object)(object)GameManager.instance == (Object)null) { return false; } try { return !GameManager.Multiplayer() || PhotonNetwork.IsMasterClient; } catch { return false; } } private static bool IsPlayableLevel() { return ModEnemyLevelRules.IsPlayableLevel(); } private static bool TryFindSpawnPosition(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; PlayerAvatar val = null; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { val = item; break; } } Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(val2, 18f, 65f, false); if ((Object)(object)val3 == (Object)null) { val3 = SemiFunc.LevelPointGetFurthestFromPlayer(val2, 5f); } return ModEnemyNavigation.TryFindClearSpawn(((Object)(object)val3 != (Object)null) ? ((Component)val3).transform.position : (val2 + Vector3.forward * 15f), 8f, out position); } } internal sealed class ConfectionerController : MonoBehaviour, IModEnemyTumbleReceiver { private enum State { Roam, PlaceCandy, SeekCandy, CarryCandy, Deliver } private readonly List _parts = new List(); private readonly List _candies = new List(); private readonly HashSet _markedSteamIds = new HashSet(); private SpawnedAuditorPart _body; private GumballValuable _gumball; private SpawnedConfectionerCandy _selectedCandy; private Quaternion _selectedCandyLocalRotation = Quaternion.identity; private NavMeshAgent _agent; private ExtractionPoint _deliveryPoint; private State _state; private Quaternion _facing = Quaternion.identity; private int _health; private int _previousExtractionCount; private float _candyTimer; private float _roamTimer; private Vector3 _roamDestination; private bool _hasRoamDestination; private Vector3 _pendingCandyPosition; private bool _hasPendingCandy; private float _placementElapsed; private float _placementStuckTimer; private float _lastPlacementDistance = float.MaxValue; private float _destinationTimer; private float _deliveryTimer; private float _screenPulseTimer; private float _lethalAccumulator; private float _soundTimer; private float _flinchTimer; private float _damageCooldown; private float _rewardTimer; private float _deliveryElapsed; private float _deliveryStuckTimer; private float _lastDeliveryDistance = float.MaxValue; private float _lastClaimedHit = -999f; private bool _everEnteredExtraction; private bool _oneAnnounced; private bool _planningLast; private bool _initialized; private bool _dead; private bool _cleaning; private bool _rewardDropped; public bool CanReceiveTumbleAttack { get { if (_initialized) { return !_dead; } return false; } } internal bool Initialize(Vector3 position) { //IL_0006: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_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_0121: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; _health = Mathf.Max(1, Plugin.Settings.ConfectionerHealth.Value); _agent = ((Component)this).gameObject.AddComponent(); ((Behaviour)_agent).enabled = false; _agent.speed = Mathf.Max(1f, Plugin.Settings.ConfectionerMoveSpeed.Value); _agent.acceleration = 20f; _agent.angularSpeed = 420f; _agent.radius = 0.34f; _agent.height = 1.45f; _agent.stoppingDistance = 0.62f; _body = SpawnPart("Valuables/03 Medium/Valuable Museum Gumball", position + Vector3.up * 0.72f, new Vector3(0.72f, 0.82f, 0.72f), AuditorPartRole.Body); for (int i = 0; i < 4; i++) { SpawnPart("Valuables/01 Tiny/Valuable Wizard Diamond", position + Vector3.up * 0.25f, new Vector3(0.54f, 1.56f, 0.54f), (i < 2) ? AuditorPartRole.LegLeft : AuditorPartRole.LegRight); } if (_body == null || _parts.Count != 5) { CleanupParts(); return false; } _gumball = _body.Root.GetComponentInChildren(true); for (int j = 0; j < _parts.Count; j++) { SpawnedAuditorPart spawnedAuditorPart = _parts[j]; ((Component)spawnedAuditorPart.Phys).gameObject.AddComponent().Initialize(this, spawnedAuditorPart); ((Component)spawnedAuditorPart.Phys).gameObject.AddComponent().Initialize(this, j); } IgnoreSelfCollisions(); _state = State.Roam; _candyTimer = Random.Range(0.9f, 1.5f); _roamTimer = 0f; _deliveryTimer = Random.Range(14f, 22f); _soundTimer = Random.Range(0.65f, 1f); _initialized = true; PinParts(immediate: true); Plugin.Log.LogInfo((object)$"The Confectioner assembled a guest-visible gumball stepper with {_health} HP."); return true; } private SpawnedAuditorPart SpawnPart(string resource, Vector3 position, Vector3 scale, AuditorPartRole role) { //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) SpawnedAuditorPart spawnedAuditorPart = ConfectionerSpawner.SpawnEnemyPart(resource, position, scale, role); if (spawnedAuditorPart != null) { _parts.Add(spawnedAuditorPart); } return spawnedAuditorPart; } internal bool ActivateNavigation(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; return ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform, 6f); } private void Update() { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) if (!_initialized || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (_dead) { UpdateDeath(); return; } _flinchTimer = Mathf.Max(0f, _flinchTimer - Time.deltaTime); _damageCooldown = Mathf.Max(0f, _damageCooldown - Time.deltaTime); _soundTimer -= Time.deltaTime; MaintainCandiesAndRules(); UpdateCandyCreation(); UpdateBehaviour(); PinParts(immediate: false); if (!(_soundTimer <= 0f)) { return; } _soundTimer = Random.Range(0.55f, 0.9f); SpawnedAuditorPart body = _body; if (body != null) { PhysGrabObjectImpactDetector impactDetector = body.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactLight(76f, _body.Phys.centerPoint); } } } private void LateUpdate() { if (!_initialized || _dead || (Object)(object)_gumball == (Object)null) { return; } foreach (SpawnedConfectionerCandy candy in _candies) { if (candy != null && candy.Alive) { ConfectionerSpawner.MaintainCross(candy); } } if ((Object)(object)_gumball.closedLidsMesh != (Object)null) { ((Component)_gumball.closedLidsMesh).gameObject.SetActive(true); } if ((Object)(object)_gumball.openLidsMesh != (Object)null) { ((Component)_gumball.openLidsMesh).gameObject.SetActive(false); } if ((Object)(object)_gumball.eyeBallMesh != (Object)null) { ((Component)_gumball.eyeBallMesh).gameObject.SetActive(false); } } private void UpdateCandyCreation() { //IL_0060: 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_00aa: Unknown result type (might be due to invalid IL or missing references) if (_candies.Count >= 3 || _hasPendingCandy || _state != State.Roam) { return; } _candyTimer -= Time.deltaTime; if (!(_candyTimer > 0f)) { if (!TryFindCandySpawn(out var position)) { _candyTimer = Random.Range(0.65f, 1.25f); return; } _pendingCandyPosition = position; _hasPendingCandy = true; _placementElapsed = 0f; _placementStuckTimer = 0f; _lastPlacementDistance = float.MaxValue; _destinationTimer = 0f; _state = State.PlaceCandy; Plugin.Log.LogInfo((object)$"The Confectioner chose a visible candy placement route to {position}."); } } private bool TryFindCandySpawn(out Vector3 position) { //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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_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_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) position = ((Component)this).transform.position; NavMeshHit val = default(NavMeshHit); for (int i = 0; i < 2; i++) { float num = ((i == 0) ? 9f : 5.5f); float num2 = float.MinValue; for (int j = 0; j < 36; j++) { float num3 = Random.Range(7f, 17f); if (!NavMesh.SamplePosition(((Component)this).transform.position + Quaternion.Euler(0f, Random.Range(0f, 360f), 0f) * Vector3.forward * num3, ref val, 4f, -1) || !HasCompleteDeliveryPath(((NavMeshHit)(ref val)).position)) { continue; } float num4 = NearestCandyPlacement(((NavMeshHit)(ref val)).position); if (_candies.Count <= 0 || !(num4 < num)) { float num5 = num4 * 0.8f - Mathf.Abs(Vector3.Distance(((Component)this).transform.position, ((NavMeshHit)(ref val)).position) - 11f) * 0.35f + Random.Range(0f, 2f); if (num5 > num2) { num2 = num5; position = ((NavMeshHit)(ref val)).position; } } } if (num2 > float.MinValue) { return true; } } List list = SemiFunc.LevelPointsGetAll(); if (list == null || list.Count == 0) { return false; } NavMeshHit val3 = default(NavMeshHit); for (int k = 0; k < 2; k++) { float num6 = ((k == 0) ? 9f : 5.5f); float num7 = float.MinValue; int num8 = Random.Range(0, list.Count); for (int l = 0; l < list.Count; l++) { LevelPoint val2 = list[(num8 + l) % list.Count]; if ((Object)(object)val2 == (Object)null || val2.Truck || ((Object)(object)val2.Room != (Object)null && val2.Room.Truck) || !NavMesh.SamplePosition(((Component)val2).transform.position, ref val3, 2.5f, -1) || !HasCompleteDeliveryPath(((NavMeshHit)(ref val3)).position)) { continue; } float num9 = NearestCandyPlacement(((NavMeshHit)(ref val3)).position); if (_candies.Count > 0 && num9 < num6) { continue; } float num10 = 100f; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { num10 = Mathf.Min(num10, Vector3.Distance(((NavMeshHit)(ref val3)).position, ((Component)item).transform.position)); } } float num11 = num9 * 2.4f + Mathf.Clamp(num10, 0f, 18f) * 0.35f + Random.Range(0f, 2.5f); if (num11 > num7) { num7 = num11; position = ((NavMeshHit)(ref val3)).position; } } if (num7 > float.MinValue) { return true; } } return false; } private float NearestCandyPlacement(Vector3 candidate) { //IL_0028: 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) float num = 100f; foreach (SpawnedConfectionerCandy candy in _candies) { if (candy != null && candy.Alive) { num = Mathf.Min(num, Vector3.Distance(candidate, candy.InitialPlacementPosition)); } } return num; } private void MaintainCandiesAndRules() { int num = 0; bool flag = false; foreach (SpawnedConfectionerCandy candy in _candies) { if (candy == null || !candy.Alive || (Object)(object)candy.Root == (Object)null) { continue; } if (ConfectionerSpawner.IsInExtraction(candy)) { num++; } PlayerAvatar val = ConfectionerSpawner.CurrentHolder(candy); if ((Object)(object)val != (Object)null && !candy.CarriedByEnemy) { candy.WasGrabbed = true; string text = SemiFunc.PlayerGetSteamID(val); if (!string.IsNullOrEmpty(text)) { _markedSteamIds.Add(text); } } } int dollarValue = ((num < 3) ? Mathf.RoundToInt(Plugin.Settings.ConfectionerCandyValue.Value) : 0); foreach (SpawnedConfectionerCandy candy2 in _candies) { if (candy2 != null && candy2.Alive && (Object)(object)candy2.Root != (Object)null) { ConfectionerSpawner.MaintainCandy(candy2, dollarValue); } } if (num > _previousExtractionCount) { _everEnteredExtraction = true; _deliveryTimer = Random.Range(4f, 7f); if (num == 1) { Announce("three"); } else if (num == 2) { Announce("two"); } else if (num >= 3 && !_oneAnnounced) { _oneAnnounced = true; Announce("one"); } } if (num < 2) { _oneAnnounced = false; _planningLast = false; } else if (_previousExtractionCount >= 3 && num == 2) { _oneAnnounced = false; } if (num == 2) { foreach (SpawnedConfectionerCandy candy3 in _candies) { if (candy3 != null && candy3.Alive && !ConfectionerSpawner.IsInExtraction(candy3) && (Object)(object)ConfectionerSpawner.CurrentHolder(candy3) != (Object)null) { flag = true; break; } } } bool flag2 = num == 2 && (flag || _planningLast); if (flag2 && !_oneAnnounced) { _oneAnnounced = true; Announce("one"); } if (!flag2 && num < 3) { _screenPulseTimer = 0f; } if (num >= 3) { ApplyLethalCandyDrain(); } else { _lethalAccumulator = 0f; if (flag2) { ApplyMarkedScreenPulse(); } } _previousExtractionCount = num; } private void Announce(string word) { //IL_0060: 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) foreach (PlayerAvatar item in MarkedLivingPlayers()) { if (GameManager.Multiplayer() && (Object)(object)item.photonView != (Object)null) { item.photonView.RPC("ChatMessageSendRPC", item.photonView.Owner, new object[2] { word, false }); } else { item.ChatMessageSendRPC(word, false, default(PhotonMessageInfo)); } PulseWithoutNetDamage(item); } } private void ApplyMarkedScreenPulse() { _screenPulseTimer -= Time.deltaTime; if (_screenPulseTimer > 0f) { return; } _screenPulseTimer = 0.58f; foreach (PlayerAvatar item in MarkedLivingPlayers()) { PulseWithoutNetDamage(item); } } private static void PulseWithoutNetDamage(PlayerAvatar player) { if (GunAccess.IsLiving(player)) { ConfectionerReviveEffectBridge.Send(player); } } private void ApplyLethalCandyDrain() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) _lethalAccumulator += Time.deltaTime; int num = Mathf.FloorToInt(_lethalAccumulator / 0.1f); if (num <= 0) { return; } _lethalAccumulator -= (float)num * 0.1f; int num2 = Mathf.Clamp(num, 1, 20); foreach (PlayerAvatar item in MarkedLivingPlayers()) { PlayerHealth playerHealth = item.playerHealth; if (playerHealth != null) { playerHealth.HurtOther(num2, ((Component)item).transform.position, false, -1, false); } } } private List MarkedLivingPlayers() { List list = new List(); foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { string text = SemiFunc.PlayerGetSteamID(item); if (!string.IsNullOrEmpty(text) && _markedSteamIds.Contains(text)) { list.Add(item); } } } return list; } private void UpdateBehaviour() { if (_flinchTimer > 0f) { StopAgent(); return; } switch (_state) { case State.SeekCandy: UpdateSeekCandy(); break; case State.PlaceCandy: UpdatePlaceCandy(); break; case State.CarryCandy: case State.Deliver: UpdateDeliverCandy(); break; default: UpdateRoam(); break; } } private void UpdatePlaceCandy() { //IL_0033: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) if (!_hasPendingCandy) { _state = State.Roam; _roamTimer = 0f; return; } _placementElapsed += Time.deltaTime; float num = Vector3.Distance(((Component)this).transform.position, _pendingCandyPosition); if (num <= 1.2f) { PlacePendingCandy(_pendingCandyPosition); return; } if (num < _lastPlacementDistance - 0.09f) { _lastPlacementDistance = num; _placementStuckTimer = 0f; } else { _placementStuckTimer += Time.deltaTime; } if (!NavigateTo(_pendingCandyPosition, 0.72f)) { _placementStuckTimer += Time.deltaTime * 1.5f; } if (_placementStuckTimer >= 4.5f && TryFindCandySpawn(out var position)) { _pendingCandyPosition = position; _placementStuckTimer = 0f; _lastPlacementDistance = Vector3.Distance(((Component)this).transform.position, position); _destinationTimer = 0f; Plugin.Log.LogWarning((object)$"The Confectioner replaced a stalled placement route with {position}."); } else if (_placementElapsed >= 24f) { Vector3 val = ((Component)this).transform.position + _facing * Vector3.forward * 0.9f; NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(val, ref val2, 2f, -1)) { val = ((NavMeshHit)(ref val2)).position; } PlacePendingCandy(val); } } private void PlacePendingCandy(Vector3 position) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) StopAgent(); Vector3 val = ((Component)this).transform.position + _facing * new Vector3(0f, 1.25f, 0.72f); SpawnedConfectionerCandy spawnedConfectionerCandy = ConfectionerSpawner.SpawnCandy(val); if (spawnedConfectionerCandy != null) { spawnedConfectionerCandy.InitialPlacementPosition = position; spawnedConfectionerCandy.Impact.ImpactDisable(0.8f); if ((Object)(object)spawnedConfectionerCandy.Phys.rb != (Object)null && !spawnedConfectionerCandy.Phys.rb.isKinematic) { spawnedConfectionerCandy.Phys.rb.velocity = _facing * Vector3.forward * 1.15f + Vector3.up * 0.55f; spawnedConfectionerCandy.Phys.rb.angularVelocity = Vector3.zero; } _candies.Add(spawnedConfectionerCandy); SpawnedAuditorPart body = _body; if (body != null) { PhysGrabObjectImpactDetector impactDetector = body.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactHeavy(112f, _body.Phys.centerPoint); } } Plugin.Log.LogInfo((object)$"The Confectioner visibly dropped candy {_candies.Count}/3 from {val} toward {position}."); } _hasPendingCandy = false; _placementElapsed = 0f; _placementStuckTimer = 0f; _lastPlacementDistance = float.MaxValue; _state = State.Roam; _hasRoamDestination = false; _roamTimer = 0f; _candyTimer = Mathf.Max(3f, Plugin.Settings.ConfectionerCandyInterval.Value) * Random.Range(0.72f, 0.96f); } private void UpdateRoam() { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_0155: Unknown result type (might be due to invalid IL or missing references) _deliveryTimer -= Time.deltaTime; if (_everEnteredExtraction && _deliveryTimer <= 0f && TrySelectCandyForDelivery()) { _state = State.SeekCandy; _destinationTimer = 0f; } else { if (!ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform)) { return; } _agent.speed = Mathf.Max(1f, Plugin.Settings.ConfectionerMoveSpeed.Value); _agent.isStopped = false; _roamTimer -= Time.deltaTime; bool flag = _hasRoamDestination && !_agent.pathPending && Vector3.Distance(((Component)this).transform.position, _roamDestination) <= 1.15f; bool flag2 = _hasRoamDestination && !_agent.pathPending && !_agent.hasPath && !flag; if ((!_hasRoamDestination || flag || flag2) && _roamTimer <= 0f && TryChooseRoamDestination(out var destination)) { _roamDestination = destination; _hasRoamDestination = true; _roamTimer = Random.Range(4.8f, 7.4f); if (!ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, destination, 2.5f)) { _hasRoamDestination = false; _roamTimer = 0.8f; } } } } private bool TryChooseRoamDestination(out Vector3 destination) { //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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_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) destination = ((Component)this).transform.position; List list = SemiFunc.LevelPointsGetAll(); if (list == null || list.Count == 0) { return false; } float num = float.MinValue; int num2 = Random.Range(0, list.Count); for (int i = 0; i < list.Count; i++) { LevelPoint val = list[(num2 + i) % list.Count]; if ((Object)(object)val == (Object)null || val.Truck || ((Object)(object)val.Room != (Object)null && val.Room.Truck)) { continue; } float num3 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position); if (num3 < 6f || num3 > 32f || !HasCompleteDeliveryPath(((Component)val).transform.position)) { continue; } float num4 = 100f; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { num4 = Mathf.Min(num4, Vector3.Distance(((Component)val).transform.position, ((Component)item).transform.position)); } } if (!(num4 < 5.5f)) { float num5 = Mathf.Min(num3, 20f) * 0.18f + Mathf.Min(num4, 20f) * 0.32f + Random.Range(0f, 2.2f); if (num5 > num) { num = num5; destination = ((Component)val).transform.position; } } } return num > float.MinValue; } private bool TrySelectCandyForDelivery() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) _deliveryPoint = FindExtractionPoint(); if ((Object)(object)_deliveryPoint == (Object)null) { _deliveryTimer = 5f; return false; } SpawnedConfectionerCandy spawnedConfectionerCandy = null; float num = float.MaxValue; foreach (SpawnedConfectionerCandy candy in _candies) { if (candy != null && candy.Alive && !((Object)(object)candy.Phys == (Object)null) && !ConfectionerSpawner.IsInExtraction(candy) && !((Object)(object)ConfectionerSpawner.CurrentHolder(candy) != (Object)null)) { Vector3 val = candy.Phys.centerPoint - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; spawnedConfectionerCandy = candy; } } } _selectedCandy = spawnedConfectionerCandy; if (spawnedConfectionerCandy == null) { _deliveryTimer = Random.Range(7f, 12f); return false; } int num2 = CountExtractedCandies(); _planningLast = num2 == 2; return true; } private void UpdateSeekCandy() { //IL_003e: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (!CandyAvailable(_selectedCandy)) { AbandonDelivery(5f); } else if ((Object)(object)ConfectionerSpawner.CurrentHolder(_selectedCandy) != (Object)null) { AbandonDelivery(7f); } else if (Vector3.Distance(((Component)this).transform.position, _selectedCandy.Phys.centerPoint) <= 1f) { _selectedCandy.CarriedByEnemy = true; _selectedCandyLocalRotation = Quaternion.Inverse(_facing) * ((Component)_selectedCandy.Phys).transform.rotation; _state = State.CarryCandy; _destinationTimer = 0f; _deliveryElapsed = 0f; _deliveryStuckTimer = 0f; _lastDeliveryDistance = float.MaxValue; } else { NavigateTo(_selectedCandy.Phys.centerPoint, 0.58f); } } private void UpdateDeliverCandy() { //IL_0076: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) if (!CandyAvailable(_selectedCandy) || (Object)(object)_deliveryPoint == (Object)null) { AbandonDelivery(5f); return; } if ((Object)(object)ConfectionerSpawner.CurrentHolder(_selectedCandy) != (Object)null) { _selectedCandy.CarriedByEnemy = false; AbandonDelivery(8f); return; } _selectedCandy.CarriedByEnemy = true; _deliveryElapsed += Time.deltaTime; Vector3 val = ((Component)this).transform.position + _facing * new Vector3(0f, 0.86f, 0.34f); PhysGrabObjectImpactDetector impact = _selectedCandy.Impact; if (impact != null) { impact.ImpactDisable(0.8f); } _selectedCandy.Phys.OverrideKinematic(0.8f); _selectedCandy.Phys.SetPositionLogic(val, _facing * _selectedCandyLocalRotation); Vector3 val2 = DeliveryPosition(_deliveryPoint); if (!TryGetDeliveryApproach(val2, out var approach)) { ReleaseCandyAndRetry(2.5f); return; } float num = Vector3.Distance(((Component)this).transform.position, approach); if (num <= 1.25f || Vector3.Distance(((Component)this).transform.position, val2) <= 2.2f) { DropCandyAtExtraction(val2); return; } if (num < _lastDeliveryDistance - 0.08f) { _lastDeliveryDistance = num; _deliveryStuckTimer = 0f; } else { _deliveryStuckTimer += Time.deltaTime; } if (!NavigateTo(approach, 0.82f)) { _deliveryStuckTimer += Time.deltaTime * 2f; } if (_deliveryStuckTimer >= 3.5f || _deliveryElapsed >= 14f) { ReleaseCandyAndRetry(2.5f); } else { _state = State.Deliver; } } private void DropCandyAtExtraction(Vector3 position) { //IL_0038: 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_0043: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) StopAgent(); _selectedCandy.CarriedByEnemy = false; PhysGrabObjectImpactDetector impact = _selectedCandy.Impact; if (impact != null) { impact.ImpactDisable(0.75f); } _selectedCandy.Phys.SetPositionLogic(position + Vector3.up * 0.35f, Quaternion.identity); if ((Object)(object)_selectedCandy.Phys.rb != (Object)null && !_selectedCandy.Phys.rb.isKinematic) { _selectedCandy.Phys.rb.velocity = Vector3.zero; _selectedCandy.Phys.rb.angularVelocity = Vector3.zero; } RoomVolumeCheck roomCheck = _selectedCandy.RoomCheck; if (roomCheck != null) { roomCheck.CheckSet(); } Plugin.Log.LogInfo((object)"The Confectioner placed one unattended candy into the extraction area."); _selectedCandy = null; _planningLast = false; _state = State.Roam; _deliveryTimer = Random.Range(6f, 10f); _roamTimer = 0f; } private bool NavigateTo(Vector3 point, float stoppingDistance) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (!ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform)) { return false; } _agent.speed = Mathf.Max(1f, Plugin.Settings.ConfectionerMoveSpeed.Value); _agent.stoppingDistance = stoppingDistance; _agent.isStopped = false; _destinationTimer -= Time.deltaTime; if (_destinationTimer <= 0f) { _destinationTimer = 0.16f; return ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, point, 2.8f); } if (!_agent.hasPath) { return _agent.pathPending; } return true; } private bool TryGetDeliveryApproach(Vector3 delivery, out Vector3 approach) { //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) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) approach = delivery; if ((Object)(object)_agent == (Object)null || !((Behaviour)_agent).enabled || !_agent.isOnNavMesh) { return false; } NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(delivery, ref val, 6f, -1) && HasCompleteDeliveryPath(((NavMeshHit)(ref val)).position)) { approach = ((NavMeshHit)(ref val)).position; return true; } float num = float.MaxValue; foreach (LevelPoint item in SemiFunc.LevelPointsGetAll()) { if (!((Object)(object)item == (Object)null) && !item.Truck && (!((Object)(object)item.Room != (Object)null) || !item.Room.Truck) && HasCompleteDeliveryPath(((Component)item).transform.position)) { Vector3 val2 = ((Component)item).transform.position - delivery; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; approach = ((Component)item).transform.position; } } } return num < 100f; } private bool HasCompleteDeliveryPath(Vector3 destination) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 NavMeshPath val = new NavMeshPath(); if (NavMesh.CalculatePath(((Component)this).transform.position, destination, -1, val)) { return (int)val.status == 0; } return false; } private void ReleaseCandyAndRetry(float delay) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0083: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_selectedCandy?.Phys != (Object)null) { _selectedCandy.CarriedByEnemy = false; PhysGrabObjectImpactDetector impact = _selectedCandy.Impact; if (impact != null) { impact.ImpactDisable(0.6f); } _selectedCandy.Phys.SetPositionLogic(((Component)this).transform.position + _facing * Vector3.forward * 0.62f + Vector3.up * 0.22f, Quaternion.Euler(90f, ((Component)this).transform.eulerAngles.y, 0f)); if ((Object)(object)_selectedCandy.Phys.rb != (Object)null && !_selectedCandy.Phys.rb.isKinematic) { _selectedCandy.Phys.rb.velocity = Vector3.zero; _selectedCandy.Phys.rb.angularVelocity = Vector3.zero; } } Plugin.Log.LogWarning((object)"The Confectioner released a stalled candy and will retry its delivery route."); AbandonDelivery(delay); } private void AbandonDelivery(float delay) { if (_selectedCandy != null) { _selectedCandy.CarriedByEnemy = false; } _selectedCandy = null; _deliveryPoint = null; _planningLast = false; _deliveryElapsed = 0f; _deliveryStuckTimer = 0f; _lastDeliveryDistance = float.MaxValue; _state = State.Roam; _deliveryTimer = delay; _roamTimer = 0f; } private static bool CandyAvailable(SpawnedConfectionerCandy candy) { if (candy != null && candy.Alive && (Object)(object)candy.Root != (Object)null && (Object)(object)candy.Phys != (Object)null && !candy.Phys.dead) { return candy.Root.activeInHierarchy; } return false; } private int CountExtractedCandies() { int num = 0; foreach (SpawnedConfectionerCandy candy in _candies) { if (candy != null && candy.Alive && ConfectionerSpawner.IsInExtraction(candy)) { num++; } } return num; } private static ExtractionPoint FindExtractionPoint() { ExtractionPoint[] array = Object.FindObjectsOfType(); foreach (ExtractionPoint val in array) { if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeInHierarchy) { return val; } } return null; } private static Vector3 DeliveryPosition(ExtractionPoint point) { //IL_001f: 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_002e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)point?.extractionArea != (Object)null) { return point.extractionArea.transform.position; } if (!((Object)(object)point != (Object)null)) { return Vector3.zero; } return ((Component)point).transform.position; } private void PinParts(bool immediate) { //IL_0028: 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_005f: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_0146: 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_015d: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0296: 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_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: 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) Vector3 val = (((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) ? _agent.velocity : Vector3.zero); val.y = 0f; Quaternion val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.04f) ? Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up) : _facing); _facing = (immediate ? val2 : Quaternion.RotateTowards(_facing, val2, 420f * Time.deltaTime)); bool flag = ((Vector3)(ref val)).sqrMagnitude > 0.08f; float num = Time.time * (flag ? 6.6f : 1.8f); float num2 = Mathf.Sin(num); float num3 = (flag ? (Mathf.Abs(Mathf.Sin(num * 2f)) * 0.055f) : 0f); Quaternion rotation = _facing * Quaternion.Euler(flag ? (num2 * 3.5f) : 0f, flag ? (Mathf.Sin(num * 0.5f) * 4f) : 0f, flag ? ((0f - num2) * 4.5f) : 0f); PosePart(_body, ((Component)this).transform.position + Vector3.up * (0.7f + num3), rotation, immediate); Vector3[] array = (Vector3[])(object)new Vector3[4] { new Vector3(-0.145f, 0.46f, 0.105f), new Vector3(0.145f, 0.46f, 0.105f), new Vector3(-0.145f, 0.46f, -0.105f), new Vector3(0.145f, 0.46f, -0.105f) }; Vector3 val3 = default(Vector3); for (int i = 0; i < 4; i++) { float num4 = num + (float)i * MathF.PI * 0.5f; float num5 = (flag ? (Mathf.Sin(num4) * 0.145f) : 0f); float num6 = (flag ? (Mathf.Max(0f, Mathf.Sin(num4)) * 0.085f) : 0f); Vector3 start = ((Component)this).transform.position + _facing * array[i]; ((Vector3)(ref val3))..ctor(array[i].x * 1.015f, 0.045f + num6, array[i].z + num5); Vector3 end = ((Component)this).transform.position + _facing * val3; PoseSegment(_parts[i + 1], start, end, immediate); } } private static void PoseSegment(SpawnedAuditorPart part, Vector3 start, Vector3 end, bool immediate) { //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) //IL_0002: 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_001d: 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_0029: 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_002e: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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) Vector3 val = end - start; Quaternion rotation = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? Quaternion.FromToRotation(Vector3.up, ((Vector3)(ref val)).normalized) : Quaternion.identity); PosePart(part, (start + end) * 0.5f, rotation, immediate); } private static void PosePart(SpawnedAuditorPart part, Vector3 center, Quaternion rotation, bool immediate) { //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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00f0: 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_00f8: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)part?.Phys == (Object)null) && part.Alive) { if (part.GeometryFrames > 0) { AuditorSpawner.RefreshGeometry(part); part.GeometryFrames--; } part.ImpactDetector.destroyDisable = true; part.Phys.OverrideKinematic(0.35f); part.Phys.OverrideGrabDisable(0.35f); part.Phys.OverrideIndestructible(0.35f); Vector3 val = center - rotation * part.VisualCenterOffset; Vector3 val2 = (immediate ? val : Vector3.Lerp(((Component)part.Phys).transform.position, val, 1f - Mathf.Exp((0f - Time.deltaTime) * 13.5f))); Quaternion val3 = (immediate ? rotation : Quaternion.Slerp(((Component)part.Phys).transform.rotation, rotation, 1f - Mathf.Exp((0f - Time.deltaTime) * 12f))); part.Phys.SetPositionLogic(val2, val3); } } private void IgnoreSelfCollisions() { List list = new List(); foreach (SpawnedAuditorPart part in _parts) { if (part?.Colliders != null) { list.AddRange(part.Colliders); } } for (int i = 0; i < list.Count; i++) { for (int j = i + 1; j < list.Count; j++) { if ((Object)(object)list[i] != (Object)null && (Object)(object)list[j] != (Object)null) { Physics.IgnoreCollision(list[i], list[j], true); } } } } private void StopAgent() { if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } } internal bool TryClaimWeaponHit(int sourceId) { if (_dead || !ModEnemyWeaponDamage.TryClaim((Object)(object)this, sourceId) || Time.time - _lastClaimedHit < 0.06f) { return false; } _lastClaimedHit = Time.time; return true; } internal void ReceiveWeaponHit(Vector3 point, int damage) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (!_dead && damage > 0) { _health -= Mathf.Max(1, damage); if (_damageCooldown <= 0f) { _damageCooldown = 0.08f; ModEnemyFeedback.DamageHit(_body?.ImpactDetector, _body?.Phys, point, 94f); } if (_health <= 0) { Die(); } } } public void ReceiveTumbleAttack(int partIndex, int damage, Vector3 hitPosition, Vector3 direction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ReceiveWeaponHit(hitPosition, Mathf.Max(1, damage)); if (!_dead) { _flinchTimer = 0.34f; StopAgent(); } } internal void ExecuteForLab() { if (!_dead) { _health = 0; Die(); } } private void Die() { if (_dead) { return; } _dead = true; StopAgent(); foreach (SpawnedConfectionerCandy candy in _candies) { ConfectionerSpawner.DestroyCandy(candy); } _candies.Clear(); foreach (SpawnedAuditorPart part in _parts) { if (part != null && part.Alive) { part.Alive = false; part.ImpactDetector.destroyDisable = false; part.ImpactDetector.DestroyObject(true); } } _rewardTimer = 0.08f; } private void UpdateDeath() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (_rewardDropped) { return; } _rewardTimer -= Time.deltaTime; if (_rewardTimer > 0f) { return; } _rewardDropped = true; if (Plugin.Settings.ConfectionerDropEnemyValuable.Value && !((Object)(object)AssetManager.instance?.enemyValuableMedium == (Object)null)) { GameObject enemyValuableMedium = AssetManager.instance.enemyValuableMedium; if (GameManager.Multiplayer()) { PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)enemyValuableMedium).name, ((Component)this).transform.position + Vector3.up * 0.42f, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate(enemyValuableMedium, ((Component)this).transform.position + Vector3.up * 0.42f, Quaternion.identity); } } } private void OnDestroy() { if (!_initialized || _cleaning || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } _cleaning = true; foreach (SpawnedConfectionerCandy candy in _candies) { ConfectionerSpawner.DestroyCandy(candy); } _candies.Clear(); CleanupParts(); } private void CleanupParts() { foreach (SpawnedAuditorPart part in _parts) { if (part != null && part.Alive) { AuditorSpawner.Destroy(part); } } _parts.Clear(); } } internal sealed class ConfectionerHitProxy : MonoBehaviour { private ConfectionerController _controller; private SpawnedAuditorPart _part; private float _cooldown; private readonly Dictionary _previous = new Dictionary(); private readonly HashSet _current = new HashSet(); private static int _bulletFrame = -1; private static ItemGunBullet[] _bullets = Array.Empty(); internal void Initialize(ConfectionerController controller, SpawnedAuditorPart part) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown _controller = controller; _part = part; SpawnedAuditorPart part2 = _part; if (part2 == null) { return; } PhysGrabObjectImpactDetector impactDetector = part2.ImpactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.AddListener(new UnityAction(OnHurtColliderHit)); } } } private void Update() { _cooldown = Mathf.Max(0f, _cooldown - Time.deltaTime); if (_cooldown <= 0f && SemiFunc.IsMasterClientOrSingleplayer()) { DetectExpandedBulletHit(); } } private void OnDestroy() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown SpawnedAuditorPart part = _part; if (part == null) { return; } PhysGrabObjectImpactDetector impactDetector = part.ImpactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.RemoveListener(new UnityAction(OnHurtColliderHit)); } } } private void OnHurtColliderHit() { //IL_0072: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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)_controller == (Object)null || _cooldown > 0f || !SemiFunc.IsMasterClientOrSingleplayer() || !_controller.TryClaimWeaponHit(ModEnemyWeaponDamage.CurrentClaimId)) { return; } _cooldown = 0.16f; Vector3 val = (((Object)(object)_part?.Phys != (Object)null) ? _part.Phys.centerPoint : ((Component)this).transform.position); if (EnemyLabBridge.IsExecutionHitNear(val)) { _controller.ExecuteForLab(); return; } int num = ModEnemyWeaponDamage.CurrentOrFallback(Plugin.Settings.ConfectionerDamagePerHit.Value); if (num > 0) { _controller.ReceiveWeaponHit(val, num); } } private void DetectExpandedBulletHit() { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0156: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_controller == (Object)null || _part?.Renderers == null) { return; } if (_bulletFrame != Time.frameCount) { _bulletFrame = Time.frameCount; _bullets = Object.FindObjectsOfType(); } _current.Clear(); ItemGunBullet[] bullets = _bullets; foreach (ItemGunBullet val in bullets) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent() != (Object)null || (Object)(object)val.hurtCollider == (Object)null || !((Component)val.hurtCollider).gameObject.activeInHierarchy) { continue; } int instanceID = ((Object)val).GetInstanceID(); _current.Add(instanceID); Vector3 position = ((Component)val.hurtCollider).transform.position; Vector3 value; bool num = _previous.TryGetValue(instanceID, out value); _previous[instanceID] = position; if (!(num ? SegmentIntersects(value, position) : Within(position)) || !_controller.TryClaimWeaponHit(instanceID)) { continue; } _cooldown = 0.22f; if (EnemyLabBridge.IsExecutionHitNear(position)) { _controller.ExecuteForLab(); return; } int num2 = ModEnemyWeaponDamage.Resolve(val.hurtCollider, Plugin.Settings.ConfectionerDamagePerHit.Value); if (num2 > 0) { _controller.ReceiveWeaponHit(position, num2); } return; } if (_previous.Count <= _current.Count) { return; } List list = null; foreach (int key in _previous.Keys) { if (!_current.Contains(key)) { if (list == null) { list = new List(); } list.Add(key); } } foreach (int item in list ?? new List()) { _previous.Remove(item); } } private bool Within(Vector3 point) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Settings.ConfectionerHitDetectionPadding.Value, 0.12f, 0.8f); float num2 = num * num; Renderer[] renderers = _part.Renderers; foreach (Renderer val in renderers) { if ((Object)(object)val != (Object)null && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; if (((Bounds)(ref bounds)).SqrDistance(point) <= num2) { return true; } } } return false; } private bool SegmentIntersects(Vector3 start, Vector3 end) { //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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Settings.ConfectionerHitDetectionPadding.Value, 0.12f, 0.8f); Renderer[] renderers = _part.Renderers; foreach (Renderer val in renderers) { if (!((Object)(object)val == (Object)null) && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; ((Bounds)(ref bounds)).Expand(num * 2f); if (SegmentBounds(start, end, bounds)) { return true; } } } return false; } private static bool SegmentBounds(Vector3 start, Vector3 end, Bounds bounds) { //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) //IL_0002: 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_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float num = 0f; float num2 = 1f; for (int i = 0; i < 3; i++) { float num3 = ((Vector3)(ref start))[i]; float num4 = ((Vector3)(ref val))[i]; Vector3 val2; if (Mathf.Abs(num4) < 1E-05f) { val2 = ((Bounds)(ref bounds)).min; if (!(num3 < ((Vector3)(ref val2))[i])) { val2 = ((Bounds)(ref bounds)).max; if (!(num3 > ((Vector3)(ref val2))[i])) { continue; } } return false; } float num5 = 1f / num4; val2 = ((Bounds)(ref bounds)).min; float num6 = (((Vector3)(ref val2))[i] - num3) * num5; val2 = ((Bounds)(ref bounds)).max; float num7 = (((Vector3)(ref val2))[i] - num3) * num5; if (num6 > num7) { float num8 = num7; num7 = num6; num6 = num8; } num = Mathf.Max(num, num6); num2 = Mathf.Min(num2, num7); if (num > num2) { return false; } } return true; } } internal sealed class ConfectionerManager : MonoBehaviour { private int _levelId; private float _spawnTimer; private bool _attemptFinished; private bool _probed; private bool _available; private ConfectionerController _encounter; internal void Tick() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (!IsHostReady()) { return; } Probe(); int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } if (!ModEnemyLevelRules.IsPlayableLevel()) { DestroyCurrent(); return; } LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null || !instance.Generated || _attemptFinished) { return; } _spawnTimer -= Time.deltaTime; if (!(_spawnTimer > 0f)) { _attemptFinished = true; if (Random.value <= Mathf.Clamp01(Plugin.Settings.ConfectionerSpawnChance.Value) && TryFindSpawn(out var position)) { Create(position, "automatic"); } } } private void ResetForLevel(int levelId) { DestroyCurrent(); _levelId = levelId; _spawnTimer = Mathf.Max(0f, Plugin.Settings.ConfectionerSpawnDelay.Value); _attemptFinished = false; } private bool Create(Vector3 position, string source) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0085: Unknown result type (might be due to invalid IL or missing references) if (!_available && !ConfectionerSpawner.PrefabsAvailable()) { Plugin.Log.LogWarning((object)"The Confectioner could not resolve its gumball body, candy crystal, or diamond legs."); return false; } DestroyCurrent(); GameObject val = new GameObject("The Confectioner Encounter (Host Logic)"); val.SetActive(false); val.transform.position = position; ConfectionerController confectionerController = val.AddComponent(); if (!confectionerController.Initialize(position)) { Object.Destroy((Object)(object)val); return false; } val.SetActive(true); if (!confectionerController.ActivateNavigation(position)) { Object.Destroy((Object)(object)val); return false; } _encounter = confectionerController; Plugin.Log.LogInfo((object)($"The Confectioner spawned at {position} ({source}); its body and all three " + $"${Mathf.RoundToInt(Plugin.Settings.ConfectionerCandyValue.Value)} candies use vanilla network objects.")); return true; } internal bool DebugSpawnAt(Vector3 requestedPosition) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (!IsHostReady() || (!ModEnemySpawnCoordinator.IsDirectorRequestActive && (Object)(object)PlayerAvatar.instance == (Object)null) || !ModEnemyLevelRules.IsPlayableLevel()) { return false; } Probe(); NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requestedPosition, ref val, 12f, -1)) { return false; } _attemptFinished = true; return Create(((NavMeshHit)(ref val)).position, ModEnemySpawnCoordinator.CurrentSpawnSource); } internal void MarkAutomaticAttemptFinished() { int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } _attemptFinished = true; } internal void DebugDespawn() { if (IsHostReady()) { _attemptFinished = true; DestroyCurrent(); } } private void DestroyCurrent() { if ((Object)(object)_encounter != (Object)null) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); _encounter = null; } } private void Probe() { if (!_probed && !((Object)(object)RunManager.instance == (Object)null)) { _probed = true; _available = ConfectionerSpawner.PrefabsAvailable(); Plugin.Log.LogInfo((object)$"The Confectioner prefab probe: available={_available}."); } } private static bool TryFindSpawn(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; PlayerAvatar val = null; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { val = item; break; } } Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(val2, 14f, 52f, false) ?? SemiFunc.LevelPointGetFurthestFromPlayer(val2, 7f); return ModEnemyNavigation.TryFindClearSpawn(((Object)(object)val3 != (Object)null) ? ((Component)val3).transform.position : (val2 + Vector3.forward * 14f), 7f, out position); } private static bool IsHostReady() { try { return (Object)(object)GameManager.instance != (Object)null && (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient); } catch { return false; } } } internal static class ConfectionerReviveEffectBridge { private const float RelayHeight = -700f; private const BindingFlags PrivateInstance = BindingFlags.Instance | BindingFlags.NonPublic; private static readonly MethodInfo LocalEffectMethod = typeof(ItemReviveItem).GetMethod("ReviveScreenEffectSpawnRPC", BindingFlags.Instance | BindingFlags.NonPublic); private static string _resourcePath; private static GameObject _relayRoot; private static ItemReviveItem _relay; private static PhotonView _view; private static bool _warned; internal static bool Send(PlayerAvatar player) { //IL_0081: 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)player?.photonView == (Object)null || !EnsureRelay()) { return false; } PinRelay(); try { if (GameManager.Multiplayer()) { _view.RPC("ReviveScreenEffectSpawnRPC", (RpcTarget)0, new object[1] { player.photonView.ViewID }); } else { LocalEffectMethod?.Invoke(_relay, new object[2] { player.photonView.ViewID, (object)default(PhotonMessageInfo) }); } return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("The Confectioner could not send the Revive Item overlay: " + ex.Message)); return false; } } private static bool EnsureRelay() { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_relayRoot != (Object)null && (Object)(object)_relay != (Object)null && (Object)(object)_view != (Object)null) { return true; } _relayRoot = null; _relay = null; _view = null; if (!SemiFunc.IsMasterClientOrSingleplayer()) { return false; } if (_resourcePath == null) { _resourcePath = FindResourcePath(); } if (string.IsNullOrEmpty(_resourcePath)) { WarnOnce("no vanilla Revive Item resource was found"); return false; } GameObject val = Resources.Load(_resourcePath); if ((Object)(object)val == (Object)null) { WarnOnce("the Revive Item resource '" + _resourcePath + "' could not be loaded"); return false; } try { Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0f, -700f, 0f); _relayRoot = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject(_resourcePath, val2, Quaternion.identity, (byte)0, (object[])null) : Object.Instantiate(val, val2, Quaternion.identity)); } catch (Exception ex) { WarnOnce("the Revive Item relay failed to spawn: " + ex.Message); return false; } GameObject relayRoot = _relayRoot; _relay = ((relayRoot != null) ? relayRoot.GetComponentInChildren(true) : null); GameObject relayRoot2 = _relayRoot; _view = ((relayRoot2 != null) ? relayRoot2.GetComponentInChildren(true) : null); if ((Object)(object)_relayRoot == (Object)null || (Object)(object)_relay == (Object)null || (Object)(object)_view == (Object)null) { WarnOnce("the spawned Revive Item lacked its vanilla RPC receiver"); DestroyRelay(); return false; } ((Object)_relayRoot).name = "The Confectioner Revive Screen Relay (Hidden)"; ItemAttributes componentInChildren = _relayRoot.GetComponentInChildren(true); if (componentInChildren != null) { componentInChildren.DisableUI(true); } PhysGrabObject componentInChildren2 = _relayRoot.GetComponentInChildren(true); if ((Object)(object)componentInChildren2 != (Object)null) { componentInChildren2.OverrideGrabDisable(999999f); componentInChildren2.OverrideKinematic(999999f); componentInChildren2.OverrideIndestructible(999999f); } PhysGrabObjectImpactDetector componentInChildren3 = _relayRoot.GetComponentInChildren(true); if ((Object)(object)componentInChildren3 != (Object)null) { componentInChildren3.destroyDisable = true; componentInChildren3.playerHurtDisable = true; ((Behaviour)componentInChildren3).enabled = false; } Collider[] componentsInChildren = _relayRoot.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } Renderer[] componentsInChildren2 = _relayRoot.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].enabled = false; } MapIconSuppressor.Attach(_relayRoot); PinRelay(); Plugin.Log.LogInfo((object)("The Confectioner created a hidden vanilla Revive Item screen-effect relay from '" + _resourcePath + "'.")); return true; } private static string FindResourcePath() { if (StatsManager.instance?.itemDictionary == null) { return null; } foreach (Item value in StatsManager.instance.itemDictionary.Values) { string text = ((PrefabRef)(object)value?.prefab)?.ResourcePath; if (!string.IsNullOrEmpty(text)) { GameObject val = Resources.Load(text); if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponentInChildren(true) != (Object)null) { return text; } } } return null; } private static void PinRelay() { //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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_relayRoot == (Object)null)) { Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, -700f, 0f); PhysGrabObject componentInChildren = _relayRoot.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.OverrideGrabDisable(1f); componentInChildren.OverrideKinematic(1f); componentInChildren.OverrideIndestructible(1f); componentInChildren.SetPositionLogic(val, Quaternion.identity); } else { _relayRoot.transform.SetPositionAndRotation(val, Quaternion.identity); } } } private static void DestroyRelay() { if (!((Object)(object)_relayRoot == (Object)null)) { if (GameManager.Multiplayer() && (Object)(object)_view != (Object)null) { PhotonNetwork.Destroy(_relayRoot); } else { Object.Destroy((Object)(object)_relayRoot); } _relayRoot = null; _relay = null; _view = null; } } private static void WarnOnce(string message) { if (!_warned) { _warned = true; Plugin.Log.LogWarning((object)("The Confectioner screen relay is unavailable: " + message + ".")); } } } internal sealed class SpawnedConfectionerCandy { internal GameObject Root; internal PhysGrabObject Phys; internal PhysGrabObjectImpactDetector Impact; internal ValuableObject Valuable; internal RoomVolumeCheck RoomCheck; internal PhotonView View; internal Renderer[] Renderers; internal GameObject CrossRoot; internal PhysGrabObject CrossPhys; internal PhysGrabObjectImpactDetector CrossImpact; internal ValuableObject CrossValuable; internal PhotonView CrossView; internal bool Alive = true; internal int SentDollarValue = int.MinValue; internal bool CrossValueSent; internal Vector3 VisualCenterOffset; internal Vector3 CrossVisualCenterOffset; internal Quaternion CrossRelativeRotation = Quaternion.identity; internal Vector3 InitialPlacementPosition; internal int GeometryFrames = 12; internal bool WasGrabbed; internal bool CarriedByEnemy; } internal static class ConfectionerSpawner { internal const string BodyResourcePath = "Valuables/03 Medium/Valuable Museum Gumball"; internal const string CandyResourcePath = "Valuables/03 Medium/Valuable Wizard Crystal"; internal const string LegResourcePath = "Valuables/01 Tiny/Valuable Wizard Diamond"; private const BindingFlags PrivateInstance = BindingFlags.Instance | BindingFlags.NonPublic; private static readonly FieldInfo InExtractionPointField = typeof(RoomVolumeCheck).GetField("inExtractionPoint", BindingFlags.Instance | BindingFlags.NonPublic); internal static bool PrefabsAvailable() { if ((Object)(object)Resources.Load("Valuables/03 Medium/Valuable Museum Gumball") != (Object)null && (Object)(object)Resources.Load("Valuables/03 Medium/Valuable Wizard Crystal") != (Object)null) { return (Object)(object)Resources.Load("Valuables/01 Tiny/Valuable Wizard Diamond") != (Object)null; } return false; } internal static SpawnedAuditorPart SpawnEnemyPart(string resourcePath, Vector3 position, Vector3 scale, AuditorPartRole role) { //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) return AuditorSpawner.SpawnEnemyPart(resourcePath, position, scale, role); } internal static SpawnedConfectionerCandy SpawnCandy(Vector3 position) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0052: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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) //IL_00ac: 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_00f7: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) GameObject val = Resources.Load("Valuables/03 Medium/Valuable Wizard Crystal"); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"The Confectioner could not load candy resource 'Valuables/03 Medium/Valuable Wizard Crystal'."); return null; } Vector3 val2 = Vector3.Scale(val.transform.localScale, new Vector3(0.46f, 0.46f, 0.46f)); object[] array = new object[3] { val2.x, val2.y, val2.z }; float num = Random.Range(0f, 360f); Quaternion val3 = Quaternion.Euler(90f, num, 0f); GameObject val4 = null; GameObject val5 = null; try { val4 = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject("Valuables/03 Medium/Valuable Wizard Crystal", position, val3, (byte)0, array) : Object.Instantiate(val, position, val3)); val5 = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject("Valuables/03 Medium/Valuable Wizard Crystal", position, val3 * Quaternion.Euler(0f, 0f, 90f), (byte)0, array) : Object.Instantiate(val, position, val3 * Quaternion.Euler(0f, 0f, 90f))); } catch (Exception arg) { if ((Object)(object)val4 != (Object)null) { DestroyRoot(val4); } if ((Object)(object)val5 != (Object)null) { DestroyRoot(val5); } Plugin.Log.LogError((object)$"The Confectioner could not network-spawn a candy: {arg}"); return null; } if ((Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null) { DestroyRoot(val4); DestroyRoot(val5); return null; } ((Object)val4).name = "The Confectioner Candy X (Primary Valuable)"; ((Object)val5).name = "The Confectioner Candy X (Visual Cross)"; val4.transform.localScale = val2; val5.transform.localScale = val2; PhysGrabObject componentInChildren = val4.GetComponentInChildren(true); PhysGrabObjectImpactDetector componentInChildren2 = val4.GetComponentInChildren(true); ValuableObject componentInChildren3 = val4.GetComponentInChildren(true); PhysGrabObject componentInChildren4 = val5.GetComponentInChildren(true); PhysGrabObjectImpactDetector componentInChildren5 = val5.GetComponentInChildren(true); ValuableObject componentInChildren6 = val5.GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren2 == (Object)null || (Object)(object)componentInChildren3 == (Object)null || (Object)(object)componentInChildren4 == (Object)null || (Object)(object)componentInChildren5 == (Object)null || (Object)(object)componentInChildren6 == (Object)null) { DestroyRoot(val4); DestroyRoot(val5); return null; } componentInChildren2.destroyDisable = true; componentInChildren.OverrideIndestructible(2f); componentInChildren5.destroyDisable = true; componentInChildren5.playerHurtDisable = true; RoomVolumeCheck val6 = ((Component)componentInChildren6).GetComponent() ?? ((Component)componentInChildren6).GetComponentInParent(); if ((Object)(object)val6 != (Object)null) { ((Behaviour)val6).enabled = false; } componentInChildren4.OverrideGrabDisable(2f); componentInChildren4.OverrideKinematic(2f); componentInChildren4.OverrideIndestructible(2f); Collider[] componentsInChildren = val5.GetComponentsInChildren(true); foreach (Collider val7 in componentsInChildren) { if ((Object)(object)val7 != (Object)null) { val7.enabled = false; } } EncounterValuableNeutralizer.Apply(val5); ItemAttributes componentInChildren7 = val5.GetComponentInChildren(true); if (componentInChildren7 != null) { componentInChildren7.DisableUI(true); } MapIconSuppressor.Attach(val5); componentsInChildren = val4.GetComponentsInChildren(true); foreach (Collider val8 in componentsInChildren) { if ((Object)(object)val8 == (Object)null) { continue; } Collider[] componentsInChildren2 = val5.GetComponentsInChildren(true); foreach (Collider val9 in componentsInChildren2) { if ((Object)(object)val9 != (Object)null) { Physics.IgnoreCollision(val8, val9, true); } } } if ((Object)(object)componentInChildren.rb != (Object)null) { componentInChildren.rb.collisionDetectionMode = (CollisionDetectionMode)2; componentInChildren.rb.interpolation = (RigidbodyInterpolation)1; componentInChildren.rb.drag = 2.2f; componentInChildren.rb.angularDrag = 28f; } SpawnedConfectionerCandy obj = new SpawnedConfectionerCandy { Root = val4, Phys = componentInChildren, Impact = componentInChildren2, Valuable = componentInChildren3, RoomCheck = (((Component)componentInChildren3).GetComponent() ?? ((Component)componentInChildren3).GetComponentInParent()), View = val4.GetComponentInChildren(true), Renderers = val4.GetComponentsInChildren(true), CrossRoot = val5, CrossPhys = componentInChildren4, CrossImpact = componentInChildren5, CrossValuable = componentInChildren6, CrossView = val5.GetComponentInChildren(true), InitialPlacementPosition = position }; RefreshVisualCenters(obj); ConfigureCrossGeometry(obj, num); return obj; } internal static void MaintainCandy(SpawnedConfectionerCandy candy, int dollarValue) { //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)candy?.Phys == (Object)null || !candy.Alive) { return; } if ((Object)(object)candy.Impact != (Object)null) { candy.Impact.destroyDisable = true; } candy.Phys.OverrideIndestructible(0.45f); if (!candy.CarriedByEnemy && (Object)(object)CurrentHolder(candy) == (Object)null && (Object)(object)candy.Phys.rb != (Object)null && !candy.Phys.rb.isKinematic) { Rigidbody rb = candy.Phys.rb; rb.angularVelocity *= Mathf.Exp(-18f * Time.deltaTime); Vector3 angularVelocity = candy.Phys.rb.angularVelocity; if (((Vector3)(ref angularVelocity)).sqrMagnitude < 0.0004f) { candy.Phys.rb.angularVelocity = Vector3.zero; } } MaintainCross(candy); int num = Mathf.Clamp(dollarValue, 0, 50000); if (candy.SentDollarValue != num && (Object)(object)candy.Valuable != (Object)null) { if (GameManager.Multiplayer() && (Object)(object)candy.View != (Object)null) { candy.View.RPC("DollarValueSetRPC", (RpcTarget)0, new object[1] { (float)num }); } else { candy.Valuable.DollarValueSetRPC((float)num, default(PhotonMessageInfo)); } candy.SentDollarValue = num; } } internal static void MaintainCross(SpawnedConfectionerCandy candy) { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_019c: Unknown result type (might be due to invalid IL or missing references) if (candy == null || !candy.Alive || (Object)(object)candy.CrossRoot == (Object)null || (Object)(object)candy.CrossPhys == (Object)null || (Object)(object)candy.CrossImpact == (Object)null) { return; } candy.CrossImpact.destroyDisable = true; candy.CrossImpact.playerHurtDisable = true; candy.CrossPhys.OverrideGrabDisable(0.45f); candy.CrossPhys.OverrideKinematic(0.45f); candy.CrossPhys.OverrideIndestructible(0.45f); Collider[] componentsInChildren = candy.CrossRoot.GetComponentsInChildren(true); foreach (Collider val in componentsInChildren) { if ((Object)(object)val != (Object)null) { val.enabled = false; } } if (candy.GeometryFrames > 0) { RefreshVisualCenters(candy); candy.GeometryFrames--; } Quaternion val2 = ((Component)candy.Phys).transform.rotation * candy.CrossRelativeRotation; Vector3 val3 = ((Component)candy.Phys).transform.position + ((Component)candy.Phys).transform.rotation * candy.VisualCenterOffset - val2 * candy.CrossVisualCenterOffset; candy.CrossPhys.SetPositionLogic(val3, val2); if (!candy.CrossValueSent && (Object)(object)candy.CrossValuable != (Object)null) { if (GameManager.Multiplayer() && (Object)(object)candy.CrossView != (Object)null) { candy.CrossView.RPC("DollarValueSetRPC", (RpcTarget)0, new object[1] { 0f }); } else { candy.CrossValuable.DollarValueSetRPC(0f, default(PhotonMessageInfo)); } candy.CrossValueSent = true; } } private static void RefreshVisualCenters(SpawnedConfectionerCandy candy) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)candy?.Phys == (Object)null) && !((Object)(object)candy.CrossPhys == (Object)null)) { if (TryGetVisualCenter(candy.Root, out var center)) { candy.VisualCenterOffset = Quaternion.Inverse(((Component)candy.Phys).transform.rotation) * (center - ((Component)candy.Phys).transform.position); } if (TryGetVisualCenter(candy.CrossRoot, out var center2)) { candy.CrossVisualCenterOffset = Quaternion.Inverse(((Component)candy.CrossPhys).transform.rotation) * (center2 - ((Component)candy.CrossPhys).transform.position); } } } private static void ConfigureCrossGeometry(SpawnedConfectionerCandy candy, float yaw) { //IL_0066: 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_007b: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0093: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00e2: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00fe: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)candy?.Phys == (Object)null) && !((Object)(object)candy.CrossPhys == (Object)null) && TryGetVisualGeometry(candy.Root, ((Component)candy.Phys).transform, out var centerOffset, out var longAxis) && TryGetVisualGeometry(candy.CrossRoot, ((Component)candy.CrossPhys).transform, out var centerOffset2, out var longAxis2)) { Vector3 val = ((Component)candy.Phys).transform.position + ((Component)candy.Phys).transform.rotation * centerOffset; Quaternion val2 = Quaternion.AngleAxis(yaw, Vector3.up); Quaternion val3 = val2 * Quaternion.FromToRotation(longAxis, Vector3.forward); Quaternion val4 = val2 * Quaternion.FromToRotation(longAxis2, Vector3.right); candy.VisualCenterOffset = centerOffset; candy.CrossVisualCenterOffset = centerOffset2; candy.CrossRelativeRotation = Quaternion.Inverse(val3) * val4; candy.Phys.SetPositionLogic(val - val3 * centerOffset, val3); candy.CrossPhys.SetPositionLogic(val - val4 * centerOffset2, val4); } } private static bool TryGetVisualGeometry(GameObject root, Transform pose, out Vector3 centerOffset, out Vector3 longAxis) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0164: 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_0149: 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_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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) centerOffset = Vector3.zero; longAxis = Vector3.up; if ((Object)(object)root == (Object)null || (Object)(object)pose == (Object)null) { return false; } bool flag = false; Bounds val = default(Bounds); Renderer[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { if ((Object)(object)val2 == (Object)null || !val2.enabled) { continue; } Bounds localBounds = val2.localBounds; Vector3 center = ((Bounds)(ref localBounds)).center; Vector3 extents = ((Bounds)(ref localBounds)).extents; if (((Vector3)(ref extents)).sqrMagnitude < 1E-06f) { continue; } for (int j = -1; j <= 1; j += 2) { for (int k = -1; k <= 1; k += 2) { for (int l = -1; l <= 1; l += 2) { Vector3 val3 = center + Vector3.Scale(extents, new Vector3((float)j, (float)k, (float)l)); Vector3 val4 = pose.InverseTransformPoint(((Component)val2).transform.TransformPoint(val3)); if (!flag) { ((Bounds)(ref val))..ctor(val4, Vector3.zero); flag = true; } else { ((Bounds)(ref val)).Encapsulate(val4); } } } } } if (!flag) { return false; } centerOffset = ((Bounds)(ref val)).center; Vector3 size = ((Bounds)(ref val)).size; if (size.x >= size.y && size.x >= size.z) { longAxis = Vector3.right; } else if (size.y >= size.z) { longAxis = Vector3.up; } else { longAxis = Vector3.forward; } return true; } private static bool TryGetVisualCenter(GameObject root, out Vector3 center) { //IL_0017: 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_001c: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) center = (((Object)(object)root != (Object)null) ? root.transform.position : Vector3.zero); bool flag = false; Bounds val = default(Bounds); Renderer[] array = ((root != null) ? root.GetComponentsInChildren(true) : null) ?? Array.Empty(); foreach (Renderer val2 in array) { if ((Object)(object)val2 == (Object)null || !val2.enabled) { continue; } Bounds bounds = val2.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!(((Vector3)(ref size)).sqrMagnitude < 1E-06f)) { if (!flag) { val = val2.bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(val2.bounds); } } } if (flag) { center = ((Bounds)(ref val)).center; } return flag; } internal static bool IsInExtraction(SpawnedConfectionerCandy candy) { if ((Object)(object)candy?.RoomCheck == (Object)null || InExtractionPointField == null) { return false; } try { object value = InExtractionPointField.GetValue(candy.RoomCheck); bool flag = default(bool); int num; if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch { return false; } } internal static PlayerAvatar CurrentHolder(SpawnedConfectionerCandy candy) { if (candy?.Phys?.playerGrabbing == null) { return null; } foreach (PhysGrabber item in candy.Phys.playerGrabbing) { if ((Object)(object)item?.playerAvatar != (Object)null && GunAccess.IsLiving(item.playerAvatar)) { return item.playerAvatar; } } return null; } internal static void DestroyCandy(SpawnedConfectionerCandy candy) { if (!((Object)(object)candy?.Root == (Object)null) && candy.Alive) { candy.Alive = false; DestroyRoot(candy.CrossRoot); DestroyRoot(candy.Root); } } private static void DestroyRoot(GameObject root) { if (!((Object)(object)root == (Object)null)) { if (GameManager.Multiplayer()) { PhotonNetwork.Destroy(root); } else { Object.Destroy((Object)(object)root); } } } } internal sealed class CupidController : MonoBehaviour, IModEnemyTumbleReceiver, IModEnemyTranqAware { private enum State { SearchFirst, PrepareFirst, FireFirst, SeekSecond, PrepareSecond, FireSecond, RecoverArrow, Linked, Stunned, Dead } private const float FirstPrepareSeconds = 0.92f; private const float FirstFlightSeconds = 0.72f; private const float SecondPrepareSeconds = 1.02f; private const float SecondFlightSeconds = 0.78f; private const float FallbackShaftHalfLength = 0.48f; private const float RecoveryReloadSeconds = 0.9f; private const float MissContinuationDistance = 22f; private static readonly MethodInfo NewRayHitPointMethod = typeof(ItemDrone).GetMethod("NewRayHitPoint", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo PlayerAvatarTargetField = typeof(ItemDrone).GetField("playerAvatarTarget", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo TargetIsPlayerField = typeof(ItemDrone).GetField("targetIsPlayer", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo TargetIsLocalPlayerField = typeof(ItemDrone).GetField("targetIsLocalPlayer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); internal const int SharedDamageEnemyIndex = -742103; private readonly List _parts = new List(); private SpawnedCupid _spawned; private NavMeshAgent _agent; private State _state; private State _resumeState; private PlayerAvatar _first; private PlayerAvatar _secondPlayer; private PhysGrabObject _secondValuable; private PhysGrabObjectImpactDetector _secondImpact; private Vector3 _visualForward = Vector3.forward; private float _phase; private float _scanTimer; private float _destinationTimer; private float _stateTimer; private float _pullTimer; private float _soundTimer; private float _stunTimer; private float _activationTimer; private float _firstAimTimer; private float _linkBeamTimer; private float _rewardTimer; private float _lastClaimedHit = -10f; private float _lastSharedDamage = -10f; private float _lastValuableBreakDamage = -10f; private int _lastSharedSource; private int _lastSharedAmount; private int _health; private bool _initialized; private bool _dead; private bool _rewardDropped; private bool _cleaning; private bool _firstArrowAttached; private bool _secondArrowAttached; private bool _linkBeamAttached; private Vector3 _shotOrigin; private Vector3 _shotDirection; private Vector3 _shotEndPoint; private Vector3 _firstArrowDirection = Vector3.forward; private Vector3 _secondArrowDirection = Vector3.forward; private Vector3 _lastArrowFlightPoint; private Vector3 _blockedArrowPoint; private Vector3 _blockedArrowDirection = Vector3.forward; private Vector3 _recoveryPickupStart; private Vector3 _recoveryLandingStart; private Vector3 _recoveryLandingEnd; private float _recoveryPickupTimer = -1f; private float _recoveryLandingTimer = -1f; private float _recoveryLandingDuration; private float _recoveryReloadTimer; private PhysGrabObject _recentlyBlockedValuable; private float _recentlyBlockedValuableUntil; private int _blockedArrowIndex = -1; public bool CanReceiveTumbleAttack { get { if (_initialized) { return !_dead; } return false; } } internal bool Initialize(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_014a: 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) ((Component)this).transform.position = position; _health = Mathf.Max(1, Plugin.Settings.CupidHealth.Value); _agent = ((Component)this).gameObject.AddComponent(); ((Behaviour)_agent).enabled = false; _agent.speed = Mathf.Max(1f, Plugin.Settings.CupidSwimSpeed.Value); _agent.acceleration = 7f; _agent.angularSpeed = 170f; _agent.radius = 0.34f; _agent.height = 1.15f; _agent.stoppingDistance = 1.25f; _spawned = CupidSpawner.Spawn(position + Vector3.up * 1.25f); if (_spawned == null) { return false; } int num = 0; foreach (CupidPart part in _spawned.Parts) { if (!((Object)(object)part?.Spawned?.Phys == (Object)null)) { _parts.Add(part); DeadAirSpawner.RefreshRenderedGeometry(part.Spawned); if (part.Role == CupidPartRole.Shaft) { part.Spawned.LongAxisLocal = Vector3.up; part.MeasuredHalfLength = Mathf.Clamp(part.Spawned.VisualSize.y * 0.5f, 0.28f, 1.4f); } part.Spawned.GeometryCalibrationFrames = 0; ((Component)part.Spawned.Phys).gameObject.AddComponent().Initialize(this, part.Spawned, num); ((Component)part.Spawned.Phys).gameObject.AddComponent().Initialize(this, num); num++; } } if (_parts.Count < 6) { CupidSpawner.Destroy(_spawned); return false; } _phase = Random.Range(0f, MathF.PI * 2f); _scanTimer = 0.15f; _destinationTimer = 0.1f; _soundTimer = Random.Range(0.7f, 1.2f); _activationTimer = 0.85f; _linkBeamTimer = 0f; _state = State.SearchFirst; _initialized = true; CupidLinkRegistry.Register(this); PinVisuals(); Plugin.Log.LogInfo((object)$"The Cupid assembled three network-visible Love Potion arrows with {_health} HP."); return true; } internal bool ActivateNavigation(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; return ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform, 6f); } private void Update() { if (!_initialized || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (_dead) { UpdateDeath(); return; } float deltaTime = Time.deltaTime; _scanTimer -= deltaTime; _destinationTimer -= deltaTime; _pullTimer -= deltaTime; _soundTimer -= deltaTime; _stateTimer += deltaTime; _stunTimer = Mathf.Max(0f, _stunTimer - deltaTime); _activationTimer = Mathf.Max(0f, _activationTimer - deltaTime); _linkBeamTimer = Mathf.Max(0f, _linkBeamTimer - deltaTime); _recoveryReloadTimer = Mathf.Max(0f, _recoveryReloadTimer - deltaTime); UpdateHeading(); if (_activationTimer > 0f) { StopAgent(); PinVisuals(); UpdateAudio(); return; } if (_stunTimer > 0f) { StopAgent(); if (_state != State.Stunned) { _resumeState = _state; _state = State.Stunned; } } else if (_state == State.Stunned) { SetState((_resumeState != State.Stunned && _resumeState != State.Dead) ? _resumeState : (((Object)(object)_first != (Object)null) ? State.SeekSecond : State.SearchFirst)); } switch (_state) { case State.SearchFirst: UpdateSearchFirst(); break; case State.PrepareFirst: UpdatePrepareFirst(); break; case State.FireFirst: UpdateFireFirst(); break; case State.SeekSecond: UpdateSeekSecond(); break; case State.PrepareSecond: UpdatePrepareSecond(); break; case State.FireSecond: UpdateFireSecond(); break; case State.RecoverArrow: UpdateRecoverArrow(); break; case State.Linked: UpdateLinked(); break; } PinVisuals(); UpdateAudio(); } private void UpdateSearchFirst() { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) if (_recoveryReloadTimer > 0f) { StopAgent(); return; } if (_scanTimer <= 0f) { _scanTimer = 0.22f; PlayerAvatar val = FindNearestPlayer(null); if ((Object)(object)val != (Object)(object)_first && (Object)(object)val != (Object)null) { Plugin.Log.LogInfo((object)("The Cupid acquired " + ((Object)val).name + " as its first link endpoint.")); _firstAimTimer = 0f; _destinationTimer = 0f; } _first = val; } if (!GunAccess.IsLiving(_first)) { Roam(); return; } _firstAimTimer += Time.deltaTime; Vector3 val2 = PlayerPoint(_first); if (HasLineOfSightToPlayer(_first) || (_firstAimTimer >= 1.15f && HasEmergencyFiringLine(_first))) { StopAgent(); _shotOrigin = VisualCenter(); Vector3 val3 = val2 - _shotOrigin; _shotDirection = ((Vector3)(ref val3)).normalized; _firstArrowDirection = _shotDirection; SetState(State.PrepareFirst); BodyImpact(112f); Plugin.Log.LogInfo((object)$"The Cupid entered its first-shot windup after {_firstAimTimer:F2}s of acquisition."); } else { SeekFirstFiringLane(val2); } } private void UpdatePrepareFirst() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0048: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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) if (!GunAccess.IsLiving(_first)) { ResetHunt(); return; } StopAgent(); Vector3 val = PlayerPoint(_first) - VisualCenter(); if (((Vector3)(ref val)).sqrMagnitude > 0.001f) { Vector3 val2 = Vector3.Slerp(_shotDirection, ((Vector3)(ref val)).normalized, 1f - Mathf.Exp(-8f * Time.deltaTime)); _shotDirection = ((Vector3)(ref val2)).normalized; _firstArrowDirection = _shotDirection; } if (!(_stateTimer < 0.92f)) { _shotOrigin = PreparedArrowTip(_shotDirection); _shotEndPoint = PlayerArrowPoint(_first, _firstArrowDirection); _lastArrowFlightPoint = _shotOrigin; SetState(State.FireFirst); BodyImpact(138f); } } private void UpdateFireFirst() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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) if (!GunAccess.IsLiving(_first)) { ResetHunt(); return; } float t = Mathf.Clamp01(_stateTimer / 0.72f); Vector3 val = Arc(_shotOrigin, _shotEndPoint, t); if (TryFindArrowObstruction(_lastArrowFlightPoint, val, _first, null, out var obstruction)) { BeginArrowRecovery(0, obstruction, val - _lastArrowFlightPoint); return; } _lastArrowFlightPoint = val; if (_stateTimer >= 0.72f) { if (Vector3.Distance(PlayerArrowPoint(_first, _firstArrowDirection), _shotEndPoint) > MovingTargetTolerance(1.05f)) { BeginMissedArrowRecall(0, _shotEndPoint, ArcTangent(_shotOrigin, _shotEndPoint), "missed its moving target"); } else { CompleteFirstArrow(); } } } private void CompleteFirstArrow() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) _firstArrowAttached = true; ApplyArrowImpact(_first, _firstArrowDirection); SetState(State.SeekSecond); _scanTimer = 0f; } private void UpdateSeekSecond() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(_first)) { ResetHunt(); return; } if (_recoveryReloadTimer > 0f) { StopAgent(); return; } if (_scanTimer <= 0f) { _scanTimer = 0.28f; _secondPlayer = FindNearestPlayer(_first, 80f); if (!GunAccess.IsLiving(_secondPlayer)) { _secondPlayer = null; _secondValuable = FindHeavyValuable(); } } if (!SecondValid()) { if (_stateTimer >= 8f) { ResetHunt(); } else { RoamAround(((Component)_first).transform.position); } return; } Vector3 val = SecondPoint(); MoveToward(val, 0.28f, 0.82f); if (Vector3.Distance(VisualCenter(), val) <= 7f && HasLineOfSight(val, ((Object)(object)_secondPlayer != (Object)null) ? ((Component)_secondPlayer).transform : ((Component)_secondValuable).transform)) { StopAgent(); _shotOrigin = VisualCenter(); Vector3 val2 = val - _shotOrigin; _shotDirection = ((Vector3)(ref val2)).normalized; _secondArrowDirection = _shotDirection; SetState(State.PrepareSecond); BodyImpact(122f); } } private void UpdatePrepareSecond() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(_first) || !SecondValid()) { ResetHunt(); return; } StopAgent(); Vector3 val = SecondPoint() - VisualCenter(); if (((Vector3)(ref val)).sqrMagnitude > 0.001f) { Vector3 val2 = Vector3.Slerp(_shotDirection, ((Vector3)(ref val)).normalized, 1f - Mathf.Exp(-7f * Time.deltaTime)); _shotDirection = ((Vector3)(ref val2)).normalized; _secondArrowDirection = _shotDirection; } if (!(_stateTimer < 1.02f)) { _shotOrigin = PreparedArrowTip(_shotDirection); _shotEndPoint = SecondArrowPoint(_secondArrowDirection); _lastArrowFlightPoint = _shotOrigin; SetState(State.FireSecond); BodyImpact(146f); } } private void UpdateFireSecond() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0074: 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_0060: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0094: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(_first) || !SecondValid()) { ResetHunt(); return; } float t = Mathf.Clamp01(_stateTimer / 0.78f); Vector3 val = Arc(_shotOrigin, _shotEndPoint, t); if (TryFindArrowObstruction(_lastArrowFlightPoint, val, _secondPlayer, _secondValuable, out var obstruction)) { BeginArrowRecovery(1, obstruction, val - _lastArrowFlightPoint); return; } _lastArrowFlightPoint = val; if (_stateTimer >= 0.78f) { if (Vector3.Distance(SecondArrowPoint(_secondArrowDirection), _shotEndPoint) > (((Object)(object)_secondPlayer != (Object)null) ? MovingTargetTolerance(1.05f) : MovingTargetTolerance(1.25f))) { BeginMissedArrowRecall(1, _shotEndPoint, ArcTangent(_shotOrigin, _shotEndPoint), "missed its second endpoint"); } else { CompleteSecondArrow(); } } } private void CompleteSecondArrow() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) _secondArrowAttached = true; if (GunAccess.IsLiving(_secondPlayer)) { ApplyArrowImpact(_secondPlayer, _secondArrowDirection); } AttachValuableListeners(); SetState(State.Linked); _pullTimer = 0f; BodyImpact(148f); Plugin.Log.LogInfo((object)("The Cupid linked " + ((Object)_first).name + " to " + (((Object)(object)_secondPlayer != (Object)null) ? ((Object)_secondPlayer).name : ((Object)_secondValuable).name) + ".")); } private void ApplyArrowImpact(PlayerAvatar player, Vector3 direction) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_004d: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_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) if (GunAccess.IsLiving(player)) { PlayerHealth playerHealth = player.playerHealth; if (playerHealth != null) { playerHealth.MaterialEffectOverride((Effect)0); } Vector3 val = direction; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = ((Component)player).transform.position - ((Component)this).transform.position; val.y = 0f; } val = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : ((Component)this).transform.forward); player.ForceImpulse(val * 11.2f + Vector3.up * 2.2f); BodyImpact(184f); } } private void BeginArrowRecovery(int arrowIndex, RaycastHit hit, Vector3 direction) { //IL_0038: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_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_001f: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref direction)).sqrMagnitude < 0.001f) { direction = ((arrowIndex == 0) ? _firstArrowDirection : _secondArrowDirection); } Vector3 val = ((((Vector3)(ref direction)).sqrMagnitude > 0.001f) ? ((Vector3)(ref direction)).normalized : Vector3.forward); BeginArrowRecoveryAtPoint(arrowIndex, ((RaycastHit)(ref hit)).point - val * 0.035f, val, "struck cover"); } private void BeginArrowRecoveryAtPoint(int arrowIndex, Vector3 point, Vector3 direction, string reason) { //IL_002d: 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_0082: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) if (_state != State.RecoverArrow && _blockedArrowIndex < 0) { if (((Vector3)(ref direction)).sqrMagnitude < 0.001f) { direction = ((arrowIndex == 0) ? _firstArrowDirection : _secondArrowDirection); } if (arrowIndex == 1 && (Object)(object)_secondValuable != (Object)null) { _recentlyBlockedValuable = _secondValuable; _recentlyBlockedValuableUntil = Time.time + 3.2f; } _blockedArrowIndex = arrowIndex; _blockedArrowDirection = ((((Vector3)(ref direction)).sqrMagnitude > 0.001f) ? ((Vector3)(ref direction)).normalized : Vector3.forward); _blockedArrowPoint = point; _recoveryPickupStart = point; _recoveryPickupTimer = -1f; _recoveryLandingTimer = -1f; _destinationTimer = 0f; SetState(State.RecoverArrow); BodyImpact(126f); Plugin.Log.LogInfo((object)$"The Cupid's arrow {arrowIndex + 1} {reason}; it is swimming over to recover it."); } } private void BeginMissedArrowRecall(int arrowIndex, Vector3 point, Vector3 direction, string reason) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0065: Unknown result type (might be due to invalid IL or missing references) BeginArrowRecoveryAtPoint(arrowIndex, point, direction, reason); if (_state == State.RecoverArrow && _blockedArrowIndex == arrowIndex) { Vector3 val = ResolveMissLanding(point, direction); _recoveryLandingStart = point; _recoveryLandingEnd = val; _recoveryLandingDuration = Mathf.Clamp(Vector3.Distance(point, val) / 22f, 0.18f, 0.72f); _recoveryLandingTimer = _recoveryLandingDuration; _blockedArrowPoint = point; } } private void UpdateRecoverArrow() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_0144: Unknown result type (might be due to invalid IL or missing references) if (_blockedArrowIndex < 0) { ResetHunt(); return; } if (_blockedArrowIndex == 1 && !GunAccess.IsLiving(_first)) { ResetHunt(); return; } if (_recoveryLandingTimer >= 0f) { StopAgent(); _recoveryLandingTimer -= Time.deltaTime; float num = Mathf.Clamp01(1f - _recoveryLandingTimer / Mathf.Max(0.01f, _recoveryLandingDuration)); _blockedArrowPoint = Vector3.Lerp(_recoveryLandingStart, _recoveryLandingEnd, num); if (num < 1f) { return; } _blockedArrowPoint = _recoveryLandingEnd; _recoveryLandingTimer = -1f; _destinationTimer = 0f; } if (_recoveryPickupTimer >= 0f) { StopAgent(); _recoveryPickupTimer -= Time.deltaTime; float num2 = ((_stateTimer >= 3f) ? 0.92f : 0.68f); float num3 = Mathf.Clamp01(1f - _recoveryPickupTimer / num2); _blockedArrowPoint = Vector3.Lerp(_recoveryPickupStart, VisualCenter() + Vector3.up * 0.08f, Mathf.SmoothStep(0f, 1f, num3)); if (!(_recoveryPickupTimer > 0f)) { FinishArrowRecovery(); } } else if (Vector3.Distance(VisualCenter(), _blockedArrowPoint) > 1.25f && _stateTimer < 3f) { MoveToward(_blockedArrowPoint, 0.12f, 1.16f); } else { StopAgent(); _recoveryPickupStart = _blockedArrowPoint; _recoveryPickupTimer = ((_stateTimer >= 3f) ? 0.92f : 0.68f); BodyImpact(92f); } } private void FinishArrowRecovery() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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) int blockedArrowIndex = _blockedArrowIndex; _blockedArrowIndex = -1; _blockedArrowPoint = Vector3.zero; _recoveryPickupTimer = -1f; _recoveryLandingTimer = -1f; _shotEndPoint = Vector3.zero; _destinationTimer = 0f; _recoveryReloadTimer = 0.9f; BodyImpact(68f); if (blockedArrowIndex == 0) { ResetHunt(); return; } _secondPlayer = null; _secondValuable = null; _secondArrowAttached = false; SetState(State.SeekSecond); _scanTimer = 0f; } private void UpdateLinked() { //IL_0029: 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_0034: 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) if (!GunAccess.IsLiving(_first) || !SecondValid()) { ResetHunt(); return; } UpdateLinkBeam(); RoamAround((PlayerPoint(_first) + SecondPoint()) * 0.5f); if (_pullTimer <= 0f) { _pullTimer = 0.58f; PullLinkedTargets(); BodyImpact(74f); } } private void Roam() { //IL_0029: 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_0073: Unknown result type (might be due to invalid IL or missing references) if (!(_destinationTimer > 0f)) { _destinationTimer = Random.Range(2.2f, 3.7f); LevelPoint val = SemiFunc.LevelPointGetPlayerDistance(((Component)this).transform.position, 7f, 32f, false) ?? SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 5f); if ((Object)(object)val != (Object)null) { ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, ((Component)val).transform.position, 4f); } } } private void RoamAround(Vector3 around) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_003c: 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_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) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (!(_destinationTimer > 0f)) { _destinationTimer = 0.8f; Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(3.5f, 6f); MoveToward(around + new Vector3(val.x, 0f, val.y), 0f, 0.8f); } } private void MoveToward(Vector3 point, float refresh, float speedScale = 1f) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (!(_destinationTimer > 0f)) { _destinationTimer = refresh; _agent.speed = Mathf.Max(1f, Plugin.Settings.CupidSwimSpeed.Value * speedScale); ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, point, 3.5f); } } private void SeekFirstFiringLane(Vector3 target) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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) if (!(_destinationTimer > 0f)) { Vector3 val = ((Component)this).transform.position - target; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.04f) { val = ((((Vector3)(ref _visualForward)).sqrMagnitude > 0.01f) ? (-_visualForward) : Vector3.back); } ((Vector3)(ref val)).Normalize(); float num = HorizontalDistanceXZ(((Component)this).transform.position, target); Vector3 requested; if (num < 5.8f || num > 12.5f) { requested = target + val * 7.4f; } else { float num2 = ((Mathf.Sin(_phase) >= 0f) ? 1f : (-1f)); requested = ((Component)this).transform.position + Vector3.Cross(Vector3.up, val) * (2.8f * num2); } _destinationTimer = 0.32f; _agent.speed = Mathf.Max(1f, Plugin.Settings.CupidSwimSpeed.Value * 1.05f); ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, requested, 3.5f); } } private static float HorizontalDistanceXZ(Vector3 left, Vector3 right) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) left.y = 0f; right.y = 0f; return Vector3.Distance(left, right); } private PlayerAvatar FindNearestPlayer(PlayerAvatar excluded, float radius = -1f) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar result = null; float num = ((radius > 0f) ? radius : Mathf.Max(12f, Plugin.Settings.CupidDetectionRange.Value * 1.5f)); float num2 = num * num; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (!((Object)(object)item == (Object)(object)excluded) && GunAccess.IsLiving(item)) { Vector3 val = ((Component)item).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num2) { num2 = sqrMagnitude; result = item; } } } return result; } private PhysGrabObject FindHeavyValuable() { //IL_00b4: 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) PhysGrabObject val = null; PhysGrabObject val2 = null; float num = 14400f; float num2 = 0f; float num3 = 14400f; ValuableObject[] array = Object.FindObjectsOfType(); foreach (ValuableObject val3 in array) { if ((Object)(object)val3 == (Object)null || MapIconSuppressor.OwnsValuable(val3)) { continue; } PhysGrabObject val4 = ((Component)val3).GetComponentInParent() ?? ((Component)val3).GetComponentInChildren(true); if (!((Object)(object)val4 == (Object)null) && !val4.dead && !((Object)(object)val4.rb == (Object)null) && !IsOwnPhys(val4) && (!((Object)(object)val4 == (Object)(object)_recentlyBlockedValuable) || !(Time.time < _recentlyBlockedValuableUntil))) { Vector3 val5 = val4.centerPoint - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude; if (val4.massOriginal >= 4.5f && sqrMagnitude < num) { num = sqrMagnitude; val = val4; } else if (val4.massOriginal >= 1.5f && (val4.massOriginal > num2 + 0.01f || (Mathf.Abs(val4.massOriginal - num2) <= 0.01f && sqrMagnitude < num3))) { num2 = val4.massOriginal; num3 = sqrMagnitude; val2 = val4; } } } return val ?? val2; } private float MovingTargetTolerance(float minimum) { //IL_0001: 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) float num = Vector3.Distance(_shotOrigin, _shotEndPoint); return Mathf.Clamp(minimum + num * 0.035f, minimum, 2.2f); } private Vector3 ResolveMissLanding(Vector3 point, Vector3 direction) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0043: 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_004d: 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_004f: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_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) //IL_008d: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) //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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_013c: 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_0143: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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) Vector3 val = ((((Vector3)(ref direction)).sqrMagnitude > 0.001f) ? ((Vector3)(ref direction)).normalized : ((((Vector3)(ref _visualForward)).sqrMagnitude > 0.001f) ? ((Vector3)(ref _visualForward)).normalized : Vector3.forward)); Vector3 val2 = point + val * 0.06f; Vector3 to = val2 + val * 22f; if (TryFindArrowObstruction(val2, to, null, null, out var obstruction)) { return ((RaycastHit)(ref obstruction)).point - val * 0.035f; } RaycastHit[] array = Physics.RaycastAll(point + val * 8f + Vector3.up * 4f, Vector3.down, 18f, -5, (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val3 = array2[num]; if (!((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null) && !IsOwnCollider(((RaycastHit)(ref val3)).collider)) { return ((RaycastHit)(ref val3)).point + Vector3.up * 0.055f; } } NavMeshHit val4 = default(NavMeshHit); if (NavMesh.SamplePosition(point + val * 8f, ref val4, 10f, -1)) { return ((NavMeshHit)(ref val4)).position + Vector3.up * 0.055f; } return ((Component)this).transform.position + Vector3.up * 0.12f; } private bool SecondValid() { if (!GunAccess.IsLiving(_secondPlayer)) { if ((Object)(object)_secondValuable != (Object)null && !IsOwnPhys(_secondValuable) && !_secondValuable.dead) { return ((Component)_secondValuable).gameObject.activeInHierarchy; } return false; } return true; } private Vector3 SecondPoint() { //IL_003a: 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_0022: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_secondPlayer != (Object)null)) { if (!((Object)(object)_secondValuable != (Object)null)) { return ((Component)this).transform.position; } return _secondValuable.centerPoint; } return PlayerPoint(_secondPlayer); } private static Vector3 PlayerPoint(PlayerAvatar player) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_001a: Unknown result type (might be due to invalid IL or missing references) return ((Component)player).transform.position + Vector3.up * 0.72f; } private static Vector3 PlayerArrowPoint(PlayerAvatar player, Vector3 direction) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_007b: Unknown result type (might be due to invalid IL or missing references) //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) if ((Object)(object)player == (Object)null) { return Vector3.zero; } if (((Vector3)(ref direction)).sqrMagnitude < 0.001f) { direction = ((Component)player).transform.forward; } direction.y = 0f; if (((Vector3)(ref direction)).sqrMagnitude < 0.001f) { direction = Vector3.forward; } return ((Component)player).transform.position + Vector3.up * 1.02f - ((Vector3)(ref direction)).normalized * 0.34f; } private Vector3 SecondArrowPoint(Vector3 direction) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_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) //IL_006b: 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_0043: 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) if ((Object)(object)_secondPlayer != (Object)null) { return PlayerArrowPoint(_secondPlayer, direction); } if ((Object)(object)_secondValuable == (Object)null) { return ((Component)this).transform.position; } if (((Vector3)(ref direction)).sqrMagnitude < 0.001f) { direction = Vector3.up; } return _secondValuable.centerPoint - ((Vector3)(ref direction)).normalized * 0.2f + Vector3.up * 0.12f; } private Vector3 VisualCenter() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_001a: Unknown result type (might be due to invalid IL or missing references) return ((Component)this).transform.position + Vector3.up * 1.24f; } private Vector3 PreparedArrowTip(Vector3 direction) { //IL_0016: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0042: 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_0013: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref direction)).sqrMagnitude < 0.001f) { direction = Vector3.forward; } return VisualCenter() + ((Vector3)(ref direction)).normalized * ShaftHalfLength(0) + Vector3.up * 0.1f; } private void PullLinkedTargets() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0042: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00e2: Unknown result type (might be due to invalid IL or missing references) Vector3 val = PlayerPoint(_first); Vector3 val2 = SecondPoint(); float num = Vector3.Distance(val, val2); float num2 = Mathf.Max(2.5f, Plugin.Settings.CupidTetherDistance.Value * 0.82f); if (!(num <= num2) && HasClearTetherLine(val, val2) && TryPathDirections(val, val2, out var firstDirection, out var secondDirection)) { float num3 = Mathf.Clamp(21f + (num - num2) * 2.25f, 21f, 45f); PullPlayer(_first, firstDirection, num3); if ((Object)(object)_secondPlayer != (Object)null) { PullPlayer(_secondPlayer, secondDirection, num3); } else if ((Object)(object)_secondValuable?.rb != (Object)null && !_secondValuable.rb.isKinematic) { _secondValuable.rb.AddForce(secondDirection * num3, (ForceMode)2); } BodyImpact(96f); } } private bool HasClearTetherLine(Vector3 from, Vector3 to) { //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) //IL_0002: 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_0018: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = to - from; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return true; } RaycastHit[] array = Physics.RaycastAll(from, ((Vector3)(ref val)).normalized, ((Vector3)(ref val)).magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val2 = array2[num]; if ((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null || IsOwnCollider(((RaycastHit)(ref val2)).collider)) { continue; } PlayerAvatar componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)(object)_first) && !((Object)(object)componentInParent == (Object)(object)_secondPlayer)) { PhysGrabObject componentInParent2 = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent(); if ((!((Object)(object)componentInParent2 != (Object)null) || (!((Object)(object)_secondValuable == (Object)null) && SameItemScope(componentInParent2, _secondValuable))) && (!((Object)(object)componentInParent2 != (Object)null) || !((Object)(object)_secondValuable != (Object)null)) && !((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent() != (Object)null)) { return false; } } } return true; } private static bool TryPathDirections(Vector3 first, Vector3 second, out Vector3 firstDirection, out Vector3 secondDirection) { //IL_0002: 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_0008: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_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_0077: 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_008d: 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_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_009c: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) firstDirection = (secondDirection = Vector3.zero); NavMeshHit val = default(NavMeshHit); NavMeshHit val2 = default(NavMeshHit); if (!NavMesh.SamplePosition(first, ref val, 3f, -1) || !NavMesh.SamplePosition(second, ref val2, 3f, -1)) { return false; } NavMeshPath val3 = new NavMeshPath(); if (!NavMesh.CalculatePath(((NavMeshHit)(ref val)).position, ((NavMeshHit)(ref val2)).position, -1, val3) || (int)val3.status != 0 || val3.corners.Length < 2) { return false; } Vector3 val4 = val3.corners[1] - first; Vector3 val5 = val3.corners[val3.corners.Length - 2] - second; val4.y = Mathf.Clamp(val4.y, -0.25f, 0.5f); val5.y = Mathf.Clamp(val5.y, -0.25f, 0.5f); if (((Vector3)(ref val4)).sqrMagnitude < 0.01f || ((Vector3)(ref val5)).sqrMagnitude < 0.01f) { return false; } firstDirection = ((Vector3)(ref val4)).normalized; secondDirection = ((Vector3)(ref val5)).normalized; return true; } private static void PullPlayer(PlayerAvatar player, Vector3 direction, float force) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) PlayerTumble val = ((player != null) ? ((Component)player).GetComponentInChildren(true) : null); if (!((Object)(object)val == (Object)null)) { val.TumbleRequest(true, false); val.TumbleForce(direction * force + Vector3.up * 1.1f); } } internal void TryShareDamage(PlayerAvatar source, int damage) { //IL_00ce: 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) if (_state != State.Linked || damage <= 0 || (Object)(object)source == (Object)null || ((Object)(object)source != (Object)(object)_first && (Object)(object)source != (Object)(object)_secondPlayer)) { return; } int instanceID = ((Object)source).GetInstanceID(); if (_lastSharedSource == instanceID && _lastSharedAmount == damage && Time.time - _lastSharedDamage < 0.09f) { return; } _lastSharedSource = instanceID; _lastSharedAmount = damage; _lastSharedDamage = Time.time; int num = Mathf.Max(1, Mathf.RoundToInt((float)damage * Mathf.Clamp01(Plugin.Settings.CupidDamageShare.Value))); PlayerAvatar val = (((Object)(object)source == (Object)(object)_first) ? _secondPlayer : _first); if (GunAccess.IsLiving(val)) { PlayerHealth playerHealth = val.playerHealth; if (playerHealth != null) { playerHealth.HurtOther(num, PlayerPoint(val), false, -742103, false); } } else if ((Object)(object)source == (Object)(object)_first && (Object)(object)_secondImpact != (Object)null) { _secondImpact.BreakLight(_secondValuable.centerPoint, false); } } private void AttachValuableListeners() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown DetachValuableListeners(); if ((Object)(object)_secondValuable == (Object)null) { return; } _secondImpact = ((Component)_secondValuable).GetComponentInParent() ?? ((Component)_secondValuable).GetComponentInChildren(true); _secondValuable.OverrideIndestructible(2.05f); PhysGrabObjectImpactDetector secondImpact = _secondImpact; if (secondImpact != null) { UnityEvent onAllBreaks = secondImpact.onAllBreaks; if (onAllBreaks != null) { onAllBreaks.AddListener(new UnityAction(OnValuableBreak)); } } PhysGrabObjectImpactDetector secondImpact2 = _secondImpact; if (secondImpact2 != null) { UnityEvent onDestroy = secondImpact2.onDestroy; if (onDestroy != null) { onDestroy.AddListener(new UnityAction(OnValuableDestroyed)); } } } private void DetachValuableListeners() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown PhysGrabObjectImpactDetector secondImpact = _secondImpact; if (secondImpact != null) { UnityEvent onAllBreaks = secondImpact.onAllBreaks; if (onAllBreaks != null) { onAllBreaks.RemoveListener(new UnityAction(OnValuableBreak)); } } PhysGrabObjectImpactDetector secondImpact2 = _secondImpact; if (secondImpact2 != null) { UnityEvent onDestroy = secondImpact2.onDestroy; if (onDestroy != null) { onDestroy.RemoveListener(new UnityAction(OnValuableDestroyed)); } } _secondImpact = null; } private void OnValuableBreak() { DamageFirstFromValuableDamage(18); } private void OnValuableDestroyed() { DamageFirstFromValuableDamage(30); } private void DamageFirstFromValuableDamage(int damage) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (_state == State.Linked && GunAccess.IsLiving(_first) && !(Time.time - _lastValuableBreakDamage < 0.16f)) { _lastValuableBreakDamage = Time.time; PlayerHealth playerHealth = _first.playerHealth; if (playerHealth != null) { playerHealth.HurtOther(Mathf.Max(1, damage), PlayerPoint(_first), false, -742103, false); } } } private void ResetHunt() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_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) DetachValuableListeners(); _first = null; _secondPlayer = null; _secondValuable = null; _firstArrowAttached = false; _secondArrowAttached = false; _blockedArrowIndex = -1; _blockedArrowPoint = Vector3.zero; _recoveryPickupTimer = -1f; _recoveryLandingTimer = -1f; _shotEndPoint = Vector3.zero; _lastValuableBreakDamage = -10f; _firstAimTimer = 0f; SetState(State.SearchFirst); _scanTimer = 0f; } private void UpdateHeading() { //IL_0028: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) ? _agent.velocity : Vector3.zero); val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.04f) { Vector3 val2 = Vector3.Slerp(_visualForward, ((Vector3)(ref val)).normalized, 1f - Mathf.Exp(-4.5f * Time.deltaTime)); _visualForward = ((Vector3)(ref val2)).normalized; } } private void PinVisuals() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00fb: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: 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_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028e: 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_0296: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: 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_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: 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_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) float num = Time.time + _phase; Vector3 center = VisualCenter() + Vector3.up * (Mathf.Sin(num * 2.05f) * 0.11f); Vector3 val = ((((Vector3)(ref _visualForward)).sqrMagnitude > 0.01f) ? _visualForward : Vector3.forward); Vector3 val2 = Vector3.Cross(Vector3.up, val); Vector3 normalized = ((Vector3)(ref val2)).normalized; Vector3 up = Vector3.up; if (_state == State.RecoverArrow && _blockedArrowIndex == 0) { PinArrow(0, _blockedArrowPoint, _blockedArrowDirection); } else if (_state == State.PrepareFirst) { float num2 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(_stateTimer / 0.92f)); Vector3 val3 = up; val2 = Vector3.Slerp(val3, _firstArrowDirection, num2); Vector3 normalized2 = ((Vector3)(ref val2)).normalized; Vector3 val4 = Vector3.Lerp(IdleArrowTip(center, val3), PreparedArrowTip(_firstArrowDirection), num2); val4 += normalized * Mathf.Sin(num2 * MathF.PI) * 0.11f; PinArrow(0, val4, normalized2, num2 * 210f); } else if (_state == State.FireFirst) { float num3 = Mathf.Clamp01(_stateTimer / 0.72f); Vector3 tip = Arc(_shotOrigin, _shotEndPoint, num3); val2 = _shotEndPoint - _shotOrigin; PinArrow(0, tip, ((Vector3)(ref val2)).normalized, num3 * 720f); } else if (_firstArrowAttached && (Object)(object)_first != (Object)null) { PinArrow(0, PlayerArrowPoint(_first, _firstArrowDirection), _firstArrowDirection); } else { Vector3 direction = up; PinArrow(0, IdleArrowTip(center, direction), direction); } if (_state == State.RecoverArrow && _blockedArrowIndex == 1) { PinArrow(1, _blockedArrowPoint, _blockedArrowDirection); } else if (_state == State.PrepareSecond) { float num4 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(_stateTimer / 1.02f)); val2 = normalized * 0.82f + up * 0.57f; Vector3 normalized3 = ((Vector3)(ref val2)).normalized; val2 = Vector3.Slerp(normalized3, _secondArrowDirection, num4); Vector3 normalized4 = ((Vector3)(ref val2)).normalized; Vector3 val5 = Vector3.Lerp(IdleArrowTip(center, normalized3), PreparedArrowTip(_secondArrowDirection), num4); val5 -= normalized * Mathf.Sin(num4 * MathF.PI) * 0.13f; PinArrow(1, val5, normalized4, (0f - num4) * 240f); } else if (_state == State.FireSecond) { float num5 = Mathf.Clamp01(_stateTimer / 0.78f); Vector3 tip2 = Arc(_shotOrigin, _shotEndPoint, num5); val2 = _shotEndPoint - _shotOrigin; PinArrow(1, tip2, ((Vector3)(ref val2)).normalized, (0f - num5) * 720f); } else if (_secondArrowAttached) { PinArrow(1, SecondArrowPoint(_secondArrowDirection), _secondArrowDirection); } else { val2 = normalized * 0.82f + up * 0.57f; Vector3 normalized5 = ((Vector3)(ref val2)).normalized; PinArrow(1, IdleArrowTip(center, normalized5), normalized5); } if (_firstArrowAttached && _secondArrowAttached) { Vector3 val6 = PlayerPoint(_first); Vector3 val7 = SecondPoint(); val2 = val7 - val6; Vector3 normalized6 = ((Vector3)(ref val2)).normalized; PinArrow(2, (val6 + val7) * 0.5f + normalized6 * ShaftHalfLength(2), normalized6); } else { val2 = -normalized * 0.82f + up * 0.57f; Vector3 normalized7 = ((Vector3)(ref val2)).normalized; PinArrow(2, IdleArrowTip(center, normalized7), normalized7); } } private Vector3 IdleArrowTip(Vector3 center, Vector3 direction) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) return center + ((Vector3)(ref direction)).normalized * ShaftHalfLength(0); } private float ShaftHalfLength(int arrowIndex) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) foreach (CupidPart part in _parts) { if (part == null || part.ArrowIndex != arrowIndex || part.Role != CupidPartRole.Shaft || part.Spawned == null) { continue; } if (part.MeasuredHalfLength > 0.02f) { return part.MeasuredHalfLength; } PhysGrabObject phys = part.Spawned.Phys; Transform val = ((phys != null) ? ((Component)phys).transform : null); Vector3 normalized; if (!((Object)(object)val != (Object)null)) { normalized = ((Vector3)(ref part.Spawned.LongAxisLocal)).normalized; } else { Vector3 val2 = val.TransformDirection(part.Spawned.LongAxisLocal); normalized = ((Vector3)(ref val2)).normalized; } Vector3 val3 = normalized; float num = float.PositiveInfinity; float num2 = float.NegativeInfinity; Renderer[] array = (Renderer[])(((object)part.Spawned.Renderers) ?? ((object)new Renderer[0])); foreach (Renderer val4 in array) { if (!((Object)(object)val4 == (Object)null) && val4.enabled) { Bounds bounds = val4.bounds; float num3 = Vector3.Dot(((Bounds)(ref bounds)).center, val3); float num4 = Mathf.Abs(val3.x) * ((Bounds)(ref bounds)).extents.x + Mathf.Abs(val3.y) * ((Bounds)(ref bounds)).extents.y + Mathf.Abs(val3.z) * ((Bounds)(ref bounds)).extents.z; num = Mathf.Min(num, num3 - num4); num2 = Mathf.Max(num2, num3 + num4); } } if (!float.IsInfinity(num) && num2 - num > 0.05f) { part.MeasuredHalfLength = Mathf.Clamp((num2 - num) * 0.5f, 0.2f, 1.4f); return part.MeasuredHalfLength; } } return 0.48f; } private static Vector3 Arc(Vector3 from, Vector3 to, float t) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_004e: 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_005d: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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) float num = Mathf.Clamp01(t); Vector3 val = to - from; Vector3 val2 = Vector3.Cross(((Vector3)(ref val)).normalized, Vector3.up); if (((Vector3)(ref val2)).sqrMagnitude < 0.001f) { val2 = Vector3.right; } return Vector3.Lerp(from, to, num) + Vector3.up * Mathf.Sin(num * MathF.PI) * 0.32f + ((Vector3)(ref val2)).normalized * Mathf.Sin(num * MathF.PI) * 0.055f; } private static Vector3 ArcTangent(Vector3 from, Vector3 to) { //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) //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Arc(from, to, 1f) - Arc(from, to, 0.975f); if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = to - from; } if (!(((Vector3)(ref val)).sqrMagnitude > 0.0001f)) { return Vector3.forward; } return ((Vector3)(ref val)).normalized; } private void PinArrow(int arrowIndex, Vector3 tip, Vector3 direction, float roll = 0f) { //IL_0024: 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_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_0041: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref direction)).sqrMagnitude < 0.001f) { direction = Vector3.up; } ((Vector3)(ref direction)).Normalize(); float num = ShaftHalfLength(arrowIndex); Vector3 val = tip - direction * Mathf.Max(0.05f, num - 0.09f); foreach (CupidPart part in _parts) { if (part.ArrowIndex == arrowIndex && !((Object)(object)part.Spawned?.Phys == (Object)null)) { Vector3 val2 = ((part.Role == CupidPartRole.Heart) ? (-direction) : direction); Quaternion val3 = AlignLongAxis(part.Spawned.LongAxisLocal, val2, Vector3.up); val3 = Quaternion.AngleAxis(roll, val2) * val3; Vector3 val4 = ((part.Role == CupidPartRole.Heart) ? tip : val) - val3 * part.Spawned.VisualCenterOffset; part.Spawned.ImpactDetector.destroyDisable = true; part.Spawned.Phys.OverrideGrabDisable(0.3f); part.Spawned.Phys.OverrideKinematic(0.3f); part.Spawned.Phys.OverrideIndestructible(0.3f); part.Spawned.Phys.SetPositionLogic(val4, val3); } } } private static Quaternion AlignLongAxis(Vector3 localAxis, Vector3 worldDirection, Vector3 normal) { //IL_0017: 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_001c: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0056: 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_005c: 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_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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((((Vector3)(ref localAxis)).sqrMagnitude > 0.001f) ? ((Vector3)(ref localAxis)).normalized : Vector3.up); Quaternion val2 = Quaternion.FromToRotation(val, worldDirection); Vector3 val3 = ((Mathf.Abs(Vector3.Dot(val, Vector3.up)) < 0.92f) ? Vector3.up : Vector3.forward); Vector3 val4 = Vector3.ProjectOnPlane(val2 * val3, worldDirection); Vector3 val5 = Vector3.ProjectOnPlane(normal, worldDirection); if (((Vector3)(ref val4)).sqrMagnitude < 0.0001f || ((Vector3)(ref val5)).sqrMagnitude < 0.0001f) { return val2; } return Quaternion.AngleAxis(Vector3.SignedAngle(val4, val5, worldDirection), worldDirection) * val2; } private bool TryFindArrowObstruction(Vector3 from, Vector3 to, PlayerAvatar allowedPlayer, PhysGrabObject allowedValuable, out RaycastHit obstruction) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_010a: 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) obstruction = default(RaycastHit); Vector3 val = to - from; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.005f) { return false; } RaycastHit[] array = Physics.SphereCastAll(from, 0.045f, val / magnitude, magnitude, -5, (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val2 = array2[num]; Collider collider = ((RaycastHit)(ref val2)).collider; if ((Object)(object)collider == (Object)null || IsOwnCollider(collider)) { continue; } PlayerAvatar val3 = ((Component)collider).GetComponentInParent() ?? ((Component)collider).GetComponentInChildren(true); if ((Object)(object)val3 != (Object)null) { if ((Object)(object)val3 == (Object)(object)allowedPlayer) { return false; } obstruction = val2; return true; } PlayerTumble val4 = ((Component)collider).GetComponentInParent() ?? ((Component)collider).GetComponentInChildren(true); if ((Object)(object)val4 != (Object)null && (Object)(object)val4.playerAvatar != (Object)null) { if ((Object)(object)val4.playerAvatar == (Object)(object)allowedPlayer) { return false; } obstruction = val2; return true; } PhysGrabObject val5 = ((Component)collider).GetComponentInParent() ?? ((Component)collider).GetComponentInChildren(true); if ((Object)(object)val5 != (Object)null && SameItemScope(val5, allowedValuable)) { return false; } if ((Object)(object)val5 != (Object)null && IsHeldByPlayer(val5, allowedPlayer)) { return false; } obstruction = val2; return true; } return false; } private static bool IsHeldByPlayer(PhysGrabObject phys, PlayerAvatar player) { if ((Object)(object)phys == (Object)null || (Object)(object)player == (Object)null || phys.playerGrabbing == null) { return false; } foreach (PhysGrabber item in phys.playerGrabbing) { if ((Object)(object)item != (Object)null && (Object)(object)item.playerAvatar == (Object)(object)player) { return true; } } return false; } private static bool SameItemScope(PhysGrabObject left, PhysGrabObject right) { if ((Object)(object)left == (Object)null || (Object)(object)right == (Object)null) { return false; } if ((Object)(object)left == (Object)(object)right) { return true; } PhotonView componentInParent = ((Component)left).GetComponentInParent(); PhotonView componentInParent2 = ((Component)right).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent2 != (Object)null && componentInParent.ViewID != 0 && componentInParent.ViewID == componentInParent2.ViewID) { return true; } Transform transform = ((Component)left).transform; Transform transform2 = ((Component)right).transform; if (!((Object)(object)transform == (Object)(object)transform2) && !transform.IsChildOf(transform2)) { return transform2.IsChildOf(transform); } return true; } private bool HasLineOfSight(Vector3 target, Transform allowed) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_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) Vector3 val = VisualCenter(); Vector3 val2 = target - val; RaycastHit[] array = Physics.RaycastAll(val, ((Vector3)(ref val2)).normalized, ((Vector3)(ref val2)).magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val3 = array2[num]; if ((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null || IsOwnCollider(((RaycastHit)(ref val3)).collider)) { continue; } if ((Object)(object)allowed != (Object)null && ((Object)(object)((Component)((RaycastHit)(ref val3)).collider).transform == (Object)(object)allowed || ((Component)((RaycastHit)(ref val3)).collider).transform.IsChildOf(allowed) || allowed.IsChildOf(((Component)((RaycastHit)(ref val3)).collider).transform))) { return true; } PlayerAvatar val4 = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() ?? ((Component)((RaycastHit)(ref val3)).collider).GetComponentInChildren(true); if ((Object)(object)val4 != (Object)null) { if ((Object)(object)allowed != (Object)null) { return (Object)(object)((Component)val4).transform == (Object)(object)allowed; } return false; } PhysGrabObject componentInParent = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { if ((Object)(object)_secondValuable != (Object)null && (Object)(object)componentInParent == (Object)(object)_secondValuable) { return true; } } else if (!((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() != (Object)null)) { return false; } } return true; } private void UpdateLinkBeam() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_0106: Invalid comparison between Unknown and I4 //IL_0165: 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_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) MarionetteDronePart marionetteDronePart = _spawned?.LinkEmitter; if ((Object)(object)marionetteDronePart?.Phys == (Object)null || (Object)(object)marionetteDronePart.Drone == (Object)null || (Object)(object)marionetteDronePart.Toggle == (Object)null) { return; } Vector3 val = PlayerPoint(_first) + Vector3.up * 0.18f; Vector3 val2 = SecondPoint() - val; Quaternion val3 = ((((Vector3)(ref val2)).sqrMagnitude > 0.001f) ? Quaternion.LookRotation(((Vector3)(ref val2)).normalized, Vector3.up) : Quaternion.identity); marionetteDronePart.Impact.destroyDisable = true; marionetteDronePart.Phys.OverrideGrabDisable(0.3f); marionetteDronePart.Phys.OverrideKinematic(0.3f); marionetteDronePart.Phys.OverrideIndestructible(0.3f); marionetteDronePart.Phys.SetPositionLogic(val - val3 * marionetteDronePart.VisualCenterOffset, val3); if (_linkBeamAttached && (int)marionetteDronePart.Drone.currentState == 3) { return; } _linkBeamAttached = false; if (!marionetteDronePart.Toggle.toggleState) { marionetteDronePart.Toggle.ToggleItem(true, -1); _linkBeamTimer = 0.26f; } else { if (_linkBeamTimer > 0f || NewRayHitPointMethod == null) { return; } try { Vector3 val4; int num; int num2; Transform val5; if (GunAccess.IsLiving(_secondPlayer)) { val4 = PlayerPoint(_secondPlayer); num = (((Object)(object)_secondPlayer.photonView != (Object)null) ? _secondPlayer.photonView.ViewID : 0); num2 = -1; val5 = _secondPlayer.PlayerVisionTarget.VisionTransform; } else { PhysGrabObject secondValuable = _secondValuable; object obj = ((secondValuable != null) ? ((Component)secondValuable).GetComponent() : null); if (obj == null) { PhysGrabObject secondValuable2 = _secondValuable; obj = ((secondValuable2 != null) ? ((Component)secondValuable2).GetComponentInParent() : null); } PhotonView val6 = (PhotonView)obj; PhysGrabObject secondValuable3 = _secondValuable; PhysGrabObjectCollider val7 = ((secondValuable3 != null) ? ((Component)secondValuable3).GetComponentInChildren(true) : null); if ((Object)(object)val6 == (Object)null || (GameManager.Multiplayer() && val6.ViewID == 0) || (Object)(object)val7 == (Object)null) { _linkBeamTimer = 0.55f; return; } val4 = ((Component)val7).transform.position; num = val6.ViewID; num2 = val7.colliderID; val5 = ((Component)_secondValuable).transform; } if (GunAccess.IsLiving(_secondPlayer)) { PlayerAvatarTargetField?.SetValue(marionetteDronePart.Drone, _secondPlayer); TargetIsPlayerField?.SetValue(marionetteDronePart.Drone, true); TargetIsLocalPlayerField?.SetValue(marionetteDronePart.Drone, (Object)(object)_secondPlayer.photonView != (Object)null && _secondPlayer.photonView.IsMine); } NewRayHitPointMethod.Invoke(marionetteDronePart.Drone, new object[4] { val4, num, num2, val5 }); marionetteDronePart.Drone.MagnetActiveToggle(true); marionetteDronePart.Drone.StateSet((State)3); _linkBeamAttached = true; Plugin.Log.LogInfo((object)"The Cupid published its vanilla tether beam for host and unmodded guests."); } catch (Exception ex) { _linkBeamTimer = 0.55f; Plugin.Log.LogWarning((object)("The Cupid could not publish its tether beam: " + ex.GetBaseException().Message)); } } } private void ClearLinkBeam() { MarionetteDronePart marionetteDronePart = _spawned?.LinkEmitter; _linkBeamAttached = false; _linkBeamTimer = 0f; if ((Object)(object)marionetteDronePart?.Drone == (Object)null) { return; } marionetteDronePart.Drone.MagnetActiveToggle(false); marionetteDronePart.Drone.StateSet((State)0); try { ItemToggle toggle = marionetteDronePart.Toggle; if (toggle != null) { toggle.ToggleItem(false, -1); } } catch { } } private bool HasLineOfSightToPlayer(PlayerAvatar player) { //IL_0010: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(player)) { return false; } Vector3 position = ((Component)player).transform.position; Vector3 right = ((Component)player).transform.right; float[] array = new float[4] { 0.48f, 0.9f, 1.3f, 1.62f }; float[] array2 = new float[3] { 0f, -0.28f, 0.28f }; float[] array3 = array; foreach (float num in array3) { float[] array4 = array2; foreach (float num2 in array4) { if (HasLineOfSight(position + Vector3.up * num + right * num2, ((Component)player).transform)) { return true; } } } return false; } private bool HasEmergencyFiringLine(PlayerAvatar player) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(player)) { return false; } Vector3 val = VisualCenter() + Vector3.up * 0.24f; Vector3 val2 = ((Component)player).transform.position + Vector3.up * 1.34f - val; RaycastHit[] array = Physics.RaycastAll(val, ((Vector3)(ref val2)).normalized, ((Vector3)(ref val2)).magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val3 = array2[num]; Collider collider = ((RaycastHit)(ref val3)).collider; if ((Object)(object)collider == (Object)null || IsOwnCollider(collider)) { continue; } if ((Object)(object)((Component)collider).GetComponentInParent() == (Object)(object)player) { return true; } PlayerTumble componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.playerAvatar == (Object)(object)player) { return true; } if (!((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)collider).GetComponentInParent() != (Object)null)) { Bounds bounds = collider.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (Mathf.Max(size.x, Mathf.Max(size.y, size.z)) >= 1.35f) { return false; } } } return true; } private bool IsOwnCollider(Collider collider) { foreach (CupidPart part in _parts) { if ((Object)(object)part?.Spawned?.Root != (Object)null && ((Object)(object)((Component)collider).transform == (Object)(object)part.Spawned.Root.transform || ((Component)collider).transform.IsChildOf(part.Spawned.Root.transform))) { return true; } } if ((Object)(object)_spawned?.LinkEmitter?.Root != (Object)null && ((Object)(object)((Component)collider).transform == (Object)(object)_spawned.LinkEmitter.Root.transform || ((Component)collider).transform.IsChildOf(_spawned.LinkEmitter.Root.transform))) { return true; } return false; } private bool IsOwnPhys(PhysGrabObject phys) { if ((Object)(object)phys == (Object)null) { return false; } foreach (CupidPart part in _parts) { if ((Object)(object)part?.Spawned?.Phys == (Object)(object)phys) { return true; } } return false; } private void UpdateAudio() { if (!(_soundTimer > 0f)) { _soundTimer = ((_state == State.Linked) ? Random.Range(0.55f, 0.9f) : Random.Range(1.1f, 1.7f)); BodyImpact((_state == State.Linked) ? 72f : 34f); } } private void BodyImpact(float force) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) SpawnedDeadAirPart spawnedDeadAirPart = ((_parts.Count > 1) ? _parts[1].Spawned : null); if (spawnedDeadAirPart != null) { PhysGrabObjectImpactDetector impactDetector = spawnedDeadAirPart.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactLight(force, spawnedDeadAirPart.Phys.centerPoint); } } } private void StopAgent() { if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } } private void SetState(State state) { if (_state == State.Linked && state != State.Linked) { ClearLinkBeam(); } _state = state; _stateTimer = 0f; } internal bool TryClaimWeaponHit(int sourceId) { if (_dead || !ModEnemyWeaponDamage.TryClaim((Object)(object)this, sourceId) || Time.time - _lastClaimedHit < 0.055f) { return false; } _lastClaimedHit = Time.time; return true; } internal void ReceiveWeaponHit(int partIndex, Vector3 point, int damage) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (!_dead && damage > 0) { _health -= damage; CupidPart cupidPart = ((partIndex >= 0 && partIndex < _parts.Count) ? _parts[partIndex] : _parts[0]); if ((Object)(object)cupidPart?.Spawned?.ImpactDetector != (Object)null) { ModEnemyFeedback.DamageHit(cupidPart.Spawned.ImpactDetector, cupidPart.Spawned.Phys, point, 96f); } if (_health <= 0) { Die(); } } } internal void ExecuteForLab() { if (!_dead) { _health = 0; Die(); } } public void ReceiveTumbleAttack(int partIndex, int damage, Vector3 point, Vector3 direction) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ReceiveWeaponHit(partIndex, point, Mathf.Max(1, damage)); _stunTimer = Mathf.Max(_stunTimer, 0.45f); } public void OnTranqStunned(float duration) { _stunTimer = Mathf.Max(_stunTimer, Mathf.Clamp(duration, 0.6f, 5f)); } private void Die() { if (_dead) { return; } _dead = true; SetState(State.Dead); MarionetteSpawner.DestroyDrone(_spawned?.LinkEmitter); if (_spawned != null) { _spawned.LinkEmitter = null; } StopAgent(); DetachValuableListeners(); CupidLinkRegistry.Unregister(this); foreach (CupidPart item in _spawned?.Parts ?? new List()) { if (item != null && item.Spawned?.Alive == true) { item.Spawned.Alive = false; item.Spawned.ImpactDetector.destroyDisable = false; item.Spawned.ImpactDetector.DestroyObject(true); } } _rewardTimer = 0.08f; } private void UpdateDeath() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (_rewardDropped) { return; } _rewardTimer -= Time.deltaTime; if (_rewardTimer > 0f) { return; } _rewardDropped = true; if (Plugin.Settings.CupidDropEnemyValuable.Value && !((Object)(object)AssetManager.instance?.enemyValuableMedium == (Object)null)) { GameObject enemyValuableMedium = AssetManager.instance.enemyValuableMedium; Vector3 val = ((Component)this).transform.position + Vector3.up * 0.5f; if (GameManager.Multiplayer()) { PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)enemyValuableMedium).name, val, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate(enemyValuableMedium, val, Quaternion.identity); } } } private void OnDestroy() { CupidLinkRegistry.Unregister(this); DetachValuableListeners(); if (_initialized && !_cleaning && SemiFunc.IsMasterClientOrSingleplayer()) { _cleaning = true; if (!_dead) { CupidSpawner.Destroy(_spawned); } } } } internal static class CupidLinkRegistry { private static readonly List Controllers = new List(); internal static void Register(CupidController controller) { if ((Object)(object)controller != (Object)null && !Controllers.Contains(controller)) { Controllers.Add(controller); } } internal static void Unregister(CupidController controller) { Controllers.Remove(controller); } internal static void Notify(PlayerAvatar player, int damage, int enemyIndex) { if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)player == (Object)null || damage <= 0 || enemyIndex == -742103) { return; } for (int num = Controllers.Count - 1; num >= 0; num--) { CupidController cupidController = Controllers[num]; if ((Object)(object)cupidController == (Object)null) { Controllers.RemoveAt(num); } else { cupidController.TryShareDamage(player, damage); } } } } [HarmonyPatch(typeof(PlayerHealth), "HurtOtherRPC")] internal static class CupidPlayerDamagePatch { [HarmonyPostfix] private static void Postfix(PlayerHealth __instance, int damage, int enemyIndex) { CupidLinkRegistry.Notify(((Object)(object)__instance != (Object)null) ? (((Component)__instance).GetComponentInParent() ?? ((Component)__instance).GetComponentInChildren(true)) : null, damage, enemyIndex); } } internal sealed class CupidManager : MonoBehaviour { private int _levelId; private float _spawnTimer; private bool _attemptFinished; private bool _probed; private bool _available; private CupidController _encounter; internal void Tick() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (!IsHostReady()) { return; } Probe(); int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } if (!ModEnemyLevelRules.IsPlayableLevel()) { DestroyCurrent(); return; } LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null || !instance.Generated || _attemptFinished) { return; } _spawnTimer -= Time.deltaTime; if (!(_spawnTimer > 0f)) { _attemptFinished = true; if (Random.value <= Mathf.Clamp01(Plugin.Settings.CupidSpawnChance.Value) && TryFindSpawn(out var position)) { Create(position, "automatic"); } } } private void ResetForLevel(int levelId) { DestroyCurrent(); _levelId = levelId; _spawnTimer = Mathf.Max(0f, Plugin.Settings.CupidSpawnDelay.Value); _attemptFinished = false; } private bool Create(Vector3 position, string source) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0085: Unknown result type (might be due to invalid IL or missing references) if (!_available && !CupidSpawner.PrefabsAvailable()) { Plugin.Log.LogWarning((object)"The Cupid could not resolve Love Potion and shaft resources."); return false; } DestroyCurrent(); GameObject val = new GameObject("The Cupid Encounter (Host Logic)"); val.SetActive(false); val.transform.position = position; CupidController cupidController = val.AddComponent(); if (!cupidController.Initialize(position)) { Object.Destroy((Object)(object)val); return false; } val.SetActive(true); if (!cupidController.ActivateNavigation(position)) { Object.Destroy((Object)(object)val); return false; } _encounter = cupidController; Plugin.Log.LogInfo((object)$"The Cupid spawned at {position} ({source})."); return true; } internal bool DebugSpawnAt(Vector3 requested) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (!IsHostReady() || (!ModEnemySpawnCoordinator.IsDirectorRequestActive && (Object)(object)PlayerAvatar.instance == (Object)null) || !ModEnemyLevelRules.IsPlayableLevel()) { return false; } Probe(); NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requested, ref val, 12f, -1)) { return false; } _attemptFinished = true; return Create(((NavMeshHit)(ref val)).position, ModEnemySpawnCoordinator.CurrentSpawnSource); } internal void MarkAutomaticAttemptFinished() { int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } _attemptFinished = true; } internal void DebugDespawn() { if (IsHostReady()) { _attemptFinished = true; DestroyCurrent(); } } private void DestroyCurrent() { if ((Object)(object)_encounter != (Object)null) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); _encounter = null; } } private void Probe() { if (!_probed && !((Object)(object)RunManager.instance == (Object)null)) { _probed = true; _available = CupidSpawner.PrefabsAvailable(); Plugin.Log.LogInfo((object)$"The Cupid prefab probe: available={_available}, heart={CupidSpawner.HeartResource}, shaft={CupidSpawner.ShaftResource}."); } } private static bool TryFindSpawn(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; PlayerAvatar val = null; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { val = item; break; } } Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(val2, 18f, 55f, false) ?? SemiFunc.LevelPointGetFurthestFromPlayer(val2, 8f); return ModEnemyNavigation.TryFindClearSpawn(((Object)(object)val3 != (Object)null) ? ((Component)val3).transform.position : (val2 + Vector3.forward * 18f), 7f, out position); } private static bool IsHostReady() { try { return (Object)(object)GameManager.instance != (Object)null && (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient); } catch { return false; } } } internal sealed class CupidPartHitProxy : MonoBehaviour { private CupidController _controller; private SpawnedDeadAirPart _part; private int _index; private float _cooldown; internal void Initialize(CupidController controller, SpawnedDeadAirPart part, int index) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown _controller = controller; _part = part; _index = index; SpawnedDeadAirPart part2 = _part; if (part2 == null) { return; } PhysGrabObjectImpactDetector impactDetector = part2.ImpactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.AddListener(new UnityAction(OnHit)); } } } private void Update() { _cooldown = Mathf.Max(0f, _cooldown - Time.deltaTime); } private void OnDestroy() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown SpawnedDeadAirPart part = _part; if (part == null) { return; } PhysGrabObjectImpactDetector impactDetector = part.ImpactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.RemoveListener(new UnityAction(OnHit)); } } } private void OnHit() { //IL_0072: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_controller == (Object)null || _cooldown > 0f || !SemiFunc.IsMasterClientOrSingleplayer() || !_controller.TryClaimWeaponHit(ModEnemyWeaponDamage.CurrentClaimId)) { return; } _cooldown = 0.13f; Vector3 val = (((Object)(object)_part?.Phys != (Object)null) ? _part.Phys.centerPoint : ((Component)this).transform.position); if (EnemyLabBridge.IsExecutionHitNear(val)) { _controller.ExecuteForLab(); return; } int num = ModEnemyWeaponDamage.CurrentOrFallback(Plugin.Settings.CupidDamagePerHit.Value); if (num > 0) { _controller.ReceiveWeaponHit(_index, val, num); } } } internal enum CupidPartRole { Shaft, Heart } internal sealed class CupidPart { internal SpawnedDeadAirPart Spawned; internal CupidPartRole Role; internal int ArrowIndex; internal float MeasuredHalfLength; } internal sealed class SpawnedCupid { internal readonly List Parts = new List(); internal MarionetteDronePart LinkEmitter; } internal static class CupidSpawner { private static readonly string[] SizeFolders = new string[7] { "01 Tiny", "02 Small", "03 Medium", "04 Big", "05 Wide", "06 Tall", "07 Very Tall" }; private static string _heartResource; internal static string HeartResource { get { Resolve(); return _heartResource; } } internal static string ShaftResource => "Valuables/07 Very Tall/Valuable Wizard Broom"; internal static bool PrefabsAvailable() { Resolve(); if (!string.IsNullOrEmpty(_heartResource)) { return (Object)(object)Resources.Load(ShaftResource) != (Object)null; } return false; } private static void Resolve() { if (!string.IsNullOrEmpty(_heartResource)) { return; } string[] sizeFolders = SizeFolders; foreach (string text in sizeFolders) { string text2 = "Valuables/" + text + "/Valuable Wizard Love Potion"; if ((Object)(object)Resources.Load(text2) != (Object)null) { _heartResource = text2; break; } } } internal static SpawnedCupid Spawn(Vector3 position) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_003d: 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 (!PrefabsAvailable()) { return null; } SpawnedCupid spawnedCupid = new SpawnedCupid(); for (int i = 0; i < 3; i++) { if (!Add(spawnedCupid, ShaftResource, position, new Vector3(0.012f, 0.19f, 0.012f), CupidPartRole.Shaft, i) || !Add(spawnedCupid, HeartResource, position, new Vector3(0.38f, 0.38f, 0.38f), CupidPartRole.Heart, i)) { Destroy(spawnedCupid); return null; } } spawnedCupid.LinkEmitter = MarionetteSpawner.SpawnBeamEmitter(new Vector3(position.x, 3000f, position.z), "Items/Item Drone Indestructible"); if (spawnedCupid.LinkEmitter == null) { Destroy(spawnedCupid); return null; } return spawnedCupid; } private static bool Add(SpawnedCupid result, string resource, Vector3 position, Vector3 scale, CupidPartRole role, int arrow) { //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) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) SpawnedDeadAirPart spawnedDeadAirPart = DeadAirSpawner.Spawn(resource, position, Quaternion.identity, scale, role == CupidPartRole.Heart, grabbable: false, 2f, (role == CupidPartRole.Shaft) ? 0.004f : 0.04f); if (spawnedDeadAirPart == null) { return false; } try { if (role == CupidPartRole.Shaft) { spawnedDeadAirPart.LongAxisLocal = Vector3.up; } spawnedDeadAirPart.ImpactDetector.destroyDisable = true; spawnedDeadAirPart.ImpactDetector.playerHurtDisable = true; spawnedDeadAirPart.Phys.OverrideGrabDisable(1f); spawnedDeadAirPart.Phys.OverrideKinematic(1f); spawnedDeadAirPart.Phys.OverrideIndestructible(1f); Trap[] componentsInChildren = spawnedDeadAirPart.Root.GetComponentsInChildren(true); foreach (Trap val in componentsInChildren) { if ((Object)(object)val != (Object)null) { ((Behaviour)val).enabled = false; } } HurtCollider[] componentsInChildren2 = spawnedDeadAirPart.Root.GetComponentsInChildren(true); foreach (HurtCollider val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(false); } } ValuableLovePotion[] componentsInChildren3 = spawnedDeadAirPart.Root.GetComponentsInChildren(true); foreach (ValuableLovePotion val3 in componentsInChildren3) { if ((Object)(object)val3 != (Object)null) { ((Behaviour)val3).enabled = false; Object.Destroy((Object)(object)val3); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("The Cupid rejected a visual part: " + ex.Message)); DeadAirSpawner.Destroy(spawnedDeadAirPart); return false; } result.Parts.Add(new CupidPart { Spawned = spawnedDeadAirPart, Role = role, ArrowIndex = arrow }); return true; } internal static void Destroy(SpawnedCupid cupid) { if (cupid == null) { return; } foreach (CupidPart part in cupid.Parts) { if (part?.Spawned != null) { DeadAirSpawner.Destroy(part.Spawned); } } MarionetteSpawner.DestroyDrone(cupid.LinkEmitter); cupid.LinkEmitter = null; cupid.Parts.Clear(); } } internal sealed class DeadAirController : MonoBehaviour, IModEnemyTumbleReceiver { private enum BehaviourState { Hunting, AttackWindup, Recovering, Fleeing, Dead } private readonly List _parts = new List(); private readonly HashSet _claimedWeaponBullets = new HashSet(); private readonly Dictionary _playerLastNoiseTime = new Dictionary(); private NavMeshAgent _agent; private PlayerAvatar _target; private SpawnedDeadAirPart _body; private SpawnedDeadAirPart _grabProxy; private SpawnedDeadAirPart _physicsAnchor; private BehaviourState _state; private int _health; private float _spawnTime; private float _lastNearbyNoiseTime; private Vector3 _lastLoudNoisePosition; private float _destinationTimer; private float _targetTimer; private float _targetOccludedTimer; private float _stateTimer; private float _attackWindupElapsed; private float _movementSoundTimer; private float _movementPulseTimer; private int _movementPulsesRemaining; private int _movementPulseCursor; private float _lastClaimedWeaponHitTime = -999f; private float _rewardTimer; private float _releasedPhysicsTimer; private float _settledPhysicsTimer; private float _slamEligibleUntil; private float _slamDamageCooldown; private float _resumeImpactGraceTimer; private float _grabStartedAt; private Vector3 _slamMotionOrigin; private Vector3 _lastAcceptedSlamPosition; private bool _hasLastAcceptedSlamPosition; private float _tumbleFlinchTimer; private float _damagePulseTimer; private float _damageFeedbackCooldown; private bool _rewardDropped; private bool _wasBodyGrabbed; private bool _agentDisabledForPhysics; private bool _suppressSlamDamage; private float _ignoreOwnNoiseUntil; private Vector3 _lastOwnNoisePosition; private bool _initialized; private bool _cleaningUp; private bool _firstHitLogged; private bool _firstFleeLogged; private bool _firstAttackLogged; private bool _firstMovementSoundLogged; private const float AttackWindupSeconds = 0.55f; private const float RecoverySeconds = 1.1f; private const float FleeSeconds = 5f; private const float ReleasedPhysicsSeconds = 2.75f; private const float InitialQuietObservationSeconds = 2f; private const float SilentDetectionRange = 18f; private const float TargetOcclusionGraceSeconds = 0.35f; private static readonly Quaternion BodySideRotation = Quaternion.AngleAxis(90f, Vector3.up) * Quaternion.AngleAxis(90f, Vector3.right); public bool CanReceiveTumbleAttack { get { if (_initialized) { return _state != BehaviourState.Dead; } return false; } } internal bool Initialize(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00ed: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Expected O, but got Unknown //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: 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_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: 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_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Expected O, but got Unknown //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Expected O, but got Unknown ((Component)this).transform.position = position; _health = Mathf.Max(1, Plugin.Settings.DeadAirHealth.Value); _spawnTime = Time.time; _lastNearbyNoiseTime = Time.time; _state = BehaviourState.Hunting; _agent = ((Component)this).gameObject.AddComponent(); ((Behaviour)_agent).enabled = false; _agent.speed = Mathf.Max(2f, Plugin.Settings.DeadAirHuntSpeed.Value); _agent.acceleration = 45f; _agent.angularSpeed = 720f; _agent.radius = 0.42f; _agent.height = 1.35f; _agent.stoppingDistance = 0.78f; _agent.autoBraking = true; _body = DeadAirSpawner.Spawn("Valuables/04 Big/Valuable Museum Boombox", position, BodySideRotation, Vector3.one * 0.68f, isBody: true, grabbable: true); if (_body == null) { return false; } _body.LocalOffset = new Vector3(0f, Mathf.Max(0.16f, _body.VisualHalfHeight + 0.04f), 0f); _body.LocalRotation = BodySideRotation; _body.SmoothedLocalOffset = _body.LocalOffset; _body.SmoothedLocalRotation = _body.LocalRotation; _body.PoseInitialized = true; _parts.Add(_body); float[] array = new float[3] { -1f, 0f, 1f }; for (int i = 0; i < 2; i++) { float num = ((i == 0) ? (-1f) : 1f); for (int j = 0; j < array.Length; j++) { float num2 = array[j]; bool flag = i == 0 && j == 1; SpawnedDeadAirPart spawnedDeadAirPart = DeadAirSpawner.Spawn("Valuables/07 Very Tall/Valuable Wizard Broom", position, Quaternion.identity, Vector3.one * 0.06f, isBody: false, flag); if (spawnedDeadAirPart == null) { CleanupParts(); return false; } spawnedDeadAirPart.LegStart = new Vector3(num * 0.175f, 0.135f, num2 * 0.17f); spawnedDeadAirPart.LegEnd = new Vector3(num * 0.31f, 0.025f, num2 * 0.235f); spawnedDeadAirPart.LocalOffset = (spawnedDeadAirPart.LegStart + spawnedDeadAirPart.LegEnd) * 0.5f; Vector3 val = spawnedDeadAirPart.LegEnd - spawnedDeadAirPart.LegStart; spawnedDeadAirPart.LegDirection = ((Vector3)(ref val)).normalized; spawnedDeadAirPart.LocalRotation = Quaternion.FromToRotation(spawnedDeadAirPart.LongAxisLocal, spawnedDeadAirPart.LegDirection); spawnedDeadAirPart.GaitPhase = ((((i + j) & 1) == 0) ? 0f : MathF.PI); spawnedDeadAirPart.IsGrabProxy = flag; spawnedDeadAirPart.SmoothedLocalOffset = spawnedDeadAirPart.LocalOffset; spawnedDeadAirPart.SmoothedLocalRotation = spawnedDeadAirPart.LocalRotation; spawnedDeadAirPart.PoseInitialized = true; _parts.Add(spawnedDeadAirPart); if (flag) { _grabProxy = spawnedDeadAirPart; } } } if (_grabProxy == null) { CleanupParts(); return false; } DeadAirGrabRedirect.Register(_body.Phys, _grabProxy.Phys); ((Component)_grabProxy.Phys).gameObject.AddComponent().Initialize(_grabProxy.Phys); ((Component)_body.Phys).gameObject.AddComponent().Initialize(_body.Phys); IgnoreSelfCollisions(); for (int k = 0; k < _parts.Count; k++) { SpawnedDeadAirPart spawnedDeadAirPart2 = _parts[k]; ((Component)spawnedDeadAirPart2.Phys).gameObject.AddComponent().Initialize(this, k, spawnedDeadAirPart2.ImpactDetector, spawnedDeadAirPart2.Renderers); ((Component)spawnedDeadAirPart2.Phys).gameObject.AddComponent().Initialize(this, k); } UnityEvent onImpactMedium = _grabProxy.ImpactDetector.onImpactMedium; if (onImpactMedium != null) { onImpactMedium.AddListener(new UnityAction(OnBodyImpactMedium)); } UnityEvent onImpactHeavy = _grabProxy.ImpactDetector.onImpactHeavy; if (onImpactHeavy != null) { onImpactHeavy.AddListener(new UnityAction(OnBodyImpactHeavy)); } UnityEvent onImpactMedium2 = _body.ImpactDetector.onImpactMedium; if (onImpactMedium2 != null) { onImpactMedium2.AddListener(new UnityAction(OnBodyImpactMedium)); } UnityEvent onImpactHeavy2 = _body.ImpactDetector.onImpactHeavy; if (onImpactHeavy2 != null) { onImpactHeavy2.AddListener(new UnityAction(OnBodyImpactHeavy)); } _movementSoundTimer = Random.Range(0.55f, 0.9f); _initialized = true; DeadAirNoiseBridge.Register(this); PinParts(physicsDriven: false); Plugin.Log.LogInfo((object)$"The Dead Air assembled one sideways Museum Boombox and six short downward-splayed Wizard Broom legs with {_health} HP; the host grabs its radio while unmodded guests use the silent left-middle leg anchor."); return true; } private void IgnoreSelfCollisions() { for (int i = 0; i < _parts.Count; i++) { Collider[] colliders = _parts[i].Colliders; if (colliders == null) { continue; } for (int j = i + 1; j < _parts.Count; j++) { Collider[] colliders2 = _parts[j].Colliders; if (colliders2 == null) { continue; } Collider[] array = colliders; foreach (Collider val in array) { if ((Object)(object)val == (Object)null) { continue; } Collider[] array2 = colliders2; foreach (Collider val2 in array2) { if ((Object)(object)val2 != (Object)null) { Physics.IgnoreCollision(val, val2, true); } } } } } } internal bool ActivateNavigation(Vector3 requestedPosition) { //IL_000e: 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_0062: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if ((Object)(object)_agent == (Object)null || !NavMesh.SamplePosition(requestedPosition, ref val, 4f, -1)) { Plugin.Log.LogError((object)"The Dead Air could not find NavMesh during activation."); return false; } ((Component)this).transform.position = ((NavMeshHit)(ref val)).position; ((Behaviour)_agent).enabled = true; if (!_agent.isOnNavMesh && !_agent.Warp(((NavMeshHit)(ref val)).position)) { return false; } return _agent.isOnNavMesh; } private void Update() { //IL_00eb: 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_00f0: Unknown result type (might be due to invalid IL or missing references) if (!_initialized || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (_state == BehaviourState.Dead) { UpdateDeath(); return; } _damagePulseTimer = Mathf.Max(0f, _damagePulseTimer - Time.deltaTime); _damageFeedbackCooldown = Mathf.Max(0f, _damageFeedbackCooldown - Time.deltaTime); _slamDamageCooldown = Mathf.Max(0f, _slamDamageCooldown - Time.deltaTime); _resumeImpactGraceTimer = Mathf.Max(0f, _resumeImpactGraceTimer - Time.deltaTime); bool flag = IsBodyGrabbed(); if (flag && !_wasBodyGrabbed) { SpawnedDeadAirPart spawnedDeadAirPart = _physicsAnchor ?? _grabProxy; _grabStartedAt = Time.time; _slamMotionOrigin = (((Object)(object)spawnedDeadAirPart?.Phys != (Object)null) ? ((Component)spawnedDeadAirPart.Phys).transform.position : ((Component)this).transform.position); _slamEligibleUntil = -999f; } if (flag) { _releasedPhysicsTimer = 2.75f; _settledPhysicsTimer = 0f; ArmSlamFromDeliberateMotion(released: false); } else if (_wasBodyGrabbed) { _releasedPhysicsTimer = 2.75f; _settledPhysicsTimer = 0f; ArmSlamFromDeliberateMotion(released: true); } if (flag || _releasedPhysicsTimer > 0f) { UpdatePhysicsDrivenPose(flag); PinParts(physicsDriven: true); UpdateNearMusic(); _wasBodyGrabbed = flag; return; } ResumeNavigationAfterPhysics(); if (_tumbleFlinchTimer > 0f) { _tumbleFlinchTimer = Mathf.Max(0f, _tumbleFlinchTimer - Time.deltaTime); StopAgent(); PinParts(physicsDriven: false); UpdateNearMusic(); _wasBodyGrabbed = flag; return; } UpdateTarget(); switch (_state) { case BehaviourState.Fleeing: UpdateFleeing(); break; case BehaviourState.AttackWindup: UpdateAttackWindup(); break; case BehaviourState.Recovering: UpdateRecovery(); break; default: UpdateHunting(); break; } PinParts(physicsDriven: false); UpdateMovementSound(); UpdateNearMusic(); _wasBodyGrabbed = flag; } private bool IsBodyGrabbed() { bool num = IsGrabbed(_body); bool flag = IsGrabbed(_grabProxy); if (num) { _physicsAnchor = _body; } else if (flag) { _physicsAnchor = _grabProxy; } return num || flag; } private static bool IsGrabbed(SpawnedDeadAirPart part) { if ((Object)(object)part?.Phys != (Object)null) { if (!part.Phys.grabbed && !part.Phys.grabbedLocal) { return part.Phys.playerGrabbing.Count > 0; } return true; } return false; } private void ArmSlamFromDeliberateMotion(bool released) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) SpawnedDeadAirPart spawnedDeadAirPart = _physicsAnchor ?? _grabProxy; if (!((Object)(object)spawnedDeadAirPart?.Phys == (Object)null)) { Vector3 position = ((Component)spawnedDeadAirPart.Phys).transform.position; float num; if (!((Object)(object)spawnedDeadAirPart.Phys.rb != (Object)null)) { num = 0f; } else { Vector3 velocity = spawnedDeadAirPart.Phys.rb.velocity; num = ((Vector3)(ref velocity)).magnitude; } float num2 = num; float num3 = Vector3.Distance(position, _slamMotionOrigin); float num4 = (_hasLastAcceptedSlamPosition ? Vector3.Distance(position, _lastAcceptedSlamPosition) : float.PositiveInfinity); if (!(Time.time - _grabStartedAt < 0.14f) && !(num2 < 3.25f) && !(num3 < 0.22f) && !(num4 < 0.32f)) { _slamEligibleUntil = Time.time + (released ? 2.75f : 0.24f); } } } private void UpdatePhysicsDrivenPose(bool grabbed) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) SpawnedDeadAirPart spawnedDeadAirPart = _physicsAnchor ?? _grabProxy; if ((Object)(object)spawnedDeadAirPart?.Phys == (Object)null) { _releasedPhysicsTimer = 0f; return; } if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled) { if (_agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } ((Behaviour)_agent).enabled = false; _agentDisabledForPhysics = true; } Quaternion rotation = ((Component)spawnedDeadAirPart.Phys).transform.rotation; Quaternion val = rotation * Quaternion.Inverse(spawnedDeadAirPart.LocalRotation); Vector3 val2 = ((Component)spawnedDeadAirPart.Phys).transform.position + rotation * spawnedDeadAirPart.VisualCenterOffset; ((Component)this).transform.rotation = val; ((Component)this).transform.position = val2 - val * spawnedDeadAirPart.LocalOffset; if (grabbed) { return; } _releasedPhysicsTimer = Mathf.Max(0f, _releasedPhysicsTimer - Time.deltaTime); Rigidbody rb = spawnedDeadAirPart.Phys.rb; int num; if (!((Object)(object)rb == (Object)null)) { Vector3 val3 = rb.velocity; if (((Vector3)(ref val3)).sqrMagnitude < 0.3f) { val3 = rb.angularVelocity; num = ((((Vector3)(ref val3)).sqrMagnitude < 1f) ? 1 : 0); } else { num = 0; } } else { num = 1; } bool flag = (byte)num != 0; _settledPhysicsTimer = (flag ? (_settledPhysicsTimer + Time.deltaTime) : 0f); if (_settledPhysicsTimer >= 0.42f) { _releasedPhysicsTimer = 0f; } } private void ResumeNavigationAfterPhysics() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_00d8: 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_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if (!_agentDisabledForPhysics || (Object)(object)_agent == (Object)null || !NavMesh.SamplePosition(((Component)this).transform.position, ref val, 4f, -1)) { return; } Vector3 val2 = Vector3.ProjectOnPlane(((Component)this).transform.forward, Vector3.up); ((Component)this).transform.rotation = ((((Vector3)(ref val2)).sqrMagnitude > 0.01f) ? Quaternion.LookRotation(((Vector3)(ref val2)).normalized, Vector3.up) : Quaternion.identity); ((Component)this).transform.position = ((NavMeshHit)(ref val)).position; if ((Object)(object)_physicsAnchor?.Phys?.rb != (Object)null && !_physicsAnchor.Phys.rb.isKinematic) { _physicsAnchor.Phys.rb.velocity = Vector3.zero; _physicsAnchor.Phys.rb.angularVelocity = Vector3.zero; } if ((Object)(object)_physicsAnchor?.Phys != (Object)null) { Quaternion val3 = ((Component)this).transform.rotation * _physicsAnchor.LocalRotation; Vector3 val4 = ((NavMeshHit)(ref val)).position + ((Component)this).transform.rotation * _physicsAnchor.LocalOffset - val3 * _physicsAnchor.VisualCenterOffset; _physicsAnchor.Phys.Teleport(val4, val3); if ((Object)(object)_physicsAnchor.Phys.rb != (Object)null && !_physicsAnchor.Phys.rb.isKinematic) { _physicsAnchor.Phys.rb.velocity = Vector3.zero; _physicsAnchor.Phys.rb.angularVelocity = Vector3.zero; } } ((Behaviour)_agent).enabled = true; _agent.Warp(((NavMeshHit)(ref val)).position); _agent.isStopped = true; _agentDisabledForPhysics = false; _physicsAnchor = null; _resumeImpactGraceTimer = 0.8f; _slamEligibleUntil = -999f; _hasLastAcceptedSlamPosition = false; _state = BehaviourState.Hunting; _lastNearbyNoiseTime = Time.time; } private void OnBodyImpactMedium() { ApplySlamDamage(Plugin.Settings.DeadAirMediumSlamDamage.Value, "medium"); } private void OnBodyImpactHeavy() { ApplySlamDamage(Plugin.Settings.DeadAirHeavySlamDamage.Value, "heavy"); } private void ApplySlamDamage(int damage, string impactName) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (!_suppressSlamDamage && !(_resumeImpactGraceTimer > 0f) && _state != BehaviourState.Dead && SemiFunc.IsMasterClientOrSingleplayer() && !(Time.time > _slamEligibleUntil) && !(_slamDamageCooldown > 0f)) { SpawnedDeadAirPart spawnedDeadAirPart = _physicsAnchor ?? _grabProxy; _lastAcceptedSlamPosition = (((Object)(object)spawnedDeadAirPart?.Phys != (Object)null) ? ((Component)spawnedDeadAirPart.Phys).transform.position : ((Component)this).transform.position); _hasLastAcceptedSlamPosition = true; _slamMotionOrigin = _lastAcceptedSlamPosition; _slamEligibleUntil = -999f; _slamDamageCooldown = 0.68f; _health -= Mathf.Max(1, damage); Plugin.Log.LogInfo((object)$"The Dead Air took {Mathf.Max(1, damage)} {impactName} slam damage; HP={Mathf.Max(0, _health)}/{Mathf.Max(1, Plugin.Settings.DeadAirHealth.Value)}."); if (_health <= 0) { Die(); } } } internal void HearNoise(Vector3 position, float radius) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (_initialized && _state != BehaviourState.Dead && (!(Time.time <= _ignoreOwnNoiseUntil) || !(Vector3.Distance(position, _lastOwnNoisePosition) <= 1.6f)) && !(Vector3.Distance(((Component)this).transform.position, position) > Mathf.Max(0.25f, radius))) { _lastNearbyNoiseTime = Time.time; PlayerAvatar val = FindNearestLivingPlayer(position, 2.5f); if ((Object)(object)val != (Object)null) { _playerLastNoiseTime[((Object)val).GetInstanceID()] = Time.time; } float num = Mathf.Clamp(Plugin.Settings.DeadAirLoudNoiseRadius.Value, 3f, 15f); if (radius >= num) { StartFleeing(position, radius); } } } private void UpdateTarget() { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) _targetTimer -= Time.deltaTime; if (GunAccess.IsLiving(_target)) { if (HasClearAttackPath(_target)) { _targetOccludedTimer = 0f; if (_targetTimer > 0f) { return; } } else { _targetOccludedTimer += Time.deltaTime; StopAgent(); if (_targetOccludedTimer < 0.35f) { return; } _target = null; _targetTimer = 0f; } } _targetTimer = 0.25f; _target = null; _targetOccludedTimer = 0f; if (Time.time - _spawnTime < 2f) { return; } float num = float.MinValue; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (!GunAccess.IsLiving(item)) { continue; } float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position); if (num2 > 18f || !HasClearAttackPath(item)) { continue; } float silenceSeconds = GetSilenceSeconds(item); if (!(silenceSeconds < 0.55f)) { float num3 = silenceSeconds * 1.5f - num2 * 0.08f; if (num3 > num) { num = num3; _target = item; } } } } private float GetSilenceSeconds(PlayerAvatar player) { float num = Mathf.Max(_spawnTime, _lastNearbyNoiseTime); if ((Object)(object)player != (Object)null && _playerLastNoiseTime.TryGetValue(((Object)player).GetInstanceID(), out var value)) { num = Mathf.Max(num, value); } return Mathf.Max(0f, Time.time - num); } private void UpdateHunting() { //IL_014a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_agent == (Object)null || !_agent.isOnNavMesh || !GunAccess.IsLiving(_target)) { StopAgent(); return; } if (!HasClearAttackPath(_target)) { StopAgent(); return; } float silenceSeconds = GetSilenceSeconds(_target); float num = Mathf.Clamp(Plugin.Settings.DeadAirQuietSecondsForFullSpeed.Value, 1.5f, 12f); float num2 = Mathf.InverseLerp(0.55f, num, silenceSeconds); if (num2 <= 0.01f) { StopAgent(); return; } float horizontalRange = Mathf.Clamp(Plugin.Settings.DeadAirAttackRange.Value, 0.8f, 2f); if (IsWithinAttackVolume(_target, horizontalRange) && HasClearAttackPath(_target)) { BeginAttack(); return; } _agent.speed = Mathf.Lerp(1.6f, Mathf.Clamp(Plugin.Settings.DeadAirHuntSpeed.Value, 2f, 10f), num2); _agent.isStopped = false; _destinationTimer -= Time.deltaTime; if (_destinationTimer <= 0f) { _destinationTimer = 0.14f; _agent.SetDestination(((Component)_target).transform.position); } } private void BeginAttack() { _state = BehaviourState.AttackWindup; _stateTimer = 0.55f; _attackWindupElapsed = 0f; StopAgent(); } private void UpdateAttackWindup() { StopAgent(); _stateTimer -= Time.deltaTime; _attackWindupElapsed += Time.deltaTime; if (!(_stateTimer > 0f)) { PerformAttack(); _state = BehaviourState.Recovering; _stateTimer = 1.1f; } } private void PerformAttack() { //IL_0088: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_0101: 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) int num = Mathf.Clamp(Plugin.Settings.DeadAirAttackDamage.Value, 1, 100); float num2 = Mathf.Clamp(Plugin.Settings.DeadAirAttackRange.Value, 0.8f, 2f) + 0.35f; bool flag = false; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item) && IsWithinAttackVolume(item, num2) && HasClearAttackPath(item)) { PlayerHealth playerHealth = item.playerHealth; if (playerHealth != null) { playerHealth.HurtOther(num, ((Component)item).transform.position, false, -1, false); } flag = true; } } ModEnemyValuableDamage.BreakLightInCone(((Object)(object)_body?.Phys != (Object)null) ? _body.Phys.centerPoint : (((Component)this).transform.position + Vector3.up * 0.25f), ((Component)this).transform.forward, num2 + 0.2f, -0.1f, IsOwnCollider); if ((Object)(object)_body?.ImpactDetector != (Object)null && (Object)(object)_body.Phys != (Object)null) { using (DeadAirNoiseBridge.SuppressOwnNoise()) { _suppressSlamDamage = true; try { _body.ImpactDetector.ImpactHeavy(100f, _body.Phys.centerPoint); } finally { _suppressSlamDamage = false; } } } if (!_firstAttackLogged) { _firstAttackLogged = true; Plugin.Log.LogInfo((object)("The Dead Air completed its first lunge (" + (flag ? $"{num} damage" : "miss") + ").")); } } private void UpdateRecovery() { StopAgent(); _stateTimer -= Time.deltaTime; if (_stateTimer <= 0f) { _state = BehaviourState.Hunting; _lastNearbyNoiseTime = Time.time; } } private void StartFleeing(Vector3 noisePosition, float radius) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_000b: 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) if (_state == BehaviourState.Fleeing) { _lastLoudNoisePosition = noisePosition; _stateTimer = Mathf.Max(_stateTimer, 0.55f); return; } _lastLoudNoisePosition = noisePosition; _state = BehaviourState.Fleeing; _stateTimer = 5f; _destinationTimer = 0f; if ((Object)(object)_agent != (Object)null && _agent.isOnNavMesh) { _agent.speed = Mathf.Clamp(Plugin.Settings.DeadAirFleeSpeed.Value, 4f, 16f); _agent.isStopped = false; SetFleeDestination(); } if ((Object)(object)_body?.ImpactDetector != (Object)null && (Object)(object)_body.Phys != (Object)null) { using (DeadAirNoiseBridge.SuppressOwnNoise()) { _suppressSlamDamage = true; try { _body.ImpactDetector.ImpactHeavy(100f, _body.Phys.centerPoint); } finally { _suppressSlamDamage = false; } } } if (!_firstFleeLogged) { _firstFleeLogged = true; Plugin.Log.LogInfo((object)$"The Dead Air fled from its first loud vanilla noise (radius {radius:F1}m). Voice, gunfire and impacts use this same path."); } } private void UpdateFleeing() { if ((Object)(object)_agent == (Object)null || !_agent.isOnNavMesh) { return; } _stateTimer -= Time.deltaTime; if (_stateTimer <= 0f) { _state = BehaviourState.Hunting; _lastNearbyNoiseTime = Time.time; StopAgent(); return; } _agent.speed = Mathf.Clamp(Plugin.Settings.DeadAirFleeSpeed.Value, 4f, 16f); _agent.isStopped = false; _destinationTimer -= Time.deltaTime; if (_destinationTimer <= 0f || (!_agent.pathPending && _agent.remainingDistance < 1f)) { _destinationTimer = 0.65f; SetFleeDestination(); } } private void SetFleeDestination() { //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) //IL_004d: 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_00d9: 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_00f8: 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) if ((Object)(object)_agent == (Object)null || !_agent.isOnNavMesh) { return; } Vector3 val = ((Component)this).transform.position - _lastLoudNoisePosition; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.05f) { val = Random.insideUnitSphere; val.y = 0f; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(Vector3.up, val) * Random.Range(-0.45f, 0.45f); Vector3 position = ((Component)this).transform.position; Vector3 val3 = val + val2; NavMeshHit val4 = default(NavMeshHit); if (NavMesh.SamplePosition(position + ((Vector3)(ref val3)).normalized * 11f, ref val4, 7f, -1)) { _agent.SetDestination(((NavMeshHit)(ref val4)).position); return; } LevelPoint val5 = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 5f); if ((Object)(object)val5 != (Object)null && NavMesh.SamplePosition(((Component)val5).transform.position, ref val4, 5f, -1)) { _agent.SetDestination(((NavMeshHit)(ref val4)).position); } } private void StopAgent() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_agent == (Object)null) && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.velocity = Vector3.zero; } } private bool HasClearAttackPath(PlayerAvatar player) { //IL_0051: 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_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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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) if ((Object)(object)player == (Object)null) { return false; } Vector3 val = (((Object)(object)_body?.Phys != (Object)null) ? _body.Phys.centerPoint : (((Component)this).transform.position + Vector3.up * 0.38f)); Vector3 val2 = ((Component)player).transform.position + Vector3.up * 0.65f; if (GunAccess.TryGetPlayerBounds(player, out var bounds)) { val2 = ((Bounds)(ref bounds)).ClosestPoint(val); } Vector3 val3 = val2 - val; float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude <= 0.1f) { return true; } RaycastHit[] array = Physics.RaycastAll(val, val3 / magnitude, magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val4 = array2[num]; if (!IsOwnCollider(((RaycastHit)(ref val4)).collider) && !((Object)(object)ResolveHitPlayer(((RaycastHit)(ref val4)).collider) == (Object)(object)player) && !IsVanillaEnemyCollider(((RaycastHit)(ref val4)).collider)) { return false; } } return true; } private bool IsWithinAttackVolume(PlayerAvatar player, float horizontalRange) { //IL_0017: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || !GunAccess.TryGetPlayerBounds(player, out var bounds)) { return false; } Vector3 val = ((Bounds)(ref bounds)).center - ((Component)this).transform.position; val.y = 0f; float num = Mathf.Max(0.1f, horizontalRange) + Mathf.Max(((Bounds)(ref bounds)).extents.x, ((Bounds)(ref bounds)).extents.z); if (((Vector3)(ref val)).sqrMagnitude > num * num) { return false; } float y = ((Component)this).transform.position.y; if (((Bounds)(ref bounds)).max.y >= y - 0.08f) { return ((Bounds)(ref bounds)).min.y <= y + 0.92f; } return false; } private void UpdateMovementSound() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_agent == (Object)null)) { Vector3 velocity = _agent.velocity; if (!(((Vector3)(ref velocity)).sqrMagnitude < 0.5f) && !((Object)(object)_body?.ImpactDetector == (Object)null) && !((Object)(object)_body.Phys == (Object)null)) { if (_movementPulsesRemaining > 0) { _movementPulseTimer -= Time.deltaTime; if (_movementPulseTimer <= 0f) { EmitScuttleTick(); _movementPulsesRemaining--; _movementPulseTimer = Random.Range(0.0275f, 0.045f); } return; } _movementSoundTimer -= Time.deltaTime; if (!(_movementSoundTimer > 0f)) { _movementSoundTimer = Random.Range(0.525f, 0.825f); _movementPulsesRemaining = Random.Range(2, 4); _movementPulseTimer = 0f; if (!_firstMovementSoundLogged) { _firstMovementSoundLogged = true; Plugin.Log.LogInfo((object)"The Dead Air emitted its first guest-audible two-to-three-tick insect scuttle through vanilla impact RPCs."); } } return; } } _movementPulsesRemaining = 0; } private void EmitScuttleTick() { //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_0095: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _parts.Count; i++) { SpawnedDeadAirPart spawnedDeadAirPart = _parts[_movementPulseCursor++ % _parts.Count]; if (spawnedDeadAirPart.Alive && !spawnedDeadAirPart.IsBody && !((Object)(object)spawnedDeadAirPart.ImpactDetector == (Object)null) && !((Object)(object)spawnedDeadAirPart.Phys == (Object)null)) { using (DeadAirNoiseBridge.SuppressOwnNoise()) { _lastOwnNoisePosition = spawnedDeadAirPart.Phys.centerPoint; _ignoreOwnNoiseUntil = Time.time + 0.22f; spawnedDeadAirPart.ImpactDetector.ImpactLight(96f, spawnedDeadAirPart.Phys.centerPoint); break; } } } } private void UpdateNearMusic() { //IL_0043: 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_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) if (!((Object)(object)MusicEnemyNear.instance == (Object)null) && GunAccess.IsLiving(PlayerAvatar.instance)) { float num = Mathf.Clamp(Plugin.Settings.DeadAirNearMusicRange.Value, 3f, 40f); Vector3 val = ((Component)PlayerAvatar.instance).transform.position - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude <= num * num) { MusicEnemyNear.instance.OverrideActive(0.35f); } } } internal bool TryClaimWeaponHit(int bulletInstanceId) { if (!ModEnemyWeaponDamage.TryClaim((Object)(object)this, bulletInstanceId)) { return false; } if (Time.time - _lastClaimedWeaponHitTime < 0.06f) { return false; } _lastClaimedWeaponHitTime = Time.time; return true; } internal void HurtPart(int partIndex, int damage) { //IL_0038: 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) if (_state == BehaviourState.Dead || partIndex < 0 || partIndex >= _parts.Count) { return; } SpawnedDeadAirPart spawnedDeadAirPart = _parts[partIndex]; if (spawnedDeadAirPart.Alive) { damage = ParasiteEffectRegistry.ModifyEnemyDamageAt(spawnedDeadAirPart.Phys.centerPoint, damage); _health -= Mathf.Max(1, damage); PlayDamageFeedback(spawnedDeadAirPart, spawnedDeadAirPart.Phys.centerPoint); if (!_firstHitLogged) { _firstHitLogged = true; Plugin.Log.LogInfo((object)$"The Dead Air accepted its first weapon hit; HP={Mathf.Max(0, _health)}/{Mathf.Max(1, Plugin.Settings.DeadAirHealth.Value)}."); } if (_health <= 0) { Die(); } } } private void PlayDamageFeedback(SpawnedDeadAirPart part, Vector3 hitPosition) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) _damagePulseTimer = 0.22f; if (_damageFeedbackCooldown > 0f || (Object)(object)part?.ImpactDetector == (Object)null) { return; } _damageFeedbackCooldown = 0.09f; using (DeadAirNoiseBridge.SuppressOwnNoise()) { _suppressSlamDamage = true; try { ModEnemyFeedback.DamageHit(_body?.ImpactDetector ?? part.ImpactDetector, _body?.Phys ?? part.Phys, hitPosition, 78f); } finally { _suppressSlamDamage = false; } } } public void ReceiveTumbleAttack(int partIndex, int damage, Vector3 hitPosition, Vector3 direction) { HurtPart(partIndex, damage); if (_state != BehaviourState.Dead && !IsBodyGrabbed()) { _tumbleFlinchTimer = 0.34f; StopAgent(); } } internal void ExecuteForLab() { if (_state != BehaviourState.Dead && SemiFunc.IsMasterClientOrSingleplayer()) { Plugin.Log.LogInfo((object)"Enemy Lab execution round hit The Dead Air."); _health = 0; Die(); } } private void Die() { if (_state == BehaviourState.Dead) { return; } _state = BehaviourState.Dead; _target = null; DeadAirNoiseBridge.Unregister(this); if ((Object)(object)_agent != (Object)null && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } using (DeadAirNoiseBridge.SuppressOwnNoise()) { foreach (SpawnedDeadAirPart part in _parts) { if (part.Alive) { part.Alive = false; if ((Object)(object)part.ImpactDetector != (Object)null) { part.ImpactDetector.destroyDisable = false; part.ImpactDetector.DestroyObject(true); } else { DeadAirSpawner.Destroy(part); } } } } _rewardTimer = 0.08f; Plugin.Log.LogInfo((object)$"The Dead Air was destroyed; its vanilla enemy orb will be released after {0.08f:F2}s."); } private void UpdateDeath() { if (!_rewardDropped) { _rewardTimer -= Time.deltaTime; if (_rewardTimer <= 0f) { DropReward(); } } } private void DropReward() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_00a5: 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_0095: Unknown result type (might be due to invalid IL or missing references) _rewardDropped = true; if (!Plugin.Settings.DeadAirDropEnemyValuable.Value || (Object)(object)AssetManager.instance == (Object)null) { return; } GameObject val = (GameObject)(1 switch { 2 => AssetManager.instance.enemyValuableMedium, 1 => AssetManager.instance.enemyValuableSmall, _ => AssetManager.instance.enemyValuableBig, }); if (!((Object)(object)val == (Object)null)) { Vector3 val2 = ((Component)this).transform.position + Vector3.up * 0.45f; if (GameManager.Multiplayer()) { PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)val).name, val2, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate(val, val2, Quaternion.identity); } } } private void PinParts(bool physicsDriven) { //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: 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) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_0552: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_0531: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_0538: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) //IL_0751: Unknown result type (might be due to invalid IL or missing references) //IL_0756: Unknown result type (might be due to invalid IL or missing references) //IL_075a: Unknown result type (might be due to invalid IL or missing references) //IL_075f: Unknown result type (might be due to invalid IL or missing references) //IL_0768: Unknown result type (might be due to invalid IL or missing references) //IL_076d: Unknown result type (might be due to invalid IL or missing references) //IL_0771: Unknown result type (might be due to invalid IL or missing references) //IL_0776: Unknown result type (might be due to invalid IL or missing references) //IL_0703: Unknown result type (might be due to invalid IL or missing references) //IL_0705: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) //IL_070e: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Unknown result type (might be due to invalid IL or missing references) //IL_061b: Unknown result type (might be due to invalid IL or missing references) //IL_064d: Unknown result type (might be due to invalid IL or missing references) //IL_05c4: Unknown result type (might be due to invalid IL or missing references) //IL_0781: Unknown result type (might be due to invalid IL or missing references) //IL_078c: Unknown result type (might be due to invalid IL or missing references) //IL_0793: Unknown result type (might be due to invalid IL or missing references) //IL_0798: Unknown result type (might be due to invalid IL or missing references) //IL_079d: Unknown result type (might be due to invalid IL or missing references) //IL_07a8: Unknown result type (might be due to invalid IL or missing references) //IL_07af: Unknown result type (might be due to invalid IL or missing references) //IL_07b4: Unknown result type (might be due to invalid IL or missing references) //IL_07b9: Unknown result type (might be due to invalid IL or missing references) //IL_07bb: Unknown result type (might be due to invalid IL or missing references) //IL_07bf: Unknown result type (might be due to invalid IL or missing references) //IL_07c4: Unknown result type (might be due to invalid IL or missing references) //IL_07c9: Unknown result type (might be due to invalid IL or missing references) //IL_07ce: Unknown result type (might be due to invalid IL or missing references) //IL_07dc: Unknown result type (might be due to invalid IL or missing references) //IL_07e1: Unknown result type (might be due to invalid IL or missing references) //IL_0815: Unknown result type (might be due to invalid IL or missing references) //IL_0817: Unknown result type (might be due to invalid IL or missing references) //IL_07fb: Unknown result type (might be due to invalid IL or missing references) //IL_0800: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Unknown result type (might be due to invalid IL or missing references) //IL_06c5: Unknown result type (might be due to invalid IL or missing references) //IL_06c7: Unknown result type (might be due to invalid IL or missing references) //IL_06d1: Unknown result type (might be due to invalid IL or missing references) //IL_06d6: Unknown result type (might be due to invalid IL or missing references) //IL_06d8: Unknown result type (might be due to invalid IL or missing references) //IL_06da: Unknown result type (might be due to invalid IL or missing references) //IL_06dc: Unknown result type (might be due to invalid IL or missing references) //IL_06e1: Unknown result type (might be due to invalid IL or missing references) //IL_06e5: Unknown result type (might be due to invalid IL or missing references) //IL_06ec: Unknown result type (might be due to invalid IL or missing references) //IL_06f1: Unknown result type (might be due to invalid IL or missing references) //IL_06f6: Unknown result type (might be due to invalid IL or missing references) float num = 0f; float num2 = 0f; float num3 = 0f; float num4 = 0f; float num5 = 0f; if (_state == BehaviourState.AttackWindup) { float num6 = Mathf.Clamp01(_attackWindupElapsed / 0.55f); float num7 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(num6 / 0.64f)); num5 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((num6 - 0.62f) / 0.38f)); num = -0.1f * num7 + 0.52f * num5; num2 = -0.055f * num7 + 0.035f * num5; num3 = 10f * num7 - 12f * num5; num4 = Mathf.Max(num7, num5); } else if (_state == BehaviourState.Recovering) { float num8 = Mathf.Clamp01(_stateTimer / 1.1f); num8 = Mathf.SmoothStep(0f, 1f, num8); num = 0.42f * num8; num2 = 0.05f * num8; num3 = -14f * num8; num4 = num8; num5 = num8; } Vector3 velocity; float num9; if (!physicsDriven && (Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled) { velocity = _agent.velocity; if (((Vector3)(ref velocity)).sqrMagnitude > 0.4f) { num9 = Mathf.Sin(Time.time * ((_state == BehaviourState.Fleeing) ? 23f : 17f)) * 0.04f; goto IL_0179; } } num9 = 0f; goto IL_0179; IL_0179: float num10 = num9; int num11; if (!physicsDriven && (Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled) { velocity = _agent.velocity; num11 = ((((Vector3)(ref velocity)).sqrMagnitude > 0.4f) ? 1 : 0); } else { num11 = 0; } bool flag = (byte)num11 != 0; float num12 = ((_state == BehaviourState.Fleeing) ? 23f : 17f); float num13 = ((_tumbleFlinchTimer > 0f) ? Mathf.Sin(Mathf.Clamp01(_tumbleFlinchTimer / 0.34f) * MathF.PI) : 0f); float num14 = ((_damagePulseTimer > 0f) ? Mathf.Sin(Mathf.Clamp01(_damagePulseTimer / 0.22f) * MathF.PI) : 0f); foreach (SpawnedDeadAirPart part in _parts) { if (!part.Alive || (Object)(object)part.Phys == (Object)null) { continue; } part.ImpactDetector.destroyDisable = true; part.Phys.OverrideIndestructible(0.3f); if (part.IsGrabProxy || part.IsBody) { part.Phys.OverrideMass(Mathf.Clamp(Plugin.Settings.DeadAirGrabMass.Value, 2f, 12f), 0.35f); if (physicsDriven && part == _physicsAnchor) { continue; } if (!physicsDriven) { part.Phys.OverrideZeroGravity(0.35f); part.Phys.OverrideDrag(12f, 0.35f); part.Phys.OverrideAngularDrag(18f, 0.35f); } else { part.Phys.OverrideKinematic(0.3f); } } else { part.Phys.OverrideKinematic(0.3f); part.Phys.OverrideGrabDisable(0.3f); } if (part.GeometryCalibrationFrames > 0) { DeadAirSpawner.RefreshRenderedGeometry(part); part.GeometryCalibrationFrames--; if (part.IsBody) { part.LocalOffset.y = Mathf.Max(0.16f, part.VisualHalfHeight + 0.04f); } if (part.GeometryCalibrationFrames == 0) { string text = (part.IsBody ? "body" : (part.IsGrabProxy ? "grab leg" : "leg")); Plugin.Log.LogInfo((object)$"Dead Air geometry {text}: scale={part.Root.transform.localScale}, rendered={part.VisualSize}, centerOffset={part.VisualCenterOffset}, longAxis={part.LongAxisLocal}."); } } Vector3 val = part.LocalOffset; if (part.IsBody) { val.z += num; val.z -= num13 * 0.14f; val.z -= num14 * 0.075f; val.y += num10 + num2 - num14 * 0.018f; } Quaternion val2 = part.LocalRotation; if (part.IsBody && Mathf.Abs(num3) > 0.01f) { val2 = Quaternion.AngleAxis(num3, Vector3.right) * part.LocalRotation; } if (part.IsBody && num13 > 0.001f) { val2 = Quaternion.AngleAxis(15f * num13, Vector3.right) * val2; } if (part.IsBody && num14 > 0.001f) { val2 = Quaternion.AngleAxis(Mathf.Sin(Time.time * 48f) * 7f * num14, Vector3.forward) * val2; } if (!part.IsBody) { Vector3 legStart = part.LegStart; Vector3 legEnd = part.LegEnd; legStart.y += num10 * 0.65f; if (flag) { float num15 = Mathf.Sin(Time.time * num12 + part.GaitPhase); legEnd.z += num15 * 0.14f; legEnd.y += Mathf.Max(0f, num15) * 0.12f; legEnd.x += Mathf.Sign(legEnd.x) * Mathf.Max(0f, 0f - num15) * 0.045f; } legStart.z += num; legStart.x += Mathf.Sign(legStart.x) * num14 * 0.035f; legEnd.x += Mathf.Sign(legEnd.x) * num14 * 0.065f; legEnd.z += num * 0.18f; legEnd.x += Mathf.Sign(legEnd.x) * num4 * 0.035f; if (part.LegStart.z > 0.05f) { legEnd.z += num5 * 0.16f; legEnd.y += num5 * 0.035f; } else if (part.LegStart.z < -0.05f) { legEnd.z -= num4 * 0.055f; } val = (legStart + legEnd) * 0.5f; Vector3 val3 = legEnd - legStart; val2 = Quaternion.FromToRotation(part.LongAxisLocal, ((Vector3)(ref val3)).normalized); } if (!part.PoseInitialized) { part.SmoothedLocalOffset = val; part.SmoothedLocalRotation = val2; part.PoseInitialized = true; } else { float num16 = 1f - Mathf.Exp(-18f * Time.deltaTime); float num17 = 1f - Mathf.Exp(-16f * Time.deltaTime); part.SmoothedLocalOffset = Vector3.Lerp(part.SmoothedLocalOffset, val, num16); part.SmoothedLocalRotation = Quaternion.Slerp(part.SmoothedLocalRotation, val2, num17); } Vector3 val4 = ((Component)this).transform.position + ((Component)this).transform.rotation * part.SmoothedLocalOffset; Quaternion val5 = ((Component)this).transform.rotation * part.SmoothedLocalRotation; Vector3 val6 = val4 - val5 * part.VisualCenterOffset; if (Vector3.Distance(((Component)part.Phys).transform.position, val6) > 0.01f || Quaternion.Angle(((Component)part.Phys).transform.rotation, val5) > 0.5f) { part.Phys.SetPositionLogic(val6, val5); } } } private bool IsOwnCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } Transform hitTransform = ((Component)collider).transform; return _parts.Any((SpawnedDeadAirPart part) => (Object)(object)part.Root != (Object)null && ((Object)(object)hitTransform == (Object)(object)part.Root.transform || hitTransform.IsChildOf(part.Root.transform))); } private static bool IsVanillaEnemyCollider(Collider collider) { if ((Object)(object)collider != (Object)null) { if (!((Object)(object)((Component)collider).GetComponentInParent() != (Object)null)) { return (Object)(object)((Component)collider).GetComponentInParent() != (Object)null; } return true; } return false; } private static PlayerAvatar ResolveHitPlayer(Collider collider) { if ((Object)(object)collider == (Object)null) { return null; } PlayerController componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent?.playerAvatarScript != (Object)null) { return componentInParent.playerAvatarScript; } PlayerAvatar componentInParent2 = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null) { return componentInParent2; } return ((Component)collider).GetComponentInParent()?.playerAvatar; } private static PlayerAvatar FindNearestLivingPlayer(Vector3 position, float maximumDistance) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar result = null; float num = maximumDistance * maximumDistance; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { Vector3 val = ((Component)item).transform.position - position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude <= num) { num = sqrMagnitude; result = item; } } } return result; } private void OnDestroy() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown DeadAirGrabRedirect.Unregister(_body?.Phys); if ((Object)(object)_grabProxy?.ImpactDetector != (Object)null) { UnityEvent onImpactMedium = _grabProxy.ImpactDetector.onImpactMedium; if (onImpactMedium != null) { onImpactMedium.RemoveListener(new UnityAction(OnBodyImpactMedium)); } UnityEvent onImpactHeavy = _grabProxy.ImpactDetector.onImpactHeavy; if (onImpactHeavy != null) { onImpactHeavy.RemoveListener(new UnityAction(OnBodyImpactHeavy)); } } if ((Object)(object)_body?.ImpactDetector != (Object)null) { UnityEvent onImpactMedium2 = _body.ImpactDetector.onImpactMedium; if (onImpactMedium2 != null) { onImpactMedium2.RemoveListener(new UnityAction(OnBodyImpactMedium)); } UnityEvent onImpactHeavy2 = _body.ImpactDetector.onImpactHeavy; if (onImpactHeavy2 != null) { onImpactHeavy2.RemoveListener(new UnityAction(OnBodyImpactHeavy)); } } DeadAirNoiseBridge.Unregister(this); if (_initialized && !_cleaningUp && SemiFunc.IsMasterClientOrSingleplayer()) { CleanupParts(); } } private void CleanupParts() { if (_cleaningUp) { return; } _cleaningUp = true; DeadAirGrabRedirect.Unregister(_body?.Phys); DeadAirNoiseBridge.Unregister(this); foreach (SpawnedDeadAirPart part in _parts) { if (part.Alive && (Object)(object)part.Root != (Object)null) { DeadAirSpawner.Destroy(part); } } } } internal static class DeadAirGrabRedirect { private static readonly Dictionary ProxyByBody = new Dictionary(); internal static void Register(PhysGrabObject body, PhysGrabObject proxy) { if ((Object)(object)body != (Object)null && (Object)(object)proxy != (Object)null) { ProxyByBody[((Object)body).GetInstanceID()] = proxy; } } internal static void Unregister(PhysGrabObject body) { if ((Object)(object)body != (Object)null) { ProxyByBody.Remove(((Object)body).GetInstanceID()); } } internal static bool TryGet(PhysGrabObject body, out PhysGrabObject proxy) { proxy = null; if ((Object)(object)body == (Object)null || !ProxyByBody.TryGetValue(((Object)body).GetInstanceID(), out var value)) { return false; } if ((Object)(object)value == (Object)null || value.dead) { ProxyByBody.Remove(((Object)body).GetInstanceID()); return false; } proxy = value; return true; } internal static bool AddGrabber(PhysGrabObject body, int playerPhotonViewId, PhotonMessageInfo info) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (!TryGet(body, out var proxy)) { return false; } PhotonView val = PhotonView.Find(playerPhotonViewId); PhysGrabber val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if (PhotonNetwork.IsMasterClient && (Object)(object)val != (Object)null && val.IsMine) { return false; } if ((Object)(object)val2 == (Object)null || !SemiFunc.OwnerOnlyRPC(info, val2.photonView)) { return true; } PhotonView componentInParent = ((Component)proxy).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && !proxy.playerGrabbing.Contains(val2)) { componentInParent.RPC("GrabPlayerAddRPC", (RpcTarget)0, new object[1] { playerPhotonViewId }); } return true; } internal static bool RemoveGrabber(PhysGrabObject body, int playerPhotonViewId, PhotonMessageInfo info) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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) //IL_00b2: 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_00b9: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if (!TryGet(body, out var proxy)) { return false; } PhotonView val = PhotonView.Find(playerPhotonViewId); PhysGrabber val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if (PhotonNetwork.IsMasterClient && (Object)(object)val != (Object)null && val.IsMine) { return false; } if ((Object)(object)val2 == (Object)null || !SemiFunc.OwnerOnlyRPC(info, val2.photonView)) { return true; } Rigidbody rb = proxy.rb; if ((Object)(object)rb != (Object)null && proxy.playerGrabbing.Contains(val2)) { float num = Mathf.Max(rb.mass * 1.5f, 1f); Vector3 val3 = Vector3.ClampMagnitude(val2.physGrabPointPullerPosition - val2.physGrabPoint.position, val2.forceMax) * num; val3 *= 0.5f + val2.throwStrength; rb.AddForce(val3, (ForceMode)1); } val2.grabbed = false; PhotonView componentInParent = ((Component)proxy).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { componentInParent.RPC("GrabPlayerRemoveRPC", (RpcTarget)0, new object[1] { playerPhotonViewId }); } return true; } } [HarmonyPatch(typeof(PhysGrabObject), "GrabStartedRPC")] internal static class DeadAirBodyGrabStartedPatch { private static bool Prefix(PhysGrabObject __instance, int playerPhotonID, PhotonMessageInfo _info) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return !DeadAirGrabRedirect.AddGrabber(__instance, playerPhotonID, _info); } } [HarmonyPatch(typeof(PhysGrabObject), "GrabEndedRPC")] internal static class DeadAirBodyGrabEndedPatch { private static bool Prefix(PhysGrabObject __instance, int playerPhotonID, PhotonMessageInfo _info) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return !DeadAirGrabRedirect.RemoveGrabber(__instance, playerPhotonID, _info); } } internal sealed class DeadAirHitProxy : MonoBehaviour { private DeadAirController _controller; private int _partIndex; private PhysGrabObjectImpactDetector _impactDetector; private Renderer[] _renderers; private float _cooldown; private readonly Dictionary _previousBulletPositions = new Dictionary(); private readonly HashSet _currentBulletIds = new HashSet(); private static int _cachedBulletFrame = -1; private static ItemGunBullet[] _cachedBullets = Array.Empty(); internal void Initialize(DeadAirController controller, int partIndex, PhysGrabObjectImpactDetector impactDetector, Renderer[] renderers) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown _controller = controller; _partIndex = partIndex; _impactDetector = impactDetector; _renderers = renderers ?? Array.Empty(); PhysGrabObjectImpactDetector impactDetector2 = _impactDetector; if (impactDetector2 != null) { UnityEvent onHurtColliderHit = impactDetector2.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.AddListener(new UnityAction(OnHurtColliderHit)); } } } private void Update() { if (_cooldown > 0f) { _cooldown -= Time.deltaTime; } if (_cooldown <= 0f && SemiFunc.IsMasterClientOrSingleplayer()) { DetectExpandedBulletHit(); } } private void OnDestroy() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown PhysGrabObjectImpactDetector impactDetector = _impactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.RemoveListener(new UnityAction(OnHurtColliderHit)); } } } private void OnHurtColliderHit() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_controller == (Object)null || _cooldown > 0f || !SemiFunc.IsMasterClientOrSingleplayer() || !_controller.TryClaimWeaponHit(ModEnemyWeaponDamage.CurrentClaimId)) { return; } _cooldown = 0.18f; if (EnemyLabBridge.IsExecutionHitNear(((Object)(object)_impactDetector != (Object)null) ? ((Component)_impactDetector).transform.position : ((Component)this).transform.position)) { _controller.ExecuteForLab(); return; } int num = ModEnemyWeaponDamage.CurrentOrFallback(Plugin.Settings.DeadAirDamagePerHit.Value); if (num > 0) { _controller.HurtPart(_partIndex, num); } } private void DetectExpandedBulletHit() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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) if ((Object)(object)_controller == (Object)null) { return; } if (_cachedBulletFrame != Time.frameCount) { _cachedBulletFrame = Time.frameCount; _cachedBullets = Object.FindObjectsOfType(); } _currentBulletIds.Clear(); ItemGunBullet[] cachedBullets = _cachedBullets; foreach (ItemGunBullet val in cachedBullets) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent() != (Object)null) { continue; } HurtCollider hurtCollider = val.hurtCollider; if ((Object)(object)hurtCollider == (Object)null || !((Component)hurtCollider).gameObject.activeInHierarchy) { continue; } int instanceID = ((Object)val).GetInstanceID(); _currentBulletIds.Add(instanceID); Vector3 position = ((Component)hurtCollider).transform.position; Vector3 value; bool num = _previousBulletPositions.TryGetValue(instanceID, out value); _previousBulletPositions[instanceID] = position; if (!(num ? SegmentIntersectsExpandedBounds(value, position) : WithinExpandedBounds(position)) || !_controller.TryClaimWeaponHit(instanceID)) { continue; } _cooldown = 0.3f; if (EnemyLabBridge.IsExecutionHitNear(position)) { _controller.ExecuteForLab(); return; } int num2 = ModEnemyWeaponDamage.Resolve(hurtCollider, Plugin.Settings.DeadAirDamagePerHit.Value); if (num2 > 0) { _controller.HurtPart(_partIndex, num2); } return; } if (_previousBulletPositions.Count <= _currentBulletIds.Count) { return; } List list = null; foreach (int key in _previousBulletPositions.Keys) { if (!_currentBulletIds.Contains(key)) { if (list == null) { list = new List(); } list.Add(key); } } foreach (int item in list ?? new List()) { _previousBulletPositions.Remove(item); } } private bool WithinExpandedBounds(Vector3 position) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_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_0063: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Settings.DeadAirHitDetectionPadding.Value, 0.12f, 0.75f); float num2 = num * num; Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if ((Object)(object)val != (Object)null && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; if (((Bounds)(ref bounds)).SqrDistance(position) <= num2) { return true; } } } Vector3 val2 = (((Object)(object)_impactDetector != (Object)null) ? ((Component)_impactDetector).transform.position : ((Component)this).transform.position); float num3 = 0.35f + num; Vector3 val3 = position - val2; return ((Vector3)(ref val3)).sqrMagnitude <= num3 * num3; } private bool SegmentIntersectsExpandedBounds(Vector3 start, Vector3 end) { //IL_00a4: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Settings.DeadAirHitDetectionPadding.Value, 0.12f, 0.75f); Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if (!((Object)(object)val == (Object)null) && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; ((Bounds)(ref bounds)).Expand(num * 2f); if (SegmentIntersectsBounds(start, end, bounds)) { return true; } } } Vector3 point = (((Object)(object)_impactDetector != (Object)null) ? ((Component)_impactDetector).transform.position : ((Component)this).transform.position); float num2 = 0.35f + num; return DistancePointToSegmentSquared(point, start, end) <= num2 * num2; } private static bool SegmentIntersectsBounds(Vector3 start, Vector3 end, Bounds bounds) { //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) //IL_0002: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 val = end - start; float num = 0f; float num2 = 1f; for (int i = 0; i < 3; i++) { float num3 = ((Vector3)(ref start))[i]; float num4 = ((Vector3)(ref val))[i]; Vector3 val2 = ((Bounds)(ref bounds)).min; float num5 = ((Vector3)(ref val2))[i]; val2 = ((Bounds)(ref bounds)).max; float num6 = ((Vector3)(ref val2))[i]; if (Mathf.Abs(num4) < 1E-05f) { if (num3 < num5 || num3 > num6) { return false; } continue; } float num7 = 1f / num4; float num8 = (num5 - num3) * num7; float num9 = (num6 - num3) * num7; if (num8 > num9) { float num10 = num9; num9 = num8; num8 = num10; } num = Mathf.Max(num, num8); num2 = Mathf.Min(num2, num9); if (num > num2) { return false; } } return true; } private static float DistancePointToSegmentSquared(Vector3 point, Vector3 start, Vector3 end) { //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) //IL_0002: 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_0029: 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_002b: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_004e: 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) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; Vector3 val2; if (sqrMagnitude <= 1E-06f) { val2 = point - start; return ((Vector3)(ref val2)).sqrMagnitude; } float num = Mathf.Clamp01(Vector3.Dot(point - start, val) / sqrMagnitude); Vector3 val3 = start + val * num; val2 = point - val3; return ((Vector3)(ref val2)).sqrMagnitude; } } internal sealed class DeadAirManager : MonoBehaviour { private int _levelInstanceId; private float _spawnTimer; private bool _attemptFinished; private bool _prefabProbeFinished; private bool _prefabsAvailable; private bool _levelReadyLogged; private DeadAirController _encounter; internal void Tick() { if (!IsHostOrSingleplayerReady()) { return; } ProbePrefabs(); LevelGenerator instance = LevelGenerator.Instance; int num = (((Object)(object)instance != (Object)null) ? ((Object)instance).GetInstanceID() : 0); if (num != _levelInstanceId) { ResetForLevel(num); } if (!IsPlayableLevel()) { DestroyCurrentEncounter(); } else if (!((Object)(object)instance == (Object)null) && instance.Generated && !_attemptFinished) { if (!_levelReadyLogged) { _levelReadyLogged = true; Plugin.Log.LogInfo((object)"The Dead Air detected a generated playable level; automatic spawn timer started."); } _spawnTimer -= Time.deltaTime; if (!(_spawnTimer > 0f)) { _attemptFinished = true; TryCreateEncounter(); } } } private void ResetForLevel(int levelId) { if ((Object)(object)_encounter != (Object)null) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); } _encounter = null; _levelInstanceId = levelId; _spawnTimer = Mathf.Max(0f, Plugin.Settings.DeadAirSpawnDelay.Value); _attemptFinished = false; _levelReadyLogged = false; } private void TryCreateEncounter() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) Vector3 position; if (Random.value > Mathf.Clamp01(Plugin.Settings.DeadAirSpawnChance.Value)) { Plugin.Log.LogInfo((object)"The Dead Air skipped this level by spawn chance."); } else if (!_prefabsAvailable && !DeadAirSpawner.PrefabsAvailable()) { Plugin.Log.LogWarning((object)"The Dead Air could not find its vanilla Museum Boombox and Wizard Broom prefabs."); } else if (!TryFindSpawnPosition(out position)) { Plugin.Log.LogWarning((object)"Could not find a valid navigation point for The Dead Air."); } else { CreateEncounter(position, "automatic"); } } private bool CreateEncounter(Vector3 position, string source) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_001e: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) DestroyCurrentEncounter(); GameObject val = new GameObject("The Dead Air Encounter (Host Only)"); val.SetActive(false); val.transform.position = position; DeadAirController deadAirController = val.AddComponent(); if (!deadAirController.Initialize(position)) { Object.Destroy((Object)(object)val); Plugin.Log.LogError((object)"The Dead Air failed to initialize."); return false; } val.SetActive(true); if (!deadAirController.ActivateNavigation(position)) { Object.Destroy((Object)(object)val); Plugin.Log.LogError((object)"The Dead Air failed to activate navigation."); return false; } _encounter = deadAirController; Plugin.Log.LogInfo((object)$"The Dead Air spawned at {position} ({source}); its boombox body and six broom legs are vanilla networked objects."); return true; } internal bool DebugSpawnAt(Vector3 requestedPosition) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!IsHostOrSingleplayerReady() || (!ModEnemySpawnCoordinator.IsDirectorRequestActive && (Object)(object)PlayerAvatar.instance == (Object)null) || !IsPlayableLevel()) { Plugin.Log.LogWarning((object)"Enemy Lab rejected The Dead Air because no playable host level is active."); return false; } ProbePrefabs(); if (!_prefabsAvailable && !DeadAirSpawner.PrefabsAvailable()) { Plugin.Log.LogWarning((object)"Enemy Lab could not load the vanilla Museum Boombox and Wizard Broom prefabs for The Dead Air."); return false; } NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requestedPosition, ref val, 12f, -1)) { Plugin.Log.LogWarning((object)$"Enemy Lab could not find NavMesh near {requestedPosition} for The Dead Air."); return false; } _attemptFinished = true; return CreateEncounter(((NavMeshHit)(ref val)).position, ModEnemySpawnCoordinator.CurrentSpawnSource); } internal void MarkAutomaticAttemptFinished() { int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelInstanceId) { ResetForLevel(num); } _attemptFinished = true; } internal void DebugDespawn() { if (IsHostOrSingleplayerReady()) { _attemptFinished = true; DestroyCurrentEncounter(); Plugin.Log.LogInfo((object)"The Dead Air despawned by Enemy Lab."); } } private void DestroyCurrentEncounter() { if (!((Object)(object)_encounter == (Object)null)) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); _encounter = null; } } private void ProbePrefabs() { if (!_prefabProbeFinished && !((Object)(object)RunManager.instance == (Object)null)) { _prefabProbeFinished = true; _prefabsAvailable = DeadAirSpawner.PrefabsAvailable(); if (_prefabsAvailable) { Plugin.Log.LogInfo((object)"The Dead Air verified vanilla resources: Valuables/04 Big/Valuable Museum Boombox + six Valuables/07 Very Tall/Valuable Wizard Broom parts."); } else { Plugin.Log.LogWarning((object)"The Dead Air's vanilla body or leg resource is unavailable."); } } } private static bool IsHostOrSingleplayerReady() { if ((Object)(object)GameManager.instance == (Object)null) { return false; } try { return !GameManager.Multiplayer() || PhotonNetwork.IsMasterClient; } catch { return false; } } private static bool IsPlayableLevel() { return ModEnemyLevelRules.IsPlayableLevel(); } private static bool TryFindSpawnPosition(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; PlayerAvatar val = null; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { val = item; break; } } Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(val2, 18f, 65f, false); if ((Object)(object)val3 == (Object)null) { val3 = SemiFunc.LevelPointGetFurthestFromPlayer(val2, 6f); } return ModEnemyNavigation.TryFindClearSpawn(((Object)(object)val3 != (Object)null) ? ((Component)val3).transform.position : (val2 + Vector3.forward * 18f), 8f, out position); } } internal static class DeadAirNoiseBridge { private sealed class NoiseSuppressionScope : IDisposable { private bool _disposed; public void Dispose() { if (!_disposed) { _disposed = true; _suppressionDepth = Mathf.Max(0, _suppressionDepth - 1); } } } private static readonly FieldInfo LoudnessField = typeof(PlayerVoiceChat).GetField("clipLoudness", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo VoicePlayerField = typeof(PlayerVoiceChat).GetField("playerAvatar", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly List Listeners = new List(); private static readonly List Voices = new List(); private static readonly Dictionary LastVoiceReport = new Dictionary(); private static readonly HashSet LoggedVoiceActors = new HashSet(); private static int _suppressionDepth; private static float _voiceScanTimer; private static float _voiceRefreshTimer; private static bool _missingLoudnessLogged; internal static void Register(DeadAirController controller) { if ((Object)(object)controller != (Object)null && !Listeners.Contains(controller)) { Listeners.Add(controller); } } internal static void Unregister(DeadAirController controller) { Listeners.Remove(controller); } internal static IDisposable SuppressOwnNoise() { _suppressionDepth++; return new NoiseSuppressionScope(); } internal static void Tick() { //IL_01f6: Unknown result type (might be due to invalid IL or missing references) if (Listeners.Count == 0 || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } _voiceScanTimer -= Time.deltaTime; _voiceRefreshTimer -= Time.deltaTime; if (_voiceScanTimer > 0f) { return; } _voiceScanTimer = 0.075f; if (LoudnessField == null) { if (!_missingLoudnessLogged) { _missingLoudnessLogged = true; ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"The Dead Air could not find PlayerVoiceChat.clipLoudness; direct player-voice hearing is unavailable on this game build."); } } return; } if (_voiceRefreshTimer <= 0f) { Voices.Clear(); Voices.AddRange(Object.FindObjectsOfType()); _voiceRefreshTimer = 1.25f; } float num = Mathf.Clamp(Plugin.Settings.DeadAirVoiceLoudnessThreshold.Value, 0.001f, 0.1f); float num2 = Mathf.Clamp(Plugin.Settings.DeadAirVoiceNoiseRadius.Value, 5.3f, 24f); for (int num3 = Voices.Count - 1; num3 >= 0; num3--) { PlayerVoiceChat val = Voices[num3]; if ((Object)(object)val == (Object)null) { Voices.RemoveAt(num3); continue; } float num4; try { num4 = ((LoudnessField.GetValue(val) is float num5) ? num5 : 0f); } catch { continue; } if (num4 < num) { continue; } PlayerAvatar val2 = FindVoicePlayer(val); if (!GunAccess.IsLiving(val2)) { continue; } PhotonView photonView = val2.photonView; int num6 = ((photonView != null) ? photonView.OwnerActorNr : ((Object)val2).GetInstanceID()); if (LastVoiceReport.TryGetValue(num6, out var value) && Time.time - value < 0.16f) { continue; } LastVoiceReport[num6] = Time.time; float num7 = Mathf.InverseLerp(num, Mathf.Max(num + 0.001f, num * 4f), num4); float num8 = num2 * Mathf.Lerp(0.85f, 1.35f, num7); Report(((Component)val2).transform.position, num8, pathfindOnly: false); if (LoggedVoiceActors.Add(num6)) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)$"The Dead Air directly heard player voice from actor {num6} (loudness {num4:0.0000}, radius {num8:0.0}m). This path also covers unmodded guests."); } } } } private static PlayerAvatar FindVoicePlayer(PlayerVoiceChat voice) { try { object? obj = VoicePlayerField?.GetValue(voice); PlayerAvatar val = (PlayerAvatar)((obj is PlayerAvatar) ? obj : null); if (val != null) { return val; } } catch { } PhotonView component = ((Component)voice).GetComponent(); int num = ((component != null) ? component.OwnerActorNr : (-1)); foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if ((Object)(object)item != (Object)null && (Object)(object)item.photonView != (Object)null && item.photonView.OwnerActorNr == num) { return item; } } return null; } internal static void Report(Vector3 position, float radius, bool pathfindOnly) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (_suppressionDepth > 0 || pathfindOnly || radius <= 0f) { return; } for (int num = Listeners.Count - 1; num >= 0; num--) { DeadAirController deadAirController = Listeners[num]; if ((Object)(object)deadAirController == (Object)null) { Listeners.RemoveAt(num); } else { try { deadAirController.HearNoise(position, radius); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)("The Dead Air ignored one malformed vanilla noise event: " + ex.Message)); } } } } } } [HarmonyPatch(typeof(EnemyDirector), "SetInvestigate")] internal static class DeadAirInvestigatePatch { [HarmonyPrefix] private static void BeforeVanillaInvestigate(Vector3 __0, float __1, bool __2) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) DeadAirNoiseBridge.Report(__0, __1, __2); } } internal sealed class SpawnedDeadAirPart { internal string ResourcePath; internal GameObject Root; internal PhysGrabObject Phys; internal PhysGrabObjectImpactDetector ImpactDetector; internal ItemAttributes Attributes; internal Renderer[] Renderers; internal Collider[] Colliders; internal Vector3 LocalOffset; internal Quaternion LocalRotation; internal Vector3 VisualCenterOffset; internal Vector3 LongAxisLocal = Vector3.up; internal float VisualHalfHeight; internal Vector3 VisualSize; internal Vector3 BaseScale = Vector3.one; internal int GeometryCalibrationFrames = 20; internal Vector3 LegDirection; internal Vector3 LegStart; internal Vector3 LegEnd; internal float GaitPhase; internal Vector3 SmoothedLocalOffset; internal Quaternion SmoothedLocalRotation; internal bool PoseInitialized; internal bool IsBody; internal bool IsGrabProxy; internal bool Alive = true; } internal static class DeadAirSpawner { internal const string BodyResourcePath = "Valuables/04 Big/Valuable Museum Boombox"; internal const string LegResourcePath = "Valuables/07 Very Tall/Valuable Wizard Broom"; internal static bool PrefabsAvailable() { if ((Object)(object)Resources.Load("Valuables/04 Big/Valuable Museum Boombox") != (Object)null) { return (Object)(object)Resources.Load("Valuables/07 Very Tall/Valuable Wizard Broom") != (Object)null; } return false; } internal static SpawnedDeadAirPart Spawn(string resourcePath, Vector3 position, Quaternion rotation, Vector3 scaleMultiplier, bool isBody, bool grabbable = false, float maximumScaleMultiplier = 1.5f, float minimumScaleMultiplier = 0.04f) { //IL_003d: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0086: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00b8: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) GameObject val = Resources.Load(resourcePath); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("The Dead Air could not load vanilla resource '" + resourcePath + "'.")); return null; } float num = Mathf.Clamp(minimumScaleMultiplier, 0.0001f, maximumScaleMultiplier); ((Vector3)(ref scaleMultiplier))..ctor(Mathf.Clamp(scaleMultiplier.x, num, maximumScaleMultiplier), Mathf.Clamp(scaleMultiplier.y, num, maximumScaleMultiplier), Mathf.Clamp(scaleMultiplier.z, num, maximumScaleMultiplier)); Vector3 val2 = Vector3.Scale(val.transform.localScale, scaleMultiplier); object[] array = new object[3] { val2.x, val2.y, val2.z }; GameObject val3; try { val3 = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject(resourcePath, position, rotation, (byte)0, array) : Object.Instantiate(val, position, rotation)); } catch (Exception arg) { Plugin.Log.LogError((object)$"The Dead Air failed to network-spawn '{resourcePath}': {arg}"); return null; } if ((Object)(object)val3 == (Object)null) { return null; } val3.transform.localScale = val2; EncounterValuableNeutralizer.Apply(val3); ModEnemyInventoryBlocker.Attach(val3); Trap[] componentsInChildren = val3.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Behaviour)componentsInChildren[i]).enabled = false; } MusicalValuableLogic[] componentsInChildren2 = val3.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { ((Behaviour)componentsInChildren2[i]).enabled = false; } SpawnedDeadAirPart spawnedDeadAirPart = new SpawnedDeadAirPart { ResourcePath = resourcePath, Root = val3, Phys = val3.GetComponentInChildren(true), ImpactDetector = val3.GetComponentInChildren(true), Attributes = val3.GetComponentInChildren(true), Renderers = val3.GetComponentsInChildren(true), Colliders = val3.GetComponentsInChildren(true), BaseScale = val2, IsBody = isBody }; if ((Object)(object)spawnedDeadAirPart.Phys == (Object)null || (Object)(object)spawnedDeadAirPart.ImpactDetector == (Object)null) { Plugin.Log.LogError((object)("The Dead Air resource '" + resourcePath + "' lacks vanilla physical components.")); Destroy(spawnedDeadAirPart); return null; } RefreshRenderedGeometry(spawnedDeadAirPart); ItemAttributes attributes = spawnedDeadAirPart.Attributes; if (attributes != null) { attributes.DisableUI(true); } spawnedDeadAirPart.ImpactDetector.destroyDisable = true; spawnedDeadAirPart.Phys.OverrideIndestructible(1f); if (grabbable) { spawnedDeadAirPart.Phys.clientNonKinematic = true; } else { spawnedDeadAirPart.Phys.OverrideGrabDisable(1f); spawnedDeadAirPart.Phys.OverrideKinematic(1f); } MapIconSuppressor.Attach(val3); return spawnedDeadAirPart; } internal static void RefreshRenderedGeometry(SpawnedDeadAirPart part) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0202: 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_020a: 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_0088: 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_0231: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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_01c1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)part?.Phys == (Object)null || part.Renderers == null) { return; } bool flag = false; Bounds val = default(Bounds); Renderer[] renderers = part.Renderers; foreach (Renderer val2 in renderers) { if ((Object)(object)val2 == (Object)null || !val2.enabled || (!(val2 is MeshRenderer) && !(val2 is SkinnedMeshRenderer))) { continue; } Bounds bounds = val2.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!(((Vector3)(ref size)).sqrMagnitude < 1E-06f) && !(((Bounds)(ref bounds)).size.x > 10f) && !(((Bounds)(ref bounds)).size.y > 10f) && !(((Bounds)(ref bounds)).size.z > 10f)) { if (!flag) { val = bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(bounds); } } } if (!flag) { return; } Transform transform = ((Component)part.Phys).transform; part.VisualCenterOffset = Quaternion.Inverse(transform.rotation) * (((Bounds)(ref val)).center - transform.position); part.VisualHalfHeight = ((Bounds)(ref val)).extents.y; part.VisualSize = ((Bounds)(ref val)).size; Bounds val3 = default(Bounds); bool flag2 = false; Vector3 min = ((Bounds)(ref val)).min; Vector3 max = ((Bounds)(ref val)).max; Vector3 val4 = default(Vector3); for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { for (int l = 0; l < 2; l++) { ((Vector3)(ref val4))..ctor((j == 0) ? min.x : max.x, (k == 0) ? min.y : max.y, (l == 0) ? min.z : max.z); Vector3 val5 = transform.InverseTransformPoint(val4); if (!flag2) { ((Bounds)(ref val3))..ctor(val5, Vector3.zero); flag2 = true; } else { ((Bounds)(ref val3)).Encapsulate(val5); } } } } Vector3 size2 = ((Bounds)(ref val3)).size; part.LongAxisLocal = ((size2.x >= size2.y && size2.x >= size2.z) ? Vector3.right : ((size2.y >= size2.z) ? Vector3.up : Vector3.forward)); } internal static void Destroy(SpawnedDeadAirPart part) { if (!((Object)(object)part?.Root == (Object)null)) { if (GameManager.Multiplayer()) { PhotonNetwork.Destroy(part.Root); } else { Object.Destroy((Object)(object)part.Root); } part.Alive = false; } } } internal sealed class DeliriumController : MonoBehaviour, IModEnemyTumbleReceiver, IModEnemyTranqAware { private const float BerserkStandDuration = 0.58f; private const float BerserkFoldDuration = 2.48f; private const float BerserkPursuitSpeed = 2.65f; private const float BerserkClamberMinimumDuration = 0.82f; private const float BerserkClamberTravelSpeed = 2.15f; private const float SurfaceAttachDuration = 0.42f; private const float SurfaceRootOffset = 0.19f; private const float SurfacePatchRadius = 0.22f; private const float GroundTraversalRadius = 0.13f; private const float GroundTraversalTop = 0.88f; private static readonly List Active = new List(); private static readonly string[] SizeFolders = new string[7] { "01 Tiny", "02 Small", "03 Medium", "04 Big", "05 Wide", "06 Tall", "07 Very Tall" }; private static readonly string[] PendantNames = new string[5] { "Valuable Pendant", "Valuable Manor Pendant", "Valuable Museum Pendant", "Valuable Arctic Pendant", "Valuable Wizard Pendant" }; private static readonly string[] ServerRackNames = new string[5] { "Valuable Server Rack", "Valuable Manor Server Rack", "Valuable Museum Server Rack", "Valuable Arctic Server Rack", "Valuable Wizard Server Rack" }; private readonly List _parts = new List(); private readonly List _baseScales = new List(); private readonly List _segmentWorldLengths = new List(); private readonly List _partViews = new List(); private readonly List _disappearScales = new List(); private readonly List _lastPosePositions = new List(); private readonly List _lastPoseRotations = new List(); private readonly List _disappearPositions = new List(); private readonly List _disappearRotations = new List(); private readonly List _ownColliders = new List(); private readonly RaycastHit[] _visibilityHits = (RaycastHit[])(object)new RaycastHit[64]; private PlayerAvatar _target; private PlayerAvatar _visibilityTarget; private Quaternion _facing = Quaternion.identity; private Quaternion _crawlFacing = Quaternion.identity; private float _poseSendTimer; private bool _sendPoseThisFrame; private int _reconstructionPoseCursor = -1; private int _poseOnlyIndex = -1; private float _scan; private float _sightClearTimer; private float _sightVisibleTimer; private float _closeTimer; private float _flashlightTimer; private float _flashlightArmedAt; private float _proximityArmedAt; private float _nextHeadTwitch; private float _headTwitchStartedAt = -10f; private float _headTwitchDirection = 1f; private float _berserkAttackCooldown; private float _berserkStartedAt = -999f; private int _sanity = 3; private bool _initialized; private bool _disappearing; private float _disappearStartedAt; private float _nextDisappearPoseAt; private bool _teleportCommitted; private bool _berserk; private bool _sightLatched; private DeliriumManager _manager; private NavMeshAgent _agent; private readonly Vector3[] _crawlContacts = (Vector3[])(object)new Vector3[4]; private readonly bool[] _crawlContactValid = new bool[4]; private readonly RaycastHit[] _crawlProbeHits = (RaycastHit[])(object)new RaycastHit[16]; private readonly RaycastHit[] _clamberProbeHits = (RaycastHit[])(object)new RaycastHit[24]; private readonly Collider[] _clamberOverlap = (Collider[])(object)new Collider[24]; private readonly float[] _nextCrawlProbeAt = new float[4]; private Vector3 _lastCrawlPosition; private float _crawlTravelPhase; private float _berserkStuckTime; private float _nextObstacleProbeAt; private readonly NavMeshPath _localBypassPath = new NavMeshPath(); private Vector3[] _localBypassCorners = Array.Empty(); private int _localBypassCornerIndex; private float _localBypassUntil; private float _nextLocalBypassAttemptAt; private bool _clambering; private float _clamberStartedAt; private float _activeClamberDuration = 0.82f; private float _clamberPoseProgress; private float _clamberRise; private float _clamberArcHeight = 0.055f; private Vector3 _clamberStart; private Vector3 _clamberEnd; private Vector3 _clamberForward; private Collider _clamberObstacle; private bool _surfaceCrawling; private float _surfaceStartedAt; private float _surfaceLastProgressAt; private Vector3 _surfaceStartPosition; private Vector3 _surfaceContact; private Vector3 _surfaceNormal = Vector3.up; private Vector3 _surfaceDirection = Vector3.forward; private float _surfaceDirectionLockUntil; private int _surfaceDetourSign = 1; private Vector3 _groundDetourDirection; private float _groundDetourUntil; private Collider _groundDetourObstacle; private int _groundDetourSign = 1; private Vector3 _lastStableGroundPosition; private bool _hasStableGroundPosition; private float _nextStableGroundProbeAt; private Quaternion _surfaceStartFacing = Quaternion.identity; private Collider _surfaceObstacle; private bool _surfaceFarSideAttempted; private int _surfaceRecoveryAttempts; private readonly RaycastHit[] _surfaceHits = (RaycastHit[])(object)new RaycastHit[32]; private static readonly float[] FarSideAdvances = new float[6] { 1.05f, 1.42f, 1.82f, 2.26f, 2.72f, 3.18f }; private static readonly float[] FarSideOffsets = new float[9] { 0f, -0.36f, 0.36f, -0.72f, 0.72f, -1.08f, 1.08f, -1.44f, 1.44f }; private static readonly float[] GroundDetourAngles = new float[10] { -28f, 28f, -44f, 44f, -62f, 62f, -80f, 80f, -102f, 102f }; internal PlayerAvatar Target => _target; public bool CanReceiveTumbleAttack { get { if (_initialized) { return !_disappearing; } return false; } } internal bool Initialize(Vector3 position, int sanity = 3, bool berserk = false, DeliriumManager manager = null, PlayerAvatar target = null) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_010e: 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_0138: 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_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: 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) ((Component)this).transform.position = position; _manager = manager; _target = target; _sanity = Mathf.Clamp(sanity, 0, 3); _berserk = berserk || _sanity == 0; if (_berserk) { _berserkStartedAt = Time.time; _crawlFacing = _facing; } _flashlightArmedAt = Time.time + 1.1f; _proximityArmedAt = Time.time + 0.85f; _nextHeadTwitch = Time.time + Random.Range(2.2f, 5f); _lastCrawlPosition = position; _lastStableGroundPosition = position; _hasStableGroundPosition = true; if (!TryResolveRequiredPrefabs(out var pendant, out var torso, out var pelvis, out var limb)) { Plugin.Log.LogWarning((object)"The Delirium refused to manifest: the required Pendant, Phone, HDD, or Server Rack prefab was unavailable. No fallback was used."); return false; } try { if (Add(pendant, Vector3.one * 0.98f) == null || Add(torso, new Vector3(2.08f, 3.18f, 2.72f)) == null || Add(pelvis, Vector3.one * 0.58f) == null || Add(limb, new Vector3(0.058f, 0.37f, 0.058f)) == null || Add(limb, new Vector3(0.058f, 0.37f, 0.058f)) == null || Add(limb, new Vector3(0.058f, 0.37f, 0.058f)) == null || Add(limb, new Vector3(0.058f, 0.37f, 0.058f)) == null || Add(limb, new Vector3(0.061f, 0.41f, 0.061f)) == null || Add(limb, new Vector3(0.061f, 0.41f, 0.061f)) == null || Add(limb, new Vector3(0.061f, 0.41f, 0.061f)) == null || Add(limb, new Vector3(0.061f, 0.41f, 0.061f)) == null) { throw new InvalidOperationException("A required Delirium visual could not be network-spawned."); } for (int i = 0; i < _parts.Count; i++) { SpawnedDeadAirPart spawnedDeadAirPart = _parts[i]; if (spawnedDeadAirPart == null || (Object)(object)spawnedDeadAirPart.Root == (Object)null || (Object)(object)spawnedDeadAirPart.Phys == (Object)null) { throw new InvalidOperationException("A spawned Delirium visual is missing physical state."); } if ((Object)(object)spawnedDeadAirPart.ImpactDetector != (Object)null) { spawnedDeadAirPart.ImpactDetector.playerHurtDisable = true; spawnedDeadAirPart.ImpactDetector.destroyDisable = true; } ((Component)spawnedDeadAirPart.Phys).gameObject.AddComponent().Initialize(this, i); } PrepareInternalCollisions(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("The Delirium manifestation rolled back with no relics: " + ex.Message)); Rollback(); return false; } _agent = ((Component)this).gameObject.AddComponent(); ((Behaviour)_agent).enabled = false; _agent.speed = 4.8f; _agent.acceleration = 18f; _agent.angularSpeed = 520f; _agent.radius = 0.26f; _agent.height = 1.72f; _agent.stoppingDistance = 0.18f; _agent.autoBraking = false; _agent.updateRotation = false; _agent.autoTraverseOffMeshLink = true; _agent.autoRepath = true; _agent.obstacleAvoidanceType = (ObstacleAvoidanceType)4; _initialized = true; Active.Add(this); UpdateVisibilityTarget(_target); Pose(force: true); Plugin.Log.LogInfo((object)$"The Delirium assembled on the Mimic rig from pendant={pendant}, torso={torso} (back-forward), pelvis={pelvis} (back-forward), serverRack={limb}; parts={_parts.Count}."); return true; } internal bool ActivateNavigation(Vector3 position) { //IL_001d: 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_0030: Unknown result type (might be due to invalid IL or missing references) if (_berserk) { ((Component)this).transform.position = position; KeepBerserkAgentDisabled(); return true; } bool num = TryActivateLocalNavigation(position); if (!num) { Plugin.Log.LogWarning((object)$"The Delirium kept surface movement because no local NavMesh point existed at {position}."); } return num; } private bool TryActivateLocalNavigation(Vector3 requested) { //IL_0010: 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_0029: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_agent == (Object)null) { return false; } NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requested, ref val, 0.28f, -1)) { return false; } Vector3 val2 = ((NavMeshHit)(ref val)).position - requested; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(val2.x, val2.z); if (((Vector2)(ref val3)).sqrMagnitude > 0.0484f || Mathf.Abs(val2.y) > 0.25f) { return false; } return TryActivateKnownNavPoint(((NavMeshHit)(ref val)).position); } private bool TryActivateKnownNavPoint(Vector3 point) { //IL_0010: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_agent == (Object)null) { return false; } NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(point, ref val, 0.12f, -1)) { Vector3 val2 = ((NavMeshHit)(ref val)).position - point; if (!(((Vector3)(ref val2)).sqrMagnitude > 0.0144f)) { Vector3 position = ((Component)this).transform.position; if (((Behaviour)_agent).enabled) { ((Behaviour)_agent).enabled = false; } ((Component)this).transform.position = ((NavMeshHit)(ref val)).position; ((Behaviour)_agent).enabled = true; if (!_agent.Warp(((NavMeshHit)(ref val)).position) || !_agent.isOnNavMesh) { ((Behaviour)_agent).enabled = false; ((Component)this).transform.position = position; return false; } _agent.isStopped = false; return true; } } return false; } internal bool ReconstructInPlace(Vector3 position, int sanity, bool berserk, PlayerAvatar target) { //IL_004c: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) if (!_initialized || _parts.Count != 11) { return false; } StopBerserkPursuit(); if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled) { ((Behaviour)_agent).enabled = false; } ((Component)this).transform.position = position; _target = target; _sanity = Mathf.Clamp(sanity, 0, 3); _berserk = berserk || _sanity == 0; _berserkStartedAt = (_berserk ? Time.time : (-999f)); _disappearing = false; _teleportCommitted = false; _sightLatched = false; _sightVisibleTimer = 0f; _sightClearTimer = 0f; _closeTimer = 0f; _flashlightTimer = 0f; _flashlightArmedAt = Time.time + 1.1f; _proximityArmedAt = Time.time + 0.85f; _berserkAttackCooldown = (_berserk ? 2.8600001f : 0f); _crawlFacing = _facing; _crawlTravelPhase = 0f; _lastCrawlPosition = position; _lastStableGroundPosition = position; _hasStableGroundPosition = true; _nextStableGroundProbeAt = 0f; _berserkStuckTime = 0f; _nextObstacleProbeAt = 0f; ClearLocalBypass(); _nextLocalBypassAttemptAt = 0f; _clambering = false; _clamberObstacle = null; _clamberPoseProgress = 0f; _clamberRise = 0f; _surfaceCrawling = false; _surfaceObstacle = null; _surfaceNormal = Vector3.up; _surfaceDirection = _crawlFacing * Vector3.forward; _surfaceDirectionLockUntil = 0f; _surfaceDetourSign = 1; _groundDetourDirection = Vector3.zero; _groundDetourUntil = 0f; _groundDetourObstacle = null; Array.Clear(_crawlContactValid, 0, _crawlContactValid.Length); Array.Clear(_nextCrawlProbeAt, 0, _nextCrawlProbeAt.Length); for (int i = 0; i < _parts.Count; i++) { SpawnedDeadAirPart spawnedDeadAirPart = _parts[i]; if ((Object)(object)spawnedDeadAirPart?.Root == (Object)null || (Object)(object)spawnedDeadAirPart.Phys == (Object)null) { return false; } if ((Object)(object)spawnedDeadAirPart.ImpactDetector != (Object)null) { spawnedDeadAirPart.ImpactDetector.playerHurtDisable = true; spawnedDeadAirPart.ImpactDetector.destroyDisable = true; } } UpdateVisibilityTarget(target); _poseSendTimer = 0f; _sendPoseThisFrame = true; _reconstructionPoseCursor = 0; if (_berserk) { KeepBerserkAgentDisabled(); } else { ActivateNavigation(position); } return true; } private void KeepBerserkAgentDisabled() { if (!((Object)(object)_agent == (Object)null) && ((Behaviour)_agent).enabled) { if (_agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } ((Behaviour)_agent).enabled = false; } } private SpawnedDeadAirPart Add(string resource, Vector3 scale) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: 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) Vector3 position = (GameManager.Multiplayer() ? VoodooSpawner.HiddenPosition : (((Component)this).transform.position + Vector3.up)); SpawnedDeadAirPart spawnedDeadAirPart = MimicSpawner.SpawnPart(resource, position, scale); if (spawnedDeadAirPart == null || (Object)(object)spawnedDeadAirPart.Root == (Object)null || (Object)(object)spawnedDeadAirPart.Phys == (Object)null) { if (spawnedDeadAirPart != null) { DeadAirSpawner.Destroy(spawnedDeadAirPart); } return null; } Trap[] componentsInChildren = spawnedDeadAirPart.Root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Behaviour)componentsInChildren[i]).enabled = false; } MusicalValuableLogic[] componentsInChildren2 = spawnedDeadAirPart.Root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { ((Behaviour)componentsInChildren2[i]).enabled = false; } PhoneValuable[] componentsInChildren3 = spawnedDeadAirPart.Root.GetComponentsInChildren(true); foreach (PhoneValuable val in componentsInChildren3) { val.hasRung = true; val.ringIntervalTimer = 999999f; val.ringTimer = 0f; if ((Object)(object)val.phoneLight != (Object)null) { val.phoneLight.SetActive(false); } ((Behaviour)val).enabled = false; } _parts.Add(spawnedDeadAirPart); _baseScales.Add(spawnedDeadAirPart.Root.transform.localScale); _segmentWorldLengths.Add(Mathf.Max(0f, (spawnedDeadAirPart.VisualSize.y > 0.01f) ? spawnedDeadAirPart.VisualSize.y : (spawnedDeadAirPart.VisualHalfHeight * 2f))); PhotonView val2 = spawnedDeadAirPart.Root.GetComponentInChildren(true) ?? ((Component)spawnedDeadAirPart.Phys).GetComponentInParent(); _partViews.Add(val2); _lastPosePositions.Add(((Component)this).transform.position); _lastPoseRotations.Add(Quaternion.identity); if (GameManager.Multiplayer()) { PhotonView val3 = val2; if ((Object)(object)val3 != (Object)null) { val3.Synchronization = (ViewSynchronization)0; val3.ObservedComponents?.Clear(); } SetLocalRenderers(spawnedDeadAirPart, enabled: false); spawnedDeadAirPart.Phys.SetPositionLogic(VoodooSpawner.HiddenPosition, Quaternion.identity); } if (_parts.Count >= 4) { spawnedDeadAirPart.LongAxisLocal = Vector3.up; } spawnedDeadAirPart.GeometryCalibrationFrames = 0; return spawnedDeadAirPart; } private void PrepareInternalCollisions() { _ownColliders.Clear(); foreach (SpawnedDeadAirPart part in _parts) { if ((Object)(object)part?.Root == (Object)null) { continue; } Collider[] componentsInChildren = part.Root.GetComponentsInChildren(true); foreach (Collider val in componentsInChildren) { if ((Object)(object)val != (Object)null && !_ownColliders.Contains(val)) { _ownColliders.Add(val); } } } for (int j = 0; j < _ownColliders.Count; j++) { Collider val2 = _ownColliders[j]; if ((Object)(object)val2 == (Object)null) { continue; } for (int k = j + 1; k < _ownColliders.Count; k++) { Collider val3 = _ownColliders[k]; if ((Object)(object)val3 != (Object)null) { Physics.IgnoreCollision(val2, val3, true); } } } } private void Update() { //IL_0099: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_0198: Unknown result type (might be due to invalid IL or missing references) if (!_initialized || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (_disappearing) { TickDisappear(); return; } if (_reconstructionPoseCursor >= 0) { TickReconstructionPose(); return; } _scan -= Time.deltaTime; if (_scan <= 0f) { _scan = 0.2f; if (!GunAccess.IsLiving(_target)) { _target = FindNearestLivingPlayer(); } } UpdateVisibilityTarget(_target); if (GunAccess.IsLiving(_target)) { Vector3 val = ((Component)_target).transform.position - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.001f) { _facing = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); } float magnitude = ((Vector3)(ref val)).magnitude; _berserkAttackCooldown -= Time.deltaTime; if (_berserk) { float num = Time.time - _berserkStartedAt; if (num >= 2.48f) { UpdateBerserkPursuit(_target); } else { StopBerserkPursuit(); } _closeTimer = 0f; _flashlightTimer = 0f; if (num >= 2.48f && _berserkAttackCooldown <= 0f && TryGetBerserkKillContact(_target, out var attackPoint) && HasLineOfSightToPoint(_target, attackPoint)) { PlayerHealth playerHealth = _target.playerHealth; if (playerHealth != null) { playerHealth.HurtOther(666, attackPoint, false, -1, false); } _berserkAttackCooldown = 0.82f; } } else { StopBerserkPursuit(); bool flag = magnitude < 24f && IsObservedByTarget(_target); if (Time.time >= _flashlightArmedAt && flag && IsIlluminatedByTargetFlashlight(_target)) { _flashlightTimer += Time.deltaTime; if (_flashlightTimer >= 0.18f) { RegisterSanityExposure("flashlight"); return; } } else { _flashlightTimer = 0f; } if (flag) { _closeTimer = 0f; _sightClearTimer = 0f; if (!_sightLatched) { _sightVisibleTimer += Time.deltaTime; if (_sightVisibleTimer >= 0.32f) { RegisterSanityExposure("sighting"); return; } } } else { _sightVisibleTimer = 0f; if (_sightLatched) { _sightClearTimer += Time.deltaTime; if (_sightClearTimer >= 2.25f) { _sightLatched = false; _sightClearTimer = 0f; } } } if (!flag && Time.time >= _proximityArmedAt && magnitude <= 8f) { _closeTimer += Time.deltaTime; if (_closeTimer >= 0.24f) { Plugin.Log.LogInfo((object)"The Delirium collapsed from proximity without consuming sanity."); BeginDisappear(); return; } } else { _closeTimer = 0f; } } } else { StopBerserkPursuit(); _closeTimer = 0f; _flashlightTimer = 0f; } _poseSendTimer -= Time.deltaTime; _sendPoseThisFrame = _poseSendTimer <= 0f; if (_sendPoseThisFrame) { _poseSendTimer = 1f / 30f; } Pose(force: false); } private void TickReconstructionPose() { int num = Mathf.Min(_parts.Count, _reconstructionPoseCursor + 2); _sendPoseThisFrame = true; for (int i = _reconstructionPoseCursor; i < num; i++) { SpawnedDeadAirPart spawnedDeadAirPart = _parts[i]; if ((Object)(object)spawnedDeadAirPart?.Root != (Object)null && (Object)(object)spawnedDeadAirPart.Phys != (Object)null && (Object)(object)spawnedDeadAirPart.ImpactDetector != (Object)null) { spawnedDeadAirPart.ImpactDetector.playerHurtDisable = true; spawnedDeadAirPart.ImpactDetector.destroyDisable = true; } _poseOnlyIndex = i; Pose(force: true); } _poseOnlyIndex = -1; _reconstructionPoseCursor = num; if (_reconstructionPoseCursor >= _parts.Count) { _reconstructionPoseCursor = -1; _poseSendTimer = 1f / 30f; } } private PlayerAvatar FindNearestLivingPlayer() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar result = null; float num = float.MaxValue; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { Vector3 val = ((Component)item).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (!(sqrMagnitude >= num)) { result = item; num = sqrMagnitude; } } } return result; } private void RegisterSanityExposure(string source) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (!_berserk && !_disappearing) { _sanity = Mathf.Max(0, _sanity - 1); _berserk = _sanity == 0; _sightLatched = true; _sightVisibleTimer = 0f; _sightClearTimer = 0f; _closeTimer = 0f; _flashlightTimer = 0f; Plugin.Log.LogInfo((object)$"The Delirium exposure ({source}) registered: count={3 - _sanity}/3, sanity={_sanity}."); if (_berserk) { _berserkStartedAt = Time.time; _berserkAttackCooldown = 2.8600001f; _crawlFacing = _facing; StopBerserkPursuit(); Plugin.Log.LogWarning((object)"The Delirium reached zero sanity and entered its berserk pursuit."); } else { BeginDisappear(); } } } private bool HasLineOfSight(PlayerAvatar player) { //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_0020: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_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) if ((Object)(object)player == (Object)null) { return false; } Vector3 end = ((Component)player).transform.position + Vector3.up * 0.85f; if (GunAccess.TryGetPlayerBounds(player, out var bounds)) { end = ((Bounds)(ref bounds)).center; } return HasLineOfSightToPoint(player, end); } private bool HasLineOfSightToPoint(PlayerAvatar player, Vector3 end) { //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_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_002c: 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_0041: 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_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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return false; } if (!HasUnblockedRayToPlayer(player, ((Component)this).transform.position + Vector3.up * 0.35f, end) && !HasUnblockedRayToPlayer(player, ((Component)this).transform.position + Vector3.up * 1.18f, end)) { return HasUnblockedRayToPlayer(player, ((Component)this).transform.position + Vector3.up * 2.2f, end); } return true; } private bool HasUnblockedRayToPlayer(PlayerAvatar player, Vector3 start, Vector3 end) { //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) //IL_0002: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_004d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.05f) { return true; } int num = Physics.RaycastNonAlloc(start, val / magnitude, _visibilityHits, magnitude, -5, (QueryTriggerInteraction)1); float num2 = float.MaxValue; PlayerAvatar val2 = null; for (int i = 0; i < num; i++) { RaycastHit val3 = _visibilityHits[i]; if (!((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null) && !IsOwnCollider(((RaycastHit)(ref val3)).collider) && !(((RaycastHit)(ref val3)).distance >= num2)) { num2 = ((RaycastHit)(ref val3)).distance; val2 = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent(); } } if (num2 != float.MaxValue) { return (Object)(object)val2 == (Object)(object)player; } return true; } private bool IsOwnCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } if (_ownColliders.Contains(collider)) { return true; } foreach (SpawnedDeadAirPart part in _parts) { if ((Object)(object)part?.Root != (Object)null && ((Object)(object)((Component)collider).gameObject == (Object)(object)part.Root || ((Component)collider).transform.IsChildOf(part.Root.transform))) { return true; } } return false; } private bool TryGetBerserkKillContact(PlayerAvatar player, out Vector3 attackPoint) { //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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_00dc: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) attackPoint = (((Object)(object)player != (Object)null) ? (((Component)player).transform.position + Vector3.up * 0.85f) : ((Component)this).transform.position); if (!GunAccess.IsLiving(player)) { return false; } if (GunAccess.TryGetPlayerBounds(player, out var bounds)) { float num = float.MaxValue; Vector3 val = ((Bounds)(ref bounds)).center; for (int i = 0; i < 4; i++) { Vector3 val2 = ((Component)this).transform.position + Vector3.up * i switch { 2 => 1.43f, 1 => 0.82f, 0 => 0.22f, _ => 2.04f, }; Vector3 val3 = ((Bounds)(ref bounds)).ClosestPoint(val2); float num2 = Vector3.Distance(val2, val3); if (num2 < num) { num = num2; val = val3; } } attackPoint = val; return num <= 0.78f; } Vector3 val4 = ((Component)player).transform.position - ((Component)this).transform.position; float y = val4.y; val4.y = 0f; if (((Vector3)(ref val4)).sqrMagnitude <= 0.6083999f && y >= -0.7f) { return y <= 2.55f; } return false; } private bool IsObservedByTarget(PlayerAvatar player) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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) //IL_0060: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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) if (!GunAccess.IsLiving(player)) { return false; } Transform val = player.PlayerVisionTarget?.VisionTransform; Vector3 eye = (((Object)(object)val != (Object)null) ? val.position : (((Component)player).transform.position + Vector3.up)); Vector3 forward = (((Object)(object)val != (Object)null) ? val.forward : ((Component)player).transform.forward); if (((Vector3)(ref forward)).sqrMagnitude < 0.001f) { return false; } float minimumDot = Mathf.Cos(0.9075712f); ((Vector3)(ref forward)).Normalize(); if (!IsObservedSample(player, eye, forward, ((Component)this).transform.position + Vector3.up * 0.72f, minimumDot) && !IsObservedSample(player, eye, forward, ((Component)this).transform.position + Vector3.up * 1.43f, minimumDot)) { return IsObservedSample(player, eye, forward, ((Component)this).transform.position + Vector3.up * 2.05f, minimumDot); } return true; } private bool IsObservedSample(PlayerAvatar player, Vector3 eye, Vector3 forward, Vector3 sample, float minimumDot) { //IL_0000: 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) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0031: Unknown result type (might be due to invalid IL or missing references) Vector3 val = sample - eye; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.05f) { return true; } if (Vector3.Dot(forward, val / magnitude) < minimumDot) { return false; } return HasStrictViewerRay(player, eye, sample); } private bool HasStrictViewerRay(PlayerAvatar player, Vector3 start, Vector3 end) { //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) //IL_0002: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0053: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.05f) { return true; } int num = Physics.RaycastNonAlloc(start, val / magnitude, _visibilityHits, magnitude + 0.08f, -5, (QueryTriggerInteraction)1); float num2 = float.MaxValue; bool flag = false; for (int i = 0; i < num; i++) { RaycastHit val2 = _visibilityHits[i]; if (!((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null)) { Transform transform = ((Component)((RaycastHit)(ref val2)).collider).transform; if (!((Object)(object)transform == (Object)(object)((Component)player).transform) && !transform.IsChildOf(((Component)player).transform) && !(((RaycastHit)(ref val2)).distance >= num2)) { num2 = ((RaycastHit)(ref val2)).distance; flag = IsOurPart(transform); } } } return num2 == float.MaxValue || flag; } private bool IsIlluminatedByTargetFlashlight(PlayerAvatar player) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_0161: 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) if ((Object)(object)player == (Object)null || (Object)(object)player.flashlightController == (Object)null || !player.flashlightController.LightActive || (Object)(object)player.flashlightController.spotlight == (Object)null || !((Behaviour)player.flashlightController.spotlight).enabled || !((Component)player.flashlightController.spotlight).gameObject.activeInHierarchy) { return false; } Transform val = (((Object)(object)player.flashlightLightAim != (Object)null) ? ((Component)player.flashlightLightAim).transform : ((Component)player.flashlightController).transform); Vector3 val2 = ((Component)this).transform.position + Vector3.up * 1.3f - val.position; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude < 0.15f || magnitude > 30f) { return false; } float num = 22f; if ((Object)(object)player.flashlightController.spotlight != (Object)null) { num = Mathf.Clamp(player.flashlightController.spotlight.spotAngle * 0.52f, 14f, 34f); } if (Vector3.Angle(val.forward, val2) > num) { return false; } int num2 = Physics.RaycastNonAlloc(val.position, val2 / magnitude, _visibilityHits, magnitude + 0.4f, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); float num3 = float.MaxValue; bool flag = false; for (int i = 0; i < num2; i++) { RaycastHit val3 = _visibilityHits[i]; if (!((Object)(object)((RaycastHit)(ref val3)).transform == (Object)null) && !((Object)(object)((RaycastHit)(ref val3)).transform == (Object)(object)((Component)player).transform) && !((RaycastHit)(ref val3)).transform.IsChildOf(((Component)player).transform) && !(((RaycastHit)(ref val3)).distance >= num3)) { num3 = ((RaycastHit)(ref val3)).distance; flag = IsOurPart(((RaycastHit)(ref val3)).transform); } } return num3 == float.MaxValue || flag; } private bool IsOurPart(Transform candidate) { foreach (SpawnedDeadAirPart part in _parts) { if (!((Object)(object)part?.Root == (Object)null)) { Transform transform = part.Root.transform; if ((Object)(object)candidate == (Object)(object)transform || candidate.IsChildOf(transform)) { return true; } } } return false; } private void Pose(bool force) { //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: 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_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: 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_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) if (_parts.Count != 11) { return; } if (_berserk) { PoseBerserk(force); return; } float num = Mathf.Sin(Time.time * 2.15f) * 0.055f; float num2 = Mathf.Sin(Time.time * 1.25f) * 0.18f; float num3 = num2 * 0.23f; float num4 = num2 * 0.31f; float num5 = 12f + Mathf.Sin(Time.time * 1.35f) * 1.4f; if (Time.time >= _nextHeadTwitch) { _headTwitchStartedAt = Time.time; _headTwitchDirection = ((Random.value < 0.5f) ? (-1f) : 1f); _nextHeadTwitch = Time.time + Random.Range(3.4f, 7.2f); } float num6 = Time.time - _headTwitchStartedAt; float num7 = ((num6 >= 0f && num6 <= 0.34f) ? (Mathf.Sin(num6 / 0.34f * MathF.PI) * _headTwitchDirection) : 0f); Quaternion facing = _facing; Vector3 position = ((Component)this).transform.position; Vector3 localCenter = default(Vector3); ((Vector3)(ref localCenter))..ctor(0f, 2.08f + num, 0.31f); Vector3 localCenter2 = default(Vector3); ((Vector3)(ref localCenter2))..ctor(0f, 1.61f + num * 0.55f, 0.2f); Vector3 localCenter3 = default(Vector3); ((Vector3)(ref localCenter3))..ctor(0f, 1.27f + num * 0.35f, 0.11f); PoseVisual(0, localCenter, Quaternion.Euler(4f + num5 * 0.65f, num7 * 4f, num7 * 22f), position, facing, force); PoseVisual(1, localCenter2, Quaternion.Euler(90f + num5, 180f, 0f), position, facing, force); PoseVisual(2, localCenter3, Quaternion.Euler(90f + num5 * 0.52f, 180f, 0f), position, facing, force); Vector3 localStart = default(Vector3); ((Vector3)(ref localStart))..ctor(-0.235f, 1.56f, 0.27f); Vector3 localStart2 = default(Vector3); ((Vector3)(ref localStart2))..ctor(0.235f, 1.56f, 0.27f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(-0.285f, 0.96f, 0.3f - num3); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0.285f, 0.96f, 0.3f + num3); Vector3 localEnd = default(Vector3); ((Vector3)(ref localEnd))..ctor(-0.285f, 0.2f, 0.35f - num3 * 1.55f); Vector3 localEnd2 = default(Vector3); ((Vector3)(ref localEnd2))..ctor(0.285f, 0.2f, 0.35f + num3 * 1.55f); PoseSegment(3, localStart, val, position, facing, force); PoseSegment(4, val, localEnd, position, facing, force); PoseSegment(5, localStart2, val2, position, facing, force); PoseSegment(6, val2, localEnd2, position, facing, force); Vector3 localStart3 = default(Vector3); ((Vector3)(ref localStart3))..ctor(-0.105f, 1.19f, 0.1f); Vector3 localStart4 = default(Vector3); ((Vector3)(ref localStart4))..ctor(0.105f, 1.19f, 0.1f); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(-0.115f, 0.56f, 0.07f + num4 * 0.7f); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(0.115f, 0.56f, 0.07f - num4 * 0.7f); Vector3 localEnd3 = default(Vector3); ((Vector3)(ref localEnd3))..ctor(-0.13f, 0.07f, 0.06f + num4); Vector3 localEnd4 = default(Vector3); ((Vector3)(ref localEnd4))..ctor(0.13f, 0.07f, 0.06f - num4); PoseSegment(7, localStart3, val3, position, facing, force); PoseSegment(8, val3, localEnd3, position, facing, force); PoseSegment(9, localStart4, val4, position, facing, force); PoseSegment(10, val4, localEnd4, position, facing, force); } private void PoseBerserk(bool force) { //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: 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_022e: 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_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_033d: 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_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039e: 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_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Unknown result type (might be due to invalid IL or missing references) //IL_05c4: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_05dc: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Unknown result type (might be due to invalid IL or missing references) //IL_05f2: Unknown result type (might be due to invalid IL or missing references) //IL_05f7: Unknown result type (might be due to invalid IL or missing references) //IL_0608: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_062f: Unknown result type (might be due to invalid IL or missing references) //IL_0636: Unknown result type (might be due to invalid IL or missing references) //IL_063b: Unknown result type (might be due to invalid IL or missing references) //IL_063f: Unknown result type (might be due to invalid IL or missing references) //IL_0657: Unknown result type (might be due to invalid IL or missing references) //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_0671: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_0689: Unknown result type (might be due to invalid IL or missing references) //IL_068b: Unknown result type (might be due to invalid IL or missing references) //IL_068d: Unknown result type (might be due to invalid IL or missing references) //IL_068f: Unknown result type (might be due to invalid IL or missing references) //IL_06a3: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_06a7: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_06bd: Unknown result type (might be due to invalid IL or missing references) //IL_06bf: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Unknown result type (might be due to invalid IL or missing references) //IL_06e4: Unknown result type (might be due to invalid IL or missing references) //IL_06f8: Unknown result type (might be due to invalid IL or missing references) //IL_06fe: Unknown result type (might be due to invalid IL or missing references) //IL_0703: Unknown result type (might be due to invalid IL or missing references) //IL_0714: Unknown result type (might be due to invalid IL or missing references) //IL_0728: Unknown result type (might be due to invalid IL or missing references) //IL_072e: Unknown result type (might be due to invalid IL or missing references) //IL_0733: Unknown result type (might be due to invalid IL or missing references) //IL_0744: Unknown result type (might be due to invalid IL or missing references) //IL_076a: Unknown result type (might be due to invalid IL or missing references) //IL_0771: Unknown result type (might be due to invalid IL or missing references) //IL_0776: Unknown result type (might be due to invalid IL or missing references) //IL_0787: Unknown result type (might be due to invalid IL or missing references) //IL_07ad: Unknown result type (might be due to invalid IL or missing references) //IL_07b4: Unknown result type (might be due to invalid IL or missing references) //IL_07b9: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_056b: Unknown result type (might be due to invalid IL or missing references) //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_0575: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_0583: Unknown result type (might be due to invalid IL or missing references) //IL_087e: Unknown result type (might be due to invalid IL or missing references) //IL_0896: Unknown result type (might be due to invalid IL or missing references) //IL_08bb: Unknown result type (might be due to invalid IL or missing references) //IL_08c0: Unknown result type (might be due to invalid IL or missing references) //IL_08c2: Unknown result type (might be due to invalid IL or missing references) //IL_08d3: Unknown result type (might be due to invalid IL or missing references) //IL_08e2: Unknown result type (might be due to invalid IL or missing references) //IL_08e9: Unknown result type (might be due to invalid IL or missing references) //IL_08ee: Unknown result type (might be due to invalid IL or missing references) //IL_08ff: Unknown result type (might be due to invalid IL or missing references) //IL_0904: Unknown result type (might be due to invalid IL or missing references) //IL_0906: Unknown result type (might be due to invalid IL or missing references) //IL_0917: Unknown result type (might be due to invalid IL or missing references) //IL_0926: Unknown result type (might be due to invalid IL or missing references) //IL_092d: Unknown result type (might be due to invalid IL or missing references) //IL_0932: Unknown result type (might be due to invalid IL or missing references) //IL_0936: Unknown result type (might be due to invalid IL or missing references) //IL_094e: Unknown result type (might be due to invalid IL or missing references) //IL_0966: Unknown result type (might be due to invalid IL or missing references) //IL_0968: Unknown result type (might be due to invalid IL or missing references) //IL_096a: Unknown result type (might be due to invalid IL or missing references) //IL_096c: Unknown result type (might be due to invalid IL or missing references) //IL_0980: Unknown result type (might be due to invalid IL or missing references) //IL_0982: Unknown result type (might be due to invalid IL or missing references) //IL_0984: Unknown result type (might be due to invalid IL or missing references) //IL_0986: Unknown result type (might be due to invalid IL or missing references) //IL_099b: Unknown result type (might be due to invalid IL or missing references) //IL_099d: Unknown result type (might be due to invalid IL or missing references) //IL_099f: Unknown result type (might be due to invalid IL or missing references) //IL_09a1: Unknown result type (might be due to invalid IL or missing references) //IL_09b6: Unknown result type (might be due to invalid IL or missing references) //IL_09b8: Unknown result type (might be due to invalid IL or missing references) //IL_09ba: Unknown result type (might be due to invalid IL or missing references) //IL_09bc: Unknown result type (might be due to invalid IL or missing references) //IL_0848: Unknown result type (might be due to invalid IL or missing references) //IL_084b: Unknown result type (might be due to invalid IL or missing references) //IL_0850: Unknown result type (might be due to invalid IL or missing references) //IL_0852: Unknown result type (might be due to invalid IL or missing references) //IL_0854: Unknown result type (might be due to invalid IL or missing references) //IL_085b: Unknown result type (might be due to invalid IL or missing references) //IL_0860: Unknown result type (might be due to invalid IL or missing references) //IL_0862: Unknown result type (might be due to invalid IL or missing references) //IL_0865: Unknown result type (might be due to invalid IL or missing references) //IL_086a: Unknown result type (might be due to invalid IL or missing references) //IL_086c: Unknown result type (might be due to invalid IL or missing references) //IL_086e: Unknown result type (might be due to invalid IL or missing references) //IL_0875: Unknown result type (might be due to invalid IL or missing references) //IL_087a: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; float num = Mathf.Max(0f, time - _berserkStartedAt); float num2 = Mathf.Clamp01((num - 0.58f) / Mathf.Max(0.01f, 1.9000001f)); float num3 = Quintic01(Mathf.InverseLerp(0f, 0.72f, num2)); float num4 = Quintic01(Mathf.InverseLerp(0.18f, 0.8f, num2)); float num5 = Quintic01(Mathf.InverseLerp(0.27f, 0.87f, num2)); float num6 = Quintic01(Mathf.InverseLerp(0.43f, 0.94f, num2)); float num7 = Quintic01(Mathf.InverseLerp(0.51f, 1f, num2)); float num8 = num3; float num9 = Mathf.Max(0f, num - 2.48f); float num10 = _crawlTravelPhase + num9 * 0.42f; float num11 = Mathf.Sin(num10); float num12 = 0f - num11; float num13 = Mathf.Pow(Mathf.Max(0f, Mathf.Sin(num10)), 2f); float num14 = Mathf.Pow(Mathf.Max(0f, Mathf.Sin(num10 + MathF.PI)), 2f); float num15 = Mathf.Sin(time * 15.7f) * 0.012f; float num16 = Mathf.Abs(Mathf.Sin(num10 * 0.5f)) * 0.024f; Quaternion val = Quaternion.Slerp(_facing, _crawlFacing, num8); Vector3 position = ((Component)this).transform.position; float num17 = (_clambering ? Mathf.Sin(Mathf.Clamp01(_clamberPoseProgress) * MathF.PI) : 0f); Vector3 localCenter = Vector3.Lerp(new Vector3(0f, 2.08f, 0.31f), new Vector3(0f, 0.91f + num16, 0.62f), num8); Vector3 localCenter2 = Vector3.Lerp(new Vector3(0f, 1.61f, 0.2f), new Vector3(0f, 0.64f + num16 * 0.55f, 0.19f), num8); Vector3 localCenter3 = Vector3.Lerp(new Vector3(0f, 1.27f, 0.11f), new Vector3(0f, 0.5f + num16 * 0.3f, -0.29f), num8); localCenter.y += num17 * 0.15f; localCenter2.y += num17 * 0.12f; localCenter3.y += num17 * 0.09f; Quaternion val2 = Quaternion.Inverse(val) * _facing * Quaternion.Euler(34f, 0f, num15 * 180f); PoseVisual(0, localCenter, Quaternion.Slerp(Quaternion.Euler(4f, 0f, 0f), val2, num8), position, val, force); PoseVisual(1, localCenter2, Quaternion.Slerp(Quaternion.Euler(102f, 180f, 0f), Quaternion.Euler(139f + num15 * 90f, 180f, 0f), num8), position, val, force); PoseVisual(2, localCenter3, Quaternion.Slerp(Quaternion.Euler(96f, 180f, 0f), Quaternion.Euler(145f, 180f, (0f - num15) * 80f), num8), position, val, force); Vector3 val3 = Vector3.Lerp(new Vector3(-0.235f, 1.56f, 0.27f), new Vector3(-0.17f, 0.64f, 0.24f), num3); Vector3 val4 = Vector3.Lerp(new Vector3(0.235f, 1.56f, 0.27f), new Vector3(0.17f, 0.64f, 0.24f), num3); Vector3 val5 = Vector3.Lerp(new Vector3(-0.285f, 0.2f, 0.35f), new Vector3(-0.49f, 0.07f + num13 * 0.12f, 0.66f + num11 * 0.27f), num4); Vector3 val6 = Vector3.Lerp(new Vector3(0.285f, 0.2f, 0.35f), new Vector3(0.49f, 0.07f + num14 * 0.12f, 0.66f + num12 * 0.27f), num5); if (_clambering) { float num18 = Mathf.Clamp01(_clamberPoseProgress); float num19 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(num18 / 0.3f)); float num20 = 1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.58f, 0.94f, num18)); float num21 = _clamberRise * (1f - Quintic01(num18)); val5.y += num21 * num19 * num20; val6.y += num21 * num19 * num20; val5.z += 0.18f * num19 * num20; val6.z += 0.18f * num19 * num20; } float num22 = ((!_clambering) ? Quintic01(Mathf.InverseLerp(0.48f, 1.05f, num9)) : 0f); if (num22 > 0f) { val5 = Vector3.Lerp(val5, SnapCrawlContact(val5, 0, num13, position, val), num22); val6 = Vector3.Lerp(val6, SnapCrawlContact(val6, 1, num14, position, val), num22); } val5.x = Mathf.Min(val5.x, -0.22f); val6.x = Mathf.Max(val6.x, 0.22f); Vector3 val7 = Vector3.Lerp(new Vector3(-0.285f, 0.96f, 0.3f), SolveTwoBoneJoint(val3, val5, new Vector3(-0.72f, 0.34f, 0.31f), 0.7f, 0.78f), num4); Vector3 val8 = Vector3.Lerp(new Vector3(0.285f, 0.96f, 0.3f), SolveTwoBoneJoint(val4, val6, new Vector3(0.72f, 0.34f, 0.31f), 0.7f, 0.78f), num5); val7.x = Mathf.Min(val7.x, -0.16f); val8.x = Mathf.Max(val8.x, 0.16f); PoseSegment(3, val3, val7, position, val, force, 0f, 0.018f); PoseSegment(4, val7, val5, position, val, force, 0.018f); PoseSegment(5, val4, val8, position, val, force, 0f, 0.018f); PoseSegment(6, val8, val6, position, val, force, 0.018f); Vector3 val9 = Vector3.Lerp(new Vector3(-0.105f, 1.19f, 0.1f), new Vector3(-0.15f, 0.5f, -0.25f), num3); Vector3 val10 = Vector3.Lerp(new Vector3(0.105f, 1.19f, 0.1f), new Vector3(0.15f, 0.5f, -0.25f), num3); Vector3 val11 = Vector3.Lerp(new Vector3(-0.13f, 0.07f, 0.06f), new Vector3(-0.48f, 0.065f + num14 * 0.11f, -0.61f + num12 * 0.25f), num6); Vector3 val12 = Vector3.Lerp(new Vector3(0.13f, 0.07f, 0.06f), new Vector3(0.48f, 0.065f + num13 * 0.11f, -0.61f + num11 * 0.25f), num7); if (_clambering) { float num23 = Mathf.Clamp01(_clamberPoseProgress); float num24 = Mathf.Sin(Mathf.Clamp01(Mathf.InverseLerp(0.42f, 1f, num23)) * MathF.PI); val11.y += num24 * 0.21f; val12.y += num24 * 0.21f; val11.z += num24 * 0.12f; val12.z += num24 * 0.12f; } if (num22 > 0f) { val11 = Vector3.Lerp(val11, SnapCrawlContact(val11, 2, num14, position, val), num22); val12 = Vector3.Lerp(val12, SnapCrawlContact(val12, 3, num13, position, val), num22); } val11.x = Mathf.Min(val11.x, -0.18f); val12.x = Mathf.Max(val12.x, 0.18f); Vector3 val13 = Vector3.Lerp(new Vector3(-0.115f, 0.56f, 0.07f), SolveTwoBoneJoint(val9, val11, new Vector3(-0.7f, 0.31f, -0.24f), 0.66f, 0.76f), num6); Vector3 val14 = Vector3.Lerp(new Vector3(0.115f, 0.56f, 0.07f), SolveTwoBoneJoint(val10, val12, new Vector3(0.7f, 0.31f, -0.24f), 0.66f, 0.76f), num7); val13.x = Mathf.Min(val13.x, -0.13f); val14.x = Mathf.Max(val14.x, 0.13f); PoseSegment(7, val9, val13, position, val, force, 0f, 0.018f); PoseSegment(8, val13, val11, position, val, force, 0.018f); PoseSegment(9, val10, val14, position, val, force, 0f, 0.018f); PoseSegment(10, val14, val12, position, val, force, 0.018f); } private static Vector3 SolveTwoBoneJoint(Vector3 start, Vector3 end, Vector3 pole, float upperLength, float lowerLength) { //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) //IL_0002: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_008f: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.001f) { return (start + end) * 0.5f; } float num = Mathf.Clamp(magnitude, Mathf.Abs(upperLength - lowerLength) + 0.001f, upperLength + lowerLength - 0.001f); Vector3 val2 = val / magnitude; float num2 = (upperLength * upperLength - lowerLength * lowerLength + num * num) / (2f * num); float num3 = Mathf.Sqrt(Mathf.Max(0f, upperLength * upperLength - num2 * num2)); Vector3 val3 = pole - start; val3 -= val2 * Vector3.Dot(val3, val2); if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { val3 = Vector3.Cross(val2, Vector3.up); if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { val3 = Vector3.Cross(val2, Vector3.forward); } } return start + val2 * num2 + ((Vector3)(ref val3)).normalized * num3; } private static float Quintic01(float value) { value = Mathf.Clamp01(value); return value * value * value * (value * (value * 6f - 15f) + 10f); } private void UpdateBerserkPursuit(PlayerAvatar player) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_005c: Unknown result type (might be due to invalid IL or missing references) //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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: 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_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(player)) { return; } if (_surfaceCrawling) { TickSurfaceCrawl(player); return; } if (_clambering) { TickBerserkClamber(player); return; } KeepBerserkAgentDisabled(); UpdateStableGroundAnchor(); Vector3 val = _lastCrawlPosition; if (PreventSolidTraversal(val)) { val = ((Component)this).transform.position; } Vector3 val2 = ((Component)this).transform.position - val; val2.y = 0f; _crawlTravelPhase += ((Vector3)(ref val2)).magnitude * 7.8f; _lastCrawlPosition = ((Component)this).transform.position; Vector3 val4; Vector3 val3 = (val4 = ((Component)player).transform.position - ((Component)this).transform.position); val4.y = 0f; bool flag = val3.y < -0.38f; bool flag2 = ((Vector3)(ref val4)).sqrMagnitude > 1.5625f || flag; if (flag2 && Time.time >= _nextObstacleProbeAt) { _nextObstacleProbeAt = Time.time + 0.11f; if ((flag && TryBeginLowerSurfaceDescent(player)) || TryBeginBerserkClamber(player)) { return; } } if (flag2 && ((Vector3)(ref val2)).sqrMagnitude < 0.000144f) { _berserkStuckTime += Time.deltaTime; } else { _berserkStuckTime = Mathf.Max(0f, _berserkStuckTime - Time.deltaTime * 2.5f); } if (_berserkStuckTime >= 0.38f) { if (flag && TryBeginLowerSurfaceDescent(player)) { _berserkStuckTime = 0f; return; } if (TryBeginBerserkClamber(player)) { _berserkStuckTime = 0f; return; } if (TryBeginLocalBypass(player)) { _berserkStuckTime = 0f; return; } _berserkStuckTime = 0.24f; } Vector3 position = ((Component)this).transform.position; if (flag2) { TryDirectBerserkStep(player); } Vector3 val5 = ((Component)this).transform.position - position; val5.y = 0f; if (((Vector3)(ref val5)).sqrMagnitude < 0.0001f) { val5 = val4; } Quaternion val6 = ((((Vector3)(ref val5)).sqrMagnitude > 0.025f) ? Quaternion.LookRotation(((Vector3)(ref val5)).normalized, Vector3.up) : _facing); _crawlFacing = Quaternion.Slerp(_crawlFacing, val6, 1f - Mathf.Exp((0f - Time.deltaTime) * 5.2f)); } private void TryDirectBerserkStep(PlayerAvatar player) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) Vector3 val = GetBerserkPursuitPoint(player) - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { TryBeginLowerSurfaceDescent(player); return; } ((Vector3)(ref val)).Normalize(); if (Time.time < _groundDetourUntil && ((Vector3)(ref _groundDetourDirection)).sqrMagnitude > 0.5f) { if (TryGroundDetourStep()) { return; } ClearGroundDetour(); } float num = Mathf.Min(0.22f, 2.65f * Time.deltaTime + 0.035f); Vector3 val2 = ((Component)this).transform.position + Vector3.up * 0.16f; Vector3 val3 = ((Component)this).transform.position + Vector3.up * 0.88f; int count = Physics.CapsuleCastNonAlloc(val2, val3, 0.13f, val, _surfaceHits, num, -5, (QueryTriggerInteraction)1); RaycastHit nearest; bool flag = TryGetNearestTraversalBlock(_surfaceHits, count, out nearest); RaycastHit nearest2; if (flag && TryBeginGroundDetour(val, ((RaycastHit)(ref nearest)).collider)) { TryGroundDetourStep(); } else if ((!TryGetNearestSurfaceHit(_surfaceHits, count, out nearest2) || !BeginSurfaceCrawl(nearest2, val)) && !flag) { Vector3 val4 = ((Component)this).transform.position + val * 2.65f * Time.deltaTime; RaycastHit val5 = default(RaycastHit); if (Physics.Raycast(val4 + Vector3.up * 0.62f, Vector3.down, ref val5, 1.28f, -5, (QueryTriggerInteraction)1) && IsClamberSurface(((RaycastHit)(ref val5)).collider) && ((RaycastHit)(ref val5)).normal.y > 0.52f) { val4.y = ((RaycastHit)(ref val5)).point.y; } ((Component)this).transform.position = val4; } } private Vector3 GetBerserkPursuitPoint(PlayerAvatar player) { //IL_009e: 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_002b: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (_localBypassCornerIndex < _localBypassCorners.Length && Time.time < _localBypassUntil) { while (_localBypassCornerIndex < _localBypassCorners.Length) { Vector3 val = _localBypassCorners[_localBypassCornerIndex]; Vector3 val2 = val - ((Component)this).transform.position; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude > 0.0784f) { return val; } _localBypassCornerIndex++; } } ClearLocalBypass(); if (!((Object)(object)player != (Object)null)) { return ((Component)this).transform.position; } return ((Component)player).transform.position; } private bool TryBeginLocalBypass(PlayerAvatar player) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(player) || Time.time < _nextLocalBypassAttemptAt) { return false; } _nextLocalBypassAttemptAt = Time.time + 0.46f; ClearGroundDetour(); NavMeshHit val = default(NavMeshHit); NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(((Component)this).transform.position, ref val, 0.72f, -1) && NavMesh.SamplePosition(((Component)player).transform.position, ref val2, 1.35f, -1) && NavMesh.CalculatePath(((NavMeshHit)(ref val)).position, ((NavMeshHit)(ref val2)).position, -1, _localBypassPath) && (int)_localBypassPath.status == 0) { Vector3[] corners = _localBypassPath.corners; int i; for (i = 0; i < corners.Length && HorizontalDistance(corners[i], ((Component)this).transform.position) < 0.28f; i++) { } if (i < corners.Length) { _localBypassCorners = corners; _localBypassCornerIndex = i; _localBypassUntil = Time.time + 6f; Plugin.Log.LogInfo((object)$"The Delirium discarded a stalled local route and began walking {corners.Length - i} physical bypass corner(s)."); return true; } } return TryBeginPhysicalFloorBypass(player); } private bool TryBeginPhysicalFloorBypass(PlayerAvatar player) { //IL_0006: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0209: 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_0216: 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_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = _crawlFacing * Vector3.forward; } ((Vector3)(ref val)).Normalize(); int num = Physics.RaycastNonAlloc(((Component)this).transform.position + Vector3.up * 0.52f, Vector3.down, _clamberProbeHits, 1.08f, -5, (QueryTriggerInteraction)1); Collider val2 = null; float num2 = float.MaxValue; for (int i = 0; i < num; i++) { RaycastHit val3 = _clamberProbeHits[i]; if (IsClamberSurface(((RaycastHit)(ref val3)).collider) && !(((RaycastHit)(ref val3)).normal.y < 0.56f) && !(((RaycastHit)(ref val3)).distance >= num2)) { num2 = ((RaycastHit)(ref val3)).distance; val2 = ((RaycastHit)(ref val3)).collider; } } float[] array = new float[7] { 72f, -72f, 108f, -108f, 145f, -145f, 180f }; float[] obj = new float[5] { 0.46f, 0.68f, 0.92f, 1.18f, 1.42f }; Vector3 val4 = Vector3.zero; float num3 = float.MinValue; bool flag = false; float[] array2 = obj; foreach (float num4 in array2) { float[] array3 = array; for (int k = 0; k < array3.Length; k++) { Vector3 val5 = Quaternion.AngleAxis(array3[k], Vector3.up) * val; Vector3 requested = ((Component)this).transform.position + val5 * num4; if (!TryResolvePhysicalLanding(requested, 0.86f, 2.32f, 1.55f, 0.92f, 1.32f, val2, out var landing)) { continue; } Vector3 val6 = landing - ((Component)this).transform.position; float arcHeight = Mathf.Clamp(0.18f + Mathf.Max(0f, val6.y) * 0.24f + Mathf.Max(0f, 0f - val6.y) * 0.14f, 0.18f, 0.52f); if (HasClamberRouteClear(((Component)this).transform.position, landing, arcHeight, val2)) { Vector3 val7 = landing - ((Component)this).transform.position; val7.y = 0f; float num5 = Vector3.Dot(((Vector3)(ref val7)).normalized, val) * 0.55f + ((Vector3)(ref val7)).magnitude * 0.12f - Vector3.Distance(landing, ((Component)player).transform.position) * 0.04f; if (!(num5 <= num3)) { num3 = num5; val4 = landing; flag = true; } } } } if (!flag) { return false; } Collider surfaceObstacle = _surfaceObstacle; _surfaceObstacle = val2; if (!BeginLocalRecoveryClamber(val4)) { _surfaceObstacle = surfaceObstacle; return false; } Plugin.Log.LogInfo((object)$"The Delirium began a local physical floor bypass toward {val4} without relocation."); return true; } private void ClearLocalBypass() { _localBypassCorners = Array.Empty(); _localBypassCornerIndex = 0; _localBypassUntil = 0f; } private bool TryBeginGroundDetour(Vector3 toward, Collider obstacle) { //IL_0023: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_00db: 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) toward.y = 0f; if (((Vector3)(ref toward)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref toward)).Normalize(); Vector3 groundDetourDirection = Vector3.zero; float num = float.MinValue; float distance = Mathf.Max(0.18f, 2.65f * Time.deltaTime + 0.11f); int groundDetourSign = _groundDetourSign; float[] groundDetourAngles = GroundDetourAngles; foreach (float num2 in groundDetourAngles) { Vector3 val = Quaternion.AngleAxis(num2, Vector3.up) * toward; if (HasGroundRoute(val, distance, out var _)) { float num3 = Vector3.Dot(val, toward); int num4 = ((!(num2 < 0f)) ? 1 : (-1)); float num5 = ((num4 == _groundDetourSign) ? 0.08f : 0f); float num6 = num3 * 1.6f - Mathf.Abs(num2) * 0.006f + num5; if (!(num6 <= num)) { num = num6; groundDetourDirection = ((Vector3)(ref val)).normalized; groundDetourSign = num4; } } } if (((Vector3)(ref groundDetourDirection)).sqrMagnitude < 0.5f) { return false; } _groundDetourDirection = groundDetourDirection; _groundDetourObstacle = obstacle; _groundDetourSign = groundDetourSign; _groundDetourUntil = Time.time + 1.55f; _berserkStuckTime = 0f; return true; } private bool TryGroundDetourStep() { //IL_0018: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_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) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_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) float num = Mathf.Max(0.025f, 2.65f * Time.deltaTime); if (!HasGroundRoute(_groundDetourDirection, num + 0.055f, out var floorPoint)) { bool flag = false; for (int i = 1; i <= 4; i++) { Vector3 direction = Quaternion.AngleAxis((float)(_groundDetourSign * i) * 18f, Vector3.up) * _groundDetourDirection; if (HasGroundRoute(direction, num + 0.055f, out floorPoint)) { _groundDetourDirection = ((Vector3)(ref direction)).normalized; _groundDetourUntil = Mathf.Max(_groundDetourUntil, Time.time + 0.72f); flag = true; break; } } if (!flag) { return false; } } Vector3 val = ((Component)this).transform.position + _groundDetourDirection * num; val.y = floorPoint.y; ((Component)this).transform.position = val; _lastCrawlPosition = val; Quaternion val2 = Quaternion.LookRotation(_groundDetourDirection, Vector3.up); _crawlFacing = Quaternion.Slerp(_crawlFacing, val2, 1f - Mathf.Exp((0f - Time.deltaTime) * 7.2f)); return true; } private bool HasGroundRoute(Vector3 direction, float distance, out Vector3 floorPoint) { //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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_005c: 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) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) floorPoint = ((Component)this).transform.position; if (((Vector3)(ref direction)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref direction)).Normalize(); Vector3 val = ((Component)this).transform.position + Vector3.up * 0.16f; Vector3 val2 = ((Component)this).transform.position + Vector3.up * 0.88f; int num = Physics.CapsuleCastNonAlloc(val, val2, 0.13f, direction, _clamberProbeHits, distance, -5, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Collider collider = ((RaycastHit)(ref _clamberProbeHits[i])).collider; if (IsHardTraversalBlock(collider)) { return false; } } int num2 = Physics.RaycastNonAlloc(((Component)this).transform.position + direction * distance + Vector3.up * 0.72f, Vector3.down, _surfaceHits, 1.3f, -5, (QueryTriggerInteraction)1); float num3 = float.MaxValue; bool flag = false; for (int j = 0; j < num2; j++) { RaycastHit val3 = _surfaceHits[j]; if (IsClamberSurface(((RaycastHit)(ref val3)).collider) && !(((RaycastHit)(ref val3)).normal.y < 0.56f) && !(((RaycastHit)(ref val3)).distance >= num3)) { float num4 = ((RaycastHit)(ref val3)).point.y - ((Component)this).transform.position.y; if (!(num4 > 0.2f) && !(num4 < -0.36f)) { num3 = ((RaycastHit)(ref val3)).distance; floorPoint = ((RaycastHit)(ref val3)).point + Vector3.up * 0.012f; flag = true; } } } if (flag) { return HasBodyClearanceAt(floorPoint, null); } return false; } private void ClearGroundDetour() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) _groundDetourDirection = Vector3.zero; _groundDetourUntil = 0f; _groundDetourObstacle = null; } private bool TryBeginLowerSurfaceDescent(PlayerAvatar player) { //IL_001e: 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_0048: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0160: 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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0179: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: 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) //IL_01b8: 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_01c4: 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_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: 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_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: 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_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(player) || _surfaceCrawling || _clambering || ((Component)player).transform.position.y >= ((Component)this).transform.position.y - 0.38f) { return false; } int num = Physics.RaycastNonAlloc(((Component)this).transform.position + Vector3.up * 0.54f, Vector3.down, _clamberProbeHits, 1.12f, -5, (QueryTriggerInteraction)1); RaycastHit val = default(RaycastHit); float num2 = float.MaxValue; for (int i = 0; i < num; i++) { RaycastHit val2 = _clamberProbeHits[i]; if (IsClamberSurface(((RaycastHit)(ref val2)).collider) && !(((RaycastHit)(ref val2)).normal.y < 0.56f) && !(((RaycastHit)(ref val2)).distance >= num2)) { num2 = ((RaycastHit)(ref val2)).distance; val = val2; } } if (num2 == float.MaxValue) { return false; } Vector3 val3 = ((Component)player).transform.position - ((Component)this).transform.position; val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = Vector3.ProjectOnPlane(_crawlFacing * Vector3.forward, Vector3.up); } if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = ((Component)this).transform.forward; } ((Vector3)(ref val3)).Normalize(); Vector3 val4 = Vector3.Cross(Vector3.up, val3); Vector3 normalized = ((Vector3)(ref val4)).normalized; Vector3[] obj = new Vector3[6] { val3, default(Vector3), default(Vector3), default(Vector3), default(Vector3), default(Vector3) }; val4 = val3 + normalized * 0.65f; obj[1] = ((Vector3)(ref val4)).normalized; val4 = val3 - normalized * 0.65f; obj[2] = ((Vector3)(ref val4)).normalized; obj[3] = normalized; obj[4] = -normalized; obj[5] = -val3; Vector3[] array = (Vector3[])(object)obj; float[] obj2 = new float[6] { 0.46f, 0.68f, 0.92f, 1.18f, 1.46f, 1.72f }; Vector3 landing = Vector3.zero; float num3 = float.MaxValue; bool flag = false; float[] array2 = obj2; foreach (float num4 in array2) { Vector3[] array3 = array; foreach (Vector3 val5 in array3) { Vector3 requested = ((Component)this).transform.position + val5 * num4; if (!TryResolvePhysicalLanding(requested, 0.96f, 3.15f, 1.86f, 0.28f, 2.05f, ((RaycastHit)(ref val)).collider, out var landing2)) { continue; } float num5 = ((Component)this).transform.position.y - landing2.y; if (num5 < 0.24f) { continue; } float arcHeight = Mathf.Clamp(0.22f + num5 * 0.16f, 0.22f, 0.52f); if (HasClamberRouteClear(((Component)this).transform.position, landing2, arcHeight, ((RaycastHit)(ref val)).collider)) { Vector3 val6 = landing2 - ((Component)this).transform.position; val6.y = 0f; float num6 = ((Vector3)(ref val6)).magnitude + Vector3.Distance(landing2, ((Component)player).transform.position) * 0.2f; if (!(num6 >= num3)) { num3 = num6; landing = landing2; flag = true; } } } } if (!flag) { return false; } Collider surfaceObstacle = _surfaceObstacle; _surfaceObstacle = ((RaycastHit)(ref val)).collider; if (!BeginLocalRecoveryClamber(landing)) { _surfaceObstacle = surfaceObstacle; return false; } Plugin.Log.LogInfo((object)("The Delirium began a controlled descent from " + DescribeCollider(((RaycastHit)(ref val)).collider) + " toward its lower target.")); return true; } private void UpdateStableGroundAnchor() { //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_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_004e: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) if (_surfaceCrawling || _clambering || Time.time < _nextStableGroundProbeAt) { return; } _nextStableGroundProbeAt = Time.time + 0.12f; int num = Physics.RaycastNonAlloc(((Component)this).transform.position + Vector3.up * 0.58f, Vector3.down, _clamberProbeHits, 1.18f, -5, (QueryTriggerInteraction)1); RaycastHit val = default(RaycastHit); float num2 = float.MaxValue; for (int i = 0; i < num; i++) { RaycastHit val2 = _clamberProbeHits[i]; if (IsClamberSurface(((RaycastHit)(ref val2)).collider) && !(((RaycastHit)(ref val2)).normal.y < 0.62f) && !(((RaycastHit)(ref val2)).distance >= num2)) { num2 = ((RaycastHit)(ref val2)).distance; val = val2; } } if (num2 != float.MaxValue && HasBroadSurfacePatch(((RaycastHit)(ref val)).point, ((RaycastHit)(ref val)).normal, ((RaycastHit)(ref val)).collider, 0.18f)) { Vector3 val3 = ((RaycastHit)(ref val)).point + Vector3.up * 0.015f; if (HasBodyClearanceAt(val3, ((RaycastHit)(ref val)).collider)) { _lastStableGroundPosition = val3; _hasStableGroundPosition = true; } } } private bool HasBroadSurfacePatch(Vector3 point, Vector3 normal, Collider reference, float radius) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)reference == (Object)null || ((Vector3)(ref normal)).sqrMagnitude < 0.5f) { return false; } ((Vector3)(ref normal)).Normalize(); Vector3 val = Vector3.Cross(normal, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = Vector3.Cross(normal, Vector3.forward); } if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = Vector3.Cross(normal, Vector3.right); } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(normal, val); Vector3 normalized = ((Vector3)(ref val2)).normalized; if (!HasSurfaceSample(point, point, normal, reference)) { return false; } bool num = HasSurfaceSample(point + val * radius, point, normal, reference); bool flag = HasSurfaceSample(point - val * radius, point, normal, reference); if (!num || !flag) { return false; } bool flag2 = HasSurfaceSample(point + normalized * radius, point, normal, reference); bool flag3 = HasSurfaceSample(point - normalized * radius, point, normal, reference); if (!(Mathf.Abs(normal.y) < 0.58f)) { return flag2 && flag3; } return flag2 || flag3; } private bool HasSurfaceSample(Vector3 sample, Vector3 planePoint, Vector3 planeNormal, Collider reference) { //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) //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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) int num = Physics.RaycastNonAlloc(sample + planeNormal * 0.28f, -planeNormal, _clamberProbeHits, 0.58f, -5, (QueryTriggerInteraction)1); float num2 = float.MaxValue; RaycastHit val = default(RaycastHit); Vector3 normal; for (int i = 0; i < num; i++) { RaycastHit val2 = _clamberProbeHits[i]; if (IsClamberSurface(((RaycastHit)(ref val2)).collider) && !(((RaycastHit)(ref val2)).distance >= num2)) { normal = ((RaycastHit)(ref val2)).normal; if (!(Vector3.Dot(((Vector3)(ref normal)).normalized, planeNormal) < 0.72f)) { num2 = ((RaycastHit)(ref val2)).distance; val = val2; } } } if (num2 == float.MaxValue) { return false; } if (Mathf.Abs(Vector3.Dot(((RaycastHit)(ref val)).point - planePoint, planeNormal)) > 0.12f) { return false; } if (!IsSameClamberAssembly(((RaycastHit)(ref val)).collider, reference)) { normal = ((RaycastHit)(ref val)).normal; return Vector3.Dot(((Vector3)(ref normal)).normalized, planeNormal) >= 0.86f; } return true; } private bool HasSurfaceRootClearance(Vector3 surfacePoint, Vector3 normal, Collider platform) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapSphereNonAlloc(surfacePoint + ((Vector3)(ref normal)).normalized * 0.19f, 0.13f, _clamberOverlap, -5, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Collider val = _clamberOverlap[i]; if (IsHardTraversalBlock(val) && !IsSameClamberAssembly(val, platform)) { return false; } } return true; } private bool TryRetreatToStableGround() { //IL_000b: 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_0020: 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_0043: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!_hasStableGroundPosition) { return false; } Vector3 val = _lastStableGroundPosition - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude > 5.5224996f || Mathf.Abs(val.y) > 1.85f || !HasBodyClearanceAt(_lastStableGroundPosition, null) || !HasClamberRouteClear(((Component)this).transform.position, _lastStableGroundPosition, 0.22f, null)) { return false; } return BeginLocalRecoveryClamber(_lastStableGroundPosition); } private bool BeginSurfaceCrawl(RaycastHit wall, Vector3 incoming) { //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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_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_0074: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00ea: 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_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_0157: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) if (!IsClamberSurface(((RaycastHit)(ref wall)).collider)) { return false; } Vector3 val = ((RaycastHit)(ref wall)).normal; Vector3 normalized = ((Vector3)(ref val)).normalized; if (((Vector3)(ref normalized)).sqrMagnitude < 0.5f) { return false; } if (!HasBroadSurfacePatch(((RaycastHit)(ref wall)).point, normalized, ((RaycastHit)(ref wall)).collider, 0.22f)) { return false; } _surfaceCrawling = true; _surfaceStartedAt = Time.time; _surfaceLastProgressAt = Time.time; _surfaceStartPosition = ((Component)this).transform.position; _surfaceContact = ((RaycastHit)(ref wall)).point + normalized * 0.19f; _surfaceObstacle = ((RaycastHit)(ref wall)).collider; _surfaceFarSideAttempted = false; _surfaceRecoveryAttempts = 0; _surfaceNormal = normalized; Vector3 val2 = Vector3.ProjectOnPlane(incoming, normalized); Vector3 val3 = Vector3.ProjectOnPlane(Vector3.up, normalized); _surfaceDirection = ((((Vector3)(ref val2)).sqrMagnitude > 0.05f) ? ((Vector3)(ref val2)).normalized : val3); if (((Vector3)(ref val3)).sqrMagnitude > 0.05f && Mathf.Abs(normalized.y) < 0.6f) { val = _surfaceDirection * 0.42f + ((Vector3)(ref val3)).normalized * 0.9f; _surfaceDirection = ((Vector3)(ref val)).normalized; } if (((Vector3)(ref _surfaceDirection)).sqrMagnitude < 0.05f) { _surfaceDirection = Vector3.Cross(normalized, Vector3.right); } ((Vector3)(ref _surfaceDirection)).Normalize(); _surfaceDirectionLockUntil = Time.time + 0.72f; Vector3 val4 = Vector3.Cross(normalized, _surfaceDirection); Vector3 val5 = (((Object)(object)_target != (Object)null) ? (((Component)_target).transform.position - ((Component)this).transform.position) : incoming); _surfaceDetourSign = ((Vector3.Dot(val4, val5) >= 0f) ? 1 : (-1)); _surfaceStartFacing = _crawlFacing; _berserkStuckTime = 0f; _berserkAttackCooldown = Mathf.Max(_berserkAttackCooldown, 0.62f); Array.Clear(_crawlContactValid, 0, _crawlContactValid.Length); if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled) { if (_agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } ((Behaviour)_agent).enabled = false; } return true; } private void TickSurfaceCrawl(PlayerAvatar player) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_008d: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_033d: 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_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034f: 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_035a: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0393: 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_0250: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_028e: 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_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_0583: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(player)) { EndSurfaceCrawl(((Component)this).transform.position, reactivateAgent: false); return; } float num = Time.time - _surfaceStartedAt; if (IsDoorCollider(_surfaceObstacle)) { EndSurfaceCrawl(_surfaceStartPosition, reactivateAgent: true); return; } Quaternion val = Quaternion.LookRotation(_surfaceDirection, _surfaceNormal); if (num < 0.42f) { float num2 = Quintic01(num / 0.42f); ((Component)this).transform.position = Vector3.Lerp(_surfaceStartPosition, _surfaceContact, num2); _crawlFacing = Quaternion.Slerp(_surfaceStartFacing, val, num2); _lastCrawlPosition = ((Component)this).transform.position; return; } if (!_surfaceFarSideAttempted && num >= 0.38f) { _surfaceFarSideAttempted = true; if (TryBeginFarSideClamber(player)) { return; } } Vector3 val2 = ((Component)player).transform.position - ((Component)this).transform.position; Vector3 val3 = Vector3.ProjectOnPlane(val2, _surfaceNormal); Vector3 val4; if (Mathf.Abs(_surfaceNormal.y) < 0.6f && num < 1.8f) { val4 = Vector3.ProjectOnPlane(Vector3.up, _surfaceNormal); Vector3 normalized = ((Vector3)(ref val4)).normalized; val3 = ((((Vector3)(ref val3)).sqrMagnitude > 0.01f) ? (((Vector3)(ref val3)).normalized * 0.45f + normalized * 0.9f) : normalized); } if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = _surfaceDirection; } ((Vector3)(ref val3)).Normalize(); if (Time.time >= _surfaceDirectionLockUntil) { val4 = Vector3.Slerp(_surfaceDirection, val3, 1f - Mathf.Exp((0f - Time.deltaTime) * 4.8f)); _surfaceDirection = ((Vector3)(ref val4)).normalized; } float num3 = 2.173f * Time.deltaTime; int count = Physics.SphereCastNonAlloc(((Component)this).transform.position + _surfaceNormal * 0.12f, 0.13f, _surfaceDirection, _surfaceHits, num3 + 0.16f, -5, (QueryTriggerInteraction)1); if (TryGetNearestSurfaceHit(_surfaceHits, count, out var nearest) && Vector3.Dot(((RaycastHit)(ref nearest)).normal, _surfaceNormal) < 0.82f && HasBroadSurfacePatch(((RaycastHit)(ref nearest)).point, ((RaycastHit)(ref nearest)).normal, ((RaycastHit)(ref nearest)).collider, 0.22f) && HasSurfaceRootClearance(((RaycastHit)(ref nearest)).point, ((RaycastHit)(ref nearest)).normal, ((RaycastHit)(ref nearest)).collider)) { val4 = ((RaycastHit)(ref nearest)).normal; _surfaceNormal = ((Vector3)(ref val4)).normalized; val4 = Vector3.ProjectOnPlane(_surfaceDirection, _surfaceNormal); _surfaceDirection = ((Vector3)(ref val4)).normalized; if (((Vector3)(ref _surfaceDirection)).sqrMagnitude < 0.01f) { val4 = Vector3.ProjectOnPlane(Vector3.up, _surfaceNormal); _surfaceDirection = ((Vector3)(ref val4)).normalized; } ((Component)this).transform.position = ((RaycastHit)(ref nearest)).point + _surfaceNormal * 0.19f; } else { Vector3 val5 = ((Component)this).transform.position + _surfaceDirection * num3; int count2 = Physics.RaycastNonAlloc(val5 + _surfaceNormal * 0.34f, -_surfaceNormal, _surfaceHits, 0.82f, -5, (QueryTriggerInteraction)1); if (TryGetNearestSurfaceHit(_surfaceHits, count2, out var nearest2) && HasBroadSurfacePatch(((RaycastHit)(ref nearest2)).point, ((RaycastHit)(ref nearest2)).normal, ((RaycastHit)(ref nearest2)).collider, 0.22f) && HasSurfaceRootClearance(((RaycastHit)(ref nearest2)).point, ((RaycastHit)(ref nearest2)).normal, ((RaycastHit)(ref nearest2)).collider)) { val4 = ((RaycastHit)(ref nearest2)).normal; Vector3 normalized2 = ((Vector3)(ref val4)).normalized; val4 = Vector3.Slerp(_surfaceNormal, normalized2, 1f - Mathf.Exp((0f - Time.deltaTime) * 10f)); _surfaceNormal = ((Vector3)(ref val4)).normalized; ((Component)this).transform.position = ((RaycastHit)(ref nearest2)).point + _surfaceNormal * 0.19f; } else { if (TryExitSurfaceAtLedge(val5)) { return; } if (TryRetreatToStableGround()) { Plugin.Log.LogInfo((object)"The Delirium rejected a narrow or discontinuous crawl surface and returned toward its last supported floor."); return; } ChooseLockedSurfaceDetour(val2, alternate: false); } } Vector3 val6 = ((Component)this).transform.position - _lastCrawlPosition; _crawlTravelPhase += ((Vector3)(ref val6)).magnitude * 7.8f; if (((Vector3)(ref val6)).sqrMagnitude > 1.6000002E-05f) { _surfaceLastProgressAt = Time.time; _surfaceRecoveryAttempts = 0; } _lastCrawlPosition = ((Component)this).transform.position; _crawlFacing = Quaternion.Slerp(_crawlFacing, Quaternion.LookRotation(_surfaceDirection, _surfaceNormal), 1f - Mathf.Exp((0f - Time.deltaTime) * 7.5f)); if (Time.time - _surfaceLastProgressAt > 0.82f) { _surfaceRecoveryAttempts++; if ((!(((Component)this).transform.position.y - _surfaceStartPosition.y > 0.2f) || !TryExitSurfaceAtLedge(((Component)this).transform.position + _surfaceDirection * 0.14f)) && !TryBeginFarSideClamber(player)) { _surfaceLastProgressAt = Time.time; ChooseLockedSurfaceDetour(val2, alternate: true); } } } private void ChooseLockedSurfaceDetour(Vector3 toPlayer, bool alternate) { //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) if (!alternate && Time.time < _surfaceDirectionLockUntil) { return; } if (alternate) { _surfaceDetourSign = -_surfaceDetourSign; } Vector3 val = Vector3.Cross(_surfaceNormal, _surfaceDirection); Vector3 normalized = ((Vector3)(ref val)).normalized; if (((Vector3)(ref normalized)).sqrMagnitude < 0.01f) { val = Vector3.Cross(_surfaceNormal, Vector3.up); normalized = ((Vector3)(ref val)).normalized; } if (((Vector3)(ref normalized)).sqrMagnitude < 0.01f) { val = Vector3.Cross(_surfaceNormal, Vector3.right); normalized = ((Vector3)(ref val)).normalized; } val = Vector3.ProjectOnPlane(Vector3.up, _surfaceNormal); Vector3 normalized2 = ((Vector3)(ref val)).normalized; Vector3 val2 = normalized * (float)_surfaceDetourSign; if (((Vector3)(ref normalized2)).sqrMagnitude > 0.01f && Mathf.Abs(_surfaceNormal.y) < 0.6f) { val = val2 * 0.72f + normalized2 * 0.58f; val2 = ((Vector3)(ref val)).normalized; } if (!alternate && Vector3.Dot(val2, toPlayer) < -0.12f) { _surfaceDetourSign = -_surfaceDetourSign; val2 = normalized * (float)_surfaceDetourSign; if (((Vector3)(ref normalized2)).sqrMagnitude > 0.01f && Mathf.Abs(_surfaceNormal.y) < 0.6f) { val = val2 * 0.72f + normalized2 * 0.58f; val2 = ((Vector3)(ref val)).normalized; } } if (((Vector3)(ref val2)).sqrMagnitude > 0.01f) { _surfaceDirection = ((Vector3)(ref val2)).normalized; } _surfaceDirectionLockUntil = Time.time + (alternate ? 0.92f : 0.72f); } private bool TryExitSurfaceAtLedge(Vector3 candidate) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0078: 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_0082: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00e1: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_015f: Unknown result type (might be due to invalid IL or missing references) float num = ((Component)this).transform.position.y - _surfaceStartPosition.y; if (!(_surfaceNormal.y > 0.35f) && !(num > 0.42f)) { return false; } float[] array = new float[6] { 0.34f, 0.52f, 0.72f, 0.94f, 1.2f, 1.55f }; foreach (float num2 in array) { Vector3 requested = candidate - _surfaceNormal * 0.38f + _surfaceDirection * num2; if (!TryResolvePhysicalLanding(requested, 0.82f, 2.05f, 1.78f, 1.3f, 1.28f, null, out var landing)) { continue; } Vector3 val = landing - ((Component)this).transform.position; Vector3 val2 = Vector3.ProjectOnPlane(val, Vector3.up); bool flag = _surfaceNormal.y > 0.52f && Vector3.Dot(val2, _surfaceDirection) > 0.1f && ((Vector3)(ref val2)).sqrMagnitude < 1.8225001f && val.y > -1.28f; if (!(num > 0.2f) || !(landing.y < _surfaceStartPosition.y + 0.15f) || flag) { Vector3 val3 = landing - ((Component)this).transform.position; if (!(((Vector3)(ref val3)).sqrMagnitude >= 3.2399998f) && BeginLocalRecoveryClamber(landing)) { return true; } } } return false; } private bool TryResolvePhysicalLanding(Vector3 requested, float rayHeight, float rayDistance, float maxPlanarDistance, float maxRise, float maxDrop, Collider platform, out Vector3 landing) { //IL_0002: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0034: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_008a: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) landing = Vector3.zero; int num = Physics.RaycastNonAlloc(requested + Vector3.up * rayHeight, Vector3.down, _clamberProbeHits, rayDistance, -5, (QueryTriggerInteraction)1); RaycastHit val = default(RaycastHit); float num2 = float.MaxValue; for (int i = 0; i < num; i++) { RaycastHit val2 = _clamberProbeHits[i]; if (IsClamberSurface(((RaycastHit)(ref val2)).collider) && !(((RaycastHit)(ref val2)).normal.y < 0.58f) && !(((RaycastHit)(ref val2)).distance >= num2)) { num2 = ((RaycastHit)(ref val2)).distance; val = val2; } } if (num2 == float.MaxValue) { return false; } if (!HasBroadSurfacePatch(((RaycastHit)(ref val)).point, ((RaycastHit)(ref val)).normal, ((RaycastHit)(ref val)).collider, 0.18f)) { return false; } Vector3 val3 = ((RaycastHit)(ref val)).point + Vector3.up * 0.015f; Vector3 val4 = val3 - ((Component)this).transform.position; Vector3 val5 = Vector3.ProjectOnPlane(val4, Vector3.up); if (((Vector3)(ref val5)).sqrMagnitude > maxPlanarDistance * maxPlanarDistance || val4.y > maxRise || val4.y < 0f - maxDrop) { return false; } if (!HasClamberClearance(val3, platform ?? ((RaycastHit)(ref val)).collider)) { return false; } landing = val3; return true; } private bool EndSurfaceCrawl(Vector3 position, bool reactivateAgent) { //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_006d: 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) if (reactivateAgent && !_berserk && !TryActivateKnownNavPoint(position)) { _surfaceLastProgressAt = Time.time; return false; } _surfaceCrawling = false; _surfaceObstacle = null; _surfaceNormal = Vector3.up; _surfaceRecoveryAttempts = 0; _surfaceDirectionLockUntil = 0f; _surfaceDetourSign = 1; Array.Clear(_crawlContactValid, 0, _crawlContactValid.Length); ((Component)this).transform.position = position; _berserkStuckTime = 0f; return true; } private bool TryGetNearestSurfaceHit(RaycastHit[] hits, int count, out RaycastHit nearest) { //IL_0001: 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_001a: 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_003e: Unknown result type (might be due to invalid IL or missing references) nearest = default(RaycastHit); float num = float.MaxValue; bool result = false; for (int i = 0; i < count; i++) { RaycastHit val = hits[i]; if (IsClamberSurface(((RaycastHit)(ref val)).collider) && !(((RaycastHit)(ref val)).distance >= num)) { num = ((RaycastHit)(ref val)).distance; nearest = val; result = true; } } return result; } private bool TryGetNearestTraversalBlock(RaycastHit[] hits, int count, out RaycastHit nearest) { //IL_0001: 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_001a: 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_003e: Unknown result type (might be due to invalid IL or missing references) nearest = default(RaycastHit); float num = float.MaxValue; bool result = false; for (int i = 0; i < count; i++) { RaycastHit val = hits[i]; if (IsHardTraversalBlock(((RaycastHit)(ref val)).collider) && !(((RaycastHit)(ref val)).distance >= num)) { num = ((RaycastHit)(ref val)).distance; nearest = val; result = true; } } return result; } private bool PreventSolidTraversal(Vector3 previous) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0024: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0074: 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) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.position - previous; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.015f) { return false; } int count = Physics.SphereCastNonAlloc(previous + Vector3.up * 0.34f, 0.13f, val / magnitude, _surfaceHits, magnitude + 0.06f, -5, (QueryTriggerInteraction)1); if (!TryGetNearestTraversalBlock(_surfaceHits, count, out var _)) { return false; } ((Component)this).transform.position = previous; if (!_berserk && (Object)(object)_agent != (Object)null && (!((Behaviour)_agent).enabled || !_agent.isOnNavMesh)) { ActivateNavigation(previous); } if (!_berserk && (Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.Warp(previous); _agent.ResetPath(); _agent.isStopped = false; } return true; } private bool IsHardTraversalBlock(Collider collider) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)collider == (Object)null || collider.isTrigger || IsOwnCollider(collider) || IsLevelGeneratorExtraHelper(collider)) { return false; } if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null || (Object)(object)((Component)collider).GetComponentInParent() != (Object)null) { return false; } Rigidbody val = collider.attachedRigidbody ?? ((Component)collider).GetComponentInParent(); if ((Object)(object)val != (Object)null && !val.isKinematic) { Bounds bounds = collider.bounds; float num = Mathf.Max(((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.z); if (((Bounds)(ref bounds)).size.y <= 0.38f && num <= 0.62f) { return false; } } return true; } private bool TryBeginBerserkClamber(PlayerAvatar player) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: 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_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: 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_0277: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(player) || _clambering) { return false; } Vector3 val = GetBerserkPursuitPoint(player) - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = ((Component)this).transform.position + Vector3.up * 0.2f; Vector3 val3 = ((Component)this).transform.position + Vector3.up * 1.06f; int num = Physics.CapsuleCastNonAlloc(val2, val3, 0.13f, val, _clamberProbeHits, 1.24f, -5, (QueryTriggerInteraction)1); RaycastHit val4 = default(RaycastHit); bool flag = false; float num2 = float.MaxValue; for (int i = 0; i < num; i++) { RaycastHit val5 = _clamberProbeHits[i]; if (IsClamberSurface(((RaycastHit)(ref val5)).collider) && !(((RaycastHit)(ref val5)).distance >= num2)) { num2 = ((RaycastHit)(ref val5)).distance; val4 = val5; flag = true; } } if (!flag) { return false; } if (IsUnsafeFarSideObstacle(((RaycastHit)(ref val4)).collider)) { if (TryBeginGroundDetour(val, ((RaycastHit)(ref val4)).collider)) { return TryGroundDetourStep(); } return false; } int num3 = Physics.RaycastNonAlloc(((RaycastHit)(ref val4)).point + val * 0.3f + Vector3.up * 1.38f, Vector3.down, _clamberProbeHits, 1.72f, -5, (QueryTriggerInteraction)1); RaycastHit top = default(RaycastHit); bool flag2 = false; float num4 = float.MaxValue; for (int j = 0; j < num3; j++) { RaycastHit val6 = _clamberProbeHits[j]; if (IsClamberSurface(((RaycastHit)(ref val6)).collider) && !(((RaycastHit)(ref val6)).normal.y < 0.58f)) { float num5 = ((RaycastHit)(ref val6)).point.y - ((Component)this).transform.position.y; if (!(num5 < 0.12f) && !(num5 > 1.16f) && !(((RaycastHit)(ref val6)).distance >= num4)) { num4 = ((RaycastHit)(ref val6)).distance; top = val6; flag2 = true; } } } if (!flag2) { return BeginSurfaceCrawl(val4, val); } if (!TryFindClamberLanding(val4, top, val, out var landing)) { return BeginSurfaceCrawl(val4, val); } Collider val7 = (((Object)(object)((RaycastHit)(ref top)).collider != (Object)null) ? ((RaycastHit)(ref top)).collider : ((RaycastHit)(ref val4)).collider); Vector3 position = ((Component)this).transform.position; float num6 = Mathf.Max(0f, landing.y - position.y); float num7 = Mathf.Clamp(0.16f + num6 * 0.22f, 0.16f, 0.42f); if (!HasClamberRouteClear(position, landing, num7, val7)) { if (TryBeginGroundDetour(val, ((RaycastHit)(ref val4)).collider)) { return TryGroundDetourStep(); } return false; } ClearGroundDetour(); _clambering = true; _clamberStartedAt = Time.time; _clamberPoseProgress = 0f; _clamberStart = ((Component)this).transform.position; _clamberEnd = landing; _clamberObstacle = val7; _activeClamberDuration = Mathf.Max(0.82f, Vector3.Distance(_clamberStart, _clamberEnd) / 2.15f); _clamberForward = val; _clamberRise = num6; _clamberArcHeight = num7; Array.Clear(_crawlContactValid, 0, _crawlContactValid.Length); if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled) { if (_agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } ((Behaviour)_agent).enabled = false; } return true; } private bool TryFindClamberLanding(RaycastHit front, RaycastHit top, Vector3 forward, out Vector3 landing) { //IL_0002: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00c8: 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_00d2: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) landing = Vector3.zero; float num = float.MaxValue; bool result = false; float[] array = new float[6] { 0.18f, 0.26f, 0.34f, 0.5f, 0.68f, 0.88f }; foreach (float num2 in array) { Vector3 val = ((RaycastHit)(ref top)).point + forward * num2; if (!TryResolvePhysicalLanding(val, 0.72f, 1.18f, 1.3f, 1.2f, 0.18f, ((RaycastHit)(ref top)).collider, out var landing2)) { continue; } float num3 = landing2.y - ((Component)this).transform.position.y; if (num3 < 0.1f || num3 > 1.2f || landing2.y < ((RaycastHit)(ref top)).point.y - 0.14f) { continue; } Vector3 val2 = landing2 - ((RaycastHit)(ref front)).point; val2.y = 0f; if (!(Vector3.Dot(val2, forward) < 0.12f)) { Vector3 val3 = landing2 - val; float num4 = ((Vector3)(ref val3)).sqrMagnitude + Mathf.Abs(num2 - 0.58f) * 0.08f; if (!(num4 >= num)) { num = num4; landing = landing2; result = true; } } } return result; } private bool TryBeginFarSideClamber(PlayerAvatar player) { //IL_0006: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00ea: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: 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) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033c: 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_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.04f) { return false; } ((Vector3)(ref val)).Normalize(); if ((Object)(object)_surfaceObstacle != (Object)null) { if (IsUnsafeFarSideObstacle(_surfaceObstacle)) { return false; } Bounds bounds = _surfaceObstacle.bounds; if (((Bounds)(ref bounds)).max.y - _surfaceStartPosition.y > 1.42f) { return false; } } Vector3 val2 = Vector3.Cross(Vector3.up, val); Vector3 normalized = ((Vector3)(ref val2)).normalized; float num = 0f; if ((Object)(object)_surfaceObstacle != (Object)null) { Bounds bounds2 = _surfaceObstacle.bounds; Vector3 extents = ((Bounds)(ref bounds2)).extents; float num2 = Mathf.Abs(val.x) * extents.x + Mathf.Abs(val.y) * extents.y + Mathf.Abs(val.z) * extents.z; num = Mathf.Max(0f, Vector3.Dot(((Bounds)(ref bounds2)).center - ((Component)this).transform.position, val) + num2 + 0.34f); if (num > 1.46f) { return false; } } bool flag = false; Vector3 val3 = Vector3.zero; float num3 = float.MaxValue; float[] farSideOffsets = FarSideOffsets; foreach (float num4 in farSideOffsets) { float[] farSideAdvances = FarSideAdvances; for (int j = 0; j < farSideAdvances.Length; j++) { float num5 = Mathf.Max(farSideAdvances[j], num); Vector3 requested = ((Component)this).transform.position + val * num5 + normalized * num4; if (!TryResolvePhysicalLanding(requested, 2.05f, 4.75f, 1.72f, 1.55f, 1.35f, null, out var landing)) { continue; } Vector3 val4 = landing - ((Component)this).transform.position; float num6 = Vector3.Dot(Vector3.ProjectOnPlane(val4, Vector3.up), val); if (!(num6 < 0.58f)) { float num7 = Mathf.Abs(num6 - Mathf.Max(num, 1.55f)) + Mathf.Abs(num4) * 0.42f + Mathf.Abs(val4.y) * 0.08f; if (!(num7 >= num3)) { num3 = num7; val3 = landing; flag = true; } } } } if (!flag) { return false; } Vector3 val5 = val3 - ((Component)this).transform.position; if (((Vector3)(ref val5)).magnitude > 1.72f) { return false; } Collider surfaceObstacle = _surfaceObstacle; float clamberRise = Mathf.Max(0f, val5.y); float num8; if (!((Object)(object)surfaceObstacle != (Object)null)) { num8 = 0.34f; } else { Bounds bounds3 = surfaceObstacle.bounds; num8 = ((Bounds)(ref bounds3)).max.y - ((Component)this).transform.position.y + 0.18f; } float num9 = Mathf.Max(Mathf.Clamp(num8, 0.34f, 1.2f), Mathf.Clamp(0.34f + Mathf.Max(0f, 0f - val5.y) * 0.24f, 0.34f, 0.82f)); if (!HasClamberRouteClear(((Component)this).transform.position, val3, num9, surfaceObstacle)) { return false; } ClearGroundDetour(); _surfaceCrawling = false; _surfaceObstacle = null; _clambering = true; _clamberStartedAt = Time.time; _clamberPoseProgress = 0f; _clamberStart = ((Component)this).transform.position; _clamberEnd = val3; _clamberObstacle = surfaceObstacle; _activeClamberDuration = Mathf.Max(0.82f, ((Vector3)(ref val5)).magnitude / 2.15f); _clamberForward = val; _clamberRise = clamberRise; _clamberArcHeight = num9; Array.Clear(_crawlContactValid, 0, _crawlContactValid.Length); if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled) { ((Behaviour)_agent).enabled = false; } Plugin.Log.LogInfo((object)($"The Delirium began a furniture clamber of {((Vector3)(ref val5)).magnitude:F2}m " + $"over a {_clamberArcHeight:F2}m arc in {_activeClamberDuration:F2}s.")); return true; } private bool HasOverheadClamberSurface() { //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_005c: 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) if (_surfaceNormal.y < -0.28f) { return true; } int num = Physics.RaycastNonAlloc(((Component)this).transform.position + Vector3.up * 0.08f, Vector3.up, _surfaceHits, 1.08f, -5, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { RaycastHit val = _surfaceHits[i]; if (IsClamberSurface(((RaycastHit)(ref val)).collider) && ((RaycastHit)(ref val)).normal.y < -0.3f) { return true; } } return false; } private void TickBerserkClamber(PlayerAvatar player) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_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_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: 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_02db: 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_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033a: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: 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_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) float num = (_clamberPoseProgress = Mathf.Clamp01((Time.time - _clamberStartedAt) / Mathf.Max(0.01f, _activeClamberDuration))); float num2 = Quintic01(num); Vector3 val = Vector3.Lerp(_clamberStart, _clamberEnd, num2); val.y += Mathf.Sin(num * MathF.PI) * _clamberArcHeight; Vector3 position = ((Component)this).transform.position; Vector3 val2 = val - position; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude > 0.001f) { int num3 = Physics.CapsuleCastNonAlloc(position + Vector3.up * 0.16f, position + Vector3.up * 0.88f, 0.13f, val2 / magnitude, _surfaceHits, magnitude + 0.025f, -5, (QueryTriggerInteraction)1); RaycastHit wall = default(RaycastHit); float num4 = float.MaxValue; for (int i = 0; i < num3; i++) { RaycastHit val3 = _surfaceHits[i]; if (!IsSameClamberAssembly(((RaycastHit)(ref val3)).collider, _clamberObstacle) && IsHardTraversalBlock(((RaycastHit)(ref val3)).collider) && !(((RaycastHit)(ref val3)).distance >= num4)) { num4 = ((RaycastHit)(ref val3)).distance; wall = val3; } } if (num4 < float.MaxValue) { Collider clamberObstacle = _clamberObstacle; _clambering = false; _clamberObstacle = null; _clamberPoseProgress = 0f; _clamberRise = 0f; _clamberArcHeight = 0.055f; _activeClamberDuration = 0.82f; ((Component)this).transform.position = position; _lastCrawlPosition = position; _berserkStuckTime = 0f; _berserkAttackCooldown = Mathf.Max(_berserkAttackCooldown, 0.62f); Vector3 incoming = val2 / magnitude; bool flag = IsClamberSurface(((RaycastHit)(ref wall)).collider) && BeginSurfaceCrawl(wall, incoming); if (!flag) { if (!_berserk) { ActivateNavigation(position); } if (!_berserk && (Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.ResetPath(); _agent.isStopped = false; ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, ((Component)player).transform.position, 0.35f); } } Plugin.Log.LogInfo((object)("The Delirium safely aborted a clamber at " + DescribeCollider(((RaycastHit)(ref wall)).collider) + " after crossing " + DescribeCollider(clamberObstacle) + "; " + (flag ? "continued on the surface." : "restored pursuit at the same position."))); return; } } ((Component)this).transform.position = val; Vector3 val4 = val - _lastCrawlPosition; _crawlTravelPhase += ((Vector3)(ref val4)).magnitude * 7.8f; _lastCrawlPosition = val; Quaternion val5 = Quaternion.LookRotation(_clamberForward, Vector3.up); _crawlFacing = Quaternion.Slerp(_crawlFacing, val5, 1f - Mathf.Exp((0f - Time.deltaTime) * 8.5f)); if (!(num < 1f)) { _clambering = false; _clamberObstacle = null; _clamberPoseProgress = 0f; _clamberRise = 0f; _clamberArcHeight = 0.055f; _activeClamberDuration = 0.82f; Array.Clear(_crawlContactValid, 0, _crawlContactValid.Length); if (_berserk || !TryActivateKnownNavPoint(_clamberEnd)) { ((Component)this).transform.position = _clamberEnd; _lastCrawlPosition = _clamberEnd; Plugin.Log.LogInfo((object)"The Delirium completed its clamber in direct-movement mode without relocation."); } if (!_berserk && (Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.isStopped = false; ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, ((Component)player).transform.position, 0.35f); } _berserkStuckTime = 0f; _berserkAttackCooldown = Mathf.Max(_berserkAttackCooldown, 0.48f); } } private bool HasClamberClearance(Vector3 landing, Collider platform) { //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) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0016: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = landing + Vector3.up * 0.18f; Vector3 val2 = landing + Vector3.up * 0.78f; int num = Physics.OverlapCapsuleNonAlloc(val, val2, 0.13f, _clamberOverlap, -5, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Collider val3 = _clamberOverlap[i]; if (IsClamberSurface(val3) && !((Object)(object)val3 == (Object)(object)platform) && val3.ClosestPoint(val2).y > landing.y + 0.12f) { return false; } } return true; } private bool HasBodyClearanceAt(Vector3 position, Collider platform) { //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) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0016: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) Vector3 val = position + Vector3.up * 0.16f; Vector3 val2 = position + Vector3.up * 0.88f; int num = Physics.OverlapCapsuleNonAlloc(val, val2, 0.13f, _clamberOverlap, -5, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Collider val3 = _clamberOverlap[i]; if (IsHardTraversalBlock(val3) && !IsSameClamberAssembly(val3, platform)) { Bounds bounds = val3.bounds; if (!(((Bounds)(ref bounds)).max.y <= position.y + 0.1f)) { return false; } } } return true; } private bool HasClamberRouteClear(Vector3 start, Vector3 end, float arcHeight, Collider platform) { //IL_0017: 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_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_0039: 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_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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) for (int i = 1; i <= 14; i++) { float num = (float)i / 14f; float num2 = Quintic01(num); Vector3 val = Vector3.Lerp(start, end, num2); val.y += Mathf.Sin(num * MathF.PI) * arcHeight; Vector3 val2 = val + Vector3.up * 0.16f; Vector3 val3 = val + Vector3.up * 0.88f; int num3 = Physics.OverlapCapsuleNonAlloc(val2, val3, 0.13f, _clamberOverlap, -5, (QueryTriggerInteraction)1); for (int j = 0; j < num3; j++) { Collider val4 = _clamberOverlap[j]; if (IsHardTraversalBlock(val4) && !IsSameClamberAssembly(val4, platform)) { Bounds bounds = val4.bounds; if (!(((Bounds)(ref bounds)).max.y <= val.y + 0.1f)) { return false; } } } } return true; } private static bool IsUnsafeFarSideObstacle(Collider collider) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00e6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)collider == (Object)null) { return false; } Transform val = ((Component)collider).transform; int num = 0; while ((Object)(object)val != (Object)null && num < 8) { string text = (((Object)val).name ?? string.Empty).ToLowerInvariant(); if (text.Contains("tent") || text.Contains("canopy") || text.Contains("awning") || text.Contains("tarp") || text.Contains("marquee") || text.Contains("pavilion")) { return true; } num++; val = val.parent; } Bounds bounds = collider.bounds; float num2 = Mathf.Max(((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.z); float num3 = Mathf.Min(((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.z); if (((Bounds)(ref bounds)).size.y > 1.3f && num2 > 1.3f) { return num3 > 0.42f; } return false; } private bool IsClamberSurface(Collider collider) { if ((Object)(object)collider == (Object)null || collider.isTrigger || IsOwnCollider(collider) || IsLevelGeneratorExtraHelper(collider) || IsDoorCollider(collider)) { return false; } if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null || (Object)(object)((Component)collider).GetComponentInParent() != (Object)null) { return false; } Rigidbody attachedRigidbody = collider.attachedRigidbody; if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null && (Object)(object)attachedRigidbody != (Object)null && !attachedRigidbody.isKinematic) { return false; } if (!((Object)(object)attachedRigidbody == (Object)null)) { return attachedRigidbody.isKinematic; } return true; } private static bool IsSameClamberAssembly(Collider candidate, Collider reference) { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)candidate == (Object)null || (Object)(object)reference == (Object)null) { return false; } if ((Object)(object)candidate == (Object)(object)reference) { return true; } Rigidbody attachedRigidbody = candidate.attachedRigidbody; Rigidbody attachedRigidbody2 = reference.attachedRigidbody; if ((Object)(object)attachedRigidbody != (Object)null && (Object)(object)attachedRigidbody == (Object)(object)attachedRigidbody2) { return true; } PhysGrabObject componentInParent = ((Component)candidate).GetComponentInParent(); PhysGrabObject componentInParent2 = ((Component)reference).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent == (Object)(object)componentInParent2) { return true; } Transform transform = ((Component)candidate).transform; Transform transform2 = ((Component)reference).transform; if ((Object)(object)transform == (Object)(object)transform2 || transform.IsChildOf(transform2) || transform2.IsChildOf(transform)) { return true; } if ((Object)(object)transform.parent != (Object)null && (Object)(object)transform.parent == (Object)(object)transform2.parent) { if (IsAuthoredFurnitureRoot(transform.parent)) { return true; } Bounds bounds = reference.bounds; ((Bounds)(ref bounds)).Expand(0.16f); if (((Bounds)(ref bounds)).Intersects(candidate.bounds)) { return true; } } return false; } private static bool IsAuthoredFurnitureRoot(Transform root) { if ((Object)(object)root == (Object)null) { return false; } string text = (((Object)root).name ?? string.Empty).ToLowerInvariant(); if (text.Contains("room") || text.Contains("module") || text.Contains("level") || text.Contains("generator") || text.Contains("environment") || text.Contains("geometry")) { return false; } if (!text.Contains("chair") && !text.Contains("table") && !text.Contains("desk") && !text.Contains("stool") && !text.Contains("bench") && !text.Contains("shelf") && !text.Contains("cabinet") && !text.Contains("counter") && !text.Contains("plant") && !text.Contains("sofa") && !text.Contains("couch")) { return text.Contains("furniture"); } return true; } private bool TryRecoverSurfaceToLocalFloor(PlayerAvatar player) { //IL_0017: 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_000a: 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_0048: 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_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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)player != (Object)null) ? (((Component)player).transform.position - ((Component)this).transform.position) : _surfaceDirection); val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = Vector3.ProjectOnPlane(_surfaceDirection, Vector3.up); } if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = ((Component)this).transform.forward; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(Vector3.up, val); Vector3 normalized = ((Vector3)(ref val2)).normalized; Vector3[] obj = new Vector3[6] { val, normalized, -normalized, -val, default(Vector3), default(Vector3) }; val2 = val + normalized; obj[4] = ((Vector3)(ref val2)).normalized; val2 = val - normalized; obj[5] = ((Vector3)(ref val2)).normalized; Vector3[] array = (Vector3[])(object)obj; float[] array2 = new float[4] { 0.34f, 0.58f, 0.86f, 1.08f }; NavMeshHit val4 = default(NavMeshHit); foreach (float num in array2) { Vector3[] array3 = array; foreach (Vector3 val3 in array3) { if (!NavMesh.SamplePosition(_surfaceStartPosition + val3 * num + Vector3.up * 0.08f, ref val4, 0.3f, -1)) { continue; } Vector3 val5 = ((NavMeshHit)(ref val4)).position - ((Component)this).transform.position; if (((Vector3)(ref val5)).sqrMagnitude > 1.6899998f || Mathf.Abs(val5.y) > 1.18f) { continue; } Vector3 val6 = ((NavMeshHit)(ref val4)).position - ((Component)this).transform.position; val6.y = 0f; float magnitude = ((Vector3)(ref val6)).magnitude; if (magnitude > 0.05f) { int num2 = Physics.SphereCastNonAlloc(((Component)this).transform.position + Vector3.up * 0.34f, 0.12f, val6 / magnitude, _surfaceHits, magnitude, -5, (QueryTriggerInteraction)1); bool flag = false; for (int k = 0; k < num2; k++) { Collider collider = ((RaycastHit)(ref _surfaceHits[k])).collider; if (IsHardTraversalBlock(collider) && !IsSameClamberAssembly(collider, _surfaceObstacle)) { flag = true; break; } } if (flag) { continue; } } if (BeginLocalRecoveryClamber(((NavMeshHit)(ref val4)).position)) { Plugin.Log.LogInfo((object)$"The Delirium began a local animated recovery from a stalled surface toward {((NavMeshHit)(ref val4)).position}."); return true; } } } return false; } private bool BeginLocalRecoveryClamber(Vector3 landing) { //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_0023: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00e9: 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_00f8: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) Vector3 val = landing - ((Component)this).transform.position; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.025f) { return EndSurfaceCrawl(landing, reactivateAgent: true); } if (magnitude > 1.85f) { return false; } Vector3 val2 = Vector3.ProjectOnPlane(val, Vector3.up); Vector3 normalized; if (!(((Vector3)(ref val2)).sqrMagnitude > 0.0025f)) { Vector3 val3 = Vector3.ProjectOnPlane(_surfaceDirection, Vector3.up); normalized = ((Vector3)(ref val3)).normalized; } else { normalized = ((Vector3)(ref val2)).normalized; } Vector3 clamberForward = normalized; if (((Vector3)(ref clamberForward)).sqrMagnitude < 0.0025f) { clamberForward = _crawlFacing * Vector3.forward; } Collider surfaceObstacle = _surfaceObstacle; _surfaceCrawling = false; _surfaceObstacle = null; _surfaceNormal = Vector3.up; _surfaceRecoveryAttempts = 0; _clambering = true; _clamberStartedAt = Time.time; _clamberPoseProgress = 0f; _clamberStart = ((Component)this).transform.position; _clamberEnd = landing; _clamberObstacle = surfaceObstacle; _clamberForward = clamberForward; _clamberRise = Mathf.Max(0f, val.y); _activeClamberDuration = Mathf.Max(0.52f, magnitude / Mathf.Max(1.2f, 1.677f)); _clamberArcHeight = Mathf.Clamp(0.18f + Mathf.Max(0f, 0f - val.y) * 0.18f, 0.18f, 0.42f); _berserkAttackCooldown = Mathf.Max(_berserkAttackCooldown, _activeClamberDuration + 0.42f); _lastCrawlPosition = ((Component)this).transform.position; _berserkStuckTime = 0f; Array.Clear(_crawlContactValid, 0, _crawlContactValid.Length); if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled) { ((Behaviour)_agent).enabled = false; } return true; } private static string DescribeCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return ""; } string name = ((Object)collider).name; Transform parent = ((Component)collider).transform.parent; return name + " [" + (((parent != null) ? ((Object)parent).name : null) ?? "root") + "]"; } private static bool IsDoorCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } Transform val = ((Component)collider).transform; int num = 0; while ((Object)(object)val != (Object)null && num < 7) { string text = ((Object)val).name ?? string.Empty; if (text.IndexOf("door", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("hinge", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } num++; val = val.parent; } return false; } private static float HorizontalDistance(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) //IL_0002: 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) Vector3 val = a - b; val.y = 0f; return ((Vector3)(ref val)).magnitude; } private static bool IsLevelGeneratorExtraHelper(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } if (!(((Object)collider).name ?? string.Empty).StartsWith("Extra", StringComparison.OrdinalIgnoreCase)) { return false; } Transform root = ((Component)collider).transform.root; return (((Object)(object)root != (Object)null) ? ((Object)root).name : string.Empty).IndexOf("Level Generator", StringComparison.OrdinalIgnoreCase) >= 0; } private Vector3 SnapCrawlContact(Vector3 localPoint, int contactIndex, float lift, Vector3 root, Quaternion basis) { //IL_0000: 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) //IL_0004: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) Vector3 val = root + basis * localPoint; if (contactIndex < 0 || contactIndex >= _crawlContacts.Length) { return localPoint; } if (lift > 0.62f) { _crawlContactValid[contactIndex] = false; return localPoint; } bool flag = Time.time >= _nextCrawlProbeAt[contactIndex]; if (!_crawlContactValid[contactIndex] && flag && TryFindCrawlSurface(val, basis, out var contact)) { _crawlContacts[contactIndex] = contact; _crawlContactValid[contactIndex] = true; _nextCrawlProbeAt[contactIndex] = Time.time + 0.085f; } else { if (_crawlContactValid[contactIndex] && flag) { Vector3 val2 = _crawlContacts[contactIndex] - val; if (((Vector3)(ref val2)).sqrMagnitude > 0.7f && TryFindCrawlSurface(val, basis, out contact)) { val2 = _crawlContacts[contactIndex] - contact; if (((Vector3)(ref val2)).sqrMagnitude > 0.035f) { float num = 1f - Mathf.Exp((0f - Time.deltaTime) * 13f); _crawlContacts[contactIndex] = Vector3.Lerp(_crawlContacts[contactIndex], contact, num); _nextCrawlProbeAt[contactIndex] = Time.time + 0.085f; goto IL_0153; } } } if (flag) { _nextCrawlProbeAt[contactIndex] = Time.time + 0.085f; } } goto IL_0153; IL_0153: if (!_crawlContactValid[contactIndex]) { return localPoint; } return Quaternion.Inverse(basis) * (_crawlContacts[contactIndex] - root); } private bool TryFindCrawlSurface(Vector3 desired, Quaternion basis, out Vector3 contact) { //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) //IL_0010: 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_0021: 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_0023: 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_0038: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) contact = desired; float bestScore = float.MaxValue; bool found = false; ProbeCrawlDirection(desired, Vector3.down, ref contact, ref bestScore, ref found); ProbeCrawlDirection(desired, basis * Vector3.left, ref contact, ref bestScore, ref found); ProbeCrawlDirection(desired, basis * Vector3.right, ref contact, ref bestScore, ref found); ProbeCrawlDirection(desired, Vector3.up, ref contact, ref bestScore, ref found); ProbeCrawlDirection(desired, basis * Vector3.forward, ref contact, ref bestScore, ref found); ProbeCrawlDirection(desired, basis * Vector3.back, ref contact, ref bestScore, ref found); return found; } private void ProbeCrawlDirection(Vector3 desired, Vector3 direction, ref Vector3 best, ref float bestScore, ref bool found) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_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_0038: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) ((Vector3)(ref direction)).Normalize(); int num = Physics.RaycastNonAlloc(desired - direction * 0.58f, direction, _crawlProbeHits, 1.16f, -5, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { RaycastHit val = _crawlProbeHits[i]; if (IsClamberSurface(((RaycastHit)(ref val)).collider)) { Vector3 val2 = ((RaycastHit)(ref val)).point - desired; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (!(sqrMagnitude >= bestScore)) { bestScore = sqrMagnitude; best = ((RaycastHit)(ref val)).point + ((RaycastHit)(ref val)).normal * 0.025f; found = true; } } } } private void StopBerserkPursuit() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) if (_surfaceCrawling) { _surfaceCrawling = false; _surfaceObstacle = null; _surfaceNormal = Vector3.up; _surfaceDirection = _facing * Vector3.forward; Array.Clear(_crawlContactValid, 0, _crawlContactValid.Length); if (_berserk) { KeepBerserkAgentDisabled(); } else { ActivateNavigation(((Component)this).transform.position); } } if (_clambering) { _clambering = false; _clamberObstacle = null; _clamberPoseProgress = 0f; _clamberRise = 0f; if (_berserk) { KeepBerserkAgentDisabled(); } else { ActivateNavigation(((Component)this).transform.position); } Array.Clear(_crawlContactValid, 0, _crawlContactValid.Length); } if (!_berserk && (Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } } private void PoseSegment(int index, Vector3 localStart, Vector3 localEnd, Vector3 root, Quaternion basis, bool force, float trimStart = 0f, float trimEnd = 0f) { //IL_0020: 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_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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0059: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || index >= _parts.Count) { return; } SpawnedDeadAirPart spawnedDeadAirPart = _parts[index]; Vector3 val = localEnd - localStart; if (spawnedDeadAirPart != null && !(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude > trimStart + trimEnd + 0.04f) { Vector3 val2 = val / magnitude; localStart += val2 * trimStart; localEnd -= val2 * trimEnd; val = localEnd - localStart; } Quaternion localRotation = Quaternion.FromToRotation(spawnedDeadAirPart.LongAxisLocal, ((Vector3)(ref val)).normalized); float num = ((index < _segmentWorldLengths.Count) ? _segmentWorldLengths[index] : 0f); if (num <= 0.001f) { num = SegmentReferenceLength(index); } Vector3 value = ((index < _baseScales.Count) ? _baseScales[index] : Vector3.one); if (_berserk && num > 0.001f) { float num2 = Mathf.Clamp(((Vector3)(ref val)).magnitude / num * 0.94f, 0.24f, 1.2f); value.y *= num2; } PoseVisual(index, (localStart + localEnd) * 0.5f, localRotation, root, basis, force, value); } } private static float SegmentReferenceLength(int index) { switch (index) { case 3: case 5: return 0.602f; case 4: case 6: return 0.762f; case 7: case 9: return 0.632f; case 8: case 10: return 0.493f; default: return 0f; } } private void PoseVisual(int index, Vector3 localCenter, Quaternion localRotation, Vector3 root, Quaternion basis, bool force, Vector3? scaleOverride = null) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: 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_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025b: 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_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: 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_0378: Unknown result type (might be due to invalid IL or missing references) if ((_poseOnlyIndex >= 0 && index != _poseOnlyIndex) || index < 0 || index >= _parts.Count) { return; } SpawnedDeadAirPart spawnedDeadAirPart = _parts[index]; if (spawnedDeadAirPart == null || !spawnedDeadAirPart.Alive || (Object)(object)spawnedDeadAirPart.Phys == (Object)null) { return; } if (spawnedDeadAirPart.GeometryCalibrationFrames > 0) { DeadAirSpawner.RefreshRenderedGeometry(spawnedDeadAirPart); spawnedDeadAirPart.GeometryCalibrationFrames--; } Vector3 val = ((index < _baseScales.Count) ? _baseScales[index] : spawnedDeadAirPart.Root.transform.localScale); Vector3 val2 = scaleOverride ?? val; Vector3 val3 = spawnedDeadAirPart.Root.transform.localScale - val2; if (((Vector3)(ref val3)).sqrMagnitude > 1E-07f) { spawnedDeadAirPart.Root.transform.localScale = val2; } Vector3 val4 = root + basis * localCenter; Quaternion val5 = basis * localRotation; Vector3 val6 = default(Vector3); ((Vector3)(ref val6))..ctor((Mathf.Abs(val.x) > 0.0001f) ? (val2.x / val.x) : 1f, (Mathf.Abs(val.y) > 0.0001f) ? (val2.y / val.y) : 1f, (Mathf.Abs(val.z) > 0.0001f) ? (val2.z / val.z) : 1f); Vector3 val7 = Vector3.Scale(spawnedDeadAirPart.VisualCenterOffset, val6); Vector3 val8 = val4 - val5 * val7; while (_lastPosePositions.Count <= index) { _lastPosePositions.Add(val8); } while (_lastPoseRotations.Count <= index) { _lastPoseRotations.Add(val5); } _lastPosePositions[index] = val8; _lastPoseRotations[index] = val5; if ((Object)(object)spawnedDeadAirPart.ImpactDetector != (Object)null) { spawnedDeadAirPart.ImpactDetector.destroyDisable = true; } spawnedDeadAirPart.Phys.OverrideKinematic(0.35f); spawnedDeadAirPart.Phys.OverrideGrabDisable(0.35f); spawnedDeadAirPart.Phys.OverrideIndestructible(0.35f); float num = (force ? 1f : (1f - Mathf.Exp(-28f * Time.deltaTime))); Vector3 val9 = Vector3.Lerp(((Component)spawnedDeadAirPart.Phys).transform.position, val8, num); Quaternion val10 = Quaternion.Slerp(((Component)spawnedDeadAirPart.Phys).transform.rotation, val5, num); if (!GameManager.Multiplayer()) { SetLocalRenderers(spawnedDeadAirPart, enabled: true); spawnedDeadAirPart.Phys.SetPositionLogic(val9, val10); return; } bool flag = (Object)(object)_target?.photonView != (Object)null && _target.photonView.IsMine; SetLocalRenderers(spawnedDeadAirPart, flag); if (flag) { spawnedDeadAirPart.Phys.SetPositionLogic(val9, val10); return; } spawnedDeadAirPart.Phys.SetPositionLogic(VoodooSpawner.HiddenPosition, Quaternion.identity); PhotonView val11 = ((index < _partViews.Count) ? _partViews[index] : null); if (force || _sendPoseThisFrame) { PlayerAvatar target = _target; object obj; if (target == null) { obj = null; } else { PhotonView photonView = target.photonView; obj = ((photonView != null) ? photonView.Owner : null); } if (obj != null && (Object)(object)val11 != (Object)null) { val11.RPC("SetPositionRPC", _target.photonView.Owner, new object[2] { val8, val5 }); } } } private void UpdateVisibilityTarget(PlayerAvatar next) { if (!((Object)(object)_visibilityTarget == (Object)(object)next)) { HideFrom(_visibilityTarget); _visibilityTarget = next; _poseSendTimer = 0f; _sendPoseThisFrame = true; } } private void HideFrom(PlayerAvatar player) { //IL_0074: 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_00d2: 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) if (!GameManager.Multiplayer() || (Object)(object)player?.photonView == (Object)null) { return; } bool isMine = player.photonView.IsMine; for (int i = 0; i < _parts.Count; i++) { SpawnedDeadAirPart spawnedDeadAirPart = _parts[i]; if ((Object)(object)spawnedDeadAirPart?.Root == (Object)null || (Object)(object)spawnedDeadAirPart.Phys == (Object)null) { continue; } if (isMine) { SetLocalRenderers(spawnedDeadAirPart, enabled: false); spawnedDeadAirPart.Phys.SetPositionLogic(VoodooSpawner.HiddenPosition, Quaternion.identity); continue; } PhotonView val = ((i < _partViews.Count) ? _partViews[i] : null); if (player.photonView.Owner != null && (Object)(object)val != (Object)null) { val.RPC("SetPositionRPC", player.photonView.Owner, new object[2] { VoodooSpawner.HiddenPosition, Quaternion.identity }); } } } private static void SetLocalRenderers(SpawnedDeadAirPart part, bool enabled) { if (part?.Renderers == null) { return; } Renderer[] renderers = part.Renderers; foreach (Renderer val in renderers) { if ((Object)(object)val != (Object)null) { val.enabled = enabled; } } } internal static void ReportExternalAttack(Vector3 position) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) for (int num = Active.Count - 1; num >= 0; num--) { DeliriumController deliriumController = Active[num]; if ((Object)(object)deliriumController == (Object)null) { Active.RemoveAt(num); } else if (!deliriumController._berserk) { Vector3 val = ((Component)deliriumController).transform.position - position; if (((Vector3)(ref val)).sqrMagnitude < 16f) { deliriumController.BeginDisappear(); } } } } private static bool TryResolveRequiredPrefabs(out string pendant, out string torso, out string pelvis, out string limb) { pendant = FindFirst(PendantNames); MimicSpawner.PrefabsAvailable(); torso = MimicSpawner.TorsoResourcePath; pelvis = MimicSpawner.PelvisResourcePath; limb = FindFirst(ServerRackNames); if (!string.IsNullOrEmpty(pendant) && !string.IsNullOrEmpty(torso) && !string.IsNullOrEmpty(pelvis)) { return !string.IsNullOrEmpty(limb); } return false; } private static string FindFirst(string[] names) { string[] sizeFolders = SizeFolders; foreach (string text in sizeFolders) { foreach (string text2 in names) { string text3 = "Valuables/" + text + "/" + text2; if ((Object)(object)Resources.Load(text3) != (Object)null) { return text3; } } } return null; } private void BeginDisappear() { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) if (_disappearing) { return; } _reconstructionPoseCursor = -1; _poseOnlyIndex = -1; StopBerserkPursuit(); _disappearing = true; _nextDisappearPoseAt = 0f; _teleportCommitted = false; _disappearStartedAt = Time.time; _manager?.BeginTeleportSearch(this, _target); _disappearScales.Clear(); _disappearPositions.Clear(); _disappearRotations.Clear(); for (int i = 0; i < _parts.Count; i++) { SpawnedDeadAirPart spawnedDeadAirPart = _parts[i]; _disappearScales.Add(((Object)(object)spawnedDeadAirPart?.Root != (Object)null) ? spawnedDeadAirPart.Root.transform.localScale : Vector3.one); _disappearPositions.Add((i < _lastPosePositions.Count) ? _lastPosePositions[i] : (((Object)(object)spawnedDeadAirPart?.Phys != (Object)null) ? ((Component)spawnedDeadAirPart.Phys).transform.position : ((Component)this).transform.position)); _disappearRotations.Add((i < _lastPoseRotations.Count) ? _lastPoseRotations[i] : (((Object)(object)spawnedDeadAirPart?.Phys != (Object)null) ? ((Component)spawnedDeadAirPart.Phys).transform.rotation : Quaternion.identity)); if ((Object)(object)spawnedDeadAirPart?.ImpactDetector != (Object)null) { spawnedDeadAirPart.ImpactDetector.playerHurtDisable = true; spawnedDeadAirPart.ImpactDetector.destroyDisable = true; } if (!((Object)(object)spawnedDeadAirPart?.Phys == (Object)null)) { spawnedDeadAirPart.Phys.OverrideKinematic(2f); spawnedDeadAirPart.Phys.OverrideGrabDisable(2f); spawnedDeadAirPart.Phys.OverrideIndestructible(2f); } } if (!GameManager.Multiplayer() || !((Object)(object)_target?.photonView != (Object)null) || _target.photonView.IsMine) { return; } foreach (SpawnedDeadAirPart part in _parts) { if (!((Object)(object)part?.Phys == (Object)null)) { SetLocalRenderers(part, enabled: false); part.Phys.SetPositionLogic(VoodooSpawner.HiddenPosition, Quaternion.identity); } } } private void TickDisappear() { //IL_0078: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: 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_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) float num = Time.time - _disappearStartedAt; float num2 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.2f, 1.3f, num)); float num3 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.64f, 1.34f, num)); bool flag = Time.time >= _nextDisappearPoseAt; if (flag) { _nextDisappearPoseAt = Time.time + 0.067f; } Vector3 val = ((Component)this).transform.position + Vector3.up * 0.72f; for (int i = 0; i < _parts.Count; i++) { SpawnedDeadAirPart spawnedDeadAirPart = _parts[i]; if (!((Object)(object)spawnedDeadAirPart?.Root == (Object)null) && !((Object)(object)spawnedDeadAirPart.Phys == (Object)null)) { Vector3 val2 = ((i < _disappearPositions.Count) ? _disappearPositions[i] : ((Component)spawnedDeadAirPart.Phys).transform.position); Quaternion val3 = ((i < _disappearRotations.Count) ? _disappearRotations[i] : ((Component)spawnedDeadAirPart.Phys).transform.rotation); float num4 = (float)(i + 1) * 1.73f; Vector3 val4 = new Vector3(Mathf.Sin(num4), 0f, Mathf.Cos(num4 * 0.83f)) * (0.035f + (float)(i % 3) * 0.008f); Vector3 val5 = val2 + val4 * num2 + Vector3.down * (0.16f * num2 + 0.62f * num2 * num2); val5 = Vector3.Lerp(val5, val + Vector3.down * 0.58f, num3 * 0.82f); Quaternion rotation = val3 * Quaternion.Euler(Mathf.Sin(num4) * 22f * num2, Mathf.Cos(num4 * 0.77f) * 17f * num2, Mathf.Sin(num4 * 1.19f) * 26f * num2); PlaceDisappearVisual(i, val5, rotation, flag); } } if (num >= 1.42f && !_teleportCommitted) { _teleportCommitted = true; DeliriumManager deliriumManager = _manager ?? Object.FindObjectOfType(); if ((Object)(object)deliriumManager != (Object)null && deliriumManager.IsTeleportSearchPending(this)) { _teleportCommitted = false; } else if (!((Object)(object)deliriumManager != (Object)null) || !deliriumManager.TryCompleteTeleport(this, _sanity, _berserk)) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } private void PlaceDisappearVisual(int index, Vector3 position, Quaternion rotation, bool sendRemotePose) { //IL_0057: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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) if (index < 0 || index >= _parts.Count) { return; } SpawnedDeadAirPart spawnedDeadAirPart = _parts[index]; if ((Object)(object)spawnedDeadAirPart?.Root == (Object)null || (Object)(object)spawnedDeadAirPart.Phys == (Object)null) { return; } if (!GameManager.Multiplayer()) { SetLocalRenderers(spawnedDeadAirPart, enabled: true); spawnedDeadAirPart.Phys.SetPositionLogic(position, rotation); return; } bool flag = (Object)(object)_target?.photonView != (Object)null && _target.photonView.IsMine; SetLocalRenderers(spawnedDeadAirPart, flag); if (flag) { spawnedDeadAirPart.Phys.SetPositionLogic(position, rotation); return; } PhotonView val = ((index < _partViews.Count) ? _partViews[index] : null); if (sendRemotePose) { PlayerAvatar target = _target; object obj; if (target == null) { obj = null; } else { PhotonView photonView = target.photonView; obj = ((photonView != null) ? photonView.Owner : null); } if (obj != null && (Object)(object)val != (Object)null) { val.RPC("SetPositionRPC", _target.photonView.Owner, new object[2] { position, rotation }); } } } public void ReceiveTumbleAttack(int partIndex, int damage, Vector3 hitPosition, Vector3 direction) { if (!_berserk) { BeginDisappear(); } } public void OnTranqStunned(float duration) { BeginDisappear(); } internal void OnStunMineTriggered() { BeginDisappear(); } private void Rollback() { foreach (SpawnedDeadAirPart part in _parts) { if (part != null) { DeadAirSpawner.Destroy(part); } } _parts.Clear(); _baseScales.Clear(); _segmentWorldLengths.Clear(); _partViews.Clear(); _disappearScales.Clear(); _lastPosePositions.Clear(); _lastPoseRotations.Clear(); _disappearPositions.Clear(); _disappearRotations.Clear(); _ownColliders.Clear(); } private void OnDestroy() { Active.Remove(this); Rollback(); } } internal sealed class DeliriumManager : MonoBehaviour { private sealed class TeleportSearch { internal DeliriumController Departing; internal PlayerAvatar Target; internal Vector3 Previous; internal List Points; internal int PointIndex; internal int RadialIndex; internal float AngleOffset; internal bool Complete; internal bool Found; internal Vector3 Best; internal float BestScore = float.MaxValue; } private DeliriumController _encounter; private readonly List _recentTeleportPositions = new List(); private TeleportSearch _teleportSearch; internal bool HasLiveEncounter { get { if ((Object)(object)_encounter != (Object)null) { return _encounter.CanReceiveTumbleAttack; } return false; } } internal void Tick() { if (!HostReady() || !ModEnemyLevelRules.IsPlayableLevel()) { Despawn(); } else { ProcessTeleportSearch(4); } } internal bool DebugSpawnAt(Vector3 requested) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return DebugSpawnInternal(requested, berserk: false); } internal bool DebugSpawnBerserkAt(Vector3 requested) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return DebugSpawnInternal(requested, berserk: true); } private bool DebugSpawnInternal(Vector3 requested, bool berserk) { //IL_0010: 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_0012: 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: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if (!HostReady() || !ModEnemyLevelRules.IsPlayableLevel()) { return false; } Vector3 val = requested; NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(requested, ref val2, 12f, -1)) { val = ((NavMeshHit)(ref val2)).position; } Despawn(); GameObject val3 = new GameObject("The Delirium Encounter (Host Logic)"); val3.SetActive(false); val3.transform.position = val; DeliriumController deliriumController = val3.AddComponent(); if (!deliriumController.Initialize(val, (!berserk) ? 3 : 0, berserk, this)) { Object.Destroy((Object)(object)val3); return false; } val3.SetActive(true); deliriumController.ActivateNavigation(val); _encounter = deliriumController; RememberTeleport(val); Plugin.Log.LogInfo((object)string.Format("The Delirium manifested{0} at {1} ({2}).", berserk ? " already berserk" : string.Empty, val, ModEnemySpawnCoordinator.CurrentSpawnSource)); return true; } internal void MarkAutomaticAttemptFinished() { } internal void BeginTeleportSearch(DeliriumController departing, PlayerAvatar target) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)departing == (Object)null)) { _teleportSearch = new TeleportSearch { Departing = departing, Target = target, Previous = ((Component)departing).transform.position, Points = SemiFunc.LevelPointsGetAll(), AngleOffset = Random.Range(0f, 360f) }; } } internal bool IsTeleportSearchPending(DeliriumController departing) { if (_teleportSearch != null && (Object)(object)_teleportSearch.Departing == (Object)(object)departing) { return !_teleportSearch.Complete; } return false; } internal bool TryCompleteTeleport(DeliriumController departing, int sanity, bool berserk) { //IL_009f: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)departing == (Object)null || (Object)(object)_encounter != (Object)(object)departing || !HostReady() || !ModEnemyLevelRules.IsPlayableLevel()) { return false; } PlayerAvatar target = departing.Target; if (_teleportSearch == null || (Object)(object)_teleportSearch.Departing != (Object)(object)departing) { BeginTeleportSearch(departing, target); ProcessTeleportSearch(8); } if (_teleportSearch == null || !_teleportSearch.Complete || !_teleportSearch.Found) { Plugin.Log.LogWarning((object)"The Delirium could not find a hidden room for its teleport; the encounter was cleaned up."); _encounter = null; _teleportSearch = null; return false; } Vector3 best = _teleportSearch.Best; _teleportSearch = null; if (!departing.ReconstructInPlace(best, sanity, berserk, target)) { _encounter = null; return false; } RememberTeleport(best); Plugin.Log.LogInfo((object)$"The Delirium collapsed and teleported to a hidden point at {best}."); return true; } internal void DebugDespawn() { if (HostReady()) { Despawn(); } } private void Despawn() { if ((Object)(object)_encounter != (Object)null) { GameObject gameObject = ((Component)_encounter).gameObject; _encounter = null; if ((Object)(object)gameObject != (Object)null) { gameObject.SetActive(false); Object.Destroy((Object)(object)gameObject); } } _recentTeleportPositions.Clear(); _teleportSearch = null; } private void ProcessTeleportSearch(int budget) { TeleportSearch teleportSearch = _teleportSearch; if (teleportSearch == null || teleportSearch.Complete) { return; } if (!GunAccess.IsLiving(teleportSearch.Target)) { teleportSearch.Complete = true; return; } List points = teleportSearch.Points; while (budget > 0 && points != null && teleportSearch.PointIndex < points.Count) { EvaluateLevelPoint(teleportSearch, points[teleportSearch.PointIndex++]); budget--; } if (points != null && teleportSearch.PointIndex < points.Count) { return; } if (teleportSearch.Found) { teleportSearch.Complete = true; return; } while (budget-- > 0 && teleportSearch.RadialIndex < 48) { EvaluateRadialPoint(teleportSearch, teleportSearch.RadialIndex++); if (teleportSearch.Found) { teleportSearch.Complete = true; return; } } if (teleportSearch.RadialIndex >= 48) { teleportSearch.Complete = true; } } private void EvaluateLevelPoint(TeleportSearch search, LevelPoint point) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if ((Object)(object)point == (Object)null || !NavMesh.SamplePosition(((Component)point).transform.position, ref val, 2.25f, -1)) { return; } float num = HorizontalDistance(((NavMeshHit)(ref val)).position, ((Component)search.Target).transform.position); if (num < 14f || num > 26f || !ModEnemyNavigation.TryFindClearSpawn(((NavMeshHit)(ref val)).position, 3.5f, out var position)) { return; } float num2 = HorizontalDistance(position, ((Component)search.Target).transform.position); float num3 = HorizontalDistance(position, search.Previous); if (num2 < 14f || num2 > 26f || num3 < 7.5f || IsRecentTeleport(position, 6.25f)) { return; } bool flag = IsOccludedFromTarget(position, search.Target); if (flag || !IsInsideTargetView(position, search.Target)) { float num4 = (flag ? 0f : 100f) + Mathf.Abs(num2 - 19f) + Mathf.Abs(num3 - 14f) * 0.12f + Random.Range(0f, 1.2f); if (!(num4 >= search.BestScore)) { search.BestScore = num4; search.Best = position; search.Found = true; } } } private void EvaluateRadialPoint(TeleportSearch search, int index) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00ca: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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) float[] array = new float[4] { 15.5f, 18.5f, 21.5f, 24.5f }; int num = index / 12; int num2 = index % 12; float num3 = (search.AngleOffset + (float)num2 * 30f + (float)num * 11f) * (MathF.PI / 180f); Vector3 val = ((Component)search.Target).transform.position + new Vector3(Mathf.Cos(num3), 0f, Mathf.Sin(num3)) * array[num]; NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(val, ref val2, 2.8f, -1) && ModEnemyNavigation.TryFindClearSpawn(((NavMeshHit)(ref val2)).position, 2.2f, out var position)) { Vector3 val3 = position - val; val3.y = 0f; float num4 = HorizontalDistance(position, ((Component)search.Target).transform.position); float num5 = HorizontalDistance(position, search.Previous); if (!(((Vector3)(ref val3)).sqrMagnitude > 9.61f) && !(num4 < 14f) && !(num4 > 26f) && !(num5 < 7.5f) && !IsRecentTeleport(position, 6.25f) && (IsOccludedFromTarget(position, search.Target) || !IsInsideTargetView(position, search.Target))) { search.Best = position; search.Found = true; } } } private bool TryFindHiddenTeleport(Vector3 previous, PlayerAvatar target, out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0424: 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_0108: 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_020e: 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_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023e: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; List list = SemiFunc.LevelPointsGetAll(); if (GunAccess.IsLiving(target) && list != null && list.Count > 0) { float num = float.MaxValue; Vector3 val = Vector3.zero; bool flag = false; NavMeshHit val2 = default(NavMeshHit); foreach (LevelPoint item in list) { if ((Object)(object)item == (Object)null || !NavMesh.SamplePosition(((Component)item).transform.position, ref val2, 2.25f, -1)) { continue; } float num2 = HorizontalDistance(((NavMeshHit)(ref val2)).position, ((Component)target).transform.position); if (num2 < 14f || num2 > 26f || !IsOccludedFromTarget(((NavMeshHit)(ref val2)).position, target) || !ModEnemyNavigation.TryFindClearSpawn(((NavMeshHit)(ref val2)).position, 3.5f, out var position2)) { continue; } float num3 = HorizontalDistance(position2, ((Component)target).transform.position); if (num3 < 14f || num3 > 26f || !IsOccludedFromTarget(position2, target)) { continue; } float num4 = HorizontalDistance(position2, previous); if (!(num4 < 7.5f) && !IsRecentTeleport(position2, 6.25f)) { float num5 = Mathf.Abs(num3 - 19f) + Mathf.Abs(num4 - 14f) * 0.12f + Random.Range(0f, 1.2f); if (!(num5 >= num)) { num = num5; val = position2; flag = true; } } } if (flag) { position = val; return true; } num = float.MaxValue; flag = false; NavMeshHit val3 = default(NavMeshHit); foreach (LevelPoint item2 in list) { if ((Object)(object)item2 == (Object)null || !NavMesh.SamplePosition(((Component)item2).transform.position, ref val3, 2.25f, -1)) { continue; } float num6 = HorizontalDistance(((NavMeshHit)(ref val3)).position, ((Component)target).transform.position); if (num6 < 14f || num6 > 26f || IsInsideTargetView(((NavMeshHit)(ref val3)).position, target) || !ModEnemyNavigation.TryFindClearSpawn(((NavMeshHit)(ref val3)).position, 3.5f, out var position3)) { continue; } float num7 = HorizontalDistance(position3, ((Component)target).transform.position); if (num7 < 14f || num7 > 26f || IsInsideTargetView(position3, target)) { continue; } float num8 = HorizontalDistance(position3, previous); if (!(num8 < 7.5f) && !IsRecentTeleport(position3, 6.25f)) { float num9 = Mathf.Abs(num7 - 19f) + Mathf.Abs(num8 - 14f) * 0.12f + Random.Range(0f, 1.2f); if (!(num9 >= num)) { num = num9; val = position3; flag = true; } } } if (flag) { position = val; return true; } } if (GunAccess.IsLiving(target)) { float num10 = Random.Range(0f, 360f); float[] array = new float[4] { 15.5f, 18.5f, 21.5f, 24.5f }; NavMeshHit val5 = default(NavMeshHit); for (int i = 0; i < array.Length; i++) { for (int j = 0; j < 12; j++) { float num11 = (num10 + (float)j * 30f + (float)i * 11f) * (MathF.PI / 180f); Vector3 val4 = ((Component)target).transform.position + new Vector3(Mathf.Cos(num11), 0f, Mathf.Sin(num11)) * array[i]; if (!NavMesh.SamplePosition(val4, ref val5, 2.8f, -1) || !ModEnemyNavigation.TryFindClearSpawn(((NavMeshHit)(ref val5)).position, 2.2f, out var position4)) { continue; } Vector3 val6 = position4 - val4; val6.y = 0f; if (!(((Vector3)(ref val6)).sqrMagnitude > 9.61f)) { float num12 = HorizontalDistance(position4, ((Component)target).transform.position); float num13 = HorizontalDistance(position4, previous); if (!(num12 < 14f) && !(num12 > 26f) && !(num13 < 7.5f) && !IsRecentTeleport(position4, 6.25f) && (IsOccludedFromTarget(position4, target) || !IsInsideTargetView(position4, target))) { position = position4; return true; } } } } } return false; } private void RememberTeleport(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) _recentTeleportPositions.Add(position); while (_recentTeleportPositions.Count > 5) { _recentTeleportPositions.RemoveAt(0); } } private bool IsRecentTeleport(Vector3 position, float radius) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) float num = radius * radius; foreach (Vector3 recentTeleportPosition in _recentTeleportPositions) { Vector3 val = position - recentTeleportPosition; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < num) { return true; } } return false; } private static bool IsOccludedFromTarget(Vector3 candidate, PlayerAvatar target) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_001a: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(target)) { return true; } Vector3 val = candidate + Vector3.up * 1.45f; Vector3 val2 = ((Component)target).transform.position + Vector3.up * 0.85f; RaycastHit val3 = default(RaycastHit); if (!Physics.Linecast(val, val2, ref val3, -5, (QueryTriggerInteraction)1)) { return false; } if ((Object)(object)((RaycastHit)(ref val3)).transform != (Object)(object)((Component)target).transform) { return !((RaycastHit)(ref val3)).transform.IsChildOf(((Component)target).transform); } return false; } private static bool IsInsideTargetView(Vector3 candidate, PlayerAvatar target) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(target)) { return false; } Transform val = (((Object)(object)target.PlayerVisionTarget != (Object)null) ? target.PlayerVisionTarget.VisionTransform : ((Component)target).transform); Vector3 val2 = candidate + Vector3.up * 1.4f - val.position; val2.y *= 0.65f; if (((Vector3)(ref val2)).sqrMagnitude > 0.01f) { return Vector3.Dot(val.forward, ((Vector3)(ref val2)).normalized) > 0.42f; } return false; } private static float HorizontalDistance(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) //IL_0002: 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) Vector3 val = a - b; val.y = 0f; return ((Vector3)(ref val)).magnitude; } private static bool HostReady() { try { return (Object)(object)GameManager.instance != (Object)null && (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient); } catch { return false; } } } internal sealed class EffigyController : MonoBehaviour, IModEnemyTumbleReceiver { private readonly List _parts = new List(); private readonly HashSet _claimedWeaponBullets = new HashSet(); private readonly Dictionary _lastKillAttempt = new Dictionary(); private readonly Dictionary _transparentVisionCache = new Dictionary(); private NavMeshAgent _agent; private PlayerAvatar _target; private int _health; private float _destinationTimer; private float _movementSoundTimer; private float _damagePulseTimer; private float _damageFeedbackCooldown; private float _valuableDamageTimer; private float _lastClaimedWeaponHitTime = -999f; private float _observationHeight = 1.5f; private bool _initialized; private bool _cleaningUp; private bool _dead; private bool _rewardDropped; private float _rewardTimer; private bool _observationStateInitialized; private bool _wasObserved; private bool _proximityActivated; private bool _firstHitLogged; private bool _firstMovementSoundLogged; private bool _movementSoundWing; private Vector3 ObservationPoint => ((Component)this).transform.position + Vector3.up * _observationHeight; public bool CanReceiveTumbleAttack { get { if (_initialized) { return !_dead; } return false; } } internal bool Initialize(Vector3 position) { //IL_0006: 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_00e9: 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_0114: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_018d: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: 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_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: 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_023c: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; _health = Mathf.Max(1, Plugin.Settings.EffigyHealth.Value); _agent = ((Component)this).gameObject.AddComponent(); ((Behaviour)_agent).enabled = false; _agent.speed = Mathf.Max(4f, Plugin.Settings.EffigyMoveSpeed.Value); _agent.acceleration = 80f; _agent.angularSpeed = 1080f; _agent.radius = 0.38f; _agent.height = 2.2f; _agent.stoppingDistance = 0.15f; _agent.autoBraking = false; float num = Mathf.Clamp(Plugin.Settings.EffigyVisualScale.Value, 0.8f, 1.45f); SpawnedEffigyPart spawnedEffigyPart = EffigySpawner.Spawn("Valuables/07 Very Tall/Valuable Manor Golden Statue", position, Quaternion.identity, new Vector3(num * 0.92f, num * 1.18f, num * 0.92f)); if (spawnedEffigyPart == null) { return false; } Bounds rendererBounds = GetRendererBounds(spawnedEffigyPart, position + Vector3.up * 1.2f); float num2 = Mathf.Clamp(((Bounds)(ref rendererBounds)).size.y * 0.21f, 0.45f, 0.85f); float num3 = Mathf.Clamp(((Component)spawnedEffigyPart.Phys).transform.position.y - ((Bounds)(ref rendererBounds)).min.y + 0.02f - num2, -1f, 3f); spawnedEffigyPart.LocalOffset = Vector3.up * num3; spawnedEffigyPart.LocalRotation = Quaternion.identity; _parts.Add(spawnedEffigyPart); _observationHeight = Mathf.Clamp(((Bounds)(ref rendererBounds)).size.y * 0.72f, 1.35f, 3.2f); Vector3 val = spawnedEffigyPart.LocalOffset + spawnedEffigyPart.LocalRotation * spawnedEffigyPart.VisualCenterOffset; float num4 = Mathf.Clamp(((Bounds)(ref rendererBounds)).extents.z * 0.68f, 0.14f, 0.38f); Vector3 val3 = default(Vector3); for (int i = 0; i < 2; i++) { float num5 = ((i == 0) ? (-1f) : 1f); SpawnedEffigyPart spawnedEffigyPart2 = EffigySpawner.Spawn(EffigySpawner.WingResourcePath, position, Quaternion.identity, new Vector3(0.58f, 0.72f, 0.32f)); if (spawnedEffigyPart2 == null) { CleanupParts(); return false; } spawnedEffigyPart2.PinByVisualCenter = true; Vector3 val2 = new Vector3(num5 * 0.64f, -0.77f, -0.04f); Vector3 normalized = ((Vector3)(ref val2)).normalized; float num6 = Mathf.Max(spawnedEffigyPart2.VisualSize.x, Mathf.Max(spawnedEffigyPart2.VisualSize.y, spawnedEffigyPart2.VisualSize.z)); ((Vector3)(ref val3))..ctor(val.x + num5 * 0.13f, _observationHeight * 0.91f, val.z - num4); spawnedEffigyPart2.LocalOffset = val3 + normalized * (num6 * 0.28f); spawnedEffigyPart2.LocalRotation = Quaternion.FromToRotation(spawnedEffigyPart2.LongAxisLocal, normalized); _parts.Add(spawnedEffigyPart2); } IgnoreSelfCollisions(); for (int j = 0; j < _parts.Count; j++) { SpawnedEffigyPart spawnedEffigyPart3 = _parts[j]; ((Component)spawnedEffigyPart3.Phys).gameObject.AddComponent().Initialize(this, j, spawnedEffigyPart3.ImpactDetector, spawnedEffigyPart3.Renderers); ((Component)spawnedEffigyPart3.Phys).gameObject.AddComponent().Initialize(this, j); } _movementSoundTimer = Random.Range(0.4f, 0.7f); _initialized = true; PinParts(); Plugin.Log.LogInfo((object)($"The Weeping Angel assembled from one vertically stretched humanoid statue and two shoulder-attached folded Broom wings with {_health} HP; " + $"pedestal sunk {num2:F2}m so the statue's feet meet the navigation floor.")); return true; } internal bool ActivateNavigation(Vector3 requestedPosition) { //IL_000e: 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_0062: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if ((Object)(object)_agent == (Object)null || !NavMesh.SamplePosition(requestedPosition, ref val, 4f, -1)) { Plugin.Log.LogError((object)"The Weeping Angel could not find NavMesh during activation."); return false; } ((Component)this).transform.position = ((NavMeshHit)(ref val)).position; ((Behaviour)_agent).enabled = true; if (!_agent.isOnNavMesh && !_agent.Warp(((NavMeshHit)(ref val)).position)) { return false; } return _agent.isOnNavMesh; } private void Update() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) if (!_initialized || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (_dead) { UpdateDeath(); return; } _damagePulseTimer = Mathf.Max(0f, _damagePulseTimer - Time.deltaTime); _damageFeedbackCooldown = Mathf.Max(0f, _damageFeedbackCooldown - Time.deltaTime); UpdateTarget(); if (!TryActivateFromPlayerProximity()) { if ((Object)(object)_agent != (Object)null && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.velocity = Vector3.zero; } PinParts(); return; } bool flag = IsObservedByAnyPlayer(); if (!_observationStateInitialized || flag != _wasObserved) { _observationStateInitialized = true; _wasObserved = flag; Plugin.Log.LogDebug((object)(flag ? "The Weeping Angel froze because a living player can see it." : "The Weeping Angel is unobserved and may move.")); } UpdateMovement(flag); PinParts(); UpdateMovementSound(flag); CheckPlayerContact(flag); CheckValuableContact(flag); UpdateNearMusic(); } private void UpdateTarget() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) _target = null; float num = float.MaxValue; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { Vector3 val = ((Component)item).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; _target = item; } } } } private bool TryActivateFromPlayerProximity() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (_proximityActivated) { return true; } float num = Mathf.Clamp(Plugin.Settings.EffigyActivationRange.Value, 12f, 80f); float num2 = num * num; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { Vector3 val = ((Component)item).transform.position - ((Component)this).transform.position; if (!(((Vector3)(ref val)).sqrMagnitude > num2)) { _proximityActivated = true; _destinationTimer = 0f; Plugin.Log.LogInfo((object)$"The Weeping Angel awakened after a living player entered its {num:F0}m initial proximity radius."); return true; } } } return false; } private void UpdateMovement(bool observed) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_agent == (Object)null || !_agent.isOnNavMesh) { return; } if (observed || !GunAccess.IsLiving(_target)) { _agent.isStopped = true; _agent.velocity = Vector3.zero; return; } _agent.speed = Mathf.Clamp(Plugin.Settings.EffigyMoveSpeed.Value, 4f, 20f); _agent.isStopped = false; _destinationTimer -= Time.deltaTime; if (_destinationTimer <= 0f) { _destinationTimer = 0.12f; _agent.SetDestination(((Component)_target).transform.position); } } private bool IsObservedByAnyPlayer() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0126: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Settings.EffigyObservationRange.Value, 8f, 100f); float num2 = Mathf.Cos(Mathf.Clamp(Plugin.Settings.EffigyObservationFov.Value, 30f, 170f) * 0.5f * (MathF.PI / 180f)); Vector3[] array = (Vector3[])(object)new Vector3[3] { ObservationPoint, ((Component)this).transform.position + Vector3.up * Mathf.Max(0.85f, _observationHeight * 0.68f), ((Component)this).transform.position + Vector3.up * Mathf.Max(0.3f, _observationHeight * 0.28f) }; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (!GunAccess.IsLiving(item)) { continue; } Transform val = item.PlayerVisionTarget?.VisionTransform; Vector3 val2 = (((Object)(object)val != (Object)null) ? val.position : (((Component)item).transform.position + Vector3.up)); Vector3 val3 = (((Object)(object)val != (Object)null) ? val.forward : ((Component)item).transform.forward); Vector3[] array2 = array; for (int i = 0; i < array2.Length; i++) { Vector3 val4 = array2[i] - val2; float magnitude = ((Vector3)(ref val4)).magnitude; if (magnitude <= 0.1f) { return true; } if (magnitude > num) { continue; } Vector3 val5 = val4 / magnitude; if (Vector3.Dot(((Vector3)(ref val3)).normalized, val5) < num2) { continue; } RaycastHit[] array3 = Physics.RaycastAll(val2, val5, magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); bool flag = false; RaycastHit[] array4 = array3; for (int j = 0; j < array4.Length; j++) { RaycastHit val6 = array4[j]; if (!IsEffigyCollider(((RaycastHit)(ref val6)).collider) && !((Object)(object)ResolveHitPlayer(((RaycastHit)(ref val6)).collider) == (Object)(object)item) && !IsEnemyCollider(((RaycastHit)(ref val6)).collider) && !IsTransparentVisionSurface(((RaycastHit)(ref val6)).collider)) { flag = true; break; } } if (!flag) { return true; } } } return false; } private bool IsTransparentVisionSurface(Collider collider) { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)collider == (Object)null) { return false; } int instanceID = ((Object)collider).GetInstanceID(); if (_transparentVisionCache.TryGetValue(instanceID, out var value)) { return value; } Renderer[] componentsInChildren = ((Component)collider).GetComponentsInChildren(true); if (componentsInChildren.Length == 0 && (Object)(object)((Component)collider).transform.parent != (Object)null) { componentsInChildren = ((Component)((Component)collider).transform.parent).GetComponentsInChildren(true); } bool flag = false; Renderer[] array = componentsInChildren; for (int i = 0; i < array.Length; i++) { Material[] sharedMaterials = array[i].sharedMaterials; foreach (Material val in sharedMaterials) { if (!((Object)(object)val == (Object)null)) { string text = (((Object)(object)val.shader != (Object)null) ? ((Object)val.shader).name : string.Empty); bool num = text.IndexOf("transparent", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("glass", StringComparison.OrdinalIgnoreCase) >= 0; bool flag2 = val.renderQueue >= 2900; bool flag3 = val.HasProperty("_Color") && val.color.a < 0.92f; if (num || flag2 || flag3) { flag = true; break; } } } if (flag) { break; } } _transparentVisionCache[instanceID] = flag; return flag; } private void UpdateMovementSound(bool observed) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) if (observed || (Object)(object)_agent == (Object)null) { return; } Vector3 velocity = _agent.velocity; if (((Vector3)(ref velocity)).sqrMagnitude < 1f) { return; } _movementSoundTimer -= Time.deltaTime; if (_movementSoundTimer > 0f) { return; } _movementSoundTimer = Random.Range(0.325f, 0.575f); IEnumerable source = _parts.Where((SpawnedEffigyPart part) => part.Alive && (Object)(object)part.ImpactDetector != (Object)null && (Object)(object)part.Phys != (Object)null); SpawnedEffigyPart spawnedEffigyPart = (_movementSoundWing ? source.FirstOrDefault((SpawnedEffigyPart part) => part.ResourcePath == EffigySpawner.WingResourcePath) : source.FirstOrDefault((SpawnedEffigyPart part) => part.ResourcePath == "Valuables/07 Very Tall/Valuable Manor Golden Statue")); if (spawnedEffigyPart == null) { spawnedEffigyPart = source.FirstOrDefault(); } _movementSoundWing = !_movementSoundWing; if (spawnedEffigyPart != null) { spawnedEffigyPart.ImpactDetector.ImpactLight((spawnedEffigyPart.ResourcePath == "Valuables/07 Very Tall/Valuable Manor Golden Statue") ? 100f : 90f, spawnedEffigyPart.Phys.centerPoint); if (!_firstMovementSoundLogged) { _firstMovementSoundLogged = true; Plugin.Log.LogInfo((object)"The Weeping Angel emitted its first networked movement scrape through a vanilla impact RPC."); } } } private void CheckPlayerContact(bool observed) { //IL_0170: 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_00cc: 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) if (observed) { return; } float num = Mathf.Clamp(Plugin.Settings.EffigyKillPadding.Value, 0f, 0.35f); foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (!GunAccess.IsLiving(item) || !TryGetPlayerBounds(item, out var bounds)) { continue; } bool flag = false; foreach (SpawnedEffigyPart part in _parts) { if (!part.Alive || part.Colliders == null) { continue; } Collider[] colliders = part.Colliders; foreach (Collider val in colliders) { if (!((Object)(object)val == (Object)null) && val.enabled && !val.isTrigger && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds2 = val.bounds; ((Bounds)(ref bounds2)).Expand(num * 2f); if (((Bounds)(ref bounds2)).Intersects(bounds)) { flag = true; break; } } } if (flag) { break; } } if (!flag) { continue; } int instanceID = ((Object)item).GetInstanceID(); if (!_lastKillAttempt.TryGetValue(instanceID, out var value) || !(Time.time - value < 0.2f)) { _lastKillAttempt[instanceID] = Time.time; PlayerHealth playerHealth = item.playerHealth; if (playerHealth != null) { playerHealth.HurtOther(100000, ((Component)item).transform.position, false, -1, false); } Plugin.Log.LogInfo((object)"The Weeping Angel touched a player and issued an instant-kill hit."); } } } private void CheckValuableContact(bool observed) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) if (!observed && !((Object)(object)_agent == (Object)null)) { Vector3 velocity = _agent.velocity; if (!(((Vector3)(ref velocity)).sqrMagnitude < 1f)) { _valuableDamageTimer -= Time.deltaTime; if (!(_valuableDamageTimer > 0f)) { _valuableDamageTimer = 0.18f; ModEnemyValuableDamage.BreakMediumInCone(((Component)this).transform.position + Vector3.up * 0.35f, ((Component)this).transform.forward, 1.25f, -1f, IsOwnCollider); } return; } } _valuableDamageTimer = Mathf.Min(_valuableDamageTimer, 0.1f); } private bool IsOwnCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } Transform hit = ((Component)collider).transform; return _parts.Any((SpawnedEffigyPart part) => (Object)(object)part.Root != (Object)null && ((Object)(object)hit == (Object)(object)part.Root.transform || hit.IsChildOf(part.Root.transform))); } private void UpdateNearMusic() { //IL_0043: 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_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) if (!((Object)(object)MusicEnemyNear.instance == (Object)null) && GunAccess.IsLiving(PlayerAvatar.instance)) { float num = Mathf.Clamp(Plugin.Settings.EffigyNearMusicRange.Value, 3f, 40f); Vector3 val = ((Component)PlayerAvatar.instance).transform.position - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude <= num * num) { MusicEnemyNear.instance.OverrideActive(0.35f); } } } internal bool TryClaimWeaponHit(int bulletInstanceId) { if (!ModEnemyWeaponDamage.TryClaim((Object)(object)this, bulletInstanceId)) { return false; } if (Time.time - _lastClaimedWeaponHitTime < 0.06f) { return false; } _lastClaimedWeaponHitTime = Time.time; return true; } internal void HurtPart(int partIndex, int damage) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (_dead || partIndex < 0 || partIndex >= _parts.Count) { return; } SpawnedEffigyPart spawnedEffigyPart = _parts[partIndex]; if (spawnedEffigyPart.Alive) { damage = ParasiteEffectRegistry.ModifyEnemyDamageAt(spawnedEffigyPart.Phys.centerPoint, damage); _health -= Mathf.Max(1, damage); PlayDamageFeedback(spawnedEffigyPart, spawnedEffigyPart.Phys.centerPoint); if (!_firstHitLogged) { _firstHitLogged = true; Plugin.Log.LogInfo((object)$"The Weeping Angel accepted its first weapon hit; HP={Mathf.Max(0, _health)}/{Mathf.Max(1, Plugin.Settings.EffigyHealth.Value)}."); } if (_health <= 0) { Die(); } } } private void PlayDamageFeedback(SpawnedEffigyPart part, Vector3 hitPosition) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) _damagePulseTimer = 0.22f; if (!(_damageFeedbackCooldown > 0f) && !((Object)(object)part?.ImpactDetector == (Object)null)) { _damageFeedbackCooldown = 0.09f; ModEnemyFeedback.DamageHit(part.ImpactDetector, part.Phys, hitPosition, 82f); } } public void ReceiveTumbleAttack(int partIndex, int damage, Vector3 hitPosition, Vector3 direction) { HurtPart(partIndex, damage); } internal void ExecuteForLab() { if (!_dead && SemiFunc.IsMasterClientOrSingleplayer()) { Plugin.Log.LogInfo((object)"Enemy Lab execution round hit The Weeping Angel."); _health = 0; Die(); } } private void Die() { if (_dead) { return; } _dead = true; _target = null; if ((Object)(object)_agent != (Object)null && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } foreach (SpawnedEffigyPart part in _parts) { if (part.Alive) { part.Alive = false; if ((Object)(object)part.ImpactDetector != (Object)null) { part.ImpactDetector.destroyDisable = false; part.ImpactDetector.DestroyObject(true); } else { EffigySpawner.Destroy(part); } } } _rewardTimer = 0.08f; Plugin.Log.LogInfo((object)("The Weeping Angel was destroyed; its vanilla enemy orb will be released after " + $"{0.08f:F2}s.")); } private void UpdateDeath() { if (!_rewardDropped) { _rewardTimer -= Time.deltaTime; if (!(_rewardTimer > 0f)) { DropReward(); } } } private void DropReward() { //IL_0078: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) _rewardDropped = true; if (!Plugin.Settings.EffigyDropEnemyValuable.Value || (Object)(object)AssetManager.instance == (Object)null) { return; } GameObject val = (GameObject)(Mathf.Clamp(Plugin.Settings.EffigyRewardTier.Value, 1, 3) switch { 2 => AssetManager.instance.enemyValuableMedium, 1 => AssetManager.instance.enemyValuableSmall, _ => AssetManager.instance.enemyValuableBig, }); if (!((Object)(object)val == (Object)null)) { Vector3 val2 = ((Component)this).transform.position + Vector3.up * 0.6f; if (GameManager.Multiplayer()) { PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)val).name, val2, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate(val, val2, Quaternion.identity); } } } private void PinParts() { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: 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_015d: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) float num = ((_damagePulseTimer > 0f) ? Mathf.Sin(Mathf.Clamp01(_damagePulseTimer / 0.22f) * MathF.PI) : 0f); foreach (SpawnedEffigyPart part in _parts) { if (part.Alive && !((Object)(object)part.Phys == (Object)null)) { part.ImpactDetector.destroyDisable = true; part.Phys.OverrideKinematic(0.3f); part.Phys.OverrideGrabDisable(0.3f); part.Phys.OverrideIndestructible(0.3f); if (part.GeometryCalibrationFrames > 0) { EffigySpawner.RefreshVisualGeometry(part); part.GeometryCalibrationFrames--; } Vector3 val = ((Component)this).transform.position + ((Component)this).transform.rotation * part.LocalOffset; float num2 = ((part.ResourcePath == "Valuables/07 Very Tall/Valuable Manor Golden Statue") ? 1f : Mathf.Sign(part.LocalOffset.x)); Quaternion val2 = Quaternion.AngleAxis(num * ((part.ResourcePath == "Valuables/07 Very Tall/Valuable Manor Golden Statue") ? 3.2f : 6f) * num2, Vector3.forward); Quaternion val3 = ((Component)this).transform.rotation * val2 * part.LocalRotation; Vector3 val4 = (part.PinByVisualCenter ? (val - val3 * part.VisualCenterOffset) : val); if (Vector3.Distance(((Component)part.Phys).transform.position, val4) > 0.01f || Quaternion.Angle(((Component)part.Phys).transform.rotation, val3) > 0.5f) { part.Phys.SetPositionLogic(val4, val3); } } } } private void IgnoreSelfCollisions() { for (int i = 0; i < _parts.Count; i++) { Collider[] colliders = _parts[i].Colliders; for (int j = i + 1; j < _parts.Count; j++) { Collider[] colliders2 = _parts[j].Colliders; Collider[] array = colliders ?? Array.Empty(); foreach (Collider val in array) { Collider[] array2 = colliders2 ?? Array.Empty(); foreach (Collider val2 in array2) { if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { Physics.IgnoreCollision(val, val2, true); } } } } } } private static Bounds GetRendererBounds(SpawnedEffigyPart part, Vector3 fallbackCenter) { //IL_0004: 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_0076: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) bool flag = false; Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(fallbackCenter, new Vector3(0.8f, 2.2f, 0.8f)); Renderer[] array = part.Renderers ?? Array.Empty(); foreach (Renderer val in array) { if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.activeInHierarchy) { if (!flag) { bounds = val.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } } } return bounds; } private static bool TryGetPlayerBounds(PlayerAvatar player, out Bounds bounds) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_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) //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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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) PlayerController instance = PlayerController.instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.playerAvatarScript == (Object)(object)player && (Object)(object)instance.col != (Object)null) { bounds = instance.col.bounds; return true; } PlayerAvatarCollision componentInChildren = ((Component)player).GetComponentInChildren(true); if ((Object)(object)componentInChildren?.Collider != (Object)null) { bounds = ((Collider)componentInChildren.Collider).bounds; return true; } Collider componentInChildren2 = ((Component)player).GetComponentInChildren(true); if ((Object)(object)componentInChildren2 != (Object)null) { bounds = componentInChildren2.bounds; return true; } bounds = new Bounds(((Component)player).transform.position + Vector3.up, Vector3.one); return true; } private bool IsEffigyCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } Transform transform = ((Component)collider).transform; foreach (SpawnedEffigyPart part in _parts) { if ((Object)(object)part.Root != (Object)null && ((Object)(object)transform == (Object)(object)part.Root.transform || transform.IsChildOf(part.Root.transform))) { return true; } } return false; } private static PlayerAvatar ResolveHitPlayer(Collider collider) { if ((Object)(object)collider == (Object)null) { return null; } PlayerController componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent?.playerAvatarScript != (Object)null) { return componentInParent.playerAvatarScript; } PlayerAvatar componentInParent2 = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null) { return componentInParent2; } return ((Component)collider).GetComponentInParent()?.playerAvatar; } private static bool IsEnemyCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } if (!((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)collider).GetComponentInParent() != (Object)null)) { return (Object)(object)((Component)collider).GetComponentInParent() != (Object)null; } return true; } private void OnDestroy() { if (_initialized && !_cleaningUp && SemiFunc.IsMasterClientOrSingleplayer()) { CleanupParts(); } } private void CleanupParts() { if (_cleaningUp) { return; } _cleaningUp = true; foreach (SpawnedEffigyPart part in _parts) { if (part.Alive && (Object)(object)part.Root != (Object)null) { EffigySpawner.Destroy(part); } } } } internal sealed class EffigyHitProxy : MonoBehaviour { private EffigyController _controller; private int _partIndex; private PhysGrabObjectImpactDetector _impactDetector; private Renderer[] _renderers; private float _cooldown; private static int _cachedBulletFrame = -1; private static ItemGunBullet[] _cachedBullets = Array.Empty(); internal void Initialize(EffigyController controller, int partIndex, PhysGrabObjectImpactDetector impactDetector, Renderer[] renderers) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown _controller = controller; _partIndex = partIndex; _impactDetector = impactDetector; _renderers = renderers ?? Array.Empty(); PhysGrabObjectImpactDetector impactDetector2 = _impactDetector; if (impactDetector2 != null) { UnityEvent onHurtColliderHit = impactDetector2.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.AddListener(new UnityAction(OnHurtColliderHit)); } } } private void Update() { if (_cooldown > 0f) { _cooldown -= Time.deltaTime; } if (_cooldown <= 0f && SemiFunc.IsMasterClientOrSingleplayer()) { DetectExpandedBulletHit(); } } private void OnDestroy() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown PhysGrabObjectImpactDetector impactDetector = _impactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.RemoveListener(new UnityAction(OnHurtColliderHit)); } } } private void OnHurtColliderHit() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_controller == (Object)null || _cooldown > 0f || !SemiFunc.IsMasterClientOrSingleplayer() || !_controller.TryClaimWeaponHit(ModEnemyWeaponDamage.CurrentClaimId)) { return; } _cooldown = 0.18f; if (EnemyLabBridge.IsExecutionHitNear(((Object)(object)_impactDetector != (Object)null) ? ((Component)_impactDetector).transform.position : ((Component)this).transform.position)) { _controller.ExecuteForLab(); return; } int num = ModEnemyWeaponDamage.CurrentOrFallback(Plugin.Settings.EffigyDamagePerHit.Value); if (num > 0) { _controller.HurtPart(_partIndex, num); } } private void DetectExpandedBulletHit() { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_controller == (Object)null) { return; } if (_cachedBulletFrame != Time.frameCount) { _cachedBulletFrame = Time.frameCount; _cachedBullets = Object.FindObjectsOfType(); } ItemGunBullet[] cachedBullets = _cachedBullets; foreach (ItemGunBullet val in cachedBullets) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent() != (Object)null) { continue; } HurtCollider hurtCollider = val.hurtCollider; if ((Object)(object)hurtCollider == (Object)null || !((Component)hurtCollider).gameObject.activeInHierarchy || !WithinExpandedVisualBounds(((Component)hurtCollider).transform.position)) { continue; } int instanceID = ((Object)val).GetInstanceID(); if (!_controller.TryClaimWeaponHit(instanceID)) { continue; } _cooldown = 0.3f; if (EnemyLabBridge.IsExecutionHitNear(((Component)hurtCollider).transform.position)) { _controller.ExecuteForLab(); break; } int num = ModEnemyWeaponDamage.Resolve(hurtCollider, Plugin.Settings.EffigyDamagePerHit.Value); if (num > 0) { _controller.HurtPart(_partIndex, num); } break; } } private bool WithinExpandedVisualBounds(Vector3 hitPosition) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_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_0063: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Settings.EffigyHitDetectionPadding.Value, 0.1f, 0.65f); float num2 = num * num; Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if ((Object)(object)val != (Object)null && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; if (((Bounds)(ref bounds)).SqrDistance(hitPosition) <= num2) { return true; } } } Vector3 val2 = (((Object)(object)_impactDetector != (Object)null) ? ((Component)_impactDetector).transform.position : ((Component)this).transform.position); float num3 = 0.5f + num; Vector3 val3 = hitPosition - val2; return ((Vector3)(ref val3)).sqrMagnitude <= num3 * num3; } } internal sealed class EffigyManager : MonoBehaviour { private int _levelInstanceId; private float _spawnTimer; private bool _attemptFinished; private bool _prefabProbeFinished; private bool _prefabAvailable; private bool _levelReadyLogged; private EffigyController _encounter; internal void Tick() { if (!IsHostOrSingleplayerReady()) { return; } ProbePrefabs(); LevelGenerator instance = LevelGenerator.Instance; int num = (((Object)(object)instance != (Object)null) ? ((Object)instance).GetInstanceID() : 0); if (num != _levelInstanceId) { ResetForLevel(num); } if (!IsPlayableLevel()) { DestroyCurrentEncounter(); } else if (!((Object)(object)instance == (Object)null) && instance.Generated && !_attemptFinished) { if (!_levelReadyLogged) { _levelReadyLogged = true; Plugin.Log.LogInfo((object)"The Weeping Angel detected a generated playable level; automatic spawn timer started."); } _spawnTimer -= Time.deltaTime; if (!(_spawnTimer > 0f)) { _attemptFinished = true; TryCreateEncounter(); } } } private void ResetForLevel(int levelId) { if ((Object)(object)_encounter != (Object)null) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); } _encounter = null; _levelInstanceId = levelId; _spawnTimer = Mathf.Max(0f, Plugin.Settings.EffigySpawnDelay.Value); _attemptFinished = false; _levelReadyLogged = false; } private void TryCreateEncounter() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) Vector3 position; if (Random.value > Mathf.Clamp01(Plugin.Settings.EffigySpawnChance.Value)) { Plugin.Log.LogInfo((object)"The Weeping Angel skipped this level by spawn chance."); } else if (!_prefabAvailable && !EffigySpawner.MainPrefabAvailable()) { Plugin.Log.LogWarning((object)"The Weeping Angel could not find the vanilla Golden Statue network prefab."); } else if (!TryFindSpawnPosition(out position)) { Plugin.Log.LogWarning((object)"Could not find a valid navigation point for The Weeping Angel."); } else { CreateEncounter(position, "automatic"); } } private bool CreateEncounter(Vector3 position, string source) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_001e: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) DestroyCurrentEncounter(); GameObject val = new GameObject("The Weeping Angel Encounter (Host Only)"); val.SetActive(false); val.transform.position = position; EffigyController effigyController = val.AddComponent(); if (!effigyController.Initialize(position)) { Object.Destroy((Object)(object)val); Plugin.Log.LogError((object)"The Weeping Angel failed to initialize."); return false; } val.SetActive(true); if (!effigyController.ActivateNavigation(position)) { Object.Destroy((Object)(object)val); Plugin.Log.LogError((object)"The Weeping Angel failed to activate navigation."); return false; } _encounter = effigyController; Plugin.Log.LogInfo((object)$"The Weeping Angel spawned at {position} ({source}); only vanilla networked objects are visible to guests."); return true; } internal bool DebugSpawnAt(Vector3 requestedPosition) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!IsHostOrSingleplayerReady() || (!ModEnemySpawnCoordinator.IsDirectorRequestActive && (Object)(object)PlayerAvatar.instance == (Object)null) || !IsPlayableLevel()) { Plugin.Log.LogWarning((object)"Enemy Lab rejected The Weeping Angel because no playable host level is active."); return false; } ProbePrefabs(); if (!_prefabAvailable && !EffigySpawner.MainPrefabAvailable()) { Plugin.Log.LogWarning((object)"Enemy Lab could not load the vanilla Golden Statue network prefab for The Weeping Angel."); return false; } NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requestedPosition, ref val, 12f, -1)) { Plugin.Log.LogWarning((object)$"Enemy Lab could not find NavMesh near {requestedPosition} for The Weeping Angel."); return false; } _attemptFinished = true; return CreateEncounter(((NavMeshHit)(ref val)).position, ModEnemySpawnCoordinator.CurrentSpawnSource); } internal void MarkAutomaticAttemptFinished() { int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelInstanceId) { ResetForLevel(num); } _attemptFinished = true; } internal void DebugDespawn() { if (IsHostOrSingleplayerReady()) { _attemptFinished = true; DestroyCurrentEncounter(); Plugin.Log.LogInfo((object)"The Weeping Angel despawned by Enemy Lab."); } } private void DestroyCurrentEncounter() { if (!((Object)(object)_encounter == (Object)null)) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); _encounter = null; } } private void ProbePrefabs() { if (!_prefabProbeFinished && !((Object)(object)RunManager.instance == (Object)null)) { _prefabProbeFinished = true; _prefabAvailable = EffigySpawner.MainPrefabAvailable(); if (_prefabAvailable) { Plugin.Log.LogInfo((object)"The Weeping Angel verified vanilla body resource: Valuables/07 Very Tall/Valuable Manor Golden Statue"); } else { Plugin.Log.LogWarning((object)"The Weeping Angel body resource is unavailable: Valuables/07 Very Tall/Valuable Manor Golden Statue"); } } } private static bool IsHostOrSingleplayerReady() { if ((Object)(object)GameManager.instance == (Object)null) { return false; } try { return !GameManager.Multiplayer() || PhotonNetwork.IsMasterClient; } catch { return false; } } private static bool IsPlayableLevel() { return ModEnemyLevelRules.IsPlayableLevel(); } private static bool TryFindSpawnPosition(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; PlayerAvatar val = null; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { val = item; break; } } Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(val2, 22f, 70f, false); if ((Object)(object)val3 == (Object)null) { val3 = SemiFunc.LevelPointGetFurthestFromPlayer(val2, 8f); } return ModEnemyNavigation.TryFindClearSpawn(((Object)(object)val3 != (Object)null) ? ((Component)val3).transform.position : (val2 + Vector3.forward * 20f), 8f, out position); } } internal sealed class SpawnedEffigyPart { internal string ResourcePath; internal GameObject Root; internal PhysGrabObject Phys; internal PhysGrabObjectImpactDetector ImpactDetector; internal ItemAttributes Attributes; internal Renderer[] Renderers; internal Collider[] Colliders; internal Vector3 LocalOffset; internal Quaternion LocalRotation; internal Vector3 VisualCenterOffset; internal Vector3 VisualSize; internal Vector3 LongAxisLocal = Vector3.up; internal bool PinByVisualCenter; internal bool LongAxisCalibrated; internal int GeometryCalibrationFrames = 16; internal bool Alive = true; } internal static class EffigySpawner { private static readonly string[] SizeFolders = new string[7] { "01 Tiny", "02 Small", "03 Medium", "04 Big", "05 Wide", "06 Tall", "07 Very Tall" }; internal const string MainResourcePath = "Valuables/07 Very Tall/Valuable Manor Golden Statue"; private const string FallbackWingResourcePath = "Valuables/07 Very Tall/Valuable Wizard Broom"; private static string _wingResourcePath; internal static string WingResourcePath { get { object obj = _wingResourcePath; if (obj == null) { obj = FindValuable("Valuable Manor Painting") ?? "Valuables/07 Very Tall/Valuable Wizard Broom"; _wingResourcePath = (string)obj; } return (string)obj; } } internal static bool MainPrefabAvailable() { if ((Object)(object)Resources.Load("Valuables/07 Very Tall/Valuable Manor Golden Statue") != (Object)null) { return (Object)(object)Resources.Load(WingResourcePath) != (Object)null; } return false; } private static string FindValuable(string prefabName) { string[] sizeFolders = SizeFolders; foreach (string text in sizeFolders) { string text2 = "Valuables/" + text + "/" + prefabName; if ((Object)(object)Resources.Load(text2) != (Object)null) { return text2; } } return null; } internal static SpawnedEffigyPart Spawn(string resourcePath, Vector3 position, Quaternion rotation, Vector3 scaleMultiplier) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00a8: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) GameObject val = Resources.Load(resourcePath); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("The Weeping Angel could not load vanilla resource '" + resourcePath + "'.")); return null; } ((Vector3)(ref scaleMultiplier))..ctor(Mathf.Clamp(scaleMultiplier.x, 0.12f, 2f), Mathf.Clamp(scaleMultiplier.y, 0.12f, 2f), Mathf.Clamp(scaleMultiplier.z, 0.12f, 2f)); Vector3 val2 = Vector3.Scale(val.transform.localScale, scaleMultiplier); object[] array = new object[3] { val2.x, val2.y, val2.z }; GameObject val3; try { val3 = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject(resourcePath, position, rotation, (byte)0, array) : Object.Instantiate(val, position, rotation)); } catch (Exception arg) { Plugin.Log.LogError((object)$"The Weeping Angel failed to network-spawn '{resourcePath}': {arg}"); return null; } if ((Object)(object)val3 == (Object)null) { return null; } if (!GameManager.Multiplayer()) { val3.transform.localScale = val2; } EncounterValuableNeutralizer.Apply(val3); SpawnedEffigyPart spawnedEffigyPart = new SpawnedEffigyPart { ResourcePath = resourcePath, Root = val3, Phys = val3.GetComponentInChildren(true), ImpactDetector = val3.GetComponentInChildren(true), Attributes = val3.GetComponentInChildren(true), Renderers = val3.GetComponentsInChildren(true), Colliders = val3.GetComponentsInChildren(true) }; if ((Object)(object)spawnedEffigyPart.Phys == (Object)null || (Object)(object)spawnedEffigyPart.ImpactDetector == (Object)null) { Plugin.Log.LogError((object)("The Weeping Angel resource '" + resourcePath + "' lacks vanilla physical components.")); Destroy(spawnedEffigyPart); return null; } RefreshVisualGeometry(spawnedEffigyPart); ItemAttributes attributes = spawnedEffigyPart.Attributes; if (attributes != null) { attributes.DisableUI(true); } spawnedEffigyPart.ImpactDetector.destroyDisable = true; spawnedEffigyPart.Phys.OverrideIndestructible(1f); spawnedEffigyPart.Phys.OverrideGrabDisable(1f); spawnedEffigyPart.Phys.OverrideKinematic(1f); MapIconSuppressor.Attach(val3); return spawnedEffigyPart; } internal static void RefreshVisualGeometry(SpawnedEffigyPart part) { //IL_0021: 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_00f7: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_018d: 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_0086: 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) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)part?.Phys == (Object)null || part.Renderers == null) { return; } bool flag = false; Bounds val = default(Bounds); Renderer[] renderers = part.Renderers; foreach (Renderer val2 in renderers) { if ((Object)(object)val2 == (Object)null || !val2.enabled || (!(val2 is MeshRenderer) && !(val2 is SkinnedMeshRenderer))) { continue; } Bounds bounds = val2.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!(((Vector3)(ref size)).sqrMagnitude < 1E-06f) && !(((Bounds)(ref bounds)).size.x > 10f) && !(((Bounds)(ref bounds)).size.y > 10f) && !(((Bounds)(ref bounds)).size.z > 10f)) { if (!flag) { val = bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(bounds); } } } if (flag) { Transform transform = ((Component)part.Phys).transform; part.VisualCenterOffset = Quaternion.Inverse(transform.rotation) * (((Bounds)(ref val)).center - transform.position); part.VisualSize = ((Bounds)(ref val)).size; if (!part.LongAxisCalibrated) { Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(Mathf.Abs(Vector3.Dot(((Bounds)(ref val)).size, transform.right)), Mathf.Abs(Vector3.Dot(((Bounds)(ref val)).size, transform.up)), Mathf.Abs(Vector3.Dot(((Bounds)(ref val)).size, transform.forward))); part.LongAxisLocal = ((val3.x >= val3.y && val3.x >= val3.z) ? Vector3.right : ((val3.y >= val3.z) ? Vector3.up : Vector3.forward)); part.LongAxisCalibrated = true; } } } internal static void Destroy(SpawnedEffigyPart part) { if (!((Object)(object)part?.Root == (Object)null)) { if (GameManager.Multiplayer()) { PhotonNetwork.Destroy(part.Root); } else { Object.Destroy((Object)(object)part.Root); } part.Alive = false; } } } internal static class EncounterTuning { internal const float RewardDelaySeconds = 0.08f; } internal static class EncounterValuableNeutralizer { private const BindingFlags InstanceFields = BindingFlags.Instance | BindingFlags.NonPublic; private static readonly FieldInfo DollarValueOriginal = typeof(ValuableObject).GetField("dollarValueOriginal", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo DollarValueCurrent = typeof(ValuableObject).GetField("dollarValueCurrent", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo DollarValueSet = typeof(ValuableObject).GetField("dollarValueSet", BindingFlags.Instance | BindingFlags.NonPublic); internal static void Apply(GameObject root) { if (!((Object)(object)root == (Object)null)) { ValuableObject[] componentsInChildren = root.GetComponentsInChildren(true); foreach (ValuableObject obj in componentsInChildren) { DollarValueOriginal?.SetValue(obj, 0f); DollarValueCurrent?.SetValue(obj, 0f); DollarValueSet?.SetValue(obj, true); } } } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "Update")] internal static class EncounterValuableUiPatch { private static void Postfix(PhysGrabObjectImpactDetector __instance) { if ((Object)(object)__instance != (Object)null && (Object)(object)((Component)__instance).GetComponentInParent() != (Object)null) { __instance.inCart = true; } } } internal static class EnemyLabBridge { private const string ApiTypeName = "UnknownEnemyLab.EnemyLabApi, UnknownEnemyLab"; private static readonly string CarouselEncounterId = "unknown.REPO.TheCarousel.Carousel"; private static readonly string WeepingAngelEncounterId = "unknown.REPO.TheCarousel.WeepingAngel"; private static readonly string DeadAirEncounterId = "unknown.REPO.TheCarousel.DeadAir"; private static readonly string BrokerEncounterId = "unknown.REPO.TheCarousel.Broker"; private static readonly string BellhopEncounterId = "unknown.REPO.TheCarousel.Bellhop"; private static readonly string VoodooEncounterId = "unknown.REPO.TheCarousel.Voodoo"; private static readonly string AnatomistEncounterId = "unknown.REPO.TheCarousel.Anatomist"; private static readonly string ParasiteEncounterId = "unknown.REPO.TheCarousel.Parasite"; private static readonly string AuditorEncounterId = "unknown.REPO.TheCarousel.Auditor"; private static readonly string PlaybackEncounterId = "unknown.REPO.TheCarousel.Backlash"; private static readonly string MimicEncounterId = "unknown.REPO.TheCarousel.Mimic"; private static readonly string ConfectionerEncounterId = "unknown.REPO.TheCarousel.Confectioner"; private static readonly string UndertowEncounterId = "unknown.REPO.TheCarousel.Undertow"; private static readonly string CupidEncounterId = "unknown.REPO.TheCarousel.Cupid"; private static readonly string MarionetteEncounterId = "unknown.REPO.TheCarousel.Marionette"; private static readonly string DeliriumEncounterId = "unknown.REPO.TheCarousel.Delirium"; private static readonly string DeliriumBerserkEncounterId = "unknown.REPO.TheCarousel.DeliriumBerserk"; private static readonly string ImitatorPlayerAvatarLabEncounterId = "unknown.REPO.TheCarousel.ImitatorPlayerAvatarLab"; internal static bool IsAvailable() { return Type.GetType("UnknownEnemyLab.EnemyLabApi, UnknownEnemyLab", throwOnError: false) != null; } internal static void TryRegister(CarouselManager carouselManager, EffigyManager effigyManager, DeadAirManager deadAirManager, BrokerManager brokerManager, BellhopManager bellhopManager, VoodooManager voodooManager, AnatomistManager anatomistManager, ParasiteManager parasiteManager, AuditorManager auditorManager, PlaybackManager playbackManager, MimicManager mimicManager, ConfectionerManager confectionerManager, UndertowManager undertowManager, CupidManager cupidManager, MarionetteManager marionetteManager, DeliriumManager deliriumManager, ImitatorPlayerAvatarLabManager imitatorPlayerAvatarLabManager) { if ((Object)(object)carouselManager == (Object)null || (Object)(object)effigyManager == (Object)null || (Object)(object)deadAirManager == (Object)null || (Object)(object)brokerManager == (Object)null || (Object)(object)bellhopManager == (Object)null || (Object)(object)anatomistManager == (Object)null || (Object)(object)parasiteManager == (Object)null || (Object)(object)auditorManager == (Object)null || (Object)(object)playbackManager == (Object)null || (Object)(object)mimicManager == (Object)null || (Object)(object)confectionerManager == (Object)null || (Object)(object)undertowManager == (Object)null || (Object)(object)cupidManager == (Object)null || (Object)(object)marionetteManager == (Object)null) { return; } try { MethodInfo methodInfo = Type.GetType("UnknownEnemyLab.EnemyLabApi, UnknownEnemyLab", throwOnError: false)?.GetMethod("RegisterEncounter", BindingFlags.Static | BindingFlags.Public); UncataloguedDebugApi.Clear(); RegisterEncounter(methodInfo, CarouselEncounterId, "The Carousel", carouselManager.DebugSpawnAt, carouselManager.DebugDespawn); RegisterEncounter(methodInfo, WeepingAngelEncounterId, "The Weeping Angel", effigyManager.DebugSpawnAt, effigyManager.DebugDespawn); RegisterEncounter(methodInfo, DeadAirEncounterId, "The Dead Air", deadAirManager.DebugSpawnAt, deadAirManager.DebugDespawn); RegisterEncounter(methodInfo, BrokerEncounterId, "The Broker", brokerManager.DebugSpawnAt, brokerManager.DebugDespawn); RegisterEncounter(methodInfo, BellhopEncounterId, "The Bellhop", bellhopManager.DebugSpawnAt, bellhopManager.DebugDespawn); RegisterEncounter(methodInfo, AnatomistEncounterId, "The Anatomist", anatomistManager.DebugSpawnAt, anatomistManager.DebugDespawn); RegisterEncounter(methodInfo, ParasiteEncounterId, "The Parasite", parasiteManager.DebugSpawnAt, parasiteManager.DebugDespawn); RegisterEncounter(methodInfo, AuditorEncounterId, "The Auditor", auditorManager.DebugSpawnAt, auditorManager.DebugDespawn); RegisterEncounter(methodInfo, PlaybackEncounterId, "The Backlash", playbackManager.DebugSpawnAt, playbackManager.DebugDespawn); RegisterEncounter(methodInfo, MimicEncounterId, "The Mimic", mimicManager.DebugSpawnAt, mimicManager.DebugDespawn); RegisterEncounter(methodInfo, ConfectionerEncounterId, "The Confectioner", confectionerManager.DebugSpawnAt, confectionerManager.DebugDespawn); RegisterEncounter(methodInfo, UndertowEncounterId, "The Undertow", undertowManager.DebugSpawnAt, undertowManager.DebugDespawn); RegisterEncounter(methodInfo, CupidEncounterId, "The Cupid", cupidManager.DebugSpawnAt, cupidManager.DebugDespawn); RegisterEncounter(methodInfo, MarionetteEncounterId, "The Marionette", marionetteManager.DebugSpawnAt, marionetteManager.DebugDespawn); Plugin.Log.LogInfo((object)("The Uncatalogued registered fourteen public debug encounters; Unknown Enemy Lab=" + ((methodInfo != null) ? "connected" : "not installed") + ". Voodoo, Delirium and the network PlayerAvatar experiment remain WIP/offline.")); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"Could not register with Unknown Enemy Lab: {arg}"); } } private static void RegisterEncounter(MethodInfo register, string encounterId, string displayName, Func spawn, Action despawn) { UncataloguedDebugApi.Register(encounterId, displayName, spawn, despawn); if (register == null) { return; } try { register.Invoke(null, new object[4] { encounterId, displayName, spawn, despawn }); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Unknown Enemy Lab registration failed for " + displayName + ": " + ex.Message)); } } internal static void TryUnregister() { UncataloguedDebugApi.Clear(); try { MethodInfo methodInfo = Type.GetType("UnknownEnemyLab.EnemyLabApi, UnknownEnemyLab", throwOnError: false)?.GetMethod("UnregisterEncounter", BindingFlags.Static | BindingFlags.Public); methodInfo?.Invoke(null, new object[1] { CarouselEncounterId }); methodInfo?.Invoke(null, new object[1] { WeepingAngelEncounterId }); methodInfo?.Invoke(null, new object[1] { DeadAirEncounterId }); methodInfo?.Invoke(null, new object[1] { BrokerEncounterId }); methodInfo?.Invoke(null, new object[1] { BellhopEncounterId }); methodInfo?.Invoke(null, new object[1] { VoodooEncounterId }); methodInfo?.Invoke(null, new object[1] { AnatomistEncounterId }); methodInfo?.Invoke(null, new object[1] { ParasiteEncounterId }); methodInfo?.Invoke(null, new object[1] { AuditorEncounterId }); methodInfo?.Invoke(null, new object[1] { PlaybackEncounterId }); methodInfo?.Invoke(null, new object[1] { MimicEncounterId }); methodInfo?.Invoke(null, new object[1] { ConfectionerEncounterId }); methodInfo?.Invoke(null, new object[1] { UndertowEncounterId }); methodInfo?.Invoke(null, new object[1] { CupidEncounterId }); methodInfo?.Invoke(null, new object[1] { MarionetteEncounterId }); methodInfo?.Invoke(null, new object[1] { DeliriumEncounterId }); methodInfo?.Invoke(null, new object[1] { DeliriumBerserkEncounterId }); methodInfo?.Invoke(null, new object[1] { ImitatorPlayerAvatarLabEncounterId }); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)("Enemy Lab unregister skipped: " + ex.Message)); } } } internal static bool IsExecutionHitNear(Vector3 position) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) try { MethodInfo methodInfo = Type.GetType("UnknownEnemyLab.EnemyLabApi, UnknownEnemyLab", throwOnError: false)?.GetMethod("IsExecutionHitNear", BindingFlags.Static | BindingFlags.Public); bool flag = default(bool); int num; if (methodInfo != null) { object obj = methodInfo.Invoke(null, new object[2] { position, 1.5f }); if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)("Enemy Lab execution-hit check skipped: " + ex.Message)); } return false; } } } internal sealed class CarouselVisualBulletMarker : MonoBehaviour { } internal static class GunAccess { private static readonly FieldInfo BatteryLifeIntField = FindInstanceField(typeof(ItemBattery), "batteryLifeInt"); private static readonly FieldInfo PlayerDisabledField = FindInstanceField(typeof(PlayerAvatar), "isDisabled"); private static readonly FieldInfo PlayerDeadField = FindInstanceField(typeof(PlayerAvatar), "deadSet"); private static readonly FieldInfo BulletHitField = FindInstanceField(typeof(ItemGunBullet), "bulletHit"); private static readonly FieldInfo BulletHitPositionField = FindInstanceField(typeof(ItemGunBullet), "hitPosition"); private static readonly FieldInfo BulletLineCurveField = FindInstanceField(typeof(ItemGunBullet), "shootLineWidthCurve"); private static FieldInfo FindInstanceField(Type type, string name) { return type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } internal static void Refill(ItemBattery battery) { if (!((Object)(object)battery == (Object)null)) { battery.autoDrain = false; battery.batteryLife = 100f; BatteryLifeIntField?.SetValue(battery, battery.batteryBars); } } internal static bool IsLiving(PlayerAvatar player) { if ((Object)(object)player == (Object)null || !((Component)player).gameObject.activeInHierarchy) { return false; } bool num = PlayerDisabledField != null && (bool)PlayerDisabledField.GetValue(player); bool flag = PlayerDeadField != null && (bool)PlayerDeadField.GetValue(player); if (!num && !flag) { return !LateJoinSafety.IsProtected(player); } return false; } internal static bool TryGetPlayerBounds(PlayerAvatar player, out Bounds bounds) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b3: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) PlayerController instance = PlayerController.instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.playerAvatarScript == (Object)(object)player && (Object)(object)instance.col != (Object)null) { bounds = instance.col.bounds; return true; } PlayerAvatarCollision val = ((player != null) ? ((Component)player).GetComponentInChildren(true) : null); if ((Object)(object)val?.Collider != (Object)null) { bounds = ((Collider)val.Collider).bounds; return true; } Collider val2 = ((player != null) ? ((Component)player).GetComponentInChildren(true) : null); if ((Object)(object)val2 != (Object)null) { bounds = val2.bounds; return true; } bounds = (((Object)(object)player != (Object)null) ? new Bounds(((Component)player).transform.position + Vector3.up, Vector3.one) : default(Bounds)); return (Object)(object)player != (Object)null; } internal static bool PlayHarmlessShot(ItemGun gun, Vector3 direction, Vector3 endPosition) { //IL_004d: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0181: 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_01ec: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gun?.gunMuzzle == (Object)null || (Object)(object)gun.bulletPrefab == (Object)null || ((Vector3)(ref direction)).sqrMagnitude < 0.01f) { return false; } Transform gunMuzzle = gun.gunMuzzle; ((Vector3)(ref direction)).Normalize(); Sound soundShoot = gun.soundShoot; if (soundShoot != null) { soundShoot.Play(gunMuzzle.position, 1f, 1f, 1f, 1f); } Sound soundShootGlobal = gun.soundShootGlobal; if (soundShootGlobal != null) { soundShootGlobal.Play(gunMuzzle.position, 1f, 1f, 1f, 1f); } if ((Object)(object)gun.muzzleFlashPrefab != (Object)null) { ItemGunMuzzleFlash component = Object.Instantiate(gun.muzzleFlashPrefab, gunMuzzle.position, Quaternion.LookRotation(direction), gunMuzzle).GetComponent(); if (component != null) { component.ActivateAllEffects(); } } Vector3 val = endPosition - gunMuzzle.position; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { endPosition = gunMuzzle.position + direction * Mathf.Max(5f, gun.gunRange); } if (SemiFunc.IsMultiplayer()) { PhotonView componentInParent = ((Component)gun).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && componentInParent.ViewID > 0) { componentInParent.RPC("ShootBulletRPC", (RpcTarget)0, new object[3] { endPosition, false, -1 }); return true; } GameObject val2 = Object.Instantiate(gun.bulletPrefab, gunMuzzle.position, Quaternion.LookRotation(direction)); val2.AddComponent(); ItemGunBullet component2 = val2.GetComponent(); if ((Object)(object)component2 == (Object)null) { Object.Destroy((Object)(object)val2); return false; } HurtCollider[] componentsInChildren = val2.GetComponentsInChildren(true); foreach (HurtCollider obj in componentsInChildren) { obj.playerLogic = false; obj.physLogic = false; obj.enemyLogic = false; } BulletHitPositionField?.SetValue(component2, endPosition); BulletHitField?.SetValue(component2, true); BulletLineCurveField?.SetValue(component2, gun.shootLineWidthCurve); component2.ActivateAll(); return true; } gun.ShootBulletRPC(endPosition, false, -1, default(PhotonMessageInfo)); return true; } } internal sealed class GunHitProxy : MonoBehaviour { private CarouselController _controller; private int _gunIndex; private PhysGrabObjectImpactDetector _impactDetector; private Renderer[] _renderers; private float _cooldown; private readonly Dictionary _previousBulletPositions = new Dictionary(); private readonly HashSet _currentBulletIds = new HashSet(); private static int _cachedBulletFrame = -1; private static ItemGunBullet[] _cachedBullets = Array.Empty(); internal void Initialize(CarouselController controller, int gunIndex, PhysGrabObjectImpactDetector impactDetector, Renderer[] renderers) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown _controller = controller; _gunIndex = gunIndex; _impactDetector = impactDetector; _renderers = renderers ?? Array.Empty(); PhysGrabObjectImpactDetector impactDetector2 = _impactDetector; if (impactDetector2 != null) { UnityEvent onHurtColliderHit = impactDetector2.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.AddListener(new UnityAction(OnHurtColliderHit)); } } } private void Update() { if (_cooldown > 0f) { _cooldown -= Time.deltaTime; } if (_cooldown <= 0f && SemiFunc.IsMasterClientOrSingleplayer()) { DetectExpandedBulletHit(); } } private void OnDestroy() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown PhysGrabObjectImpactDetector impactDetector = _impactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.RemoveListener(new UnityAction(OnHurtColliderHit)); } } } private void OnHurtColliderHit() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_controller == (Object)null || _cooldown > 0f || !SemiFunc.IsMasterClientOrSingleplayer() || !_controller.TryClaimWeaponHit(ModEnemyWeaponDamage.CurrentClaimId)) { return; } _cooldown = 0.18f; if (EnemyLabBridge.IsExecutionHitNear(((Object)(object)_impactDetector != (Object)null) ? ((Component)_impactDetector).transform.position : ((Component)this).transform.position)) { _controller.ExecuteForLab(); return; } int num = ModEnemyWeaponDamage.CurrentOrFallback(Plugin.Settings.DamagePerHit.Value); if (num > 0) { _controller.HurtGun(_gunIndex, num); } } private void DetectExpandedBulletHit() { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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) if ((Object)(object)_controller == (Object)null) { return; } if (_cachedBulletFrame != Time.frameCount) { _cachedBulletFrame = Time.frameCount; _cachedBullets = Object.FindObjectsOfType(); } _currentBulletIds.Clear(); ItemGunBullet[] cachedBullets = _cachedBullets; foreach (ItemGunBullet val in cachedBullets) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent() != (Object)null) { continue; } HurtCollider val2 = val?.hurtCollider; if ((Object)(object)val2 == (Object)null || !((Component)val2).gameObject.activeInHierarchy) { continue; } int instanceID = ((Object)val).GetInstanceID(); _currentBulletIds.Add(instanceID); Vector3 position = ((Component)val2).transform.position; Vector3 value; bool num = _previousBulletPositions.TryGetValue(instanceID, out value); _previousBulletPositions[instanceID] = position; if (!(num ? SegmentIntersectsExpandedVisualBounds(value, position) : WithinExpandedVisualBounds(position)) || !_controller.TryClaimWeaponHit(instanceID)) { continue; } _cooldown = 0.35f; _controller.ReportExpandedHit(); if (EnemyLabBridge.IsExecutionHitNear(((Component)val2).transform.position)) { _controller.ExecuteForLab(); return; } int num2 = ModEnemyWeaponDamage.Resolve(val2, Plugin.Settings.DamagePerHit.Value); if (num2 > 0) { _controller.HurtGun(_gunIndex, num2); } return; } if (_previousBulletPositions.Count <= _currentBulletIds.Count) { return; } List list = null; foreach (int key in _previousBulletPositions.Keys) { if (!_currentBulletIds.Contains(key)) { if (list == null) { list = new List(); } list.Add(key); } } foreach (int item in list ?? new List()) { _previousBulletPositions.Remove(item); } } private bool WithinExpandedVisualBounds(Vector3 hitPosition) { //IL_00ac: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Mathf.Max(0.82f, Plugin.Settings.HitDetectionPadding.Value), 0.82f, 1.3f); float num2 = num * num; Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if ((Object)(object)val != (Object)null && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; if (((Bounds)(ref bounds)).SqrDistance(hitPosition) <= num2) { return true; } } } Vector3 val2 = (((Object)(object)_impactDetector != (Object)null) ? ((Component)_impactDetector).transform.position : ((Component)this).transform.position); float num3 = 0.45f + num; Vector3 val3 = hitPosition - val2; return ((Vector3)(ref val3)).sqrMagnitude <= num3 * num3; } private bool SegmentIntersectsExpandedVisualBounds(Vector3 start, Vector3 end) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_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_0073: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Mathf.Max(0.82f, Plugin.Settings.HitDetectionPadding.Value), 0.82f, 1.3f); Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if (!((Object)(object)val == (Object)null) && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; ((Bounds)(ref bounds)).Expand(num * 2f); if (SegmentIntersectsBounds(start, end, bounds)) { return true; } } } Vector3 point = (((Object)(object)_impactDetector != (Object)null) ? ((Component)_impactDetector).transform.position : ((Component)this).transform.position); float num2 = 0.45f + num; return DistancePointToSegmentSquared(point, start, end) <= num2 * num2; } private static bool SegmentIntersectsBounds(Vector3 start, Vector3 end, Bounds bounds) { //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) //IL_0002: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 val = end - start; float num = 0f; float num2 = 1f; for (int i = 0; i < 3; i++) { float num3 = ((Vector3)(ref start))[i]; float num4 = ((Vector3)(ref val))[i]; Vector3 val2 = ((Bounds)(ref bounds)).min; float num5 = ((Vector3)(ref val2))[i]; val2 = ((Bounds)(ref bounds)).max; float num6 = ((Vector3)(ref val2))[i]; if (Mathf.Abs(num4) < 1E-05f) { if (num3 < num5 || num3 > num6) { return false; } continue; } float num7 = 1f / num4; float num8 = (num5 - num3) * num7; float num9 = (num6 - num3) * num7; if (num8 > num9) { float num10 = num9; num9 = num8; num8 = num10; } num = Mathf.Max(num, num8); num2 = Mathf.Min(num2, num9); if (num > num2) { return false; } } return true; } private static float DistancePointToSegmentSquared(Vector3 point, Vector3 start, Vector3 end) { //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) //IL_0002: 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_0029: 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_002b: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_004e: 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) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; Vector3 val2; if (sqrMagnitude <= 1E-06f) { val2 = point - start; return ((Vector3)(ref val2)).sqrMagnitude; } float num = Mathf.Clamp01(Vector3.Dot(point - start, val) / sqrMagnitude); Vector3 val3 = start + val * num; val2 = point - val3; return ((Vector3)(ref val2)).sqrMagnitude; } } internal sealed class ImitatorPlayerAvatarLabManager : MonoBehaviour { private GameObject _root; private ImitatorPlayerAvatarLabController _controller; private int _sceneHandle = -1; private bool _guestVisualCandidatesLogged; internal void Tick() { //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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 if ((Object)(object)_root == (Object)null) { _controller = null; return; } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).handle != _sceneHandle || !ModEnemyLevelRules.IsPlayableLevel() || (Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated || (Object)(object)GameDirector.instance == (Object)null || (int)GameDirector.instance.currentState != 2 || ((Object)(object)_controller != (Object)null && _controller.Expired)) { DestroyCurrent("automatic safety cleanup"); } } internal bool DebugSpawnAt(Vector3 requested) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0198: 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) if (!EnemyLabBridge.IsAvailable() || !IsHostReady() || !ModEnemyLevelRules.IsPlayableLevel() || (Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated || (Object)(object)NetworkManager.instance == (Object)null || (Object)(object)NetworkManager.instance.playerAvatarPrefab == (Object)null || !GameManager.Multiplayer() || !PhotonNetwork.InRoom) { Plugin.Log.LogWarning((object)"PlayerAvatar Network Lab requires a generated multiplayer host level and Unknown Enemy Lab."); return false; } Vector3 val = requested; NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(requested, ref val2, 8f, -1)) { val = ((NavMeshHit)(ref val2)).position; } DestroyCurrent("replacement"); GameObject playerAvatarPrefab = NetworkManager.instance.playerAvatarPrefab; GameObject val3 = null; try { ImitatorPlayerAvatarLabRegistry.BeginSpawn(); val3 = PhotonNetwork.InstantiateRoomObject(((Object)playerAvatarPrefab).name, val, Quaternion.identity, (byte)0, new object[2] { "__UNCATALOGUED_PLAYER_AVATAR_NETWORK_LAB_V1__", Environment.TickCount }); } catch (Exception arg) { Plugin.Log.LogError((object)$"PlayerAvatar Network Lab could not instantiate the room-owned Semibot prefab: {arg}"); if ((Object)(object)val3 != (Object)null) { Object.Destroy((Object)(object)val3); } return false; } finally { ImitatorPlayerAvatarLabRegistry.EndSpawn(); } PlayerAvatar val4 = val3.GetComponent() ?? val3.GetComponentInChildren(true); if ((Object)(object)val4 == (Object)null) { Plugin.Log.LogWarning((object)"PlayerAvatar Network Lab instantiated the configured prefab but found no PlayerAvatar component."); TryDestroyNetworkObject(val3); return false; } ImitatorPlayerAvatarLabRegistry.Register(val4, managed: true); _root = val3; ((Object)_root).name = "The Imitator - Genuine PlayerAvatar Network Lab"; _controller = _root.AddComponent(); if (!_controller.Initialize(val4, val, networked: true)) { DestroyCurrent("initialization failure"); return false; } ImitatorPlayerAvatarLabRegistry.AttachController(val4, _controller); Scene activeScene = SceneManager.GetActiveScene(); _sceneHandle = ((Scene)(ref activeScene)).handle; LogGuestVisibleVisualCandidates(); LogNetworkProbeState(val4); Plugin.Log.LogWarning((object)"PlayerAvatar Network Lab spawned ONE room-owned genuine Semibot for 30 seconds with host collision disabled and the prefab's default colour. It is Enemy-Lab-only and never enters automatic spawning. WARNING: unmodified guests will temporarily add the probe to their vanilla PlayerList; check map/spectator/player UI and late joining."); return true; } private static void LogNetworkProbeState(PlayerAvatar avatar) { try { PhotonView[] componentsInChildren = ((Component)((Component)avatar).transform.root).GetComponentsInChildren(true); List list = new List(); PhotonView[] array = componentsInChildren; foreach (PhotonView val in array) { if ((Object)(object)val == (Object)null) { continue; } if (val.ObservedComponents != null) { foreach (Component observedComponent in val.ObservedComponents) { list.Add(((Object)(object)observedComponent != (Object)null) ? ((object)observedComponent).GetType().Name : "null"); } } Plugin.Log.LogInfo((object)($"PlayerAvatar Network Lab PhotonView: view={val.ViewID}, " + "owner=" + ((val.Owner != null) ? val.Owner.ActorNumber.ToString() : "room") + ", controller=" + ((val.Controller != null) ? val.Controller.ActorNumber.ToString() : "none") + ", " + $"isMine={val.IsMine}, observed={val.ObservedComponents?.Count ?? 0}.")); } Plugin.Log.LogInfo((object)("PlayerAvatar Network Lab observable stream: [" + string.Join(", ", list) + "].")); } catch (Exception ex) { Plugin.Log.LogWarning((object)("PlayerAvatar Network Lab could not inspect its PhotonView: " + ex.Message)); } } private void LogGuestVisibleVisualCandidates() { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) if (_guestVisualCandidatesLogged) { return; } _guestVisualCandidatesLogged = true; try { PlayerAvatarMenu[] array = Resources.FindObjectsOfTypeAll(); Plugin.Log.LogInfo((object)$"PlayerAvatar Lab guest-visual scan found {array.Length} PlayerAvatarMenu candidate(s)."); int num = Mathf.Min(array.Length, 16); for (int i = 0; i < num; i++) { PlayerAvatarMenu val = array[i]; if (!((Object)(object)val == (Object)null)) { GameObject gameObject = ((Component)((Component)val).transform.root).gameObject; PhotonView componentInChildren = gameObject.GetComponentInChildren(true); ManualLogSource log = Plugin.Log; string[] obj = new string[11] { $"PlayerAvatar Lab guest-visual candidate {i}: ", "object='", ((Object)val).name, "', root='", ((Object)gameObject).name, "', ", $"worldAvatar={val.worldAvatar}, ", null, null, null, null }; Scene scene = gameObject.scene; obj[7] = $"sceneValid={((Scene)(ref scene)).IsValid()}, "; obj[8] = "photonView="; obj[9] = (((Object)(object)componentInChildren != (Object)null) ? componentInChildren.ViewID.ToString() : "none"); obj[10] = "."; log.LogInfo((object)string.Concat(obj)); } } GameObject val2 = NetworkManager.instance?.playerAvatarPrefab; if ((Object)(object)val2 != (Object)null) { PhotonView componentInChildren2 = val2.GetComponentInChildren(true); Plugin.Log.LogInfo((object)("PlayerAvatar Lab configured network prefab: '" + ((Object)val2).name + "', " + $"PlayerAvatarMenu={(Object)(object)val2.GetComponentInChildren(true) != (Object)null}, " + $"PhotonView={(Object)(object)componentInChildren2 != (Object)null}.")); } IPunPrefabPool prefabPool = PhotonNetwork.PrefabPool; DefaultPool val3 = (DefaultPool)(object)((prefabPool is DefaultPool) ? prefabPool : null); if (val3 != null) { int num2 = 0; foreach (KeyValuePair item in val3.ResourceCache) { GameObject value = item.Value; if (!((Object)(object)value == (Object)null) && (!((Object)(object)value.GetComponentInChildren(true) == (Object)null) || !((Object)(object)value.GetComponentInChildren(true) == (Object)null))) { num2++; Plugin.Log.LogInfo((object)("PlayerAvatar Lab PUN visual prefab: key='" + item.Key + "', root='" + ((Object)value).name + "', " + $"PlayerAvatar={(Object)(object)value.GetComponentInChildren(true) != (Object)null}, " + $"PlayerAvatarMenu={(Object)(object)value.GetComponentInChildren(true) != (Object)null}.")); } } Plugin.Log.LogInfo((object)$"PlayerAvatar Lab PUN cache contained {num2} Semibot visual candidate(s)."); return; } object prefabPool2 = PhotonNetwork.PrefabPool; Type type = prefabPool2?.GetType(); Plugin.Log.LogInfo((object)("PlayerAvatar Lab PUN pool type: '" + (type?.FullName ?? "null") + "' (custom pool).")); int num3 = 0; if (prefabPool2 != null && type != null) { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { object value2; try { value2 = fieldInfo.GetValue(prefabPool2); } catch { continue; } if (!(value2 is IDictionary dictionary)) { continue; } foreach (DictionaryEntry item2 in dictionary) { object? value3 = item2.Value; GameObject val4 = (GameObject)((value3 is GameObject) ? value3 : null); if (val4 != null && !((Object)(object)val4 == (Object)null) && (!((Object)(object)val4.GetComponentInChildren(true) == (Object)null) || !((Object)(object)val4.GetComponentInChildren(true) == (Object)null))) { num3++; Plugin.Log.LogInfo((object)("PlayerAvatar Lab custom-pool visual prefab: " + $"field='{fieldInfo.Name}', key='{item2.Key}', root='{((Object)val4).name}', " + $"PlayerAvatar={(Object)(object)val4.GetComponentInChildren(true) != (Object)null}, " + $"PlayerAvatarMenu={(Object)(object)val4.GetComponentInChildren(true) != (Object)null}.")); } } } } Plugin.Log.LogInfo((object)$"PlayerAvatar Lab custom PUN pool exposed {num3} Semibot visual candidate(s)."); } catch (Exception ex) { Plugin.Log.LogDebug((object)("PlayerAvatar Lab guest-visual candidate scan was unavailable: " + ex.Message)); } } internal void DebugDespawn() { DestroyCurrent("Enemy Lab despawn"); } private void DestroyCurrent(string reason) { if ((Object)(object)_root != (Object)null) { Plugin.Log.LogInfo((object)("PlayerAvatar Network Lab removed its room-owned Semibot (" + reason + ").")); ImitatorPlayerAvatarLabRegistry.Unregister(_root.GetComponent() ?? _root.GetComponentInChildren(true)); TryDestroyNetworkObject(_root); } _root = null; _controller = null; } private static void TryDestroyNetworkObject(GameObject root) { if ((Object)(object)root == (Object)null) { return; } try { PhotonView val = root.GetComponent() ?? root.GetComponentInChildren(true); if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient && (Object)(object)val != (Object)null && val.ViewID != 0) { PhotonNetwork.Destroy(root); return; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("PlayerAvatar Network Lab network deletion failed; using local cleanup: " + ex.Message)); } root.SetActive(false); Object.Destroy((Object)(object)root); } private static bool IsHostReady() { try { return (Object)(object)GameManager.instance != (Object)null && (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient); } catch { return false; } } } internal sealed class ImitatorPlayerAvatarLabController : MonoBehaviour { private static readonly FieldInfo AvatarIsLocal = AccessTools.Field(typeof(PlayerAvatar), "isLocal"); private static readonly FieldInfo AvatarIsMoving = AccessTools.Field(typeof(PlayerAvatar), "isMoving"); private static readonly FieldInfo AvatarIsSprinting = AccessTools.Field(typeof(PlayerAvatar), "isSprinting"); private static readonly FieldInfo AvatarIsGrounded = AccessTools.Field(typeof(PlayerAvatar), "isGrounded"); private static readonly FieldInfo AvatarInputRaw = AccessTools.Field(typeof(PlayerAvatar), "InputDirectionRaw"); private static readonly FieldInfo AvatarRbVelocity = AccessTools.Field(typeof(PlayerAvatar), "rbVelocity"); private static readonly FieldInfo AvatarRbVelocityRaw = AccessTools.Field(typeof(PlayerAvatar), "rbVelocityRaw"); private static readonly FieldInfo AvatarClientPosition = AccessTools.Field(typeof(PlayerAvatar), "clientPosition"); private static readonly FieldInfo AvatarClientPositionCurrent = AccessTools.Field(typeof(PlayerAvatar), "clientPositionCurrent"); private static readonly FieldInfo AvatarClientRotation = AccessTools.Field(typeof(PlayerAvatar), "clientRotation"); private static readonly FieldInfo AvatarClientRotationCurrent = AccessTools.Field(typeof(PlayerAvatar), "clientRotationCurrent"); private static readonly FieldInfo AvatarRotationDisabled = AccessTools.Field(typeof(PlayerAvatar), "rotationDisabled"); private static readonly FieldInfo AvatarRotationOverrideActive = AccessTools.Field(typeof(PlayerAvatar), "rotationOverrideActive"); private static readonly FieldInfo AvatarSteamId = AccessTools.Field(typeof(PlayerAvatar), "steamID"); private static readonly FieldInfo AvatarPlayerName = AccessTools.Field(typeof(PlayerAvatar), "playerName"); private static readonly FieldInfo VisualPosition = AccessTools.Field(typeof(PlayerAvatarVisuals), "visualPosition"); private static readonly FieldInfo ShowSelfTimer = AccessTools.Field(typeof(PlayerAvatarVisuals), "showSelfOverrideTimer"); private static readonly FieldInfo CollisionScale = AccessTools.Field(typeof(PlayerAvatarCollision), "Scale"); private PlayerAvatar _avatar; private NavMeshAgent _agent; private float _lifeTimer = 30f; private float _decisionTimer; private float _poseTimer; private bool _studyingMap; private Vector3 _lastPosition; private Vector3 _wanderTarget; private float _serializationLogTimer; internal bool Expired => _lifeTimer <= 0f; internal bool Initialize(PlayerAvatar avatar, Vector3 position, bool networked) { //IL_005a: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_058b: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) //IL_05a4: Unknown result type (might be due to invalid IL or missing references) _avatar = avatar; if ((Object)(object)_avatar == (Object)null) { return false; } ((Behaviour)_avatar).enabled = false; SetField(AvatarIsLocal, _avatar, false); SetField(AvatarIsGrounded, _avatar, true); SetField(AvatarClientPosition, _avatar, position); SetField(AvatarClientPositionCurrent, _avatar, position); SetField(AvatarClientRotation, _avatar, Quaternion.identity); SetField(AvatarClientRotationCurrent, _avatar, Quaternion.identity); SetField(AvatarRotationDisabled, _avatar, true); SetField(AvatarRotationOverrideActive, _avatar, true); SetField(AvatarSteamId, _avatar, "__UNCATALOGUED_PLAYER_AVATAR_LAB__"); SetField(AvatarPlayerName, _avatar, "Imitator Lab"); if ((Object)(object)StatsManager.instance != (Object)null && !StatsManager.instance.playerUpgradeSpeed.ContainsKey("__UNCATALOGUED_PLAYER_AVATAR_LAB__")) { StatsManager.instance.playerUpgradeSpeed.Add("__UNCATALOGUED_PLAYER_AVATAR_LAB__", 0); } PhotonView[] componentsInChildren = ((Component)((Component)this).transform).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Behaviour)componentsInChildren[i]).enabled = networked; } DisableGameplayComponents(); DisableGameplayComponents(); DisableGameplayComponents(); DisableGameplayComponents(); DisableGameplayComponents(); DisableGameplayComponents(); DisableGameplayComponents(); DisableGameplayComponents(); PlayerAvatarCollision[] componentsInChildren2 = ((Component)((Component)this).transform).GetComponentsInChildren(true); foreach (PlayerAvatarCollision val in componentsInChildren2) { if (!((Object)(object)val == (Object)null)) { SetField(CollisionScale, val, Vector3.zero); if ((Object)(object)val.CollisionTransform != (Object)null) { val.CollisionTransform.localScale = Vector3.zero; } if ((Object)(object)val.Collider != (Object)null) { ((Collider)val.Collider).enabled = false; } } } MapToolController[] componentsInChildren3 = ((Component)((Component)this).transform).GetComponentsInChildren(true); foreach (MapToolController val2 in componentsInChildren3) { if (!((Object)(object)val2 == (Object)null)) { if ((Object)(object)val2.VisualTransform != (Object)null) { ((Component)val2.VisualTransform).gameObject.SetActive(false); } if ((Object)(object)val2.DisplayMesh != (Object)null) { ((Renderer)val2.DisplayMesh).enabled = false; } if ((Object)(object)val2.StickMesh != (Object)null) { ((Renderer)val2.StickMesh).enabled = false; } if ((Object)(object)val2.MainUnitMesh != (Object)null) { ((Renderer)val2.MainUnitMesh).enabled = false; } } } FlashlightController[] componentsInChildren4 = ((Component)((Component)this).transform).GetComponentsInChildren(true); foreach (FlashlightController val3 in componentsInChildren4) { if (!((Object)(object)val3 == (Object)null)) { val3.LightActive = false; if ((Object)(object)val3.mesh != (Object)null) { ((Renderer)val3.mesh).enabled = false; } if ((Object)(object)val3.meshShadows != (Object)null) { ((Renderer)val3.meshShadows).enabled = false; } if ((Object)(object)val3.spotlight != (Object)null) { ((Behaviour)val3.spotlight).enabled = false; } if ((Object)(object)val3.halo != (Object)null) { val3.halo.enabled = false; } } } int num = LayerMask.NameToLayer("Ignore Raycast"); Collider[] componentsInChildren5 = ((Component)((Component)this).transform).GetComponentsInChildren(true); foreach (Collider val4 in componentsInChildren5) { val4.enabled = false; if (num >= 0) { ((Component)val4).gameObject.layer = num; } } Rigidbody[] componentsInChildren6 = ((Component)((Component)this).transform).GetComponentsInChildren(true); foreach (Rigidbody val5 in componentsInChildren6) { val5.detectCollisions = false; if (!val5.isKinematic) { val5.velocity = Vector3.zero; val5.angularVelocity = Vector3.zero; val5.isKinematic = true; } } LineRenderer[] componentsInChildren7 = ((Component)((Component)this).transform).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren7.Length; i++) { ((Renderer)componentsInChildren7[i]).enabled = false; } TrailRenderer[] componentsInChildren8 = ((Component)((Component)this).transform).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren8.Length; i++) { ((Renderer)componentsInChildren8[i]).enabled = false; } PlayerAvatarVisuals playerAvatarVisuals = _avatar.playerAvatarVisuals; object obj; if (playerAvatarVisuals == null) { obj = null; } else { GameObject animBotRoot = playerAvatarVisuals.animBotRoot; obj = ((animBotRoot != null) ? animBotRoot.transform : null); } Transform val6 = (Transform)obj; if ((Object)(object)val6 != (Object)null) { int num2 = 0; Renderer[] componentsInChildren9 = ((Component)((Component)this).transform).GetComponentsInChildren(true); foreach (Renderer val7 in componentsInChildren9) { if (!((Object)(object)val7 == (Object)null) && !((Object)(object)((Component)val7).transform == (Object)(object)val6) && !((Component)val7).transform.IsChildOf(val6)) { val7.enabled = false; num2++; } } Plugin.Log.LogInfo((object)$"PlayerAvatar Lab hid {num2} non-Semibot helper renderer(s)."); } _agent = ((Component)this).gameObject.GetComponent() ?? ((Component)this).gameObject.AddComponent(); _agent.speed = 1.65f; _agent.acceleration = 5.5f; _agent.angularSpeed = 260f; _agent.stoppingDistance = 2.2f; _agent.radius = 0.25f; _agent.height = 1.6f; _agent.updateRotation = true; _agent.Warp(position); _lastPosition = position; _wanderTarget = position; _decisionTimer = 0.5f; KeepVisualVisible(position, Quaternion.identity); return true; } private void Update() { //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: 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_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0247: 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_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_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0369: 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_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0387: 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_038e: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: 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_0455: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_avatar == (Object)null) { return; } _lifeTimer -= Time.deltaTime; _decisionTimer -= Time.deltaTime; _poseTimer -= Time.deltaTime; PlayerAvatar val = FindNearestRealPlayer(); if (_decisionTimer <= 0f) { _decisionTimer = Random.Range(2.2f, 4.2f); _studyingMap = Random.value < 0.28f; _poseTimer = (_studyingMap ? Random.Range(1f, 1.8f) : 0f); if (!_studyingMap && (Object)(object)val != (Object)null) { Vector3 val2 = -((Component)val).transform.forward * Random.Range(1.7f, 2.8f) + ((Component)val).transform.right * Random.Range(-1.2f, 1.2f); SetDestination(((Component)val).transform.position + val2); } else if (!_studyingMap) { Vector3 destination = ((Component)this).transform.position + Random.insideUnitSphere * 7f; destination.y = ((Component)this).transform.position.y; SetDestination(destination); } else if ((Object)(object)_agent != (Object)null && _agent.isOnNavMesh) { _agent.ResetPath(); } } if (!_studyingMap && (Object)(object)val != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) > 5.5f) { SetDestination(((Component)val).transform.position - ((Component)val).transform.forward * 2.2f); } Vector3 val3 = (((Component)this).transform.position - _lastPosition) / Mathf.Max(Time.deltaTime, 0.0001f); _lastPosition = ((Component)this).transform.position; bool flag = !_studyingMap && ((Vector3)(ref val3)).sqrMagnitude > 0.01f; Vector3 val4 = ((Component)this).transform.InverseTransformDirection(val3); SetField(AvatarIsMoving, _avatar, flag); SetField(AvatarIsSprinting, _avatar, ((Vector3)(ref val3)).magnitude > 2.2f); SetField(AvatarInputRaw, _avatar, flag ? ((Vector3)(ref val4)).normalized : Vector3.zero); SetField(AvatarRbVelocity, _avatar, val4); SetField(AvatarRbVelocityRaw, _avatar, val3); KeepVisualVisible(((Component)this).transform.position, ((Component)this).transform.rotation); Vector3 val5; if (!_studyingMap) { val5 = ((Component)this).transform.forward; } else { Vector3 val6 = ((Component)this).transform.forward + Vector3.down * 0.65f; val5 = ((Vector3)(ref val6)).normalized; } Vector3 val7 = val5; if ((Object)(object)_avatar.PlayerVisionTarget?.VisionTransform != (Object)null) { Transform visionTransform = _avatar.PlayerVisionTarget.VisionTransform; visionTransform.position = ((Component)this).transform.position + Vector3.up * 1.35f; visionTransform.rotation = Quaternion.LookRotation(val7, Vector3.up); } if ((Object)(object)_avatar.localCamera != (Object)null) { Transform transform = ((Component)_avatar.localCamera).transform; transform.position = ((Component)this).transform.position + Vector3.up * 1.35f; transform.rotation = Quaternion.LookRotation(val7, Vector3.up); } _serializationLogTimer -= Time.deltaTime; if (_serializationLogTimer <= 0f) { _serializationLogTimer = 5f; PhotonView photonView = _avatar.photonView; Plugin.Log.LogInfo((object)($"PlayerAvatar Network Lab heartbeat: view={((photonView != null) ? photonView.ViewID : 0)}, " + $"pos={((Component)this).transform.position}, moving={flag}, lifetime={Mathf.Max(0f, _lifeTimer):F1}s.")); } } private void LateUpdate() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) PlayerAvatarVisuals val = _avatar?.playerAvatarVisuals; if (!((Object)(object)val == (Object)null)) { if ((Object)(object)val.headUpTransform != (Object)null) { val.headUpTransform.localRotation = Quaternion.identity; } if ((Object)(object)val.bodyTopUpTransform != (Object)null) { val.bodyTopUpTransform.localRotation = Quaternion.identity; } if ((Object)(object)val.headSideTransform != (Object)null) { val.headSideTransform.localRotation = Quaternion.identity; } if ((Object)(object)val.bodyTopSideTransform != (Object)null) { val.bodyTopSideTransform.localRotation = Quaternion.identity; } } } private void KeepVisualVisible(Vector3 position, Quaternion rotation) { //IL_000b: 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_0037: 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_007b: Unknown result type (might be due to invalid IL or missing references) SetField(AvatarClientPosition, _avatar, position); SetField(AvatarClientPositionCurrent, _avatar, position); SetField(AvatarClientRotation, _avatar, rotation); SetField(AvatarClientRotationCurrent, _avatar, rotation); if ((Object)(object)_avatar.playerAvatarVisuals != (Object)null) { SetField(VisualPosition, _avatar.playerAvatarVisuals, position); SetField(ShowSelfTimer, _avatar.playerAvatarVisuals, 2f); } } private void SetDestination(Vector3 requested) { //IL_001c: 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_0034: 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) NavMeshHit val = default(NavMeshHit); if (!((Object)(object)_agent == (Object)null) && _agent.isOnNavMesh && NavMesh.SamplePosition(requested, ref val, 5f, -1)) { _wanderTarget = ((NavMeshHit)(ref val)).position; _agent.SetDestination(_wanderTarget); } } private PlayerAvatar FindNearestRealPlayer() { //IL_004a: 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_005f: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar result = null; float num = float.MaxValue; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (!((Object)(object)item == (Object)null) && !((Object)(object)item == (Object)(object)_avatar) && !ImitatorPlayerAvatarLabRegistry.IsLabAvatar(item) && GunAccess.IsLiving(item)) { Vector3 val = ((Component)item).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = item; } } } return result; } internal void WritePlayerAvatarStream(PhotonStream stream) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_00ff: Unknown result type (might be due to invalid IL or missing references) stream.SendNext((object)false); stream.SendNext((object)false); stream.SendNext((object)false); stream.SendNext((object)false); stream.SendNext((object)(bool)(AvatarIsMoving?.GetValue(_avatar) ?? ((object)false))); stream.SendNext((object)true); stream.SendNext((object)false); stream.SendNext((object)(Vector3)(AvatarInputRaw?.GetValue(_avatar) ?? ((object)Vector3.zero))); stream.SendNext((object)(Vector3)(AvatarRbVelocity?.GetValue(_avatar) ?? ((object)Vector3.zero))); stream.SendNext((object)(Vector3)(AvatarRbVelocityRaw?.GetValue(_avatar) ?? ((object)Vector3.zero))); stream.SendNext((object)((Component)this).transform.position); stream.SendNext((object)((Component)this).transform.rotation); stream.SendNext((object)true); stream.SendNext((object)true); stream.SendNext((object)false); stream.SendNext((object)0); stream.SendNext((object)Vector3.zero); stream.SendNext((object)false); stream.SendNext((object)0); } internal void WriteCollisionStream(PhotonStream stream) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) stream.SendNext((object)Vector3.zero); } internal void WriteLocalCameraStream(PhotonStream stream) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.position + Vector3.up * 1.35f; stream.SendNext((object)val); stream.SendNext((object)((Component)this).transform.rotation); stream.SendNext((object)false); stream.SendNext((object)false); } internal void WriteVisionStream(PhotonStream stream) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) stream.SendNext((object)0f); stream.SendNext((object)((Component)this).transform.rotation); } internal void WritePhysGrabberStream(PhotonStream stream) { //IL_0006: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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) //IL_003d: 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) Vector3 val = ((Component)this).transform.position + ((Component)this).transform.forward * 0.35f + Vector3.up; stream.SendNext((object)val); stream.SendNext((object)val); stream.SendNext((object)Vector3.zero); stream.SendNext((object)false); stream.SendNext((object)0); stream.SendNext((object)(byte)0); } private void DisableGameplayComponents() where T : Behaviour { T[] componentsInChildren = ((Component)((Component)this).transform).GetComponentsInChildren(true); foreach (T val in componentsInChildren) { if ((Object)(object)val != (Object)null) { ((Behaviour)val).enabled = false; } } } private static void SetField(FieldInfo field, object owner, object value) { if (field != null && owner != null) { field.SetValue(owner, value); } } } internal static class ImitatorPlayerAvatarLabRegistry { internal const string NetworkMarker = "__UNCATALOGUED_PLAYER_AVATAR_NETWORK_LAB_V1__"; private static readonly HashSet AvatarIds = new HashSet(); private static readonly HashSet ManagedAvatarIds = new HashSet(); private static readonly Dictionary Controllers = new Dictionary(); [ThreadStatic] private static bool _spawning; internal static bool IsSpawning => _spawning; internal static void BeginSpawn() { _spawning = true; } internal static void EndSpawn() { _spawning = false; } internal static void Register(PlayerAvatar avatar, bool managed) { if (!((Object)(object)avatar == (Object)null)) { int instanceID = ((Object)avatar).GetInstanceID(); AvatarIds.Add(instanceID); if (managed) { ManagedAvatarIds.Add(instanceID); } } } internal static void AttachController(PlayerAvatar avatar, ImitatorPlayerAvatarLabController controller) { if ((Object)(object)avatar != (Object)null && (Object)(object)controller != (Object)null) { Controllers[((Object)avatar).GetInstanceID()] = controller; } } internal static bool TryGetController(PlayerAvatar avatar, out ImitatorPlayerAvatarLabController controller) { controller = null; if ((Object)(object)avatar != (Object)null && Controllers.TryGetValue(((Object)avatar).GetInstanceID(), out controller)) { return (Object)(object)controller != (Object)null; } return false; } internal static bool IsManagedAvatar(PlayerAvatar avatar) { if ((Object)(object)avatar != (Object)null) { return ManagedAvatarIds.Contains(((Object)avatar).GetInstanceID()); } return false; } internal static bool IsLabAvatar(PlayerAvatar avatar) { if ((Object)(object)avatar != (Object)null) { return AvatarIds.Contains(((Object)avatar).GetInstanceID()); } return false; } internal static bool IsNetworkProbe(PhotonView view) { object[] array = ((view != null) ? view.InstantiationData : null); if (array != null && array.Length != 0 && array[0] is string text) { return text == "__UNCATALOGUED_PLAYER_AVATAR_NETWORK_LAB_V1__"; } return false; } internal static void Unregister(PlayerAvatar avatar) { if (!((Object)(object)avatar == (Object)null)) { int instanceID = ((Object)avatar).GetInstanceID(); AvatarIds.Remove(instanceID); ManagedAvatarIds.Remove(instanceID); Controllers.Remove(instanceID); } } } internal static class ImitatorPlayerAvatarLabAwakePatch { [HarmonyPrefix] private static bool Prefix(PlayerAvatar __instance) { if (!ImitatorPlayerAvatarLabRegistry.IsSpawning) { return true; } PhotonView component = ((Component)__instance).GetComponent(); __instance.photonView = component; ImitatorPlayerAvatarLabRegistry.Register(__instance, managed: true); return false; } } internal static class ImitatorPlayerAvatarLabHealthAwakePatch { [HarmonyPrefix] private static bool Prefix() { return !ImitatorPlayerAvatarLabRegistry.IsSpawning; } } internal static class ImitatorPlayerAvatarLabVisibilityPatch { [HarmonyPrefix] private static bool Prefix(PlayerAvatarVisuals __instance) { if (!ImitatorPlayerAvatarLabRegistry.IsLabAvatar(__instance?.playerAvatar)) { return true; } if ((Object)(object)__instance.meshParent != (Object)null) { __instance.meshParent.SetActive(true); } if ((Object)(object)__instance.animBotRoot != (Object)null) { Renderer[] componentsInChildren = __instance.animBotRoot.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].shadowCastingMode = (ShadowCastingMode)1; } } return false; } } internal static class ImitatorPlayerAvatarLabDestroyPatch { [HarmonyPrefix] private static bool Prefix(PlayerAvatar __instance) { bool num = ImitatorPlayerAvatarLabRegistry.IsManagedAvatar(__instance); ImitatorPlayerAvatarLabRegistry.Unregister(__instance); return !num; } } internal static class ImitatorPlayerAvatarLabPlayerSerializePatch { [HarmonyPrefix] private static bool Prefix(PlayerAvatar __instance, PhotonStream stream) { if (!stream.IsWriting || !ImitatorPlayerAvatarLabRegistry.TryGetController(__instance, out var controller)) { return true; } controller.WritePlayerAvatarStream(stream); return false; } } internal static class ImitatorPlayerAvatarLabCollisionSerializePatch { [HarmonyPrefix] private static bool Prefix(PlayerAvatarCollision __instance, PhotonStream stream) { PlayerAvatar avatar = __instance?.PlayerAvatar; if (!stream.IsWriting || !ImitatorPlayerAvatarLabRegistry.TryGetController(avatar, out var controller)) { return true; } controller.WriteCollisionStream(stream); return false; } } internal static class ImitatorPlayerAvatarLabCameraSerializePatch { [HarmonyPrefix] private static bool Prefix(PlayerLocalCamera __instance, PhotonStream stream) { PlayerAvatar avatar = ((__instance != null) ? ((Component)__instance).GetComponentInParent() : null); if (!stream.IsWriting || !ImitatorPlayerAvatarLabRegistry.TryGetController(avatar, out var controller)) { return true; } controller.WriteLocalCameraStream(stream); return false; } } internal static class ImitatorPlayerAvatarLabVisionSerializePatch { [HarmonyPrefix] private static bool Prefix(PlayerVisionTarget __instance, PhotonStream stream) { PlayerAvatar avatar = ((__instance != null) ? ((Component)__instance).GetComponentInParent() : null); if (!stream.IsWriting || !ImitatorPlayerAvatarLabRegistry.TryGetController(avatar, out var controller)) { return true; } controller.WriteVisionStream(stream); return false; } } internal static class ImitatorPlayerAvatarLabGrabberSerializePatch { [HarmonyPrefix] private static bool Prefix(PhysGrabber __instance, PhotonStream stream) { PlayerAvatar avatar = ((__instance != null) ? ((Component)__instance).GetComponentInParent() : null); if (!stream.IsWriting || !ImitatorPlayerAvatarLabRegistry.TryGetController(avatar, out var controller)) { return true; } controller.WritePhysGrabberStream(stream); return false; } } internal static class ImperiumDebugBridge { private const string PortalTypeName = "Imperium.API.Portal"; private const string ElementTypeName = "Imperium.API.Types.Portals.ImpPortalElement"; private const string ButtonTypeName = "Imperium.API.Types.Portals.ImpPortalButton"; private static bool _registered; private static float _nextAttemptAt; internal static void Tick() { if (!_registered && !(Time.unscaledTime < _nextAttemptAt)) { _nextAttemptAt = Time.unscaledTime + 2f; TryRegister(); } } internal static void TryRegister() { if (_registered) { return; } Type type = FindType("Imperium.API.Portal"); Type type2 = FindType("Imperium.API.Types.Portals.ImpPortalElement"); Type type3 = FindType("Imperium.API.Types.Portals.ImpPortalButton"); if (type == null || type2 == null || type3 == null) { return; } try { object obj = type.GetMethod("ForGuid", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(string) }, null)?.Invoke(null, new object[1] { "unknown.REPO.TheCarousel" }); MethodInfo methodInfo = obj?.GetType().GetMethod("InSection", BindingFlags.Instance | BindingFlags.Public); ConstructorInfo constructor = type3.GetConstructor(new Type[2] { typeof(string), typeof(Action) }); if (obj == null || methodInfo == null || constructor == null) { return; } object obj2 = methodInfo.Invoke(obj, new object[1] { "The Uncatalogued enemies" }); MethodInfo methodInfo2 = obj2?.GetType().GetMethod("Register", BindingFlags.Instance | BindingFlags.Public); UncataloguedDebugApi.EncounterInfo[] encounters = UncataloguedDebugApi.GetEncounters(); if (obj2 == null || methodInfo2 == null || encounters.Length == 0) { return; } Array array = Array.CreateInstance(type2, encounters.Length * 2); int num = 0; UncataloguedDebugApi.EncounterInfo[] array2 = encounters; for (int i = 0; i < array2.Length; i++) { UncataloguedDebugApi.EncounterInfo encounterInfo = array2[i]; string encounterId = encounterInfo.Id; object value = constructor.Invoke(new object[2] { "Spawn " + encounterInfo.DisplayName, (Action)delegate { UncataloguedDebugApi.TrySpawnNearLocalPlayer(encounterId); } }); object value2 = constructor.Invoke(new object[2] { "Despawn " + encounterInfo.DisplayName, (Action)delegate { UncataloguedDebugApi.TryDespawn(encounterId); } }); array.SetValue(value, num++); array.SetValue(value2, num++); } methodInfo2.Invoke(obj2, new object[1] { array }); _registered = true; Plugin.Log.LogInfo((object)$"The Uncatalogued registered {encounters.Length} encounters in Imperium's Portal."); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)("Imperium Portal integration is not ready: " + ex.Message)); } } } internal static void Reset() { _registered = false; _nextAttemptAt = 0f; } private static Type FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type type = assemblies[i].GetType(fullName, throwOnError: false); if (type != null) { return type; } } return null; } } internal static class LateJoinTransientException { internal static Exception NullReferenceOnly(Exception exception) { if (exception != null && !(exception is NullReferenceException)) { return exception; } return null; } internal static Exception DictionaryOrNullReference(Exception exception) { if (exception != null && !(exception is NullReferenceException) && !(exception is KeyNotFoundException)) { return exception; } return null; } } [HarmonyPatch(typeof(PlayerEyes), "LookAtTransform")] internal static class LateJoinPlayerEyesGuard { [HarmonyPrefix] private static bool Prefix(PlayerEyes __instance, bool ___hasPlayerRig, PlayerAvatar ___playerAvatar, PlayerAvatarVisuals ___playerAvatarVisuals, PlayerAvatarRightArm ___playerAvatarRightArm) { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.lookAt == (Object)null || (Object)(object)__instance.targetIdle == (Object)null) { return false; } if (___hasPlayerRig && ((Object)(object)___playerAvatar == (Object)null || (Object)(object)___playerAvatarVisuals == (Object)null || (Object)(object)___playerAvatarRightArm == (Object)null)) { return false; } return true; } [HarmonyFinalizer] private static Exception Finalizer(Exception __exception) { return LateJoinTransientException.NullReferenceOnly(__exception); } } [HarmonyPatch(typeof(PlayerEyes), "Update")] internal static class LateJoinPlayerEyesUpdateGuard { [HarmonyFinalizer] private static Exception Finalizer(Exception __exception) { return LateJoinTransientException.NullReferenceOnly(__exception); } } [HarmonyPatch(typeof(EnemyOnScreen), "GetOnScreen")] internal static class LateJoinEnemyOnScreenLookupGuard { [HarmonyPrefix] private static bool Prefix(PlayerAvatar _playerAvatar, ref bool __result, Dictionary ___OnScreenPlayer, Dictionary ___CulledPlayer) { if (!GameManager.Multiplayer()) { return true; } if ((Object)(object)_playerAvatar == (Object)null || (Object)(object)_playerAvatar.photonView == (Object)null) { __result = false; return false; } int viewID = _playerAvatar.photonView.ViewID; if (viewID == 0) { __result = false; return false; } if (___OnScreenPlayer == null || ___CulledPlayer == null) { __result = false; return false; } if (!___OnScreenPlayer.TryGetValue(viewID, out var value)) { ___OnScreenPlayer[viewID] = false; ___CulledPlayer[viewID] = true; value = false; } else if (!___CulledPlayer.ContainsKey(viewID)) { ___CulledPlayer[viewID] = true; } __result = value; return false; } } internal static class LateJoinEnemyDictionaryRepair { private const BindingFlags InstanceFields = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; internal static void EnsureOnScreen(EnemyOnScreen owner) { if ((Object)(object)owner == (Object)null || (Object)(object)GameDirector.instance == (Object)null) { return; } FieldInfo fieldInfo = AccessTools.Field(typeof(EnemyOnScreen), "OnScreenPlayer"); FieldInfo fieldInfo2 = AccessTools.Field(typeof(EnemyOnScreen), "CulledPlayer"); Dictionary dictionary = fieldInfo?.GetValue(owner) as Dictionary; Dictionary dictionary2 = fieldInfo2?.GetValue(owner) as Dictionary; if (dictionary == null || dictionary2 == null) { return; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if ((Object)(object)player == (Object)null || (Object)(object)player.photonView == (Object)null) { continue; } int viewID = player.photonView.ViewID; if (viewID != 0) { if (!dictionary.ContainsKey(viewID)) { dictionary[viewID] = false; } if (!dictionary2.ContainsKey(viewID)) { dictionary2[viewID] = true; } } } } internal static void EnsureVision(EnemyVision owner) { if ((Object)(object)owner == (Object)null || (Object)(object)GameDirector.instance == (Object)null) { return; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if ((Object)(object)player == (Object)null || (Object)(object)player.photonView == (Object)null) { continue; } int viewID = player.photonView.ViewID; if (viewID != 0) { if (!owner.VisionsTriggered.ContainsKey(viewID)) { owner.VisionsTriggered[viewID] = 0; } if (!owner.VisionTriggered.ContainsKey(viewID)) { owner.VisionTriggered[viewID] = false; } } } } internal static MethodBase FindCoroutineMoveNext(Type owner, string fragment) { Type[] nestedTypes = owner.GetNestedTypes(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (Type type in nestedTypes) { if (type.Name.Contains(fragment)) { MethodInfo methodInfo = AccessTools.Method(type, "MoveNext", (Type[])null, (Type[])null); if (methodInfo != null) { return methodInfo; } } } return null; } internal static T GetOwner(object stateMachine) where T : class { if (stateMachine == null) { return null; } return AccessTools.Field(stateMachine.GetType(), "<>4__this")?.GetValue(stateMachine) as T; } } [HarmonyPatch] internal static class LateJoinEnemyOnScreenCoroutineGuard { private static MethodBase TargetMethod() { return LateJoinEnemyDictionaryRepair.FindCoroutineMoveNext(typeof(EnemyOnScreen), ""); } [HarmonyPrefix] private static void Prefix(object __instance) { LateJoinEnemyDictionaryRepair.EnsureOnScreen(LateJoinEnemyDictionaryRepair.GetOwner(__instance)); } [HarmonyFinalizer] private static Exception Finalizer(Exception __exception) { return LateJoinTransientException.DictionaryOrNullReference(__exception); } } [HarmonyPatch] internal static class LateJoinEnemyVisionCoroutineGuard { private static MethodBase TargetMethod() { return LateJoinEnemyDictionaryRepair.FindCoroutineMoveNext(typeof(EnemyVision), ""); } [HarmonyPrefix] private static void Prefix(object __instance) { LateJoinEnemyDictionaryRepair.EnsureVision(LateJoinEnemyDictionaryRepair.GetOwner(__instance)); } [HarmonyFinalizer] private static Exception Finalizer(Exception __exception) { return LateJoinTransientException.DictionaryOrNullReference(__exception); } } [HarmonyPatch(typeof(EnemyRobe), "Update")] internal static class LateJoinEnemyRobeGuard { [HarmonyPrefix] private static void Prefix(EnemyRobe __instance, PlayerAvatar ___targetPlayer, ref bool ___stateImpulse, ref float ___stateTimer) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0042: 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_0023: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 if (!((Object)(object)__instance == (Object)null) && !((Object)(object)___targetPlayer != (Object)null) && ((int)__instance.currentState == 4 || (int)__instance.currentState == 3 || (int)__instance.currentState == 5 || (int)__instance.currentState == 6 || (int)__instance.currentState == 7)) { __instance.currentState = (State)1; ___stateImpulse = true; ___stateTimer = 0f; } } [HarmonyFinalizer] private static Exception Finalizer(Exception __exception) { return LateJoinTransientException.DictionaryOrNullReference(__exception); } } [HarmonyPatch(typeof(PlayerTumble), "FixedUpdate")] internal static class LateJoinPlayerTumbleGuard { [HarmonyFinalizer] private static Exception Finalizer(Exception __exception) { return LateJoinTransientException.NullReferenceOnly(__exception); } } [HarmonyPatch(typeof(PhysGrabBeam), "DrawCurve")] internal static class LateJoinPhysGrabBeamGuard { [HarmonyPrefix] private static bool Prefix(PhysGrabBeam __instance) { if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.playerAvatar != (Object)null && (Object)(object)__instance.playerAvatar.physGrabber != (Object)null && (Object)(object)__instance.PhysGrabPointOrigin != (Object)null && (Object)(object)__instance.PhysGrabPoint != (Object)null && (Object)(object)__instance.PhysGrabPointPuller != (Object)null && (Object)(object)__instance.lineRenderer != (Object)null) { return true; } if ((Object)(object)__instance?.lineRenderer != (Object)null) { ((Renderer)__instance.lineRenderer).enabled = false; } if ((Object)(object)__instance?.lineRendererOverCharge != (Object)null) { ((Renderer)__instance.lineRendererOverCharge).enabled = false; } return false; } [HarmonyFinalizer] private static Exception Finalizer(Exception __exception) { return LateJoinTransientException.NullReferenceOnly(__exception); } } [HarmonyPatch(typeof(PhysGrabBeam), "LateUpdate")] internal static class LateJoinPhysGrabBeamUpdateGuard { [HarmonyFinalizer] private static Exception Finalizer(Exception __exception) { return LateJoinTransientException.NullReferenceOnly(__exception); } } [HarmonyPatch(typeof(PhysGrabObject), "PhysicsGrabbingManipulation")] internal static class LateJoinPhysGrabObjectGuard { [HarmonyPrefix] private static bool Prefix(PhysGrabObject __instance) { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.rb == (Object)null) { return false; } for (int num = __instance.playerGrabbing.Count - 1; num >= 0; num--) { PhysGrabber val = __instance.playerGrabbing[num]; if ((Object)(object)val == (Object)null || (Object)(object)val.playerAvatar == (Object)null || (Object)(object)val.physGrabPoint == (Object)null) { __instance.playerGrabbing.RemoveAt(num); } } return __instance.playerGrabbing.Count > 0; } [HarmonyFinalizer] private static Exception Finalizer(Exception __exception) { return LateJoinTransientException.NullReferenceOnly(__exception); } } [HarmonyPatch(typeof(PhysGrabObject), "FixedUpdate")] internal static class LateJoinPhysGrabObjectFixedUpdateGuard { [HarmonyFinalizer] private static Exception Finalizer(Exception __exception) { return LateJoinTransientException.NullReferenceOnly(__exception); } } internal static class LateJoinSafety { private sealed class PendingActor { internal int ActorNumber; internal float FirstSeen; internal float LastSeen; internal float StableSince = -1f; internal bool Released; } private const float MinimumGraceSeconds = 7f; private const float RequiredStableSeconds = 2.25f; private static readonly HashSet TrustedActors = new HashSet(); private static readonly HashSet TrustedAvatars = new HashSet(); private static readonly Dictionary Pending = new Dictionary(); private static int _sceneHandle = -1; private static bool _baselineEstablished; private static float _pollTimer; internal static void Tick() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!PhotonNetwork.InRoom || !PhotonNetwork.IsMasterClient) { ResetIfNeeded(); return; } Scene activeScene = SceneManager.GetActiveScene(); int handle = ((Scene)(ref activeScene)).handle; if (_sceneHandle != handle) { Reset(handle); } if (!ModEnemyLevelRules.IsPlayableLevel() || (Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated) { return; } if (!_baselineEstablished) { EstablishBaseline(); return; } _pollTimer -= Time.deltaTime; if (_pollTimer > 0f) { return; } _pollTimer = 0.2f; HashSet hashSet = new HashSet(); Player[] playerList = PhotonNetwork.PlayerList; foreach (Player val in playerList) { if (val == null || val.IsInactive) { continue; } int actorNumber = val.ActorNumber; hashSet.Add(actorNumber); if (!TrustedActors.Contains(actorNumber)) { if (!Pending.TryGetValue(actorNumber, out var value)) { value = new PendingActor { ActorNumber = actorNumber, FirstSeen = Time.time, LastSeen = Time.time }; Pending.Add(actorNumber, value); Plugin.Log.LogInfo((object)$"Late-join safety is shielding Photon actor {actorNumber} from custom enemies while its avatar settles."); } value.LastSeen = Time.time; } } foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if ((Object)(object)item == (Object)null || TrustedAvatars.Contains(((Object)item).GetInstanceID())) { continue; } int num = ResolveActor(item); if (num <= 0 || TrustedActors.Contains(num) || !Pending.TryGetValue(num, out var value2) || value2.Released) { continue; } value2.LastSeen = Time.time; if (!IsAvatarStable(item, num)) { value2.StableSince = -1f; continue; } if (value2.StableSince < 0f) { value2.StableSince = Time.time; } if (!(Time.time - value2.FirstSeen < 7f) && !(Time.time - value2.StableSince < 2.25f)) { value2.Released = true; TrustedActors.Add(num); TrustedAvatars.Add(((Object)item).GetInstanceID()); Plugin.Log.LogInfo((object)$"Late-join safety released Photon actor {num} after a stable avatar grace period; custom enemies may now target it."); } } List list = null; foreach (KeyValuePair item2 in Pending) { if (!hashSet.Contains(item2.Key) && !(Time.time - item2.Value.LastSeen < 3f)) { if (list == null) { list = new List(); } list.Add(item2.Key); } } if (list == null) { return; } foreach (int item3 in list) { Pending.Remove(item3); } } internal static bool IsProtected(PlayerAvatar avatar) { if ((Object)(object)avatar == (Object)null || !_baselineEstablished || !PhotonNetwork.InRoom || !PhotonNetwork.IsMasterClient) { return false; } if (IsLocalHostAvatar(avatar)) { TrustedAvatars.Add(((Object)avatar).GetInstanceID()); if (PhotonNetwork.LocalPlayer != null) { TrustedActors.Add(PhotonNetwork.LocalPlayer.ActorNumber); } return false; } int num = ResolveActor(avatar); if (TrustedAvatars.Contains(((Object)avatar).GetInstanceID())) { if (num > 0) { return !TrustedActors.Contains(num); } return true; } if (num > 0 && TrustedActors.Contains(num)) { TrustedAvatars.Add(((Object)avatar).GetInstanceID()); return false; } if (num > 0 && Pending.TryGetValue(num, out var value)) { return !value.Released; } return true; } private static void EstablishBaseline() { TrustedActors.Clear(); TrustedAvatars.Clear(); Pending.Clear(); if (PhotonNetwork.LocalPlayer != null) { TrustedActors.Add(PhotonNetwork.LocalPlayer.ActorNumber); } foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (IsLocalHostAvatar(item)) { TrustedAvatars.Add(((Object)item).GetInstanceID()); Plugin.Log.LogInfo((object)"Late-join safety trusted the room owner's generated-level avatar immediately."); continue; } int num = ResolveActor(item); if ((Object)(object)item != (Object)null && num > 0 && IsAvatarStable(item, num)) { TrustedActors.Add(num); TrustedAvatars.Add(((Object)item).GetInstanceID()); } } Player[] playerList = PhotonNetwork.PlayerList; foreach (Player val in playerList) { if (val != null && !val.IsInactive && !TrustedActors.Contains(val.ActorNumber)) { Pending.Add(val.ActorNumber, new PendingActor { ActorNumber = val.ActorNumber, FirstSeen = Time.time, LastSeen = Time.time }); Plugin.Log.LogInfo((object)$"Late-join safety found actor {val.ActorNumber} without a settled generated-level avatar and started its grace period."); } } _baselineEstablished = true; _pollTimer = 0.2f; Plugin.Log.LogInfo((object)$"Late-join safety established the generated-level baseline with {TrustedActors.Count} Photon actor(s)."); } private static int ResolveActor(PlayerAvatar avatar) { PhotonView obj = ResolveView(avatar); int? obj2; if (obj == null) { obj2 = null; } else { Player owner = obj.Owner; obj2 = ((owner != null) ? new int?(owner.ActorNumber) : ((int?)null)); } int? num = obj2; return num.GetValueOrDefault(); } private static bool IsLocalHostAvatar(PlayerAvatar avatar) { if ((Object)(object)avatar == (Object)null || !PhotonNetwork.IsMasterClient) { return false; } if ((Object)(object)avatar == (Object)(object)PlayerAvatar.instance || (Object)(object)avatar == (Object)(object)PlayerController.instance?.playerAvatarScript) { return true; } if (PhotonNetwork.PlayerList != null && PhotonNetwork.PlayerList.Length == 1) { return true; } PhotonView val = ResolveView(avatar); if ((Object)(object)val != (Object)null) { return val.IsMine; } return false; } private static PhotonView ResolveView(PlayerAvatar avatar) { object obj = ((avatar != null) ? ((Component)avatar).GetComponent() : null); if (obj == null) { obj = ((avatar != null) ? ((Component)avatar).GetComponentInParent() : null); if (obj == null) { if (avatar == null) { return null; } obj = ((Component)avatar).GetComponentInChildren(true); } } return (PhotonView)obj; } private static bool IsAvatarStable(PlayerAvatar avatar, int expectedActor) { //IL_009a: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)avatar == (Object)null || !((Component)avatar).gameObject.activeInHierarchy || (Object)(object)avatar.playerHealth == (Object)null) { return false; } PhotonView val = ResolveView(avatar); if ((Object)(object)val == (Object)null || val.ViewID <= 0 || val.Owner == null || val.Owner.ActorNumber != expectedActor) { return false; } PlayerAvatarCollision componentInChildren = ((Component)avatar).GetComponentInChildren(true); if ((Object)(object)componentInChildren?.Collider == (Object)null || !((Collider)componentInChildren.Collider).enabled || !((Component)componentInChildren.Collider).gameObject.activeInHierarchy) { return false; } Vector3 position = ((Component)avatar).transform.position; if (IsFinite(position.x) && IsFinite(position.y) && IsFinite(position.z) && Mathf.Abs(position.x) < 10000f && Mathf.Abs(position.y) < 10000f) { return Mathf.Abs(position.z) < 10000f; } return false; } private static bool IsFinite(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } private static void ResetIfNeeded() { if (_sceneHandle != -1 || _baselineEstablished || Pending.Count > 0) { Reset(-1); } } private static void Reset(int sceneHandle) { _sceneHandle = sceneHandle; _baselineEstablished = false; _pollTimer = 0f; TrustedActors.Clear(); TrustedAvatars.Clear(); Pending.Clear(); } } internal sealed class MapIconSuppressor : MonoBehaviour { private static readonly List Instances = new List(); private static float _globalScanTimer; private static bool _globalScanRequested; private const float GlobalFallbackScanInterval = 0.9f; private static bool _customRemovalLogged; private static bool _valuableRemovalLogged; private static bool _discoverGraphicRemovalLogged; private static bool _guestSuppressionRpcFailureLogged; private static readonly FieldInfo ValuableDiscoveredField = typeof(ValuableObject).GetField("discovered", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo ValuableReminderField = typeof(ValuableObject).GetField("discoveredReminder", BindingFlags.Instance | BindingFlags.NonPublic); private readonly HashSet _valuables = new HashSet(); private readonly HashSet _customIcons = new HashSet(); private readonly HashSet _guestDiscoveryRpcViewIds = new HashSet(); internal static bool GuestMapPreviewEnabled { get; private set; } internal static void Attach(GameObject root) { if (!((Object)(object)root == (Object)null) && !((Object)(object)root.GetComponent() != (Object)null)) { MapIconSuppressor mapIconSuppressor = root.AddComponent(); mapIconSuppressor.CacheTargets(); mapIconSuppressor.SuppressValuableDiscovery(); mapIconSuppressor.SuppressCustomSources(); _globalScanRequested = true; } } private void Awake() { if (!Instances.Contains(this)) { Instances.Add(this); } CacheTargets(); SuppressValuableDiscovery(); SuppressCustomSources(); _globalScanRequested = true; } private void OnDestroy() { Instances.Remove(this); } internal static void TickAll(bool force = false) { if (Instances.Count == 0) { _globalScanRequested = false; _globalScanTimer = 0.9f; return; } _globalScanTimer -= Time.unscaledDeltaTime; if (!force && !_globalScanRequested && _globalScanTimer > 0f) { return; } _globalScanRequested = false; _globalScanTimer = 0.9f; for (int num = Instances.Count - 1; num >= 0; num--) { MapIconSuppressor mapIconSuppressor = Instances[num]; if ((Object)(object)mapIconSuppressor == (Object)null) { Instances.RemoveAt(num); } else { mapIconSuppressor.SuppressValuableDiscovery(); if (GuestMapPreviewEnabled) { mapIconSuppressor.RevealSourcesForPreview(); } else { mapIconSuppressor.SuppressCustomSources(); } } } if (GuestMapPreviewEnabled) { return; } MapCustomEntity[] array = Object.FindObjectsOfType(true); foreach (MapCustomEntity val in array) { if ((Object)(object)val != (Object)null && IsOwnedMapEntity(val)) { Object.Destroy((Object)(object)((Component)val).gameObject); if (!_customRemovalLogged) { _customRemovalLogged = true; Plugin.Log.LogInfo((object)"Removed the first Carousel weapon entry from the host's local map."); } } } MapValuable[] array2 = Object.FindObjectsOfType(true); foreach (MapValuable val2 in array2) { if ((Object)(object)val2 != (Object)null && (Object)(object)val2.target != (Object)null && IsOwnedValuable(val2.target)) { Object.Destroy((Object)(object)((Component)val2).gameObject); if (!_valuableRemovalLogged) { _valuableRemovalLogged = true; Plugin.Log.LogInfo((object)"Removed The Weeping Angel's valuable entry from the host's local map."); } } } ValuableDiscoverGraphic[] array3 = Object.FindObjectsOfType(true); foreach (ValuableDiscoverGraphic val3 in array3) { if ((Object)(object)val3 != (Object)null && (Object)(object)val3.target != (Object)null && IsOwnedPhysGrabObject(val3.target)) { Object.Destroy((Object)(object)((Component)val3).gameObject); if (!_discoverGraphicRemovalLogged) { _discoverGraphicRemovalLogged = true; Plugin.Log.LogInfo((object)"Removed the first encounter-part valuable discovery frame from the host UI."); } } } } internal static void SetGuestMapPreview(bool enabled) { GuestMapPreviewEnabled = enabled; _globalScanTimer = 0f; TickAll(force: true); } private void CacheTargets() { _customIcons.Clear(); MapCustom[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (MapCustom val in componentsInChildren) { if ((Object)(object)val != (Object)null) { _customIcons.Add(val); } } _valuables.Clear(); ValuableObject[] componentsInChildren2 = ((Component)this).GetComponentsInChildren(true); foreach (ValuableObject val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)null) { _valuables.Add(val2); } } } private void SuppressCustomSources() { foreach (MapCustom customIcon in _customIcons) { if (!((Object)(object)customIcon == (Object)null)) { customIcon.autoAdd = false; customIcon.Hide(); ((Behaviour)customIcon).enabled = false; } } } private void SuppressValuableDiscovery() { foreach (ValuableObject valuable in _valuables) { if ((Object)(object)valuable == (Object)null) { continue; } ValuableDiscoveredField?.SetValue(valuable, true); ValuableReminderField?.SetValue(valuable, false); PhysGrabObjectImpactDetector component = ((Component)valuable).GetComponent(); if ((Object)(object)component != (Object)null) { component.inCart = true; } if (!GameManager.Multiplayer() || !PhotonNetwork.IsMasterClient || !PhotonNetwork.InRoom) { continue; } PhotonView component2 = ((Component)valuable).GetComponent(); if ((Object)(object)component2 == (Object)null || component2.ViewID == 0 || !_guestDiscoveryRpcViewIds.Add(component2.ViewID)) { continue; } try { component2.RPC("DiscoverRPC", (RpcTarget)4, Array.Empty()); if ((Object)(object)component != (Object)null) { component2.RPC("InCartRPC", (RpcTarget)4, new object[1] { true }); } } catch (Exception ex) { if (!_guestSuppressionRpcFailureLogged) { _guestSuppressionRpcFailureLogged = true; Plugin.Log.LogWarning((object)("Could not suppress an encounter valuable frame for unmodded guests: " + ex.Message)); } } } } private void RevealSourcesForPreview() { if ((Object)(object)Map.Instance == (Object)null) { return; } MapCustomEntity[] array = Object.FindObjectsOfType(true); foreach (MapCustom customIcon in _customIcons) { if ((Object)(object)customIcon == (Object)null) { continue; } customIcon.autoAdd = false; ((Behaviour)customIcon).enabled = true; bool flag = false; MapCustomEntity[] array2 = array; foreach (MapCustomEntity val in array2) { if ((Object)(object)val != (Object)null && (Object)(object)val.mapCustom == (Object)(object)customIcon) { flag = true; break; } } if (!flag) { customIcon.Add(); } } MapValuable[] array3 = Object.FindObjectsOfType(true); foreach (ValuableObject valuable in _valuables) { if ((Object)(object)valuable == (Object)null) { continue; } bool flag2 = false; MapValuable[] array4 = array3; foreach (MapValuable val2 in array4) { if ((Object)(object)val2 != (Object)null && (Object)(object)val2.target == (Object)(object)valuable) { flag2 = true; break; } } if (!flag2) { Map.Instance.AddValuable(valuable); } } } private static bool IsOwnedMapEntity(MapCustomEntity entity) { foreach (MapIconSuppressor instance in Instances) { if (!((Object)(object)instance == (Object)null)) { if ((Object)(object)entity.mapCustom != (Object)null && instance._customIcons.Contains(entity.mapCustom)) { return true; } if ((Object)(object)entity.Parent != (Object)null && ((Object)(object)entity.Parent == (Object)(object)((Component)instance).transform || entity.Parent.IsChildOf(((Component)instance).transform))) { return true; } } } return false; } private static bool IsOwnedValuable(ValuableObject target) { foreach (MapIconSuppressor instance in Instances) { if ((Object)(object)instance != (Object)null && instance._valuables.Contains(target)) { return true; } } return false; } private static bool IsOwnedPhysGrabObject(PhysGrabObject target) { if ((Object)(object)target == (Object)null) { return false; } foreach (MapIconSuppressor instance in Instances) { if ((Object)(object)instance == (Object)null) { continue; } foreach (ValuableObject valuable in instance._valuables) { if ((Object)(object)valuable != (Object)null && ((Object)(object)((Component)valuable).GetComponent() == (Object)(object)target || (Object)(object)((Component)valuable).GetComponentInChildren(true) == (Object)(object)target || ((Component)target).transform.IsChildOf(((Component)valuable).transform))) { return true; } } } return false; } internal static bool OwnsValuable(ValuableObject target) { if ((Object)(object)target != (Object)null) { return IsOwnedValuable(target); } return false; } } internal static class MarionetteAggressionBridge { internal sealed class Target { internal IModEnemyTumbleReceiver Receiver; internal MonoBehaviour Controller; internal Transform BeamTransform; internal PhotonView BeamView; } private static readonly Dictionary AggressiveStates = new Dictionary(StringComparer.Ordinal) { { "DeadAirController", "Hunting" }, { "BrokerController", "Hostile" }, { "MimicController", "Charge" }, { "UndertowController", "Approach" }, { "BellhopController", "Retreating" } }; private static readonly BindingFlags InstanceFields = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static readonly MethodInfo ElsaUpdateState = typeof(EnemyElsa).GetMethod("UpdateState", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo ElsaPlayerTarget = typeof(EnemyElsa).GetField("playerTarget", InstanceFields); private static readonly FieldInfo ElsaAngryTimer = typeof(EnemyElsa).GetField("angryTimer", InstanceFields); private static readonly FieldInfo ElsaAngryTimerMax = typeof(EnemyElsa).GetField("angryTimerMax", InstanceFields); private static readonly FieldInfo ElsaPhotonView = typeof(EnemyElsa).GetField("photonView", InstanceFields); private static readonly FieldInfo EnemyTargetPlayer = typeof(Enemy).GetField("TargetPlayerAvatar", InstanceFields); private static readonly FieldInfo EnemyTargetView = typeof(Enemy).GetField("TargetPlayerViewID", InstanceFields); private static readonly FieldInfo EnemyHasChaseBegin = typeof(Enemy).GetField("HasStateChaseBegin", InstanceFields); private static readonly FieldInfo EnemyHasChase = typeof(Enemy).GetField("HasStateChase", InstanceFields); private static readonly FieldInfo OnScreenPlayers = typeof(EnemyOnScreen).GetField("OnScreenPlayer", InstanceFields); private static readonly FieldInfo CulledPlayers = typeof(EnemyOnScreen).GetField("CulledPlayer", InstanceFields); internal static Target FindNearest(Vector3 origin, float radius) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) Target result = null; float num = radius * radius; HashSet hashSet = new HashSet(); TumbleHitProxy[] array = Object.FindObjectsOfType(); foreach (TumbleHitProxy tumbleHitProxy in array) { IModEnemyTumbleReceiver modEnemyTumbleReceiver = (((Object)(object)tumbleHitProxy != (Object)null) ? tumbleHitProxy.Receiver : null); if (modEnemyTumbleReceiver == null || !modEnemyTumbleReceiver.CanReceiveTumbleAttack || modEnemyTumbleReceiver is MarionetteController || !hashSet.Add(modEnemyTumbleReceiver)) { continue; } MonoBehaviour val = (MonoBehaviour)((modEnemyTumbleReceiver is MonoBehaviour) ? modEnemyTumbleReceiver : null); PhotonView componentInParent = ((Component)tumbleHitProxy).GetComponentInParent(); if (!((Object)(object)val == (Object)null) && !((Object)(object)componentInParent == (Object)null) && ((Component)val).gameObject.activeInHierarchy) { Vector3 val2 = ((Component)tumbleHitProxy).transform.position - origin; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (!(sqrMagnitude >= num)) { num = sqrMagnitude; result = new Target { Receiver = modEnemyTumbleReceiver, Controller = val, BeamTransform = ((Component)tumbleHitProxy).transform, BeamView = componentInParent }; } } } return result; } internal static bool Valid(Target target) { if (target != null && target.Receiver != null && target.Receiver.CanReceiveTumbleAttack && (Object)(object)target.Controller != (Object)null && ((Component)target.Controller).gameObject.activeInHierarchy && (Object)(object)target.BeamTransform != (Object)null) { return (Object)(object)target.BeamView != (Object)null; } return false; } internal static void Force(Target target, PlayerAvatar player) { if (!Valid(target) || !GunAccess.IsLiving(player)) { return; } MonoBehaviour controller = target.Controller; Type type = ((object)controller).GetType(); if (controller is MimicController mimicController) { mimicController.ForceHostileByMarionette(player); return; } if (controller is UndertowController undertowController) { undertowController.ForceHostileByMarionette(player); return; } SetField(type, controller, "_target", player); SetField(type, controller, "_targetTimer", 1.1f); SetField(type, controller, "_scanTimer", 0.25f); SetField(type, controller, "_destinationTimer", 0f); SetField(type, controller, "_lastSeenTimer", 2.5f); if (type == typeof(AuditorController)) { SetField(type, controller, "_retaliationTimer", 3f); } else if (type == typeof(PlaybackController)) { MethodInfo method = type.GetMethod("BeginRecord", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field = type.GetField("_state", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null && field != null && string.Equals(field.GetValue(controller).ToString(), "Roam", StringComparison.Ordinal)) { method.Invoke(controller, null); } } if (AggressiveStates.TryGetValue(type.Name, out var value)) { SetEnumField(type, controller, "_state", value); } } internal static void ForceElsa(EnemyElsa elsa, PlayerAvatar player) { if ((Object)(object)elsa == (Object)null || !GunAccess.IsLiving(player) || ElsaUpdateState == null) { return; } try { object? obj = ElsaPlayerTarget?.GetValue(elsa); PlayerAvatar val = (PlayerAvatar)((obj is PlayerAvatar) ? obj : null); ElsaPlayerTarget?.SetValue(elsa, player); if (ElsaAngryTimer != null && ElsaAngryTimerMax != null) { ElsaAngryTimer.SetValue(elsa, ElsaAngryTimerMax.GetValue(elsa)); } object? obj2 = ElsaPhotonView?.GetValue(elsa); PhotonView val2 = (PhotonView)((obj2 is PhotonView) ? obj2 : null); if ((Object)(object)val2 != (Object)null && GameManager.Multiplayer() && (Object)(object)val != (Object)(object)player) { val2.RPC("UpdatePlayerTargetRPC", (RpcTarget)0, new object[1] { player.photonView.ViewID }); } Type parameterType = ElsaUpdateState.GetParameters()[0].ParameterType; if (!string.Equals(((object)Unsafe.As(ref elsa.currentState)/*cast due to .constrained prefix*/).ToString(), "GoToPlayerBig", StringComparison.Ordinal) && !string.Equals(((object)Unsafe.As(ref elsa.currentState)/*cast due to .constrained prefix*/).ToString(), "GoToPlayerOverBig", StringComparison.Ordinal) && !string.Equals(((object)Unsafe.As(ref elsa.currentState)/*cast due to .constrained prefix*/).ToString(), "BackToNavMeshBig", StringComparison.Ordinal) && !string.Equals(((object)Unsafe.As(ref elsa.currentState)/*cast due to .constrained prefix*/).ToString(), "LookUnderStartBig", StringComparison.Ordinal) && !string.Equals(((object)Unsafe.As(ref elsa.currentState)/*cast due to .constrained prefix*/).ToString(), "LookUnderBig", StringComparison.Ordinal) && !string.Equals(((object)Unsafe.As(ref elsa.currentState)/*cast due to .constrained prefix*/).ToString(), "LookUnderStopBig", StringComparison.Ordinal) && !string.Equals(((object)Unsafe.As(ref elsa.currentState)/*cast due to .constrained prefix*/).ToString(), "TransformSmallToBig", StringComparison.Ordinal) && !string.Equals(((object)Unsafe.As(ref elsa.currentState)/*cast due to .constrained prefix*/).ToString(), "TransformBigToSmall", StringComparison.Ordinal) && (Object)(object)val2 != (Object)null && GameManager.Multiplayer()) { val2.RPC("TransformSmallToBigRPC", (RpcTarget)0, Array.Empty()); } object obj3 = Enum.Parse(parameterType, "GoToPlayerBig"); ElsaUpdateState.Invoke(elsa, new object[1] { obj3 }); } catch (Exception ex) { Plugin.Log.LogDebug((object)("The Marionette could not force EnemyElsa hostile: " + ex.GetBaseException().Message)); } } internal static void ForceVanilla(Enemy enemy, PlayerAvatar player) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)enemy == (Object)null || !GunAccess.IsLiving(player) || !PlayerReadyForVanillaEnemy(enemy, player)) { return; } try { EnemyRobe val = ((Component)enemy).GetComponentInParent() ?? ((Component)enemy).GetComponentInChildren(true); if ((Object)(object)val != (Object)null) { SetField(typeof(EnemyRobe), val, "targetPlayer", player); SyncPlayerTarget((MonoBehaviour)(object)val, "TargetPlayerRPC", player); InvokeEnumState(typeof(EnemyRobe), val, "UpdateState", "TargetPlayer"); return; } enemy.SetChaseTarget(player); EnemyTargetPlayer?.SetValue(enemy, player); EnemyTargetView?.SetValue(enemy, player.photonView.ViewID); bool flag = EnemyHasChaseBegin != null && (bool)EnemyHasChaseBegin.GetValue(enemy); enemy.CurrentState = (EnemyState)(flag ? 3 : 4); enemy.SetChaseTimer(); EnemyElsa val2 = ((Component)enemy).GetComponentInParent() ?? ((Component)enemy).GetComponentInChildren(true); if ((Object)(object)val2 != (Object)null) { ForceElsa(val2, player); } ForceSpecialVanillaControllers(enemy, player); } catch (Exception ex) { Plugin.Log.LogDebug((object)("The Marionette could not force vanilla enemy hostile: " + ex.GetBaseException().Message)); } } internal static bool PlayerReadyForVanillaEnemy(Enemy enemy, PlayerAvatar player) { if ((Object)(object)enemy == (Object)null || !GunAccess.IsLiving(player)) { return false; } if (!GameManager.Multiplayer()) { return true; } if (!RequiresStrictActorReady(enemy)) { return true; } int num = (((Object)(object)player.photonView != (Object)null) ? player.photonView.ViewID : 0); if (num == 0) { return false; } EnemyParent componentInParent = ((Component)enemy).GetComponentInParent(); EnemyOnScreen[] componentsInChildren = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).gameObject : ((Component)enemy).gameObject).GetComponentsInChildren(true); foreach (EnemyOnScreen obj in componentsInChildren) { IDictionary dictionary = OnScreenPlayers?.GetValue(obj) as IDictionary; IDictionary dictionary2 = CulledPlayers?.GetValue(obj) as IDictionary; if (dictionary == null || dictionary2 == null || !dictionary.Contains(num) || !dictionary2.Contains(num)) { return false; } } return true; } private static bool RequiresStrictActorReady(Enemy enemy) { if ((Object)(object)enemy == (Object)null) { return false; } EnemyParent componentInParent = ((Component)enemy).GetComponentInParent(); MonoBehaviour[] componentsInChildren = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).gameObject : ((Component)enemy).gameObject).GetComponentsInChildren(true); foreach (MonoBehaviour val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { switch (((object)val).GetType().Name) { case "EnemyElsa": case "EnemyRobe": case "EnemyTick": case "EnemyAnimal": case "EnemyHunter": case "EnemyBirthdayBoy": case "EnemyTricycle": return true; } } } return false; } private static void ForceSpecialVanillaControllers(Enemy enemy, PlayerAvatar player) { HashSet hashSet = new HashSet(); EnemyParent componentInParent = ((Component)enemy).GetComponentInParent(); MonoBehaviour[] componentsInChildren; if ((Object)(object)componentInParent != (Object)null) { componentsInChildren = ((Component)componentInParent).GetComponentsInChildren(true); foreach (MonoBehaviour val in componentsInChildren) { if ((Object)(object)val != (Object)null) { hashSet.Add(val); } } } componentsInChildren = ((Component)enemy).GetComponentsInParent(true); foreach (MonoBehaviour val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null) { hashSet.Add(val2); } } componentsInChildren = ((Component)enemy).GetComponentsInChildren(true); foreach (MonoBehaviour val3 in componentsInChildren) { if ((Object)(object)val3 != (Object)null) { hashSet.Add(val3); } } foreach (MonoBehaviour item in hashSet) { Type type = ((object)item).GetType(); switch (type.Name) { case "EnemyBirthdayBoy": InvokePlayerTarget(type, item, player); InvokeEnumState(type, item, "UpdateState", "GoToPlayerAngry"); break; case "EnemyAnimal": SetField(type, item, "playerTarget", player); InvokeEnumState(type, item, "UpdateState", "GoToPlayer"); break; case "EnemyTricycle": SetField(type, item, "playerTarget", player); InvokeEnumState(type, item, "SetState", "StateBeforeAttack"); break; case "EnemyHunter": ForceHunter(type, item, player); break; case "EnemyTick": SetField(type, item, "playerTarget", player); SyncPlayerTarget(item, "UpdatePlayerTargetRPC", player); InvokeEnumState(type, item, "UpdateState", "Notice"); break; } } } private static void InvokePlayerTarget(Type type, MonoBehaviour controller, PlayerAvatar player) { MethodInfo method = type.GetMethod("UpdatePlayerTarget", InstanceFields); if (method != null) { method.Invoke(controller, new object[1] { player }); } else { SetField(type, controller, "playerTarget", player); } } private static void ForceHunter(Type type, MonoBehaviour controller, PlayerAvatar player) { //IL_0023: 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_0030: 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_0092: Unknown result type (might be due to invalid IL or missing references) Transform val = (((Object)(object)player.PlayerVisionTarget != (Object)null) ? player.PlayerVisionTarget.VisionTransform : ((Component)player).transform); Vector3 position = val.position; SetField(type, controller, "investigatePoint", position); SetField(type, controller, "investigatePointHasTransform", true); SetField(type, controller, "investigatePointTransform", val); SetField(type, controller, "investigatePointTransformPrevious", position); PhotonView componentInParent = ((Component)controller).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && GameManager.Multiplayer()) { componentInParent.RPC("UpdateInvestigationPoint", (RpcTarget)1, new object[1] { position }); } InvokeEnumState(type, controller, "UpdateState", "Aim"); } private static void SyncPlayerTarget(MonoBehaviour controller, string rpc, PlayerAvatar player) { PhotonView componentInParent = ((Component)controller).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && GameManager.Multiplayer()) { componentInParent.RPC(rpc, (RpcTarget)1, new object[1] { player.photonView.ViewID }); } } private static void InvokeEnumState(Type type, object instance, string methodName, string stateName) { try { MethodInfo method = type.GetMethod(methodName, InstanceFields); if (method == null || method.GetParameters().Length != 1) { return; } Type parameterType = method.GetParameters()[0].ParameterType; if (parameterType.IsEnum) { object obj = Enum.Parse(parameterType, stateName); FieldInfo field = type.GetField("currentState", InstanceFields); if (!(field != null) || !object.Equals(field.GetValue(instance), obj)) { method.Invoke(instance, new object[1] { obj }); } } } catch (Exception ex) { Plugin.Log.LogDebug((object)("The Marionette could not force " + type.Name + "." + stateName + ": " + ex.GetBaseException().Message)); } } private static void SetField(Type type, object instance, string name, object value) { try { FieldInfo field = type.GetField(name, InstanceFields); if (field != null && value != null && field.FieldType.IsInstanceOfType(value)) { field.SetValue(instance, value); } else if (field != null && value != null && field.FieldType == value.GetType()) { field.SetValue(instance, value); } } catch (Exception ex) { Plugin.Log.LogDebug((object)("The Marionette could not set " + type.Name + "." + name + ": " + ex.Message)); } } private static void SetEnumField(Type type, object instance, string name, string value) { try { FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.NonPublic); if (!(field == null) && field.FieldType.IsEnum) { object value2 = field.GetValue(instance); if (value2 == null || !string.Equals(value2.ToString(), value, StringComparison.Ordinal)) { field.SetValue(instance, Enum.Parse(field.FieldType, value)); SetField(type, instance, "_stateTimer", 0f); } } } catch (Exception ex) { Plugin.Log.LogDebug((object)("The Marionette could not force " + type.Name + " hostile: " + ex.Message)); } } } internal sealed class MarionetteController : MonoBehaviour, IModEnemyTumbleReceiver, IModEnemyTranqAware { private enum State { Search, Approach, Manipulate, Retreat, Restrict, Dead } private const float SearchRadius = 11.5f; private const float ConnectDistance = 2.65f; private const float HighFloatHeight = 2.48f; private const float WorkingFloatHeight = 1.82f; private static readonly MethodInfo NewRayHitPointMethod = typeof(ItemDrone).GetMethod("NewRayHitPoint", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo EnemyDeadField = typeof(EnemyHealth).GetField("dead", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo EnemyRigidbodyField = typeof(Enemy).GetField("Rigidbody", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo RigidbodyPhysField = typeof(EnemyRigidbody).GetField("physGrabObject", BindingFlags.Instance | BindingFlags.NonPublic); private SpawnedMarionette _spawned; private NavMeshAgent _agent; private State _state; private Enemy _enemyTarget; private MarionetteAggressionBridge.Target _customTarget; private PlayerAvatar _forcedPlayer; private PlayerAvatar _restrictedPlayer; private Vector3 _visualForward = Vector3.forward; private float _phase; private float _scanTimer; private float _destinationTimer; private float _stateTimer; private float _soundTimer; private float _limbBeamRetry; private float _controlBeamRetry; private float _stunTimer; private float _visualHeight = 2.48f; private float _rewardTimer; private float _lastClaimedHit = -10f; private int _health; private bool _limbBeamsReady; private bool _controlBeamAttached; private bool _controlBeamFailureLogged; private bool _limbBeamWarmupStarted; private bool _mainOpened; private bool _initialized; private bool _dead; private bool _rewardDropped; private bool _cleaning; public bool CanReceiveTumbleAttack { get { if (_initialized) { return !_dead; } return false; } } internal bool Initialize(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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) ((Component)this).transform.position = position; _health = Mathf.Max(1, Plugin.Settings.MarionetteHealth.Value); _agent = ((Component)this).gameObject.AddComponent(); ((Behaviour)_agent).enabled = false; _agent.speed = Mathf.Max(0.8f, Plugin.Settings.MarionetteMoveSpeed.Value); _agent.acceleration = 5.5f; _agent.angularSpeed = 140f; _agent.radius = 0.35f; _agent.height = 1.25f; _agent.stoppingDistance = 1.5f; _spawned = MarionetteSpawner.Spawn(position + Vector3.up * 1.55f); if ((Object)(object)_spawned?.Main?.Phys == (Object)null) { return false; } ((Component)_spawned.Main.Phys).gameObject.AddComponent().Initialize(this, _spawned.Main); ((Component)_spawned.Main.Phys).gameObject.AddComponent().Initialize(this, 0); _phase = Random.Range(0f, MathF.PI * 2f); _scanTimer = 0.2f; _destinationTimer = 0.1f; _limbBeamRetry = 0.35f; _controlBeamRetry = 0.45f; _soundTimer = Random.Range(0.8f, 1.25f); _state = State.Search; _initialized = true; PinVisuals(immediate: true); EnsureMainOpen(); Plugin.Log.LogInfo((object)$"The Marionette assembled one visible Feather Drone and five networked puppet-string beams with {_health} HP."); return true; } internal bool ActivateNavigation(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; return ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform, 6f); } private void Update() { //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Invalid comparison between Unknown and I4 if (!_initialized || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (_dead) { UpdateDeath(); return; } float deltaTime = Time.deltaTime; _scanTimer -= deltaTime; _destinationTimer -= deltaTime; _soundTimer -= deltaTime; _limbBeamRetry -= deltaTime; _controlBeamRetry -= deltaTime; _stateTimer += deltaTime; _stunTimer = Mathf.Max(0f, _stunTimer - deltaTime); UpdateHeading(); UpdateVisualHeight(); if (_stunTimer > 0f) { StopAgent(); } else { switch (_state) { case State.Search: UpdateSearch(); break; case State.Approach: UpdateApproach(); break; case State.Manipulate: UpdateManipulate(); break; case State.Retreat: UpdateRetreat(); break; case State.Restrict: UpdateRestrict(); break; } } PinVisuals(immediate: false); EnsureMainOpen(); if (_limbBeamsReady && _limbBeamRetry <= 0f) { _limbBeamRetry = 0.8f; _limbBeamsReady = LimbBeamsHealthy(); } if (!_limbBeamsReady && _limbBeamRetry <= 0f) { _limbBeamRetry = 0.8f; _limbBeamsReady = AttachLimbBeams(); } if (_state == State.Manipulate && TargetValid() && !_controlBeamAttached && _controlBeamRetry <= 0f) { _controlBeamRetry = 0.55f; _controlBeamAttached = AttachControlBeam(); } if (_controlBeamAttached && _state == State.Manipulate) { MarionetteDronePart marionetteDronePart = ControlBeamEmitter(); if (marionetteDronePart == null || (int)(marionetteDronePart.Drone?.currentState).GetValueOrDefault() != 3) { _controlBeamAttached = false; _controlBeamRetry = 0f; } } UpdateAudio(); } private void UpdateSearch() { if (_scanTimer <= 0f) { _scanTimer = 0.3f; FindTarget(); if (TargetValid()) { SetState(State.Approach); return; } } if (!(_destinationTimer > 0f)) { _destinationTimer = Random.Range(2.5f, 4.2f); ModEnemyNavigation.TrySetLocalRoamDestination(_agent, ((Component)this).transform, 5.5f, 13.5f); } } private void UpdateApproach() { //IL_0010: 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_0046: 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_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_003a: 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 (!TargetValid()) { ResetSearch(); return; } Vector3 val = TargetPoint(); if (_destinationTimer <= 0f) { _destinationTimer = 0.25f; ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, val, 3.5f); } Vector3 val2 = val - ((Component)this).transform.position; val2.y = 0f; if (!(((Vector3)(ref val2)).magnitude > 2.65f) && !(_visualHeight > 2.1000001f)) { _forcedPlayer = FindNearestPlayer(((Component)this).transform.position, 11.5f, EnemyValid(_enemyTarget) ? _enemyTarget : null); if (!GunAccess.IsLiving(_forcedPlayer)) { ResetSearch(); return; } StopAgent(); SetState(State.Manipulate); BodyImpact(118f); } } private void UpdateManipulate() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (!TargetValid() || !GunAccess.IsLiving(_forcedPlayer)) { ResetSearch(); return; } ForceCurrentTarget(); if (!(_stateTimer < 1.2f)) { ClearControlBeam(); LevelPoint val = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 10f); if ((Object)(object)val != (Object)null) { ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, ((Component)val).transform.position, 4f); } SetState(State.Retreat); } } private void UpdateRetreat() { if (TargetValid() && GunAccess.IsLiving(_forcedPlayer) && _stateTimer < 3.05f) { ForceCurrentTarget(); } if (!(_stateTimer < 3.1f)) { ResetSearch(); } } private void UpdateRestrict() { StopAgent(); if (!GunAccess.IsLiving(_restrictedPlayer) || _stateTimer >= Mathf.Max(1f, Plugin.Settings.MarionetteDisarmSeconds.Value)) { _restrictedPlayer = null; SetState(State.Retreat); return; } PhysGrabber physGrabber = _restrictedPlayer.physGrabber; if ((Object)(object)physGrabber != (Object)null) { physGrabber.OverrideGrabRelease(-1, 0.35f); physGrabber.OverrideGrabDisable(0.35f); } } private void FindTarget() { //IL_0013: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) _enemyTarget = FindEnemy(); _customTarget = MarionetteAggressionBridge.FindNearest(((Component)this).transform.position, 11.5f); if (!((Object)(object)_enemyTarget == (Object)null) && _customTarget != null) { Vector3 val = ((Component)_enemyTarget).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; val = _customTarget.BeamTransform.position - ((Component)this).transform.position; float sqrMagnitude2 = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude <= sqrMagnitude2) { _customTarget = null; } else { _enemyTarget = null; } } } private Enemy FindEnemy() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) Enemy result = null; float num = 132.25f; Enemy[] array = Object.FindObjectsOfType(); foreach (Enemy val in array) { if (EnemyValid(val)) { Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val; } } } return result; } private bool TargetValid() { if (!EnemyValid(_enemyTarget)) { return MarionetteAggressionBridge.Valid(_customTarget); } return true; } private Vector3 TargetPoint() { //IL_0072: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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) if (EnemyValid(_enemyTarget)) { PhysGrabObject val = FindEnemyBeamPhys(_enemyTarget); if (!((Object)(object)val != (Object)null)) { return ((Component)_enemyTarget).transform.position + Vector3.up * 0.7f; } return val.centerPoint; } if (!MarionetteAggressionBridge.Valid(_customTarget)) { return ((Component)this).transform.position; } return _customTarget.BeamTransform.position; } private static PhysGrabObject FindEnemyBeamPhys(Enemy enemy) { if ((Object)(object)enemy == (Object)null) { return null; } try { object? obj = EnemyRigidbodyField?.GetValue(enemy); EnemyRigidbody val = (EnemyRigidbody)((obj is EnemyRigidbody) ? obj : null); PhysGrabObject val2 = (PhysGrabObject)(((Object)(object)val != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); if (IsUsableBeamPhys(val2)) { return val2; } } catch { } EnemyParent componentInParent = ((Component)enemy).GetComponentInParent(); PhysGrabObject[] componentsInChildren = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).gameObject : ((Component)enemy).gameObject).GetComponentsInChildren(true); foreach (PhysGrabObject val3 in componentsInChildren) { if (IsUsableBeamPhys(val3)) { return val3; } } return null; } private static bool IsUsableBeamPhys(PhysGrabObject phys) { if ((Object)(object)phys == (Object)null || !((Component)phys).gameObject.activeInHierarchy) { return false; } PhotonView val = FindPhotonView(phys); PhysGrabObjectCollider componentInChildren = ((Component)phys).GetComponentInChildren(true); if ((Object)(object)val != (Object)null && (!GameManager.Multiplayer() || val.ViewID != 0)) { return (Object)(object)componentInChildren != (Object)null; } return false; } private void ForceCurrentTarget() { if (EnemyValid(_enemyTarget)) { ForceVanillaTarget(_enemyTarget, _forcedPlayer); } else { MarionetteAggressionBridge.Force(_customTarget, _forcedPlayer); } } private static void ForceVanillaTarget(Enemy enemy, PlayerAvatar player) { if (!((Object)(object)enemy == (Object)null) && GunAccess.IsLiving(player)) { MarionetteAggressionBridge.ForceVanilla(enemy, player); } } private static bool EnemyValid(Enemy enemy) { if ((Object)(object)enemy == (Object)null || !((Component)enemy).gameObject.activeInHierarchy) { return false; } EnemyHealth val = ((Component)enemy).GetComponentInParent() ?? ((Component)enemy).GetComponentInChildren(true); if (!((Object)(object)val == (Object)null) && !(EnemyDeadField == null)) { return !(bool)EnemyDeadField.GetValue(val); } return true; } private static PlayerAvatar FindNearestPlayer(Vector3 position, float radius, Enemy vanillaEnemy = null) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar result = null; float num = radius * radius; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item) && (!((Object)(object)vanillaEnemy != (Object)null) || MarionetteAggressionBridge.PlayerReadyForVanillaEnemy(vanillaEnemy, item))) { Vector3 val = ((Component)item).transform.position - position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = item; } } } return result; } private void BeginDisarm(Vector3 point) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar val = FindNearestPlayer(point, 18f); if (GunAccess.IsLiving(val)) { _restrictedPlayer = val; SetState(State.Restrict); BodyImpact(132f); } } private bool AttachLimbBeams() { //IL_00cf: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) if (_spawned == null || NewRayHitPointMethod == null) { return false; } if (!_limbBeamWarmupStarted || _spawned.LimbEmitters.Exists((MarionetteDronePart part) => (Object)(object)part?.Toggle == (Object)null || !part.Toggle.toggleState)) { _limbBeamWarmupStarted = true; foreach (MarionetteDronePart limbEmitter in _spawned.LimbEmitters) { if ((Object)(object)limbEmitter?.Toggle != (Object)null && !limbEmitter.Toggle.toggleState) { limbEmitter.Toggle.ToggleItem(true, -1); } } _limbBeamRetry = 0.26f; return false; } bool flag = true; Vector3 center = VisualCenter(); Vector3 val = ((((Vector3)(ref _visualForward)).sqrMagnitude > 0.01f) ? ((Vector3)(ref _visualForward)).normalized : Vector3.forward); Vector3 val2 = Vector3.Cross(Vector3.up, val); Vector3 normalized = ((Vector3)(ref val2)).normalized; BuildPuppetPose(center, val, normalized, out var joints, out var _); for (int num = 0; num < _spawned.LimbEmitters.Count; num++) { Vector3 attachPoint = joints[Mathf.Min(num, joints.Length - 1)]; if (!TryAttachNativeBeam(_spawned.LimbEmitters[num], _spawned.Main, attachPoint, num)) { flag = false; } } if (flag) { Plugin.Log.LogInfo((object)"The Marionette attached its five collisionless native beams as a torso, two arms and two legs."); } return flag; } private bool LimbBeamsHealthy() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 if (_spawned == null || _spawned.LimbEmitters.Count < 5) { return false; } foreach (MarionetteDronePart limbEmitter in _spawned.LimbEmitters) { if ((Object)(object)limbEmitter?.Drone == (Object)null || (int)limbEmitter.Drone.currentState != 3) { return false; } } return true; } private static bool TryAttachNativeBeam(MarionetteDronePart source, MarionetteDronePart target, Vector3 attachPoint, int index) { //IL_0151: Unknown result type (might be due to invalid IL or missing references) PhotonView val = target?.View ?? FindPhotonView(target?.Phys); object obj; if (target == null) { obj = null; } else { PhysGrabObject phys = target.Phys; obj = ((phys != null) ? ((Component)phys).GetComponentInChildren(true) : null); } PhysGrabObjectCollider val2 = (PhysGrabObjectCollider)obj; if ((Object)(object)source?.Drone == (Object)null || (Object)(object)source.Toggle == (Object)null || (Object)(object)target?.Phys == (Object)null || (Object)(object)val == (Object)null || (GameManager.Multiplayer() && val.ViewID == 0) || (Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)($"The Marionette limb beam {index} endpoint was incomplete " + $"(sourceDrone={(Object)(object)source?.Drone != (Object)null}, toggle={(Object)(object)source?.Toggle != (Object)null}, " + $"targetPhys={(Object)(object)target?.Phys != (Object)null}, view={(((Object)(object)val != (Object)null) ? val.ViewID : 0)}, " + $"collider={(Object)(object)val2 != (Object)null}).")); return false; } try { NewRayHitPointMethod.Invoke(source.Drone, new object[4] { attachPoint, val.ViewID, val2.colliderID, ((Component)target.Phys).transform }); source.Drone.MagnetActiveToggle(true); source.Drone.StateSet((State)3); return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)$"The Marionette could not attach limb beam {index}: {ex.GetBaseException().Message}"); return false; } } private bool AttachControlBeam() { //IL_00f2: Unknown result type (might be due to invalid IL or missing references) MarionetteDronePart marionetteDronePart = ControlBeamEmitter(); if ((Object)(object)marionetteDronePart?.Drone == (Object)null || (Object)(object)marionetteDronePart.Toggle == (Object)null || NewRayHitPointMethod == null) { return false; } if (!marionetteDronePart.Toggle.toggleState) { marionetteDronePart.Toggle.ToggleItem(true, -1); _controlBeamRetry = 0.26f; return false; } PhysGrabObject val = (EnemyValid(_enemyTarget) ? FindEnemyBeamPhys(_enemyTarget) : FindCustomBeamPhys(_customTarget)); if ((Object)(object)val == (Object)null) { LogControlBeamFailure("no networked PhysGrabObject was found in the complete enemy hierarchy"); return false; } PhotonView val2 = FindPhotonView(val); PhysGrabObjectCollider componentInChildren = ((Component)val).GetComponentInChildren(true); if ((Object)(object)val2 == (Object)null || (GameManager.Multiplayer() && val2.ViewID == 0) || (Object)(object)componentInChildren == (Object)null) { LogControlBeamFailure("the selected PhysGrabObject has no same-object PhotonView/collider endpoint"); return false; } try { NewRayHitPointMethod.Invoke(marionetteDronePart.Drone, new object[4] { ((Component)componentInChildren).transform.position, val2.ViewID, componentInChildren.colliderID, ((Component)val).transform }); marionetteDronePart.Drone.MagnetActiveToggle(true); marionetteDronePart.Drone.StateSet((State)3); _controlBeamFailureLogged = false; Plugin.Log.LogInfo((object)("The Marionette connected its control beam to " + TargetDebugName() + ".")); return true; } catch (Exception ex) { Plugin.Log.LogDebug((object)("The Marionette could not attach its control beam: " + ex.GetBaseException().Message)); return false; } } private static PhysGrabObject FindCustomBeamPhys(MarionetteAggressionBridge.Target target) { if (!MarionetteAggressionBridge.Valid(target)) { return null; } PhysGrabObject componentInParent = ((Component)target.BeamTransform).GetComponentInParent(); if (IsUsableBeamPhys(componentInParent)) { return componentInParent; } PhysGrabObject[] componentsInChildren = ((Component)target.Controller).GetComponentsInChildren(true); foreach (PhysGrabObject val in componentsInChildren) { if (IsUsableBeamPhys(val)) { return val; } } componentsInChildren = ((Component)target.Controller).GetComponentsInParent(true); foreach (PhysGrabObject val2 in componentsInChildren) { if (IsUsableBeamPhys(val2)) { return val2; } } return null; } private static PhotonView FindPhotonView(PhysGrabObject phys) { if ((Object)(object)phys == (Object)null) { return null; } PhotonView val = ((Component)phys).GetComponent() ?? ((Component)phys).GetComponentInParent() ?? ((Component)phys).GetComponentInChildren(true); if (!((Object)(object)val != (Object)null) || (GameManager.Multiplayer() && val.ViewID == 0)) { return null; } return val; } private string TargetDebugName() { if ((Object)(object)_enemyTarget != (Object)null) { EnemyParent componentInParent = ((Component)_enemyTarget).GetComponentInParent(); if (!((Object)(object)componentInParent != (Object)null)) { return ((Object)_enemyTarget).name; } return componentInParent.enemyName; } if (!((Object)(object)_customTarget?.Controller != (Object)null)) { return "unknown target"; } return ((object)_customTarget.Controller).GetType().Name; } private void LogControlBeamFailure(string reason) { if (!_controlBeamFailureLogged) { _controlBeamFailureLogged = true; Plugin.Log.LogWarning((object)("The Marionette found " + TargetDebugName() + " but could not connect: " + reason + ".")); } } private void ClearControlBeam() { _controlBeamAttached = false; _controlBeamFailureLogged = false; _controlBeamRetry = 0.45f; MarionetteDronePart marionetteDronePart = ControlBeamEmitter(); if (!((Object)(object)marionetteDronePart?.Drone == (Object)null)) { marionetteDronePart.Drone.MagnetActiveToggle(false); marionetteDronePart.Drone.StateSet((State)0); EnsureMainOpen(); } } private MarionetteDronePart ControlBeamEmitter() { return _spawned?.Main; } private void EnsureMainOpen() { MarionetteDronePart marionetteDronePart = _spawned?.Main; if ((Object)(object)marionetteDronePart?.Toggle == (Object)null || (Object)(object)marionetteDronePart.Drone == (Object)null || (_mainOpened && marionetteDronePart.Toggle.toggleState)) { return; } try { if (!marionetteDronePart.Toggle.toggleState) { marionetteDronePart.Toggle.ToggleItem(true, -1); } if (!_controlBeamAttached) { marionetteDronePart.Drone.MagnetActiveToggle(false); marionetteDronePart.Drone.StateSet((State)0); } _mainOpened = true; } catch (Exception ex) { Plugin.Log.LogDebug((object)("The Marionette could not keep its visible Feather Drone open: " + ex.Message)); } } private void UpdateHeading() { //IL_0028: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) ? _agent.velocity : Vector3.zero); val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.04f) { Vector3 val2 = Vector3.Slerp(_visualForward, ((Vector3)(ref val)).normalized, 1f - Mathf.Exp(-3.8f * Time.deltaTime)); _visualForward = ((Vector3)(ref val2)).normalized; } } private void UpdateVisualHeight() { float desired = 2.48f; if (_state == State.Approach || _state == State.Manipulate || _state == State.Restrict) { desired = 1.82f; } desired = CeilingLimitedHeight(desired); float num = ((desired < _visualHeight) ? 2.9f : 1.65f); _visualHeight = Mathf.Lerp(_visualHeight, desired, 1f - Mathf.Exp((0f - num) * Time.deltaTime)); } private float CeilingLimitedHeight(float desired) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_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_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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) RaycastHit[] array = Physics.RaycastAll(((Component)this).transform.position + Vector3.up * 0.22f, Vector3.up, 7f, -5, (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val = array2[num]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && !IsOwnCollider(((RaycastHit)(ref val)).collider)) { return Mathf.Clamp(((RaycastHit)(ref val)).point.y - ((Component)this).transform.position.y - 1.18f, 1.08f, desired); } } return desired; } private bool IsOwnCollider(Collider collider) { if ((Object)(object)collider == (Object)null || _spawned == null) { return false; } if (BelongsToDrone(collider, _spawned.Main) || BelongsToDrone(collider, _spawned.ControlEmitter)) { return true; } foreach (MarionetteDronePart limbEmitter in _spawned.LimbEmitters) { if (BelongsToDrone(collider, limbEmitter)) { return true; } } return false; } private static bool BelongsToDrone(Collider collider, MarionetteDronePart part) { Transform val = (((Object)(object)part?.Root != (Object)null) ? part.Root.transform : (((Object)(object)part?.Phys != (Object)null) ? ((Component)part.Phys).transform : null)); if ((Object)(object)val != (Object)null) { if (!((Object)(object)((Component)collider).transform == (Object)(object)val)) { return ((Component)collider).transform.IsChildOf(val); } return true; } return false; } private Vector3 VisualCenter() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) return ((Component)this).transform.position + Vector3.up * (_visualHeight + Mathf.Sin(Time.time * 1.8f + _phase) * 0.1f); } private void PuppetBodySway(Vector3 forward, Vector3 right, out Vector3 shoulderOffset, out Vector3 pelvisOffset) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) float num = Time.time * 0.72f + _phase; float num2 = Mathf.Sin(num) * 0.085f; float num3 = Mathf.Sin(num * 0.83f + 1.1f) * 0.026f; float num4 = 0.155f + Mathf.Sin(num * 0.61f + 2.2f) * 0.035f; shoulderOffset = right * num2 + forward * num4 + Vector3.up * num3; pelvisOffset = right * (num2 * 0.38f) + forward * (num4 * 0.2f) - Vector3.up * (num3 * 0.22f); } private void BuildPuppetPose(Vector3 center, Vector3 forward, Vector3 right, out Vector3[] joints, out Vector3[] ends) { //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) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_002b: 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_003f: 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_0120: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_0131: 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_013a: 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_0143: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_01a1: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0215: 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_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) PuppetBodySway(forward, right, out var shoulderOffset, out var pelvisOffset); Vector3 val = center + Vector3.up * 0.61f + shoulderOffset; Vector3 val2 = val; Vector3 val3 = center - Vector3.up * 0.06f + pelvisOffset; float num = Time.time * 1.48f + _phase; float num2 = Mathf.Sin(num) * 0.09f; float num3 = Mathf.Sin(num + MathF.PI * 41f / 50f) * 0.09f; float num4 = Mathf.Sin(num * 0.73f + 0.4f) * 0.1f; float num5 = Mathf.Sin(num * 0.79f + 2.1f) * 0.1f; float num6 = Mathf.Sin(num * 1.08f + 0.5f) * 0.08f; float num7 = Mathf.Sin(num * 0.94f + 2.2f) * 0.08f; float num8 = Mathf.Sin(num * 0.82f + 1.1f) * 0.09f; float num9 = Mathf.Sin(num * 0.76f + 2.7f) * 0.09f; joints = (Vector3[])(object)new Vector3[5] { val2, val, val, val3, val3 }; ends = (Vector3[])(object)new Vector3[5] { val3 - Vector3.up * 0.035f, center + shoulderOffset * 0.56f - right * (0.43f + num2) - Vector3.up * (0.18f + num6) - forward * 0.24f, center + shoulderOffset * 0.56f + right * (0.43f + num3) - Vector3.up * (0.18f + num7) - forward * 0.22f, center + pelvisOffset * 0.64f - right * (0.22f + num4) - Vector3.up * (0.94f + num8) - forward * 0.62f, center + pelvisOffset * 0.64f + right * (0.22f + num5) - Vector3.up * (0.94f + num9) - forward * 0.68f }; } private void PinVisuals(bool immediate) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0048: 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_004e: 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) //IL_0060: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_007b: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) Vector3 val = VisualCenter(); Vector3 val2 = ((((Vector3)(ref _visualForward)).sqrMagnitude > 0.01f) ? _visualForward : Vector3.forward); Vector3 pelvisOffset = Vector3.Cross(Vector3.up, val2); Vector3 normalized = ((Vector3)(ref pelvisOffset)).normalized; PuppetBodySway(val2, normalized, out var shoulderOffset, out pelvisOffset); Quaternion val3 = Quaternion.LookRotation(Vector3.down, val2); PinDrone(_spawned.Main, val + Vector3.up * 0.62f + shoulderOffset, val3, immediate); if (_spawned.ControlEmitter != null) { PinDrone(_spawned.ControlEmitter, val + Vector3.up * 0.48f + shoulderOffset, val3, immediate); } BuildPuppetPose(val, val2, normalized, out var joints, out var ends); int num = Mathf.Min(5, _spawned.LimbEmitters.Count); for (int i = 0; i < num; i++) { Vector3 val4 = joints[i] - ends[i]; Quaternion rotation = ((((Vector3)(ref val4)).sqrMagnitude > 0.001f) ? Quaternion.LookRotation(((Vector3)(ref val4)).normalized, Vector3.up) : val3); PinDrone(_spawned.LimbEmitters[i], ends[i], rotation, immediate); } } private static void PinDrone(MarionetteDronePart part, Vector3 visualCenter, Quaternion rotation, bool immediate) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)part?.Phys == (Object)null)) { part.Phys.OverrideGrabDisable(0.3f); if (part.Main) { part.Phys.OverrideKinematic(0.3f); } part.Phys.OverrideIndestructible(0.3f); if ((Object)(object)part.Phys.rb != (Object)null && !part.Phys.rb.isKinematic) { part.Phys.rb.velocity = Vector3.zero; part.Phys.rb.angularVelocity = Vector3.zero; } Vector3 val = (part.Main ? part.VisualCenterOffset : part.BeamStartOffset); Vector3 val2 = visualCenter - rotation * val; part.Phys.SetPositionLogic(val2, rotation); } } private void UpdateAudio() { if (!(_soundTimer > 0f)) { _soundTimer = Random.Range(0.85f, 1.35f); BodyImpact((_state == State.Manipulate || _state == State.Restrict) ? 82f : 38f); } } private void BodyImpact(float force) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) SpawnedMarionette spawned = _spawned; if (spawned == null) { return; } MarionetteDronePart main = spawned.Main; if (main != null) { PhysGrabObjectImpactDetector impact = main.Impact; if (impact != null) { impact.ImpactLight(force, _spawned.Main.Phys.centerPoint); } } } private void StopAgent() { if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } } private void SetState(State state) { _state = state; _stateTimer = 0f; } private void ResetSearch() { ClearControlBeam(); _enemyTarget = null; _customTarget = null; _forcedPlayer = null; _restrictedPlayer = null; SetState(State.Search); _scanTimer = 0f; } internal bool TryClaimWeaponHit(int sourceId) { if (_dead || !ModEnemyWeaponDamage.TryClaim((Object)(object)this, sourceId) || Time.time - _lastClaimedHit < 0.055f) { return false; } _lastClaimedHit = Time.time; return true; } internal void ReceiveWeaponHit(Vector3 point, int damage) { //IL_003b: 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) if (!_dead && damage > 0) { _health -= damage; ModEnemyFeedback.DamageHit(_spawned.Main.Impact, _spawned.Main.Phys, point, 96f); if (_health <= 0) { Die(); } else { BeginDisarm(point); } } } internal void ExecuteForLab() { if (!_dead) { _health = 0; Die(); } } public void ReceiveTumbleAttack(int partIndex, int damage, Vector3 point, Vector3 direction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ReceiveWeaponHit(point, Mathf.Max(1, damage)); } public void OnTranqStunned(float duration) { _stunTimer = Mathf.Max(_stunTimer, Mathf.Clamp(duration, 0.6f, 5f)); } private void Die() { if (_dead) { return; } _dead = true; SetState(State.Dead); StopAgent(); MarionetteDronePart[] array = new MarionetteDronePart[2] { _spawned.Main, _spawned.ControlEmitter }; foreach (MarionetteDronePart marionetteDronePart in array) { if (!((Object)(object)marionetteDronePart?.Impact == (Object)null)) { marionetteDronePart.Impact.destroyDisable = false; marionetteDronePart.Impact.DestroyObject(true); } } foreach (MarionetteDronePart limbEmitter in _spawned.LimbEmitters) { if ((Object)(object)limbEmitter?.Impact != (Object)null) { limbEmitter.Impact.destroyDisable = false; limbEmitter.Impact.DestroyObject(true); } } _rewardTimer = 0.08f; } private void UpdateDeath() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (_rewardDropped) { return; } _rewardTimer -= Time.deltaTime; if (_rewardTimer > 0f) { return; } _rewardDropped = true; if (Plugin.Settings.MarionetteDropEnemyValuable.Value && !((Object)(object)AssetManager.instance?.enemyValuableMedium == (Object)null)) { GameObject enemyValuableMedium = AssetManager.instance.enemyValuableMedium; Vector3 val = ((Component)this).transform.position + Vector3.up * 0.5f; if (GameManager.Multiplayer()) { PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)enemyValuableMedium).name, val, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate(enemyValuableMedium, val, Quaternion.identity); } } } private void OnDestroy() { if (_initialized && !_cleaning && SemiFunc.IsMasterClientOrSingleplayer()) { _cleaning = true; if (!_dead) { MarionetteSpawner.Destroy(_spawned); } } } } internal sealed class MarionetteHitProxy : MonoBehaviour { private MarionetteController _controller; private MarionetteDronePart _part; private float _cooldown; internal void Initialize(MarionetteController controller, MarionetteDronePart part) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown _controller = controller; _part = part; MarionetteDronePart part2 = _part; if (part2 == null) { return; } PhysGrabObjectImpactDetector impact = part2.Impact; if (impact != null) { UnityEvent onHurtColliderHit = impact.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.AddListener(new UnityAction(OnHit)); } } } private void Update() { _cooldown = Mathf.Max(0f, _cooldown - Time.deltaTime); } private void OnDestroy() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown MarionetteDronePart part = _part; if (part == null) { return; } PhysGrabObjectImpactDetector impact = part.Impact; if (impact != null) { UnityEvent onHurtColliderHit = impact.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.RemoveListener(new UnityAction(OnHit)); } } } private void OnHit() { //IL_0072: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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)_controller == (Object)null || _cooldown > 0f || !SemiFunc.IsMasterClientOrSingleplayer() || !_controller.TryClaimWeaponHit(ModEnemyWeaponDamage.CurrentClaimId)) { return; } _cooldown = 0.14f; Vector3 val = (((Object)(object)_part?.Phys != (Object)null) ? _part.Phys.centerPoint : ((Component)this).transform.position); if (EnemyLabBridge.IsExecutionHitNear(val)) { _controller.ExecuteForLab(); return; } int num = ModEnemyWeaponDamage.CurrentOrFallback(Plugin.Settings.MarionetteDamagePerHit.Value); if (num > 0) { _controller.ReceiveWeaponHit(val, num); } } } internal sealed class MarionetteManager : MonoBehaviour { private int _levelId; private float _timer; private bool _done; private bool _probed; private MarionetteController _encounter; internal void Tick() { //IL_010b: Unknown result type (might be due to invalid IL or missing references) if (!Host()) { return; } if (!_probed && (Object)(object)RunManager.instance != (Object)null) { _probed = true; Plugin.Log.LogInfo((object)$"The Marionette prefab probe: available={MarionetteSpawner.PrefabsAvailable()}."); } int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { DestroyCurrent(); _levelId = num; _timer = Plugin.Settings.MarionetteSpawnDelay.Value; _done = false; } if (!ModEnemyLevelRules.IsPlayableLevel()) { DestroyCurrent(); } else { if ((Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated || _done) { return; } _timer -= Time.deltaTime; if (!(_timer > 0f)) { _done = true; if (Random.value <= Mathf.Clamp01(Plugin.Settings.MarionetteSpawnChance.Value) && FindSpawn(out var position)) { Create(position, "automatic"); } } } } private bool Create(Vector3 position, string source) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_001e: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) DestroyCurrent(); GameObject val = new GameObject("The Marionette Encounter (Host Logic)"); val.SetActive(false); val.transform.position = position; MarionetteController marionetteController = val.AddComponent(); if (!marionetteController.Initialize(position)) { Object.Destroy((Object)(object)val); return false; } val.SetActive(true); if (!marionetteController.ActivateNavigation(position)) { Object.Destroy((Object)(object)val); return false; } _encounter = marionetteController; Plugin.Log.LogInfo((object)$"The Marionette spawned at {position} ({source})."); return true; } internal bool DebugSpawnAt(Vector3 position) { //IL_0024: 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) if (!Host() || (!ModEnemySpawnCoordinator.IsDirectorRequestActive && (Object)(object)PlayerAvatar.instance == (Object)null) || !ModEnemyLevelRules.IsPlayableLevel()) { return false; } NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(position, ref val, 12f, -1)) { return false; } _done = true; return Create(((NavMeshHit)(ref val)).position, ModEnemySpawnCoordinator.CurrentSpawnSource); } internal void MarkAutomaticAttemptFinished() { int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { DestroyCurrent(); _levelId = num; _timer = Plugin.Settings.MarionetteSpawnDelay.Value; } _done = true; } internal void DebugDespawn() { if (Host()) { _done = true; DestroyCurrent(); } } private void DestroyCurrent() { if ((Object)(object)_encounter != (Object)null) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); _encounter = null; } } private static bool FindSpawn(out Vector3 position) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_006b: 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_004f: 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) Vector3 val = (((Object)(object)PlayerAvatar.instance != (Object)null) ? ((Component)PlayerAvatar.instance).transform.position : Vector3.zero); LevelPoint val2 = SemiFunc.LevelPointGetPlayerDistance(val, 16f, 55f, false) ?? SemiFunc.LevelPointGetFurthestFromPlayer(val, 7f); return ModEnemyNavigation.TryFindClearSpawn(((Object)(object)val2 != (Object)null) ? ((Component)val2).transform.position : (val + Vector3.forward * 18f), 7f, out position); } private static bool Host() { try { return (Object)(object)GameManager.instance != (Object)null && (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient); } catch { return false; } } } internal sealed class MarionetteDronePart { internal GameObject Root; internal PhysGrabObject Phys; internal PhysGrabObjectImpactDetector Impact; internal ItemAttributes Attributes; internal PhotonView View; internal ItemDrone Drone; internal ItemToggle Toggle; internal ItemBattery Battery; internal Vector3 VisualCenterOffset; internal Vector3 BeamStartOffset; internal bool Main; } internal sealed class SpawnedMarionette { internal MarionetteDronePart Main; internal MarionetteDronePart ControlEmitter; internal readonly List LimbEmitters = new List(); } internal static class MarionetteSpawner { internal const string DroneResourcePath = "Items/Item Drone Feather"; private const float BeamEmitterScale = 0.045f; internal static bool PrefabsAvailable() { return (Object)(object)Resources.Load("Items/Item Drone Feather") != (Object)null; } internal static SpawnedMarionette Spawn(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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) if (!PrefabsAvailable()) { return null; } SpawnedMarionette spawnedMarionette = new SpawnedMarionette { Main = SpawnDrone(position, 1.08f, main: true) }; if (spawnedMarionette.Main == null) { return null; } Vector3 position2 = default(Vector3); ((Vector3)(ref position2))..ctor(position.x, 3000f, position.z); for (int i = 0; i < 5; i++) { MarionetteDronePart marionetteDronePart = SpawnDrone(position2, 0.045f, main: false); if (marionetteDronePart == null) { Destroy(spawnedMarionette); return null; } spawnedMarionette.LimbEmitters.Add(marionetteDronePart); } spawnedMarionette.ControlEmitter = SpawnDrone(position2, 0.045f, main: false); if (spawnedMarionette.ControlEmitter == null) { Destroy(spawnedMarionette); return null; } return spawnedMarionette; } internal static MarionetteDronePart SpawnBeamEmitter(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return SpawnDrone(position, 0.045f, main: false); } internal static MarionetteDronePart SpawnBeamEmitter(Vector3 position, string resourcePath) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return SpawnDrone(position, 0.045f, main: false, resourcePath); } private static MarionetteDronePart SpawnDrone(Vector3 position, float scale, bool main, string resourcePath = "Items/Item Drone Feather") { //IL_0018: 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_0023: 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_003a: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0364: 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_0409: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04af: 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_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_046f: 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_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) GameObject val = Resources.Load(resourcePath); if ((Object)(object)val == (Object)null) { return null; } Vector3 val2 = val.transform.localScale * scale; object[] array = new object[3] { val2.x, val2.y, val2.z }; GameObject val3; try { val3 = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject(resourcePath, position, Quaternion.identity, (byte)0, array) : Object.Instantiate(val, position, Quaternion.identity)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("The Marionette could not spawn beam resource '" + resourcePath + "': " + ex.Message)); return null; } val3.transform.localScale = val2; val3.AddComponent(); ModEnemyInventoryBlocker.Attach(val3); EncounterValuableNeutralizer.Apply(val3); MarionetteDronePart marionetteDronePart = new MarionetteDronePart { Root = val3, Phys = val3.GetComponentInChildren(true), Impact = val3.GetComponentInChildren(true), Attributes = val3.GetComponentInChildren(true), View = val3.GetComponentInChildren(true), Drone = val3.GetComponentInChildren(true), Toggle = val3.GetComponentInChildren(true), Battery = val3.GetComponentInChildren(true), Main = main }; if ((Object)(object)marionetteDronePart.Phys == (Object)null || (Object)(object)marionetteDronePart.Impact == (Object)null || (Object)(object)marionetteDronePart.View == (Object)null || (Object)(object)marionetteDronePart.Drone == (Object)null || (Object)(object)marionetteDronePart.Toggle == (Object)null) { DestroyDrone(marionetteDronePart); return null; } ItemAttributes attributes = marionetteDronePart.Attributes; if (attributes != null) { attributes.DisableUI(true); } marionetteDronePart.Impact.destroyDisable = true; marionetteDronePart.Impact.playerHurtDisable = true; marionetteDronePart.Phys.OverrideGrabDisable(1f); if (main) { marionetteDronePart.Phys.OverrideKinematic(1f); } marionetteDronePart.Phys.OverrideIndestructible(1f); marionetteDronePart.Phys.clientNonKinematic = false; Rigidbody[] componentsInChildren = val3.GetComponentsInChildren(true); foreach (Rigidbody val4 in componentsInChildren) { if (!((Object)(object)val4 == (Object)null)) { val4.useGravity = false; if (!main) { val4.isKinematic = false; val4.detectCollisions = false; } if (!val4.isKinematic) { val4.velocity = Vector3.zero; val4.angularVelocity = Vector3.zero; } } } if ((Object)(object)marionetteDronePart.Battery != (Object)null) { marionetteDronePart.Battery.batteryLife = Mathf.Max(10000f, marionetteDronePart.Battery.batteryLife); marionetteDronePart.Battery.batteryDrainRate = 0f; SuppressBatteryUi(marionetteDronePart.Battery); } marionetteDronePart.Drone.targetValuables = false; marionetteDronePart.Drone.targetPlayers = false; marionetteDronePart.Drone.targetEnemies = false; marionetteDronePart.Drone.targetNonValuables = false; ItemDroneIndestructible componentInChildren = val3.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { ((Behaviour)componentInChildren).enabled = false; } if (!main) { Collider[] componentsInChildren2 = val3.GetComponentsInChildren(true); foreach (Collider val5 in componentsInChildren2) { if ((Object)(object)val5 != (Object)null) { val5.enabled = false; } } } else { Collider[] componentsInChildren2 = val3.GetComponentsInChildren(true); foreach (Collider val6 in componentsInChildren2) { BoxCollider val7 = (BoxCollider)(object)((val6 is BoxCollider) ? val6 : null); if (val7 != null) { val7.size *= 0.7f; continue; } SphereCollider val8 = (SphereCollider)(object)((val6 is SphereCollider) ? val6 : null); if (val8 != null) { val8.radius *= 0.7f; continue; } CapsuleCollider val9 = (CapsuleCollider)(object)((val6 is CapsuleCollider) ? val6 : null); if (val9 != null) { val9.radius *= 0.7f; val9.height *= 0.78f; } } } ItemDroneFeather componentInChildren2 = val3.GetComponentInChildren(true); if ((Object)(object)componentInChildren2 != (Object)null) { ((Behaviour)componentInChildren2).enabled = false; } MapIconSuppressor.Attach(val3); Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(val3.transform.position, Vector3.zero); bool flag = false; Renderer[] componentsInChildren3 = val3.GetComponentsInChildren(true); foreach (Renderer val10 in componentsInChildren3) { if ((val10 is MeshRenderer || val10 is SkinnedMeshRenderer) && val10.enabled && ((Component)val10).gameObject.activeInHierarchy) { if (!flag) { bounds = val10.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val10.bounds); } } } Vector3 val11 = (flag ? val3.transform.InverseTransformVector(((Bounds)(ref bounds)).center - val3.transform.position) : Vector3.zero); marionetteDronePart.VisualCenterOffset = ((((Vector3)(ref val11)).sqrMagnitude <= 4f) ? val11 : Vector3.zero); marionetteDronePart.BeamStartOffset = marionetteDronePart.VisualCenterOffset; try { object? obj = typeof(ItemDrone).GetField("lineStartPoint", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(marionetteDronePart.Drone); Transform val12 = (Transform)((obj is Transform) ? obj : null); if ((Object)(object)val12 != (Object)null) { Vector3 beamStartOffset = Quaternion.Inverse(val3.transform.rotation) * (val12.position - val3.transform.position); if (((Vector3)(ref beamStartOffset)).sqrMagnitude <= 4f) { marionetteDronePart.BeamStartOffset = beamStartOffset; } } } catch { } try { marionetteDronePart.Toggle.ToggleItem(false, -1); } catch (Exception ex2) { Plugin.Log.LogDebug((object)("The Marionette could not publish its initial visible state: " + ex2.Message)); } return marionetteDronePart; } private static void SuppressBatteryUi(ItemBattery battery) { if ((Object)(object)battery == (Object)null) { return; } try { string[] array = new string[3] { "suppressBatteryUI", "hasBatteryVisuals", "showBattery" }; foreach (string text in array) { FieldInfo field = typeof(ItemBattery).GetField(text, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field?.FieldType == typeof(bool)) { field.SetValue(battery, text == "suppressBatteryUI"); } } object? obj = typeof(ItemBattery).GetField("batteryTransform", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(battery); Transform val = (Transform)((obj is Transform) ? obj : null); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } } catch { } } internal static void Destroy(SpawnedMarionette spawned) { if (spawned == null) { return; } DestroyDrone(spawned.Main); DestroyDrone(spawned.ControlEmitter); foreach (MarionetteDronePart limbEmitter in spawned.LimbEmitters) { DestroyDrone(limbEmitter); } spawned.ControlEmitter = null; spawned.LimbEmitters.Clear(); } internal static void DestroyDrone(MarionetteDronePart part) { if ((Object)(object)part?.Root == (Object)null) { return; } try { PhotonView val = part.View ?? part.Root.GetComponent(); if (GameManager.Multiplayer() && PhotonNetwork.IsMasterClient && (Object)(object)val != (Object)null && val.ViewID != 0) { PhotonNetwork.Destroy(val); } else { Object.Destroy((Object)(object)part.Root); } } catch { Object.Destroy((Object)(object)part.Root); } } } internal sealed class MimicController : MonoBehaviour, IPandemicDamageReceiver, IModEnemyTumbleReceiver { private enum State { Stalk, Record, Hide, Replay, Charge, Recover, Dead } private static readonly FieldInfo LoudnessField = typeof(PlayerVoiceChat).GetField("clipLoudness", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo VoicePlayerField = typeof(PlayerVoiceChat).GetField("playerAvatar", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private const float ResponseArmTimeoutSeconds = 2f; private const float ResponseWindowSeconds = 4f; private readonly List _parts = new List(); private readonly List _basePartScales = new List(); private readonly List _glitchScales = new List(); private readonly List _glitchEuler = new List(); private readonly List _glitchOffsets = new List(); private readonly HashSet _claimedHits = new HashSet(); private readonly MimicVoiceCapture _capture = new MimicVoiceCapture(); private readonly MimicVoiceRelay _relay = new MimicVoiceRelay(); private NavMeshAgent _agent; private PlayerAvatar _target; private PlayerVoiceChat _targetVoice; private SpawnedDeadAirPart _head; private SpawnedDeadAirPart _torso; private SpawnedDeadAirPart _pelvis; private SpawnedDeadAirPart _voiceAnchor; private State _state; private int _health; private float _stateTimer; private float _scanTimer; private float _destinationTimer; private float _soundTimer; private float _rewardTimer; private float _lastHitTime = -999f; private float _damagePulse; private float _glitchTimer; private float _glitchDuration; private float _replayResponseDelay; private float _responseQuietTimer; private float _responseVoiceTimer; private float _listenRepathTimer; private float _voiceOnsetTimer; private float _listeningDwellTimer; private float _listenStuckTimer; private float _lastListenDistance = float.MaxValue; private float _chargeContactCooldown; private float _attackPoseTimer; private int _chargeHitsRemaining; private float[] _recording; private int _recordingRate; private int _recordingChannels; private int _captureActor = -1; private Vector3 _listenPosition; private Vector3 _listenTargetOrigin; private bool _dead; private bool _cleaning; private bool _rewardDropped; private bool _initialized; private bool _glitchActive; private bool _responseWindowStarted; private bool _responseArmed; private bool _hasListenPosition; private bool _retaliating; private bool _recordWasObserved; private bool _recordRelocated; public bool CanReceiveTumbleAttack => !_dead; internal bool Initialize(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_0123: 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_016d: 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_0152: Unknown result type (might be due to invalid IL or missing references) if (!MimicSpawner.PrefabsAvailable()) { return false; } ((Component)this).transform.position = position; _health = Mathf.Max(1, Plugin.Settings.MimicHealth.Value); _agent = ((Component)this).gameObject.AddComponent(); ((Behaviour)_agent).enabled = false; _agent.speed = Mathf.Max(1f, Plugin.Settings.MimicStalkSpeed.Value); _agent.acceleration = 30f; _agent.angularSpeed = 520f; _agent.radius = 0.36f; _agent.height = 1.75f; _agent.stoppingDistance = 3.2f; _head = AddPart(MimicSpawner.HeadResourcePath, new Vector3(0.41f, 0.41f, 0.265f)); _torso = AddPart(MimicSpawner.TorsoResourcePath, new Vector3(2.08f, 2.64f, 2.3f)); _pelvis = AddPart(MimicSpawner.PelvisResourcePath, new Vector3(0.58f, 0.58f, 0.58f)); for (int i = 0; i < 8; i++) { AddPart(MimicSpawner.LimbResourcePath, Vector3.one * ((i < 4) ? 0.64f : 0.66f)); } _voiceAnchor = AddPart(MimicSpawner.TeethBotResourcePath, Vector3.one * 0.012f, preserveTeethBot: true); if (_head == null || _torso == null || _pelvis == null || _voiceAnchor == null || _parts.Count != 12) { Cleanup(effect: false); return false; } Collider[] array; foreach (SpawnedDeadAirPart part in _parts) { if (part == _torso || part == _voiceAnchor) { continue; } array = part.Colliders ?? Array.Empty(); foreach (Collider val in array) { if ((Object)(object)val != (Object)null) { val.enabled = false; } } ((Behaviour)part.ImpactDetector).enabled = false; } _voiceAnchor.ImpactDetector.destroyDisable = true; _voiceAnchor.ImpactDetector.playerHurtDisable = true; ((Behaviour)_voiceAnchor.ImpactDetector).enabled = false; array = _voiceAnchor.Colliders ?? Array.Empty(); foreach (Collider val2 in array) { if ((Object)(object)val2 == (Object)null) { continue; } foreach (SpawnedDeadAirPart part2 in _parts) { if (part2 == _voiceAnchor) { continue; } Collider[] array2 = part2.Colliders ?? Array.Empty(); foreach (Collider val3 in array2) { if ((Object)(object)val3 != (Object)null) { Physics.IgnoreCollision(val2, val3, true); } } } } ((Component)_torso.Phys).gameObject.AddComponent().Initialize(this, ConvertParts()); ((Component)_torso.Phys).gameObject.AddComponent().Initialize(this, 0); _state = State.Stalk; _scanTimer = 0.2f; _destinationTimer = 0f; _soundTimer = 0.65f; _glitchTimer = Random.Range(2.4f, 5.8f); _initialized = true; PinParts(force: true); Plugin.Log.LogInfo((object)$"The Mimic assembled a tall Watcher silhouette from one Television, one Phone, one HDD and eight Telescope limbs with {_health} HP; its hidden TeethBot voice anchor is ready."); return true; } private SpawnedDeadAirPart AddPart(string resource, Vector3 scale, bool preserveTeethBot = false) { //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_0016: 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_0104: 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_0124: Unknown result type (might be due to invalid IL or missing references) SpawnedDeadAirPart spawnedDeadAirPart = MimicSpawner.SpawnPart(resource, ((Component)this).transform.position + Vector3.up, scale); if (spawnedDeadAirPart == null) { return null; } if (!preserveTeethBot) { ValuableTeethBot[] componentsInChildren = spawnedDeadAirPart.Root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Behaviour)componentsInChildren[i]).enabled = false; } TrapTV[] componentsInChildren2 = spawnedDeadAirPart.Root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { ((Behaviour)componentsInChildren2[i]).enabled = false; } PhoneValuable[] componentsInChildren3 = spawnedDeadAirPart.Root.GetComponentsInChildren(true); foreach (PhoneValuable val in componentsInChildren3) { val.hasRung = true; val.ringIntervalTimer = 999999f; val.ringTimer = 0f; if ((Object)(object)val.phoneLight != (Object)null) { val.phoneLight.SetActive(false); } ((Behaviour)val).enabled = false; } } _parts.Add(spawnedDeadAirPart); _basePartScales.Add(spawnedDeadAirPart.Root.transform.localScale); _glitchScales.Add(Vector3.one); _glitchEuler.Add(Vector3.zero); _glitchOffsets.Add(Vector3.zero); spawnedDeadAirPart.GeometryCalibrationFrames = 0; return spawnedDeadAirPart; } private IEnumerable ConvertParts() { foreach (SpawnedDeadAirPart part in _parts) { yield return new SpawnedPandemicPart { Root = part.Root, Phys = part.Phys, ImpactDetector = part.ImpactDetector, Renderers = part.Renderers, Colliders = part.Colliders, Alive = part.Alive }; } } internal bool ActivateNavigation(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; return ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform, 6f); } private void Update() { //IL_0172: Unknown result type (might be due to invalid IL or missing references) if (!_initialized || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (_dead) { UpdateDeath(); return; } _scanTimer -= Time.deltaTime; _destinationTimer -= Time.deltaTime; _listenRepathTimer -= Time.deltaTime; _soundTimer -= Time.deltaTime; _damagePulse = Mathf.Max(0f, _damagePulse - Time.deltaTime); _chargeContactCooldown = Mathf.Max(0f, _chargeContactCooldown - Time.deltaTime); UpdateVisualGlitch(); switch (_state) { case State.Stalk: UpdateStalk(); break; case State.Record: UpdateRecord(); break; case State.Hide: UpdateHide(); break; case State.Replay: UpdateReplay(); break; case State.Charge: UpdateCharge(); break; case State.Recover: UpdateRecover(); break; } PinParts(force: false); if (!(_soundTimer <= 0f)) { return; } _soundTimer = ((_state == State.Charge) ? Random.Range(0.26f, 0.42f) : Random.Range(0.72f, 1.15f)); SpawnedDeadAirPart torso = _torso; if (torso != null) { PhysGrabObjectImpactDetector impactDetector = torso.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactLight((_state == State.Charge) ? 92f : 68f, _torso.Phys.centerPoint); } } } private void LateUpdate() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_voiceAnchor?.Phys != (Object)null) { _relay.LateTick(_voiceAnchor.Phys.centerPoint); } } private void UpdateStalk() { //IL_010c: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0296: 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_02db: Unknown result type (might be due to invalid IL or missing references) if (_scanTimer <= 0f) { _scanTimer = 0.2f; if (!GunAccess.IsLiving(_target)) { SetStalkTarget(FindTarget(42f, out var voice), voice); } else if ((Object)(object)_targetVoice == (Object)null) { _targetVoice = FindVoice(_target); } } if (!GunAccess.IsLiving(_target)) { SetStalkTarget(FindTarget(42f, out var voice2), voice2); } if ((Object)(object)_target == (Object)null) { if (_destinationTimer <= 0f) { _destinationTimer = Random.Range(1.6f, 2.7f); LevelPoint val = SemiFunc.LevelPointGetPlayerDistance(((Component)this).transform.position, 6f, 18f, false); if ((Object)(object)val != (Object)null) { MoveTo(((Component)val).transform.position, Plugin.Settings.MimicStalkSpeed.Value, 2f); } } return; } PrimeVoiceCapture(); Vector3.Distance(((Component)this).transform.position, ((Component)_target).transform.position); float num = (_hasListenPosition ? Vector3.Distance(((Component)this).transform.position, _listenPosition) : float.MaxValue); bool flag = _hasListenPosition && num <= 1.15f; bool flag2 = (Object)(object)_agent == (Object)null || !((Behaviour)_agent).enabled || !_agent.isOnNavMesh || (!_agent.pathPending && !_agent.hasPath && !flag); if (_hasListenPosition && !flag) { if (num < _lastListenDistance - 0.1f) { _lastListenDistance = num; _listenStuckTimer = 0f; } else { _listenStuckTimer += Time.deltaTime; } } if (!_hasListenPosition || (flag2 && _listenRepathTimer <= 0f && _listenStuckTimer >= 2.8f)) { if (TryChooseListeningDestination(_target, out var destination)) { _listenPosition = destination; _listenTargetOrigin = ((Component)_target).transform.position; _hasListenPosition = true; _listenRepathTimer = Random.Range(2.4f, 4.2f); _destinationTimer = 0f; _listeningDwellTimer = 0f; _listenStuckTimer = 0f; _lastListenDistance = Vector3.Distance(((Component)this).transform.position, destination); flag = false; } else { _listenRepathTimer = 0.75f; } } if (_hasListenPosition && !flag && _destinationTimer <= 0f) { _destinationTimer = 0.24f; MoveTo(_listenPosition, Plugin.Settings.MimicStalkSpeed.Value, 0.72f); } if (!flag) { _voiceOnsetTimer = 0f; _listeningDwellTimer = 0f; return; } StopAgent(); _listeningDwellTimer += Time.deltaTime; if (ReadLoudness(_targetVoice) > 0.0065f) { _voiceOnsetTimer += Time.deltaTime; } else { _voiceOnsetTimer = Mathf.Max(0f, _voiceOnsetTimer - Time.deltaTime * 2f); } if (_voiceOnsetTimer >= 0.09f || _listeningDwellTimer >= 1.15f) { BeginRecord(); } } private void SetStalkTarget(PlayerAvatar target, PlayerVoiceChat voice) { if ((Object)(object)_target == (Object)(object)target) { _targetVoice = voice ?? _targetVoice; return; } _capture.Dispose(); _captureActor = -1; _target = target; _targetVoice = voice; _hasListenPosition = false; _listenRepathTimer = 0f; _voiceOnsetTimer = 0f; _listeningDwellTimer = 0f; _listenStuckTimer = 0f; _lastListenDistance = float.MaxValue; } private void PrimeVoiceCapture() { PlayerAvatar target = _target; int? obj; if (target == null) { obj = null; } else { PhotonView photonView = target.photonView; obj = ((photonView != null) ? new int?(photonView.OwnerActorNr) : ((int?)null)); } int num = obj ?? (-1); if (num >= 0 && !((Object)(object)_targetVoice == (Object)null) && (!_capture.IsCapturing || _captureActor != num)) { _capture.Dispose(); _captureActor = -1; Speaker component = ((Component)_targetVoice).GetComponent(); if (_capture.Start(component, Plugin.Settings.MimicRecordSeconds.Value + 1.25f)) { _captureActor = num; } } } private void BeginRecord() { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) PrimeVoiceCapture(); bool isCapturing = _capture.IsCapturing; _recordingRate = (isCapturing ? _capture.SamplingRate : 0); _recordingChannels = (isCapturing ? _capture.Channels : 0); _state = State.Record; _stateTimer = Mathf.Clamp(Plugin.Settings.MimicRecordSeconds.Value, 3f, 7.5f); _voiceOnsetTimer = 0f; _recordWasObserved = AnyLivingPlayerCanSeeMimic(); _recordRelocated = false; StopAgent(); SpawnedDeadAirPart torso = _torso; if (torso != null) { PhysGrabObjectImpactDetector impactDetector = torso.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactMedium(96f, _torso.Phys.centerPoint); } } Plugin.Log.LogInfo((object)(isCapturing ? "The Mimic started volatile remote voice capture." : "The Mimic heard speech but no remote PCM stream was linkable; it will use the fallback ambush.")); } private void UpdateRecord() { _stateTimer -= Time.deltaTime; StopAgent(); _recordWasObserved |= AnyLivingPlayerCanSeeMimic(); if (_recordWasObserved && !_recordRelocated && ClosestLivingPlayerDistance() <= 5.4f && TryTeleportForResponseAmbush("an observed recording perch became unsafe")) { _recordRelocated = true; StopAgent(); } if (!(_stateTimer > 0f)) { _recording = _capture.Stop(); _captureActor = -1; _state = State.Hide; if (_recordWasObserved && !_recordRelocated) { _recordRelocated = TryTeleportForResponseAmbush("a watched recording finished"); } _stateTimer = (_recordRelocated ? 1.25f : 7f); _destinationTimer = 0f; if (!_recordRelocated) { ChooseHideDestination(); } } } private void ChooseHideDestination() { //IL_0020: 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_002e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_target == (Object)null) && TryChooseListeningDestination(_target, out var destination)) { _listenPosition = destination; _hasListenPosition = true; MoveTo(destination, Plugin.Settings.MimicStalkSpeed.Value * 1.28f, 0.55f); } } private void UpdateHide() { //IL_0086: 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) _stateTimer -= Time.deltaTime; if (!GunAccess.IsLiving(_target)) { BeginRecover(1f); return; } bool flag = (Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh && !_agent.pathPending && _agent.remainingDistance < 0.8f; if (flag && TargetCanSeePoint(_target, ((Component)this).transform.position, 0.02f) && _stateTimer > 1.2f) { ChooseHideDestination(); } else { if (!flag && _stateTimer > 0f) { return; } StopAgent(); _state = State.Replay; _stateTimer = 2f; bool flag2 = _relay.Start(_recording, _recordingRate, _recordingChannels, _voiceAnchor?.Phys, _target); _replayResponseDelay = (flag2 ? 0.45f : 0.25f); _responseQuietTimer = 0f; _responseVoiceTimer = 0f; _responseWindowStarted = false; _responseArmed = false; SpawnedDeadAirPart torso = _torso; if (torso != null) { PhysGrabObjectImpactDetector impactDetector = torso.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactHeavy(112f, _torso.Phys.centerPoint); } } Plugin.Log.LogInfo((object)(flag2 ? "The Mimic replayed captured speech through its TeethBot spatial anchor." : "The Mimic began its visible fallback lure because voice relay was unavailable.")); } } private void UpdateReplay() { //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) StopAgent(); if (!GunAccess.IsLiving(_target) || (Object)(object)_targetVoice == (Object)null) { _relay.Stop(); BeginRecover(0.8f); return; } if (_relay.Active) { _replayResponseDelay = 0.45f; _responseQuietTimer = 0f; _responseVoiceTimer = 0f; return; } _replayResponseDelay -= Time.deltaTime; if (_replayResponseDelay > 0f) { return; } float num = ReadLoudness(_targetVoice); if (!_responseWindowStarted) { _stateTimer -= Time.deltaTime; if (num < 0.009f) { _responseQuietTimer += Time.deltaTime; } else { _responseQuietTimer = 0f; } if (_responseQuietTimer >= 0.15f) { _responseWindowStarted = true; _responseArmed = true; _stateTimer = 4f; _responseVoiceTimer = 0f; SpawnedDeadAirPart torso = _torso; if (torso != null) { PhysGrabObjectImpactDetector impactDetector = torso.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactHeavy(132f, _torso.Phys.centerPoint); } } Plugin.Log.LogInfo((object)$"The Mimic opened its visible {4f:0.0}s response window."); } else if (_stateTimer <= 0f) { Plugin.Log.LogInfo((object)"The Mimic could not establish a quiet response floor and safely abandoned the lure."); _relay.Stop(); BeginRecover(1.1f); } return; } _stateTimer -= Time.deltaTime; if (_responseArmed) { if (num > 0.0065f) { _responseVoiceTimer += Time.deltaTime; } else { _responseVoiceTimer = Mathf.Max(0f, _responseVoiceTimer - Time.deltaTime * 2.5f); } if (_responseVoiceTimer >= 0.04f) { Plugin.Log.LogInfo((object)$"The Mimic accepted a new voice onset ({num:0.000}) as a response."); _relay.Stop(); TryTeleportForResponseAmbush(); BeginCharge(); return; } } if (!(_stateTimer <= 0f)) { return; } Plugin.Log.LogInfo((object)"The Mimic visibly closed its response window without hearing an answer."); SpawnedDeadAirPart torso2 = _torso; if (torso2 != null) { PhysGrabObjectImpactDetector impactDetector2 = torso2.ImpactDetector; if (impactDetector2 != null) { impactDetector2.ImpactMedium(88f, _torso.Phys.centerPoint); } } _relay.Stop(); BeginRecover(1.1f); } private void BeginCharge(bool retaliation = false) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(_target)) { _target = (retaliation ? FindClosestLivingTarget(55f, out _targetVoice) : FindTarget(42f, out _targetVoice)); } _state = State.Charge; _retaliating = retaliation; _chargeHitsRemaining = (retaliation ? 1 : Random.Range(3, 6)); _chargeContactCooldown = 0f; _attackPoseTimer = 0f; _stateTimer = (retaliation ? 10f : 16f); _destinationTimer = 0f; _hasListenPosition = false; _listenStuckTimer = 0f; SpawnedDeadAirPart torso = _torso; if (torso != null) { PhysGrabObjectImpactDetector impactDetector = torso.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactHeavy(118f, _torso.Phys.centerPoint); } } Plugin.Log.LogInfo((object)("The Mimic began " + (retaliation ? "retaliation" : "voice-response") + " charge against " + (((Object)(object)_target != (Object)null) ? SemiFunc.PlayerGetSteamID(_target) : "no target") + "; " + $"plannedHits={_chargeHitsRemaining}.")); } internal void ForceHostileByMarionette(PlayerAvatar player) { if (!_dead && GunAccess.IsLiving(player)) { _relay.Stop(); _capture.Dispose(); _recording = null; _captureActor = -1; _target = player; _targetVoice = ((Component)player).GetComponentInChildren(true); _state = State.Charge; _retaliating = false; _chargeHitsRemaining = Mathf.Max(_chargeHitsRemaining, 5); _chargeContactCooldown = Mathf.Min(_chargeContactCooldown, 0.15f); _attackPoseTimer = 0f; _stateTimer = Mathf.Max(_stateTimer, 16f); _destinationTimer = 0f; _hasListenPosition = false; _listenStuckTimer = 0f; } } private bool TryTeleportForResponseAmbush(string reason = "a response ambush") { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_008e: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0111: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(_target) || (Object)(object)_agent == (Object)null || !((Behaviour)_agent).enabled || !_agent.isOnNavMesh) { return false; } Vector3 position = ((Component)_target).transform.position; NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(position, ref val, 4f, -1)) { return false; } PlayerLocalCamera localCamera = _target.localCamera; Transform val2 = ((localCamera != null) ? localCamera.GetOverrideTransform() : null); Vector3 val3 = (((Object)(object)val2 != (Object)null) ? val2.forward : ((Component)_target).transform.forward); val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = Vector3.forward; } ((Vector3)(ref val3)).Normalize(); Vector3 val4 = Vector3.zero; float num = float.MinValue; NavMeshHit val6 = default(NavMeshHit); for (int i = 0; i < 32; i++) { float num2 = Random.Range(-72f, 72f); float num3 = Random.Range(4.4f, 6.8f); Vector3 val5 = Quaternion.Euler(0f, num2, 0f) * -val3; if (!NavMesh.SamplePosition(position + val5 * num3, ref val6, 2.6f, -1)) { continue; } NavMeshPath val7 = new NavMeshPath(); if (!NavMesh.CalculatePath(((NavMeshHit)(ref val6)).position, ((NavMeshHit)(ref val)).position, -1, val7) || (int)val7.status != 0) { continue; } float num4 = Vector3.Distance(((NavMeshHit)(ref val6)).position, position); if (!(num4 < 3.8f) && !(num4 > 7.4f)) { bool obstructed; float viewDot; float num5 = (IsBlindPoint(_target, ((NavMeshHit)(ref val6)).position, out obstructed, out viewDot) ? 5f : 0f) + (obstructed ? 1.5f : 0f) + Mathf.Clamp01(0f - viewDot) * 2f - Mathf.Abs(num4 - 5.2f) * 0.2f + Random.Range(0f, 0.35f); if (num5 > num) { num = num5; val4 = ((NavMeshHit)(ref val6)).position; } } } if (num == float.MinValue || !_agent.Warp(val4)) { return false; } ((Component)this).transform.position = val4; Vector3 val8 = position - val4; val8.y = 0f; if (((Vector3)(ref val8)).sqrMagnitude > 0.01f) { ((Component)this).transform.rotation = Quaternion.LookRotation(((Vector3)(ref val8)).normalized, Vector3.up); } _hasListenPosition = false; _destinationTimer = 0f; PinParts(force: true); SpawnedDeadAirPart torso = _torso; if (torso != null) { PhysGrabObjectImpactDetector impactDetector = torso.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactHeavy(126f, _torso.Phys.centerPoint); } } Plugin.Log.LogInfo((object)("The Mimic folded to an unseen perch because " + reason + "; " + $"distance={Vector3.Distance(val4, position):0.0}m.")); return true; } private void UpdateCharge() { //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: 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_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) _stateTimer -= Time.deltaTime; if (!GunAccess.IsLiving(_target)) { Plugin.Log.LogInfo((object)"The Mimic's selected respondent died before the remaining charge sequence completed."); BeginPostAttackWithdrawal(); return; } if (_stateTimer <= 0f) { Plugin.Log.LogWarning((object)$"The Mimic charge ended before all contacts: remainingHits={_chargeHitsRemaining}, timer={_stateTimer:0.00}."); BeginRecover(1.15f); return; } if (_destinationTimer <= 0f) { _destinationTimer = 0.08f; NavMeshHit val = default(NavMeshHit); if (!MoveTo(((Component)_target).transform.position, Plugin.Settings.MimicChargeSpeed.Value, 0.35f, 6f) && NavMesh.SamplePosition(((Component)_target).transform.position, ref val, 9f, -1)) { MoveTo(((NavMeshHit)(ref val)).position, Plugin.Settings.MimicChargeSpeed.Value, 0.25f, 3f); } } Vector3 val2 = ((Component)_target).transform.position - ((Component)this).transform.position; val2.y = 0f; bool flag = ((Vector3)(ref val2)).sqrMagnitude <= 6.0025f; if (_attackPoseTimer < 0f) { _attackPoseTimer = Mathf.Min(0f, _attackPoseTimer + Time.deltaTime); } else if (flag && _chargeContactCooldown <= 0f) { _attackPoseTimer = Mathf.Min(0.34f, _attackPoseTimer + Time.deltaTime); } else { _attackPoseTimer = Mathf.Max(0f, _attackPoseTimer - Time.deltaTime * 2.8f); } if (((Vector3)(ref val2)).sqrMagnitude > 1.3225f || _chargeContactCooldown > 0f || _attackPoseTimer < 0.3f) { return; } PlayerHealth playerHealth = _target.playerHealth; if (playerHealth != null) { playerHealth.HurtOther(Mathf.Max(1, Plugin.Settings.MimicAttackDamage.Value), ((Component)_target).transform.position + Vector3.up * 0.6f, false, -1, false); } PlayerTumble componentInChildren = ((Component)_target).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.TumbleRequest(true, false); componentInChildren.TumbleForce(((Vector3)(ref val2)).normalized * 11f + Vector3.up * 2.2f); } SpawnedDeadAirPart torso = _torso; if (torso != null) { PhysGrabObjectImpactDetector impactDetector = torso.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactHeavy(126f, _torso.Phys.centerPoint); } } _chargeHitsRemaining--; _chargeContactCooldown = 0.58f; _attackPoseTimer = -0.3f; if (_chargeHitsRemaining > 0 && GunAccess.IsLiving(_target)) { _destinationTimer = 0f; _stateTimer = Mathf.Max(_stateTimer, 4.5f); Plugin.Log.LogInfo((object)$"The Mimic landed one persistent attack; {_chargeHitsRemaining} hit(s) remain for this respondent."); } else { Plugin.Log.LogInfo((object)"The Mimic completed its persistent attack sequence and withdrew to a new listening perch."); BeginPostAttackWithdrawal(); } } private void BeginPostAttackWithdrawal() { _relay.Stop(); _capture.Dispose(); _recording = null; _captureActor = -1; TryTeleportForResponseAmbush("its attack sequence ended"); _state = State.Stalk; _hasListenPosition = false; _listenRepathTimer = 0f; _listenStuckTimer = 0f; _lastListenDistance = float.MaxValue; _voiceOnsetTimer = 0f; _listeningDwellTimer = 0f; _scanTimer = 0f; _destinationTimer = 0f; _chargeHitsRemaining = 0; _chargeContactCooldown = 0f; } private bool AnyLivingPlayerCanSeeMimic() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item) && TargetCanSeePoint(item, ((Component)this).transform.position, 0.02f)) { return true; } } return false; } private float ClosestLivingPlayerDistance() { //IL_002a: 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) float num = float.MaxValue; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { num = Mathf.Min(num, Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position)); } } return num; } private void BeginRecover(float seconds) { _relay.Stop(); _capture.Dispose(); _recording = null; _captureActor = -1; _state = State.Recover; _stateTimer = seconds; StopAgent(); } private void UpdateRecover() { _stateTimer -= Time.deltaTime; if (_stateTimer <= 0f) { _state = State.Stalk; _target = null; _targetVoice = null; _hasListenPosition = false; _listenRepathTimer = 0f; _voiceOnsetTimer = 0f; _scanTimer = 0.1f; _destinationTimer = 0f; } } private PlayerAvatar FindTarget(float range, out PlayerVoiceChat voice) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0058: Unknown result type (might be due to invalid IL or missing references) voice = null; PlayerAvatar val = null; float num = range * range; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { Vector3 val2 = ((Component)item).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (!(sqrMagnitude >= num) && HasCompletePath(((Component)item).transform.position)) { val = item; num = sqrMagnitude; } } } if ((Object)(object)val != (Object)null) { voice = FindVoice(val); } return val; } private PlayerAvatar FindClosestLivingTarget(float range, out PlayerVoiceChat voice) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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) voice = null; PlayerAvatar val = null; float num = range * range; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { Vector3 val2 = ((Component)item).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { val = item; num = sqrMagnitude; } } } if ((Object)(object)val != (Object)null) { voice = FindVoice(val); } return val; } private static PlayerVoiceChat FindVoice(PlayerAvatar player) { int? obj; if (player == null) { obj = null; } else { PhotonView photonView = player.photonView; obj = ((photonView != null) ? new int?(photonView.OwnerActorNr) : ((int?)null)); } int num = obj ?? (-1); PlayerVoiceChat[] array = Object.FindObjectsOfType(); foreach (PlayerVoiceChat val in array) { PhotonView component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null && component.OwnerActorNr == num) { return val; } try { if (VoicePlayerField?.GetValue(val) == player) { return val; } } catch { } } return null; } private static float ReadLoudness(PlayerVoiceChat voice) { try { return ((Object)(object)voice != (Object)null && LoudnessField?.GetValue(voice) is float num) ? num : 0f; } catch { return 0f; } } private bool HasCompletePath(Vector3 point) { //IL_0028: 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: Expected O, but got Unknown //IL_0046: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Invalid comparison between Unknown and I4 NavMeshHit val = default(NavMeshHit); if ((Object)(object)_agent == (Object)null || !((Behaviour)_agent).enabled || !_agent.isOnNavMesh || !NavMesh.SamplePosition(point, ref val, 2f, -1)) { return false; } NavMeshPath val2 = new NavMeshPath(); if (NavMesh.CalculatePath(((Component)this).transform.position, ((NavMeshHit)(ref val)).position, -1, val2)) { return (int)val2.status == 0; } return false; } private bool HasLineOfSight(PlayerAvatar player) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_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_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_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_003f: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.position + Vector3.up * 0.9f; Vector3 val2 = ((Component)player).transform.position + Vector3.up * 0.7f - val; float magnitude = ((Vector3)(ref val2)).magnitude; RaycastHit[] array = Physics.RaycastAll(val, val2 / Mathf.Max(0.01f, magnitude), magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val3 = array[i]; if (!IsOwn(((RaycastHit)(ref val3)).collider) && !((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() == (Object)(object)player)) { return false; } } return true; } private bool TryChooseListeningDestination(PlayerAvatar player, out Vector3 destination) { //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_009f: 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_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_0177: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00fd: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) destination = ((Component)this).transform.position; if ((Object)(object)player == (Object)null) { return false; } List list = new List(); List list2 = SemiFunc.LevelPointsGetAll(); if (list2 != null) { foreach (LevelPoint item in list2) { if ((Object)(object)item != (Object)null && !item.Truck && ((Object)(object)item.Room == (Object)null || !item.Room.Truck)) { list.Add(((Component)item).transform.position); } } } Vector3 position = ((Component)player).transform.position; NavMeshHit val = default(NavMeshHit); for (int i = 0; i < 2; i++) { float num = ((i == 0) ? 9f : 14f); for (int j = 0; j < 16; j++) { float num2 = (float)j * 22.5f + Random.Range(-6f, 6f); if (NavMesh.SamplePosition(position + Quaternion.Euler(0f, num2, 0f) * Vector3.forward * num, ref val, 3.2f, -1)) { list.Add(((NavMeshHit)(ref val)).position); } } } if (list.Count == 0) { return false; } float num3 = float.MinValue; int num4 = Random.Range(0, list.Count); for (int k = 0; k < list.Count; k++) { Vector3 val2 = list[(num4 + k) % list.Count]; float num5 = Vector3.Distance(val2, position); if (num5 < 7f || num5 > 22f || Vector3.Distance(val2, ((Component)this).transform.position) < 2.5f || !HasCompletePath(val2)) { continue; } bool obstructed; float viewDot; bool flag = IsBlindPoint(player, val2, out obstructed, out viewDot); float num6 = NearbyWallCover(val2); if ((flag || !(num6 < 0.45f)) && (obstructed || !(num6 < 0.18f))) { float num7 = (flag ? 10f : (-3f)) + (obstructed ? 3f : 0f) + num6 * 4f + Mathf.Clamp01(0f - viewDot + 0.25f) * 2.5f - Mathf.Abs(num5 - 12.5f) * 0.12f + Random.Range(0f, 0.65f); if (!(num7 <= num3)) { num3 = num7; destination = val2; } } } return num3 > float.MinValue; } private float NearbyWallCover(Vector3 point) { //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) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = point + Vector3.up * 0.85f; float num = 0f; for (int i = 0; i < 8; i++) { Vector3 val2 = Quaternion.Euler(0f, (float)i * 45f, 0f) * Vector3.forward; RaycastHit[] array = Physics.RaycastAll(val, val2, 3.5f, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); for (int j = 0; j < array.Length; j++) { RaycastHit val3 = array[j]; if (!IsOwn(((RaycastHit)(ref val3)).collider) && !((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() != (Object)null)) { num = Mathf.Max(num, 1f - ((RaycastHit)(ref val3)).distance / 3.5f); break; } } } return num; } private bool IsBlindPoint(PlayerAvatar player, Vector3 point, out bool obstructed, out float viewDot) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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) obstructed = false; viewDot = 1f; object obj; if (player == null) { obj = null; } else { PlayerLocalCamera localCamera = player.localCamera; obj = ((localCamera != null) ? localCamera.GetOverrideTransform() : null); } Transform val = (Transform)obj; if ((Object)(object)val == (Object)null) { val = ((player != null) ? ((Component)player).transform : null); } if ((Object)(object)val == (Object)null) { return false; } Vector3 position = val.position; Vector3 val2 = point + Vector3.up * 0.9f - position; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude < 0.1f) { return false; } viewDot = Vector3.Dot(val.forward, val2 / magnitude); RaycastHit[] array = Physics.RaycastAll(position, val2 / magnitude, magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val3 = array[i]; if (!IsOwn(((RaycastHit)(ref val3)).collider) && !((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() == (Object)(object)player)) { obstructed = true; break; } } if (!obstructed) { return viewDot < -0.04f; } return true; } private bool TargetCanSeePoint(PlayerAvatar player, Vector3 point, float dotThreshold) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) if (!IsBlindPoint(player, point, out var obstructed, out var viewDot)) { if (!obstructed) { return viewDot > dotThreshold; } return false; } if (!obstructed) { return viewDot > dotThreshold; } return false; } private bool IsOwn(Collider collider) { foreach (SpawnedDeadAirPart part in _parts) { if ((Object)(object)part?.Root != (Object)null && ((Component)collider).transform.IsChildOf(part.Root.transform)) { return true; } } return false; } private bool MoveTo(Vector3 point, float speed, float stopping, float sampleRadius = 2.4f) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_agent == (Object)null) { return false; } _agent.speed = Mathf.Max(0.5f, speed); _agent.stoppingDistance = Mathf.Max(0.1f, stopping); return ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, point, sampleRadius); } private void StopAgent() { if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } } private void UpdateVisualGlitch() { //IL_00ca: 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_0146: Unknown result type (might be due to invalid IL or missing references) if (_glitchActive) { _glitchDuration -= Time.deltaTime; if (_glitchDuration <= 0f) { _glitchActive = false; _glitchTimer = Random.Range(2.7f, 6.4f); } return; } _glitchTimer -= Time.deltaTime; if (!(_glitchTimer > 0f) && _parts.Count == 12) { _glitchActive = true; _glitchDuration = Random.Range(0.035f, 0.065f); for (int i = 0; i < 11; i++) { _glitchScales[i] = new Vector3(Random.Range(0.25f, 2.15f), Random.Range(0.28f, 2f), Random.Range(0.25f, 1.9f)); _glitchEuler[i] = new Vector3(Random.Range(-110f, 110f), Random.Range(-140f, 140f), Random.Range(-120f, 120f)); _glitchOffsets[i] = new Vector3(Random.Range(-0.18f, 0.18f), Random.Range(-0.14f, 0.14f), Random.Range(-0.16f, 0.16f)); } } } private void PinParts(bool force) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: 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_02cb: 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_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: 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_0504: 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_0508: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_0516: 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_051a: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: Unknown result type (might be due to invalid IL or missing references) //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_05c4: Unknown result type (might be due to invalid IL or missing references) //IL_05c6: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_05d2: Unknown result type (might be due to invalid IL or missing references) //IL_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_05d6: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Unknown result type (might be due to invalid IL or missing references) //IL_05e5: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_05f2: Unknown result type (might be due to invalid IL or missing references) //IL_05f4: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_05f8: Unknown result type (might be due to invalid IL or missing references) //IL_0603: Unknown result type (might be due to invalid IL or missing references) //IL_0614: Unknown result type (might be due to invalid IL or missing references) //IL_0619: Unknown result type (might be due to invalid IL or missing references) //IL_061e: Unknown result type (might be due to invalid IL or missing references) //IL_0623: Unknown result type (might be due to invalid IL or missing references) //IL_0625: Unknown result type (might be due to invalid IL or missing references) if (_parts.Count != 12) { return; } bool flag = _state == State.Charge; bool flag2 = _state == State.Replay && _responseWindowStarted && _responseArmed; float num = ((_state == State.Record) ? (Mathf.Sin(Time.time * 24f) * 0.025f) : 0f); float num2 = ((_damagePulse > 0f) ? (Mathf.Sin(_damagePulse / 0.22f * MathF.PI) * 0.075f) : 0f); Quaternion rotation = ((Component)this).transform.rotation; Vector3 position = ((Component)this).transform.position; float num3 = Mathf.Sin(Time.time * 2.15f) * 0.055f; float num4; if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled) { Vector3 velocity = _agent.velocity; if (((Vector3)(ref velocity)).sqrMagnitude > 0.05f) { num4 = Mathf.Sin(Time.time * 3.45f); goto IL_0123; } } num4 = Mathf.Sin(Time.time * 1.25f) * 0.18f; goto IL_0123; IL_0123: float num5 = (flag ? 0.16f : 0f); float num6 = (flag ? 18f : (flag2 ? (7f + Mathf.Sin(Time.time * 8.5f) * 2.8f) : (12f + Mathf.Sin(Time.time * 1.35f) * 1.4f))); float num7 = ((flag && _attackPoseTimer > 0f) ? Mathf.SmoothStep(0f, 1f, _attackPoseTimer / 0.3f) : 0f); float num8 = ((flag && _attackPoseTimer < 0f) ? Mathf.SmoothStep(0f, 1f, (0f - _attackPoseTimer) / 0.3f) : 0f); num6 += num7 * -31f + num8 * 20f; num5 += num7 * -0.2f + num8 * 0.22f; Vector3 localCenter = default(Vector3); ((Vector3)(ref localCenter))..ctor(num, 2f + num3 + num2, 0.3f + num5); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(num * 0.45f, 1.48f + num3 * 0.55f + num2 * 0.35f, 0.19f + num5 * 0.55f); Vector3 localCenter2 = default(Vector3); ((Vector3)(ref localCenter2))..ctor(0f, 1.08f + num3 * 0.35f, 0.11f + num5 * 0.2f); PoseVisual(0, localCenter, Quaternion.Euler(4f + num6 * 0.65f, 0f, num * 120f), position, rotation, force); PoseVisual(1, val, Quaternion.Euler(90f + num6, 0f, num * 80f), position, rotation, force); PoseVisual(2, localCenter2, Quaternion.Euler(90f + num6 * 0.52f, 0f, 0f), position, rotation, force); float num9 = num4 * 0.23f; float num10 = num4 * 0.31f; Vector3 localStart = default(Vector3); ((Vector3)(ref localStart))..ctor(-0.24f, 1.76f, 0.27f); Vector3 localStart2 = default(Vector3); ((Vector3)(ref localStart2))..ctor(0.24f, 1.76f, 0.27f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(flag2 ? (-0.52f) : (-0.29f), (flag2 ? 1.48f : 1.15f) + num7 * 0.64f - num8 * 0.16f, (flag2 ? 0.38f : (0.29f - num9)) - num7 * 0.48f + num8 * 0.48f); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(flag2 ? 0.52f : 0.29f, (flag2 ? 1.48f : 1.15f) + num7 * 0.64f - num8 * 0.16f, (flag2 ? 0.38f : (0.29f + num9)) - num7 * 0.48f + num8 * 0.48f); Vector3 localEnd = default(Vector3); ((Vector3)(ref localEnd))..ctor(flag2 ? (-0.63f) : (-0.29f), flag2 ? 1.72f : (flag ? (0.55f + num7 * 1.02f - num8 * 0.18f) : 0.28f), flag2 ? 0.44f : (flag ? (0.48f - num7 * 0.65f + num8 * 0.82f) : (0.34f - num9 * 1.55f))); Vector3 localEnd2 = default(Vector3); ((Vector3)(ref localEnd2))..ctor(flag2 ? 0.63f : 0.29f, flag2 ? 1.72f : (flag ? (0.55f + num7 * 1.02f - num8 * 0.18f) : 0.28f), flag2 ? 0.44f : (flag ? (0.48f - num7 * 0.65f + num8 * 0.82f) : (0.34f + num9 * 1.55f))); PoseSegment(3, localStart, val2, position, rotation, force); PoseSegment(4, val2, localEnd, position, rotation, force); PoseSegment(5, localStart2, val3, position, rotation, force); PoseSegment(6, val3, localEnd2, position, rotation, force); Vector3 localStart3 = default(Vector3); ((Vector3)(ref localStart3))..ctor(-0.105f, 1.1f, 0.1f); Vector3 localStart4 = default(Vector3); ((Vector3)(ref localStart4))..ctor(0.105f, 1.1f, 0.1f); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(-0.115f, 0.56f, 0.07f + num10 * 0.7f); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(0.115f, 0.56f, 0.07f - num10 * 0.7f); Vector3 localEnd3 = default(Vector3); ((Vector3)(ref localEnd3))..ctor(-0.13f, 0.07f, 0.06f + num10); Vector3 localEnd4 = default(Vector3); ((Vector3)(ref localEnd4))..ctor(0.13f, 0.07f, 0.06f - num10); PoseSegment(7, localStart3, val4, position, rotation, force); PoseSegment(8, val4, localEnd3, position, rotation, force); PoseSegment(9, localStart4, val5, position, rotation, force); PoseSegment(10, val5, localEnd4, position, rotation, force); PoseVisual(11, val + new Vector3(0f, 0f, -0.08f), Quaternion.identity, position, rotation, force: true); } private void PoseSegment(int index, Vector3 localStart, Vector3 localEnd, Vector3 root, Quaternion basis, bool force) { //IL_0020: 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_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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_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_004c: 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_004e: 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_005d: 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_0060: Unknown result type (might be due to invalid IL or missing references) if (index >= 0 && index < _parts.Count) { SpawnedDeadAirPart spawnedDeadAirPart = _parts[index]; Vector3 val = localEnd - localStart; if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { Quaternion localRotation = Quaternion.FromToRotation(spawnedDeadAirPart.LongAxisLocal, ((Vector3)(ref val)).normalized); PoseVisual(index, (localStart + localEnd) * 0.5f, localRotation, root, basis, force); } } } private void PoseVisual(int index, Vector3 localCenter, Quaternion localRotation, Vector3 root, Quaternion basis, bool force) { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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) if (index < 0 || index >= _parts.Count) { return; } SpawnedDeadAirPart spawnedDeadAirPart = _parts[index]; if (!((Object)(object)spawnedDeadAirPart?.Phys == (Object)null) && spawnedDeadAirPart.Alive) { if (spawnedDeadAirPart.GeometryCalibrationFrames > 0) { DeadAirSpawner.RefreshRenderedGeometry(spawnedDeadAirPart); spawnedDeadAirPart.GeometryCalibrationFrames--; } if (index < _basePartScales.Count) { Vector3 val = ((_glitchActive && index != 11) ? _glitchScales[index] : Vector3.one); spawnedDeadAirPart.Root.transform.localScale = Vector3.Scale(_basePartScales[index], val); } if (_glitchActive && index != 11) { localCenter += _glitchOffsets[index]; localRotation *= Quaternion.Euler(_glitchEuler[index]); } Vector3 val2 = root + basis * localCenter; Quaternion val3 = basis * localRotation; Vector3 val4 = val2 - val3 * spawnedDeadAirPart.VisualCenterOffset; spawnedDeadAirPart.ImpactDetector.destroyDisable = true; spawnedDeadAirPart.Phys.OverrideKinematic(0.3f); spawnedDeadAirPart.Phys.OverrideGrabDisable(0.3f); spawnedDeadAirPart.Phys.OverrideIndestructible(0.3f); float num = (force ? 1f : (1f - Mathf.Exp(-18f * Time.deltaTime))); Vector3 val5 = Vector3.Lerp(((Component)spawnedDeadAirPart.Phys).transform.position, val4, num); Quaternion val6 = Quaternion.Slerp(((Component)spawnedDeadAirPart.Phys).transform.rotation, val3, num); spawnedDeadAirPart.Phys.SetPositionLogic(val5, val6); } } public bool TryClaimWeaponHit(int id) { if (_dead || !ModEnemyWeaponDamage.TryClaim((Object)(object)this, id) || Time.time - _lastHitTime < 0.055f) { return false; } _lastHitTime = Time.time; if (!_claimedHits.Add(id)) { return id <= 0; } return true; } public void ReceiveWeaponHit(Vector3 hitPosition, int damage) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (_dead) { return; } damage = ParasiteEffectRegistry.ModifyEnemyDamageAt(hitPosition, Mathf.Max(0, damage)); if (damage > 0) { _health -= damage; _damagePulse = 0.22f; ModEnemyFeedback.DamageHit(_torso.ImpactDetector, _torso.Phys, hitPosition, 94f); if (_state != State.Charge) { _target = FindClosestLivingTarget(55f, out _targetVoice); BeginCharge(retaliation: true); } if (_health <= 0) { Die(); } } } public void ExecuteForLab() { if (!_dead) { _health = 0; Die(); } } public void ReceiveTumbleAttack(int partIndex, int damage, Vector3 hitPosition, Vector3 direction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ReceiveWeaponHit(hitPosition, Mathf.Max(1, damage)); } private void Die() { if (_dead) { return; } _dead = true; _state = State.Dead; _relay.Stop(); _capture.Dispose(); StopAgent(); foreach (SpawnedDeadAirPart part in _parts) { if (part == _torso && part.Alive) { part.Alive = false; ((Behaviour)part.ImpactDetector).enabled = true; part.ImpactDetector.destroyDisable = false; part.ImpactDetector.DestroyObject(true); } else { DeadAirSpawner.Destroy(part); } } _rewardTimer = 0.08f; } private void UpdateDeath() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (_rewardDropped) { return; } _rewardTimer -= Time.deltaTime; if (_rewardTimer > 0f) { return; } _rewardDropped = true; if (Plugin.Settings.MimicDropEnemyValuable.Value && !((Object)(object)AssetManager.instance?.enemyValuableMedium == (Object)null)) { GameObject enemyValuableMedium = AssetManager.instance.enemyValuableMedium; Vector3 val = ((Component)this).transform.position + Vector3.up * 0.5f; if (GameManager.Multiplayer()) { PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)enemyValuableMedium).name, val, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate(enemyValuableMedium, val, Quaternion.identity); } } } private void Cleanup(bool effect) { foreach (SpawnedDeadAirPart part in _parts) { if (effect && part == _torso && (Object)(object)part?.ImpactDetector != (Object)null) { part.ImpactDetector.destroyDisable = false; part.ImpactDetector.DestroyObject(true); } else { DeadAirSpawner.Destroy(part); } } _parts.Clear(); _basePartScales.Clear(); _glitchScales.Clear(); _glitchEuler.Clear(); _glitchOffsets.Clear(); } private void OnDestroy() { _relay.Stop(); _capture.Dispose(); if (_initialized && !_cleaning && SemiFunc.IsMasterClientOrSingleplayer()) { _cleaning = true; Cleanup(effect: false); } } } internal sealed class MimicManager : MonoBehaviour { private int _levelId; private float _spawnTimer; private bool _attemptFinished; private bool _probed; private bool _available; private MimicController _encounter; internal void Tick() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (!IsHostReady()) { return; } Probe(); int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } if (!ModEnemyLevelRules.IsPlayableLevel()) { DestroyCurrent(); return; } LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null || !instance.Generated || _attemptFinished) { return; } _spawnTimer -= Time.deltaTime; if (!(_spawnTimer > 0f)) { _attemptFinished = true; if (Random.value <= Mathf.Clamp01(Plugin.Settings.MimicSpawnChance.Value) && TryFindSpawn(out var position)) { Create(position, "automatic"); } } } private void ResetForLevel(int level) { DestroyCurrent(); _levelId = level; _spawnTimer = Mathf.Max(0f, Plugin.Settings.MimicSpawnDelay.Value); _attemptFinished = false; } private void Probe() { if (!_probed && !((Object)(object)RunManager.instance == (Object)null)) { _probed = true; _available = MimicSpawner.PrefabsAvailable(); Plugin.Log.LogInfo((object)$"The Mimic prefab probe: available={_available}."); } } private bool Create(Vector3 position, string source) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_002f: 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_0055: 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 (!_available && !MimicSpawner.PrefabsAvailable()) { return false; } DestroyCurrent(); GameObject val = new GameObject("The Mimic Encounter (Host Logic)"); val.SetActive(false); val.transform.position = position; MimicController mimicController = val.AddComponent(); if (!mimicController.Initialize(position)) { Object.Destroy((Object)(object)val); return false; } val.SetActive(true); if (!mimicController.ActivateNavigation(position)) { Object.Destroy((Object)(object)val); return false; } _encounter = mimicController; Plugin.Log.LogInfo((object)$"The Mimic spawned at {position} ({source})."); return true; } internal bool DebugSpawnAt(Vector3 requested) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (!IsHostReady() || (!ModEnemySpawnCoordinator.IsDirectorRequestActive && (Object)(object)PlayerAvatar.instance == (Object)null) || !ModEnemyLevelRules.IsPlayableLevel()) { return false; } Probe(); NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requested, ref val, 12f, -1)) { return false; } _attemptFinished = true; return Create(((NavMeshHit)(ref val)).position, ModEnemySpawnCoordinator.CurrentSpawnSource); } internal void MarkAutomaticAttemptFinished() { int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } _attemptFinished = true; } internal void DebugDespawn() { if (IsHostReady()) { _attemptFinished = true; DestroyCurrent(); } } private void DestroyCurrent() { if ((Object)(object)_encounter != (Object)null) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); _encounter = null; } } private static bool TryFindSpawn(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; PlayerAvatar val = null; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { val = item; break; } } Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(val2, 15f, 55f, false) ?? SemiFunc.LevelPointGetFurthestFromPlayer(val2, 7f); return ModEnemyNavigation.TryFindClearSpawn(((Object)(object)val3 != (Object)null) ? ((Component)val3).transform.position : (val2 + Vector3.forward * 15f), 7f, out position); } private static bool IsHostReady() { try { return (Object)(object)GameManager.instance != (Object)null && (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient); } catch { return false; } } } internal static class MimicSpawner { private static readonly string[] SizeFolders = new string[7] { "01 Tiny", "02 Small", "03 Medium", "04 Big", "05 Wide", "06 Tall", "07 Very Tall" }; internal static string TeethBotResourcePath { get; private set; } internal static string HeadResourcePath { get; private set; } internal static string TorsoResourcePath { get; private set; } internal static string PelvisResourcePath { get; private set; } internal static string LimbResourcePath { get; private set; } internal static bool PrefabsAvailable() { Resolve(); if (!string.IsNullOrEmpty(TeethBotResourcePath) && !string.IsNullOrEmpty(HeadResourcePath) && !string.IsNullOrEmpty(TorsoResourcePath) && !string.IsNullOrEmpty(PelvisResourcePath)) { return !string.IsNullOrEmpty(LimbResourcePath); } return false; } private static void Resolve() { if (TeethBotResourcePath == null) { TeethBotResourcePath = FindValuable("Valuable Museum Teeth Bot") ?? FindValuable("Valuable Teeth Bot"); } if (HeadResourcePath == null) { HeadResourcePath = FindValuable("Valuable Manor Television") ?? FindValuable("Valuable Television"); } if (TorsoResourcePath == null) { TorsoResourcePath = FindValuable("Valuable Arctic Phone") ?? FindValuable("Valuable Phone"); } if (PelvisResourcePath == null) { PelvisResourcePath = FindValuable("Valuable Arctic HDD") ?? FindValuable("Valuable HDD"); } if (LimbResourcePath == null) { LimbResourcePath = FindValuable("Valuable Manor Telescope") ?? FindValuable("Valuable Telescope"); } } private static string FindValuable(string prefabName) { string[] sizeFolders = SizeFolders; foreach (string text in sizeFolders) { string text2 = "Valuables/" + text + "/" + prefabName; if ((Object)(object)Resources.Load(text2) != (Object)null) { return text2; } } return null; } internal static SpawnedDeadAirPart SpawnPart(string resourcePath, Vector3 position, Vector3 scale) { //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) //IL_0007: Unknown result type (might be due to invalid IL or missing references) SpawnedDeadAirPart spawnedDeadAirPart = DeadAirSpawner.Spawn(resourcePath, position, Quaternion.identity, scale, isBody: true, grabbable: false, 8f); if (spawnedDeadAirPart == null) { return null; } spawnedDeadAirPart.ImpactDetector.playerHurtDisable = true; spawnedDeadAirPart.Phys.OverrideGrabDisable(1f); spawnedDeadAirPart.Phys.OverrideKinematic(1f); spawnedDeadAirPart.Phys.OverrideIndestructible(1f); return spawnedDeadAirPart; } } internal sealed class MimicVoiceCapture : IDisposable { private readonly object _sync = new object(); private float[] _samples = Array.Empty(); private RemoteVoiceLink _voice; private int _maximumSamples; private int _writeIndex; private int _sampleCount; internal int SamplingRate { get; private set; } internal int Channels { get; private set; } internal bool IsCapturing => _voice != null; internal bool Start(Speaker speaker, float maximumSeconds) { Dispose(); RemoteVoiceLink val = ((speaker != null) ? speaker.RemoteVoice : null); if (val == null || ((VoiceInfo)(ref val.VoiceInfo)).SamplingRate <= 0 || ((VoiceInfo)(ref val.VoiceInfo)).Channels <= 0) { return false; } SamplingRate = ((VoiceInfo)(ref val.VoiceInfo)).SamplingRate; Channels = ((VoiceInfo)(ref val.VoiceInfo)).Channels; _maximumSamples = Math.Max(1, (int)((float)(SamplingRate * Channels) * Math.Max(0.5f, maximumSeconds))); _samples = new float[_maximumSamples]; _writeIndex = 0; _sampleCount = 0; _voice = val; _voice.FloatFrameDecoded += OnFrame; return true; } private void OnFrame(FrameOut frame) { float[] array = frame?.Buf; if (array == null || array.Length == 0) { return; } lock (_sync) { for (int i = 0; i < array.Length; i++) { _samples[_writeIndex] = array[i]; _writeIndex = (_writeIndex + 1) % _maximumSamples; _sampleCount = Math.Min(_sampleCount + 1, _maximumSamples); } } } internal float[] Stop() { RemoteVoiceLink voice = _voice; _voice = null; if (voice != null) { voice.FloatFrameDecoded -= OnFrame; } lock (_sync) { if (_maximumSamples <= 0 || _sampleCount <= 0 || _samples == null || _samples.Length == 0) { _samples = Array.Empty(); _maximumSamples = 0; _writeIndex = 0; _sampleCount = 0; return Array.Empty(); } float[] array = new float[_sampleCount]; int num = (_writeIndex - _sampleCount + _maximumSamples) % _maximumSamples; int num2 = Math.Min(_sampleCount, _maximumSamples - num); Array.Copy(_samples, num, array, 0, num2); if (num2 < _sampleCount) { Array.Copy(_samples, 0, array, num2, _sampleCount - num2); } _samples = Array.Empty(); _maximumSamples = 0; _writeIndex = 0; _sampleCount = 0; return array; } } public void Dispose() { Stop(); } } internal sealed class MimicVoiceRelay { private static readonly FieldInfo RecorderField = typeof(PlayerVoiceChat).GetField("recorder", BindingFlags.Instance | BindingFlags.NonPublic); private Recorder _recorder; private InputSourceType _oldSource; private AudioClip _oldClip; private bool _oldLoop; private bool _oldDetection; private bool _oldRecording; private AudioClip _clip; private PhysGrabObject _anchor; private PhotonView _anchorView; private PhysGrabber _grabber; private float _remaining; private bool _attached; private bool _ttsFallback; private static readonly string[] DeadHostFallbackPhrases = new string[5] { "help me", "over here", "wait for me", "hello", "where are you" }; internal bool Active { get { if ((Object)(object)_recorder != (Object)null || _ttsFallback) { return _remaining > 0f; } return false; } } internal bool Start(float[] samples, int sourceRate, int channels, PhysGrabObject anchor, PlayerAvatar preferredFallbackCarrier) { //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) Stop(); _anchor = anchor; _anchorView = (((Object)(object)_anchor != (Object)null) ? ((Component)_anchor).GetComponent() : null); PlayerAvatar player = PlayerController.instance?.playerAvatarScript; if (GameManager.Multiplayer() && !GunAccess.IsLiving(player) && TryStartDeadHostFallback(preferredFallbackCarrier)) { return true; } if (samples == null || samples.Length < Math.Max(2400, channels * 400) || sourceRate <= 0 || channels <= 0 || (Object)(object)PlayerVoiceChat.instance == (Object)null) { return false; } ref Recorder recorder = ref _recorder; object? obj = RecorderField?.GetValue(PlayerVoiceChat.instance); recorder = (Recorder)((obj is Recorder) ? obj : null); if ((Object)(object)_recorder == (Object)null) { return false; } float[] array = PrepareSamples(samples, sourceRate, channels, 0.96f); if (array.Length < Math.Max(2400, channels * 400)) { _recorder = null; return false; } int num = array.Length / channels; _clip = AudioClip.Create("The Mimic volatile voice memory", num, channels, sourceRate, false); if (!_clip.SetData(array, 0)) { Object.Destroy((Object)(object)_clip); _clip = null; _recorder = null; return false; } _oldSource = _recorder.SourceType; _oldClip = _recorder.AudioClip; _oldLoop = _recorder.LoopAudioClip; _oldDetection = _recorder.VoiceDetection; _oldRecording = _recorder.RecordingEnabled; _grabber = PhysGrabber.instance; try { AttachAnchor(); _recorder.TransmitEnabled = false; _recorder.RecordingEnabled = false; _recorder.AudioClip = _clip; _recorder.LoopAudioClip = false; _recorder.VoiceDetection = false; _recorder.SourceType = (InputSourceType)1; _recorder.RecordingEnabled = true; _recorder.RestartRecording(); _recorder.TransmitEnabled = true; _remaining = _clip.length + 0.75f; return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("The Mimic voice relay could not start: " + ex.Message)); Stop(); return false; } } private bool TryStartDeadHostFallback(PlayerAvatar preferredCarrier) { PlayerAvatar val = (GunAccess.IsLiving(preferredCarrier) ? preferredCarrier : FindLivingFallbackCarrier()); if ((Object)(object)val?.photonView == (Object)null || (Object)(object)val.physGrabber == (Object)null || (Object)(object)val.physGrabber.photonView == (Object)null) { return false; } _grabber = val.physGrabber; try { AttachAnchor(); if (!_attached) { _grabber = null; return false; } int num = Mathf.Abs((val.photonView.OwnerActorNr * 397) ^ Time.frameCount); string text = DeadHostFallbackPhrases[num % DeadHostFallbackPhrases.Length]; val.photonView.RPC("ChatMessageSendRPC", (RpcTarget)0, new object[2] { text, false }); _ttsFallback = true; _remaining = 3.25f; Plugin.Log.LogInfo((object)("The Mimic switched to its dead-host vanilla TTS relay " + $"through actor {val.photonView.OwnerActorNr}.")); return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("The Mimic dead-host relay could not start: " + ex.Message)); Stop(); return false; } } private static PlayerAvatar FindLivingFallbackCarrier() { if (GameDirector.instance?.PlayerList == null) { return null; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (GunAccess.IsLiving(player) && (Object)(object)player.physGrabber != (Object)null && (Object)(object)player.photonView != (Object)null) { return player; } } return null; } private static float[] PrepareSamples(float[] source, int sourceRate, int channels, float playbackSpeed) { int num = source.Length / channels; if (num <= 0) { return Array.Empty(); } float num2 = 0f; for (int i = 0; i < source.Length; i++) { num2 = Mathf.Max(num2, Mathf.Abs(source[i])); } if (num2 < 0.0025f) { return Array.Empty(); } float num3 = Mathf.Max(0.002f, num2 * 0.075f); int num4 = num; int num5 = -1; for (int j = 0; j < num; j++) { float num6 = 0f; for (int k = 0; k < channels; k++) { num6 = Mathf.Max(num6, Mathf.Abs(source[j * channels + k])); } if (num6 >= num3) { num4 = Mathf.Min(num4, j); num5 = j; } } if (num5 < num4) { return Array.Empty(); } int num7 = Mathf.Max(1, Mathf.RoundToInt((float)sourceRate * 0.16f)); int num8 = Mathf.Max(0, num4 - num7); int num9 = Mathf.Min(num, num5 + num7 + 1); int num10 = Math.Max(1, num9 - num8); int num11 = Math.Max(1, Mathf.CeilToInt((float)num10 / Mathf.Max(0.5f, playbackSpeed))); float[] array = new float[num11 * channels]; for (int l = 0; l < num11; l++) { float num12 = (float)num8 + Mathf.Min((float)(num10 - 1), (float)l * playbackSpeed); int num13 = Mathf.FloorToInt(num12); int num14 = Math.Min(num9 - 1, num13 + 1); float num15 = num12 - (float)num13; for (int m = 0; m < channels; m++) { float num16 = source[num13 * channels + m]; float num17 = source[num14 * channels + m]; array[l * channels + m] = Mathf.LerpUnclamped(num16, num17, num15); } } float num18 = 0f; for (int n = 0; n < array.Length; n++) { num18 = Mathf.Max(num18, Mathf.Abs(array[n])); } float num19 = ((num18 > 0.0001f) ? Mathf.Clamp(0.72f / num18, 0.85f, 3f) : 1f); for (int num20 = 0; num20 < array.Length; num20++) { array[num20] = Mathf.Clamp(array[num20] * num19, -0.92f, 0.92f); } int num21 = Math.Min(num11 / 2, Mathf.Max(1, sourceRate / 125)); for (int num22 = 0; num22 < num21; num22++) { float num23 = (float)num22 / (float)num21; int num24 = num11 - 1 - num22; for (int num25 = 0; num25 < channels; num25++) { array[num22 * channels + num25] *= num23; array[num24 * channels + num25] *= num23; } } return array; } private void AttachAnchor() { if (!((Object)(object)_anchor == (Object)null) && !((Object)(object)_anchorView == (Object)null) && _anchorView.ViewID != 0 && !((Object)(object)_grabber == (Object)null) && !((Object)(object)_grabber.photonView == (Object)null) && _grabber.photonView.ViewID != 0 && GameManager.Multiplayer()) { _anchorView.RPC("GrabPlayerAddRPC", (RpcTarget)0, new object[1] { _grabber.photonView.ViewID }); _attached = true; } } internal void LateTick(Vector3 position) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (!Active) { return; } if ((Object)(object)_recorder != (Object)null && GameManager.Multiplayer() && !GunAccess.IsLiving(PlayerController.instance?.playerAvatarScript)) { Stop(); return; } _remaining -= Time.deltaTime; if ((Object)(object)_recorder != (Object)null) { _recorder.TransmitEnabled = true; PlayerVoiceChat instance = PlayerVoiceChat.instance; if (instance != null) { instance.OverridePosition(position, 0.15f); } PlayerVoiceChat instance2 = PlayerVoiceChat.instance; if (instance2 != null) { instance2.OverrideNoTalkAnimation(0.15f); } PlayerVoiceChat instance3 = PlayerVoiceChat.instance; if (instance3 != null) { instance3.OverrideHearSelf(0.04f, 0.15f); } } if (_remaining <= 0f) { Stop(); } } internal void Stop() { //IL_00f2: Unknown result type (might be due to invalid IL or missing references) if (_attached && (Object)(object)_anchorView != (Object)null && _anchorView.ViewID != 0 && (Object)(object)_grabber != (Object)null && (Object)(object)_grabber.photonView != (Object)null && _grabber.photonView.ViewID != 0 && GameManager.Multiplayer()) { try { _anchorView.RPC("GrabPlayerRemoveRPC", (RpcTarget)0, new object[1] { _grabber.photonView.ViewID }); } catch { } } _attached = false; if ((Object)(object)_recorder != (Object)null) { try { _recorder.RecordingEnabled = false; _recorder.AudioClip = _oldClip; _recorder.LoopAudioClip = _oldLoop; _recorder.VoiceDetection = _oldDetection; _recorder.SourceType = _oldSource; _recorder.RecordingEnabled = _oldRecording; if (_oldRecording) { _recorder.RestartRecording(); } _recorder.TransmitEnabled = true; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)("The Mimic voice restore skipped: " + ex.Message)); } } } _recorder = null; _ttsFallback = false; _anchor = null; _anchorView = null; _grabber = null; _remaining = 0f; if ((Object)(object)_clip != (Object)null) { Object.Destroy((Object)(object)_clip); _clip = null; } } } internal static class ModEnemyFeedback { internal static void DamageHit(PhysGrabObjectImpactDetector detector, PhysGrabObject phys, Vector3 position, float impactForce) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_01de: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: 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_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0216: 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_0222: 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_022b: 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_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0256: 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_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0273: 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_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_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_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: 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_0168: 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_017a: 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) if ((Object)(object)detector == (Object)null) { return; } detector.BreakLight(position, false); detector.ImpactHeavy(Mathf.Clamp(impactForce * 1.35f, 42f, 135f), position); if (GameManager.Multiplayer()) { PhotonView component = ((Component)detector).GetComponent(); if ((Object)(object)component != (Object)null && component.ViewID != 0) { Vector3 val = (((Object)(object)phys != (Object)null) ? ((Component)phys).transform.right : Vector3.right); Vector3 val2 = (((Object)(object)phys != (Object)null) ? ((Component)phys).transform.up : Vector3.up); Vector3 val3 = (((Object)(object)phys != (Object)null) ? ((Component)phys).transform.forward : Vector3.forward); Vector3[] array = (Vector3[])(object)new Vector3[7] { Vector3.zero, val * 0.16f, -val * 0.16f, val2 * 0.18f, -val2 * 0.08f, val3 * 0.14f + val2 * 0.08f, -val3 * 0.14f + val2 * 0.08f }; foreach (Vector3 val4 in array) { component.RPC("ImpactEffectRPC", (RpcTarget)0, new object[1] { position + val4 }); } } } else if ((Object)(object)AssetManager.instance != (Object)null) { Vector3 val5 = (((Object)(object)phys != (Object)null) ? ((Component)phys).transform.right : Vector3.right); Vector3 val6 = (((Object)(object)phys != (Object)null) ? ((Component)phys).transform.up : Vector3.up); Vector3 val7 = (((Object)(object)phys != (Object)null) ? ((Component)phys).transform.forward : Vector3.forward); Vector3[] array = (Vector3[])(object)new Vector3[7] { Vector3.zero, val5 * 0.16f, -val5 * 0.16f, val6 * 0.18f, -val6 * 0.08f, val7 * 0.14f + val6 * 0.08f, -val7 * 0.14f + val6 * 0.08f }; foreach (Vector3 val8 in array) { AssetManager.instance.PhysImpactEffect(position + val8); } } } } internal sealed class ModEnemyGrabLimit : MonoBehaviour { private PhysGrabObject _phys; private float _heldTime; private float _maximum = 3f; internal void Initialize(PhysGrabObject phys) { _phys = phys; ResetLimit(); } private void Update() { //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)_phys == (Object)null) { return; } int count = _phys.playerGrabbing.Count; if (count <= 0) { _heldTime = 0f; ResetLimit(); return; } float num = 1f + (float)(count - 1) * 1.5f; _heldTime += Time.deltaTime; if (_heldTime < _maximum * num) { return; } PhotonView componentInParent = ((Component)_phys).GetComponentInParent(); int num2 = (((Object)(object)componentInParent != (Object)null) ? componentInParent.ViewID : (-1)); foreach (PhysGrabber item in _phys.playerGrabbing.ToList()) { if (!((Object)(object)item == (Object)null)) { if (GameManager.Multiplayer() && (Object)(object)item.photonView != (Object)null) { item.photonView.RPC("ReleaseObjectRPC", (RpcTarget)0, new object[3] { false, 1f, num2 }); } else { item.ReleaseObject(num2, 1f); } } } _phys.OverrideGrabDisable(1f); if ((Object)(object)_phys.rb != (Object)null) { _phys.rb.AddRelativeTorque(Vector3.up * Mathf.Max(0.1f, _phys.rb.mass), (ForceMode)1); } _heldTime = 0f; ResetLimit(); } private void ResetLimit() { _maximum = 3f * Random.Range(0.9f, 1.1f); } } internal sealed class ModEnemyInventoryBlocker : MonoBehaviour { internal static void Attach(GameObject root) { if ((Object)(object)root == (Object)null) { return; } if ((Object)(object)root.GetComponent() == (Object)null) { root.AddComponent(); } ItemEquippable[] componentsInChildren = root.GetComponentsInChildren(true); foreach (ItemEquippable val in componentsInChildren) { if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).GetComponent() == (Object)null) { ((Component)val).gameObject.AddComponent(); } } PhysGrabObject[] componentsInChildren2 = root.GetComponentsInChildren(true); foreach (PhysGrabObject val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)null && (Object)(object)((Component)val2).GetComponent() == (Object)null) { ((Component)val2).gameObject.AddComponent(); } } } internal static bool Contains(ItemEquippable item) { if ((Object)(object)item == (Object)null) { return false; } if ((Object)(object)((Component)item).GetComponentInParent() != (Object)null || (Object)(object)((Component)item).GetComponentInChildren(true) != (Object)null) { return true; } PhotonView componentInParent = ((Component)item).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { if (!((Object)(object)((Component)componentInParent).GetComponent() != (Object)null)) { return (Object)(object)((Component)componentInParent).GetComponentInChildren(true) != (Object)null; } return true; } return false; } } [HarmonyPatch(typeof(ItemEquippable), "RPC_RequestEquip")] internal static class ModEnemyInventoryEquipPatch { private static bool Prefix(ItemEquippable __instance) { if (!ModEnemyInventoryBlocker.Contains(__instance)) { return true; } PhysGrabObject obj = ((Component)__instance).GetComponent() ?? ((Component)__instance).GetComponentInParent(); if (obj != null) { obj.OverrideGrabDisable(0.8f); } return false; } } [HarmonyPatch(typeof(ItemEquippable), "Update")] internal static class ModEnemyInventoryUpdatePatch { private static bool Prefix(ItemEquippable __instance) { return !ModEnemyInventoryBlocker.Contains(__instance); } } internal static class ModEnemyNavigation { internal static bool TryFindClearSpawn(Vector3 candidate, float sampleRadius, out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //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_005c: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; NavMeshHit val3 = default(NavMeshHit); for (int i = 0; i < 14; i++) { Vector3 val = candidate; float num = sampleRadius; if (i > 0) { Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val2 = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(4.5f, 14f); val += new Vector3(val2.x, 0f, val2.y); num = 3.5f; } if (NavMesh.SamplePosition(val, ref val3, num, -1) && IsClearOfExistingEnemies(((NavMeshHit)(ref val3)).position, 4.25f)) { position = ((NavMeshHit)(ref val3)).position; return true; } } return false; } internal static bool EnsureOnNavMesh(NavMeshAgent agent, Transform owner, float sampleRadius = 4f) { //IL_0027: 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_0058: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)agent == (Object)null || (Object)(object)owner == (Object)null) { return false; } if (((Behaviour)agent).enabled && agent.isOnNavMesh) { return true; } NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(owner.position, ref val, sampleRadius, -1)) { return false; } if (!((Behaviour)agent).enabled) { ((Behaviour)agent).enabled = true; } owner.position = ((NavMeshHit)(ref val)).position; if (agent.Warp(((NavMeshHit)(ref val)).position)) { return agent.isOnNavMesh; } return false; } internal static bool TrySetDestination(NavMeshAgent agent, Transform owner, Vector3 requested, float sampleRadius = 3f) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if (!EnsureOnNavMesh(agent, owner) || !NavMesh.SamplePosition(requested, ref val, sampleRadius, -1)) { return false; } agent.isStopped = false; if (agent.SetDestination(((NavMeshHit)(ref val)).position)) { return true; } agent.ResetPath(); return agent.SetDestination(((NavMeshHit)(ref val)).position); } internal static bool TrySetLocalRoamDestination(NavMeshAgent agent, Transform owner, float minimumDistance = 4f, float maximumDistance = 11f) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)agent == (Object)null || (Object)(object)owner == (Object)null || maximumDistance <= 0f) { return false; } minimumDistance = Mathf.Clamp(minimumDistance, 0f, maximumDistance); for (int i = 0; i < 10; i++) { Vector2 val = Random.insideUnitCircle; if (((Vector2)(ref val)).sqrMagnitude < 0.001f) { val = Vector2.right; } ((Vector2)(ref val)).Normalize(); float num = Random.Range(minimumDistance, maximumDistance); Vector3 requested = owner.position + new Vector3(val.x, 0f, val.y) * num; if (TrySetDestination(agent, owner, requested, 3.5f)) { return true; } } return false; } private static bool IsClearOfExistingEnemies(Vector3 position, float radius) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_004d: 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_006f: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_011a: Unknown result type (might be due to invalid IL or missing references) float num = radius * radius; if (NearAny(Object.FindObjectsOfType(), position, num) || NearAny(Object.FindObjectsOfType(), position, num) || NearAny(Object.FindObjectsOfType(), position, num) || NearAny(Object.FindObjectsOfType(), position, num) || NearAny(Object.FindObjectsOfType(), position, num) || NearAny(Object.FindObjectsOfType(), position, num) || NearAny(Object.FindObjectsOfType(), position, num) || NearAny(Object.FindObjectsOfType(), position, num) || NearAny(Object.FindObjectsOfType(), position, num) || NearAny(Object.FindObjectsOfType(), position, num) || NearAny(Object.FindObjectsOfType(), position, num) || NearAny(Object.FindObjectsOfType(), position, num) || NearAny(Object.FindObjectsOfType(), position, num) || NearAny(Object.FindObjectsOfType(), position, num) || NearAny(Object.FindObjectsOfType(), position, num) || NearAny(Object.FindObjectsOfType(), position, num)) { return false; } EnemyParent[] array = Object.FindObjectsOfType(); foreach (EnemyParent val in array) { if ((Object)(object)val != (Object)null && HorizontalDistanceSquared(((Component)val).transform.position, position) < num) { return false; } } return true; } private static bool NearAny(T[] objects, Vector3 position, float radiusSquared) where T : Component { //IL_0027: 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) foreach (T val in objects) { if ((Object)(object)val != (Object)null && HorizontalDistanceSquared(((Component)val).transform.position, position) < radiusSquared) { return true; } } return false; } private static float HorizontalDistanceSquared(Vector3 left, Vector3 right) { //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) //IL_0002: 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) Vector3 val = left - right; val.y = 0f; return ((Vector3)(ref val)).sqrMagnitude; } } internal static class ModEnemySpawnCoordinator { private sealed class Candidate { internal string Name; internal int Tier; internal Func Weight; internal Func Spawn; internal Func IsAlive; } private sealed class AutomaticSlot { internal Candidate Candidate; internal bool WasAlive; internal bool FinalExtractionExpedited; internal bool RespawnLimitLogged; internal float VanillaDespawnedTimeMin = 60f; internal float VanillaDespawnedTimeMax = 120f; internal int MaximumRespawns = 2; internal int RespawnsCompleted; internal float RespawnAt = float.PositiveInfinity; } private static readonly List Candidates = new List(); private static readonly List AutomaticSlots = new List(); private static readonly HashSet SelectedNames = new HashSet(); private const BindingFlags InstanceFields = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static readonly FieldInfo AllExtractionPointsCompletedField = typeof(RoundDirector).GetField("allExtractionPointsCompleted", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo ExtractionPointsField = typeof(RoundDirector).GetField("extractionPoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo ExtractionPointsCompletedField = typeof(RoundDirector).GetField("extractionPointsCompleted", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo DespawnedDecreaseMultiplierField = typeof(EnemyDirector).GetField("despawnedDecreaseMultiplier", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo DespawnedTimeMultiplierField = typeof(EnemyDirector).GetField("despawnedTimeMultiplier", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static CarouselManager _carousel; private static EffigyManager _effigy; private static DeadAirManager _deadAir; private static BrokerManager _broker; private static BellhopManager _bellhop; private static VoodooManager _voodoo; private static AnatomistManager _anatomist; private static ParasiteManager _parasite; private static AuditorManager _auditor; private static PlaybackManager _playback; private static MimicManager _mimic; private static ConfectionerManager _confectioner; private static UndertowManager _undertow; private static CupidManager _cupid; private static MarionetteManager _marionette; private static DeliriumManager _delirium; private static int _levelId; private static int _selectedCount; private static bool _levelClosed; private static bool _directorRequestActive; private static bool _respawnRequestActive; private static bool _selectionLogged; internal static string CurrentSpawnSource { get { if (!_respawnRequestActive) { if (!_directorRequestActive) { return "Enemy Lab"; } return "vanilla EnemyDirector slot"; } return "vanilla-style respawn"; } } internal static bool IsDirectorRequestActive { get { if (!_directorRequestActive) { return _respawnRequestActive; } return true; } } internal static void Initialize(CarouselManager carousel, EffigyManager effigy, DeadAirManager deadAir, BrokerManager broker, BellhopManager bellhop, VoodooManager voodoo, AnatomistManager anatomist, ParasiteManager parasite, AuditorManager auditor, PlaybackManager playback, MimicManager mimic, ConfectionerManager confectioner, UndertowManager undertow, CupidManager cupid, MarionetteManager marionette, DeliriumManager delirium) { _carousel = carousel; _effigy = effigy; _deadAir = deadAir; _broker = broker; _bellhop = bellhop; _voodoo = voodoo; _anatomist = anatomist; _parasite = parasite; _auditor = auditor; _playback = playback; _mimic = mimic; _confectioner = confectioner; _undertow = undertow; _cupid = cupid; _marionette = marionette; _delirium = delirium; Candidates.Clear(); Add("The Dead Air", 1, () => Plugin.Settings.DeadAirSpawnChance.Value, delegate(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) _deadAir.MarkAutomaticAttemptFinished(); return _deadAir.DebugSpawnAt(position); }); Add("The Broker", 1, () => Plugin.Settings.BrokerSpawnChance.Value, delegate(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) _broker.MarkAutomaticAttemptFinished(); return _broker.DebugSpawnAt(position); }); Add("The Carousel", 2, () => Plugin.Settings.SpawnChance.Value, delegate(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) _carousel.MarkAutomaticAttemptFinished(); return _carousel.DebugSpawnAt(position); }); Add("The Bellhop", 2, () => Plugin.Settings.BellhopSpawnChance.Value, delegate(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) _bellhop.MarkAutomaticAttemptFinished(); return _bellhop.DebugSpawnAt(position); }); Add("The Anatomist", 2, () => Plugin.Settings.AnatomistSpawnChance.Value, delegate(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) _anatomist.MarkAutomaticAttemptFinished(); return _anatomist.DebugSpawnAt(position); }); Add("The Parasite", 2, () => Plugin.Settings.ParasiteSpawnChance.Value, delegate(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) _parasite.MarkAutomaticAttemptFinished(); return _parasite.DebugSpawnAt(position); }); Add("The Auditor", 2, () => Plugin.Settings.AuditorSpawnChance.Value, delegate(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) _auditor.MarkAutomaticAttemptFinished(); return _auditor.DebugSpawnAt(position); }); Add("The Backlash", 2, () => Plugin.Settings.PlaybackSpawnChance.Value, delegate(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) _playback.MarkAutomaticAttemptFinished(); return _playback.DebugSpawnAt(position); }); Add("The Mimic", 3, () => Plugin.Settings.MimicSpawnChance.Value, delegate(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) _mimic.MarkAutomaticAttemptFinished(); return _mimic.DebugSpawnAt(position); }); Add("The Confectioner", 2, () => Plugin.Settings.ConfectionerSpawnChance.Value, delegate(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) _confectioner.MarkAutomaticAttemptFinished(); return _confectioner.DebugSpawnAt(position); }); Add("The Weeping Angel", 3, () => Plugin.Settings.EffigySpawnChance.Value, delegate(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) _effigy.MarkAutomaticAttemptFinished(); return _effigy.DebugSpawnAt(position); }); Add("The Undertow", 3, () => Plugin.Settings.UndertowSpawnChance.Value, delegate(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) _undertow.MarkAutomaticAttemptFinished(); return _undertow.DebugSpawnAt(position); }); Add("The Cupid", 2, () => Plugin.Settings.CupidSpawnChance.Value, delegate(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) _cupid.MarkAutomaticAttemptFinished(); return _cupid.DebugSpawnAt(position); }); Add("The Marionette", 2, () => Plugin.Settings.MarionetteSpawnChance.Value, delegate(Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) _marionette.MarkAutomaticAttemptFinished(); return _marionette.DebugSpawnAt(position); }); } private static void Add(string name, int tier, Func weight, Func spawn) { Candidates.Add(new Candidate { Name = name, Tier = tier, Weight = weight, Spawn = spawn, IsAlive = BuildAliveProbe(name) }); } private static Func BuildAliveProbe(string name) { return name switch { "The Carousel" => () => HasLiving(), "The Weeping Angel" => () => HasLiving(), "The Dead Air" => () => HasLiving(), "The Broker" => () => HasLiving(), "The Bellhop" => () => HasLiving(), "The Voodoo" => HasLivingVoodoo, "The Anatomist" => () => HasLiving(), "The Parasite" => () => HasLiving(), "The Auditor" => () => HasLiving(), "The Backlash" => () => HasLiving(), "The Mimic" => () => HasLiving(), "The Confectioner" => () => HasLiving(), "The Undertow" => () => HasLiving(), "The Cupid" => () => HasLiving(), "The Marionette" => () => HasLiving(), "The Delirium" => () => (Object)(object)_delirium != (Object)null && _delirium.HasLiveEncounter, _ => () => false, }; } private static bool HasLiving() where T : MonoBehaviour, IModEnemyTumbleReceiver { T[] array = Object.FindObjectsOfType(); foreach (T val in array) { if ((Object)(object)val != (Object)null && val.CanReceiveTumbleAttack) { return true; } } return false; } private static bool HasLivingVoodoo() { VoodooController[] array = Object.FindObjectsOfType(); foreach (VoodooController voodooController in array) { if ((Object)(object)voodooController != (Object)null && voodooController.IsEncounterAlive) { return true; } } return false; } internal static void Tick() { PrepareLevel(); LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null || !instance.Generated) { return; } if (!_levelClosed) { _levelClosed = true; _carousel?.MarkAutomaticAttemptFinished(); _effigy?.MarkAutomaticAttemptFinished(); _deadAir?.MarkAutomaticAttemptFinished(); _broker?.MarkAutomaticAttemptFinished(); _bellhop?.MarkAutomaticAttemptFinished(); _voodoo?.MarkAutomaticAttemptFinished(); _anatomist?.MarkAutomaticAttemptFinished(); _parasite?.MarkAutomaticAttemptFinished(); _auditor?.MarkAutomaticAttemptFinished(); _playback?.MarkAutomaticAttemptFinished(); _mimic?.MarkAutomaticAttemptFinished(); _confectioner?.MarkAutomaticAttemptFinished(); _undertow?.MarkAutomaticAttemptFinished(); _cupid?.MarkAutomaticAttemptFinished(); _marionette?.MarkAutomaticAttemptFinished(); _delirium?.MarkAutomaticAttemptFinished(); if (!_selectionLogged) { _selectionLogged = true; Plugin.Log.LogInfo((object)$"EnemyDirector integration closed this level with {_selectedCount} mod enemy slot replacement(s); per-slot replacement chance was {Mathf.Clamp01(Plugin.Settings.ModEnemySlotReplacementChance.Value / 100f):P1} and independent per-enemy lotteries are disabled."); } } TickAutomaticRespawns(); } internal static bool TryReplaceVanillaSlot(EnemySetup setup, Vector3 vanillaPosition) { //IL_0172: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) PrepareLevel(); if (_levelClosed || (Object)(object)setup == (Object)null || !SemiFunc.IsMasterClientOrSingleplayer() || !ModEnemyLevelRules.IsPlayableLevel()) { return false; } int num = (((Object)(object)RunManager.instance != (Object)null && RunManager.instance.levelsCompleted < 3) ? 1 : 2); if (_selectedCount >= num) { return false; } int num2 = ResolveTier(setup); List list = new List(); float num3 = 0f; foreach (Candidate candidate2 in Candidates) { if (candidate2.Tier == num2 && !SelectedNames.Contains(candidate2.Name)) { float num4 = Mathf.Clamp01(candidate2.Weight()); if (!(num4 <= 0f)) { list.Add(candidate2); num3 += num4; } } } if (list.Count == 0) { return false; } float num5 = Mathf.Clamp01(Plugin.Settings.ModEnemySlotReplacementChance.Value / 100f); if (Random.value > num5) { return false; } float num6 = Random.value * num3; Candidate candidate = list[list.Count - 1]; foreach (Candidate item in list) { num6 -= Mathf.Clamp01(item.Weight()); if (num6 <= 0f) { candidate = item; break; } } Vector3 val = Random.insideUnitSphere * 4f; val.y = 0f; _directorRequestActive = true; bool flag; try { flag = candidate.Spawn(vanillaPosition + val); if (!flag) { flag = candidate.Spawn(vanillaPosition); } } finally { _directorRequestActive = false; } if (!flag) { Plugin.Log.LogWarning((object)("EnemyDirector selected " + candidate.Name + ", but its vanilla slot was retained because the encounter could not spawn.")); return false; } ReadVanillaRespawnProfile(setup, out var minimum, out var maximum, out var maximumRespawns); SelectedNames.Add(candidate.Name); _selectedCount++; AutomaticSlots.Add(new AutomaticSlot { Candidate = candidate, WasAlive = true, VanillaDespawnedTimeMin = minimum, VanillaDespawnedTimeMax = maximum, MaximumRespawns = maximumRespawns }); Plugin.Log.LogInfo((object)$"EnemyDirector replaced one difficulty-{num2} vanilla enemy slot with {candidate.Name} ({_selectedCount}/{num} mod slots this level); vanilla defeated timer={minimum:0.#}-{maximum:0.#}s, MOD respawn cap={maximumRespawns}."); return true; } private static void TickAutomaticRespawns() { //IL_0200: 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) if (AutomaticSlots.Count == 0 || !SemiFunc.IsMasterClientOrSingleplayer() || !ModEnemyLevelRules.IsPlayableLevel()) { return; } bool flag = AreAllExtractionsCompleted(); foreach (AutomaticSlot automaticSlot in AutomaticSlots) { if (automaticSlot?.Candidate == null) { continue; } if (automaticSlot.Candidate.IsAlive != null && automaticSlot.Candidate.IsAlive()) { automaticSlot.WasAlive = true; automaticSlot.FinalExtractionExpedited = false; automaticSlot.RespawnAt = float.PositiveInfinity; continue; } if (automaticSlot.WasAlive) { automaticSlot.WasAlive = false; if (automaticSlot.RespawnsCompleted >= automaticSlot.MaximumRespawns) { automaticSlot.RespawnAt = float.PositiveInfinity; if (!automaticSlot.RespawnLimitLogged) { automaticSlot.RespawnLimitLogged = true; Plugin.Log.LogInfo((object)$"{automaticSlot.Candidate.Name} exhausted its MOD respawn cap ({automaticSlot.MaximumRespawns}); its consumed vanilla slot will stay defeated for this level."); } continue; } float num = CalculateVanillaDefeatedCooldown(automaticSlot); automaticSlot.RespawnAt = Time.time + num; Plugin.Log.LogInfo((object)$"{automaticSlot.Candidate.Name} entered the replaced vanilla enemy's exact defeated cooldown ({num:F1}s; respawn {automaticSlot.RespawnsCompleted + 1}/{automaticSlot.MaximumRespawns})."); } if (flag && !automaticSlot.FinalExtractionExpedited) { automaticSlot.FinalExtractionExpedited = true; if (!float.IsPositiveInfinity(automaticSlot.RespawnAt) && automaticSlot.RespawnAt - Time.time > 30f) { automaticSlot.RespawnAt = Time.time; Plugin.Log.LogInfo((object)("Final extraction set " + automaticSlot.Candidate.Name + "'s remaining defeated timer to zero, matching EnemyDirector.")); } } if (Time.time < automaticSlot.RespawnAt) { continue; } if (!TryFindRespawnPosition(out var position)) { automaticSlot.RespawnAt = Time.time + 3f; continue; } bool flag2 = false; _respawnRequestActive = true; try { flag2 = automaticSlot.Candidate.Spawn(position); } finally { _respawnRequestActive = false; } if (flag2) { automaticSlot.RespawnsCompleted++; automaticSlot.WasAlive = true; automaticSlot.FinalExtractionExpedited = false; automaticSlot.RespawnAt = float.PositiveInfinity; Plugin.Log.LogInfo((object)$"{automaticSlot.Candidate.Name} respawned from its original vanilla enemy slot at {position}."); } else { automaticSlot.RespawnAt = Time.time + 3f; Plugin.Log.LogWarning((object)(automaticSlot.Candidate.Name + "'s respawn could not find a usable encounter position; retrying shortly.")); } } } private static float CalculateVanillaDefeatedCooldown(AutomaticSlot slot) { float num = Mathf.Max(0f, slot.VanillaDespawnedTimeMin); float num2 = Mathf.Max(num, slot.VanillaDespawnedTimeMax); float num3 = ReadDirectorMultiplier(DespawnedDecreaseMultiplierField, 1f); float num4 = ReadDirectorMultiplier(DespawnedTimeMultiplierField, 1f); return Mathf.Max(Random.Range(num, num2) * num3 * num4, 1f) * 3f; } private static float ReadDirectorMultiplier(FieldInfo field, float fallback) { try { EnemyDirector instance = EnemyDirector.instance; if ((Object)(object)instance != (Object)null && field?.GetValue(instance) is float num) { return Mathf.Max(0f, num); } } catch (Exception ex) { Plugin.Log.LogWarning((object)$"Could not read a vanilla EnemyDirector respawn multiplier; using {fallback:0.##}: {ex.Message}"); } return fallback; } private static void ReadVanillaRespawnProfile(EnemySetup setup, out float minimum, out float maximum, out int maximumRespawns) { minimum = 60f; maximum = 120f; maximumRespawns = 2; if (setup?.spawnObjects == null) { return; } bool flag = false; bool flag2 = false; foreach (PrefabRef spawnObject in setup.spawnObjects) { GameObject val = ((PrefabRef)(object)spawnObject)?.Prefab; if (!((Object)(object)val == (Object)null)) { EnemyParent component = val.GetComponent(); if (!flag && (Object)(object)component != (Object)null) { minimum = Mathf.Max(0f, component.DespawnedTimeMin); maximum = Mathf.Max(minimum, component.DespawnedTimeMax); flag = true; } EnemyHealth componentInChildren = val.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null && componentInChildren.spawnValuable) { int num = Mathf.Max(0, componentInChildren.spawnValuableMax - 1); maximumRespawns = (flag2 ? Mathf.Min(maximumRespawns, num) : num); flag2 = true; } } } maximumRespawns = Mathf.Max(0, maximumRespawns); } private static bool AreAllExtractionsCompleted() { RoundDirector instance = RoundDirector.instance; if ((Object)(object)instance == (Object)null) { return false; } try { if (AllExtractionPointsCompletedField?.GetValue(instance) is bool result) { return result; } if (ExtractionPointsField?.GetValue(instance) is int num && ExtractionPointsCompletedField?.GetValue(instance) is int num2) { return num > 0 && num2 >= num; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not read the vanilla final-extraction state; normal MOD respawn cooldown remains active: " + ex.Message)); } return false; } private static bool TryFindRespawnPosition(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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) position = Vector3.zero; List list = SemiFunc.LevelPointsGetAll(); if (list == null || list.Count == 0) { return false; } List list2 = new List(); List list3 = new List(); NavMeshHit val = default(NavMeshHit); foreach (LevelPoint item in list) { if ((Object)(object)item == (Object)null || item.Truck || ((Object)(object)item.Room != (Object)null && item.Room.Truck) || !NavMesh.SamplePosition(((Component)item).transform.position, ref val, 2f, -1)) { continue; } float num = float.PositiveInfinity; foreach (PlayerAvatar item2 in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item2)) { num = Mathf.Min(num, Vector3.Distance(((NavMeshHit)(ref val)).position, ((Component)item2).transform.position)); } } if (num >= 18f) { list2.Add(((NavMeshHit)(ref val)).position); } else if (num >= 8f) { list3.Add(((NavMeshHit)(ref val)).position); } } List list4 = ((list2.Count > 0) ? list2 : list3); if (list4.Count == 0) { return false; } position = list4[Random.Range(0, list4.Count)]; return true; } private static int ResolveTier(EnemySetup setup) { EnemyDirector instance = EnemyDirector.instance; if (instance?.enemiesDifficulty3 != null && instance.enemiesDifficulty3.Contains(setup)) { return 3; } if (instance?.enemiesDifficulty2 != null && instance.enemiesDifficulty2.Contains(setup)) { return 2; } return 1; } private static void PrepareLevel() { LevelGenerator instance = LevelGenerator.Instance; int num = (((Object)(object)instance != (Object)null) ? ((Object)instance).GetInstanceID() : 0); if (num != _levelId) { _levelId = num; _selectedCount = 0; _levelClosed = false; _selectionLogged = false; SelectedNames.Clear(); AutomaticSlots.Clear(); } } } internal static class ModEnemyLevelRules { internal static bool IsPlayableLevel() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)RunManager.instance == (Object)null) { return false; } Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; if (!string.IsNullOrEmpty(name) && name.IndexOf("Arena", StringComparison.OrdinalIgnoreCase) >= 0) { return false; } try { return !SemiFunc.RunIsLobbyMenu() && !SemiFunc.MenuLevel() && !SemiFunc.RunIsShop() && !SemiFunc.RunIsArena(); } catch { return false; } } } [HarmonyPatch(typeof(LevelGenerator), "EnemySpawn")] internal static class ModEnemyVanillaSlotPatch { [HarmonyPrefix] private static bool Prefix(EnemySetup enemySetup, Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !ModEnemySpawnCoordinator.TryReplaceVanillaSlot(enemySetup, position); } } internal interface IModEnemyTranqAware { void OnTranqStunned(float duration); } internal static class ModEnemyTranqStun { private sealed class Entry { internal IModEnemyTumbleReceiver Receiver; internal MonoBehaviour Behaviour; internal ModEnemyTranqStunDriver Driver; internal readonly List Parts = new List(); } private static readonly List Entries = new List(); private static readonly Dictionary ConfirmedTranqColliders = new Dictionary(); private static readonly FieldInfo PlayerCausingHurtField = typeof(HurtCollider).GetField("playerCausingHurt", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); internal static bool IsPlayerTranq(HurtCollider source) { if ((Object)(object)source == (Object)null || source.enemyKill || !source.enemyStun || source.enemyStunTime <= 0f) { return false; } object? obj = PlayerCausingHurtField?.GetValue(source); if ((Object)((obj is PlayerAvatar) ? obj : null) == (Object)null) { return false; } if (!ConfirmedTranqColliders.TryGetValue(((Object)source).GetInstanceID(), out var value) || Time.time > value) { return false; } return (Object)(object)((Component)source).GetComponentInParent() != (Object)null; } internal static void MarkConfirmedTranq(HurtCollider source) { if ((Object)(object)source == (Object)null) { return; } ConfirmedTranqColliders[((Object)source).GetInstanceID()] = Time.time + 3f; if (ConfirmedTranqColliders.Count <= 64) { return; } List list = null; foreach (KeyValuePair confirmedTranqCollider in ConfirmedTranqColliders) { if (confirmedTranqCollider.Value < Time.time) { if (list == null) { list = new List(); } list.Add(confirmedTranqCollider.Key); } } foreach (int item in list ?? new List()) { ConfirmedTranqColliders.Remove(item); } } internal static void Register(IModEnemyTumbleReceiver receiver, Transform part) { MonoBehaviour behaviour = (MonoBehaviour)((receiver is MonoBehaviour) ? receiver : null); if (receiver != null && !((Object)(object)behaviour == (Object)null) && !((Object)(object)part == (Object)null) && !IsStunImmune(receiver)) { CleanupDeadEntries(); Entry entry = Entries.Find((Entry candidate) => candidate != null && (Object)(object)candidate.Behaviour == (Object)(object)behaviour); if (entry == null) { entry = new Entry { Receiver = receiver, Behaviour = behaviour }; entry.Driver = ((Component)behaviour).gameObject.GetComponent() ?? ((Component)behaviour).gameObject.AddComponent(); entry.Driver.Initialize(behaviour); Entries.Add(entry); } if (!entry.Parts.Contains(part)) { entry.Parts.Add(part); entry.Driver?.RegisterPart(part); } } } internal static void Unregister(IModEnemyTumbleReceiver receiver, Transform part) { MonoBehaviour behaviour = (MonoBehaviour)((receiver is MonoBehaviour) ? receiver : null); Entry entry = Entries.Find((Entry candidate) => candidate != null && (Object)(object)candidate.Behaviour == (Object)(object)behaviour); if (entry != null) { entry.Parts.Remove(part); if (entry.Parts.Count == 0 || (Object)(object)entry.Behaviour == (Object)null) { Entries.Remove(entry); } } } internal static bool TryApply(IModEnemyTumbleReceiver receiver, HurtCollider source, Vector3 hitPosition) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || !IsPlayerTranq(source) || receiver == null || IsStunImmune(receiver)) { return false; } MonoBehaviour behaviour = (MonoBehaviour)((receiver is MonoBehaviour) ? receiver : null); Entry entry = Entries.Find((Entry candidate) => candidate != null && (Object)(object)candidate.Behaviour == (Object)(object)behaviour); if (entry == null || (Object)(object)entry.Driver == (Object)null) { return false; } Apply(entry, source, hitPosition); return true; } internal static bool TryApplyNearest(HurtCollider source, Vector3 hitPosition) { //IL_00b0: 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_005c: Unknown result type (might be due to invalid IL or missing references) //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) if (!SemiFunc.IsMasterClientOrSingleplayer() || !IsPlayerTranq(source)) { return false; } CleanupDeadEntries(); Entry entry = null; float num = 5.0625f; foreach (Entry entry2 in Entries) { foreach (Transform part in entry2.Parts) { if (!((Object)(object)part == (Object)null)) { Vector3 val = part.position - hitPosition; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; entry = entry2; } } } } if (entry == null) { return false; } Apply(entry, source, hitPosition); return true; } private static void Apply(Entry entry, HurtCollider source, Vector3 hitPosition) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) float duration = Mathf.Clamp(source.enemyStunTime, 0.5f, 8f); if (entry.Receiver is IModEnemyTranqAware modEnemyTranqAware) { modEnemyTranqAware.OnTranqStunned(duration); } entry.Driver.Stun(duration); Transform val = null; float num = float.MaxValue; foreach (Transform part in entry.Parts) { if (!((Object)(object)part == (Object)null)) { Vector3 val2 = part.position - hitPosition; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val = part; } } } PhysGrabObjectImpactDetector obj = ((val != null) ? ((Component)val).GetComponentInParent() : null) ?? ((val != null) ? ((Component)val).GetComponentInChildren(true) : null); if (obj != null) { obj.ImpactLight(18f, hitPosition); } } private static bool IsStunImmune(IModEnemyTumbleReceiver receiver) { return receiver is EffigyController; } private static void CleanupDeadEntries() { for (int num = Entries.Count - 1; num >= 0; num--) { Entry entry = Entries[num]; if (entry == null || (Object)(object)entry.Behaviour == (Object)null) { Entries.RemoveAt(num); } else { entry.Parts.RemoveAll((Transform part) => (Object)(object)part == (Object)null); if (entry.Parts.Count == 0) { Entries.RemoveAt(num); } } } } } [HarmonyPatch(typeof(ItemGun), "ShootBulletRPC")] internal static class ModEnemyTranqShotPatch { private static readonly FieldInfo HurtColliderField = typeof(ItemGun).GetField("hurtCollider", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); [HarmonyPostfix] private static void Postfix(ItemGun __instance) { if (!((Object)(object)__instance == (Object)null) && (!((Object)(object)((Component)__instance).GetComponent() == (Object)null) || !((Object)(object)((Component)__instance).GetComponentInParent() == (Object)null) || !((Object)(object)((Component)__instance).GetComponentInChildren(true) == (Object)null))) { object? obj = HurtColliderField?.GetValue(__instance); ModEnemyTranqStun.MarkConfirmedTranq((HurtCollider)((obj is HurtCollider) ? obj : null)); } } } internal sealed class ModEnemyTranqStunDriver : MonoBehaviour { private sealed class RigPose { internal PhysGrabObject Phys; internal Vector3 LocalPosition; internal Quaternion LocalRotation; } private MonoBehaviour _target; private NavMeshAgent[] _agents = Array.Empty(); private bool[] _agentWasStopped = Array.Empty(); private readonly List _registeredParts = new List(); private readonly List _rig = new List(); private float _remaining; private bool _stunned; internal void Initialize(MonoBehaviour target) { _target = target; _agents = (((Object)(object)target != (Object)null) ? ((Component)target).GetComponentsInChildren(true) : Array.Empty()); } internal void RegisterPart(Transform part) { if ((Object)(object)part != (Object)null && !_registeredParts.Contains(part)) { _registeredParts.Add(part); } } internal void Stun(float duration) { if ((Object)(object)_target == (Object)null) { return; } _remaining = Mathf.Max(_remaining, duration); if (_stunned) { PinPhysics(duration); return; } _stunned = true; CaptureRig(); _agentWasStopped = new bool[_agents.Length]; for (int i = 0; i < _agents.Length; i++) { NavMeshAgent val = _agents[i]; if (!((Object)(object)val == (Object)null) && ((Behaviour)val).enabled && val.isOnNavMesh) { _agentWasStopped[i] = val.isStopped; val.isStopped = true; } } ((Behaviour)_target).enabled = false; PinPhysics(duration); } private void Update() { if (_stunned) { _remaining -= Time.deltaTime; PinPhysics(Mathf.Max(0.12f, _remaining)); if (!(_remaining > 0f)) { Release(); } } } private void PinPhysics(float duration) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_target == (Object)null) { return; } PhysGrabObject[] componentsInChildren = ((Component)_target).GetComponentsInChildren(true); foreach (PhysGrabObject val in componentsInChildren) { if (val != null) { val.OverrideKinematic(duration + 0.2f); } if ((Object)(object)val?.rb != (Object)null && !val.rb.isKinematic) { val.rb.velocity = Vector3.zero; val.rb.angularVelocity = Vector3.zero; } } foreach (RigPose item in _rig) { PhysGrabObject val2 = item?.Phys; if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.rb == (Object)null)) { Vector3 val3 = ((Component)_target).transform.TransformPoint(item.LocalPosition); Quaternion val4 = ((Component)_target).transform.rotation * item.LocalRotation; val2.OverrideGrabDisable(duration + 0.25f); val2.OverrideKinematic(duration + 0.25f); val2.OverrideIndestructible(duration + 0.25f); val2.SetPositionLogic(val3, val4); if (!val2.rb.isKinematic) { val2.rb.velocity = Vector3.zero; val2.rb.angularVelocity = Vector3.zero; } } } } private void CaptureRig() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00bd: Unknown result type (might be due to invalid IL or missing references) _rig.Clear(); HashSet hashSet = new HashSet(); foreach (Transform registeredPart in _registeredParts) { if (!((Object)(object)registeredPart == (Object)null)) { PhysGrabObject val = ((Component)registeredPart).GetComponent() ?? ((Component)registeredPart).GetComponentInParent() ?? ((Component)registeredPart).GetComponentInChildren(true); if (!((Object)(object)val == (Object)null) && hashSet.Add(val)) { _rig.Add(new RigPose { Phys = val, LocalPosition = ((Component)_target).transform.InverseTransformPoint(val.rb.position), LocalRotation = Quaternion.Inverse(((Component)_target).transform.rotation) * val.rb.rotation }); } } } } private void Release() { _stunned = false; _remaining = 0f; _rig.Clear(); if ((Object)(object)_target == (Object)null) { return; } ((Behaviour)_target).enabled = true; for (int i = 0; i < _agents.Length; i++) { NavMeshAgent val = _agents[i]; if ((Object)(object)val != (Object)null && ((Behaviour)val).enabled && val.isOnNavMesh) { val.isStopped = i < _agentWasStopped.Length && _agentWasStopped[i]; } } } private void OnDestroy() { if (_stunned && (Object)(object)_target != (Object)null) { ((Behaviour)_target).enabled = true; } } } internal static class ModEnemyTrapCompatibility { private static readonly FieldInfo PhysIsEnemyField = AccessTools.Field(typeof(PhysGrabObject), "isEnemy"); private static readonly FieldInfo StunBitPhysField = AccessTools.Field(typeof(ItemMineStun), "bitPhysGrabObject"); internal static bool TryGetTrapTarget(Collider collider, out TumbleHitProxy proxy, out PhysGrabObject phys) { proxy = null; phys = null; if ((Object)(object)collider == (Object)null) { return false; } proxy = ((Component)collider).GetComponentInParent(); if ((Object)(object)proxy == (Object)null || !proxy.CanTriggerPlayerTrap) { return false; } phys = ((Component)collider).GetComponentInParent(); if ((Object)(object)phys != (Object)null) { return PhysIsEnemyField != null; } return false; } internal static bool ReadEnemyFlag(PhysGrabObject phys) { bool flag = default(bool); int num; if ((Object)(object)phys != (Object)null) { object obj = PhysIsEnemyField?.GetValue(phys); if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } internal static void WriteEnemyFlag(PhysGrabObject phys, bool value) { if ((Object)(object)phys != (Object)null) { PhysIsEnemyField?.SetValue(phys, value); } } internal static void ApplyStunMineDamage(ItemMineStun stun) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)stun == (Object)null || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } object? obj = StunBitPhysField?.GetValue(stun); PhysGrabObject val = (PhysGrabObject)((obj is PhysGrabObject) ? obj : null); TumbleHitProxy tumbleHitProxy = ((val != null) ? ((Component)val).GetComponent() : null) ?? ((val != null) ? ((Component)val).GetComponentInChildren(true) : null); if (!((Object)(object)tumbleHitProxy == (Object)null) && tumbleHitProxy.CanTriggerPlayerTrap) { HurtCollider val2 = (((Object)(object)stun.hurtCollider != (Object)null) ? stun.hurtCollider.GetComponent() : null); int damage = (((Object)(object)val2 != (Object)null && val2.enemyDamage > 0) ? val2.enemyDamage : 12); Vector3 centerPoint = val.centerPoint; Vector3 val3 = centerPoint - ((Component)stun).transform.position; if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = Vector3.up; } tumbleHitProxy.ReceiveStunMineHit(stun, damage, centerPoint, ((Vector3)(ref val3)).normalized); } } } [HarmonyPatch(typeof(ItemMineStun), "OnTriggered")] internal static class ModEnemyStunMineTriggeredPatch { [HarmonyPostfix] private static void Postfix(ItemMineStun __instance) { ModEnemyTrapCompatibility.ApplyStunMineDamage(__instance); } } [HarmonyPatch(typeof(ItemMineStun), "ElectricityEffect")] internal static class ModEnemyStunMineElectricityPatch { [HarmonyPostfix] private static void Postfix(ItemMineStun __instance) { ModEnemyTrapCompatibility.ApplyStunMineDamage(__instance); } } [HarmonyPatch(typeof(ItemMineTrigger), "PassesTriggerChecks")] internal static class ModEnemyMinePassesTriggerPatch { [HarmonyPrefix] private static bool Prefix(ItemMineTrigger __instance, Collider other, ref bool __result) { if (!SemiFunc.IsMasterClientOrSingleplayer() || !ModEnemyTrapCompatibility.TryGetTrapTarget(other, out var _, out var _)) { return true; } ItemMine componentInParent = ((Component)__instance).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null || !componentInParent.triggeredByEnemies) { return true; } __result = true; return false; } } [HarmonyPatch(typeof(ItemMineTrigger), "TryAcquireTarget")] internal static class ModEnemyMineAcquireTargetPatch { internal readonly struct EnemyFlagState { internal PhysGrabObject Phys { get; } internal bool WasEnemy { get; } internal EnemyFlagState(PhysGrabObject phys, bool wasEnemy) { Phys = phys; WasEnemy = wasEnemy; } } [HarmonyPrefix] private static void Prefix(Collider other, out EnemyFlagState __state) { __state = default(EnemyFlagState); if (SemiFunc.IsMasterClientOrSingleplayer() && ModEnemyTrapCompatibility.TryGetTrapTarget(other, out var _, out var phys)) { bool wasEnemy = ModEnemyTrapCompatibility.ReadEnemyFlag(phys); __state = new EnemyFlagState(phys, wasEnemy); ModEnemyTrapCompatibility.WriteEnemyFlag(phys, value: true); } } [HarmonyPostfix] private static void Postfix(EnemyFlagState __state) { if ((Object)(object)__state.Phys != (Object)null) { ModEnemyTrapCompatibility.WriteEnemyFlag(__state.Phys, __state.WasEnemy); } } } internal sealed class ModEnemyTrapSensor : MonoBehaviour { private const float ExtraRadius = 0.22f; internal static void Attach(GameObject physRoot) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //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_004d: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)physRoot == (Object)null || (Object)(object)physRoot.GetComponentInChildren(true) != (Object)null) { return; } Renderer[] componentsInChildren = physRoot.GetComponentsInChildren(true); bool flag = false; Bounds val = default(Bounds); Renderer[] array = componentsInChildren; Vector3 val3; foreach (Renderer val2 in array) { if ((Object)(object)val2 == (Object)null) { continue; } Bounds bounds = val2.bounds; val3 = ((Bounds)(ref bounds)).size; if (!(((Vector3)(ref val3)).sqrMagnitude < 0.0001f)) { if (!flag) { val = val2.bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(val2.bounds); } } } if (!flag) { Collider componentInChildren = physRoot.GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { return; } val = componentInChildren.bounds; } GameObject val4 = new GameObject("The Uncatalogued Trap Sensor") { layer = physRoot.layer }; val4.transform.SetParent(physRoot.transform, false); val4.transform.localPosition = physRoot.transform.InverseTransformPoint(((Bounds)(ref val)).center); val4.AddComponent(); SphereCollider obj = val4.AddComponent(); ((Collider)obj).isTrigger = true; Vector3 lossyScale = physRoot.transform.lossyScale; float num = Mathf.Max(0.01f, Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Max(Mathf.Abs(lossyScale.y), Mathf.Abs(lossyScale.z)))); val3 = ((Bounds)(ref val)).extents; obj.radius = (((Vector3)(ref val3)).magnitude + 0.22f) / num; } } internal static class ModEnemyValuableDamage { internal static int BreakLightInCone(Vector3 origin, Vector3 forward, float radius, float minimumDot, Func isOwnCollider) { //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 BreakInCone(origin, forward, radius, minimumDot, isOwnCollider, medium: false); } internal static int BreakMediumInCone(Vector3 origin, Vector3 forward, float radius, float minimumDot, Func isOwnCollider) { //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 BreakInCone(origin, forward, radius, minimumDot, isOwnCollider, medium: true); } private static int BreakInCone(Vector3 origin, Vector3 forward, float radius, float minimumDot, Func isOwnCollider, bool medium) { //IL_0013: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_010c: 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_0139: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) int num = 0; float num2 = Mathf.Clamp(radius, 0.2f, 4f); Vector3 val = forward; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.001f) { val = Vector3.forward; } ((Vector3)(ref val)).Normalize(); ValuableObject[] array = Object.FindObjectsOfType(); foreach (ValuableObject val2 in array) { if ((Object)(object)val2 == (Object)null || MapIconSuppressor.OwnsValuable(val2)) { continue; } PhysGrabObject val3 = ((Component)val2).GetComponent() ?? ((Component)val2).GetComponentInParent(); if ((Object)(object)val3 == (Object)null || val3.dead || !((Component)val3).gameObject.activeInHierarchy || (Object)(object)((Component)val3).GetComponent() != (Object)null || (Object)(object)((Component)val3).GetComponentInParent() != (Object)null || (Object)(object)((Component)val3).GetComponentInChildren(true) != (Object)null) { continue; } Vector3 val4 = val3.centerPoint - origin; float magnitude = ((Vector3)(ref val4)).magnitude; if (magnitude > num2 || magnitude <= 0.01f) { continue; } Vector3 val5 = val4; val5.y = 0f; if ((((Vector3)(ref val5)).sqrMagnitude > 0.001f && Vector3.Dot(val, ((Vector3)(ref val5)).normalized) < minimumDot) || !HasClearPath(origin, val4 / magnitude, magnitude, val3, isOwnCollider)) { continue; } PhysGrabObjectImpactDetector val6 = ((Component)val3).GetComponent() ?? ((Component)val3).GetComponentInChildren(true); if (!((Object)(object)val6 == (Object)null)) { if (medium) { val6.BreakMedium(val3.centerPoint, false); } else { val6.BreakLight(val3.centerPoint, false); } num++; } } return num; } private static bool HasClearPath(Vector3 origin, Vector3 direction, float distance, PhysGrabObject target, Func isOwnCollider) { //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) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) RaycastHit[] array = Physics.RaycastAll(origin, direction, distance, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val = array2[num]; Collider collider = ((RaycastHit)(ref val)).collider; if ((Object)(object)((collider != null) ? ((Component)collider).GetComponentInParent() : null) == (Object)(object)target) { return true; } if (isOwnCollider == null || !isOwnCollider(((RaycastHit)(ref val)).collider)) { Collider collider2 = ((RaycastHit)(ref val)).collider; if (!((Object)(object)((collider2 != null) ? ((Component)collider2).GetComponentInParent() : null) != (Object)null)) { return false; } } } return true; } } internal static class ModEnemyWeaponDamage { [ThreadStatic] private static HurtCollider _current; [ThreadStatic] private static HurtCollider _lastSource; [ThreadStatic] private static int _lastSourceFrame; private static readonly Dictionary RecentClaims = new Dictionary(); private static float _nextClaimCleanup; private static HurtCollider EffectiveSource { get { if (!((Object)(object)_current != (Object)null)) { if (_lastSourceFrame != Time.frameCount) { return null; } return _lastSource; } return _current; } } internal static int CurrentClaimId { get { HurtCollider effectiveSource = EffectiveSource; if ((Object)(object)effectiveSource == (Object)null) { return 0; } ItemGunBullet componentInParent = ((Component)effectiveSource).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { return ((Object)componentInParent).GetInstanceID(); } int instanceID = ((Object)effectiveSource).GetInstanceID(); if (instanceID != int.MinValue) { return -Math.Abs(instanceID); } return -2147483647; } } internal static HurtCollider Current => EffectiveSource; internal static bool TryClaim(Object receiver, int sourceId) { if (receiver == (Object)null || sourceId == 0) { return true; } float time = Time.time; long key = ((long)receiver.GetInstanceID() << 32) ^ (uint)sourceId; if (RecentClaims.TryGetValue(key, out var value) && time < value) { return false; } RecentClaims[key] = time + ((sourceId > 0) ? 2f : 0.32f); if (time >= _nextClaimCleanup) { _nextClaimCleanup = time + 8f; List list = null; foreach (KeyValuePair recentClaim in RecentClaims) { if (recentClaim.Value <= time) { if (list == null) { list = new List(); } list.Add(recentClaim.Key); } } foreach (long item in list ?? new List()) { RecentClaims.Remove(item); } } return true; } internal static int CurrentOrFallback(int fallback) { return Resolve(EffectiveSource, fallback); } internal static int Resolve(HurtCollider source, int fallback) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)source == (Object)null) { return Math.Max(0, fallback); } if (ModEnemyTranqStun.IsPlayerTranq(source)) { ModEnemyTranqStun.TryApplyNearest(source, ((Component)source).transform.position); return 0; } ItemMelee componentInParent = ((Component)source).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { int num = 0; HurtCollider[] componentsInChildren = ((Component)componentInParent).GetComponentsInChildren(true); foreach (HurtCollider val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { if (val.enemyKill) { return 1000000; } num = Math.Max(num, val.enemyDamage); } } if (num > 0) { return num; } } if (!source.enemyKill) { return Math.Max(0, source.enemyDamage); } return 1000000; } internal static HurtCollider Push(HurtCollider source) { HurtCollider current = _current; _current = source; _lastSource = source; _lastSourceFrame = Time.frameCount; return current; } internal static void Restore(HurtCollider previous) { _current = previous; } } [HarmonyPatch(typeof(HurtCollider), "PhysObjectHurt")] internal static class ModEnemyWeaponDamagePatch { [HarmonyPrefix] private static void Prefix(HurtCollider __instance, out HurtCollider __state) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) __state = ModEnemyWeaponDamage.Push(__instance); if ((Object)(object)__instance != (Object)null && (__instance.enemyKill || __instance.enemyDamage > 0) && !ModEnemyTranqStun.IsPlayerTranq(__instance)) { DeliriumController.ReportExternalAttack(((Component)__instance).transform.position); } } [HarmonyPostfix] private static void Postfix(HurtCollider __state) { ModEnemyWeaponDamage.Restore(__state); } [HarmonyFinalizer] private static Exception Finalizer(Exception __exception, HurtCollider __state) { ModEnemyWeaponDamage.Restore(__state); return __exception; } } internal interface IPandemicDamageReceiver { bool TryClaimWeaponHit(int bulletInstanceId); void ReceiveWeaponHit(Vector3 hitPosition, int damage); void ExecuteForLab(); } internal sealed class PandemicHitProxy : MonoBehaviour { private IPandemicDamageReceiver _receiver; private Renderer[] _renderers = Array.Empty(); private PhysGrabObjectImpactDetector[] _impactDetectors = Array.Empty(); private readonly Dictionary _previousBulletPositions = new Dictionary(); private readonly HashSet _currentBulletIds = new HashSet(); private float _cooldown; private static int _cachedBulletFrame = -1; private static ItemGunBullet[] _cachedBullets = Array.Empty(); internal void Initialize(IPandemicDamageReceiver receiver, IEnumerable parts) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown _receiver = receiver; List list = new List(); List list2 = new List(); foreach (SpawnedPandemicPart part in parts) { if (part?.Renderers != null) { list.AddRange(part.Renderers); } if ((Object)(object)part?.ImpactDetector != (Object)null) { list2.Add(part.ImpactDetector); UnityEvent onHurtColliderHit = part.ImpactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.AddListener(new UnityAction(OnHurtColliderHit)); } } } _renderers = list.ToArray(); _impactDetectors = list2.ToArray(); } private void Update() { if (_cooldown > 0f) { _cooldown -= Time.deltaTime; } if (_cooldown <= 0f && SemiFunc.IsMasterClientOrSingleplayer()) { DetectExpandedBulletHit(); } } private void OnDestroy() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown PhysGrabObjectImpactDetector[] impactDetectors = _impactDetectors; foreach (PhysGrabObjectImpactDetector obj in impactDetectors) { if (obj != null) { UnityEvent onHurtColliderHit = obj.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.RemoveListener(new UnityAction(OnHurtColliderHit)); } } } } private void OnHurtColliderHit() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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) if (_receiver == null || _cooldown > 0f || !SemiFunc.IsMasterClientOrSingleplayer() || !_receiver.TryClaimWeaponHit(ModEnemyWeaponDamage.CurrentClaimId)) { return; } _cooldown = 0.16f; Vector3 val = ClosestVisualPoint(((Component)this).transform.position); if (EnemyLabBridge.IsExecutionHitNear(val)) { _receiver.ExecuteForLab(); return; } int num = ModEnemyWeaponDamage.CurrentOrFallback(25); if (num > 0) { _receiver.ReceiveWeaponHit(val, num); } } private void DetectExpandedBulletHit() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) if (_receiver == null) { return; } if (_cachedBulletFrame != Time.frameCount) { _cachedBulletFrame = Time.frameCount; _cachedBullets = Object.FindObjectsOfType(); } _currentBulletIds.Clear(); ItemGunBullet[] cachedBullets = _cachedBullets; foreach (ItemGunBullet val in cachedBullets) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent() != (Object)null) { continue; } HurtCollider hurtCollider = val.hurtCollider; if ((Object)(object)hurtCollider == (Object)null || !((Component)hurtCollider).gameObject.activeInHierarchy) { continue; } int instanceID = ((Object)val).GetInstanceID(); _currentBulletIds.Add(instanceID); Vector3 position = ((Component)hurtCollider).transform.position; Vector3 value; bool num = _previousBulletPositions.TryGetValue(instanceID, out value); _previousBulletPositions[instanceID] = position; if (!(num ? SegmentIntersectsVisuals(value, position) : WithinVisuals(position)) || !_receiver.TryClaimWeaponHit(instanceID)) { continue; } _cooldown = 0.25f; if (EnemyLabBridge.IsExecutionHitNear(position)) { _receiver.ExecuteForLab(); return; } int num2 = ModEnemyWeaponDamage.Resolve(hurtCollider, 25); if (num2 > 0) { _receiver.ReceiveWeaponHit(position, num2); } return; } if (_previousBulletPositions.Count <= _currentBulletIds.Count) { return; } List list = null; foreach (int key in _previousBulletPositions.Keys) { if (!_currentBulletIds.Contains(key)) { if (list == null) { list = new List(); } list.Add(key); } } foreach (int item in list ?? new List()) { _previousBulletPositions.Remove(item); } } private bool WithinVisuals(Vector3 position) { //IL_006a: 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_0080: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(0.3f, 0.12f, 0.75f); float num2 = num * num; Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if ((Object)(object)val != (Object)null && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; if (((Bounds)(ref bounds)).SqrDistance(position) <= num2) { return true; } } } Vector3 val2 = position - (((Component)this).transform.position + Vector3.up * 1.05f); return ((Vector3)(ref val2)).sqrMagnitude <= Mathf.Pow(0.6f + num, 2f); } private bool SegmentIntersectsVisuals(Vector3 start, Vector3 end) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_005d: 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_005f: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(0.3f, 0.12f, 0.75f); Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if (!((Object)(object)val == (Object)null) && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; ((Bounds)(ref bounds)).Expand(num * 2f); if (SegmentIntersectsBounds(start, end, bounds)) { return true; } } } Vector3 point = ((Component)this).transform.position + Vector3.up * 1.05f; float num2 = 0.6f + num; return DistancePointToSegmentSquared(point, start, end) <= num2 * num2; } private Vector3 ClosestVisualPoint(Vector3 origin) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0050: 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_0054: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) Vector3 result = ((Component)this).transform.position + Vector3.up; float num = float.MaxValue; Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { if (!((Object)(object)val == (Object)null) && val.enabled) { Bounds bounds = val.bounds; Vector3 val2 = ((Bounds)(ref bounds)).ClosestPoint(origin); Vector3 val3 = val2 - origin; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val2; } } } return result; } private static bool SegmentIntersectsBounds(Vector3 start, Vector3 end, Bounds bounds) { //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) //IL_0002: 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_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float num = 0f; float num2 = 1f; for (int i = 0; i < 3; i++) { float num3 = ((Vector3)(ref start))[i]; float num4 = ((Vector3)(ref val))[i]; Vector3 val2; if (Mathf.Abs(num4) < 1E-05f) { val2 = ((Bounds)(ref bounds)).min; if (!(num3 < ((Vector3)(ref val2))[i])) { val2 = ((Bounds)(ref bounds)).max; if (!(num3 > ((Vector3)(ref val2))[i])) { continue; } } return false; } float num5 = 1f / num4; val2 = ((Bounds)(ref bounds)).min; float num6 = (((Vector3)(ref val2))[i] - num3) * num5; val2 = ((Bounds)(ref bounds)).max; float num7 = (((Vector3)(ref val2))[i] - num3) * num5; if (num6 > num7) { float num8 = num7; num7 = num6; num6 = num8; } num = Mathf.Max(num, num6); num2 = Mathf.Min(num2, num7); if (num > num2) { return false; } } return true; } private static float DistancePointToSegmentSquared(Vector3 point, Vector3 start, Vector3 end) { //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) //IL_0002: 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_0029: 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_002b: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_004e: 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) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; Vector3 val2; if (sqrMagnitude <= 1E-06f) { val2 = point - start; return ((Vector3)(ref val2)).sqrMagnitude; } float num = Mathf.Clamp01(Vector3.Dot(point - start, val) / sqrMagnitude); Vector3 val3 = start + val * num; val2 = point - val3; return ((Vector3)(ref val2)).sqrMagnitude; } } internal enum PandemicBone { TorsoLeft, TorsoCenter, TorsoRight, UpperArmLeft, LowerArmLeft, UpperArmRight, LowerArmRight, UpperLegLeft, LowerLegLeft, UpperLegRight, LowerLegRight } internal sealed class SpawnedPandemicPart { internal GameObject Root; internal PhysGrabObject Phys; internal PhysGrabObjectImpactDetector ImpactDetector; internal ItemAttributes Attributes; internal Renderer[] Renderers; internal Collider[] Colliders; internal PandemicBone Bone; internal Vector3 VisualCenterOffset; internal Vector3 VisualSize; internal Vector3 LongAxisLocal = Vector3.up; internal int GeometryCalibrationFrames = 20; internal bool Alive = true; } internal static class PandemicSpawner { internal const string BranchResourcePath = "Valuables/07 Very Tall/Valuable Wizard Broom"; internal static bool PrefabAvailable() { return (Object)(object)Resources.Load("Valuables/07 Very Tall/Valuable Wizard Broom") != (Object)null; } internal static SpawnedPandemicPart Spawn(Vector3 position, Quaternion rotation, Vector3 scaleMultiplier, PandemicBone bone) { //IL_0027: 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_0051: 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_0077: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) GameObject val = Resources.Load("Valuables/07 Very Tall/Valuable Wizard Broom"); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"The Uncatalogued could not load shared branch resource 'Valuables/07 Very Tall/Valuable Wizard Broom'."); return null; } ((Vector3)(ref scaleMultiplier))..ctor(Mathf.Clamp(scaleMultiplier.x, 0.05f, 1.2f), Mathf.Clamp(scaleMultiplier.y, 0.05f, 1.2f), Mathf.Clamp(scaleMultiplier.z, 0.05f, 1.2f)); Vector3 val2 = Vector3.Scale(val.transform.localScale, scaleMultiplier); object[] array = new object[3] { val2.x, val2.y, val2.z }; GameObject val3; try { val3 = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject("Valuables/07 Very Tall/Valuable Wizard Broom", position, rotation, (byte)0, array) : Object.Instantiate(val, position, rotation)); } catch (Exception arg) { Plugin.Log.LogError((object)$"The Uncatalogued failed to network-spawn a shared branch: {arg}"); return null; } if ((Object)(object)val3 == (Object)null) { return null; } val3.transform.localScale = val2; EncounterValuableNeutralizer.Apply(val3); SpawnedPandemicPart spawnedPandemicPart = new SpawnedPandemicPart { Root = val3, Phys = val3.GetComponentInChildren(true), ImpactDetector = val3.GetComponentInChildren(true), Attributes = val3.GetComponentInChildren(true), Renderers = val3.GetComponentsInChildren(true), Colliders = val3.GetComponentsInChildren(true), Bone = bone }; if ((Object)(object)spawnedPandemicPart.Phys == (Object)null || (Object)(object)spawnedPandemicPart.ImpactDetector == (Object)null) { Plugin.Log.LogError((object)"The shared branch prefab lacks vanilla physical components."); Destroy(spawnedPandemicPart); return null; } RefreshVisualCenter(spawnedPandemicPart); spawnedPandemicPart.LongAxisLocal = Vector3.up; ItemAttributes attributes = spawnedPandemicPart.Attributes; if (attributes != null) { attributes.DisableUI(true); } spawnedPandemicPart.ImpactDetector.destroyDisable = true; spawnedPandemicPart.Phys.OverrideIndestructible(1f); spawnedPandemicPart.Phys.OverrideGrabDisable(1f); spawnedPandemicPart.Phys.OverrideKinematic(1f); MapIconSuppressor.Attach(val3); return spawnedPandemicPart; } internal static void RefreshVisualCenter(SpawnedPandemicPart part) { //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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)part?.Phys == (Object)null) && TryGetRenderedBounds(part.Renderers, out var bounds)) { part.VisualCenterOffset = Quaternion.Inverse(((Component)part.Phys).transform.rotation) * (((Bounds)(ref bounds)).center - ((Component)part.Phys).transform.position); part.VisualSize = ((Bounds)(ref bounds)).size; } } private static bool TryGetRenderedBounds(Renderer[] renderers, out Bounds bounds) { //IL_0001: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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) bounds = default(Bounds); bool flag = false; if (renderers == null) { return false; } foreach (Renderer val in renderers) { if ((Object)(object)val == (Object)null || !val.enabled || (!(val is MeshRenderer) && !(val is SkinnedMeshRenderer))) { continue; } Bounds bounds2 = val.bounds; Vector3 size = ((Bounds)(ref bounds2)).size; if (!(((Vector3)(ref size)).sqrMagnitude < 1E-06f) && !(((Bounds)(ref bounds2)).size.x > 10f) && !(((Bounds)(ref bounds2)).size.y > 10f) && !(((Bounds)(ref bounds2)).size.z > 10f)) { if (!flag) { bounds = bounds2; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(bounds2); } } } return flag; } internal static void Destroy(SpawnedPandemicPart part) { if (!((Object)(object)part?.Root == (Object)null)) { if (GameManager.Multiplayer()) { PhotonNetwork.Destroy(part.Root); } else { Object.Destroy((Object)(object)part.Root); } part.Alive = false; } } } internal sealed class ParasiteController : MonoBehaviour, IModEnemyTumbleReceiver { private enum TargetKind { None, Player, VanillaEnemy, CustomEnemy, Valuable } private sealed class Target { internal TargetKind Kind; internal PlayerAvatar Player; internal EnemyHealth EnemyHealth; internal Object CustomOwner; internal ValuableObject Valuable; internal PhysGrabObject Phys; internal Renderer[] Renderers = Array.Empty(); internal Transform Anchor; internal int Id; internal Vector3 Position { get { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player != (Object)null) { return ((Component)Player).transform.position + Vector3.up * 0.85f; } if ((Object)(object)Phys != (Object)null) { return Phys.centerPoint; } if ((Object)(object)Anchor != (Object)null) { return Anchor.position; } return Vector3.zero; } } } private static readonly MethodInfo NewRayHitPointMethod = typeof(ItemDrone).GetMethod("NewRayHitPoint", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo TargetIsPlayerField = typeof(ItemDrone).GetField("targetIsPlayer", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo TargetIsLocalPlayerField = typeof(ItemDrone).GetField("targetIsLocalPlayer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo PlayerAvatarTargetField = typeof(ItemDrone).GetField("playerAvatarTarget", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo EnemyDeadField = typeof(EnemyHealth).GetField("dead", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo EnemySpawnedField = typeof(EnemyParent).GetField("Spawned", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo DollarValueCurrentField = typeof(ValuableObject).GetField("dollarValueCurrent", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo PlayerHealthValueField = typeof(PlayerHealth).GetField("health", BindingFlags.Instance | BindingFlags.NonPublic); private readonly HashSet _completedValuables = new HashSet(); private SpawnedParasite _body; private NavMeshAgent _agent; private Target _target; private int _health; private float _scanTimer; private float _destinationTimer; private float _roamTimer; private float _attachedSeconds; private float _dotTimer; private float _soundTimer; private float _damageCooldown; private float _flinchTimer; private float _rewardTimer; private float _lastClaimedHit = -999f; private float _beamDeployTimer; private float _playerDetachBlockTimer; private float _forcedRetreatTimer; private float _wallEscapeCooldown; private float _roamStuckTimer; private float _attachmentPathFailTimer; private float _playerOcclusionTimer; private float _obstacleLift; private float _obstacleLiftDemandTimer; private int _blockedPlayerId; private Vector3 _forcedRetreatOrigin; private Vector3 _roamFacingDirection = Vector3.forward; private int _observedPlayerHealth = -1; private int _ignoredReplicatedLoss; private Quaternion _bodyRotation = Quaternion.identity; private bool _beamActive; private bool _beamDeploying; private bool _dead; private bool _initialized; private bool _cleaning; private bool _rewardDropped; public bool CanReceiveTumbleAttack { get { if (_initialized) { return !_dead; } return false; } } internal bool Initialize(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; _health = Mathf.Max(1, Plugin.Settings.ParasiteHealth.Value); _agent = ((Component)this).gameObject.AddComponent(); ((Behaviour)_agent).enabled = false; _agent.speed = Mathf.Max(0.5f, Plugin.Settings.ParasiteMoveSpeed.Value); _agent.acceleration = 28f; _agent.angularSpeed = 620f; _agent.radius = 0.3f; _agent.height = 1.15f; _agent.stoppingDistance = 0.72f; _agent.autoBraking = true; _body = ParasiteSpawner.Spawn(position + Vector3.up * 1.08f); if (_body == null) { return false; } ((Component)_body.Phys).gameObject.AddComponent().Initialize(this, _body); ((Component)_body.Phys).gameObject.AddComponent().Initialize(this, 0); _scanTimer = 0.15f; _roamTimer = 0.5f; _soundTimer = Random.Range(0.65f, 1.05f); _initialized = true; PinBody(position + Vector3.up * 1.08f, Quaternion.identity, immediate: true); Plugin.Log.LogInfo((object)$"The Parasite assembled a 1.14x Indestructible Drone fighter with {_body.Cannons.Count} inert C.A.R.T. CANNON wing(s) and {_health} HP."); return true; } internal bool ActivateNavigation(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; return ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform, 6f); } private void Update() { if (!_initialized || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (_dead) { UpdateDeath(); return; } _scanTimer -= Time.deltaTime; _destinationTimer -= Time.deltaTime; _roamTimer -= Time.deltaTime; _dotTimer -= Time.deltaTime; _soundTimer -= Time.deltaTime; _damageCooldown = Mathf.Max(0f, _damageCooldown - Time.deltaTime); _flinchTimer = Mathf.Max(0f, _flinchTimer - Time.deltaTime); _playerDetachBlockTimer = Mathf.Max(0f, _playerDetachBlockTimer - Time.deltaTime); _forcedRetreatTimer = Mathf.Max(0f, _forcedRetreatTimer - Time.deltaTime); _wallEscapeCooldown = Mathf.Max(0f, _wallEscapeCooldown - Time.deltaTime); UpdateObstacleLift(); if (_target != null && !TargetValid(_target)) { Disconnect(); } if (_scanTimer <= 0f) { _scanTimer = ((_target == null) ? 0.22f : 0.42f); Target target = FindBestTarget(); if (target != null && (_target == null || TargetPriority(target.Kind) > TargetPriority(_target.Kind))) { SetTarget(target); } } if (_target == null) { UpdateRoam(); } else if (_beamActive) { UpdateAttached(); } else { UpdateApproach(); } if (_soundTimer <= 0f) { _soundTimer = (_beamActive ? Random.Range(0.45f, 0.72f) : Random.Range(0.75f, 1.15f)); EmitDroneImpact(52f); } } private void UpdateRoam() { //IL_0031: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_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_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: 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_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) if (_forcedRetreatTimer > 0f) { if (_destinationTimer <= 0f) { _destinationTimer = 0.28f; Vector3 val = ((Component)this).transform.position - _forcedRetreatOrigin; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.04f) { val = -((Component)this).transform.forward; } ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, ((Component)this).transform.position + ((Vector3)(ref val)).normalized * 7f, 4f); } } else if (_flinchTimer > 0f) { StopAgent(); } else { Vector3 val2 = (((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) ? _agent.velocity : Vector3.zero); val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude > 0.018f) { _roamStuckTimer = 0f; _roamFacingDirection = ((Vector3)(ref val2)).normalized; } else { _roamStuckTimer += Time.deltaTime; } bool flag = (Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh && !_agent.pathPending && (!_agent.hasPath || _agent.remainingDistance <= 0.42f); bool flag2 = _roamStuckTimer >= 1.15f && (Object)(object)_agent != (Object)null && _agent.hasPath; if (_destinationTimer <= 0f && (_roamTimer <= 0f || flag || flag2)) { _destinationTimer = 0.24f; _roamTimer = Random.Range(1.15f, 2.05f); Vector3 preferredAway = Vector3.zero; if (flag2 && _wallEscapeCooldown <= 0f && TryGetWallAhead(out var normal)) { preferredAway = normal; _wallEscapeCooldown = 0.8f; } ChooseRoamDestination(preferredAway); } } Vector3 val3 = (((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) ? _agent.velocity : Vector3.zero); val3.y = 0f; Quaternion rotation = ((((Vector3)(ref val3)).sqrMagnitude > 0.025f) ? Quaternion.LookRotation(((Vector3)(ref val3)).normalized, Vector3.up) : Quaternion.LookRotation(_roamFacingDirection, Vector3.up)); PinBody(((Component)this).transform.position + HoverOffset(Vector3.up * (Mathf.Sin(Time.time * 2.1f) * 0.055f)), rotation, immediate: false); } private bool ChooseRoamDestination(Vector3 preferredAway) { //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_agent == (Object)null || !((Behaviour)_agent).enabled || !_agent.isOnNavMesh) { return false; } preferredAway.y = 0f; if (((Vector3)(ref preferredAway)).sqrMagnitude > 0.01f) { ((Vector3)(ref preferredAway)).Normalize(); } List list = LevelGenerator.Instance?.LevelPathPoints; if (list != null && list.Count > 0) { int num = Random.Range(0, list.Count); int num2 = Mathf.Min(list.Count, 28); for (int i = 0; i < num2; i++) { LevelPoint val = list[(num + i) % list.Count]; if (!((Object)(object)val == (Object)null)) { Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; val2.y = 0f; if (!(((Vector3)(ref val2)).sqrMagnitude < 10.240001f) && (!(((Vector3)(ref preferredAway)).sqrMagnitude > 0.01f) || !(Vector3.Dot(((Vector3)(ref val2)).normalized, preferredAway) < 0.12f)) && TrySetCompleteRoamPath(((Component)val).transform.position)) { return true; } } } } Vector3 normalized2 = default(Vector3); for (int j = 0; j < 14; j++) { Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 normalized = ((Vector2)(ref insideUnitCircle)).normalized; ((Vector3)(ref normalized2))..ctor(normalized.x, 0f, normalized.y); if (((Vector3)(ref preferredAway)).sqrMagnitude > 0.01f) { Vector3 val3 = normalized2 * 0.45f + preferredAway; normalized2 = ((Vector3)(ref val3)).normalized; } if (TrySetCompleteRoamPath(((Component)this).transform.position + normalized2 * Random.Range(5f, 10f))) { return true; } } _roamFacingDirection = ((((Vector3)(ref preferredAway)).sqrMagnitude > 0.01f) ? preferredAway : (-((Component)this).transform.forward)); return false; } private bool TrySetCompleteRoamPath(Vector3 requested) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_001e: 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_0034: 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_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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) NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requested, ref val, 3.5f, -1)) { return false; } NavMeshPath val2 = new NavMeshPath(); if (NavMesh.CalculatePath(((Component)this).transform.position, ((NavMeshHit)(ref val)).position, -1, val2) && (int)val2.status == 0 && val2.corners != null && val2.corners.Length >= 2) { Vector3 val3 = val2.corners[val2.corners.Length - 1] - ((Component)this).transform.position; if (!(((Vector3)(ref val3)).sqrMagnitude < 10.240001f)) { _agent.isStopped = false; if (!_agent.SetPath(val2)) { return false; } Vector3 val4 = val2.corners[1] - ((Component)this).transform.position; val4.y = 0f; if (((Vector3)(ref val4)).sqrMagnitude > 0.01f) { _roamFacingDirection = ((Vector3)(ref val4)).normalized; } _roamStuckTimer = 0f; return true; } } return false; } private bool TryGetWallAhead(out Vector3 normal) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) normal = Vector3.zero; Vector3 val = ((Component)this).transform.forward; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = _bodyRotation * Vector3.forward; val.y = 0f; } if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return false; } foreach (RaycastHit item in from item in Physics.SphereCastAll(((Component)this).transform.position + Vector3.up * 0.72f, 0.18f, ((Vector3)(ref val)).normalized, 1.05f, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1) orderby ((RaycastHit)(ref item)).distance select item) { RaycastHit current = item; if (!((Object)(object)((RaycastHit)(ref current)).collider == (Object)null) && !IsOwnCollider(((RaycastHit)(ref current)).collider)) { Vector3 normal2 = ((RaycastHit)(ref current)).normal; normal2.y = 0f; if (!(((Vector3)(ref normal2)).sqrMagnitude < 0.16f)) { normal = ((Vector3)(ref normal2)).normalized; return Vector3.Dot(normal, ((Vector3)(ref val)).normalized) < -0.18f; } } } return false; } private void UpdateApproach() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_0119: Unknown result type (might be due to invalid IL or missing references) Vector3 position = _target.Position; Vector3 horizontal = position - ((Component)this).transform.position; horizontal.y = 0f; if (_beamDeploying) { UpdateBeamDeployment(position, horizontal); return; } if (_flinchTimer > 0f) { StopAgent(); } else if (_destinationTimer <= 0f) { _destinationTimer = 0.2f; ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, position, 4f); } Vector3 val = ((((Vector3)(ref horizontal)).sqrMagnitude > 0.001f) ? ((Vector3)(ref horizontal)).normalized : ((Component)this).transform.forward); PinBody(((Component)this).transform.position + HoverOffset(Vector3.up * (Mathf.Sin(Time.time * 2.8f) * 0.045f)), Quaternion.LookRotation(val, Vector3.up), immediate: false); float num = ((_target.Kind == TargetKind.Player) ? 1.55f : 1.15f); if (((Vector3)(ref horizontal)).sqrMagnitude <= num * num && HasLineOfSight(_target.Position, _target.Phys, _target.Player)) { BeginBeamDeployment(); } } private void BeginBeamDeployment() { if (_target != null && !((Object)(object)_body?.Drone == (Object)null) && !((Object)(object)_body.Toggle == (Object)null) && !_beamDeploying && !_beamActive) { _body.Toggle.ToggleItem(true, -1); _beamDeploying = true; _beamDeployTimer = 0.24f; StopAgent(); } } private void UpdateBeamDeployment(Vector3 targetPosition, Vector3 horizontal) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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) //IL_0080: Unknown result type (might be due to invalid IL or missing references) StopAgent(); Vector3 val = ((((Vector3)(ref horizontal)).sqrMagnitude > 0.001f) ? ((Vector3)(ref horizontal)).normalized : ((Component)this).transform.forward); PinBody(((Component)this).transform.position + HoverOffset(Vector3.up * (Mathf.Sin(Time.time * 2.8f) * 0.045f)), Quaternion.LookRotation(val, Vector3.up), immediate: false); if (((Vector3)(ref horizontal)).sqrMagnitude > 5.0625f || !HasLineOfSight(targetPosition, _target?.Phys, _target?.Player)) { Target target = _target; if (target != null && target.Kind == TargetKind.Player) { ReleaseBeamKeepTarget(); } else { Disconnect(); } return; } _beamDeployTimer -= Time.deltaTime; if (!(_beamDeployTimer > 0f)) { if (!_body.Toggle.toggleState) { _body.Toggle.ToggleItem(true, -1); _beamDeployTimer = 0.12f; } else { AttachBeam(); } } } private void UpdateAttached() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_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_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: 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_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029a: 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_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: 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_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_005f: 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_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: 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_020a: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) _attachedSeconds += Time.deltaTime; if (_target.Kind == TargetKind.Player) { Vector3 position = _target.Position; Vector3 val = (((Object)(object)_body?.Phys != (Object)null) ? _body.Phys.centerPoint : (((Component)this).transform.position + Vector3.up * 0.9f)); Vector3 val2 = position - val; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; bool flag = HasLineOfSight(position, _target.Phys, _target.Player); _playerOcclusionTimer = (flag ? 0f : (_playerOcclusionTimer + Time.deltaTime)); if (sqrMagnitude > 49f || _playerOcclusionTimer >= 0.38f) { int id = _target.Id; bool flag2 = sqrMagnitude > 49f; ReleaseBeamKeepTarget(); _destinationTimer = 0f; Plugin.Log.LogInfo((object)string.Format("The Parasite released player target {0} because the tether was {1}.", id, flag2 ? "stretched" : "occluded")); return; } } if (_target.Kind == TargetKind.Player && _attachedSeconds >= 45f) { _blockedPlayerId = _target.Id; _playerDetachBlockTimer = 6f; _forcedRetreatTimer = 4.5f; _forcedRetreatOrigin = _target.Position; Disconnect(); _destinationTimer = 0f; Plugin.Log.LogInfo((object)"The Parasite released a player after 45 seconds and opened a six-second solo counterattack window."); return; } Vector3 position2 = _target.Position; Vector3 requested = AttachedDronePosition(position2); if (!FollowAttachedPosition(requested)) { if (_target.Kind == TargetKind.Player) { _attachmentPathFailTimer = 0f; if (_destinationTimer <= 0f) { _destinationTimer = 0.22f; ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, position2, 2.1f); } } else { _attachmentPathFailTimer += Time.deltaTime; if (_attachmentPathFailTimer >= 0.65f) { Plugin.Log.LogDebug((object)"The Parasite dropped a beam whose non-player target moved behind an unreachable wall."); Disconnect(); _destinationTimer = 0f; return; } } } else { _attachmentPathFailTimer = 0f; } Vector3 val3 = ((Component)this).transform.position + HoverOffset(Vector3.up * (Mathf.Sin(Time.time * 3.2f) * 0.035f)); Vector3 val4 = position2 - val3; val4.y *= 0.45f; Quaternion rotation = ((((Vector3)(ref val4)).sqrMagnitude > 0.001f) ? Quaternion.LookRotation(((Vector3)(ref val4)).normalized, Vector3.up) : ((Component)_body.Phys).transform.rotation); PinBody(val3, rotation, immediate: false); switch (_target.Kind) { case TargetKind.Player: if (IsLocalPlayer(_target.Player)) { ParasiteEffectRegistry.ProtectPlayer(_target.Player, 0.35f); } else { AmplifyRemotePlayerDamage(_target.Player); } if (_dotTimer <= 0f) { _dotTimer = 1f; if ((Object)(object)_target.Player != (Object)null && !IsLocalPlayer(_target.Player)) { _ignoredReplicatedLoss++; } ParasiteEffectRegistry.ApplyDot(_target.Player); } break; case TargetKind.VanillaEnemy: { EnemyHealth enemyHealth = _target.EnemyHealth; if (enemyHealth != null) { enemyHealth.OverrideDamageResistance(0.5f, 0.35f); } break; } case TargetKind.CustomEnemy: ParasiteEffectRegistry.ProtectCustomEnemy(_target.CustomOwner, _target.Renderers, 0.35f); break; case TargetKind.Valuable: if (_attachedSeconds >= Mathf.Max(1f, Plugin.Settings.ParasiteValuableDrainSeconds.Value)) { CorruptValuable(_target); Disconnect(); } break; } } private bool FollowAttachedPosition(Vector3 requested) { //IL_0029: 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: Expected O, but got Unknown //IL_0041: 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_0057: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_agent == (Object)null || !((Behaviour)_agent).enabled || !_agent.isOnNavMesh || !TryResolveAttachedPoint(requested, out var sampled)) { return false; } NavMeshPath val = new NavMeshPath(); if (!NavMesh.CalculatePath(((Component)this).transform.position, ((NavMeshHit)(ref sampled)).position, -1, val) || (int)val.status != 0) { return false; } Vector3 val2 = ((NavMeshHit)(ref sampled)).position - ((Component)this).transform.position; val2.y = 0f; _agent.speed = Mathf.Max(3.35f, Plugin.Settings.ParasiteMoveSpeed.Value * 1.35f); _agent.stoppingDistance = 0.24f; if (((Vector3)(ref val2)).sqrMagnitude <= 0.0784f) { StopAgent(); return true; } _agent.isStopped = false; return _agent.SetPath(val); } private bool TryResolveAttachedPoint(Vector3 requested, out NavMeshHit sampled) { //IL_0008: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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) requested.y = ((Component)this).transform.position.y; if (NavMesh.SamplePosition(requested, ref sampled, 0.72f, -1) && AttachedPointVisibleToTarget(((NavMeshHit)(ref sampled)).position)) { return true; } Vector3 val = _target?.Position ?? requested; val.y = ((Component)this).transform.position.y; for (int i = 0; i < 8; i++) { float num = (float)i * MathF.PI * 0.25f; if (NavMesh.SamplePosition(val + new Vector3(Mathf.Cos(num) * 0.78f, 0f, Mathf.Sin(num) * 0.78f), ref sampled, 0.38f, -1) && AttachedPointVisibleToTarget(((NavMeshHit)(ref sampled)).position)) { return true; } } sampled = default(NavMeshHit); return false; } private bool AttachedPointVisibleToTarget(Vector3 point) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_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_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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_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) if (_target == null) { return false; } Vector3 val = point + Vector3.up * 0.78f; Vector3 val2 = _target.Position - val; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude <= 0.08f) { return true; } RaycastHit[] array = Physics.RaycastAll(val, ((Vector3)(ref val2)).normalized, magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val3 = array[i]; if (!IsOwnCollider(((RaycastHit)(ref val3)).collider)) { PhysGrabObject componentInParent = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent(); if ((Object)(object)_target.Phys != (Object)null && (Object)(object)componentInParent == (Object)(object)_target.Phys) { return true; } if ((Object)(object)_target.Player != (Object)null && (Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() == (Object)(object)_target.Player) { return true; } return false; } } return true; } private Vector3 AttachedDronePosition(Vector3 targetPosition) { //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_0022: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_017d: 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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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 = Vector3.back; if (_target.Kind == TargetKind.VanillaEnemy || _target.Kind == TargetKind.CustomEnemy) { PlayerAvatar val2 = ClosestLivingPlayer(targetPosition); if ((Object)(object)val2 != (Object)null) { val = targetPosition - ((Component)val2).transform.position; val.y = 0f; } } else if (_target.Kind == TargetKind.Player && (Object)(object)_target.Player != (Object)null) { Transform val3 = _target.Player.PlayerVisionTarget?.VisionTransform; Vector3 val4 = (((Object)(object)val3 != (Object)null) ? val3.forward : ((Component)_target.Player).transform.forward); Vector3 val5 = (((Object)(object)val3 != (Object)null) ? val3.right : ((Component)_target.Player).transform.right); val4.y = 0f; val5.y = 0f; val = ((Vector3)(ref val4)).normalized * 0.82f + ((Vector3)(ref val5)).normalized * 0.36f; val.y = 0f; } else if ((Object)(object)_target.Anchor != (Object)null) { val = -_target.Anchor.forward; val.y = 0f; } if (((Vector3)(ref val)).sqrMagnitude < 0.001f) { val = Vector3.back; } float num = ((_target.Kind == TargetKind.Valuable) ? 0.48f : 0.2f); return targetPosition + ((Vector3)(ref val)).normalized * 0.72f + Vector3.up * num + Vector3.up * (Mathf.Sin(Time.time * 3.2f) * 0.035f); } private void SetTarget(Target target) { if (_target == null || _target.Id != target.Id || _target.Kind != target.Kind) { Disconnect(); _target = target; _destinationTimer = 0f; _observedPlayerHealth = ((target.Kind == TargetKind.Player) ? ReadPlayerHealth(target.Player) : (-1)); _ignoredReplicatedLoss = 0; } } private void AttachBeam() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) if (_target == null || (Object)(object)_body?.Drone == (Object)null) { return; } if (NewRayHitPointMethod == null) { Plugin.Log.LogWarning((object)"The Parasite could not find ItemDrone.NewRayHitPoint; native beam deployment was cancelled."); _body.Drone.DeactivateDrone(); return; } try { Vector3 position = _target.Position; int viewID; int num; Transform val; if (_target.Kind == TargetKind.Player && (Object)(object)_target.Player != (Object)null) { viewID = _target.Player.photonView.ViewID; num = -1; val = _target.Player.PlayerVisionTarget.VisionTransform; } else { PhysGrabObject phys = _target.Phys; object obj = ((phys != null) ? ((Component)phys).GetComponentInParent() : null); if (obj == null) { PhysGrabObject phys2 = _target.Phys; obj = ((phys2 != null) ? ((Component)phys2).GetComponent() : null); } PhotonView val2 = (PhotonView)obj; PhysGrabObject phys3 = _target.Phys; PhysGrabObjectCollider val3 = ((phys3 != null) ? ((Component)phys3).GetComponentInChildren(true) : null); if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null) { Plugin.Log.LogDebug((object)"The Parasite target had no vanilla beam collider; connection was deferred."); _body.Drone.DeactivateDrone(); return; } viewID = val2.ViewID; num = val3.colliderID; val = ((Component)_target.Phys).transform; position = ((Component)val3).transform.position; } NewRayHitPointMethod.Invoke(_body.Drone, new object[4] { position, viewID, num, val }); if (_target.Kind == TargetKind.Player && (Object)(object)_target.Player != (Object)null) { PlayerAvatarTargetField?.SetValue(_body.Drone, _target.Player); TargetIsPlayerField?.SetValue(_body.Drone, true); TargetIsLocalPlayerField?.SetValue(_body.Drone, (Object)(object)_target.Player.photonView != (Object)null && _target.Player.photonView.IsMine); } _body.Drone.MagnetActiveToggle(true); _body.Drone.StateSet((State)3); _beamDeploying = false; _beamActive = true; _attachedSeconds = 0f; _playerOcclusionTimer = 0f; _dotTimer = 1f; Plugin.Log.LogInfo((object)$"The Parasite connected its vanilla drone beam to {_target.Kind} target {_target.Id}."); } catch (Exception ex) { Plugin.Log.LogWarning((object)("The Parasite could not deploy its vanilla beam: " + ex.Message)); _body.Drone.DeactivateDrone(); _beamDeploying = false; _beamActive = false; } } private void Disconnect() { if ((_beamActive || _beamDeploying) && (Object)(object)_body?.Drone != (Object)null) { _body.Drone.DeactivateDrone(); } _beamActive = false; _beamDeploying = false; _beamDeployTimer = 0f; _attachedSeconds = 0f; _attachmentPathFailTimer = 0f; _playerOcclusionTimer = 0f; _target = null; _observedPlayerHealth = -1; _ignoredReplicatedLoss = 0; if ((Object)(object)_agent != (Object)null) { _agent.speed = Mathf.Max(0.5f, Plugin.Settings.ParasiteMoveSpeed.Value); _agent.stoppingDistance = 0.72f; if (((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } } _roamTimer = 0f; _destinationTimer = 0f; } private void ReleaseBeamKeepTarget() { Target target = _target; int observedPlayerHealth = ((target != null && target.Kind == TargetKind.Player) ? ReadPlayerHealth(target.Player) : (-1)); Disconnect(); if (target != null && TargetValid(target)) { _target = target; _observedPlayerHealth = observedPlayerHealth; _destinationTimer = 0f; _roamTimer = 0f; } } private Target FindBestTarget() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_01de: 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) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: 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) float num = Mathf.Clamp(Plugin.Settings.ParasiteSearchRange.Value, 4f, 35f); float num2 = num * num; Target target = FindBestEnemy(num2); if (target != null) { return target; } Target target2 = null; float num3 = float.MaxValue; Vector3 val; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item) && (!(_playerDetachBlockTimer > 0f) || ((Object)item).GetInstanceID() != _blockedPlayerId)) { val = ((Component)item).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; bool flag = HasLineOfSight(((Component)item).transform.position + Vector3.up * 0.8f, null, item); bool flag2 = sqrMagnitude <= 39.0625f && HasCompletePathTo(((Component)item).transform.position); if (sqrMagnitude < num3 && sqrMagnitude <= num2 && (flag || flag2)) { num3 = sqrMagnitude; target2 = new Target { Kind = TargetKind.Player, Player = item, Anchor = ((Component)item).transform, Id = ((Object)item).GetInstanceID() }; } } } if (target2 != null) { return target2; } Target result = null; float num4 = float.MaxValue; ValuableObject[] array = Object.FindObjectsOfType(); foreach (ValuableObject val2 in array) { if ((Object)(object)val2 == (Object)null || !((Component)val2).gameObject.activeInHierarchy || MapIconSuppressor.OwnsValuable(val2) || _completedValuables.Contains(((Object)val2).GetInstanceID())) { continue; } PhysGrabObject val3 = ((Component)val2).GetComponent() ?? ((Component)val2).GetComponentInParent(); if (!((Object)(object)val3 == (Object)null) && !val3.dead) { val = val3.centerPoint - ((Component)this).transform.position; float sqrMagnitude2 = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude2 < num4 && sqrMagnitude2 <= num2 && HasLineOfSight(val3.centerPoint, val3)) { num4 = sqrMagnitude2; result = new Target { Kind = TargetKind.Valuable, Valuable = val2, Phys = val3, Anchor = ((Component)val3).transform, Id = ((Object)val2).GetInstanceID() }; } } } return result; } private bool HasCompletePathTo(Vector3 requested) { //IL_0028: 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: Expected O, but got Unknown //IL_0046: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Invalid comparison between Unknown and I4 NavMeshHit val = default(NavMeshHit); if ((Object)(object)_agent == (Object)null || !((Behaviour)_agent).enabled || !_agent.isOnNavMesh || !NavMesh.SamplePosition(requested, ref val, 2.2f, -1)) { return false; } NavMeshPath val2 = new NavMeshPath(); if (NavMesh.CalculatePath(((Component)this).transform.position, ((NavMeshHit)(ref val)).position, -1, val2)) { return (int)val2.status == 0; } return false; } private Target FindBestEnemy(float rangeSquared) { //IL_0233: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_0268: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) Target result = null; float num = float.MaxValue; EnemyHealth[] array = Object.FindObjectsOfType(); Vector3 val5; foreach (EnemyHealth val in array) { EnemyParent val2 = ((val != null) ? ((Component)val).GetComponentInParent() : null); if (!((Object)(object)val == (Object)null) && !IsVanillaEnemyDead(val) && !((Object)(object)val2 == (Object)null) && IsVanillaEnemySpawned(val2)) { EnemyRigidbody componentInChildren = ((Component)val2).GetComponentInChildren(true); PhysGrabObject val3 = (((Object)(object)componentInChildren != (Object)null) ? (((Component)componentInChildren).GetComponent() ?? ((Component)componentInChildren).GetComponentInChildren(true)) : ((Component)val2).GetComponentInChildren(true)); Vector3 val4 = (((Object)(object)val3 != (Object)null) ? val3.centerPoint : ((Component)val).transform.position); val5 = val4 - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude; if (sqrMagnitude < num && sqrMagnitude <= rangeSquared && HasLineOfSight(val4, val3)) { num = sqrMagnitude; result = new Target { Kind = TargetKind.VanillaEnemy, EnemyHealth = val, Phys = val3, Anchor = ((Component)val).transform, Renderers = ((Component)val).GetComponentsInChildren(true), Id = ((Object)val).GetInstanceID() }; } } } Dictionary> dictionary = new Dictionary>(); TumbleHitProxy[] array2 = Object.FindObjectsOfType(); foreach (TumbleHitProxy tumbleHitProxy in array2) { IModEnemyTumbleReceiver modEnemyTumbleReceiver = tumbleHitProxy?.Receiver; Object val6 = (Object)((modEnemyTumbleReceiver is Object) ? modEnemyTumbleReceiver : null); if (modEnemyTumbleReceiver != null && !(val6 == (Object)null) && modEnemyTumbleReceiver != this) { int instanceID = val6.GetInstanceID(); if (!dictionary.TryGetValue(instanceID, out var value)) { value = new List(); dictionary.Add(instanceID, value); } value.Add(tumbleHitProxy); } } foreach (KeyValuePair> item in dictionary) { TumbleHitProxy tumbleHitProxy2 = item.Value.FirstOrDefault((TumbleHitProxy item) => (Object)(object)item != (Object)null && ((Component)item).gameObject.activeInHierarchy); if ((Object)(object)tumbleHitProxy2 == (Object)null) { continue; } PhysGrabObject componentInParent = ((Component)tumbleHitProxy2).GetComponentInParent(); Vector3 val7 = (((Object)(object)componentInParent != (Object)null) ? componentInParent.centerPoint : ((Component)tumbleHitProxy2).transform.position); val5 = val7 - ((Component)this).transform.position; float sqrMagnitude2 = ((Vector3)(ref val5)).sqrMagnitude; if (!(sqrMagnitude2 >= num) && !(sqrMagnitude2 > rangeSquared) && HasLineOfSight(val7, componentInParent)) { num = sqrMagnitude2; result = new Target { Kind = TargetKind.CustomEnemy, CustomOwner = (Object)/*isinst with value type is only supported in some contexts*/, Phys = componentInParent, Anchor = ((Component)tumbleHitProxy2).transform, Renderers = item.Value.Where((TumbleHitProxy item) => (Object)(object)item != (Object)null).SelectMany((TumbleHitProxy item) => ((Component)item).GetComponentsInChildren(true)).Distinct() .ToArray(), Id = item.Key }; } } return result; } private bool TargetValid(Target target) { if (target == null) { return false; } if (target.Kind == TargetKind.Player) { return GunAccess.IsLiving(target.Player); } if (target.Kind == TargetKind.VanillaEnemy) { if ((Object)(object)target.EnemyHealth != (Object)null && !IsVanillaEnemyDead(target.EnemyHealth)) { return ((Component)target.EnemyHealth).gameObject.activeInHierarchy; } return false; } if (target.Kind == TargetKind.CustomEnemy) { if (target.CustomOwner != (Object)null && (Object)(object)target.Anchor != (Object)null) { return ((Component)target.Anchor).gameObject.activeInHierarchy; } return false; } if (target.Kind == TargetKind.Valuable) { if ((Object)(object)target.Valuable != (Object)null && (Object)(object)target.Phys != (Object)null && !target.Phys.dead) { return ((Component)target.Phys).gameObject.activeInHierarchy; } return false; } return false; } private static int TargetPriority(TargetKind kind) { switch (kind) { case TargetKind.VanillaEnemy: case TargetKind.CustomEnemy: return 3; case TargetKind.Player: return 2; case TargetKind.Valuable: return 1; default: return 0; } } private bool HasLineOfSight(Vector3 point, PhysGrabObject expected, PlayerAvatar expectedPlayer = null) { //IL_003c: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //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_005c: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)_body?.Phys != (Object)null) ? _body.Phys.centerPoint : (((Component)this).transform.position + Vector3.up)); Vector3 val2 = point - val; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude <= 0.05f) { return true; } foreach (RaycastHit item in from item in Physics.RaycastAll(val, ((Vector3)(ref val2)).normalized, magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1) orderby ((RaycastHit)(ref item)).distance select item) { RaycastHit current = item; if (IsOwnCollider(((RaycastHit)(ref current)).collider)) { continue; } PhysGrabObject componentInParent = ((Component)((RaycastHit)(ref current)).transform).GetComponentInParent(); if ((Object)(object)expected != (Object)null && (Object)(object)componentInParent == (Object)(object)expected) { return true; } if ((Object)(object)expectedPlayer != (Object)null) { PlayerAvatar val3 = ((Component)((RaycastHit)(ref current)).transform).GetComponentInParent(); if ((Object)(object)val3 == (Object)null) { val3 = ((Component)((RaycastHit)(ref current)).transform).GetComponentInParent()?.playerAvatarScript; } if ((Object)(object)val3 == (Object)null) { val3 = ((Component)((RaycastHit)(ref current)).transform).GetComponentInParent()?.playerAvatar; } if ((Object)(object)val3 == (Object)(object)expectedPlayer) { return true; } } return false; } return true; } private bool IsOwnCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } if ((Object)(object)_body?.Root != (Object)null && ((Component)collider).transform.IsChildOf(_body.Root.transform)) { return true; } if (_body?.Cannons == null) { return false; } foreach (SpawnedParasiteDecoration cannon in _body.Cannons) { if ((Object)(object)cannon?.Root != (Object)null && ((Component)collider).transform.IsChildOf(cannon.Root.transform)) { return true; } } return false; } private void CorruptValuable(Target target) { //IL_00c3: 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_0152: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)target?.Valuable == (Object)null) && !((Object)(object)target.Phys == (Object)null)) { _completedValuables.Add(target.Id); float num = ((DollarValueCurrentField?.GetValue(target.Valuable) is float num2) ? num2 : 0f); float num3 = Mathf.Max(0f, Mathf.Floor(num * 0.7f)); PhotonView componentInParent = ((Component)target.Phys).GetComponentInParent(); if (GameManager.Multiplayer() && (Object)(object)componentInParent != (Object)null) { componentInParent.RPC("DollarValueSetRPC", (RpcTarget)0, new object[1] { num3 }); } else { target.Valuable.DollarValueSetRPC(num3, default(PhotonMessageInfo)); } PhysGrabObjectImpactDetector component = ((Component)target.Phys).GetComponent(); if ((Object)(object)component != (Object)null) { component.fragility = Mathf.Clamp(component.fragility + 35f, 1f, 100f); component.durability = Mathf.Clamp(component.durability - 35f, 1f, 100f); component.fragilityMultiplier = Mathf.Max(1.65f, component.fragilityMultiplier); component.ImpactLight(70f, target.Phys.centerPoint); } Plugin.Log.LogInfo((object)$"The Parasite completed a 10-second valuable infection: ${num:F0} -> ${num3:F0}; this object cannot be selected again."); } } private static PlayerAvatar ClosestLivingPlayer(Vector3 position) { //IL_002b: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar result = null; float num = float.MaxValue; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { Vector3 val = ((Component)item).transform.position - position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = item; } } } return result; } private static bool IsVanillaEnemyDead(EnemyHealth health) { if (!((Object)(object)health == (Object)null)) { object obj = EnemyDeadField?.GetValue(health); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } return true; } private static bool IsVanillaEnemySpawned(EnemyParent parent) { if ((Object)(object)parent != (Object)null) { object obj = EnemySpawnedField?.GetValue(parent); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return num == 0 || flag; } return false; } private static int ReadPlayerHealth(PlayerAvatar player) { if ((Object)(object)player?.playerHealth == (Object)null) { return -1; } object obj = PlayerHealthValueField?.GetValue(player.playerHealth); if (obj is int) { return (int)obj; } return -1; } private static bool IsLocalPlayer(PlayerAvatar player) { if ((Object)(object)player != (Object)null) { if (!((Object)(object)player == (Object)(object)PlayerAvatar.instance)) { if ((Object)(object)player.photonView != (Object)null) { return player.photonView.IsMine; } return false; } return true; } return false; } private void AmplifyRemotePlayerDamage(PlayerAvatar player) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) int num = ReadPlayerHealth(player); if (num < 0) { return; } if (_observedPlayerHealth < 0) { _observedPlayerHealth = num; return; } if (num > _observedPlayerHealth) { _observedPlayerHealth = num; _ignoredReplicatedLoss = 0; return; } int num2 = _observedPlayerHealth - num; _observedPlayerHealth = num; if (num2 > 0) { int num3 = Mathf.Min(num2, _ignoredReplicatedLoss); _ignoredReplicatedLoss -= num3; int num4 = num2 - num3; if (num4 > 0 && GunAccess.IsLiving(player)) { int num5 = Mathf.Max(1, Mathf.CeilToInt((float)num4 * 0.5f)); _ignoredReplicatedLoss += num5; player.playerHealth.HurtOther(num5, ((Component)player).transform.position, false, -1, false); } } } private void PinBody(Vector3 position, Quaternion rotation, bool immediate) { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_011b: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_016f: 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_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_body?.Phys == (Object)null)) { _body.ImpactDetector.destroyDisable = true; _body.Phys.OverrideGrabDisable(0.3f); _body.Phys.OverrideKinematic(0.3f); _body.Phys.OverrideIndestructible(0.3f); if ((Object)(object)_body.Phys.rb != (Object)null && !_body.Phys.rb.isKinematic) { _body.Phys.rb.velocity = Vector3.zero; _body.Phys.rb.angularVelocity = Vector3.zero; } Vector3 position2 = ((Component)_body.Phys).transform.position; Vector3 val = (immediate ? position : Vector3.MoveTowards(position2, position, Mathf.Max(3.2f, Plugin.Settings.ParasiteMoveSpeed.Value * 1.7f) * Time.deltaTime)); if (!immediate) { val = ConstrainVisualMovement(position2, val); } if (immediate) { _bodyRotation = rotation; } else { float num = (_beamActive ? 92f : 118f); _bodyRotation = Quaternion.RotateTowards(_bodyRotation, rotation, num * Time.deltaTime); } Quaternion bodyRotation = _bodyRotation; _body.Phys.SetPositionLogic(val, bodyRotation); PinCannons(val, bodyRotation, immediate); } } private Vector3 HoverOffset(Vector3 bob) { //IL_0000: 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_0017: Unknown result type (might be due to invalid IL or missing references) return Vector3.up * (1.08f + _obstacleLift) + bob; } private void UpdateObstacleLift() { //IL_0043: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_0089: 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_0093: 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_010c: 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) if ((Object)(object)_body?.Phys == (Object)null) { return; } Vector3 val = (((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) ? _agent.velocity : Vector3.zero); val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.035f && _target != null) { val = _target.Position - ((Component)this).transform.position; val.y = 0f; } if (((Vector3)(ref val)).sqrMagnitude > 0.035f) { foreach (RaycastHit item in from candidate in Physics.SphereCastAll(_body.Phys.centerPoint, 0.23f, ((Vector3)(ref val)).normalized, 0.78f, -5, (QueryTriggerInteraction)1) orderby ((RaycastHit)(ref candidate)).distance select candidate) { RaycastHit current = item; if (!((Object)(object)((RaycastHit)(ref current)).collider == (Object)null) && !IsOwnCollider(((RaycastHit)(ref current)).collider) && !((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent() != (Object)null)) { if (Mathf.Abs(((RaycastHit)(ref current)).normal.y) < 0.72f) { _obstacleLiftDemandTimer = 0.62f; } break; } } } _obstacleLiftDemandTimer = Mathf.Max(0f, _obstacleLiftDemandTimer - Time.deltaTime); float num = ((_obstacleLiftDemandTimer > 0f) ? 0.62f : 0f); _obstacleLift = Mathf.MoveTowards(_obstacleLift, num, ((num > _obstacleLift) ? 1.45f : 0.68f) * Time.deltaTime); } private Vector3 ConstrainVisualMovement(Vector3 start, Vector3 requested) { //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) //IL_0002: 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_001a: 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_0028: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) Vector3 val = requested - start; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.001f) { return requested; } foreach (RaycastHit item in from candidate in Physics.SphereCastAll(start, 0.19f, ((Vector3)(ref val)).normalized, magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1) orderby ((RaycastHit)(ref candidate)).distance select candidate) { RaycastHit current = item; if (!((Object)(object)((RaycastHit)(ref current)).collider == (Object)null) && !IsOwnCollider(((RaycastHit)(ref current)).collider)) { if (Mathf.Abs(((RaycastHit)(ref current)).normal.y) < 0.72f) { _obstacleLiftDemandTimer = 0.62f; } return start + ((Vector3)(ref val)).normalized * Mathf.Max(0f, ((RaycastHit)(ref current)).distance - 0.06f); } } return requested; } private void PinCannons(Vector3 bodyPosition, Quaternion bodyRotation, bool immediate) { //IL_007d: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00fd: 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_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0197: 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_0185: Unknown result type (might be due to invalid IL or missing references) if (_body?.Cannons == null) { return; } for (int i = 0; i < _body.Cannons.Count; i++) { SpawnedParasiteDecoration spawnedParasiteDecoration = _body.Cannons[i]; if (!((Object)(object)spawnedParasiteDecoration?.Phys == (Object)null) && spawnedParasiteDecoration.Alive) { if (spawnedParasiteDecoration.GeometryCalibrationFrames > 0) { ParasiteSpawner.RefreshDecorationGeometry(spawnedParasiteDecoration); spawnedParasiteDecoration.GeometryCalibrationFrames--; } float num = ((i == 0) ? (-1f) : 1f); Vector3 val = bodyPosition + bodyRotation * new Vector3(num * 0.225f, -0.015f, -0.075f); Quaternion val2 = bodyRotation * Quaternion.Euler(0f, (0f - num) * 10f, num * 90f) * Quaternion.Euler(90f, 0f, 0f) * Quaternion.Euler(0f, 180f, 0f); Vector3 val3 = val - val2 * spawnedParasiteDecoration.VisualCenterOffset; spawnedParasiteDecoration.ImpactDetector.destroyDisable = true; spawnedParasiteDecoration.Phys.OverrideGrabDisable(0.3f); spawnedParasiteDecoration.Phys.OverrideKinematic(0.3f); spawnedParasiteDecoration.Phys.OverrideIndestructible(0.3f); if ((Object)(object)spawnedParasiteDecoration.Phys.rb != (Object)null && !spawnedParasiteDecoration.Phys.rb.isKinematic) { spawnedParasiteDecoration.Phys.rb.velocity = Vector3.zero; spawnedParasiteDecoration.Phys.rb.angularVelocity = Vector3.zero; } spawnedParasiteDecoration.Phys.SetPositionLogic(val3, val2); } } } private void StopAgent() { if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } } private void EmitDroneImpact(float force) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_body?.ImpactDetector == (Object)null) && !((Object)(object)_body.Phys == (Object)null)) { _body.ImpactDetector.ImpactLight(force, _body.Phys.centerPoint); } } internal bool TryClaimWeaponHit(int sourceId) { if (_dead || !ModEnemyWeaponDamage.TryClaim((Object)(object)this, sourceId) || Time.time - _lastClaimedHit < 0.06f) { return false; } _lastClaimedHit = Time.time; return true; } internal void ReceiveWeaponHit(Vector3 point, int damage) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (!_dead && damage > 0) { _health -= Mathf.Max(1, damage); if (_damageCooldown <= 0f) { _damageCooldown = 0.08f; ModEnemyFeedback.DamageHit(_body?.ImpactDetector, _body?.Phys, point, 88f); } if (_health <= 0) { Die(); } } } public void ReceiveTumbleAttack(int partIndex, int damage, Vector3 hitPosition, Vector3 direction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ReceiveWeaponHit(hitPosition, Mathf.Max(1, damage)); if (!_dead) { _flinchTimer = 0.32f; StopAgent(); } } internal void ExecuteForLab() { if (!_dead) { _health = 0; Die(); } } private void Die() { if (_dead) { return; } _dead = true; Disconnect(); StopAgent(); if (_body != null && _body.Alive) { foreach (SpawnedParasiteDecoration item in _body.Cannons.ToList()) { ParasiteSpawner.Destroy(item); } _body.Cannons.Clear(); _body.Alive = false; _body.ImpactDetector.destroyDisable = false; _body.ImpactDetector.DestroyObject(true); } _rewardTimer = 0.08f; } private void UpdateDeath() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (_rewardDropped) { return; } _rewardTimer -= Time.deltaTime; if (_rewardTimer > 0f) { return; } _rewardDropped = true; if (Plugin.Settings.ParasiteDropEnemyValuable.Value && !((Object)(object)AssetManager.instance?.enemyValuableSmall == (Object)null)) { GameObject enemyValuableSmall = AssetManager.instance.enemyValuableSmall; if (GameManager.Multiplayer()) { PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)enemyValuableSmall).name, ((Component)this).transform.position + Vector3.up * 0.45f, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate(enemyValuableSmall, ((Component)this).transform.position + Vector3.up * 0.45f, Quaternion.identity); } } } private void OnDestroy() { if (_initialized && !_cleaning && SemiFunc.IsMasterClientOrSingleplayer()) { _cleaning = true; Disconnect(); if (_body != null && _body.Alive) { ParasiteSpawner.Destroy(_body); } } } } [HarmonyPatch(typeof(ItemDrone), "FixedUpdate")] internal static class ParasiteDronePhysicsPatch { private static bool Prefix(ItemDrone __instance) { if (!((Object)(object)__instance == (Object)null)) { return (Object)(object)((Component)__instance).GetComponentInParent(true) == (Object)null; } return true; } } [HarmonyPatch(typeof(ItemDrone), "FindTeleportSpot")] internal static class ParasiteDroneTeleportPatch { private static bool Prefix(ItemDrone __instance) { if (!((Object)(object)__instance == (Object)null)) { return (Object)(object)((Component)__instance).GetComponentInParent(true) == (Object)null; } return true; } } internal static class ParasiteEffectRegistry { private sealed class CustomProtection { internal Object Owner; internal Renderer[] Renderers; internal float Expires; } internal const int DotEnemyIndex = -741902; private static readonly Dictionary PlayerExpiry = new Dictionary(); private static readonly Dictionary CustomExpiry = new Dictionary(); [ThreadStatic] private static int _damageAmplificationSuppressed; internal static bool AmplificationSuppressed => _damageAmplificationSuppressed > 0; internal static void ProtectPlayer(PlayerAvatar player, float duration) { if ((Object)(object)player != (Object)null) { PlayerExpiry[((Object)player).GetInstanceID()] = Time.time + duration; } } internal static bool IsPlayerAmplified(PlayerAvatar player) { if ((Object)(object)player != (Object)null && PlayerExpiry.TryGetValue(((Object)player).GetInstanceID(), out var value)) { return value > Time.time; } return false; } internal static void ProtectCustomEnemy(Object owner, Renderer[] renderers, float duration) { if (!(owner == (Object)null)) { CustomExpiry[owner.GetInstanceID()] = new CustomProtection { Owner = owner, Renderers = (renderers ?? Array.Empty()), Expires = Time.time + duration }; } } internal static int ModifyEnemyDamageAt(Vector3 hitPosition, int damage) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (damage <= 0) { return damage; } float time = Time.time; foreach (CustomProtection value in CustomExpiry.Values) { if (value == null || value.Owner == (Object)null || value.Expires <= time) { continue; } Renderer[] renderers = value.Renderers; foreach (Renderer val in renderers) { if ((Object)(object)val != (Object)null && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; if (((Bounds)(ref bounds)).SqrDistance(hitPosition) <= 0.36f) { return Mathf.Max(1, Mathf.CeilToInt((float)damage * 0.5f)); } } } } return damage; } internal static void ApplyDot(PlayerAvatar player) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(player) || (Object)(object)player.playerHealth == (Object)null) { return; } if (GameManager.Multiplayer()) { player.playerHealth.HurtOther(1, ((Component)player).transform.position, false, -741902, false); return; } _damageAmplificationSuppressed++; try { player.playerHealth.Hurt(1, false, -741902, false); } finally { _damageAmplificationSuppressed--; } } internal static void PushSuppression() { _damageAmplificationSuppressed++; } internal static void PopSuppression() { _damageAmplificationSuppressed = Math.Max(0, _damageAmplificationSuppressed - 1); } } [HarmonyPatch(typeof(PlayerHealth), "Hurt")] internal static class ParasitePlayerDamagePatch { [HarmonyPrefix] private static void Prefix(PlayerHealth __instance, ref int damage) { if (damage > 0 && !ParasiteEffectRegistry.AmplificationSuppressed && ParasiteEffectRegistry.IsPlayerAmplified(((Component)__instance).GetComponent())) { damage = Mathf.Max(1, Mathf.CeilToInt((float)damage * 1.5f)); } } } [HarmonyPatch(typeof(PlayerHealth), "HurtOtherRPC")] internal static class ParasiteDotRpcPatch { [HarmonyPrefix] private static void Prefix(int enemyIndex, out bool __state) { __state = enemyIndex == -741902; if (__state) { ParasiteEffectRegistry.PushSuppression(); } } [HarmonyFinalizer] private static Exception Finalizer(Exception __exception, bool __state) { if (__state) { ParasiteEffectRegistry.PopSuppression(); } return __exception; } } internal sealed class ParasiteHitProxy : MonoBehaviour { private ParasiteController _controller; private SpawnedParasite _body; private float _cooldown; private readonly Dictionary _previous = new Dictionary(); private readonly HashSet _current = new HashSet(); private static int _bulletFrame = -1; private static ItemGunBullet[] _bullets = Array.Empty(); internal void Initialize(ParasiteController controller, SpawnedParasite body) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown _controller = controller; _body = body; SpawnedParasite body2 = _body; if (body2 == null) { return; } PhysGrabObjectImpactDetector impactDetector = body2.ImpactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.AddListener(new UnityAction(OnHurtColliderHit)); } } } private void Update() { _cooldown = Mathf.Max(0f, _cooldown - Time.deltaTime); if (_cooldown <= 0f && SemiFunc.IsMasterClientOrSingleplayer()) { DetectExpandedBulletHit(); } } private void OnDestroy() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown SpawnedParasite body = _body; if (body == null) { return; } PhysGrabObjectImpactDetector impactDetector = body.ImpactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.RemoveListener(new UnityAction(OnHurtColliderHit)); } } } private void OnHurtColliderHit() { //IL_0072: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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)_controller == (Object)null || _cooldown > 0f || !SemiFunc.IsMasterClientOrSingleplayer() || !_controller.TryClaimWeaponHit(ModEnemyWeaponDamage.CurrentClaimId)) { return; } _cooldown = 0.16f; Vector3 val = (((Object)(object)_body?.Phys != (Object)null) ? _body.Phys.centerPoint : ((Component)this).transform.position); if (EnemyLabBridge.IsExecutionHitNear(val)) { _controller.ExecuteForLab(); return; } int num = ModEnemyWeaponDamage.CurrentOrFallback(Plugin.Settings.ParasiteDamagePerHit.Value); if (num > 0) { _controller.ReceiveWeaponHit(val, num); } } private void DetectExpandedBulletHit() { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0156: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_controller == (Object)null || _body?.Renderers == null) { return; } if (_bulletFrame != Time.frameCount) { _bulletFrame = Time.frameCount; _bullets = Object.FindObjectsOfType(); } _current.Clear(); ItemGunBullet[] bullets = _bullets; foreach (ItemGunBullet val in bullets) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent() != (Object)null || (Object)(object)val.hurtCollider == (Object)null || !((Component)val.hurtCollider).gameObject.activeInHierarchy) { continue; } int instanceID = ((Object)val).GetInstanceID(); _current.Add(instanceID); Vector3 position = ((Component)val.hurtCollider).transform.position; Vector3 value; bool num = _previous.TryGetValue(instanceID, out value); _previous[instanceID] = position; if (!(num ? SegmentIntersects(value, position) : Within(position)) || !_controller.TryClaimWeaponHit(instanceID)) { continue; } _cooldown = 0.22f; if (EnemyLabBridge.IsExecutionHitNear(position)) { _controller.ExecuteForLab(); return; } int num2 = ModEnemyWeaponDamage.Resolve(val.hurtCollider, Plugin.Settings.ParasiteDamagePerHit.Value); if (num2 > 0) { _controller.ReceiveWeaponHit(position, num2); } return; } if (_previous.Count <= _current.Count) { return; } List list = null; foreach (int key in _previous.Keys) { if (!_current.Contains(key)) { if (list == null) { list = new List(); } list.Add(key); } } foreach (int item in list ?? new List()) { _previous.Remove(item); } } private bool Within(Vector3 point) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Settings.ParasiteHitDetectionPadding.Value, 0.12f, 0.75f); float num2 = num * num; Renderer[] renderers = _body.Renderers; foreach (Renderer val in renderers) { if ((Object)(object)val != (Object)null && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; if (((Bounds)(ref bounds)).SqrDistance(point) <= num2) { return true; } } } return false; } private bool SegmentIntersects(Vector3 start, Vector3 end) { //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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Settings.ParasiteHitDetectionPadding.Value, 0.12f, 0.75f); Renderer[] renderers = _body.Renderers; foreach (Renderer val in renderers) { if (!((Object)(object)val == (Object)null) && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds = val.bounds; ((Bounds)(ref bounds)).Expand(num * 2f); if (SegmentBounds(start, end, bounds)) { return true; } } } return false; } private static bool SegmentBounds(Vector3 start, Vector3 end, Bounds bounds) { //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) //IL_0002: 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_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float num = 0f; float num2 = 1f; for (int i = 0; i < 3; i++) { float num3 = ((Vector3)(ref start))[i]; float num4 = ((Vector3)(ref val))[i]; Vector3 val2; if (Mathf.Abs(num4) < 1E-05f) { val2 = ((Bounds)(ref bounds)).min; if (!(num3 < ((Vector3)(ref val2))[i])) { val2 = ((Bounds)(ref bounds)).max; if (!(num3 > ((Vector3)(ref val2))[i])) { continue; } } return false; } float num5 = 1f / num4; val2 = ((Bounds)(ref bounds)).min; float num6 = (((Vector3)(ref val2))[i] - num3) * num5; val2 = ((Bounds)(ref bounds)).max; float num7 = (((Vector3)(ref val2))[i] - num3) * num5; if (num6 > num7) { float num8 = num7; num7 = num6; num6 = num8; } num = Mathf.Max(num, num6); num2 = Mathf.Min(num2, num7); if (num > num2) { return false; } } return true; } } internal sealed class ParasiteManager : MonoBehaviour { private int _levelId; private float _spawnTimer; private bool _attemptFinished; private bool _probed; private bool _available; private ParasiteController _encounter; internal void Tick() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (!IsHostReady()) { return; } Probe(); int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } if (!ModEnemyLevelRules.IsPlayableLevel()) { DestroyCurrent(); return; } LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null || !instance.Generated || _attemptFinished) { return; } _spawnTimer -= Time.deltaTime; if (!(_spawnTimer > 0f)) { _attemptFinished = true; if (Random.value <= Mathf.Clamp01(Plugin.Settings.ParasiteSpawnChance.Value) && TryFindSpawn(out var position)) { Create(position, "automatic"); } } } private void ResetForLevel(int levelId) { DestroyCurrent(); _levelId = levelId; _spawnTimer = Mathf.Max(0f, Plugin.Settings.ParasiteSpawnDelay.Value); _attemptFinished = false; } private bool Create(Vector3 position, string source) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0085: Unknown result type (might be due to invalid IL or missing references) if (!_available && !ParasiteSpawner.PrefabAvailable()) { Plugin.Log.LogWarning((object)"The Parasite could not resolve its Indestructible Drone or C.A.R.T. CANNON resources."); return false; } DestroyCurrent(); GameObject val = new GameObject("The Parasite Encounter (Host Logic)"); val.SetActive(false); val.transform.position = position; ParasiteController parasiteController = val.AddComponent(); if (!parasiteController.Initialize(position)) { Object.Destroy((Object)(object)val); return false; } val.SetActive(true); if (!parasiteController.ActivateNavigation(position)) { Object.Destroy((Object)(object)val); return false; } _encounter = parasiteController; Plugin.Log.LogInfo((object)$"The Parasite spawned at {position} ({source}); guests see its enlarged drone body and two inert C.A.R.T. CANNON wings."); return true; } internal bool DebugSpawnAt(Vector3 requestedPosition) { //IL_0039: 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) if (!IsHostReady() || (!ModEnemySpawnCoordinator.IsDirectorRequestActive && (Object)(object)PlayerAvatar.instance == (Object)null) || !ModEnemyLevelRules.IsPlayableLevel()) { Plugin.Log.LogWarning((object)"Enemy Lab rejected The Parasite because no playable host level is active."); return false; } Probe(); NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requestedPosition, ref val, 12f, -1)) { return false; } _attemptFinished = true; return Create(((NavMeshHit)(ref val)).position, ModEnemySpawnCoordinator.CurrentSpawnSource); } internal void MarkAutomaticAttemptFinished() { int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } _attemptFinished = true; } internal void DebugDespawn() { if (IsHostReady()) { _attemptFinished = true; DestroyCurrent(); } } private void DestroyCurrent() { if ((Object)(object)_encounter != (Object)null) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); _encounter = null; } } private void Probe() { if (!_probed && !((Object)(object)RunManager.instance == (Object)null)) { _probed = true; _available = ParasiteSpawner.PrefabAvailable(); Plugin.Log.LogInfo((object)string.Format("The Parasite prefab probe: available={0}, resources={1} + {2}.", _available, "Items/Item Drone Indestructible", "Items/Item Cart Cannon")); } } private static bool TryFindSpawn(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; PlayerAvatar val = null; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { val = item; break; } } Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(val2, 16f, 58f, false) ?? SemiFunc.LevelPointGetFurthestFromPlayer(val2, 7f); return ModEnemyNavigation.TryFindClearSpawn(((Object)(object)val3 != (Object)null) ? ((Component)val3).transform.position : (val2 + Vector3.forward * 16f), 7f, out position); } private static bool IsHostReady() { try { return (Object)(object)GameManager.instance != (Object)null && (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient); } catch { return false; } } } internal sealed class ParasiteDroneMarker : MonoBehaviour { } internal sealed class SpawnedParasite { internal GameObject Root; internal PhysGrabObject Phys; internal PhysGrabObjectImpactDetector ImpactDetector; internal ItemAttributes Attributes; internal PhotonView View; internal ItemDrone Drone; internal ItemToggle Toggle; internal ItemBattery Battery; internal Renderer[] Renderers; internal Collider[] Colliders; internal readonly List Cannons = new List(); internal bool Alive = true; } internal sealed class SpawnedParasiteDecoration { internal GameObject Root; internal PhysGrabObject Phys; internal PhysGrabObjectImpactDetector ImpactDetector; internal PhotonView View; internal Renderer[] Renderers; internal Collider[] Colliders; internal Vector3 VisualCenterOffset; internal Vector3 VisualSize; internal int GeometryCalibrationFrames = 16; internal bool Alive = true; } internal static class ParasiteSpawner { internal const string ResourcePath = "Items/Item Drone Indestructible"; internal const string CannonResourcePath = "Items/Item Cart Cannon"; internal static bool PrefabAvailable() { if ((Object)(object)Resources.Load("Items/Item Drone Indestructible") != (Object)null) { return (Object)(object)Resources.Load("Items/Item Cart Cannon") != (Object)null; } return false; } internal static SpawnedParasite Spawn(Vector3 position) { //IL_002b: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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) //IL_0074: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02da: 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) GameObject val = Resources.Load("Items/Item Drone Indestructible"); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"The Parasite could not load vanilla resource 'Items/Item Drone Indestructible'."); return null; } Vector3 val2 = val.transform.localScale * 1.14f; object[] array = new object[3] { val2.x, val2.y, val2.z }; GameObject val3; try { val3 = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject("Items/Item Drone Indestructible", position, Quaternion.identity, (byte)0, array) : Object.Instantiate(val, position, Quaternion.identity)); } catch (Exception arg) { Plugin.Log.LogError((object)$"The Parasite failed to network-spawn its drone: {arg}"); return null; } if ((Object)(object)val3 == (Object)null) { return null; } val3.transform.localScale = val2; val3.AddComponent(); ModEnemyInventoryBlocker.Attach(val3); EncounterValuableNeutralizer.Apply(val3); SpawnedParasite spawnedParasite = new SpawnedParasite { Root = val3, Phys = val3.GetComponentInChildren(true), ImpactDetector = val3.GetComponentInChildren(true), Attributes = val3.GetComponentInChildren(true), View = val3.GetComponentInChildren(true), Drone = val3.GetComponentInChildren(true), Toggle = val3.GetComponentInChildren(true), Battery = val3.GetComponentInChildren(true), Renderers = val3.GetComponentsInChildren(true), Colliders = val3.GetComponentsInChildren(true) }; if ((Object)(object)spawnedParasite.Phys == (Object)null || (Object)(object)spawnedParasite.ImpactDetector == (Object)null || (Object)(object)spawnedParasite.View == (Object)null || (Object)(object)spawnedParasite.Drone == (Object)null || (Object)(object)spawnedParasite.Toggle == (Object)null) { Plugin.Log.LogError((object)"The Parasite drone lacks one of its required vanilla components."); Destroy(spawnedParasite); return null; } ItemAttributes attributes = spawnedParasite.Attributes; if (attributes != null) { attributes.DisableUI(true); } spawnedParasite.ImpactDetector.destroyDisable = true; spawnedParasite.ImpactDetector.playerHurtDisable = true; spawnedParasite.Phys.OverrideGrabDisable(1f); spawnedParasite.Phys.OverrideKinematic(1f); spawnedParasite.Phys.OverrideIndestructible(1f); spawnedParasite.Phys.clientNonKinematic = false; if ((Object)(object)spawnedParasite.Battery != (Object)null) { spawnedParasite.Battery.batteryLife = Mathf.Max(spawnedParasite.Battery.batteryLife, 10000f); spawnedParasite.Battery.batteryDrainRate = 0f; } spawnedParasite.Drone.targetValuables = false; spawnedParasite.Drone.targetPlayers = false; spawnedParasite.Drone.targetEnemies = false; spawnedParasite.Drone.targetNonValuables = false; ItemDroneIndestructible componentInChildren = val3.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { ((Behaviour)componentInChildren).enabled = false; } MapIconSuppressor.Attach(val3); for (int i = 0; i < 2; i++) { SpawnedParasiteDecoration spawnedParasiteDecoration = SpawnCannon(new Vector3(position.x, 3000f, position.z)); if (spawnedParasiteDecoration != null) { spawnedParasite.Cannons.Add(spawnedParasiteDecoration); } } if (spawnedParasite.Cannons.Count != 2) { Plugin.Log.LogWarning((object)$"The Parasite assembled only {spawnedParasite.Cannons.Count}/2 decorative C.A.R.T. CANNONs."); } return spawnedParasite; } private static SpawnedParasiteDecoration SpawnCannon(Vector3 position) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) GameObject val = Resources.Load("Items/Item Cart Cannon"); if ((Object)(object)val == (Object)null) { return null; } Vector3 val2 = val.transform.localScale * 0.31f; object[] array = new object[3] { val2.x, val2.y, val2.z }; GameObject val3; try { val3 = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject("Items/Item Cart Cannon", position, Quaternion.identity, (byte)0, array) : Object.Instantiate(val, position, Quaternion.identity)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("The Parasite could not spawn a decorative C.A.R.T. CANNON: " + ex.Message)); return null; } if ((Object)(object)val3 == (Object)null) { return null; } val3.transform.localScale = val2; ModEnemyInventoryBlocker.Attach(val3); EncounterValuableNeutralizer.Apply(val3); SpawnedParasiteDecoration spawnedParasiteDecoration = new SpawnedParasiteDecoration { Root = val3, Phys = val3.GetComponentInChildren(true), ImpactDetector = val3.GetComponentInChildren(true), View = val3.GetComponentInChildren(true), Renderers = val3.GetComponentsInChildren(true), Colliders = val3.GetComponentsInChildren(true) }; if ((Object)(object)spawnedParasiteDecoration.Phys == (Object)null || (Object)(object)spawnedParasiteDecoration.ImpactDetector == (Object)null) { Destroy(spawnedParasiteDecoration); return null; } ItemAttributes componentInChildren = val3.GetComponentInChildren(true); if (componentInChildren != null) { componentInChildren.DisableUI(true); } ItemToggle componentInChildren2 = val3.GetComponentInChildren(true); if ((Object)(object)componentInChildren2 != (Object)null) { ((Behaviour)componentInChildren2).enabled = false; } MonoBehaviour[] componentsInChildren = val3.GetComponentsInChildren(true); foreach (MonoBehaviour val4 in componentsInChildren) { if ((Object)(object)val4 != (Object)null && ((object)val4).GetType().Name.StartsWith("ItemCartCannon", StringComparison.Ordinal)) { ((Behaviour)val4).enabled = false; } } spawnedParasiteDecoration.ImpactDetector.destroyDisable = true; spawnedParasiteDecoration.ImpactDetector.playerHurtDisable = true; spawnedParasiteDecoration.Phys.OverrideGrabDisable(1f); spawnedParasiteDecoration.Phys.OverrideKinematic(1f); spawnedParasiteDecoration.Phys.OverrideIndestructible(1f); spawnedParasiteDecoration.Phys.clientNonKinematic = false; Collider[] colliders = spawnedParasiteDecoration.Colliders; foreach (Collider val5 in colliders) { if ((Object)(object)val5 != (Object)null) { val5.enabled = false; } } HurtCollider[] componentsInChildren2 = val3.GetComponentsInChildren(true); foreach (HurtCollider val6 in componentsInChildren2) { if ((Object)(object)val6 != (Object)null) { ((Behaviour)val6).enabled = false; } } MapIconSuppressor.Attach(val3); RefreshDecorationGeometry(spawnedParasiteDecoration); return spawnedParasiteDecoration; } internal static void RefreshDecorationGeometry(SpawnedParasiteDecoration part) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)part?.Phys == (Object)null || part.Renderers == null) { return; } bool flag = false; Bounds val = default(Bounds); Renderer[] renderers = part.Renderers; foreach (Renderer val2 in renderers) { if ((Object)(object)val2 == (Object)null || !val2.enabled || (!(val2 is MeshRenderer) && !(val2 is SkinnedMeshRenderer))) { continue; } Bounds bounds = val2.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!(((Vector3)(ref size)).sqrMagnitude < 1E-06f) && !(((Bounds)(ref bounds)).size.x > 8f) && !(((Bounds)(ref bounds)).size.y > 8f) && !(((Bounds)(ref bounds)).size.z > 8f)) { if (!flag) { val = bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(bounds); } } } if (flag) { part.VisualCenterOffset = Quaternion.Inverse(((Component)part.Phys).transform.rotation) * (((Bounds)(ref val)).center - ((Component)part.Phys).transform.position); part.VisualSize = ((Bounds)(ref val)).size; } } internal static void Destroy(SpawnedParasite part) { if ((Object)(object)part?.Root == (Object)null) { return; } foreach (SpawnedParasiteDecoration cannon in part.Cannons) { Destroy(cannon); } part.Cannons.Clear(); if (GameManager.Multiplayer()) { PhotonNetwork.Destroy(part.Root); } else { Object.Destroy((Object)(object)part.Root); } part.Alive = false; } internal static void Destroy(SpawnedParasiteDecoration part) { if (!((Object)(object)part?.Root == (Object)null) && part.Alive) { part.Alive = false; if (GameManager.Multiplayer()) { PhotonNetwork.Destroy(part.Root); } else { Object.Destroy((Object)(object)part.Root); } } } } internal sealed class PlaybackController : MonoBehaviour, IModEnemyTumbleReceiver, IModEnemyTranqAware { private enum BacklashState { Roam, Windup, Charge, BounceEmbed, BounceOut, BounceAim, Escape, Embedded, Rewind, RewindPause, Recover, Dead } private sealed class TrailSegment { internal MarionetteDronePart Source; internal MarionetteDronePart Target; internal Vector3 Start; internal Vector3 End; internal int StartRouteIndex; internal int EndRouteIndex; internal float ExpiresAt; internal float Warmup = 0.24f; internal bool Toggled; internal bool Attached; internal float NextAttachRefreshAt; internal float NextAttachLogAt; } private struct TrailPlayerCapsule { internal Vector3 Foot; internal Vector3 Waist; internal Vector3 Chest; internal Vector3 Head; } private const int RicochetCount = 10; private const float WindupDuration = 2.8f; private const float BounceEmbedDuration = 0.08f; private const float BounceOutDuration = 0.12f; private const float BounceAimDuration = 0.2f; private const float ReverseBounceDuration = 0.36f; private const float FinalEmbedDuration = 2f; private const float ChargeSpeed = 17.5f; private const float RewindSpeed = 19.5f; private const float VisualHeight = 1.08f; private const float TrailStunRadius = 0.76f; private const float ChargeSweepRadius = 0.3f; private const float RoamAgentRadius = 0.28f; private const float ChargeContactOffset = 0.055f; private const float MaximumChargeLegDuration = 2f; private const float MaximumChargeLegDistance = 29f; private const float MaximumChargeDistanceFromOrigin = 86f; private const float MinimumValidChargeSegment = 0.18f; private const float MaximumPhysicsDelta = 0.05f; private const float MaximumSweepSubstep = 0.24f; private const float FirstEscapeGuaranteedTravel = 1.4f; private const float ForcedEscapeGuaranteedTravel = 1.65f; private const float TrailContactCooldown = 1.9f; private const float TrailNoiseRadius = 10.5f; private static readonly MethodInfo NewRayHitPointMethod = typeof(ItemDrone).GetMethod("NewRayHitPoint", BindingFlags.Instance | BindingFlags.NonPublic); private const int MaximumRouteSamples = 2048; private readonly List _route = new List(2048); private readonly List _reflectionRouteIndices = new List(10); private readonly List _trails = new List(); private readonly Dictionary _trailStunCooldown = new Dictionary(); private readonly Dictionary _previousTrailPlayerCapsules = new Dictionary(); private readonly Dictionary _currentTrailPlayerCapsules = new Dictionary(); private readonly HashSet _damagedPlayersThisLeg = new HashSet(); private readonly HashSet _suppressedDamageLogThisLeg = new HashSet(); private readonly HashSet _damagedPlayersThisRewindLeg = new HashSet(); private readonly HashSet _rewindPlayersDamagedThisFrame = new HashSet(); private readonly List _hitBodies = new List(); private SpawnedPlayback _spawned; private NavMeshAgent _agent; private PlayerAvatar _target; private BacklashState _state; private Vector3 _chargeDirection = Vector3.forward; private Vector3 _pendingBounceDirection = Vector3.back; private Vector3 _visualForward = Vector3.forward; private Vector3 _bounceVisualStart = Vector3.forward; private Vector3 _bounceEmbedOffset; private Vector3 _bounceOutOffset; private Vector3 _impactVisualAxis = Vector3.forward; private Vector3 _lastTrailPoint; private Vector3 _chargeOrigin; private Vector3 _chargeLegStart; private Vector3 _lastSafeChargePosition; private Vector3 _visualEmbedOffset; private Vector3 _escapeStart; private Vector3 _escapeTarget; private Vector3 _escapeDirection; private Vector3 _lastEscapeDirection; private Vector3 _lockedAimPoint; private int _health; private int _ricochets; private int _rewindIndex; private int _lastTrailRouteIndex; private int _rewindDamageSegmentIndex = -1; private int _attackCycle; private int _chargeLegId; private int _chargeLegRouteStartIndex; private int _consecutiveNearZeroHits; private float _stateTimer; private float _scanTimer; private float _destinationTimer; private float _soundTimer; private float _damageFeedbackCooldown; private float _rewardTimer; private float _lastClaimedHit = -999f; private float _headingLockUntil; private float _nextHitAuditAt; private float _nextLosLogAt; private float _minimumPostEscapeTravel; private float _trailBatchReleaseAt = -1f; private float _visualBankRoll; private float _visualBankVelocity; private float _visualBankTarget; private float _visualSpinRoll; private bool _jackhammerWarningActive; private float _roamBlend = 1f; private bool _initialized; private bool _dead; private bool _cleaning; private bool _rewardDropped; private bool _trailFailureLogged; private bool _bounceEffectLogged; private bool _visualSpinMovingThisFrame; private bool _rewindBounceActive; private bool _chargeLegDamageArmed; private bool _trailNoiseLogged; private bool _attackLaunchCommitted; private float _escapeDuration; internal Vector3 HitCenter => ((Component)this).transform.position + Vector3.up * 1.08f; internal float HitHalfExtent => 0.68f; public bool CanReceiveTumbleAttack { get { if (_initialized) { return !_dead; } return false; } } internal bool Initialize(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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) ((Component)this).transform.position = position; _health = Mathf.Max(1, Plugin.Settings.PlaybackHealth.Value); _agent = ((Component)this).gameObject.AddComponent(); ((Behaviour)_agent).enabled = false; _agent.speed = Mathf.Max(1f, Plugin.Settings.PlaybackRoamSpeed.Value); _agent.acceleration = 14f; _agent.angularSpeed = 260f; _agent.radius = 0.28f; _agent.height = 1.25f; _agent.stoppingDistance = 1.5f; _spawned = PlaybackSpawner.Spawn(position + Vector3.up * 1.08f); if (_spawned == null) { return false; } for (int i = 0; i < _spawned.Parts.Count; i++) { SpawnedDeadAirPart spawnedDeadAirPart = _spawned.Parts[i]; SpawnedPlayback spawnedPlayback = new SpawnedPlayback { Body = spawnedDeadAirPart }; _hitBodies.Add(spawnedPlayback); ((Component)spawnedDeadAirPart.Phys).gameObject.AddComponent().Initialize(this, spawnedPlayback); ((Component)spawnedDeadAirPart.Phys).gameObject.AddComponent().Initialize(this, i); } _state = BacklashState.Roam; _scanTimer = 0f; _destinationTimer = 0.15f; _soundTimer = Random.Range(0.8f, 1.3f); _initialized = true; PinParts(immediate: true); Plugin.Log.LogInfo((object)("The Backlash assembled from '" + PlaybackSpawner.ResourcePath + "', '" + PlaybackSpawner.FinResourcePath + "' with Hammer child=" + $"{(Object)(object)_spawned.JackhammerHammer != (Object)null}, Hydraulics=" + $"{(Object)(object)_spawned.JackhammerHydraulics != (Object)null}, Animator=" + $"{(Object)(object)_spawned.JackhammerAnimator != (Object)null} and two vanilla enemy orbs with {_health} HP.")); return true; } internal bool ActivateNavigation(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; return ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform, 6f); } private void Update() { if (!_initialized || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } _visualSpinMovingThisFrame = false; if (_dead) { UpdateTrails(); UpdateDeath(); return; } _scanTimer -= Time.deltaTime; _destinationTimer -= Time.deltaTime; _soundTimer -= Time.deltaTime; _damageFeedbackCooldown = Mathf.Max(0f, _damageFeedbackCooldown - Time.deltaTime); switch (_state) { case BacklashState.Roam: UpdateRoam(); break; case BacklashState.Windup: UpdateWindup(); break; case BacklashState.Charge: UpdateCharge(); break; case BacklashState.BounceEmbed: UpdateBounceEmbed(); break; case BacklashState.BounceOut: UpdateBounceOut(); break; case BacklashState.BounceAim: UpdateBounceAim(); break; case BacklashState.Escape: UpdateEscape(); break; case BacklashState.Embedded: UpdateEmbedded(); break; case BacklashState.Rewind: UpdateRewind(); break; case BacklashState.RewindPause: UpdateRewindPause(); break; case BacklashState.Recover: UpdateRecover(); break; } UpdateTrails(); UpdateAudio(); UpdateJackhammerAnimation(); PinParts(immediate: false); } private void UpdateRoam() { //IL_00ba: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) _roamBlend = Mathf.MoveTowards(_roamBlend, 1f, Time.deltaTime / 0.45f); if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.isStopped = false; Vector3 velocity = _agent.velocity; if (((Vector3)(ref velocity)).sqrMagnitude > 0.04f) { Vector3 visualForward = _visualForward; velocity = _agent.velocity; _visualForward = SmoothDirection(visualForward, ((Vector3)(ref velocity)).normalized, 4.5f); } } if (_destinationTimer <= 0f) { _destinationTimer = Random.Range(2.1f, 3.6f); Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(5f, 12f); ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, ((Component)this).transform.position + new Vector3(val.x, 0f, val.y), 5f); } if (!(_scanTimer > 0f)) { _scanTimer = 0.12f; _target = FindNearestPlayer(34f); if (!((Object)(object)_target == (Object)null)) { StopAgent(); _lockedAimPoint = PlayerAimPoint(_target); _attackLaunchCommitted = true; _state = BacklashState.Windup; _stateTimer = 2.8f; _ricochets = 0; _visualSpinRoll = 0f; _attackCycle++; _chargeLegId = 0; _damagedPlayersThisLeg.Clear(); _suppressedDamageLogThisLeg.Clear(); _route.Clear(); _reflectionRouteIndices.Clear(); _lastTrailPoint = ((Component)this).transform.position; Plugin.Log.LogInfo((object)"The Backlash acquired a player and began its jackhammer wind-up."); } } } private void UpdateWindup() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_00c2: 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_0114: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) _stateTimer -= Time.deltaTime; if (!_attackLaunchCommitted) { BeginRecover(0.7f); return; } if (GunAccess.IsLiving(_target) && HasLineOfSight(_target)) { _lockedAimPoint = PlayerAimPoint(_target); } Vector3 val = _lockedAimPoint - HitCenter; if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = Quaternion.AngleAxis(38f, Vector3.up) * HorizontalDirection(normalized) + Vector3.up * 0.38f; Vector3 normalized2 = ((Vector3)(ref val2)).normalized; Vector3 target = ((_stateTimer > 0.58f) ? normalized2 : normalized); _visualForward = SmoothDirection(_visualForward, target, (_stateTimer > 0.58f) ? 5.8f : 11.5f); } if (!(_stateTimer > 0f)) { _chargeDirection = SafeChargeDirection((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? val : _visualForward); _route.Clear(); AddRoutePoint(((Component)this).transform.position, force: true); _chargeOrigin = ((Component)this).transform.position; _chargeLegStart = ((Component)this).transform.position; _lastSafeChargePosition = ((Component)this).transform.position; _lastTrailPoint = ((Component)this).transform.position; _lastTrailRouteIndex = _route.Count - 1; _chargeLegRouteStartIndex = _lastTrailRouteIndex; _chargeLegDamageArmed = false; _consecutiveNearZeroHits = 0; _minimumPostEscapeTravel = 0f; if ((Object)(object)_agent != (Object)null) { ((Behaviour)_agent).enabled = false; } _attackLaunchCommitted = false; _state = BacklashState.Charge; _stateTimer = 2f; BodyImpact(135f); } } private void UpdateCharge() { //IL_0018: 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_0037: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: 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_01cf: 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_019f: Unknown result type (might be due to invalid IL or missing references) _stateTimer -= Time.deltaTime; if (IsFinite(((Component)this).transform.position) && IsFinite(_chargeDirection)) { Vector3 val = ((Component)this).transform.position - _chargeOrigin; if (!(((Vector3)(ref val)).sqrMagnitude > 7396f)) { val = ((Component)this).transform.position - _chargeLegStart; if (((Vector3)(ref val)).sqrMagnitude > 841f) { BeginEmergencyRewind("charge leg exceeded its safe sweep distance"); return; } _chargeDirection = SafeChargeDirection(_chargeDirection); _visualForward = SmoothDirection(_visualForward, _chargeDirection, 8.5f); _visualBankTarget = DirectionBank(_visualForward, _chargeDirection, 18f); float contactRadius = Mathf.Clamp(Plugin.Settings.PlaybackContactRadius.Value, 0.55f, 1.8f); float num = Mathf.Max(0f, 29f - Vector3.Distance(((Component)this).transform.position, _chargeLegStart)); float num2 = Mathf.Min(17.5f * Mathf.Min(Time.deltaTime, 0.05f), num); while (num2 > 0.0001f) { float num3 = Mathf.Min(0.24f, num2); Vector3 position = ((Component)this).transform.position; if (TryFindWallHit(position, _chargeDirection, num3, out var result)) { HandleChargeWallHit(position, result); return; } Vector3 val2 = position + _chargeDirection * num3; if (TryFindSolidOverlap(val2, out var result2)) { HandleChargeOverlap(position, result2); return; } ((Component)this).transform.position = val2; _visualSpinMovingThisFrame = true; _lastSafeChargePosition = val2; AddRoutePoint(val2, force: false); RecordChargeMovement(position, val2, contactRadius); num2 -= num3; } if (Vector3.Distance(((Component)this).transform.position, _chargeLegStart) >= 28.999f) { BeginEmergencyRewind("charge leg reached its safe sweep distance"); } else if (_stateTimer <= 0f) { BeginEmergencyRewind("charge leg found no static level geometry"); } return; } } BeginEmergencyRewind("charge left the playable route bounds"); } private void RecordChargeMovement(Vector3 start, Vector3 next, float contactRadius) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Distance(_chargeLegStart, next); if (_minimumPostEscapeTravel > 0f && num >= _minimumPostEscapeTravel) { Plugin.Log.LogInfo((object)$"The Backlash completed its {_minimumPostEscapeTravel:0.00}m post-escape travel guarantee; normal wall reflection resumed."); _minimumPostEscapeTravel = 0f; } if (!(num < 0.18f)) { if (!_chargeLegDamageArmed) { ArmChargeLeg(); _chargeLegDamageArmed = true; DamagePlayersAlongSegment(_chargeLegStart, next, contactRadius); } else { DamagePlayersAlongSegment(start, next, contactRadius); } } } private void HandleChargeWallHit(Vector3 start, RaycastHit wall) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_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_007f: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_003a: Unknown result type (might be due to invalid IL or missing references) //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_004e: 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) //IL_005d: 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_0111: 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_00ff: 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_00ef: Unknown result type (might be due to invalid IL or missing references) if (((RaycastHit)(ref wall)).distance <= 0.001f && Time.time < _headingLockUntil) { ((Component)this).transform.position = _lastSafeChargePosition; _headingLockUntil = Time.time; Vector3 wallOutward = ResolveWallNormal(wall, start + Vector3.up * 1.08f); BeginNearZeroEscape(((RaycastHit)(ref wall)).collider, wallOutward, 0f); return; } Vector3 val = start + Vector3.up * 1.08f; float num = Mathf.Max(0f, ((RaycastHit)(ref wall)).distance - 0.055f); Vector3 endpoint = start + _chargeDirection * num; if (((RaycastHit)(ref wall)).distance <= 0.055f) { endpoint = _lastSafeChargePosition; } Vector3 normal = ResolveWallNormal(wall, val); Vector3 val2 = ((RaycastHit)(ref wall)).point; if ((Object)(object)((RaycastHit)(ref wall)).collider != (Object)null && (((RaycastHit)(ref wall)).distance <= 0.001f || !IsFinite(val2))) { val2 = ((RaycastHit)(ref wall)).collider.ClosestPoint(val); } CompleteChargeContact(((RaycastHit)(ref wall)).collider, val2, normal, endpoint, ((RaycastHit)(ref wall)).distance); } private void HandleChargeOverlap(Vector3 start, Collider collider) { //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) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0023: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_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_0031: 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_0051: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = start + Vector3.up * 1.08f; Vector3 val2 = (((Object)(object)collider != (Object)null) ? collider.ClosestPoint(val) : val); Vector3 val3 = val - val2; if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = -_chargeDirection; } CompleteChargeContact(collider, val2, ((Vector3)(ref val3)).normalized, _lastSafeChargePosition, 0f); } private void CompleteChargeContact(Collider collider, Vector3 point, Vector3 normal, Vector3 endpoint, float contactDistance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0061: 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_006b: 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_007c: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Distance(_chargeLegStart, endpoint); if (num < 0.18f) { BeginNearZeroEscape(collider, normal, num); return; } if (_minimumPostEscapeTravel > 0f && num < _minimumPostEscapeTravel) { Plugin.Log.LogInfo((object)$"The Backlash post-escape launch met valid solid geometry after {num:0.00}m; accepting that physical endpoint."); _minimumPostEscapeTravel = 0f; } ((Component)this).transform.position = endpoint; _lastSafeChargePosition = endpoint; _visualEmbedOffset = _chargeDirection * 0.1f; PlayBounceEffect(point); Plugin.Log.LogInfo((object)$"The Backlash leg {_chargeLegId} emitted its harmless reflection impact effect."); Plugin.Log.LogInfo((object)$"The Backlash leg {_chargeLegId} accepted blocker '{((collider != null) ? ((Object)collider).name : null)}' layer={((collider != null) ? new int?(((Component)collider).gameObject.layer) : ((int?)null))} distance={contactDistance:0.000}."); FinishChargeLeg(SafeChargeDirection(Vector3.Reflect(_chargeDirection, ((Vector3)(ref normal)).normalized)), ((Vector3)(ref normal)).normalized); } private Vector3 ResolveWallNormal(RaycastHit wall, Vector3 origin) { //IL_0002: 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_003d: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((RaycastHit)(ref wall)).normal; if (((Vector3)(ref val)).sqrMagnitude < 0.01f || ((RaycastHit)(ref wall)).distance <= 0.001f) { Vector3 val2 = (((Object)(object)((RaycastHit)(ref wall)).collider != (Object)null) ? ((RaycastHit)(ref wall)).collider.ClosestPoint(origin) : origin); val = origin - val2; } if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = -_chargeDirection; } return ((Vector3)(ref val)).normalized; } private void BeginNearZeroEscape(Collider blocker, Vector3 wallOutward, float segmentLength) { //IL_009b: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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_0175: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: 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_01c4: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) _consecutiveNearZeroHits++; if (_route.Count > _chargeLegRouteStartIndex + 1) { _route.RemoveRange(_chargeLegRouteStartIndex + 1, _route.Count - (_chargeLegRouteStartIndex + 1)); } if (_consecutiveNearZeroHits >= 3) { _minimumPostEscapeTravel = 0f; Plugin.Log.LogWarning((object)$"The Backlash rejected recovery 3/3 at '{((blocker != null) ? ((Object)blocker).name : null)}' ({segmentLength:0.000}m); aborting this attack instead of reflecting or looping."); BeginEmergencyRewind("three invalid or near-zero charge contacts exhausted recovery"); return; } bool flag = _consecutiveNearZeroHits == 2; float freeDistance; Vector3 val = ChooseEscapeDirection(wallOutward, flag, out freeDistance); float num = (flag ? 0.68f : 0.38f); float num2 = Mathf.Clamp(Mathf.Min(num, freeDistance - 0.1f), flag ? 0.48f : 0.28f, num); _escapeStart = ((Component)this).transform.position; _escapeTarget = _escapeStart + val * num2; NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(_escapeTarget, ref val2, 0.42f, -1) && Mathf.Abs(((NavMeshHit)(ref val2)).position.y - _escapeTarget.y) < 0.55f && Vector3.Distance(_escapeStart, ((NavMeshHit)(ref val2)).position) >= (flag ? 0.42f : 0.25f)) { _escapeTarget = ((NavMeshHit)(ref val2)).position; } _escapeDirection = val; _lastEscapeDirection = val; _minimumPostEscapeTravel = (flag ? 1.65f : 1.4f); _escapeDuration = (flag ? 0.42f : 0.27f); _stateTimer = _escapeDuration; _state = BacklashState.Escape; _visualEmbedOffset = Vector3.zero; _visualBankTarget = DirectionBank(_visualForward, _escapeDirection, 14f); Plugin.Log.LogWarning((object)($"The Backlash rejected near-zero leg ({segmentLength:0.000}m) at '{((blocker != null) ? ((Object)blocker).name : null)}'; " + $"recovery {_consecutiveNearZeroHits}/2 moves {Vector3.Distance(_escapeStart, _escapeTarget):0.00}m, then requires {_minimumPostEscapeTravel:0.00}m real travel without reflection, damage rearm or beam.")); } private void UpdateEscape() { //IL_0058: 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_0064: 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) //IL_0080: 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_008c: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: 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_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) _stateTimer -= Time.deltaTime; float num = Mathf.Clamp01(1f - Mathf.Max(0f, _stateTimer) / Mathf.Max(0.01f, _escapeDuration)); float num2 = num * num * (3f - 2f * num); ((Component)this).transform.position = Vector3.Lerp(_escapeStart, _escapeTarget, num2); _visualForward = SmoothDirection(_visualForward, _escapeDirection, 7.5f); _visualBankTarget = DirectionBank(_visualForward, _escapeDirection, 14f); if (_stateTimer > 0f) { return; } ((Component)this).transform.position = _escapeTarget; Vector3 direction = _escapeDirection; PlayerAvatar val = FindNearestPlayer(30f); if (GunAccess.IsLiving(val)) { Rigidbody componentInChildren = ((Component)val).GetComponentInChildren(); Vector3 val2 = PlayerAimPoint(val) + (((Object)(object)componentInChildren != (Object)null) ? componentInChildren.velocity : Vector3.zero) * 0.22f - HitCenter; if (((Vector3)(ref val2)).sqrMagnitude > 0.01f) { Vector3 val3 = Vector3.Slerp(_escapeDirection, ((Vector3)(ref val2)).normalized, 0.22f); Vector3 normalized = ((Vector3)(ref val3)).normalized; if (ProbeFreeDistance(normalized, _minimumPostEscapeTravel) >= _minimumPostEscapeTravel) { direction = normalized; } } } AddRoutePoint(((Component)this).transform.position, force: true); _lastTrailPoint = ((Component)this).transform.position; _lastTrailRouteIndex = _route.Count - 1; _chargeLegRouteStartIndex = _lastTrailRouteIndex; _chargeLegStart = ((Component)this).transform.position; _lastSafeChargePosition = ((Component)this).transform.position; _chargeDirection = SafeChargeDirection(direction); _chargeLegDamageArmed = false; _headingLockUntil = Time.time + 0.16f; _stateTimer = 2f; _state = BacklashState.Charge; } private Vector3 ChooseEscapeDirection(Vector3 wallOutward, bool forced, out float freeDistance) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0023: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_008d: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_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_0103: 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_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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_013b: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((((Vector3)(ref wallOutward)).sqrMagnitude > 0.01f) ? ((Vector3)(ref wallOutward)).normalized : (-_chargeDirection)); Vector3 val2 = Vector3.Cross(Vector3.up, val); if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = Vector3.right; } ((Vector3)(ref val2)).Normalize(); List obj = new List { val, -_chargeDirection, Quaternion.AngleAxis(32f, Vector3.up) * val, Quaternion.AngleAxis(-32f, Vector3.up) * val, Quaternion.AngleAxis(64f, Vector3.up) * val, Quaternion.AngleAxis(-64f, Vector3.up) * val, Quaternion.AngleAxis(24f, val2) * val, Quaternion.AngleAxis(-24f, val2) * val }; Vector3 val3 = val + Vector3.up * 0.45f; obj.Add(((Vector3)(ref val3)).normalized); val3 = val - Vector3.up * 0.35f; obj.Add(((Vector3)(ref val3)).normalized); Vector3 val4 = val; float num = -1f; freeDistance = 0f; foreach (Vector3 item in obj) { Vector3 val5 = SafeChargeDirection(item); float num2 = ProbeFreeDistance(val5, 3.2f); float num3 = num2; float num4 = Vector3.Dot(val5, val); num2 += Mathf.Max(0f, num4) * 0.18f; if (num4 < 0.05f) { num2 -= 1.2f; } if (forced && ((Vector3)(ref _lastEscapeDirection)).sqrMagnitude > 0.01f) { float num5 = Vector3.Dot(val5, ((Vector3)(ref _lastEscapeDirection)).normalized); num2 = ((!(num5 > 0.72f)) ? (num2 + (0.72f - num5) * 0.35f) : (num2 - 3.5f)); } if (!(num2 <= num)) { num = num2; val4 = val5; freeDistance = num3; } } freeDistance = ProbeFreeDistance(val4, 3.2f); return val4; } private float ProbeFreeDistance(Vector3 direction, float maximum) { //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) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) direction = SafeChargeDirection(direction); Vector3 val = HitCenter + direction * 0.06f; float num = maximum; int num2 = -1; RaycastHit[] array = Physics.SphereCastAll(val, 0.246f, direction, maximum, num2, (QueryTriggerInteraction)1); if (array != null) { Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit[] array2 = array; for (int num3 = 0; num3 < array2.Length; num3++) { RaycastHit val2 = array2[num3]; if (!(((RaycastHit)(ref val2)).distance <= 0.06f) && IsChargeBlocker(((RaycastHit)(ref val2)).collider)) { num = Mathf.Min(num, ((RaycastHit)(ref val2)).distance); } } } RaycastHit[] array3 = Physics.RaycastAll(val, direction, maximum, num2, (QueryTriggerInteraction)1); if (array3 != null) { Array.Sort(array3, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit[] array2 = array3; for (int num3 = 0; num3 < array2.Length; num3++) { RaycastHit val3 = array2[num3]; if (!(((RaycastHit)(ref val3)).distance <= 0.06f) && IsChargeBlocker(((RaycastHit)(ref val3)).collider)) { num = Mathf.Min(num, ((RaycastHit)(ref val3)).distance); } } } return num; } private void FinishChargeLeg(Vector3 reflected, Vector3 wallOutward) { //IL_0019: 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_0045: Unknown result type (might be due to invalid IL or missing references) //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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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) _consecutiveNearZeroHits = 0; _minimumPostEscapeTravel = 0f; AddRoutePoint(((Component)this).transform.position, force: true); RecordReflectionVertex(); int num = _route.Count - 1; CreateTrail(_lastTrailPoint, ((Component)this).transform.position, _lastTrailRouteIndex, num); _lastTrailPoint = ((Component)this).transform.position; _lastTrailRouteIndex = num; _ricochets++; Vector3 geometricReflection = ((((Vector3)(ref reflected)).sqrMagnitude > 0.01f) ? ((Vector3)(ref reflected)).normalized : (-_chargeDirection)); _pendingBounceDirection = BiasReflectionTowardTarget(geometricReflection, wallOutward); _bounceVisualStart = ((((Vector3)(ref _visualForward)).sqrMagnitude > 0.01f) ? ((Vector3)(ref _visualForward)).normalized : _chargeDirection); _bounceEmbedOffset = _chargeDirection * 0.1f; _impactVisualAxis = _chargeDirection; _bounceOutOffset = ((((Vector3)(ref wallOutward)).sqrMagnitude > 0.01f) ? (((Vector3)(ref wallOutward)).normalized * 0.58f) : (-_chargeDirection * 0.58f)); _visualEmbedOffset = _bounceEmbedOffset; _state = BacklashState.BounceEmbed; _stateTimer = 0.08f; Plugin.Log.LogInfo((object)$"The Backlash bounce {_ricochets}/{10}; embed {0.08f:0.00}s, bounce-out {0.12f:0.00}s, aim {0.2f:0.00}s."); } private void UpdateBounceEmbed() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0026: 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) _stateTimer -= Time.deltaTime; _visualEmbedOffset = _bounceEmbedOffset; _visualForward = SmoothDirection(_visualForward, _chargeDirection, 10f); if (!(_stateTimer > 0f)) { _state = BacklashState.BounceOut; _stateTimer = 0.12f; } } private void UpdateBounceOut() { //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) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) _stateTimer -= Time.deltaTime; float num = Mathf.Clamp01(1f - Mathf.Max(0f, _stateTimer) / 0.12f); num = num * num * (3f - 2f * num); _visualEmbedOffset = Vector3.Lerp(_bounceEmbedOffset, _bounceOutOffset, num); if (!(_stateTimer > 0f)) { _visualEmbedOffset = _bounceOutOffset; _state = BacklashState.BounceAim; _stateTimer = 0.2f; } } private void UpdateBounceAim() { //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) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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) _stateTimer -= Time.deltaTime; float num = Mathf.Clamp01(1f - Mathf.Max(0f, _stateTimer) / 0.2f); float num2 = num * num * (3f - 2f * num); Vector3 val = Vector3.Slerp(_bounceVisualStart, _pendingBounceDirection, num2); _visualForward = ((Vector3)(ref val)).normalized; float num3 = Vector3.SignedAngle(_bounceVisualStart, _pendingBounceDirection, Vector3.up); _visualBankTarget = Mathf.Sin(num * MathF.PI) * Mathf.Clamp(num3 * 0.18f, -20f, 20f); if (!(_stateTimer > 0f)) { _visualForward = _pendingBounceDirection; _chargeDirection = _pendingBounceDirection; _visualEmbedOffset = Vector3.zero; if (_ricochets >= 10) { _state = BacklashState.Embedded; _stateTimer = 2f; Plugin.Log.LogInfo((object)$"The Backlash bounce {_ricochets}/{10}; final pose complete, holding {2f:0.0}s."); return; } _chargeLegStart = ((Component)this).transform.position; _lastSafeChargePosition = ((Component)this).transform.position; _headingLockUntil = Time.time + 0.28f; _state = BacklashState.Charge; _stateTimer = 2f; _chargeLegRouteStartIndex = _route.Count - 1; _chargeLegDamageArmed = false; } } private Vector3 BiasReflectionTowardTarget(Vector3 geometricReflection, Vector3 wallOutward) { //IL_001e: 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_0034: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0067: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_009e: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar val = FindNearestPlayer(30f); if (!GunAccess.IsLiving(val)) { return geometricReflection; } Rigidbody componentInChildren = ((Component)val).GetComponentInChildren(); Vector3 val2 = PlayerAimPoint(val) + (((Object)(object)componentInChildren != (Object)null) ? componentInChildren.velocity : Vector3.zero) * 0.28f - HitCenter; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { return geometricReflection; } Vector3 val3 = Vector3.Slerp(geometricReflection, ((Vector3)(ref val2)).normalized, 0.24f); Vector3 normalized = ((Vector3)(ref val3)).normalized; if (((Vector3)(ref wallOutward)).sqrMagnitude > 0.01f && Vector3.Dot(normalized, wallOutward) < 0.12f) { val3 = normalized - wallOutward * Vector3.Dot(normalized, wallOutward) + wallOutward * 0.12f; normalized = ((Vector3)(ref val3)).normalized; } Plugin.Log.LogDebug((object)$"The Backlash reflection {_ricochets}/{10} biased toward player {PlayerId(val)}."); return normalized; } private void UpdateEmbedded() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0036: Unknown result type (might be due to invalid IL or missing references) _stateTimer -= Time.deltaTime; _visualForward = SmoothDirection(_visualForward, _pendingBounceDirection, 7.5f); _visualBankTarget = DirectionBank(_visualForward, _pendingBounceDirection, 16f); if (!(_stateTimer > 0f)) { BeginRewind(); } } private void UpdateRewind() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: 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_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_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: 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_0246: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_009c: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_0116: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) if (_rewindIndex < 0) { ScheduleTrailBatchRelease(); BeginRewindPause(2f); return; } UpdateRewindTrailEndpoint(); _rewindPlayersDamagedThisFrame.Clear(); Vector3 position = ((Component)this).transform.position; float num = 19.5f * Mathf.Min(Time.deltaTime, 0.05f); while (_rewindIndex >= 0 && num > 0f) { Vector3 val = _route[_rewindIndex]; float num2 = Vector3.Distance(((Component)this).transform.position, val); ArmRewindSegment(_rewindIndex); Vector3 position2 = ((Component)this).transform.position; if (num2 <= 0.001f) { if (CompleteRewindRoutePoint(Vector3.zero)) { return; } continue; } float num3 = Mathf.Min(new float[3] { num2, num, 0.24f }); Vector3 val2 = val - position2; Vector3 normalized = ((Vector3)(ref val2)).normalized; if (TryFindWallHit(position2, normalized, num3, out var result)) { float num4 = Mathf.Max(0f, ((RaycastHit)(ref result)).distance - 0.055f); Vector3 val3 = ((((RaycastHit)(ref result)).distance <= 0.055f) ? position2 : (position2 + normalized * num4)); ((Component)this).transform.position = val3; DamagePlayersAlongRewindSegment(position2, val3, val3 - position2, _rewindIndex); AbortBlockedRewind(((RaycastHit)(ref result)).collider, ((RaycastHit)(ref result)).distance); return; } Vector3 val4 = position2 + normalized * num3; if (TryFindSolidOverlap(val4, out var result2)) { AbortBlockedRewind(result2, 0f); return; } ((Component)this).transform.position = val4; DamagePlayersAlongRewindSegment(position2, val4, val4 - position2, _rewindIndex); num -= num3; if (num3 >= num2 - 0.001f && CompleteRewindRoutePoint(val4 - position2)) { return; } } Vector3 val5 = ((Component)this).transform.position - position; UpdateRewindTrailEndpoint(); if (((Vector3)(ref val5)).sqrMagnitude > 0.0001f) { _visualSpinMovingThisFrame = true; _visualForward = SmoothDirection(_visualForward, -((Vector3)(ref val5)).normalized, 9.5f); _visualBankTarget = DirectionBank(_visualForward, -((Vector3)(ref val5)).normalized, 17f); } } private bool CompleteRewindRoutePoint(Vector3 reverseMotion) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) int rewindIndex = _rewindIndex; _rewindIndex--; if (!IsReflectionVertex(rewindIndex)) { return false; } if (((Vector3)(ref reverseMotion)).sqrMagnitude > 0.0001f) { _impactVisualAxis = ((Vector3)(ref reverseMotion)).normalized; } int num = _reflectionRouteIndices.IndexOf(rewindIndex) + 1; Plugin.Log.LogInfo((object)$"The Backlash rewind vertex {num}/{_reflectionRouteIndices.Count}; reverse bounce {0.36f:0.00}s while the complete red route remains active."); BeginRewindPause(0.36f, reverseBounce: true); return true; } private void AbortBlockedRewind(Collider collider, float distance) { Plugin.Log.LogWarning((object)$"The Backlash rewind sweep stopped at solid '{((collider != null) ? ((Object)collider).name : null)}' distance={distance:0.000}; route replay aborted before crossing the surface."); DestroyTrails(); BeginRecover(0.82f); } private void BeginRewindPause(float duration, bool reverseBounce = false) { _state = BacklashState.RewindPause; _stateTimer = duration; _rewindBounceActive = reverseBounce; } private void UpdateRewindPause() { _stateTimer -= Time.deltaTime; if (!(_stateTimer > 0f)) { if (_rewindIndex < 0) { Plugin.Log.LogInfo((object)$"The Backlash rewind origin reached; holding {2f:0.0}s before patrol."); BeginRecover(0.82f); } else { _rewindBounceActive = false; _state = BacklashState.Rewind; } } } private void BeginRecover(float duration) { _attackLaunchCommitted = false; _state = BacklashState.Recover; _stateTimer = duration; _roamBlend = 0f; _target = null; if ((Object)(object)_agent != (Object)null) { ((Behaviour)_agent).enabled = false; } } private void UpdateRecover() { _stateTimer -= Time.deltaTime; if (!(_stateTimer > 0f)) { if (!ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform, 8f)) { _stateTimer = 0.35f; return; } _state = BacklashState.Roam; _scanTimer = 3.8f; _destinationTimer = 0f; _route.Clear(); DestroyTrails(); } } private void AddRoutePoint(Vector3 point, bool force) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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) if (_route.Count >= 2048) { return; } if (!force && _route.Count != 0) { Vector3 val = _route[_route.Count - 1] - point; if (!(((Vector3)(ref val)).sqrMagnitude >= 0.0484f)) { return; } } _route.Add(point); } private void RecordReflectionVertex() { int num = _route.Count - 1; if (num >= 0 && (_reflectionRouteIndices.Count <= 0 || _reflectionRouteIndices[_reflectionRouteIndices.Count - 1] != num)) { _reflectionRouteIndices.Add(num); } } private bool IsReflectionVertex(int routeIndex) { for (int num = _reflectionRouteIndices.Count - 1; num >= 0; num--) { if (_reflectionRouteIndices[num] == routeIndex) { return true; } } return false; } private void CreateTrail(Vector3 start, Vector3 end, int startRouteIndex, int endRouteIndex) { //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) //IL_0002: 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_0044: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_00f7: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; if (((Vector3)(ref val)).sqrMagnitude < 0.20249999f) { return; } string trailDroneResourcePath = PlaybackSpawner.TrailDroneResourcePath; if (string.IsNullOrEmpty(trailDroneResourcePath)) { if (!_trailFailureLogged) { _trailFailureLogged = true; Plugin.Log.LogWarning((object)"The Backlash could not resolve its native Indestructible Drone trail resource."); } return; } MarionetteDronePart marionetteDronePart = MarionetteSpawner.SpawnBeamEmitter(start + Vector3.up * 1.08f, trailDroneResourcePath); MarionetteDronePart marionetteDronePart2 = MarionetteSpawner.SpawnBeamEmitter(end + Vector3.up * 1.08f, trailDroneResourcePath); if (marionetteDronePart == null || marionetteDronePart2 == null) { if (!_trailFailureLogged) { _trailFailureLogged = true; Plugin.Log.LogWarning((object)"The Backlash could not create its native Indestructible Drone trail endpoints."); } MarionetteSpawner.DestroyDrone(marionetteDronePart); MarionetteSpawner.DestroyDrone(marionetteDronePart2); } else { _trails.Add(new TrailSegment { Source = marionetteDronePart, Target = marionetteDronePart2, Start = start + Vector3.up * 1.08f, End = end + Vector3.up * 1.08f, StartRouteIndex = startRouteIndex, EndRouteIndex = endRouteIndex, ExpiresAt = float.PositiveInfinity }); _trailFailureLogged = false; } } private void UpdateRewindTrailEndpoint() { } private void ScheduleTrailBatchRelease() { if (!(_trailBatchReleaseAt >= 0f)) { _trailBatchReleaseAt = Time.time + 0.24f; Plugin.Log.LogInfo((object)$"The Backlash completed rewind; retaining all {_trails.Count} trail segments for a 0.24-second final hold before batch cleanup."); } } private void BeginRewind() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) _visualEmbedOffset = Vector3.zero; if (_route.Count < 2) { BeginRecover(0.82f); return; } _rewindIndex = _route.Count - 2; _rewindDamageSegmentIndex = -1; _damagedPlayersThisRewindLeg.Clear(); _rewindPlayersDamagedThisFrame.Clear(); _state = BacklashState.Rewind; Plugin.Log.LogInfo((object)$"The Backlash begin rewind across {_route.Count} recorded route samples after {_ricochets}/{10} bounces."); } private void BeginEmergencyRewind(string reason) { if (_state != BacklashState.Rewind && _state != BacklashState.RewindPause && _state != BacklashState.Recover && _state != BacklashState.Dead) { StopAgent(); Plugin.Log.LogWarning((object)("The Backlash charge safety fallback: " + reason + "; preserving route and beginning rewind.")); BeginRewind(); } } private void UpdateTrails() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) if (_trailBatchReleaseAt >= 0f && Time.time >= _trailBatchReleaseAt) { int count = _trails.Count; DestroyTrails(); Plugin.Log.LogInfo((object)$"The Backlash batch-released {count} red trail segments after full rewind completion."); return; } CaptureTrailPlayerCapsules(); for (int num = _trails.Count - 1; num >= 0; num--) { TrailSegment trailSegment = _trails[num]; if (trailSegment == null || (Object)(object)trailSegment.Source?.Phys == (Object)null || (Object)(object)trailSegment.Target?.Phys == (Object)null) { DestroyTrail(trailSegment); _trails.RemoveAt(num); } else { PinBeamMarker(trailSegment.Source, trailSegment.Start); PinBeamMarker(trailSegment.Target, trailSegment.End); if ((Object)(object)trailSegment.Source.Toggle == (Object)null || (Object)(object)trailSegment.Target.Toggle == (Object)null) { LogTrailAttachFailure(trailSegment, "a native toggle component was missing"); } else { if (!trailSegment.Source.Toggle.toggleState || !trailSegment.Target.Toggle.toggleState) { TryToggle(trailSegment.Source, value: true); TryToggle(trailSegment.Target, value: true); trailSegment.Toggled = true; trailSegment.Warmup = 0.28f; } else { trailSegment.Warmup -= Time.deltaTime; if (trailSegment.Warmup <= 0f && (!trailSegment.Attached || Time.time >= trailSegment.NextAttachRefreshAt)) { string failure; bool flag = (trailSegment.Attached = AttachBeam(trailSegment.Source, trailSegment.Target, trailSegment.End, out failure)); trailSegment.NextAttachRefreshAt = Time.time + 0.16f; if (!flag) { LogTrailAttachFailure(trailSegment, failure); } } } StunTrailContacts(trailSegment); } } } CommitTrailPlayerCapsules(); } private static void LogTrailAttachFailure(TrailSegment trail, string failure) { if (trail != null && !(Time.time < trail.NextAttachLogAt)) { trail.NextAttachLogAt = Time.time + 2f; Plugin.Log.LogWarning((object)("The Backlash native trail is waiting to attach: " + failure)); } } private static void PinBeamMarker(MarionetteDronePart marker, Vector3 point) { //IL_0083: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) if ((Object)(object)marker?.Phys == (Object)null) { return; } Rigidbody rb = marker.Phys.rb; if ((Object)(object)rb != (Object)null) { rb.useGravity = false; rb.detectCollisions = false; if (rb.isKinematic) { rb.isKinematic = false; } rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; } marker.Phys.OverrideGrabDisable(0.3f); marker.Phys.OverrideIndestructible(0.3f); marker.Phys.SetPositionLogic(point - marker.BeamStartOffset, Quaternion.identity); } private static void TryToggle(MarionetteDronePart marker, bool value) { try { if ((Object)(object)marker?.Toggle != (Object)null && marker.Toggle.toggleState != value) { marker.Toggle.ToggleItem(value, -1); } } catch { } } private static bool AttachBeam(MarionetteDronePart source, MarionetteDronePart target, Vector3 end, out string failure) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (NewRayHitPointMethod == null || (Object)(object)source?.Drone == (Object)null || (Object)(object)target?.Phys == (Object)null) { failure = "the ItemDrone reflection method or endpoint physics was unavailable"; return false; } PhotonView val = target.View ?? ((Component)target.Phys).GetComponentInParent(); PhysGrabObjectCollider componentInChildren = ((Component)target.Phys).GetComponentInChildren(true); if ((Object)(object)val == (Object)null || (Object)(object)componentInChildren == (Object)null || (GameManager.Multiplayer() && val.ViewID == 0)) { failure = "the network endpoint had no ready PhotonView/collider"; return false; } try { NewRayHitPointMethod.Invoke(source.Drone, new object[4] { end, val.ViewID, componentInChildren.colliderID, ((Component)target.Phys).transform }); source.Drone.MagnetActiveToggle(true); source.Drone.StateSet((State)3); failure = null; return true; } catch (Exception ex) { failure = ex.GetBaseException().Message; return false; } } private void StunTrailContacts(TrailSegment trail) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00f4: 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_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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (!GunAccess.IsLiving(item)) { continue; } int num = PlayerId(item); if (!_currentTrailPlayerCapsules.TryGetValue(num, out var value)) { value = BuildTrailPlayerCapsule(item); } TrailPlayerCapsule value2; TrailPlayerCapsule previous = (_previousTrailPlayerCapsules.TryGetValue(num, out value2) ? value2 : value); if (!TrailTouchesPlayer(trail, previous, value) || (_trailStunCooldown.TryGetValue(num, out var value3) && Time.time < value3)) { continue; } _trailStunCooldown[num] = Time.time + 1.9f; EmitTrailNoise(item, num); PlayerTumble val = FindPlayerTumble(item); if (!((Object)(object)val == (Object)null)) { Vector3 val2 = trail.End - trail.Start; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = Vector3.forward; } val.TumbleRequest(true, false); val.TumbleForce(((Vector3)(ref val2)).normalized * 5.3f + Vector3.up * 2.15f); } } } private void CaptureTrailPlayerCapsules() { _currentTrailPlayerCapsules.Clear(); foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { _currentTrailPlayerCapsules[PlayerId(item)] = BuildTrailPlayerCapsule(item); } } } private void CommitTrailPlayerCapsules() { _previousTrailPlayerCapsules.Clear(); foreach (KeyValuePair currentTrailPlayerCapsule in _currentTrailPlayerCapsules) { _previousTrailPlayerCapsules[currentTrailPlayerCapsule.Key] = currentTrailPlayerCapsule.Value; } } private static TrailPlayerCapsule BuildTrailPlayerCapsule(PlayerAvatar player) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_002a: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_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_0082: 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_008d: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)player != (Object)null) ? ((Component)player).transform.position : Vector3.zero) + Vector3.up * 0.08f; Vector3 val2 = PlayerAimPoint(player); float num = Mathf.Clamp(val2.y - val.y, 0.72f, 1.78f); ((Vector3)(ref val2))..ctor(val2.x, val.y + num, val2.z); return new TrailPlayerCapsule { Foot = val, Waist = Vector3.Lerp(val, val2, 0.38f), Chest = Vector3.Lerp(val, val2, 0.68f), Head = val2 }; } private static bool TrailTouchesPlayer(TrailSegment trail, TrailPlayerCapsule previous, TrailPlayerCapsule current) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_001e: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0080: 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_0094: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if (trail == null) { return false; } float num = 0.5776f; if (DistanceSquaredBetweenSegments(trail.Start, trail.End, current.Foot, current.Head) <= num || DistanceSquaredBetweenSegments(trail.Start, trail.End, previous.Foot, previous.Head) <= num) { return true; } if (!(DistanceSquaredBetweenSegments(trail.Start, trail.End, previous.Foot, current.Foot) <= num) && !(DistanceSquaredBetweenSegments(trail.Start, trail.End, previous.Waist, current.Waist) <= num) && !(DistanceSquaredBetweenSegments(trail.Start, trail.End, previous.Chest, current.Chest) <= num)) { return DistanceSquaredBetweenSegments(trail.Start, trail.End, previous.Head, current.Head) <= num; } return true; } private void EmitTrailNoise(PlayerAvatar player, int playerId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0043: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null) && !((Object)(object)EnemyDirector.instance == (Object)null) && SemiFunc.IsMasterClientOrSingleplayer()) { Vector3 val = ((Component)player).transform.position + Vector3.up * 0.2f; EnemyDirector.instance.SetInvestigate(val, 10.5f, false); if (!_trailNoiseLogged) { _trailNoiseLogged = true; Plugin.Log.LogInfo((object)$"The Backlash red trail emitted its first host AI-noise event for player {playerId}: radius {10.5f:0.0}m, cooldown {1.9f:0.0}s."); } } } private static void DestroyTrail(TrailSegment trail) { if (trail != null) { MarionetteSpawner.DestroyDrone(trail.Source); MarionetteSpawner.DestroyDrone(trail.Target); } } private void DestroyTrails() { foreach (TrailSegment trail in _trails) { DestroyTrail(trail); } _trails.Clear(); _trailBatchReleaseAt = -1f; _previousTrailPlayerCapsules.Clear(); _currentTrailPlayerCapsules.Clear(); } private void UpdateJackhammerAnimation() { Animator val = _spawned?.JackhammerAnimator; if (!((Object)(object)val == (Object)null)) { if (_state == BacklashState.Windup) { float num = Mathf.Repeat((2.8f - Mathf.Max(0f, _stateTimer)) / 0.16f, 1f); val.speed = 0f; val.Play("JackhammerJackin", 0, num); _jackhammerWarningActive = true; } else if (_jackhammerWarningActive) { val.speed = 1f; val.CrossFade("Jackhammer Idle", 0.1f, 0, 0f); _jackhammerWarningActive = false; } } } private void PinParts(bool immediate) { //IL_0071: 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_0093: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: 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_01bd: 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_01c4: 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_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: 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_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: 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_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039e: 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_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: 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) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: 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_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: 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_0500: Unknown result type (might be due to invalid IL or missing references) //IL_0505: 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_052b: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_0561: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_0580: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_059d: Unknown result type (might be due to invalid IL or missing references) //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_05a4: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Unknown result type (might be due to invalid IL or missing references) //IL_05c4: Unknown result type (might be due to invalid IL or missing references) //IL_05d7: Unknown result type (might be due to invalid IL or missing references) //IL_05d9: Unknown result type (might be due to invalid IL or missing references) //IL_05db: Unknown result type (might be due to invalid IL or missing references) //IL_05dd: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_05fa: Unknown result type (might be due to invalid IL or missing references) //IL_05ff: Unknown result type (might be due to invalid IL or missing references) //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_060a: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0622: Unknown result type (might be due to invalid IL or missing references) //IL_0624: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Unknown result type (might be due to invalid IL or missing references) //IL_0628: Unknown result type (might be due to invalid IL or missing references) //IL_062f: Unknown result type (might be due to invalid IL or missing references) if (_spawned?.Parts != null && _spawned.Parts.Count >= 5) { float time = Time.time; float num = time * 2.65f; float num2 = ((_state == BacklashState.Roam) ? (Mathf.Sin(num) * 0.14f) : (Mathf.Sin(time * 8.5f) * 0.035f)); Vector3 val = ((!(((Vector3)(ref _visualForward)).sqrMagnitude > 0.01f)) ? Vector3.forward : ((_state == BacklashState.Roam) ? HorizontalDirection(_visualForward) : ((Vector3)(ref _visualForward)).normalized)); Vector3 val2 = Vector3.Cross(Vector3.up, val); Vector3 val3 = ((Vector3)(ref val2)).normalized; if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = Vector3.right; } float num3 = ((_state == BacklashState.Roam) ? (Mathf.Sin(num * 0.72f) * 10f) : 0f); float num4 = ((_state == BacklashState.Roam) ? (Mathf.Sin(num * 0.9f + 0.7f) * 20f) : ((_state == BacklashState.Windup) ? (Mathf.Sin(num * 0.75f + 0.4f) * 7f + DirectionBank(_visualForward, val, 9f)) : _visualBankTarget)); if (_state != BacklashState.BounceEmbed && _state != BacklashState.BounceOut && _state != BacklashState.BounceAim) { _visualBankRoll = Mathf.SmoothDamp(_visualBankRoll, num4, ref _visualBankVelocity, 0.11f); } else { _visualBankVelocity = 0f; } Vector3 val4; if (_state != BacklashState.Roam) { val2 = Vector3.Cross(val, val3); val4 = ((Vector3)(ref val2)).normalized; } else { val4 = Vector3.up; } Vector3 val5 = val4; Vector3 val6 = Quaternion.AngleAxis(_visualBankRoll, val) * val5; Vector3 val7 = Quaternion.AngleAxis(num3, val3) * val; val2 = Vector3.Cross(val6, val7); Vector3 val8 = ((Vector3)(ref val2)).normalized; if (((Vector3)(ref val8)).sqrMagnitude < 0.01f) { val8 = val3; } Vector3 val9 = val6; if (_visualSpinMovingThisFrame) { float num5 = ((_state == BacklashState.Rewind) ? 420f : 480f); _visualSpinRoll = Mathf.Repeat(_visualSpinRoll + num5 * Time.deltaTime, 360f); } float num6 = _roamBlend * _roamBlend * (3f - 2f * _roamBlend); Quaternion val10 = Quaternion.AngleAxis((_state == BacklashState.Roam) ? (Mathf.DeltaAngle(0f, _visualSpinRoll) * (1f - num6)) : _visualSpinRoll, val7); val6 = val10 * val6; val8 = val10 * val8; Vector3 val11 = HitCenter + Vector3.up * num2 + _visualEmbedOffset + val7 * (Mathf.Sin(num * 0.72f) * 0.06f); float num7 = ((_state == BacklashState.Roam) ? Mathf.Lerp(0.26f, 0.92f, num6) : 0.2f); if (_state == BacklashState.Windup) { float num8 = Mathf.Clamp01(1f - Mathf.Max(0f, _stateTimer) / 0.58f); float num9 = num8 * num8 * (3f - 2f * num8); num7 = Mathf.Lerp(0.9f, 0.2f, num9); } else if (_state == BacklashState.Rewind || _state == BacklashState.RewindPause) { num7 = 0.26f; } val2 = val7 * (1f - num7 * 0.78f) + val9 * num7; Vector3 normalized = ((Vector3)(ref val2)).normalized; Vector3 val12 = val10 * normalized; CurrentVisualSquash(out var axialScale, out var lateralScale, out var axis); bool immediate2 = true; Quaternion rotation = val10 * AlignLongAxis(_spawned.Parts[0].LongAxisLocal, normalized, val); PinPart(_spawned.Parts[0], val11, rotation, immediate2, axis, axialScale, lateralScale); float num10 = Mathf.Sin(num * 1.15f) * 0.07f; Vector3 val13 = -val12; Vector3 val14 = val12; Vector3 val15 = val11 + val14 * 0.48f - val6 * 0.06f; Vector3 visualCenter = ScaleContainerPoint(val11, val15 - val8 * 0.34f, axis, axialScale, lateralScale); SpawnedDeadAirPart part = _spawned.Parts[1]; Vector3 longAxisLocal = _spawned.Parts[1].LongAxisLocal; val2 = val14 * 0.62f - val8 * 0.57f - val6 * (0.18f + num10); PinPart(part, visualCenter, AlignLongAxis(longAxisLocal, ((Vector3)(ref val2)).normalized, val14), immediate2, axis, axialScale, lateralScale); Vector3 visualCenter2 = ScaleContainerPoint(val11, val15 + val8 * 0.34f, axis, axialScale, lateralScale); SpawnedDeadAirPart part2 = _spawned.Parts[2]; Vector3 longAxisLocal2 = _spawned.Parts[2].LongAxisLocal; val2 = val14 * 0.62f + val8 * 0.57f - val6 * (0.18f - num10); PinPart(part2, visualCenter2, AlignLongAxis(longAxisLocal2, ((Vector3)(ref val2)).normalized, val14), immediate2, axis, axialScale, lateralScale); Vector3 val16 = val11 + val13 * 0.045f - val6 * 0.05f; Vector3 visualCenter3 = ScaleContainerPoint(val11, val16 - val8 * 0.245f, axis, axialScale, lateralScale); PinPart(_spawned.Parts[3], visualCenter3, Quaternion.LookRotation(val13, val6), immediate2, axis, axialScale, lateralScale); Vector3 visualCenter4 = ScaleContainerPoint(val11, val16 + val8 * 0.245f, axis, axialScale, lateralScale); PinPart(_spawned.Parts[4], visualCenter4, Quaternion.LookRotation(val13, val6), immediate2, axis, axialScale, lateralScale); } } private static void PinPart(SpawnedDeadAirPart part, Vector3 visualCenter, Quaternion rotation, bool immediate, Vector3 squashAxis, float axialScale, float lateralScale) { //IL_003a: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0071: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)part?.Phys == (Object)null) && part.Alive) { if (part.GeometryCalibrationFrames > 0) { DeadAirSpawner.RefreshRenderedGeometry(part); part.GeometryCalibrationFrames--; } Vector3 val = LocalSquashFactors(rotation, squashAxis, axialScale, lateralScale); Vector3 val2 = ((((Vector3)(ref part.BaseScale)).sqrMagnitude > 0.0001f) ? part.BaseScale : part.Root.transform.localScale); part.Root.transform.localScale = Vector3.Scale(val2, val); Vector3 val3 = visualCenter - rotation * Vector3.Scale(part.VisualCenterOffset, val); Vector3 val4 = (immediate ? val3 : Vector3.Lerp(((Component)part.Phys).transform.position, val3, 1f - Mathf.Exp((0f - Time.deltaTime) * 22f))); Quaternion val5 = (immediate ? rotation : Quaternion.Slerp(((Component)part.Phys).transform.rotation, rotation, 1f - Mathf.Exp((0f - Time.deltaTime) * 24f))); part.ImpactDetector.destroyDisable = true; part.Phys.OverrideGrabDisable(0.3f); part.Phys.OverrideKinematic(0.3f); part.Phys.OverrideIndestructible(0.3f); part.Phys.SetPositionLogic(val4, val5); } } private void CurrentVisualSquash(out float axialScale, out float lateralScale, out Vector3 axis) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) axis = ((((Vector3)(ref _impactVisualAxis)).sqrMagnitude > 0.001f) ? ((Vector3)(ref _impactVisualAxis)).normalized : ((Vector3)(ref _visualForward)).normalized); axialScale = 1f; lateralScale = 1f; if (_state == BacklashState.Rewind) { int num = NextRewindReflectionIndex(); if (num < 0) { return; } Vector3 val = _route[num] - ((Component)this).transform.position; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 1.4f) { float num2 = Mathf.Clamp01(1f - magnitude / 1.4f); num2 = num2 * num2 * (3f - 2f * num2); axialScale = Mathf.Lerp(1f, 1.07f, num2); lateralScale = Mathf.Lerp(1f, 0.985f, num2); if (((Vector3)(ref val)).sqrMagnitude > 0.0001f) { axis = ((Vector3)(ref val)).normalized; } } } else if (_state == BacklashState.RewindPause && _rewindBounceActive) { float num3 = Mathf.Clamp(0.36f - Mathf.Max(0f, _stateTimer), 0f, 0.36f); if (num3 < 0.08f) { float num4 = num3 / 0.08f; num4 = num4 * num4 * (3f - 2f * num4); axialScale = Mathf.Lerp(1.07f, 0.8f, num4); lateralScale = Mathf.Lerp(0.985f, 1.06f, num4); } else if (num3 < 0.18f) { axialScale = 0.8f; lateralScale = 1.06f; } else if (num3 < 0.3f) { float num5 = (num3 - 0.18f) / 0.12f; num5 = num5 * num5 * (3f - 2f * num5); axialScale = Mathf.Lerp(0.8f, 1.04f, num5); lateralScale = Mathf.Lerp(1.06f, 0.99f, num5); } else { float num6 = (num3 - 0.3f) / 0.06f; num6 = Mathf.Clamp01(num6); num6 = num6 * num6 * (3f - 2f * num6); axialScale = Mathf.Lerp(1.04f, 1f, num6); lateralScale = Mathf.Lerp(0.99f, 1f, num6); } } else if (_state == BacklashState.BounceEmbed) { float num7 = Mathf.Clamp01(1f - Mathf.Max(0f, _stateTimer) / 0.08f); num7 = Mathf.Max(0.28f, num7); num7 = num7 * num7 * (3f - 2f * num7); axialScale = Mathf.Lerp(1f, 0.7f, num7); lateralScale = Mathf.Lerp(1f, 1.14f, num7); } else if (_state == BacklashState.BounceOut) { float num8 = Mathf.Clamp01(1f - Mathf.Max(0f, _stateTimer) / 0.12f); if (num8 < 0.72f) { float num9 = Mathf.Clamp01(num8 / 0.72f); num9 = num9 * num9 * (3f - 2f * num9); axialScale = Mathf.Lerp(0.7f, 1.1f, num9); lateralScale = Mathf.Lerp(1.14f, 0.975f, num9); } else { float num10 = Mathf.Clamp01((num8 - 0.72f) / 0.28f); num10 = num10 * num10 * (3f - 2f * num10); axialScale = Mathf.Lerp(1.1f, 1f, num10); lateralScale = Mathf.Lerp(0.975f, 1f, num10); } } } private int NextRewindReflectionIndex() { for (int num = _reflectionRouteIndices.Count - 1; num >= 0; num--) { int num2 = _reflectionRouteIndices[num]; if (num2 <= _rewindIndex) { return num2; } } return -1; } private static Vector3 ScaleContainerPoint(Vector3 center, Vector3 point, Vector3 axis, float axialScale, float lateralScale) { //IL_0017: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //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_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) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref axis)).sqrMagnitude < 0.001f) { return point; } ((Vector3)(ref axis)).Normalize(); Vector3 val = point - center; Vector3 val2 = axis * Vector3.Dot(val, axis); Vector3 val3 = val - val2; return center + val2 * axialScale + val3 * lateralScale; } private static Vector3 LocalSquashFactors(Quaternion rotation, Vector3 worldAxis, float axialScale, float lateralScale) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0058: 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_000e: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref worldAxis)).sqrMagnitude < 0.001f) { return Vector3.one; } ((Vector3)(ref worldAxis)).Normalize(); Vector3 val = Quaternion.Inverse(rotation) * worldAxis; return new Vector3(Mathf.Lerp(lateralScale, axialScale, val.x * val.x), Mathf.Lerp(lateralScale, axialScale, val.y * val.y), Mathf.Lerp(lateralScale, axialScale, val.z * val.z)); } private static Quaternion AlignLongAxis(Vector3 localAxis, Vector3 worldDirection, Vector3 desiredUp) { //IL_0017: 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_001c: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0056: 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_005c: 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_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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((((Vector3)(ref localAxis)).sqrMagnitude > 0.001f) ? ((Vector3)(ref localAxis)).normalized : Vector3.up); Quaternion val2 = Quaternion.FromToRotation(val, worldDirection); Vector3 val3 = ((Mathf.Abs(Vector3.Dot(val, Vector3.up)) < 0.9f) ? Vector3.up : Vector3.forward); Vector3 val4 = Vector3.ProjectOnPlane(val2 * val3, worldDirection); Vector3 val5 = Vector3.ProjectOnPlane(desiredUp, worldDirection); if (((Vector3)(ref val4)).sqrMagnitude < 0.001f || ((Vector3)(ref val5)).sqrMagnitude < 0.001f) { return val2; } return Quaternion.AngleAxis(Vector3.SignedAngle(val4, val5, worldDirection), worldDirection) * val2; } private bool TryFindWallHit(Vector3 controllerPosition, Vector3 direction, float distance, out RaycastHit result) { //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) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0019: 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) Vector3 origin = controllerPosition + Vector3.up * 1.08f; int layerMask = -1; return TryFindWallHit(origin, direction, distance, layerMask, out result); } private bool TryFindWallHit(Vector3 origin, Vector3 direction, float distance, int layerMask, out RaycastHit result) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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) bool found = false; float nearest = float.PositiveInfinity; result = default(RaycastHit); RaycastHit[] hits = Physics.SphereCastAll(origin, 0.3f, direction, distance, layerMask, (QueryTriggerInteraction)1); ConsiderWallHits(hits, direction, ref found, ref nearest, ref result); RaycastHit[] hits2 = Physics.RaycastAll(origin, direction, distance, layerMask, (QueryTriggerInteraction)1); ConsiderWallHits(hits2, direction, ref found, ref nearest, ref result); return found; } private bool TryFindSolidOverlap(Vector3 controllerPosition, out Collider result) { //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) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0016: 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_004e: 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) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) Vector3 val = controllerPosition + Vector3.up * 1.08f; Collider[] array = Physics.OverlapSphere(val, 0.29400003f, -1, (QueryTriggerInteraction)1); result = null; float num = float.PositiveInfinity; if (array == null) { array = Array.Empty(); } Collider[] array2 = array; foreach (Collider val2 in array2) { if (!TryClassifyChargeBlocker(val2, out var reason)) { continue; } Vector3 val3 = val2.ClosestPoint(val) - val; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (!(sqrMagnitude >= num)) { num = sqrMagnitude; result = val2; if (Time.time >= _nextHitAuditAt) { _nextHitAuditAt = Time.time + 0.8f; LogColliderAudit(val2, 0f, accepted: true, "endpoint overlap verification: " + reason); } } } return (Object)(object)result != (Object)null; } private void ConsiderWallHits(RaycastHit[] hits, Vector3 direction, ref bool found, ref float nearest, ref RaycastHit result) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) if (hits == null) { return; } Array.Sort(hits, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); for (int num = 0; num < hits.Length; num++) { RaycastHit val = hits[num]; if (((RaycastHit)(ref val)).distance <= 0.001f) { Vector3 normal = ((RaycastHit)(ref val)).normal; if (((Vector3)(ref normal)).sqrMagnitude > 0.01f && Vector3.Dot(direction, ((RaycastHit)(ref val)).normal) > 0.05f) { continue; } } string reason; bool flag = TryClassifyChargeBlocker(((RaycastHit)(ref val)).collider, out reason); if (!(reason == "registered Backlash part") && !(reason == "owned mod network helper/visual") && Time.time >= _nextHitAuditAt) { _nextHitAuditAt = Time.time + 0.8f; LogChargeHitAudit(val, flag, reason); } if (flag && !(((RaycastHit)(ref val)).distance >= nearest)) { result = val; nearest = ((RaycastHit)(ref val)).distance; found = true; } } } private void DamagePlayersAlongSegment(Vector3 start, Vector3 end, float radius) { //IL_0004: 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_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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) float num = radius * radius; Vector3 start2 = start + Vector3.up * 1.08f; Vector3 end2 = end + Vector3.up * 1.08f; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item) && DistanceSquaredToSegment(PlayerAimPoint(item), start2, end2) <= num) { DamagePlayer(item); } } } private void ArmChargeLeg() { _chargeLegId++; _damagedPlayersThisLeg.Clear(); _suppressedDamageLogThisLeg.Clear(); Plugin.Log.LogInfo((object)$"The Backlash charge segment {_chargeLegId}/{10} rearmed direct sweep damage (55)."); } private void ArmRewindSegment(int routeIndex) { if (_rewindDamageSegmentIndex != routeIndex) { _rewindDamageSegmentIndex = routeIndex; _damagedPlayersThisRewindLeg.Clear(); Plugin.Log.LogInfo((object)$"The Backlash rewind segment {routeIndex} rearmed direct sweep damage (55)."); } } private void DamagePlayersAlongRewindSegment(Vector3 start, Vector3 end, Vector3 motion, int routeIndex) { //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) //IL_0002: 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_0038: 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_0043: 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_004d: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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) Vector3 val = end - start; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { return; } float num = Mathf.Clamp(Plugin.Settings.PlaybackContactRadius.Value, 0.55f, 1.8f); float num2 = num * num; Vector3 start2 = start + Vector3.up * 1.08f; Vector3 end2 = end + Vector3.up * 1.08f; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item) && !(DistanceSquaredToSegment(PlayerAimPoint(item), start2, end2) > num2)) { DamageRewindPlayer(item, motion, routeIndex); } } } private void DamageRewindPlayer(PlayerAvatar player, Vector3 motion, int routeIndex) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_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) if (!GunAccess.IsLiving(player) || (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient)) { return; } int num = PlayerId(player); if (_rewindPlayersDamagedThisFrame.Add(num) && _damagedPlayersThisRewindLeg.Add(num)) { int num2 = Mathf.Max(55, Plugin.Settings.PlaybackContactDamage.Value); PlayerHealth playerHealth = player.playerHealth; if (playerHealth != null) { playerHealth.HurtOther(num2, PlayerAimPoint(player), false, -1, false); } Plugin.Log.LogInfo((object)$"The Backlash rewind segment {routeIndex} hit player {num}: {num2}."); PlayerTumble val = FindPlayerTumble(player); if ((Object)(object)val != (Object)null) { Vector3 val2 = ((((Vector3)(ref motion)).sqrMagnitude > 0.001f) ? ((Vector3)(ref motion)).normalized : (-_chargeDirection)); val2.y = Mathf.Max(0.08f, val2.y); val.TumbleRequest(true, false); val.TumbleForce(((Vector3)(ref val2)).normalized * 11f + Vector3.up * 2f); } BodyImpact(145f); } } private void DamagePlayer(PlayerAvatar player) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00dc: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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) if (!GunAccess.IsLiving(player) || (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient)) { return; } int num = PlayerId(player); if (!_damagedPlayersThisLeg.Add(num)) { if (_suppressedDamageLogThisLeg.Add(num)) { Plugin.Log.LogInfo((object)$"The Backlash leg {_chargeLegId} damage suppressed for player {num}; already applied this leg."); } return; } int num2 = Mathf.Max(55, Plugin.Settings.PlaybackContactDamage.Value); PlayerHealth playerHealth = player.playerHealth; if (playerHealth != null) { playerHealth.HurtOther(num2, PlayerAimPoint(player), false, -1, false); } Plugin.Log.LogInfo((object)$"The Backlash leg {_chargeLegId} damage applied to player {num}: {num2}."); PlayerTumble val = FindPlayerTumble(player); if ((Object)(object)val != (Object)null) { Vector3 chargeDirection = _chargeDirection; chargeDirection.y = Mathf.Max(0.08f, chargeDirection.y); val.TumbleRequest(true, false); val.TumbleForce(((Vector3)(ref chargeDirection)).normalized * 12f + Vector3.up * 2.2f); } BodyImpact(145f); } private static int PlayerId(PlayerAvatar player) { if (!((Object)(object)player.photonView != (Object)null) || player.photonView.ViewID == 0) { return ((Object)player).GetInstanceID(); } return player.photonView.ViewID; } private PlayerAvatar FindNearestPlayer(float range) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) PlayerAvatar result = null; float num = range * range; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item) && HasLineOfSight(item)) { Vector3 val = PlayerAimPoint(item) - HitCenter; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (!(sqrMagnitude >= num)) { num = sqrMagnitude; result = item; } } } return result; } private static Vector3 HorizontalDirection(Vector3 direction) { //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) direction.y = 0f; if (!(((Vector3)(ref direction)).sqrMagnitude > 0.0001f)) { return Vector3.forward; } return ((Vector3)(ref direction)).normalized; } private static Vector3 SafeChargeDirection(Vector3 direction) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref direction)).sqrMagnitude > 0.0001f) { return ((Vector3)(ref direction)).normalized; } return Vector3.forward; } private bool HasLineOfSight(PlayerAvatar player) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_003c: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_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_00cf: 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_00d9: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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) if (!GunAccess.IsLiving(player)) { return false; } TrailPlayerCapsule trailPlayerCapsule = BuildTrailPlayerCapsule(player); Vector3 val = ((((Vector3)(ref _visualForward)).sqrMagnitude > 0.01f) ? ((Vector3)(ref _visualForward)).normalized : ((Component)this).transform.forward); Vector3 val2 = Vector3.Cross(Vector3.up, val); if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = ((Component)this).transform.right; } ((Vector3)(ref val2)).Normalize(); Vector3[] array = (Vector3[])(object)new Vector3[3] { HitCenter, HitCenter - Vector3.up * 0.1f - val2 * 0.26f, HitCenter - Vector3.up * 0.1f + val2 * 0.26f }; Vector3[] array2 = (Vector3[])(object)new Vector3[2] { trailPlayerCapsule.Chest, trailPlayerCapsule.Head }; Vector3[] array3 = array; foreach (Vector3 origin in array3) { Vector3[] array4 = array2; foreach (Vector3 target in array4) { if (IsSolidLineClear(origin, target)) { return true; } } } if (Time.time >= _nextLosLogAt) { _nextLosLogAt = Time.time + 5f; Plugin.Log.LogInfo((object)$"The Backlash ignored player {PlayerId(player)} behind solid geometry; all body/eye-to-chest/head rays were blocked."); } return false; } private bool IsSolidLineClear(Vector3 origin, Vector3 target) { //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) //IL_0002: 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_0018: 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_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) Vector3 val = target - origin; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { return true; } RaycastHit[] array = Physics.RaycastAll(origin, ((Vector3)(ref val)).normalized, ((Vector3)(ref val)).magnitude, -1, (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val2 = array2[num]; if (IsVisionBlocker(((RaycastHit)(ref val2)).collider)) { return false; } } return true; } private bool IsVisionBlocker(Collider collider) { if (!TryClassifyChargeBlocker(collider, out var _)) { return false; } Rigidbody val = (((Object)(object)collider != (Object)null) ? collider.attachedRigidbody : null); if (!((Object)(object)val == (Object)null)) { return val.isKinematic; } return true; } private bool IsOwnCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } Transform transform = ((Component)collider).transform; if ((Object)(object)transform == (Object)(object)((Component)this).transform || transform.IsChildOf(((Component)this).transform)) { return true; } if (_spawned?.Parts != null) { foreach (SpawnedDeadAirPart part in _spawned.Parts) { if ((Object)(object)part?.Root != (Object)null && ((Object)(object)transform == (Object)(object)part.Root.transform || transform.IsChildOf(part.Root.transform))) { return true; } } } foreach (TrailSegment trail in _trails) { if (((Object)(object)trail?.Source?.Root != (Object)null && ((Object)(object)transform == (Object)(object)trail.Source.Root.transform || transform.IsChildOf(trail.Source.Root.transform))) || ((Object)(object)trail?.Target?.Root != (Object)null && ((Object)(object)transform == (Object)(object)trail.Target.Root.transform || transform.IsChildOf(trail.Target.Root.transform)))) { return true; } } return false; } private bool IsChargeBlocker(Collider collider) { string reason; return TryClassifyChargeBlocker(collider, out reason); } private bool TryClassifyChargeBlocker(Collider collider, out string reason) { if ((Object)(object)collider == (Object)null) { reason = "null collider"; return false; } if (collider.isTrigger) { reason = "trigger"; return false; } if (IsLevelGeneratorExtraHelper(collider)) { reason = "level generator broad helper"; return false; } if (IsOwnCollider(collider)) { reason = "registered Backlash part"; return false; } if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) { reason = "owned mod network helper/visual"; return false; } if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) { reason = "trail/drone helper"; return false; } if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) { reason = "player"; return false; } if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) { reason = "enemy"; return false; } Rigidbody attachedRigidbody = collider.attachedRigidbody; PhotonView componentInParent = ((Component)collider).GetComponentInParent(); Transform val = (((Object)(object)attachedRigidbody != (Object)null) ? ((Component)attachedRigidbody).transform.root : ((Component)collider).transform.root); if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null || (Object)(object)((Component)collider).GetComponentInParent() != (Object)null || (Object)(object)((Component)collider).GetComponentInParent() != (Object)null || (((Object)(object)attachedRigidbody != (Object)null || (Object)(object)componentInParent != (Object)null) && LooksLikeLooseValuable((val != null) ? ((Object)val).name : null))) { reason = "valuable/dynamic physics object"; return false; } if ((Object)(object)attachedRigidbody != (Object)null) { reason = (attachedRigidbody.isKinematic ? "solid kinematic structure" : "solid non-valuable Rigidbody obstruction"); return true; } if ((Object)(object)componentInParent != (Object)null) { reason = "solid networked room structure"; return true; } reason = "static level geometry"; return true; } private static bool LooksLikeLooseValuable(string value) { if (string.IsNullOrEmpty(value)) { return false; } if (value.IndexOf("valuable", StringComparison.OrdinalIgnoreCase) < 0 && value.IndexOf("item ", StringComparison.OrdinalIgnoreCase) < 0) { return value.IndexOf("item_", StringComparison.OrdinalIgnoreCase) >= 0; } return true; } private static bool IsLevelGeneratorExtraHelper(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } if (!(((Object)collider).name ?? string.Empty).StartsWith("Extra", StringComparison.OrdinalIgnoreCase)) { return false; } Transform root = ((Component)collider).transform.root; return (((Object)(object)root != (Object)null) ? ((Object)root).name : string.Empty).IndexOf("Level Generator", StringComparison.OrdinalIgnoreCase) >= 0; } private static void LogChargeHitAudit(RaycastHit hit, bool accepted, string reason) { Collider collider = ((RaycastHit)(ref hit)).collider; if (!((Object)(object)collider == (Object)null)) { LogColliderAudit(collider, ((RaycastHit)(ref hit)).distance, accepted, reason); } } private static void LogColliderAudit(Collider collider, float distance, bool accepted, string reason) { if (!((Object)(object)collider == (Object)null)) { Rigidbody attachedRigidbody = collider.attachedRigidbody; PhotonView componentInParent = ((Component)collider).GetComponentInParent(); Transform val = (((Object)(object)attachedRigidbody != (Object)null) ? ((Component)attachedRigidbody).transform.root : ((Component)collider).transform.root); Plugin.Log.LogWarning((object)("The Backlash hit audit: " + (accepted ? "ACCEPT" : "REJECT") + " " + $"collider='{((Object)collider).name}', root='{((val != null) ? ((Object)val).name : null)}', layer={((Component)collider).gameObject.layer}, " + $"distance={distance:0.000}, trigger={collider.isTrigger}, " + string.Format("rb='{0}', kinematic={1}, ", ((attachedRigidbody != null) ? ((Object)attachedRigidbody).name : null) ?? "none", (Object)(object)attachedRigidbody != (Object)null && attachedRigidbody.isKinematic) + $"photon={(((Object)(object)componentInParent != (Object)null) ? componentInParent.ViewID : 0)}, reason={reason}.")); } } private static bool IsFinite(Vector3 value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(value.x) && !float.IsNaN(value.y) && !float.IsNaN(value.z) && !float.IsInfinity(value.x) && !float.IsInfinity(value.y)) { return !float.IsInfinity(value.z); } return false; } private static Vector3 PlayerAimPoint(PlayerAvatar player) { //IL_005a: 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_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_0029: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player?.PlayerVisionTarget?.VisionTransform != (Object)null)) { if (!((Object)(object)player != (Object)null)) { return Vector3.zero; } return ((Component)player).transform.position + Vector3.up * 0.72f; } return player.PlayerVisionTarget.VisionTransform.position; } private static float DistanceSquaredToSegment(Vector3 point, Vector3 start, Vector3 end) { //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) //IL_0002: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_002f: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; Vector3 val2; if (sqrMagnitude < 0.0001f) { val2 = point - start; return ((Vector3)(ref val2)).sqrMagnitude; } float num = Mathf.Clamp01(Vector3.Dot(point - start, val) / sqrMagnitude); val2 = point - (start + val * num); return ((Vector3)(ref val2)).sqrMagnitude; } private static float DistanceSquaredBetweenSegments(Vector3 firstStart, Vector3 firstEnd, Vector3 secondStart, Vector3 secondEnd) { //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) //IL_0002: 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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_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) Vector3 val = firstEnd - firstStart; Vector3 val2 = secondEnd - secondStart; Vector3 val3 = firstStart - secondStart; float num = Vector3.Dot(val, val); float num2 = Vector3.Dot(val2, val2); float num3 = Vector3.Dot(val2, val3); if (num <= 1E-06f && num2 <= 1E-06f) { return ((Vector3)(ref val3)).sqrMagnitude; } float num4; float num5; if (num <= 1E-06f) { num4 = 0f; num5 = Mathf.Clamp01(num3 / num2); } else { float num6 = Vector3.Dot(val, val3); if (num2 <= 1E-06f) { num5 = 0f; num4 = Mathf.Clamp01((0f - num6) / num); } else { float num7 = Vector3.Dot(val, val2); float num8 = num * num2 - num7 * num7; num4 = ((num8 > 1E-06f) ? Mathf.Clamp01((num7 * num3 - num6 * num2) / num8) : 0f); num5 = (num7 * num4 + num3) / num2; if (num5 < 0f) { num5 = 0f; num4 = Mathf.Clamp01((0f - num6) / num); } else if (num5 > 1f) { num5 = 1f; num4 = Mathf.Clamp01((num7 - num6) / num); } } } Vector3 val4 = firstStart + val * num4; Vector3 val5 = secondStart + val2 * num5; Vector3 val6 = val4 - val5; return ((Vector3)(ref val6)).sqrMagnitude; } private static Vector3 SmoothDirection(Vector3 current, Vector3 target, float speed) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0030: 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_004d: 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) if (((Vector3)(ref target)).sqrMagnitude < 0.001f) { return current; } Vector3 val = Vector3.Slerp((((Vector3)(ref current)).sqrMagnitude > 0.001f) ? ((Vector3)(ref current)).normalized : ((Vector3)(ref target)).normalized, ((Vector3)(ref target)).normalized, 1f - Mathf.Exp((0f - Time.deltaTime) * speed)); return ((Vector3)(ref val)).normalized; } private static float DirectionBank(Vector3 visibleDirection, Vector3 motionDirection, float maximum) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref visibleDirection)).sqrMagnitude < 0.001f || ((Vector3)(ref motionDirection)).sqrMagnitude < 0.001f) { return 0f; } return Mathf.Clamp(Vector3.SignedAngle(visibleDirection, motionDirection, Vector3.up) * 0.34f, 0f - maximum, maximum); } private static PlayerTumble FindPlayerTumble(PlayerAvatar player) { PlayerTumble[] array = Object.FindObjectsOfType(); foreach (PlayerTumble val in array) { if ((Object)(object)val != (Object)null && (Object)(object)val.playerAvatar == (Object)(object)player) { return val; } } return null; } private void UpdateAudio() { if (!(_soundTimer > 0f)) { _soundTimer = ((_state == BacklashState.Windup) ? Random.Range(0.12f, 0.2f) : Random.Range(0.75f, 1.25f)); BodyImpact((_state == BacklashState.Windup) ? 76f : 24f); } } private void BodyImpact(float force) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_spawned?.ImpactDetector != (Object)null && (Object)(object)_spawned.Phys != (Object)null) { _spawned.ImpactDetector.ImpactLight(force, _spawned.Phys.centerPoint); } } private void PlayBounceEffect(Vector3 point) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_spawned?.ImpactDetector == (Object)null || (Object)(object)_spawned.Phys == (Object)null) { return; } _spawned.ImpactDetector.destroyDisable = true; _spawned.ImpactDetector.playerHurtDisable = true; _spawned.ImpactDetector.ImpactLight(38f, point); SpawnedDeadAirPart spawnedDeadAirPart = PlaybackSpawner.SpawnBounceEffect(point); if (spawnedDeadAirPart == null) { if (!_bounceEffectLogged) { _bounceEffectLogged = true; Plugin.Log.LogWarning((object)"The Backlash reflection particle spawn unavailable; retained native light-only fallback."); } return; } if (!_bounceEffectLogged) { _bounceEffectLogged = true; Plugin.Log.LogInfo((object)"The Backlash reflection uses a neutralized network Enemy Valuable small-break particle."); } ((MonoBehaviour)this).StartCoroutine(ReleaseBounceEffect(spawnedDeadAirPart, point)); } private static IEnumerator ReleaseBounceEffect(SpawnedDeadAirPart effect, Vector3 point) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) yield return null; if ((Object)(object)effect?.ImpactDetector != (Object)null && effect.Alive) { effect.ImpactDetector.destroyDisable = false; effect.ImpactDetector.playerHurtDisable = true; effect.ImpactDetector.BreakLight(point, false); } yield return (object)new WaitForSeconds(0.35f); if (effect?.Alive ?? false) { DeadAirSpawner.Destroy(effect); } } private void StopAgent() { if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } } internal bool TryClaimWeaponHit(int sourceId) { if (_dead || !ModEnemyWeaponDamage.TryClaim((Object)(object)this, sourceId) || Time.time - _lastClaimedHit < 0.06f) { return false; } _lastClaimedHit = Time.time; return true; } internal void ReceiveWeaponHit(Vector3 point, int damage) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (!_dead && damage > 0) { _health -= Mathf.Max(1, damage); if (_damageFeedbackCooldown <= 0f) { _damageFeedbackCooldown = 0.08f; ModEnemyFeedback.DamageHit(_spawned?.ImpactDetector, _spawned?.Phys, point, 96f); } if (_health <= 0) { Die(); } } } public void ReceiveTumbleAttack(int partIndex, int damage, Vector3 hitPosition, Vector3 direction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ReceiveWeaponHit(hitPosition, Mathf.Max(1, damage)); } public void OnTranqStunned(float duration) { if (!_dead) { _route.Clear(); BeginRecover(Mathf.Max(0.65f, duration * 0.2f)); } } internal void ExecuteForLab() { if (!_dead) { _health = 0; Die(); } } private void Die() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) if (_dead) { return; } _dead = true; _state = BacklashState.Dead; StopAgent(); if ((Object)(object)_agent != (Object)null) { ((Behaviour)_agent).enabled = false; } foreach (SpawnedDeadAirPart item in _spawned?.Parts ?? new List()) { if (item != null && item.Alive) { ModEnemyFeedback.DamageHit(item.ImpactDetector, item.Phys, item.Phys.centerPoint, 132f); } } DestroyTrails(); PlaybackSpawner.Destroy(_spawned); _spawned = null; _rewardTimer = 0.08f; } private void UpdateDeath() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (_rewardDropped) { return; } _rewardTimer -= Time.deltaTime; if (_rewardTimer > 0f) { return; } _rewardDropped = true; if (Plugin.Settings.PlaybackDropEnemyValuable.Value && !((Object)(object)AssetManager.instance?.enemyValuableMedium == (Object)null)) { GameObject enemyValuableMedium = AssetManager.instance.enemyValuableMedium; Vector3 val = ((Component)this).transform.position + Vector3.up * 0.42f; if (GameManager.Multiplayer()) { PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)enemyValuableMedium).name, val, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate(enemyValuableMedium, val, Quaternion.identity); } } } private void OnDestroy() { if (_initialized && !_cleaning && SemiFunc.IsMasterClientOrSingleplayer()) { _cleaning = true; DestroyTrails(); if (!_dead) { PlaybackSpawner.Destroy(_spawned); } } } } internal sealed class PlaybackHitProxy : MonoBehaviour { private PlaybackController _controller; private SpawnedPlayback _body; private float _cooldown; private readonly Dictionary _previous = new Dictionary(); private readonly HashSet _current = new HashSet(); private static int _bulletFrame = -1; private static ItemGunBullet[] _bullets = Array.Empty(); internal void Initialize(PlaybackController controller, SpawnedPlayback body) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown _controller = controller; _body = body; SpawnedPlayback body2 = _body; if (body2 == null) { return; } PhysGrabObjectImpactDetector impactDetector = body2.ImpactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.AddListener(new UnityAction(OnHurtColliderHit)); } } } private void Update() { _cooldown = Mathf.Max(0f, _cooldown - Time.deltaTime); if (_cooldown <= 0f && SemiFunc.IsMasterClientOrSingleplayer()) { DetectExpandedBulletHit(); } } private void OnDestroy() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown SpawnedPlayback body = _body; if (body == null) { return; } PhysGrabObjectImpactDetector impactDetector = body.ImpactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.RemoveListener(new UnityAction(OnHurtColliderHit)); } } } private void OnHurtColliderHit() { //IL_0072: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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)_controller == (Object)null || _cooldown > 0f || !SemiFunc.IsMasterClientOrSingleplayer() || !_controller.TryClaimWeaponHit(ModEnemyWeaponDamage.CurrentClaimId)) { return; } _cooldown = 0.16f; Vector3 val = (((Object)(object)_body?.Phys != (Object)null) ? _body.Phys.centerPoint : ((Component)this).transform.position); if (EnemyLabBridge.IsExecutionHitNear(val)) { _controller.ExecuteForLab(); return; } int num = ModEnemyWeaponDamage.CurrentOrFallback(Plugin.Settings.PlaybackDamagePerHit.Value); if (num > 0) { _controller.ReceiveWeaponHit(val, num); } } private void DetectExpandedBulletHit() { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0156: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_controller == (Object)null || _body?.Renderers == null) { return; } if (_bulletFrame != Time.frameCount) { _bulletFrame = Time.frameCount; _bullets = Object.FindObjectsOfType(); } _current.Clear(); ItemGunBullet[] bullets = _bullets; foreach (ItemGunBullet val in bullets) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent() != (Object)null || (Object)(object)val.hurtCollider == (Object)null || !((Component)val.hurtCollider).gameObject.activeInHierarchy) { continue; } int instanceID = ((Object)val).GetInstanceID(); _current.Add(instanceID); Vector3 position = ((Component)val.hurtCollider).transform.position; Vector3 value; bool num = _previous.TryGetValue(instanceID, out value); _previous[instanceID] = position; if (!(num ? SegmentIntersects(value, position) : Within(position)) || !_controller.TryClaimWeaponHit(instanceID)) { continue; } _cooldown = 0.22f; if (EnemyLabBridge.IsExecutionHitNear(position)) { _controller.ExecuteForLab(); return; } int num2 = ModEnemyWeaponDamage.Resolve(val.hurtCollider, Plugin.Settings.PlaybackDamagePerHit.Value); if (num2 > 0) { _controller.ReceiveWeaponHit(position, num2); } return; } if (_previous.Count <= _current.Count) { return; } List list = null; foreach (int key in _previous.Keys) { if (!_current.Contains(key)) { if (list == null) { list = new List(); } list.Add(key); } } foreach (int item in list ?? new List()) { _previous.Remove(item); } } private bool Within(Vector3 point) { //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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Settings.PlaybackHitDetectionPadding.Value, 0.12f, 0.9f); if ((Object)(object)_controller != (Object)null) { Bounds val = default(Bounds); ((Bounds)(ref val))..ctor(_controller.HitCenter, Vector3.one * (_controller.HitHalfExtent * 2f)); if (((Bounds)(ref val)).SqrDistance(point) <= num * num) { return true; } } float num2 = num * num; Renderer[] renderers = _body.Renderers; foreach (Renderer val2 in renderers) { if ((Object)(object)val2 != (Object)null && val2.enabled && ((Component)val2).gameObject.activeInHierarchy) { Bounds bounds = val2.bounds; if (((Bounds)(ref bounds)).SqrDistance(point) <= num2) { return true; } } } return false; } private bool SegmentIntersects(Vector3 start, Vector3 end) { //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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Plugin.Settings.PlaybackHitDetectionPadding.Value, 0.12f, 0.9f); if ((Object)(object)_controller != (Object)null) { Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(_controller.HitCenter, Vector3.one * (_controller.HitHalfExtent * 2f)); ((Bounds)(ref bounds)).Expand(num * 2f); if (SegmentBounds(start, end, bounds)) { return true; } } Renderer[] renderers = _body.Renderers; foreach (Renderer val in renderers) { if (!((Object)(object)val == (Object)null) && val.enabled && ((Component)val).gameObject.activeInHierarchy) { Bounds bounds2 = val.bounds; ((Bounds)(ref bounds2)).Expand(num * 2f); if (SegmentBounds(start, end, bounds2)) { return true; } } } return false; } private static bool SegmentBounds(Vector3 start, Vector3 end, Bounds bounds) { //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) //IL_0002: 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_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float num = 0f; float num2 = 1f; for (int i = 0; i < 3; i++) { float num3 = ((Vector3)(ref start))[i]; float num4 = ((Vector3)(ref val))[i]; Vector3 val2; if (Mathf.Abs(num4) < 1E-05f) { val2 = ((Bounds)(ref bounds)).min; if (!(num3 < ((Vector3)(ref val2))[i])) { val2 = ((Bounds)(ref bounds)).max; if (!(num3 > ((Vector3)(ref val2))[i])) { continue; } } return false; } float num5 = 1f / num4; val2 = ((Bounds)(ref bounds)).min; float num6 = (((Vector3)(ref val2))[i] - num3) * num5; val2 = ((Bounds)(ref bounds)).max; float num7 = (((Vector3)(ref val2))[i] - num3) * num5; if (num6 > num7) { float num8 = num7; num7 = num6; num6 = num8; } num = Mathf.Max(num, num6); num2 = Mathf.Min(num2, num7); if (num > num2) { return false; } } return true; } } internal sealed class PlaybackManager : MonoBehaviour { private int _levelId; private float _spawnTimer; private bool _attemptFinished; private bool _probed; private bool _available; private PlaybackController _encounter; internal void Tick() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (!IsHostReady()) { return; } Probe(); int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } if (!ModEnemyLevelRules.IsPlayableLevel()) { DestroyCurrent(); return; } LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null || !instance.Generated || _attemptFinished) { return; } _spawnTimer -= Time.deltaTime; if (!(_spawnTimer > 0f)) { _attemptFinished = true; if (Random.value <= Mathf.Clamp01(Plugin.Settings.PlaybackSpawnChance.Value) && TryFindSpawn(out var position)) { Create(position, "automatic"); } } } private void ResetForLevel(int levelId) { DestroyCurrent(); _levelId = levelId; _spawnTimer = Mathf.Max(0f, Plugin.Settings.PlaybackSpawnDelay.Value); _attemptFinished = false; } private bool Create(Vector3 position, string source) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0085: Unknown result type (might be due to invalid IL or missing references) if (!_available && !PlaybackSpawner.PrefabAvailable()) { Plugin.Log.LogWarning((object)"The Backlash could not resolve its vanilla Jackhammer/fins/orbs."); return false; } DestroyCurrent(); GameObject val = new GameObject("The Backlash Encounter (Host Logic)"); val.SetActive(false); val.transform.position = position; PlaybackController playbackController = val.AddComponent(); if (!playbackController.Initialize(position)) { Object.Destroy((Object)(object)val); return false; } val.SetActive(true); if (!playbackController.ActivateNavigation(position)) { Object.Destroy((Object)(object)val); return false; } _encounter = playbackController; Plugin.Log.LogInfo((object)$"The Backlash spawned at {position} ({source}); its Jackhammer squid body is assembled from vanilla network objects."); return true; } internal bool DebugSpawnAt(Vector3 requestedPosition) { //IL_0039: 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) if (!IsHostReady() || (!ModEnemySpawnCoordinator.IsDirectorRequestActive && (Object)(object)PlayerAvatar.instance == (Object)null) || !ModEnemyLevelRules.IsPlayableLevel()) { Plugin.Log.LogWarning((object)"Enemy Lab rejected The Backlash because no playable host level is active."); return false; } Probe(); NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requestedPosition, ref val, 12f, -1)) { return false; } _attemptFinished = true; return Create(((NavMeshHit)(ref val)).position, ModEnemySpawnCoordinator.CurrentSpawnSource); } internal void MarkAutomaticAttemptFinished() { int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } _attemptFinished = true; } internal void DebugDespawn() { if (IsHostReady()) { _attemptFinished = true; DestroyCurrent(); } } private void DestroyCurrent() { if ((Object)(object)_encounter != (Object)null) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); _encounter = null; } } private void Probe() { if (!_probed && !((Object)(object)RunManager.instance == (Object)null)) { _probed = true; _available = PlaybackSpawner.PrefabAvailable(); Plugin.Log.LogInfo((object)($"The Backlash prefab probe: available={_available}, " + "body=" + PlaybackSpawner.ResourcePath + ", fin=" + PlaybackSpawner.FinResourcePath + ", eye=" + PlaybackSpawner.EyeResourcePath + ", trail=" + PlaybackSpawner.TrailDroneResourcePath + ".")); } } private static bool TryFindSpawn(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; PlayerAvatar val = null; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { val = item; break; } } Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(val2, 14f, 54f, false) ?? SemiFunc.LevelPointGetFurthestFromPlayer(val2, 7f); return ModEnemyNavigation.TryFindClearSpawn(((Object)(object)val3 != (Object)null) ? ((Component)val3).transform.position : (val2 + Vector3.forward * 14f), 7f, out position); } private static bool IsHostReady() { try { return (Object)(object)GameManager.instance != (Object)null && (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient); } catch { return false; } } } internal sealed class SpawnedPlayback { internal readonly List Parts = new List(); internal SpawnedDeadAirPart Body; internal Animator JackhammerAnimator; internal Transform JackhammerHammer; internal Transform JackhammerHydraulics; internal bool Alive = true; internal GameObject Root => Body?.Root; internal PhysGrabObject Phys => Body?.Phys; internal PhysGrabObjectImpactDetector ImpactDetector => Body?.ImpactDetector; internal Renderer[] Renderers => Body?.Renderers; } internal static class PlaybackSpawner { private static readonly string[] BodyCandidates = new string[3] { "Valuables/06 Tall/Valuable Arctic Jackhammer", "Items/Item Jackhammer", "Items/Item Jack Hammer" }; private static readonly string[] FinCandidates = new string[5] { "Valuables/07 Very Tall/Valuable Manor Harp", "Valuables/07 Very Tall/Valuable Harp", "Valuables/04 Big/Valuable Arctic Ice Saw", "Valuables/04 Big/Valuable Ice Saw", "Valuables/03 Medium/Valuable Arctic Ice Saw" }; private static readonly string[] TrailDroneCandidates = new string[1] { "Items/Item Drone Indestructible" }; internal static string ResourcePath { get; private set; } internal static string FinResourcePath { get; private set; } internal static string EyeResourcePath { get; private set; } internal static string TrailDroneResourcePath { get; private set; } internal static bool PrefabAvailable() { Resolve(); if (!string.IsNullOrEmpty(ResourcePath) && !string.IsNullOrEmpty(FinResourcePath) && !string.IsNullOrEmpty(EyeResourcePath)) { return !string.IsNullOrEmpty(TrailDroneResourcePath); } return false; } private static void Resolve() { if (ResourcePath == null) { ResourcePath = FirstAvailable(BodyCandidates); } if (FinResourcePath == null) { FinResourcePath = FirstAvailable(FinCandidates); } if (TrailDroneResourcePath == null) { TrailDroneResourcePath = FirstAvailable(TrailDroneCandidates); } if (string.IsNullOrEmpty(EyeResourcePath) && (Object)(object)AssetManager.instance?.enemyValuableSmall != (Object)null) { string text = "Valuables/" + ((Object)AssetManager.instance.enemyValuableSmall).name; if ((Object)(object)Resources.Load(text) != (Object)null) { EyeResourcePath = text; } } } private static string FirstAvailable(IEnumerable candidates) { foreach (string candidate in candidates) { if ((Object)(object)Resources.Load(candidate) != (Object)null) { return candidate; } } return null; } internal static SpawnedPlayback Spawn(Vector3 position) { //IL_001a: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00c7: Unknown result type (might be due to invalid IL or missing references) Resolve(); if (!PrefabAvailable()) { return null; } SpawnedPlayback spawnedPlayback = new SpawnedPlayback(); SpawnedDeadAirPart spawnedDeadAirPart = Add(spawnedPlayback, ResourcePath, position, new Vector3(1.22f, 1.08f, 1.22f), body: true, 1.4f); SpawnedDeadAirPart spawnedDeadAirPart2 = Add(spawnedPlayback, FinResourcePath, position, new Vector3(0.38f, 0.38f, 0.38f), body: false, 1.25f); SpawnedDeadAirPart spawnedDeadAirPart3 = Add(spawnedPlayback, FinResourcePath, position, new Vector3(0.38f, 0.38f, 0.38f), body: false, 1.25f); SpawnedDeadAirPart spawnedDeadAirPart4 = Add(spawnedPlayback, EyeResourcePath, position, new Vector3(1.36f, 1.36f, 1.36f), body: false, 1.25f); SpawnedDeadAirPart spawnedDeadAirPart5 = Add(spawnedPlayback, EyeResourcePath, position, new Vector3(1.36f, 1.36f, 1.36f), body: false, 1.25f); if (spawnedDeadAirPart == null || spawnedDeadAirPart2 == null || spawnedDeadAirPart3 == null || spawnedDeadAirPart4 == null || spawnedDeadAirPart5 == null) { Destroy(spawnedPlayback); return null; } spawnedPlayback.Body = spawnedDeadAirPart; spawnedPlayback.JackhammerAnimator = spawnedDeadAirPart.Root.GetComponentInChildren(true); spawnedPlayback.JackhammerHammer = FindTransform(spawnedDeadAirPart.Root.transform, "Valuable Arctic Jackhammer Hammer"); spawnedPlayback.JackhammerHydraulics = FindTransform(spawnedDeadAirPart.Root.transform, "Valuable Arctic Jackhammer Hydraulics"); return spawnedPlayback; } private static Transform FindTransform(Transform root, string name) { if ((Object)(object)root == (Object)null) { return null; } if (((Object)root).name == name) { return root; } for (int i = 0; i < root.childCount; i++) { Transform val = FindTransform(root.GetChild(i), name); if ((Object)(object)val != (Object)null) { return val; } } return null; } private static SpawnedDeadAirPart Add(SpawnedPlayback result, string resource, Vector3 position, Vector3 scale, bool body, float maximumScale) { //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) //IL_0007: Unknown result type (might be due to invalid IL or missing references) SpawnedDeadAirPart spawnedDeadAirPart = DeadAirSpawner.Spawn(resource, position, Quaternion.identity, scale, body, grabbable: false, maximumScale, 0.005f); if (spawnedDeadAirPart == null) { return null; } try { NeutralizeVisualPart(spawnedDeadAirPart); } catch (Exception ex) { Plugin.Log.LogWarning((object)("The Backlash rejected visual resource '" + resource + "': " + ex.Message)); DeadAirSpawner.Destroy(spawnedDeadAirPart); return null; } result.Parts.Add(spawnedDeadAirPart); return spawnedDeadAirPart; } internal static SpawnedDeadAirPart SpawnBounceEffect(Vector3 position) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Resolve(); if (string.IsNullOrEmpty(EyeResourcePath)) { return null; } SpawnedDeadAirPart spawnedDeadAirPart = DeadAirSpawner.Spawn(EyeResourcePath, position, Quaternion.identity, new Vector3(0.2f, 0.2f, 0.2f), isBody: false, grabbable: false, 0.3f, 0.005f); if (spawnedDeadAirPart == null) { return null; } try { NeutralizeVisualPart(spawnedDeadAirPart); return spawnedDeadAirPart; } catch { DeadAirSpawner.Destroy(spawnedDeadAirPart); return null; } } private static void NeutralizeVisualPart(SpawnedDeadAirPart part) { part.ImpactDetector.destroyDisable = true; part.ImpactDetector.playerHurtDisable = true; part.Phys.OverrideGrabDisable(1f); part.Phys.OverrideKinematic(1f); part.Phys.OverrideIndestructible(1f); part.Phys.clientNonKinematic = false; Trap[] componentsInChildren = part.Root.GetComponentsInChildren(true); foreach (Trap val in componentsInChildren) { if ((Object)(object)val != (Object)null) { ((Behaviour)val).enabled = false; } } HurtCollider[] componentsInChildren2 = part.Root.GetComponentsInChildren(true); foreach (HurtCollider val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(false); } } ItemBattery[] componentsInChildren3 = part.Root.GetComponentsInChildren(true); foreach (ItemBattery val3 in componentsInChildren3) { if ((Object)(object)val3 != (Object)null) { val3.batteryLife = 10000f; val3.batteryDrainRate = 0f; } } ItemToggle[] componentsInChildren4 = part.Root.GetComponentsInChildren(true); foreach (ItemToggle val4 in componentsInChildren4) { if ((Object)(object)val4 != (Object)null) { ((Behaviour)val4).enabled = false; } } } internal static void Destroy(SpawnedPlayback playback) { if (playback == null || !playback.Alive) { return; } playback.Alive = false; foreach (SpawnedDeadAirPart part in playback.Parts) { if (part != null && part.Alive) { DeadAirSpawner.Destroy(part); } } playback.Parts.Clear(); playback.Body = null; } } [BepInPlugin("unknown.REPO.TheCarousel", "The Uncatalogued", "0.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static UpdateFunction <0>__PlayerLoopUpdate; } public const string PluginGuid = "unknown.REPO.TheCarousel"; public const string PluginName = "The Uncatalogued"; public const string PluginVersion = "0.0.1"; public const string EnemyLabPluginGuid = "unknown.REPO.EnemyLab"; private CarouselManager _manager; private EffigyManager _effigyManager; private DeadAirManager _deadAirManager; private BrokerManager _brokerManager; private BellhopManager _bellhopManager; private VoodooManager _voodooManager; private AnatomistManager _anatomistManager; private ParasiteManager _parasiteManager; private AuditorManager _auditorManager; private PlaybackManager _playbackManager; private MimicManager _mimicManager; private ConfectionerManager _confectionerManager; private UndertowManager _undertowManager; private CupidManager _cupidManager; private MarionetteManager _marionetteManager; private DeliriumManager _deliriumManager; private ImitatorPlayerAvatarLabManager _imitatorPlayerAvatarLabManager; private Harmony _harmony; private bool _hookLogged; private int _lastTickFrame = -1; private string _lastLoopError; private readonly HashSet _observedSources = new HashSet(); private bool _installingPlayerLoop; private bool _playerLoopObserved; private int _recoveryInstallCount; private SynchronizationContext _unityContext; private Timer _synchronizationWatchdog; private int _synchronizationPostPending; private int _synchronizationPostErrorLogged; private bool _guestMapPreviewKeyHeld; private int _lastSchedulerSceneHandle = int.MinValue; internal static Plugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } internal static ModSettings Settings { get; private set; } [DllImport("user32.dll")] private static extern short GetAsyncKeyState(int virtualKey); private void Awake() { //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; ProtectBepInExManager(); Settings = new ModSettings(((BaseUnityPlugin)this).Config); _manager = ((Component)this).gameObject.AddComponent(); _effigyManager = ((Component)this).gameObject.AddComponent(); _deadAirManager = ((Component)this).gameObject.AddComponent(); _brokerManager = ((Component)this).gameObject.AddComponent(); _bellhopManager = ((Component)this).gameObject.AddComponent(); _voodooManager = null; _anatomistManager = ((Component)this).gameObject.AddComponent(); _parasiteManager = ((Component)this).gameObject.AddComponent(); _auditorManager = ((Component)this).gameObject.AddComponent(); _playbackManager = ((Component)this).gameObject.AddComponent(); _mimicManager = ((Component)this).gameObject.AddComponent(); _confectionerManager = ((Component)this).gameObject.AddComponent(); _undertowManager = ((Component)this).gameObject.AddComponent(); _cupidManager = ((Component)this).gameObject.AddComponent(); _marionetteManager = ((Component)this).gameObject.AddComponent(); _deliriumManager = null; _imitatorPlayerAvatarLabManager = null; ModEnemySpawnCoordinator.Initialize(_manager, _effigyManager, _deadAirManager, _brokerManager, _bellhopManager, _voodooManager, _anatomistManager, _parasiteManager, _auditorManager, _playbackManager, _mimicManager, _confectionerManager, _undertowManager, _cupidManager, _marionetteManager, _deliriumManager); try { _harmony = new Harmony("unknown.REPO.TheCarousel.DeadAirNoise"); _harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"The Uncatalogued patched the vanilla enemy-slot and host-noise streams."); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"The Dead Air could not connect its vanilla-noise listener: {arg}"); } SceneManager.sceneLoaded += OnSceneLoaded; EnemyLabBridge.TryRegister(_manager, _effigyManager, _deadAirManager, _brokerManager, _bellhopManager, _voodooManager, _anatomistManager, _parasiteManager, _auditorManager, _playbackManager, _mimicManager, _confectionerManager, _undertowManager, _cupidManager, _marionetteManager, _deliriumManager, _imitatorPlayerAvatarLabManager); ImperiumDebugBridge.TryRegister(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"The Uncatalogued v0.0.1 loaded; protected BepInEx MonoBehaviour.LateUpdate scheduler active."); } private void ProtectBepInExManager() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; ((Component)this).gameObject.SetActive(true); ((Behaviour)this).enabled = true; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); ((BaseUnityPlugin)this).Logger.LogInfo((object)("The Uncatalogued protected the BepInEx manager: " + $"name={((Object)((Component)this).gameObject).name}, active={((Component)this).gameObject.activeSelf}, " + $"enabled={((Behaviour)this).enabled}, flags={((Object)((Component)this).gameObject).hideFlags}.")); } private void StartSynchronizationWatchdog() { _unityContext = SynchronizationContext.Current; if (_unityContext == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"The Uncatalogued could not capture Unity's synchronization context."); return; } _synchronizationWatchdog = new Timer(QueueSynchronizationContextTick, null, 250, 33); ((BaseUnityPlugin)this).Logger.LogInfo((object)("The Uncatalogued armed synchronization-context fallback: " + _unityContext.GetType().FullName + ".")); } private void QueueSynchronizationContextTick(object state) { if (Interlocked.CompareExchange(ref _synchronizationPostPending, 1, 0) != 0) { return; } try { _unityContext.Post(delegate { Interlocked.Exchange(ref _synchronizationPostPending, 0); if ((Object)(object)this != (Object)null) { TickFromGameLoop("Unity SynchronizationContext"); } }, null); } catch (Exception arg) { Interlocked.Exchange(ref _synchronizationPostPending, 0); if (Interlocked.Exchange(ref _synchronizationPostErrorLogged, 1) == 0) { ((BaseUnityPlugin)this).Logger.LogError((object)$"The Uncatalogued synchronization fallback failed: {arg}"); } } } internal void TickFromGameLoop(string source) { if (_observedSources.Add(source)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("The Uncatalogued observed loop source: " + source + ".")); } int frameCount = Time.frameCount; if (_lastTickFrame == frameCount) { return; } _lastTickFrame = frameCount; if (!_hookLogged) { _hookLogged = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)("The Uncatalogued game loop is active via " + source + ".")); } try { UpdateGuestMapPreviewInput(); LateJoinSafety.Tick(); ImperiumDebugBridge.Tick(); MapIconSuppressor.TickAll(); ModEnemySpawnCoordinator.Tick(); DeadAirNoiseBridge.Tick(); _manager?.Tick(); _effigyManager?.Tick(); _deadAirManager?.Tick(); _brokerManager?.Tick(); _bellhopManager?.Tick(); _voodooManager?.Tick(); _anatomistManager?.Tick(); _parasiteManager?.Tick(); _auditorManager?.Tick(); _playbackManager?.Tick(); _mimicManager?.Tick(); _confectionerManager?.Tick(); _undertowManager?.Tick(); _cupidManager?.Tick(); _marionetteManager?.Tick(); _deliriumManager?.Tick(); _imitatorPlayerAvatarLabManager?.Tick(); _lastLoopError = null; } catch (Exception ex) { string text = ex.ToString(); if (_lastLoopError != text) { _lastLoopError = text; ((BaseUnityPlugin)this).Logger.LogError((object)$"The Uncatalogued loop failed via {source}: {ex}"); } } } private void LateUpdate() { //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) Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).handle != _lastSchedulerSceneHandle) { _lastSchedulerSceneHandle = ((Scene)(ref activeScene)).handle; ((BaseUnityPlugin)this).Logger.LogInfo((object)("The Uncatalogued protected scheduler entered scene " + $"{((Scene)(ref activeScene)).name} (handle {((Scene)(ref activeScene)).handle}).")); } TickFromGameLoop("protected BepInEx MonoBehaviour.LateUpdate"); } private void UpdateGuestMapPreviewInput() { if (!EnemyLabBridge.IsAvailable()) { return; } try { bool keyDown = Input.GetKeyDown((KeyCode)286); bool flag = (GetAsyncKeyState(116) & 0x8000) != 0; bool num = keyDown || (flag && !_guestMapPreviewKeyHeld); _guestMapPreviewKeyHeld = flag; if (num) { bool flag2 = !MapIconSuppressor.GuestMapPreviewEnabled; MapIconSuppressor.SetGuestMapPreview(flag2); ((BaseUnityPlugin)this).Logger.LogInfo((object)(flag2 ? "Enemy Lab guest-map preview enabled: encounter network-object markers are visible on the host map." : "Enemy Lab guest-map preview disabled: encounter markers are suppressed on the host map again.")); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogDebug((object)("Guest-map preview input was unavailable: " + ex.Message)); } } private void InstallUnityPlayerLoop(string trigger) { //IL_0018: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0065: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (_installingPlayerLoop || _playerLoopObserved) { return; } _installingPlayerLoop = true; try { PlayerLoopSystem parent = PlayerLoop.GetCurrentPlayerLoop(); RemoveMarker(ref parent, typeof(CarouselPlayerLoopMarker)); PlayerLoopSystem val = new PlayerLoopSystem { type = typeof(CarouselPlayerLoopMarker) }; object obj = <>O.<0>__PlayerLoopUpdate; if (obj == null) { UpdateFunction val2 = PlayerLoopUpdate; <>O.<0>__PlayerLoopUpdate = val2; obj = (object)val2; } val.updateDelegate = (UpdateFunction)obj; PlayerLoopSystem system = val; bool flag = AppendToPhase(ref parent, typeof(Update), system); if (!flag) { AppendDirectly(ref parent, system); } PlayerLoop.SetPlayerLoop(parent); if (trigger == "plugin Awake" || _recoveryInstallCount < 3) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("The Uncatalogued inserted low-level PlayerLoop callback (" + (flag ? "Update phase" : "root fallback") + "; trigger=" + trigger + ").")); } } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"The Uncatalogued could not install the low-level PlayerLoop: {arg}"); } finally { _installingPlayerLoop = false; } } private static void RemoveMarker(ref PlayerLoopSystem parent, Type markerType) { //IL_0020: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) PlayerLoopSystem[] subSystemList = parent.subSystemList; if (subSystemList == null || subSystemList.Length == 0) { return; } List list = new List(subSystemList.Length); PlayerLoopSystem[] array = subSystemList; foreach (PlayerLoopSystem val in array) { if (!(val.type == markerType)) { PlayerLoopSystem parent2 = val; RemoveMarker(ref parent2, markerType); list.Add(parent2); } } parent.subSystemList = list.ToArray(); } private static bool AppendToPhase(ref PlayerLoopSystem parent, Type phaseType, PlayerLoopSystem system) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_003d: Unknown result type (might be due to invalid IL or missing references) if (parent.type == phaseType) { AppendDirectly(ref parent, system); return true; } PlayerLoopSystem[] subSystemList = parent.subSystemList; if (subSystemList == null) { return false; } for (int i = 0; i < subSystemList.Length; i++) { PlayerLoopSystem parent2 = subSystemList[i]; if (AppendToPhase(ref parent2, phaseType, system)) { subSystemList[i] = parent2; parent.subSystemList = subSystemList; return true; } } return false; } private static void AppendDirectly(ref PlayerLoopSystem parent, PlayerLoopSystem system) { //IL_0029: 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) PlayerLoopSystem[] array = parent.subSystemList ?? Array.Empty(); PlayerLoopSystem[] array2 = (PlayerLoopSystem[])(object)new PlayerLoopSystem[array.Length + 1]; Array.Copy(array, array2, array.Length); array2[array.Length] = system; parent.subSystemList = array2; } private static void PlayerLoopUpdate() { Instance?.OnPlayerLoopUpdate(); } private void OnPlayerLoopUpdate() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (!_playerLoopObserved) { _playerLoopObserved = true; Application.logMessageReceived -= new LogCallback(OnUnityLogMessage); ((BaseUnityPlugin)this).Logger.LogInfo((object)"The Uncatalogued low-level PlayerLoop callback is now executing."); } TickFromGameLoop("Unity LowLevel PlayerLoop.Update"); } private void OnUnityLogMessage(string condition, string stackTrace, LogType type) { if (!_playerLoopObserved && !_installingPlayerLoop) { _recoveryInstallCount++; string trigger = ((condition != null && condition.StartsWith("Changed level to:")) ? condition : $"Unity log recovery #{_recoveryInstallCount}"); InstallUnityPlayerLoop(trigger); } } private void OnBeforeRender() { TickFromGameLoop("Application.onBeforeRender"); } private void OnCameraPreCull(Camera camera) { TickFromGameLoop("Camera.onPreCull"); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { _lastTickFrame = -1; TickFromGameLoop("SceneManager.sceneLoaded (" + ((Scene)(ref scene)).name + ")"); } private void OnDisable() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string text = $"The Uncatalogued plugin was disabled: active={((Component)this).gameObject.activeSelf}, "; object arg = ((Behaviour)this).enabled; Scene scene = ((Component)this).gameObject.scene; logger.LogWarning((object)(text + $"enabled={arg}, scene={((Scene)(ref scene)).name}.")); } private void OnDestroy() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown ((BaseUnityPlugin)this).Logger.LogError((object)"The Uncatalogued plugin was destroyed; recurring callbacks cannot continue."); _imitatorPlayerAvatarLabManager?.DebugDespawn(); _synchronizationWatchdog?.Dispose(); _synchronizationWatchdog = null; Application.onBeforeRender -= new UnityAction(OnBeforeRender); Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnCameraPreCull)); SceneManager.sceneLoaded -= OnSceneLoaded; Application.logMessageReceived -= new LogCallback(OnUnityLogMessage); EnemyLabBridge.TryUnregister(); ImperiumDebugBridge.Reset(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } _harmony = null; Instance = null; } } internal sealed class ModSettings { internal readonly ConfigEntry ModEnemySlotReplacementChance; internal readonly ConfigEntry ModEnemyRespawnMinimumSeconds; internal readonly ConfigEntry ModEnemyRespawnMaximumSeconds; internal readonly ConfigEntry SpawnChance; internal readonly ConfigEntry SpawnDelay; internal readonly ConfigEntry GunHealth; internal readonly ConfigEntry DamagePerHit; internal readonly ConfigEntry RoamSpeed; internal readonly ConfigEntry VisionRange; internal readonly ConfigEntry OrbitRadius; internal readonly ConfigEntry OrbitSpeed; internal readonly ConfigEntry AttackOrbitSpeedMultiplier; internal readonly ConfigEntry GunVisualScale; internal readonly ConfigEntry AlertDelay; internal readonly ConfigEntry ShotAimTime; internal readonly ConfigEntry ShotInterval; internal readonly ConfigEntry BurstCooldown; internal readonly ConfigEntry PlayerDamagePerHit; internal readonly ConfigEntry ProjectileHitRadius; internal readonly ConfigEntry HitDetectionPadding; internal readonly ConfigEntry AimSpread; internal readonly ConfigEntry FireAimError; internal readonly ConfigEntry NearMusicRange; internal readonly ConfigEntry DropEnemyValuable; internal readonly ConfigEntry RewardTier; internal readonly ConfigEntry EffigySpawnChance; internal readonly ConfigEntry EffigySpawnDelay; internal readonly ConfigEntry EffigyHealth; internal readonly ConfigEntry EffigyDamagePerHit; internal readonly ConfigEntry EffigyMoveSpeed; internal readonly ConfigEntry EffigyActivationRange; internal readonly ConfigEntry EffigyObservationRange; internal readonly ConfigEntry EffigyObservationFov; internal readonly ConfigEntry EffigyKillPadding; internal readonly ConfigEntry EffigyVisualScale; internal readonly ConfigEntry EffigyHitDetectionPadding; internal readonly ConfigEntry EffigyNearMusicRange; internal readonly ConfigEntry EffigyDropEnemyValuable; internal readonly ConfigEntry EffigyRewardTier; internal readonly ConfigEntry DeadAirSpawnChance; internal readonly ConfigEntry DeadAirSpawnDelay; internal readonly ConfigEntry DeadAirHealth; internal readonly ConfigEntry DeadAirDamagePerHit; internal readonly ConfigEntry DeadAirHitDetectionPadding; internal readonly ConfigEntry DeadAirHuntSpeed; internal readonly ConfigEntry DeadAirFleeSpeed; internal readonly ConfigEntry DeadAirQuietSecondsForFullSpeed; internal readonly ConfigEntry DeadAirLoudNoiseRadius; internal readonly ConfigEntry DeadAirVoiceLoudnessThreshold; internal readonly ConfigEntry DeadAirVoiceNoiseRadius; internal readonly ConfigEntry DeadAirAttackRange; internal readonly ConfigEntry DeadAirAttackDamage; internal readonly ConfigEntry DeadAirNearMusicRange; internal readonly ConfigEntry DeadAirDropEnemyValuable; internal readonly ConfigEntry DeadAirRewardTier; internal readonly ConfigEntry DeadAirGrabMass; internal readonly ConfigEntry DeadAirMediumSlamDamage; internal readonly ConfigEntry DeadAirHeavySlamDamage; internal readonly ConfigEntry BrokerSpawnChance; internal readonly ConfigEntry BrokerSpawnDelay; internal readonly ConfigEntry BrokerHealth; internal readonly ConfigEntry BrokerDamagePerHit; internal readonly ConfigEntry BrokerHitDetectionPadding; internal readonly ConfigEntry BrokerFollowSpeed; internal readonly ConfigEntry BrokerHostileSpeed; internal readonly ConfigEntry BrokerOrbitRadius; internal readonly ConfigEntry BrokerVisionRange; internal readonly ConfigEntry BrokerMaximumValuableSize; internal readonly ConfigEntry BrokerSuccessChance; internal readonly ConfigEntry BrokerValueMultiplier; internal readonly ConfigEntry BrokerDigestSeconds; internal readonly ConfigEntry BrokerAttackRange; internal readonly ConfigEntry BrokerAttackDamage; internal readonly ConfigEntry BrokerNeutralMass; internal readonly ConfigEntry BrokerHostileMass; internal readonly ConfigEntry BrokerNearMusicRange; internal readonly ConfigEntry BellhopSpawnChance; internal readonly ConfigEntry BellhopSpawnDelay; internal readonly ConfigEntry BellhopHealth; internal readonly ConfigEntry BellhopDamagePerHit; internal readonly ConfigEntry BellhopHitDetectionPadding; internal readonly ConfigEntry BellhopMoveSpeed; internal readonly ConfigEntry BellhopRetreatSpeed; internal readonly ConfigEntry BellhopVisionRange; internal readonly ConfigEntry BellhopValuableSearchRange; internal readonly ConfigEntry BellhopExplosionDamage; internal readonly ConfigEntry BellhopExplosionRadius; internal readonly ConfigEntry BellhopNearMusicRange; internal readonly ConfigEntry BellhopDropEnemyValuable; internal readonly ConfigEntry BellhopRewardTier; internal readonly ConfigEntry VoodooSpawnChance; internal readonly ConfigEntry VoodooSpawnDelay; internal readonly ConfigEntry VoodooMoveSpeed; internal readonly ConfigEntry VoodooHeldSpeedMultiplier; internal readonly ConfigEntry VoodooTargetSwitchCooldown; internal readonly ConfigEntry VoodooAttackDamage; internal readonly ConfigEntry VoodooAttackRange; internal readonly ConfigEntry VoodooDollValue; internal readonly ConfigEntry VoodooDropEnemyValuable; internal readonly ConfigEntry VoodooRewardTier; internal readonly ConfigEntry AnatomistSpawnChance; internal readonly ConfigEntry AnatomistSpawnDelay; internal readonly ConfigEntry AnatomistHealth; internal readonly ConfigEntry AnatomistDamagePerHit; internal readonly ConfigEntry AnatomistHitDetectionPadding; internal readonly ConfigEntry AnatomistHeadInterval; internal readonly ConfigEntry AnatomistMaximumHeads; internal readonly ConfigEntry AnatomistCrushDamage; internal readonly ConfigEntry AnatomistDropEnemyValuable; internal readonly ConfigEntry AnatomistRewardTier; internal readonly ConfigEntry ParasiteSpawnChance; internal readonly ConfigEntry ParasiteSpawnDelay; internal readonly ConfigEntry ParasiteHealth; internal readonly ConfigEntry ParasiteDamagePerHit; internal readonly ConfigEntry ParasiteHitDetectionPadding; internal readonly ConfigEntry ParasiteMoveSpeed; internal readonly ConfigEntry ParasiteSearchRange; internal readonly ConfigEntry ParasiteValuableDrainSeconds; internal readonly ConfigEntry ParasiteDropEnemyValuable; internal readonly ConfigEntry AuditorSpawnChance; internal readonly ConfigEntry AuditorSpawnDelay; internal readonly ConfigEntry AuditorHealth; internal readonly ConfigEntry AuditorDamagePerHit; internal readonly ConfigEntry AuditorHitDetectionPadding; internal readonly ConfigEntry AuditorChargeSpeed; internal readonly ConfigEntry AuditorFleeSpeed; internal readonly ConfigEntry AuditorSearchRange; internal readonly ConfigEntry AuditorContactDamage; internal readonly ConfigEntry AuditorKnockbackForce; internal readonly ConfigEntry AuditorDropEnemyValuable; internal readonly ConfigEntry PlaybackSpawnChance; internal readonly ConfigEntry PlaybackSpawnDelay; internal readonly ConfigEntry PlaybackHealth; internal readonly ConfigEntry PlaybackDamagePerHit; internal readonly ConfigEntry PlaybackHitDetectionPadding; internal readonly ConfigEntry PlaybackRoamSpeed; internal readonly ConfigEntry PlaybackRecordSeconds; internal readonly ConfigEntry PlaybackReplaySpeed; internal readonly ConfigEntry PlaybackContactDamage; internal readonly ConfigEntry PlaybackContactRadius; internal readonly ConfigEntry PlaybackDropEnemyValuable; internal readonly ConfigEntry MimicSpawnChance; internal readonly ConfigEntry MimicSpawnDelay; internal readonly ConfigEntry MimicHealth; internal readonly ConfigEntry MimicStalkSpeed; internal readonly ConfigEntry MimicChargeSpeed; internal readonly ConfigEntry MimicRecordSeconds; internal readonly ConfigEntry MimicAttackDamage; internal readonly ConfigEntry MimicDropEnemyValuable; internal readonly ConfigEntry ConfectionerSpawnChance; internal readonly ConfigEntry ConfectionerSpawnDelay; internal readonly ConfigEntry ConfectionerHealth; internal readonly ConfigEntry ConfectionerDamagePerHit; internal readonly ConfigEntry ConfectionerHitDetectionPadding; internal readonly ConfigEntry ConfectionerMoveSpeed; internal readonly ConfigEntry ConfectionerCandyInterval; internal readonly ConfigEntry ConfectionerCandyValue; internal readonly ConfigEntry ConfectionerDropEnemyValuable; internal readonly ConfigEntry UndertowSpawnChance; internal readonly ConfigEntry UndertowSpawnDelay; internal readonly ConfigEntry UndertowHealth; internal readonly ConfigEntry UndertowDamagePerHit; internal readonly ConfigEntry UndertowSwimSpeed; internal readonly ConfigEntry UndertowDetectionRange; internal readonly ConfigEntry UndertowMooringRadius; internal readonly ConfigEntry UndertowMooringSeconds; internal readonly ConfigEntry UndertowMooringBreakDamage; internal readonly ConfigEntry UndertowFinalDamage; internal readonly ConfigEntry UndertowDropEnemyValuable; internal readonly ConfigEntry CupidSpawnChance; internal readonly ConfigEntry CupidSpawnDelay; internal readonly ConfigEntry CupidHealth; internal readonly ConfigEntry CupidDamagePerHit; internal readonly ConfigEntry CupidSwimSpeed; internal readonly ConfigEntry CupidDetectionRange; internal readonly ConfigEntry CupidTetherDistance; internal readonly ConfigEntry CupidDamageShare; internal readonly ConfigEntry CupidDropEnemyValuable; internal readonly ConfigEntry MarionetteSpawnChance; internal readonly ConfigEntry MarionetteSpawnDelay; internal readonly ConfigEntry MarionetteHealth; internal readonly ConfigEntry MarionetteDamagePerHit; internal readonly ConfigEntry MarionetteMoveSpeed; internal readonly ConfigEntry MarionetteDisarmSeconds; internal readonly ConfigEntry MarionetteDropEnemyValuable; internal readonly ConfigEntry DeliriumSpawnChance; private readonly ConfigEntry _tuningRevision; internal ModSettings(ConfigFile config) { ModEnemySlotReplacementChance = config.Bind("EnemyDirector", "ModEnemySlotReplacementChance", 40f, "Percent chance that each eligible vanilla enemy slot is replaced by one same-difficulty MOD enemy. Range 0-100; 40 means 40%. Individual enemy SpawnChance values only choose which MOD enemy is selected. Early levels still allow at most one MOD enemy and later levels at most two."); ModEnemyRespawnMinimumSeconds = config.Bind("EnemyDirector", "ModEnemyRespawnMinimumSeconds", 60f, "Legacy setting retained for config compatibility. MOD enemies now copy the replaced vanilla prefab's DespawnedTimeMin and EnemyDirector multipliers exactly."); ModEnemyRespawnMaximumSeconds = config.Bind("EnemyDirector", "ModEnemyRespawnMaximumSeconds", 120f, "Legacy setting retained for config compatibility. MOD enemies now copy the replaced vanilla prefab's DespawnedTimeMax and vanilla final-extraction rule exactly."); SpawnChance = config.Bind("Encounter", "SpawnChance", 1f, "Relative EnemyDirector rarity weight for The Carousel (difficulty-2 slot). Zero disables automatic selection."); SpawnDelay = config.Bind("Encounter", "SpawnDelay", 7f, "Legacy setting retained for config compatibility; automatic enemies now consume vanilla EnemyDirector slots during generation."); GunHealth = config.Bind("Combat", "HealthPerGun", 40, "Health of each of the three TRANQ GUNs."); DamagePerHit = config.Bind("Combat", "DamagePerWeaponHit", 15, "Compatibility fallback damage only when the attacking HurtCollider cannot be identified. Known guns and melee tools use their vanilla enemyDamage/enemyKill values."); AlertDelay = config.Bind("Combat", "AlertDelay", 0.7f, "Aiming warning time before a burst begins."); ShotAimTime = config.Bind("Combat", "ShotAimTime", 0.35f, "Seconds a queued TRANQ GUN smoothly turns toward its snapshotted aim point before firing."); ShotInterval = config.Bind("Combat", "ShotInterval", 0.7f, "Delay between queued shots in a burst. Runtime safety clamps this to 0.35-4.0 seconds."); BurstCooldown = config.Bind("Combat", "BurstCooldown", 1.9f, "Recovery time after a burst."); PlayerDamagePerHit = config.Bind("Combat", "PlayerDamagePerHit", 15, "Host-authoritative damage when a rotating muzzle sweep hits a player."); ProjectileHitRadius = config.Bind("Combat", "ProjectileHitRadius", 0.08f, "Radius in metres of the thin host-authoritative shot path. Runtime safety clamps this to 0.01-0.15."); HitDetectionPadding = config.Bind("Combat", "GunHitDetectionPadding", 1.1f, "Extra metres around each visible gun renderer that accept nearby player bullet impacts."); AimSpread = config.Bind("Combat", "AimSpreadDegrees", 18f, "Minimum random spread used by each TRANQ GUN."); FireAimError = config.Bind("Combat", "FireAimErrorDegrees", 0.1f, "Random horizontal and vertical error when the firing gun briefly turns toward a player."); NearMusicRange = config.Bind("Audio", "NearMusicRange", 15f, "Local-host distance at which the vanilla ominous enemy-near music is sustained."); DropEnemyValuable = config.Bind("Reward", "DropEnemyOrb", true, "Drop one vanilla enemy valuable after all three guns are destroyed."); RewardTier = config.Bind("Reward", "EnemyOrbTier", 2, "Vanilla enemy orb tier: 1=small, 2=medium, 3=big."); EffigySpawnChance = config.Bind("The Weeping Angel", "SpawnChance", 0.35f, "Relative EnemyDirector rarity weight for The Weeping Angel (difficulty-3 slot). Zero disables automatic selection."); EffigySpawnDelay = config.Bind("The Weeping Angel", "SpawnDelay", 11f, "Legacy compatibility setting; automatic selection now occurs inside the vanilla enemy routine."); EffigyHealth = config.Bind("The Weeping Angel", "Health", 900, "Shared health across every visible part of The Weeping Angel."); EffigyDamagePerHit = config.Bind("The Weeping Angel", "DamagePerWeaponHit", 25, "Compatibility fallback damage only when the attacking HurtCollider cannot be identified. Known weapons use their vanilla damage."); EffigyMoveSpeed = config.Bind("The Weeping Angel", "UnobservedMoveSpeed", 7.5f, "NavMesh movement speed while no living player can see The Weeping Angel."); EffigyActivationRange = config.Bind("The Weeping Angel", "InitialActivationRange", 35f, "The Weeping Angel remains completely dormant until a living player first enters this radius; after waking it uses its normal observation logic for the rest of the level."); EffigyObservationRange = config.Bind("The Weeping Angel", "ObservationRange", 60f, "Maximum distance at which a player's gaze can freeze The Weeping Angel."); EffigyObservationFov = config.Bind("The Weeping Angel", "ObservationFovDegrees", 125f, "Total gaze cone in degrees that counts as looking at The Weeping Angel."); EffigyKillPadding = config.Bind("The Weeping Angel", "TouchKillPadding", 0.08f, "Extra metres around the vanilla body colliders used for instant-kill contact."); EffigyVisualScale = config.Bind("The Weeping Angel", "BodyScale", 1.15f, "Networked scale multiplier for the vanilla humanoid statue shown identically to host and guests."); EffigyHitDetectionPadding = config.Bind("The Weeping Angel", "HitDetectionPadding", 0.25f, "Extra metres around visible renderers that accept nearby player bullet endpoints."); EffigyNearMusicRange = config.Bind("The Weeping Angel", "NearMusicRange", 18f, "Local-host range for vanilla enemy-near music."); EffigyDropEnemyValuable = config.Bind("The Weeping Angel", "DropEnemyOrb", true, "Drop a vanilla enemy valuable after The Weeping Angel is destroyed."); EffigyRewardTier = config.Bind("The Weeping Angel", "EnemyOrbTier", 3, "Vanilla enemy orb tier: 1=small, 2=medium, 3=big."); DeadAirSpawnChance = config.Bind("The Dead Air", "SpawnChance", 0.35f, "Relative EnemyDirector rarity weight for The Dead Air (difficulty-1 slot). Zero disables automatic selection."); DeadAirSpawnDelay = config.Bind("The Dead Air", "SpawnDelay", 14f, "Legacy compatibility setting; automatic selection now occurs inside the vanilla enemy routine."); DeadAirHealth = config.Bind("The Dead Air", "Health", 150, "Shared health across the boombox body and all six legs."); DeadAirDamagePerHit = config.Bind("The Dead Air", "DamagePerWeaponHit", 20, "Compatibility fallback damage only when the attacking HurtCollider cannot be identified. Known weapons use their vanilla damage."); DeadAirHitDetectionPadding = config.Bind("The Dead Air", "HitDetectionPadding", 0.28f, "Extra metres around each visible body and leg renderer that accept player bullets."); DeadAirHuntSpeed = config.Bind("The Dead Air", "FullSilenceHuntSpeed", 5.3f, "Maximum movement speed after its target has remained quiet."); DeadAirFleeSpeed = config.Bind("The Dead Air", "FleeSpeed", 8.12f, "Movement speed while fleeing a loud sound."); DeadAirQuietSecondsForFullSpeed = config.Bind("The Dead Air", "QuietSecondsForFullSpeed", 4f, "Seconds of silence required before The Dead Air reaches full hunt speed."); DeadAirLoudNoiseRadius = config.Bind("The Dead Air", "LoudNoiseRadius", 5.25f, "Minimum vanilla investigate radius that frightens The Dead Air. A normal heavy landing is exactly radius 5 and therefore no longer causes a retreat; louder voice, gunfire and impacts still do."); DeadAirVoiceLoudnessThreshold = config.Bind("The Dead Air", "VoiceLoudnessThreshold", 0.0065f, "Minimum host-observed PlayerVoiceChat loudness that counts as speech. This direct path covers unmodded guests even when voice does not create a vanilla investigate event."); DeadAirVoiceNoiseRadius = config.Bind("The Dead Air", "VoiceNoiseRadius", 10f, "Base distance in metres at which normal player speech frightens The Dead Air. Louder speech extends this modestly."); DeadAirAttackRange = config.Bind("The Dead Air", "AttackRange", 1.15f, "Horizontal range at which The Dead Air begins its interruptible lunge."); DeadAirAttackDamage = config.Bind("The Dead Air", "AttackDamage", 30, "Damage dealt by a completed close-range lunge."); DeadAirNearMusicRange = config.Bind("The Dead Air", "NearMusicRange", 15f, "Local-host range for vanilla enemy-near music."); DeadAirDropEnemyValuable = config.Bind("The Dead Air", "DropEnemyOrb", true, "Drop a vanilla enemy valuable after The Dead Air is destroyed."); DeadAirRewardTier = config.Bind("The Dead Air", "EnemyOrbTier", 1, "Legacy setting. The Dead Air now always drops the small vanilla enemy orb."); DeadAirGrabMass = config.Bind("The Dead Air", "GrabMass", 6f, "Physical mass of the grabbable radio body. Strength upgrades make lifting and throwing it substantially easier."); DeadAirMediumSlamDamage = config.Bind("The Dead Air", "MediumSlamDamage", 55, "Damage dealt to The Dead Air when its recently held body causes a vanilla medium impact."); DeadAirHeavySlamDamage = config.Bind("The Dead Air", "HeavySlamDamage", 120, "Damage dealt to The Dead Air when its recently held body causes a vanilla heavy impact."); BrokerSpawnChance = config.Bind("The Broker", "SpawnChance", 0.3f, "Relative EnemyDirector rarity weight for The Broker (difficulty-1 slot). Zero disables automatic selection."); BrokerSpawnDelay = config.Bind("The Broker", "SpawnDelay", 20f, "Legacy compatibility setting; automatic selection now occurs inside the vanilla enemy routine."); BrokerHealth = config.Bind("The Broker", "Health", 100, "Shared health across The Broker's case, open lid, mouth and four legs."); BrokerDamagePerHit = config.Bind("The Broker", "DamagePerWeaponHit", 25, "Compatibility fallback damage only when the attacking HurtCollider cannot be identified. Known weapons use their vanilla damage."); BrokerHitDetectionPadding = config.Bind("The Broker", "HitDetectionPadding", 0.3f, "Extra metres around the visible body that accept player bullets."); BrokerFollowSpeed = config.Bind("The Broker", "NeutralFollowSpeed", 2.2f, "Movement speed while harmlessly circling its chosen player."); BrokerHostileSpeed = config.Bind("The Broker", "HostileSpeed", 5.85f, "Movement speed after grabbing it or losing the appraisal gamble."); BrokerOrbitRadius = config.Bind("The Broker", "PlayerOrbitRadius", 3.2f, "Distance at which a neutral Broker circles its chosen player."); BrokerVisionRange = config.Bind("The Broker", "VisionRange", 24f, "Maximum initial player detection distance."); BrokerMaximumValuableSize = config.Bind("The Broker", "MaximumValuableSize", 0.95f, "Largest rendered dimension in metres that fits into The Broker's mouth."); BrokerSuccessChance = config.Bind("The Broker", "SuccessChance", 1f, "First-appraisal success chance. Repeating the same valuable subtracts 15 percentage points per prior success, down to 10 percent."); BrokerValueMultiplier = config.Bind("The Broker", "SuccessValueMultiplier", 1.01f, "First-appraisal value multiplier. Repeat rewards rise inversely as their success chance falls, up to 5x."); BrokerDigestSeconds = config.Bind("The Broker", "DigestSeconds", 1.25f, "Delay between swallowing a valuable and resolving the appraisal."); BrokerAttackRange = config.Bind("The Broker", "AttackRange", 1.25f, "Range of a hostile bite."); BrokerAttackDamage = config.Bind("The Broker", "AttackDamage", 10, "Damage dealt by each frequent hostile bite."); BrokerNeutralMass = config.Bind("The Broker", "NeutralGrabMass", 2.5f, "Physical mass while neutral; one player can carry it with some effort."); BrokerHostileMass = config.Bind("The Broker", "HostileGrabMass", 6f, "Physical mass after it becomes hostile. It remains grabbable but resists control."); BrokerNearMusicRange = config.Bind("The Broker", "NearMusicRange", 14f, "Local-host range for vanilla enemy-near music."); BellhopSpawnChance = config.Bind("The Bellhop", "SpawnChance", 0.25f, "Relative EnemyDirector rarity weight for The Bellhop (difficulty-2 slot). Zero disables automatic selection."); BellhopSpawnDelay = config.Bind("The Bellhop", "SpawnDelay", 23f, "Legacy compatibility setting; automatic selection now occurs inside the vanilla enemy routine."); BellhopHealth = config.Bind("The Bellhop", "Health", 200, "Shared health across its clock body, camera head and serving tray."); BellhopDamagePerHit = config.Bind("The Bellhop", "DamagePerWeaponHit", 25, "Compatibility fallback damage only when the attacking HurtCollider cannot be identified. Known weapons use their vanilla damage."); BellhopHitDetectionPadding = config.Bind("The Bellhop", "HitDetectionPadding", 0.28f, "Extra metres around visible parts that accept player bullets."); BellhopMoveSpeed = config.Bind("The Bellhop", "MoveSpeed", 3.24f, "Speed while fetching a valuable or returning to its target."); BellhopRetreatSpeed = config.Bind("The Bellhop", "RetreatSpeed", 5.22f, "Speed while first retreating and while resetting after a throw."); BellhopVisionRange = config.Bind("The Bellhop", "VisionRange", 30f, "Maximum player detection distance."); BellhopValuableSearchRange = config.Bind("The Bellhop", "ValuableSearchRange", 16f, "Maximum range used to find a loose throwable valuable."); BellhopExplosionDamage = config.Bind("The Bellhop", "ExplosionDamage", 65, "Maximum player damage from an uncaught low-gravity valuable (minimum 55)."); BellhopExplosionRadius = config.Bind("The Bellhop", "ExplosionRadius", 5.2f, "Large explosion radius in metres for an uncaught low-gravity valuable (minimum 4.8)."); BellhopNearMusicRange = config.Bind("The Bellhop", "NearMusicRange", 16f, "Local-host range for vanilla enemy-near music."); BellhopDropEnemyValuable = config.Bind("The Bellhop", "DropEnemyOrb", true, "Drop one vanilla enemy valuable after The Bellhop is destroyed."); BellhopRewardTier = config.Bind("The Bellhop", "EnemyOrbTier", 2, "Vanilla enemy orb tier: 1=small, 2=medium, 3=big."); VoodooSpawnChance = BindHiddenWip(config, "The Voodoo", "SpawnChance", 0.22f, "Relative EnemyDirector rarity weight for The Voodoo (difficulty-2 slot). Zero disables automatic selection."); VoodooSpawnDelay = BindHiddenWip(config, "The Voodoo", "SpawnDelay", 26f, "Legacy compatibility setting; automatic selection now occurs inside the vanilla enemy routine."); VoodooMoveSpeed = BindHiddenWip(config, "The Voodoo", "MoveSpeed", 1.15f, "Slow pursuit speed while its doll is not held by the current victim."); VoodooHeldSpeedMultiplier = BindHiddenWip(config, "The Voodoo", "DollHeldSpeedMultiplier", 1.3f, "Pursuit speed multiplier while the current victim holds the doll."); VoodooTargetSwitchCooldown = BindHiddenWip(config, "The Voodoo", "TargetSwitchCooldown", 90f, "Seconds before passing the doll can select another private victim again."); VoodooAttackDamage = BindHiddenWip(config, "The Voodoo", "AttackDamage", 666, "Damage dealt by The Voodoo's touch."); VoodooAttackRange = BindHiddenWip(config, "The Voodoo", "AttackRange", 0.9f, "Horizontal touch range; walls and fully closed doors still block the hit."); VoodooDollValue = BindHiddenWip(config, "The Voodoo", "DollValue", 4000f, "Exact dollar value of the light, durable, normally breakable five-stick doll."); VoodooDropEnemyValuable = BindHiddenWip(config, "The Voodoo", "DropEnemyOrb", defaultValue: true, "Drop one vanilla enemy valuable when the doll is destroyed."); VoodooRewardTier = BindHiddenWip(config, "The Voodoo", "EnemyOrbTier", 2, "Vanilla enemy orb tier: 1=small, 2=medium, 3=big."); AnatomistSpawnChance = config.Bind("The Anatomist", "SpawnChance", 0.22f, "Relative EnemyDirector rarity weight for The Anatomist (difficulty-2 slot). Zero disables automatic selection."); AnatomistSpawnDelay = config.Bind("The Anatomist", "SpawnDelay", 28f, "Legacy compatibility setting; automatic selection now occurs inside the vanilla enemy routine."); AnatomistHealth = config.Bind("The Anatomist", "Health", 350, "Shared health across the ceiling cable, palm and syringe fingers."); AnatomistDamagePerHit = config.Bind("The Anatomist", "DamagePerWeaponHit", 25, "Compatibility fallback damage only when the attacking HurtCollider cannot be identified. Known weapons use their vanilla damage."); AnatomistHitDetectionPadding = config.Bind("The Anatomist", "HitDetectionPadding", 0.32f, "Extra metres around visible parts that accept player bullet endpoints."); AnatomistHeadInterval = config.Bind("The Anatomist", "HeadDropInterval", 10f, "Average seconds between planted dummy heads before the six-head limit is reached."); AnatomistMaximumHeads = config.Bind("The Anatomist", "MaximumDummyHeads", 6, "Maximum simultaneous dummy heads; runtime range is 1-6."); AnatomistCrushDamage = config.Bind("The Anatomist", "CrushDamage", 80, "Damage dealt before The Anatomist carries a head holder into the ceiling."); AnatomistDropEnemyValuable = config.Bind("The Anatomist", "DropEnemyOrb", true, "Drop one vanilla enemy valuable after The Anatomist is destroyed."); AnatomistRewardTier = config.Bind("The Anatomist", "EnemyOrbTier", 2, "Vanilla enemy orb tier: 1=small, 2=medium, 3=big."); ParasiteSpawnChance = config.Bind("The Parasite", "SpawnChance", 0.24f, "Relative EnemyDirector rarity weight for The Parasite (difficulty-2 slot). Zero disables automatic selection."); ParasiteSpawnDelay = config.Bind("The Parasite", "SpawnDelay", 24f, "Legacy compatibility setting; automatic selection now occurs inside the vanilla enemy routine."); ParasiteHealth = config.Bind("The Parasite", "Health", 75, "Health of the slightly enlarged Indestructible Drone body."); ParasiteDamagePerHit = config.Bind("The Parasite", "DamagePerWeaponHit", 20, "Compatibility fallback damage only when the attacking HurtCollider cannot be identified. Known weapons use their vanilla damage."); ParasiteHitDetectionPadding = config.Bind("The Parasite", "HitDetectionPadding", 0.28f, "Extra metres around the visible drone renderer that accept player bullets."); ParasiteMoveSpeed = config.Bind("The Parasite", "MoveSpeed", 2.45f, "Waist-height roaming and approach speed."); ParasiteSearchRange = config.Bind("The Parasite", "SearchRange", 22f, "Maximum line-of-sight target search range."); ParasiteValuableDrainSeconds = config.Bind("The Parasite", "ValuableDrainSeconds", 10f, "Continuous beam time before a valuable loses 30 percent value and becomes fragile."); ParasiteDropEnemyValuable = config.Bind("The Parasite", "DropEnemyOrb", true, "Drop one small vanilla enemy orb after The Parasite is destroyed."); AuditorSpawnChance = config.Bind("The Auditor", "SpawnChance", 0.22f, "Relative EnemyDirector rarity weight for The Auditor (difficulty-2 slot). Zero disables automatic selection."); AuditorSpawnDelay = config.Bind("The Auditor", "SpawnDelay", 20f, "Legacy compatibility setting; automatic selection now occurs inside the vanilla enemy routine."); AuditorHealth = config.Bind("The Auditor", "Health", 65, "Low shared health of The Auditor's upgrade-box body and legs."); AuditorDamagePerHit = config.Bind("The Auditor", "DamagePerWeaponHit", 20, "Compatibility fallback damage when an attacking HurtCollider cannot be identified. Known weapons use vanilla damage."); AuditorHitDetectionPadding = config.Bind("The Auditor", "HitDetectionPadding", 0.28f, "Extra metres around visible pieces that accept nearby bullet endpoints."); AuditorChargeSpeed = config.Bind("The Auditor", "ChargeSpeed", 6.2f, "Movement speed while charging a player to steal one upgrade."); AuditorFleeSpeed = config.Bind("The Auditor", "FleeSpeed", 7.4f, "Movement speed after an upgrade has been stolen."); AuditorSearchRange = config.Bind("The Auditor", "SearchRange", 30f, "Maximum distance at which The Auditor selects a living player who owns an upgrade."); AuditorContactDamage = config.Bind("The Auditor", "ContactDamage", 8, "Small damage dealt when The Auditor reaches a theft or retaliation target."); AuditorKnockbackForce = config.Bind("The Auditor", "KnockbackForce", 18f, "Strong horizontal tumble force applied with The Auditor's contact hit."); AuditorDropEnemyValuable = config.Bind("The Auditor", "DropEnemyOrb", true, "Drop one small vanilla enemy orb on death; a carried stolen upgrade box is returned separately."); PlaybackSpawnChance = config.Bind("The Backlash", "SpawnChance", 0.2f, "Relative EnemyDirector rarity weight for The Backlash (difficulty-2 slot). Zero disables automatic selection."); PlaybackSpawnDelay = config.Bind("The Backlash", "SpawnDelay", 22f, "Legacy compatibility setting; automatic selection now occurs inside the vanilla enemy routine."); PlaybackHealth = config.Bind("The Backlash", "Health", 350, "Shared health of The Backlash's Jackhammer squid body."); PlaybackDamagePerHit = config.Bind("The Backlash", "DamagePerWeaponHit", 20, "Compatibility fallback damage when an attacking HurtCollider cannot be identified. Known weapons use vanilla damage."); PlaybackHitDetectionPadding = config.Bind("The Backlash", "HitDetectionPadding", 0.34f, "Extra metres around the assembled squid body that accept nearby bullet endpoints."); PlaybackRoamSpeed = config.Bind("The Backlash", "RoamSpeed", 2.55f, "Movement speed while The Backlash floats and searches for a victim."); PlaybackRecordSeconds = config.Bind("The Backlash", "LegacyRecordSeconds", 10f, "Reserved compatibility value; The Backlash now records its own ricochet route."); PlaybackReplaySpeed = config.Bind("The Backlash", "LegacyReplaySpeedMultiplier", 1.9f, "Reserved compatibility value; rewind speed is authored by The Backlash controller."); PlaybackContactDamage = config.Bind("The Backlash", "ChargeContactDamage", 55, "Damage dealt by each Backlash charge segment's direct swept contact (minimum 55)."); PlaybackContactRadius = config.Bind("The Backlash", "ChargeContactRadius", 1.25f, "Host-authoritative contact radius during a charge."); PlaybackDropEnemyValuable = config.Bind("The Backlash", "DropEnemyOrb", true, "Drop one medium vanilla enemy orb after The Backlash is destroyed."); MimicSpawnChance = config.Bind("The Mimic", "SpawnChance", 0.18f, "Relative EnemyDirector rarity weight for The Mimic (difficulty-3 slot). Zero disables automatic selection."); MimicSpawnDelay = config.Bind("The Mimic", "SpawnDelay", 24f, "Legacy compatibility setting; automatic selection now occurs inside the vanilla enemy routine."); MimicHealth = config.Bind("The Mimic", "Health", 600, "Shared health of The Mimic's articulated vanilla-object body."); MimicStalkSpeed = config.Bind("The Mimic", "StalkSpeed", 2.7f, "Blind-spot relocation speed before The Mimic commits to a charge."); MimicChargeSpeed = config.Bind("The Mimic", "ChargeSpeed", 7.1f, "All-fours charge speed after a voice lure is answered or approached."); MimicRecordSeconds = config.Bind("The Mimic", "RecordSeconds", 5.6f, "Post-onset PCM capture duration. A rolling pre-roll is retained and audio is never written to disk."); MimicAttackDamage = config.Bind("The Mimic", "AttackDamage", 70, "Damage dealt by a completed Mimic charge."); MimicDropEnemyValuable = config.Bind("The Mimic", "DropEnemyOrb", true, "Drop one medium vanilla enemy orb after The Mimic is destroyed."); ConfectionerSpawnChance = config.Bind("The Confectioner", "SpawnChance", 0.2f, "Relative EnemyDirector rarity weight for The Confectioner (difficulty-2 slot). Zero disables automatic selection."); ConfectionerSpawnDelay = config.Bind("The Confectioner", "SpawnDelay", 26f, "Legacy compatibility setting; automatic selection now occurs inside the vanilla enemy routine."); ConfectionerHealth = config.Bind("The Confectioner", "Health", 300, "Shared health of The Confectioner's vending body and stepping legs."); ConfectionerDamagePerHit = config.Bind("The Confectioner", "DamagePerWeaponHit", 20, "Compatibility fallback damage when an attacking HurtCollider cannot be identified. Known weapons use vanilla damage."); ConfectionerHitDetectionPadding = config.Bind("The Confectioner", "HitDetectionPadding", 0.3f, "Extra metres around visible parts that accept player bullet endpoints."); ConfectionerMoveSpeed = config.Bind("The Confectioner", "MoveSpeed", 2.45f, "Walking speed while it dances between rooms and occasionally returns candy to extraction."); ConfectionerCandyInterval = config.Bind("The Confectioner", "CandyInterval", 7.5f, "Average seconds between placing indestructible candy, up to three pieces."); ConfectionerCandyValue = config.Bind("The Confectioner", "CandyValue", 1000f, "Exact dollar value assigned to each of its three candies."); ConfectionerDropEnemyValuable = config.Bind("The Confectioner", "DropEnemyOrb", true, "Drop one medium vanilla enemy orb after The Confectioner is destroyed."); UndertowSpawnChance = config.Bind("The Undertow", "SpawnChance", 0.2f, "Relative EnemyDirector rarity weight for The Undertow (difficulty-3 slot). Zero disables automatic selection."); UndertowSpawnDelay = config.Bind("The Undertow", "SpawnDelay", 25f, "Legacy compatibility setting; automatic selection now occurs inside the vanilla enemy routine."); UndertowHealth = config.Bind("The Undertow", "Health", 650, "Shared health across the visible swimming-anchor assembly."); UndertowDamagePerHit = config.Bind("The Undertow", "DamagePerWeaponHit", 20, "Compatibility fallback damage when an attacking HurtCollider cannot be identified. Known weapons use vanilla damage."); UndertowSwimSpeed = config.Bind("The Undertow", "SwimSpeed", 3.25f, "Smooth roaming speed before the anchor moors."); UndertowDetectionRange = config.Bind("The Undertow", "DetectionRange", 19f, "Maximum distance at which it begins swimming toward a player."); UndertowMooringRadius = config.Bind("The Undertow", "MooringRadius", 7f, "Radius of the descending waterline and inward pull."); UndertowMooringSeconds = config.Bind("The Undertow", "MooringSeconds", 10f, "Seconds for the visible waterline to descend from the ceiling to the anchor."); UndertowMooringBreakDamage = config.Bind("The Undertow", "MooringBreakDamage", 100, "Ordinary weapon damage required during a dive/mooring to interrupt it. TRANQ still interrupts immediately."); UndertowFinalDamage = config.Bind("The Undertow", "FinalSurgeDamage", 60, "Damage dealt to the moored target when the waterline reaches the floor."); UndertowDropEnemyValuable = config.Bind("The Undertow", "DropEnemyOrb", true, "Drop one medium vanilla enemy orb after The Undertow is destroyed."); CupidSpawnChance = config.Bind("The Cupid", "SpawnChance", 0.24f, "Relative EnemyDirector rarity weight for The Cupid (difficulty-2 slot). Zero disables automatic selection."); CupidSpawnDelay = config.Bind("The Cupid", "SpawnDelay", 18f, "Legacy compatibility setting; automatic selection now occurs inside the vanilla enemy routine."); CupidHealth = config.Bind("The Cupid", "Health", 260, "Shared health across all three visible Love Potion arrows."); CupidDamagePerHit = config.Bind("The Cupid", "DamagePerWeaponHit", 20, "Compatibility fallback damage when the attacking HurtCollider cannot be identified."); CupidSwimSpeed = config.Bind("The Cupid", "SwimSpeed", 2.35f, "Movement speed while searching for its two link endpoints."); CupidDetectionRange = config.Bind("The Cupid", "DetectionRange", 28f, "Maximum initial player detection range."); CupidTetherDistance = config.Bind("The Cupid", "TetherDistance", 7.5f, "Distance at which linked targets begin being tumbled toward one another along a valid NavMesh path."); CupidDamageShare = config.Bind("The Cupid", "DamageShareRatio", 0.5f, "Fraction of player damage mirrored to the other linked player. Range 0-1."); CupidDropEnemyValuable = config.Bind("The Cupid", "DropEnemyOrb", true, "Drop one medium vanilla enemy orb after The Cupid is destroyed."); MarionetteSpawnChance = config.Bind("The Marionette", "SpawnChance", 0.22f, "Relative EnemyDirector rarity weight for The Marionette (difficulty-2 slot). Zero disables automatic selection."); MarionetteSpawnDelay = config.Bind("The Marionette", "SpawnDelay", 20f, "Legacy compatibility setting; automatic selection now occurs inside the vanilla enemy routine."); MarionetteHealth = config.Bind("The Marionette", "Health", 180, "Health of the visible Feather Drone puppet master."); MarionetteDamagePerHit = config.Bind("The Marionette", "DamagePerWeaponHit", 20, "Compatibility fallback damage when the attacking HurtCollider cannot be identified."); MarionetteMoveSpeed = config.Bind("The Marionette", "MoveSpeed", 1.75f, "Slow floating speed while searching for an enemy to manipulate."); MarionetteDisarmSeconds = config.Bind("The Marionette", "DisarmSeconds", 7f, "Seconds an attacking player is forced to drop and cannot hold objects."); MarionetteDropEnemyValuable = config.Bind("The Marionette", "DropEnemyOrb", true, "Drop one medium vanilla enemy orb after The Marionette is destroyed."); DeliriumSpawnChance = BindHiddenWip(config, "The Delirium", "SpawnChance", 0.004f, "Relative EnemyDirector rarity weight for The Delirium (difficulty-2 slot). Zero disables automatic selection."); RoamSpeed = config.Bind("Movement", "RoamSpeed", 2.8f, "Movement speed of the invisible host-side navigation anchor."); VisionRange = config.Bind("Movement", "VisionRange", 27f, "Maximum player detection distance."); OrbitRadius = config.Bind("Visual", "OrbitRadius", 0.1f, "Radius of the vertical three-gun orbit. Runtime safety clamps this to 0.10-0.42."); OrbitSpeed = config.Bind("Visual", "OrbitDegreesPerSecond", 95f, "Normal orbit speed in degrees per second."); AttackOrbitSpeedMultiplier = config.Bind("Visual", "AttackOrbitSpeedMultiplier", 2.65f, "Orbit speed multiplier while warning and firing. Runtime safety clamps this to 1.0-4.0."); GunVisualScale = config.Bind("Visual", "GunScale", 1.18f, "Networked visual and physical scale of each TRANQ GUN. Runtime safety clamps this to 1.0-1.3."); _tuningRevision = config.Bind("Internal", "TuningRevision", 0, "Internal default-value migration revision. Do not edit."); if (_tuningRevision.Value < 1) { if (Mathf.Approximately(FireAimError.Value, 10f)) { FireAimError.Value = 8f; } _tuningRevision.Value = 1; } if (_tuningRevision.Value < 2) { if (Mathf.Approximately(OrbitRadius.Value, 0.36f)) { OrbitRadius.Value = 0.33f; } if (Mathf.Approximately(GunVisualScale.Value, 1.12f)) { GunVisualScale.Value = 1.16f; } _tuningRevision.Value = 2; } if (_tuningRevision.Value < 3) { if (Mathf.Approximately(OrbitRadius.Value, 0.33f)) { OrbitRadius.Value = 0.26f; } if (Mathf.Approximately(FireAimError.Value, 8f)) { FireAimError.Value = 5.5f; } _tuningRevision.Value = 3; } if (_tuningRevision.Value < 4) { if (Mathf.Approximately(OrbitRadius.Value, 0.26f)) { OrbitRadius.Value = 0.15f; } if (Mathf.Approximately(FireAimError.Value, 5.5f)) { FireAimError.Value = 0.1f; } if (Mathf.Approximately(GunVisualScale.Value, 1.16f)) { GunVisualScale.Value = 1.14f; } _tuningRevision.Value = 4; } if (_tuningRevision.Value < 5) { if (Mathf.Approximately(OrbitRadius.Value, 0.15f)) { OrbitRadius.Value = 0.12f; } _tuningRevision.Value = 5; } if (_tuningRevision.Value < 6) { if (Mathf.Approximately(ShotInterval.Value, 0.12f)) { ShotInterval.Value = 0.7f; } _tuningRevision.Value = 6; } if (_tuningRevision.Value < 7) { if (PlayerDamagePerHit.Value == 8) { PlayerDamagePerHit.Value = 15; } _tuningRevision.Value = 7; } if (_tuningRevision.Value < 8) { if (Mathf.Approximately(OrbitRadius.Value, 0.12f)) { OrbitRadius.Value = 0.1f; } _tuningRevision.Value = 8; } if (_tuningRevision.Value < 9) { if (Mathf.Approximately(GunVisualScale.Value, 1.14f)) { GunVisualScale.Value = 1.18f; } _tuningRevision.Value = 9; } if (_tuningRevision.Value < 10) { if (Mathf.Approximately(EffigyObservationFov.Value, 115f)) { EffigyObservationFov.Value = 125f; } _tuningRevision.Value = 10; } if (_tuningRevision.Value < 11) { if (Mathf.Approximately(HitDetectionPadding.Value, 0.42f)) { HitDetectionPadding.Value = 0.82f; } else if (HitDetectionPadding.Value < 0.82f) { HitDetectionPadding.Value = 0.82f; } _tuningRevision.Value = 11; } if (_tuningRevision.Value < 12) { if (Mathf.Approximately(DeadAirHuntSpeed.Value, 6.2f)) { DeadAirHuntSpeed.Value = 5.89f; } if (Mathf.Approximately(DeadAirFleeSpeed.Value, 9.5f)) { DeadAirFleeSpeed.Value = 9.025f; } _tuningRevision.Value = 12; } if (_tuningRevision.Value < 13) { if (Mathf.Approximately(DeadAirHuntSpeed.Value, 5.89f)) { DeadAirHuntSpeed.Value = 5.3f; } if (Mathf.Approximately(DeadAirFleeSpeed.Value, 9.025f)) { DeadAirFleeSpeed.Value = 8.12f; } _tuningRevision.Value = 13; } if (_tuningRevision.Value < 14) { if (Mathf.Approximately(BellhopMoveSpeed.Value, 3.6f)) { BellhopMoveSpeed.Value = 3.24f; } if (Mathf.Approximately(BellhopRetreatSpeed.Value, 5.8f)) { BellhopRetreatSpeed.Value = 5.22f; } _tuningRevision.Value = 14; } if (_tuningRevision.Value < 15) { if (Mathf.Approximately(BrokerSuccessChance.Value, 0.7f)) { BrokerSuccessChance.Value = 1f; } if (Mathf.Approximately(BrokerValueMultiplier.Value, 1.5f)) { BrokerValueMultiplier.Value = 1.01f; } if (BrokerAttackDamage.Value == 35) { BrokerAttackDamage.Value = 15; } _tuningRevision.Value = 15; } if (_tuningRevision.Value < 16) { if (Mathf.Approximately(BrokerHostileSpeed.Value, 6.5f)) { BrokerHostileSpeed.Value = 5.85f; } _tuningRevision.Value = 16; } if (_tuningRevision.Value < 17) { _tuningRevision.Value = 17; } if (_tuningRevision.Value < 18) { if (DeadAirHealth.Value == 300) { DeadAirHealth.Value = 150; } if (Mathf.Approximately(DeadAirLoudNoiseRadius.Value, 5f)) { DeadAirLoudNoiseRadius.Value = 5.25f; } if (BrokerHealth.Value == 250) { BrokerHealth.Value = 100; } if (BellhopHealth.Value == 350) { BellhopHealth.Value = 200; } _tuningRevision.Value = 18; } if (_tuningRevision.Value < 19) { if (Mathf.Approximately(PlaybackRoamSpeed.Value, 2.15f)) { PlaybackRoamSpeed.Value = 2.55f; } if (Mathf.Approximately(PlaybackRecordSeconds.Value, 5f)) { PlaybackRecordSeconds.Value = 3.2f; } if (Mathf.Approximately(PlaybackReplaySpeed.Value, 1.35f)) { PlaybackReplaySpeed.Value = 1.75f; } _tuningRevision.Value = 19; } if (_tuningRevision.Value < 20) { if (PlaybackRecordSeconds.Value < 9.5f) { PlaybackRecordSeconds.Value = 10f; } _tuningRevision.Value = 20; } if (_tuningRevision.Value < 21) { if (Mathf.Approximately(MimicStalkSpeed.Value, 2.5f)) { MimicStalkSpeed.Value = 2.7f; } if (Mathf.Approximately(MimicRecordSeconds.Value, 3.4f)) { MimicRecordSeconds.Value = 5.6f; } if (Mathf.Approximately(ConfectionerCandyInterval.Value, 18f)) { ConfectionerCandyInterval.Value = 11f; } _tuningRevision.Value = 21; } if (_tuningRevision.Value < 22) { if (Mathf.Approximately(ConfectionerCandyInterval.Value, 11f)) { ConfectionerCandyInterval.Value = 7.5f; } _tuningRevision.Value = 22; } if (_tuningRevision.Value < 23) { if (Mathf.Approximately(ConfectionerMoveSpeed.Value, 2.2f)) { ConfectionerMoveSpeed.Value = 2.45f; } _tuningRevision.Value = 23; } if (_tuningRevision.Value < 24) { if (MimicHealth.Value == 250) { MimicHealth.Value = 600; } _tuningRevision.Value = 24; } if (_tuningRevision.Value < 25) { if (Mathf.Approximately(BurstCooldown.Value, 2.2f)) { BurstCooldown.Value = 1.9f; } if (Mathf.Approximately(AnatomistHeadInterval.Value, 13f)) { AnatomistHeadInterval.Value = 10f; } if (AnatomistCrushDamage.Value == 70) { AnatomistCrushDamage.Value = 80; } if (Mathf.Approximately(PlaybackReplaySpeed.Value, 1.75f)) { PlaybackReplaySpeed.Value = 1.9f; } if (PlaybackContactDamage.Value == 35 || PlaybackContactDamage.Value == 45) { PlaybackContactDamage.Value = 55; } if (Mathf.Approximately(PlaybackContactRadius.Value, 1.05f)) { PlaybackContactRadius.Value = 1.25f; } if (Mathf.Approximately(MimicChargeSpeed.Value, 6.75f)) { MimicChargeSpeed.Value = 7.1f; } if (MimicAttackDamage.Value == 45) { MimicAttackDamage.Value = 70; } _tuningRevision.Value = 25; } if (_tuningRevision.Value < 26) { _tuningRevision.Value = 26; } if (_tuningRevision.Value < 27) { if (UndertowFinalDamage.Value == 35) { UndertowFinalDamage.Value = 60; } _tuningRevision.Value = 27; } if (_tuningRevision.Value < 28) { if (Mathf.Approximately(EffigyMoveSpeed.Value, 12f)) { EffigyMoveSpeed.Value = 6f; } else if (EffigyMoveSpeed.Value > 6f) { EffigyMoveSpeed.Value = Mathf.Max(4f, EffigyMoveSpeed.Value * 0.5f); } _tuningRevision.Value = 28; } if (_tuningRevision.Value < 29) { if (Mathf.Approximately(EffigyMoveSpeed.Value, 6f)) { EffigyMoveSpeed.Value = 7.5f; } _tuningRevision.Value = 29; } if (_tuningRevision.Value < 30) { if (Mathf.Approximately(ModEnemySlotReplacementChance.Value, 0.3f) || Mathf.Approximately(ModEnemySlotReplacementChance.Value, 0.5f)) { ModEnemySlotReplacementChance.Value = 0.004f; } if (BrokerAttackDamage.Value == 15) { BrokerAttackDamage.Value = 10; } _tuningRevision.Value = 30; } if (_tuningRevision.Value < 31) { if (ModEnemySlotReplacementChance.Value > 0f && ModEnemySlotReplacementChance.Value <= 0.01f) { ConfigEntry modEnemySlotReplacementChance = ModEnemySlotReplacementChance; modEnemySlotReplacementChance.Value *= 100f; } _tuningRevision.Value = 31; } if (_tuningRevision.Value < 32) { if (Mathf.Approximately(ModEnemySlotReplacementChance.Value, 0.4f)) { ModEnemySlotReplacementChance.Value = 40f; } _tuningRevision.Value = 32; } if (_tuningRevision.Value < 33) { if (Mathf.Approximately(VisionRange.Value, 35f)) { VisionRange.Value = 27f; } if (Mathf.Approximately(HitDetectionPadding.Value, 0.82f)) { HitDetectionPadding.Value = 1.1f; } _tuningRevision.Value = 33; } if (_tuningRevision.Value < 34) { if (Mathf.Approximately(BrokerValueMultiplier.Value, 1.01f)) { BrokerValueMultiplier.Value = 1.1f; } _tuningRevision.Value = 34; } if (_tuningRevision.Value < 35) { if (Mathf.Approximately(BrokerValueMultiplier.Value, 1.1f)) { BrokerValueMultiplier.Value = 1.01f; } _tuningRevision.Value = 35; } if (_tuningRevision.Value < 36) { if (Mathf.Approximately(ConfectionerCandyValue.Value, 3000f)) { ConfectionerCandyValue.Value = 1000f; } _tuningRevision.Value = 36; } config.Save(); } private static ConfigEntry BindHiddenWip(ConfigFile config, string section, string key, T defaultValue, string description) { ConfigEntry val = config.Bind(section, key, defaultValue, description); config.Remove(((ConfigEntryBase)val).Definition); return val; } } internal sealed class CarouselPlayerLoopMarker { } internal interface IModEnemyTumbleReceiver { bool CanReceiveTumbleAttack { get; } void ReceiveTumbleAttack(int partIndex, int damage, Vector3 hitPosition, Vector3 direction); } internal sealed class TumbleHitProxy : MonoBehaviour { private static readonly Dictionary NextHitByPlayer = new Dictionary(); private static readonly Dictionary NextThrownHitBySource = new Dictionary(); private static readonly Dictionary NextSelfSlamByReceiver = new Dictionary(); private static readonly Dictionary NextStunHitByReceiverAndMine = new Dictionary(); private static readonly FieldInfo GrabbedTimerField = typeof(PhysGrabObject).GetField("grabbedTimer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo LastPlayerGrabbingField = typeof(PhysGrabObject).GetField("lastPlayerGrabbing", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo PlayerInputTriggeredField = typeof(PlayerTumble).GetField("isPlayerInputTriggered", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private IModEnemyTumbleReceiver _receiver; private int _partIndex; private PhysGrabObjectImpactDetector _impactDetector; internal IModEnemyTumbleReceiver Receiver => _receiver; internal bool CanTriggerPlayerTrap { get { if (_receiver != null && _receiver.CanReceiveTumbleAttack && !(_receiver is CarouselController)) { return !(_receiver is EffigyController); } return false; } } internal void Initialize(IModEnemyTumbleReceiver receiver, int partIndex) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown _receiver = receiver; _partIndex = partIndex; ModEnemyTranqStun.Register(receiver, ((Component)this).transform); _impactDetector = ((Component)this).GetComponentInParent() ?? ((Component)this).GetComponentInChildren(true); PhysGrabObjectImpactDetector impactDetector = _impactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.AddListener(new UnityAction(OnHurtColliderHit)); } } if (CanTriggerPlayerTrap) { ModEnemyTrapSensor.Attach(((Component)this).gameObject); } } private void OnDestroy() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown PhysGrabObjectImpactDetector impactDetector = _impactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.RemoveListener(new UnityAction(OnHurtColliderHit)); } } ModEnemyTranqStun.Unregister(_receiver, ((Component)this).transform); } private void OnHurtColliderHit() { //IL_0031: 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) ModEnemyTranqStun.TryApply(_receiver, ModEnemyWeaponDamage.Current, ((Object)(object)_impactDetector != (Object)null) ? ((Component)_impactDetector).transform.position : ((Component)this).transform.position); } internal void ReceiveStunMineHit(ItemMineStun mine, int damage, Vector3 hitPosition, Vector3 direction) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)mine == (Object)null || _receiver == null || !_receiver.CanReceiveTumbleAttack || !CanTriggerPlayerTrap || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } IModEnemyTumbleReceiver receiver = _receiver; MonoBehaviour val = (MonoBehaviour)((receiver is MonoBehaviour) ? receiver : null); if ((Object)(object)val == (Object)null) { return; } long key = ((long)((Object)val).GetInstanceID() << 32) ^ (uint)((Object)mine).GetInstanceID(); if (!NextStunHitByReceiverAndMine.TryGetValue(key, out var value) || !(Time.time < value)) { NextStunHitByReceiverAndMine[key] = Time.time + 0.48f; if (_receiver is DeliriumController deliriumController) { deliriumController.OnStunMineTriggered(); } else { _receiver.ReceiveTumbleAttack(_partIndex, Mathf.Clamp(damage, 1, 100), hitPosition, direction); } } } private void OnCollisionEnter(Collision collision) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) TrySelfSlam(collision); TryHit((collision != null) ? collision.collider : null); TryThrownHit((collision != null) ? collision.collider : null, (collision != null) ? collision.relativeVelocity : Vector3.zero); } private void OnCollisionStay(Collision collision) { TryHit((collision != null) ? collision.collider : null); } private void OnTriggerEnter(Collider other) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) TryHit(other); TryThrownHit(other, Vector3.zero); } private void OnTriggerStay(Collider other) { TryHit(other); } private void TryHit(Collider other) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) if (_receiver == null || !_receiver.CanReceiveTumbleAttack || !SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)other == (Object)null || _receiver is BrokerController) { return; } PlayerTumble componentInParent = ((Component)other).GetComponentInParent(); PhysGrabObject val = ((componentInParent != null) ? ((Component)componentInParent).GetComponent() : null); Rigidbody val2 = ((componentInParent != null) ? ((Component)componentInParent).GetComponent() : null); if ((Object)(object)componentInParent == (Object)null || (Object)(object)val == (Object)null || (Object)(object)componentInParent.hurtCollider == (Object)null || (Object)(object)val2 == (Object)null || !((Component)componentInParent.hurtCollider).gameObject.activeSelf || !WasPlayerInputTumble(componentInParent)) { return; } Vector3 velocity = val2.velocity; if (!(((Vector3)(ref velocity)).sqrMagnitude < 16f)) { PhotonView component = ((Component)componentInParent).GetComponent(); int key = (((Object)(object)component != (Object)null) ? component.ViewID : ((Object)componentInParent).GetInstanceID()); if (!NextHitByPlayer.TryGetValue(key, out var value) || !(Time.time < value)) { NextHitByPlayer[key] = Time.time + 0.5f; int num = (((Object)(object)componentInParent.hurtCollider != (Object)null && componentInParent.hurtCollider.enemyDamage > 0) ? componentInParent.hurtCollider.enemyDamage : 25); Vector3 hitPosition = other.ClosestPoint(((Component)this).transform.position); _receiver.ReceiveTumbleAttack(_partIndex, Mathf.Clamp(num, 1, 100), hitPosition, ((Vector3)(ref velocity)).normalized); componentInParent.OverrideEnemyHurt(0.5f); componentInParent.HitEnemy(); } } } private void TryThrownHit(Collider other, Vector3 relativeVelocity) { //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) if (_receiver == null || !_receiver.CanReceiveTumbleAttack || !SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)other == (Object)null || (Object)(object)((Component)other).GetComponentInParent() != (Object)null) { return; } PhysGrabObject componentInParent = ((Component)other).GetComponentInParent(); EnemyRigidbody componentInParent2 = ((Component)other).GetComponentInParent(); if ((((Object)(object)componentInParent == (Object)null || componentInParent.dead) && (Object)(object)componentInParent2 == (Object)null) || ((Object)(object)componentInParent != (Object)null && ((Object)(object)((Component)componentInParent).GetComponent() != (Object)null || (Object)(object)((Component)componentInParent).GetComponentInParent() != (Object)null || (Object)(object)((Component)componentInParent).GetComponentInChildren(true) != (Object)null)) || (Object)(object)componentInParent == (Object)null || !WasRecentlyHeldByPlayer(componentInParent)) { return; } PhysGrabObject componentInParent3 = ((Component)this).GetComponentInParent(); if (((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent == (Object)(object)componentInParent3) || (_receiver is BrokerController brokerController && brokerController.IsIntendedFoodDelivery(componentInParent))) { return; } Rigidbody val = componentInParent?.rb ?? other.attachedRigidbody ?? ((componentInParent2 != null) ? ((Component)componentInParent2).GetComponent() : null); if ((Object)(object)val == (Object)null || val.isKinematic) { return; } Vector3 val2 = val.velocity; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude < 2f) { return; } bool flag = (Object)(object)componentInParent != (Object)null && ((Object)(object)((Component)componentInParent).GetComponent() != (Object)null || (Object)(object)((Component)componentInParent).GetComponentInChildren(true) != (Object)null || (Object)(object)((Component)componentInParent).GetComponentInParent() != (Object)null || ((Component)componentInParent).gameObject.layer == LayerMask.NameToLayer("PhysGrabObjectCart")); if (flag && magnitude < 8f && ((Vector3)(ref relativeVelocity)).magnitude < 9.5f) { return; } float num = Mathf.Max(magnitude, ((Vector3)(ref relativeVelocity)).magnitude); float num2 = Mathf.Clamp(val.mass, 0.25f, 30f); float num3 = num * Mathf.Sqrt(num2); if (num < 3.25f || num3 < 4.5f) { return; } PhotonView componentInParent4 = ((Component)val).GetComponentInParent(); int key = (((Object)(object)componentInParent4 != (Object)null && componentInParent4.ViewID != 0) ? componentInParent4.ViewID : ((Object)val).GetInstanceID()); if (!NextThrownHitBySource.TryGetValue(key, out var value) || !(Time.time < value)) { NextThrownHitBySource[key] = Time.time + 0.65f; int damage = Mathf.Clamp(Mathf.RoundToInt(num3 * 3f), 10, flag ? 35 : 100); damage = ParasiteEffectRegistry.ModifyEnemyDamageAt(((Component)this).transform.position, damage); val2 = val.velocity; Vector3 normalized; if (!(((Vector3)(ref val2)).sqrMagnitude > 0.01f)) { val2 = ((Component)this).transform.position - val.worldCenterOfMass; normalized = ((Vector3)(ref val2)).normalized; } else { val2 = val.velocity; normalized = ((Vector3)(ref val2)).normalized; } Vector3 direction = normalized; Vector3 hitPosition = other.ClosestPoint(((Component)this).transform.position); _receiver.ReceiveTumbleAttack(_partIndex, damage, hitPosition, direction); } } private void TrySelfSlam(Collision collision) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0167: 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_016f: 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_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: 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_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: 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) if (_receiver == null || !_receiver.CanReceiveTumbleAttack || !SemiFunc.IsMasterClientOrSingleplayer() || collision == null || (Object)(object)collision.collider == (Object)null) { return; } IModEnemyTumbleReceiver receiver = _receiver; MonoBehaviour val = (MonoBehaviour)((receiver is MonoBehaviour) ? receiver : null); PhysGrabObject val2 = ((Component)this).GetComponent() ?? ((Component)this).GetComponentInParent(); Rigidbody val3 = val2?.rb ?? ((Component)this).GetComponentInParent(); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || val3.isKinematic || !WasRecentlyHeldByPlayer(val2)) { return; } Transform transform = ((Component)collision.collider).transform; if ((Object)(object)transform == (Object)(object)((Component)val).transform || transform.IsChildOf(((Component)val).transform)) { return; } Vector3 val4 = val3.velocity; float magnitude = ((Vector3)(ref val4)).magnitude; val4 = collision.relativeVelocity; float num = Mathf.Max(magnitude, ((Vector3)(ref val4)).magnitude); float num2 = Mathf.Clamp(val3.mass, 0.25f, 30f); float num3 = num * Mathf.Sqrt(num2); if (num < 3.4f || num3 < 4.8f) { return; } int instanceID = ((Object)val).GetInstanceID(); if (!NextSelfSlamByReceiver.TryGetValue(instanceID, out var value) || !(Time.time < value)) { NextSelfSlamByReceiver[instanceID] = Time.time + 0.62f; Vector3 val5; if (collision.contactCount <= 0) { val5 = val3.worldCenterOfMass; } else { ContactPoint contact = collision.GetContact(0); val5 = ((ContactPoint)(ref contact)).point; } Vector3 hitPosition = val5; val4 = collision.relativeVelocity; Vector3 val6; if (!(((Vector3)(ref val4)).sqrMagnitude > 0.01f)) { val4 = val3.velocity; val6 = -((Vector3)(ref val4)).normalized; } else { val4 = collision.relativeVelocity; val6 = -((Vector3)(ref val4)).normalized; } Vector3 direction = val6; int damage = Mathf.Clamp(Mathf.RoundToInt(num3 * 3.2f), 10, 85); damage = ParasiteEffectRegistry.ModifyEnemyDamageAt(((Component)val).transform.position, damage); _receiver.ReceiveTumbleAttack(_partIndex, damage, hitPosition, direction); } } private static bool WasPlayerInputTumble(PlayerTumble tumble) { if ((Object)(object)tumble == (Object)null || PlayerInputTriggeredField == null) { return false; } try { return (bool)PlayerInputTriggeredField.GetValue(tumble); } catch { return false; } } private static bool WasRecentlyHeldByPlayer(PhysGrabObject phys) { if ((Object)(object)phys == (Object)null) { return false; } if (phys.playerGrabbing != null && phys.playerGrabbing.Count > 0) { return true; } try { float num = ((GrabbedTimerField != null) ? ((float)GrabbedTimerField.GetValue(phys)) : 0f); object? obj = LastPlayerGrabbingField?.GetValue(phys); PlayerAvatar val = (PlayerAvatar)((obj is PlayerAvatar) ? obj : null); return num > 0.02f && (Object)(object)val != (Object)null; } catch { return false; } } } public static class UncataloguedDebugApi { public readonly struct EncounterInfo { public string Id { get; } public string DisplayName { get; } public EncounterInfo(string id, string displayName) { Id = id; DisplayName = displayName; } } private sealed class Encounter { internal string Id; internal string DisplayName; internal Func Spawn; internal Action Despawn; } private static readonly object Sync = new object(); private static readonly Dictionary ByKey = new Dictionary(StringComparer.OrdinalIgnoreCase); private static readonly List Ordered = new List(); internal static void Clear() { lock (Sync) { ByKey.Clear(); Ordered.Clear(); } } internal static void Register(string id, string displayName, Func spawn, Action despawn) { if (string.IsNullOrWhiteSpace(id) || string.IsNullOrWhiteSpace(displayName) || spawn == null || despawn == null) { return; } Encounter encounter = new Encounter { Id = id, DisplayName = displayName, Spawn = spawn, Despawn = despawn }; lock (Sync) { Ordered.Add(encounter); AddKey(id, encounter); AddKey(displayName, encounter); int num = id.LastIndexOf('.'); if (num >= 0 && num + 1 < id.Length) { AddKey(id.Substring(num + 1), encounter); } } } private static void AddKey(string key, Encounter encounter) { ByKey[key] = encounter; if (key.StartsWith("The ", StringComparison.OrdinalIgnoreCase)) { ByKey[key.Substring(4)] = encounter; } } public static EncounterInfo[] GetEncounters() { lock (Sync) { EncounterInfo[] array = new EncounterInfo[Ordered.Count]; for (int i = 0; i < Ordered.Count; i++) { array[i] = new EncounterInfo(Ordered[i].Id, Ordered[i].DisplayName); } return array; } } public static bool TrySpawn(string idOrDisplayName, Vector3 worldPosition) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (!CanMutate() || !TryGet(idOrDisplayName, out var encounter)) { return false; } try { return encounter.Spawn(worldPosition); } catch (Exception arg) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)$"External debug spawn failed for {encounter.DisplayName}: {arg}"); } return false; } } public static bool TrySpawnNearLocalPlayer(string idOrDisplayName) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (!TryFindLocalSpawnPoint(out var position)) { return false; } return TrySpawn(idOrDisplayName, position); } public static bool TryDespawn(string idOrDisplayName) { if (!CanMutate() || !TryGet(idOrDisplayName, out var encounter)) { return false; } try { encounter.Despawn(); return true; } catch (Exception arg) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)$"External debug despawn failed for {encounter.DisplayName}: {arg}"); } return false; } } private static bool TryGet(string key, out Encounter encounter) { encounter = null; if (string.IsNullOrWhiteSpace(key)) { return false; } lock (Sync) { return ByKey.TryGetValue(key.Trim(), out encounter); } } private static bool CanMutate() { try { return SemiFunc.IsMasterClientOrSingleplayer(); } catch { return false; } } private static bool TryFindLocalSpawnPoint(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; try { List list = SemiFunc.PlayerGetList(); if (list != null) { foreach (PlayerAvatar item in list) { if (!((Object)(object)item == (Object)null) && !((Object)(object)item.photonView == (Object)null) && item.photonView.IsMine) { Vector3 forward = ((Component)item).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.01f) { forward = Vector3.forward; } position = ((Component)item).transform.position + ((Vector3)(ref forward)).normalized * 3.4f + Vector3.up * 0.15f; return true; } } } Camera main = Camera.main; if ((Object)(object)main != (Object)null) { Vector3 forward2 = ((Component)main).transform.forward; forward2.y = 0f; position = ((Component)main).transform.position + ((Vector3)(ref forward2)).normalized * 3.4f - Vector3.up * 1.1f; return true; } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)("Could not find external debug spawn point: " + ex.Message)); } } return false; } } internal sealed class UndertowController : MonoBehaviour, IModEnemyTumbleReceiver, IModEnemyTranqAware { private enum UndertowState { Roam, Approach, Dive, Moored, Recover, Dead } private const float CompletedMooringCooldown = 8.5f; private static readonly MethodInfo NewRayHitPointMethod = typeof(ItemDrone).GetMethod("NewRayHitPoint", BindingFlags.Instance | BindingFlags.NonPublic); private readonly List _anchorParts = new List(); private readonly List _pullableItems = new List(); private SpawnedUndertow _spawned; private NavMeshAgent _agent; private PlayerAvatar _target; private UndertowState _state; private int _health; private float _stateTimer; private float _scanTimer; private float _destinationTimer; private float _forceTimer; private float _soundTimer; private float _rewardTimer; private float _attackCooldown; private float _targetLastSeenAt = -999f; private float _attackCommittedUntil = -999f; private float _waterBeamRetry; private float _countdownBeamRetry; private float _pullableScanTimer; private int _mooringBreakDamage; private float _lastClaimedHit = -999f; private float _swimHeight = 1.16f; private float _waterStartY; private float _waterEndY; private float _waterY; private float _swimPhase; private float _turnBank; private float _diveStartHeight; private Vector3 _visualForward = Vector3.forward; private Quaternion _visualRotation = Quaternion.identity; private Quaternion _diveStartRotation = Quaternion.identity; private Vector3 _mooringPosition; private bool _initialized; private bool _dead; private bool _cleaning; private bool _rewardDropped; private bool _finalSurgeApplied; private bool _mooringPositionLocked; private bool _waterBeamsWarm; private bool _waterBeamsReady; private bool _countdownBeamsWarm; private bool _countdownBeamsReady; private bool _pullableDiagnosticsLogged; public bool CanReceiveTumbleAttack { get { if (_initialized) { return !_dead; } return false; } } internal bool Initialize(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; _health = Mathf.Max(1, Plugin.Settings.UndertowHealth.Value); _agent = ((Component)this).gameObject.AddComponent(); ((Behaviour)_agent).enabled = false; _agent.speed = Mathf.Max(1f, Plugin.Settings.UndertowSwimSpeed.Value); _agent.acceleration = 9f; _agent.angularSpeed = 190f; _agent.radius = 0.42f; _agent.height = 1.25f; _agent.stoppingDistance = 0.8f; _spawned = UndertowSpawner.Spawn(position + Vector3.up * _swimHeight); if (_spawned == null) { return false; } int num = 0; foreach (UndertowPart part in _spawned.Parts) { if (!((Object)(object)part?.Spawned?.Phys == (Object)null) && !part.IsWaterMarker) { _anchorParts.Add(part); ((Component)part.Spawned.Phys).gameObject.AddComponent().Initialize(this, part.Spawned, num); ((Component)part.Spawned.Phys).gameObject.AddComponent().Initialize(this, num); num++; } } foreach (UndertowPart part2 in _spawned.Parts) { if (part2?.Spawned != null) { DeadAirSpawner.RefreshRenderedGeometry(part2.Spawned); part2.Spawned.GeometryCalibrationFrames = 0; } } _state = UndertowState.Roam; _scanTimer = 0.2f; _destinationTimer = 0.15f; _soundTimer = Random.Range(0.7f, 1.2f); _swimPhase = Random.Range(0f, MathF.PI * 2f); _visualRotation = Quaternion.identity; _initialized = true; PinVisuals(immediate: true); Plugin.Log.LogInfo((object)$"The Undertow assembled an eleven-part porcelain swimming anchor and two independent eight-beam warning rings with {_health} HP."); return true; } internal bool ActivateNavigation(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = position; return ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform, 6f); } private void Update() { if (!_initialized || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (_dead) { UpdateDeath(); return; } _scanTimer -= Time.deltaTime; _destinationTimer -= Time.deltaTime; _forceTimer -= Time.deltaTime; _soundTimer -= Time.deltaTime; _attackCooldown = Mathf.Max(0f, _attackCooldown - Time.deltaTime); _waterBeamRetry = Mathf.Max(0f, _waterBeamRetry - Time.deltaTime); _countdownBeamRetry = Mathf.Max(0f, _countdownBeamRetry - Time.deltaTime); _stateTimer += Time.deltaTime; if (_scanTimer <= 0f) { _scanTimer = 0.22f; RefreshTarget(); } switch (_state) { case UndertowState.Roam: UpdateRoam(); break; case UndertowState.Approach: UpdateApproach(); break; case UndertowState.Dive: UpdateDive(); break; case UndertowState.Moored: UpdateMoored(); break; case UndertowState.Recover: UpdateRecover(); break; } UpdateSwimDirection(); PinVisuals(immediate: false); UpdateAudio(); } private void UpdateRoam() { _swimHeight = Mathf.MoveTowards(_swimHeight, 1.16f, Time.deltaTime * 1.8f); if (GunAccess.IsLiving(_target)) { SetState(UndertowState.Approach); } else if (!(_destinationTimer > 0f)) { _destinationTimer = Random.Range(2.4f, 4f); _agent.speed = Mathf.Max(1f, Plugin.Settings.UndertowSwimSpeed.Value); ModEnemyNavigation.TrySetLocalRoamDestination(_agent, ((Component)this).transform, 5.5f, 14f); } } private void UpdateApproach() { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(_target)) { _target = null; SetState(UndertowState.Roam); return; } if (_destinationTimer <= 0f) { _destinationTimer = 0.22f; _agent.speed = Mathf.Max(1f, Plugin.Settings.UndertowSwimSpeed.Value * 1.12f); ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, ((Component)_target).transform.position, 1.15f); } Vector3 val = ((Component)_target).transform.position - ((Component)this).transform.position; val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; bool flag = HasLineOfSight(_target); if (flag) { _targetLastSeenAt = Time.time; _attackCommittedUntil = Mathf.Max(_attackCommittedUntil, Time.time + 8f); } if (_attackCooldown <= 0f && _stateTimer >= 0.28f && magnitude <= 11.5f && (magnitude <= 1.65f || flag || Time.time <= _attackCommittedUntil || Time.time - _targetLastSeenAt <= 3f)) { StopAgent(); _diveStartHeight = _swimHeight; _diveStartRotation = _visualRotation; SetState(UndertowState.Dive); _bodyImpact(84f); } } private void UpdateDive() { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) StopAgent(); float num = Mathf.Sin(Mathf.Clamp01(_stateTimer / 0.34f) * MathF.PI) * 0.12f; float num2 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((_stateTimer - 0.16f) / 1.12f)); _swimHeight = Mathf.Lerp(_diveStartHeight, 0.68f, num2) + num; if (!(_stateTimer < 1.28f)) { _mooringBreakDamage = 0; _mooringPosition = ((Component)this).transform.position; _mooringPositionLocked = true; if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled) { _agent.updatePosition = false; _agent.updateRotation = false; _agent.nextPosition = _mooringPosition; } _waterEndY = ((Component)this).transform.position.y + 0.32f; _waterStartY = FindCeilingHeight(); _waterY = _waterStartY; _finalSurgeApplied = false; _pullableDiagnosticsLogged = false; SetState(UndertowState.Moored); _bodyImpact(145f); Plugin.Log.LogInfo((object)$"The Undertow moored at {((Component)this).transform.position}; waterline {_waterStartY:F2}->{_waterEndY:F2}."); } } private void UpdateMoored() { //IL_0024: 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) StopAgent(); LockMooringPosition(); if (!GunAccess.IsLiving(_target) || HorizontalDistance(((Component)_target).transform.position, ((Component)this).transform.position) > 17f) { CancelMooring(); return; } float num = Mathf.Max(4f, Plugin.Settings.UndertowMooringSeconds.Value); float num2 = Mathf.Clamp01(_stateTimer / num); _waterY = Mathf.Lerp(_waterStartY, _waterEndY, Mathf.SmoothStep(0f, 1f, num2)); if (_forceTimer <= 0f) { _forceTimer = 0.04f; ApplyUndertowForces(num2); } if (num2 >= 1f && !_finalSurgeApplied && _stateTimer >= num + 0.22f) { _finalSurgeApplied = true; ApplyFinalSurge(); CancelMooring(8.5f); } } private void UpdateRecover() { _swimHeight = Mathf.MoveTowards(_swimHeight, 1.16f, Time.deltaTime * 0.78f); if (!(_stateTimer < 0.65f)) { SetState(GunAccess.IsLiving(_target) ? UndertowState.Approach : UndertowState.Roam); _destinationTimer = 0f; } } private void RefreshTarget() { //IL_0048: 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) //IL_00fd: 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_0112: Unknown result type (might be due to invalid IL or missing references) if (_state == UndertowState.Dive || _state == UndertowState.Moored) { return; } float num = Mathf.Max(5f, Plugin.Settings.UndertowDetectionRange.Value); if (GunAccess.IsLiving(_target)) { float num2 = Vector3.Distance(((Component)_target).transform.position, ((Component)this).transform.position); if (HasLineOfSight(_target)) { _targetLastSeenAt = Time.time; _attackCommittedUntil = Mathf.Max(_attackCommittedUntil, Time.time + 8f); return; } if (num2 <= num * 1.35f && (Time.time <= _attackCommittedUntil || Time.time - _targetLastSeenAt <= 6f)) { return; } } _target = null; PlayerAvatar val = null; float num3 = num * num; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item) && HasLineOfSight(item)) { Vector3 val2 = ((Component)item).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num3) { num3 = sqrMagnitude; val = item; } } } if ((Object)(object)val != (Object)null) { _target = val; _targetLastSeenAt = Time.time; _attackCommittedUntil = Time.time + 8f; Plugin.Log.LogInfo((object)$"The Undertow acquired a visible player at {Mathf.Sqrt(num3):F1}m; preparing to moor."); } } private void ApplyUndertowForces(float progress) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0311: 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_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: 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_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(3.5f, Plugin.Settings.UndertowMooringRadius.Value); float num2 = Mathf.Lerp(0.11f, 0.286f, progress); foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (!GunAccess.IsLiving(item)) { continue; } Vector3 position = ((Component)item).transform.position; float num3 = HorizontalDistance(position, ((Component)this).transform.position); if (position.y <= _waterY + 0.3f && num3 <= num + 3f) { Vector3 val = ((Component)this).transform.position - position; val.y = 0f; Vector3 val2 = Vector3.down * num2; if (num3 > num * 0.2f && ((Vector3)(ref val)).sqrMagnitude > 0.01f) { val2 += ((Vector3)(ref val)).normalized * Mathf.Lerp(0.154f, 0.429f, progress); } item.ForceImpulse(val2); } } _pullableScanTimer -= 0.04f; if (_pullableScanTimer <= 0f) { _pullableScanTimer = 0.5f; RefreshPullableItems(); } foreach (PhysGrabObject pullableItem in _pullableItems) { Rigidbody val3 = pullableItem?.rb; if ((Object)(object)val3 == (Object)null || (Object)(object)pullableItem == (Object)null || pullableItem.dead || LowestEnabledColliderY(pullableItem, val3.worldCenterOfMass.y) > _waterY + 0.25f) { continue; } Vector3 val4 = ((Component)this).transform.position - val3.worldCenterOfMass; val4.y = 0f; if (!(((Vector3)(ref val4)).sqrMagnitude > (num + 2f) * (num + 2f))) { Vector3 val5 = Vector3.down * (num2 * 0.55f); if (((Vector3)(ref val4)).sqrMagnitude > 0.04f) { val5 += ((Vector3)(ref val4)).normalized * Mathf.Lerp(5.25f, 12.2f, progress); } if (!val3.isKinematic) { val3.WakeUp(); Vector3 val6 = ((((Vector3)(ref val4)).sqrMagnitude > 0.04f) ? (((Vector3)(ref val4)).normalized * Mathf.Lerp(1.75f, 4.4f, progress)) : Vector3.zero); val6.y = Mathf.Min(-0.12f, val3.velocity.y); Vector3 val7 = val6 - val3.velocity; val7 = Vector3.ClampMagnitude(val7, Mathf.Lerp(0.24f, 0.52f, progress)); val3.AddForce(val7, (ForceMode)2); } else { Vector3 val8 = ((Vector3)(ref val5)).normalized * Mathf.Lerp(0.042f, 0.113f, progress); Vector3 val9 = val3.position + val8; pullableItem.SetPositionLogic(val9, val3.rotation); } } } } private void RefreshPullableItems() { _pullableItems.Clear(); HashSet hashSet = new HashSet(); PhysGrabObject[] array = Object.FindObjectsOfType(); foreach (PhysGrabObject val in array) { if (!((Object)(object)val == (Object)null) && !val.dead && !((Object)(object)val.rb == (Object)null) && ((Component)val).gameObject.activeInHierarchy && !IsOwnPhys(val) && hashSet.Add(val.rb) && !((Object)(object)((Component)val).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)val).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)val).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)val).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)val).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)val).GetComponentInChildren(true) != (Object)null)) { ValuableObject val2 = FindInItemScope(val); if (!((Object)(object)val2 != (Object)null) || !MapIconSuppressor.OwnsValuable(val2)) { _pullableItems.Add(val); } } } if (_pullableDiagnosticsLogged) { return; } _pullableDiagnosticsLogged = true; int num = 0; List list = new List(); foreach (PhysGrabObject pullableItem in _pullableItems) { if ((Object)(object)pullableItem?.rb != (Object)null && pullableItem.rb.isKinematic) { num++; } if (list.Count < 18 && (Object)(object)pullableItem != (Object)null) { ValuableObject val3 = FindInItemScope(pullableItem); list.Add(((Object)(object)val3 != (Object)null) ? ((Object)val3).name : ((Object)pullableItem).name); } } Plugin.Log.LogInfo((object)($"The Undertow current discovered {_pullableItems.Count} movable object(s) " + string.Format("({0} kinematic); sample: {1}.", num, string.Join(", ", list)))); } private static T FindInItemScope(PhysGrabObject phys) where T : Component { if ((Object)(object)phys == (Object)null) { return default(T); } T val = ((Component)phys).GetComponentInParent() ?? ((Component)phys).GetComponentInChildren(true); if ((Object)(object)val != (Object)null) { return val; } PhotonView componentInParent = ((Component)phys).GetComponentInParent(); if (!((Object)(object)componentInParent != (Object)null)) { return default(T); } return ((Component)componentInParent).GetComponentInChildren(true); } private bool IsOwnPhys(PhysGrabObject phys) { foreach (UndertowPart item in _spawned?.Parts ?? new List()) { if ((Object)(object)item?.Spawned?.Phys == (Object)(object)phys) { return true; } } foreach (MarionetteDronePart item2 in _spawned?.WaterBeams ?? new List()) { if ((Object)(object)item2?.Phys == (Object)(object)phys) { return true; } } foreach (MarionetteDronePart item3 in _spawned?.CountdownBeams ?? new List()) { if ((Object)(object)item3?.Phys == (Object)(object)phys) { return true; } } return false; } private static float LowestEnabledColliderY(PhysGrabObject phys, float fallback) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) float num = float.PositiveInfinity; Collider[] componentsInChildren = ((Component)phys).GetComponentsInChildren(true); foreach (Collider val in componentsInChildren) { if ((Object)(object)val != (Object)null && val.enabled) { float num2 = num; Bounds bounds = val.bounds; num = Mathf.Min(num2, ((Bounds)(ref bounds)).min.y); } } if (!float.IsPositiveInfinity(num)) { return num; } return fallback; } private void LockMooringPosition() { //IL_0010: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) if (!_mooringPositionLocked) { return; } ((Component)this).transform.position = _mooringPosition; if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.nextPosition = _mooringPosition; _agent.velocity = Vector3.zero; } foreach (UndertowPart anchorPart in _anchorParts) { Rigidbody val = anchorPart?.Spawned?.Phys?.rb; if (!((Object)(object)val == (Object)null) && !val.isKinematic) { val.velocity = Vector3.zero; val.angularVelocity = Vector3.zero; } } } private void ApplyFinalSurge() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0111: 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_0116: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(0, Plugin.Settings.UndertowFinalDamage.Value); float num2 = Mathf.Max(3.5f, Plugin.Settings.UndertowMooringRadius.Value) + 3f; int num3 = 0; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item) && !(HorizontalDistance(((Component)item).transform.position, ((Component)this).transform.position) > num2)) { PlayerHealth playerHealth = item.playerHealth; if (playerHealth != null) { playerHealth.HurtOther(num, ((Component)item).transform.position + Vector3.up * 0.5f, true, -1, false); } Vector3 val = ((Component)this).transform.position - ((Component)item).transform.position; val.y = 0f; item.ForceImpulse(Vector3.down * 1.4f + ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? (((Vector3)(ref val)).normalized * 1.05f) : Vector3.zero)); num3++; } } _bodyImpact(180f); Plugin.Log.LogInfo((object)$"The Undertow final surge hit {num3} player(s) inside its full mooring area."); } private void CancelMooring(float retryDelay = 0.95f) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) _mooringPositionLocked = false; if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled) { _agent.updatePosition = true; _agent.updateRotation = true; if (_agent.isOnNavMesh) { _agent.Warp(_mooringPosition); } } HideWaterline(); _attackCooldown = Mathf.Max(_attackCooldown, retryDelay); SetState(UndertowState.Recover); } public void OnTranqStunned(float duration) { if (_state == UndertowState.Dive || _state == UndertowState.Moored) { CancelMooring(3f); Plugin.Log.LogInfo((object)"A player TRANQ interrupted The Undertow's mooring."); } } private float FindCeilingHeight() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_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_0021: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00a9: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.position + Vector3.up * 0.35f; RaycastHit[] array = Physics.RaycastAll(val, Vector3.up, 7f, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val2 = array2[num]; if (!((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null) && !IsOwnCollider(((RaycastHit)(ref val2)).collider)) { return Mathf.Clamp(((RaycastHit)(ref val2)).point.y - 0.25f, val.y + 2.4f, val.y + 6f); } } return val.y + 4.2f; } private void UpdateSwimDirection() { //IL_0028: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) ? _agent.velocity : Vector3.zero); val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.05f) { float num = Mathf.Clamp((0f - Vector3.SignedAngle((((Vector3)(ref _visualForward)).sqrMagnitude > 0.01f) ? _visualForward : ((Vector3)(ref val)).normalized, ((Vector3)(ref val)).normalized, Vector3.up)) * 1.15f, -24f, 24f); float num2 = ((Mathf.Abs(num) > 2f) ? 6.8f : 1.45f); _turnBank = Mathf.Lerp(_turnBank, num, 1f - Mathf.Exp((0f - num2) * Time.deltaTime)); Vector3 val2 = Vector3.Slerp(_visualForward, ((Vector3)(ref val)).normalized, 1f - Mathf.Exp(-9.5f * Time.deltaTime)); _visualForward = ((Vector3)(ref val2)).normalized; } else { _turnBank = Mathf.Lerp(_turnBank, 0f, 1f - Mathf.Exp(-2.8f * Time.deltaTime)); } } private void PinVisuals(bool immediate) { //IL_00c7: 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_0160: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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_0198: 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_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_0142: 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_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: 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_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_021e: 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_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) float num = ((_state == UndertowState.Moored) ? 0f : ((_state == UndertowState.Dive) ? (1f - Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(_stateTimer / 1.28f))) : 1f)); float num2 = Time.time + _swimPhase; float num3 = Mathf.Sin(num2 * 1.54f) * 0.11f * num; float num4 = Mathf.Sin(num2 * 1.92f + 0.65f) * 0.16f * num; float num5 = (Mathf.Sin(num2 * 1.42f + 2.2f) * 17f + _turnBank) * num; Quaternion val2; if (_state == UndertowState.Dive) { Quaternion val = Quaternion.LookRotation((((Vector3)(ref _visualForward)).sqrMagnitude > 0.01f) ? _visualForward : Vector3.forward, Vector3.up); float num6 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(_stateTimer / 1.28f)); val2 = Quaternion.Slerp(_diveStartRotation, val, num6); } else if (_state == UndertowState.Moored) { val2 = Quaternion.LookRotation((((Vector3)(ref _visualForward)).sqrMagnitude > 0.01f) ? _visualForward : Vector3.forward, Vector3.up); } else { Quaternion val3 = Quaternion.LookRotation((((Vector3)(ref _visualForward)).sqrMagnitude > 0.01f) ? _visualForward : Vector3.forward, Vector3.up) * Quaternion.Euler(-90f, 0f, 0f); val2 = Quaternion.AngleAxis(num5, _visualForward) * val3; } _visualRotation = ((immediate || _state == UndertowState.Dive) ? val2 : Quaternion.Slerp(_visualRotation, val2, 1f - Mathf.Exp(-4.7f * Time.deltaTime))); if (_state == UndertowState.Roam || _state == UndertowState.Approach) { Vector3 val4 = _visualRotation * Vector3.down; if (((Vector3)(ref val4)).sqrMagnitude > 0.001f && ((Vector3)(ref _visualForward)).sqrMagnitude > 0.001f) { _visualRotation = Quaternion.FromToRotation(((Vector3)(ref val4)).normalized, ((Vector3)(ref _visualForward)).normalized) * _visualRotation; } } Vector3 val5 = Vector3.Cross(Vector3.up, (((Vector3)(ref _visualForward)).sqrMagnitude > 0.01f) ? ((Vector3)(ref _visualForward)).normalized : Vector3.forward); Vector3 normalized = ((Vector3)(ref val5)).normalized; Vector3 center = ((Component)this).transform.position + Vector3.up * (_swimHeight + num4) + normalized * num3; for (int i = 0; i < _anchorParts.Count; i++) { UndertowPart undertowPart = _anchorParts[i]; if (!((Object)(object)undertowPart?.Spawned?.Phys == (Object)null)) { if (undertowPart.Spawned.GeometryCalibrationFrames > 0) { DeadAirSpawner.RefreshRenderedGeometry(undertowPart.Spawned); undertowPart.Spawned.GeometryCalibrationFrames--; } PinAnchorPart(undertowPart, center, _visualRotation); } } if (_state == UndertowState.Moored) { PinWaterline(); } else { HideWaterline(); } } private static void PinAnchorPart(UndertowPart part, Vector3 center, Quaternion rotation) { //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); Vector3 val2 = default(Vector3); switch (part.Role) { case UndertowPartRole.Shank: ((Vector3)(ref val))..ctor(0f, -0.66f, 0f); ((Vector3)(ref val2))..ctor(0f, 0.49f, 0f); break; case UndertowPartRole.LeftStock: ((Vector3)(ref val))..ctor(0.04f, 0.18f, 0f); ((Vector3)(ref val2))..ctor(-0.43f, 0.18f, 0f); break; case UndertowPartRole.RightStock: ((Vector3)(ref val))..ctor(-0.04f, 0.18f, 0f); ((Vector3)(ref val2))..ctor(0.43f, 0.18f, 0f); break; case UndertowPartRole.Crown: ((Vector3)(ref val))..ctor(-0.14f, -0.55f, 0f); ((Vector3)(ref val2))..ctor(0.14f, -0.55f, 0f); break; case UndertowPartRole.LeftArm: ((Vector3)(ref val))..ctor(-0.08f, -0.55f, 0f); ((Vector3)(ref val2))..ctor(-0.3f, -0.49f, 0f); break; case UndertowPartRole.RightArm: ((Vector3)(ref val))..ctor(0.08f, -0.55f, 0f); ((Vector3)(ref val2))..ctor(0.3f, -0.49f, 0f); break; case UndertowPartRole.LeftMidArm: ((Vector3)(ref val))..ctor(-0.28f, -0.51f, 0f); ((Vector3)(ref val2))..ctor(-0.46f, -0.36f, 0f); break; case UndertowPartRole.RightMidArm: ((Vector3)(ref val))..ctor(0.28f, -0.51f, 0f); ((Vector3)(ref val2))..ctor(0.46f, -0.36f, 0f); break; case UndertowPartRole.LeftFluke: ((Vector3)(ref val))..ctor(-0.44f, -0.38f, 0f); ((Vector3)(ref val2))..ctor(-0.6f, -0.12f, 0f); break; case UndertowPartRole.RightFluke: ((Vector3)(ref val))..ctor(0.44f, -0.38f, 0f); ((Vector3)(ref val2))..ctor(0.6f, -0.12f, 0f); break; default: ((Vector3)(ref val))..ctor(0f, 0.32f, 0f); ((Vector3)(ref val2))..ctor(0f, 0.49f, 0f); break; } Vector3 val3 = center + rotation * val; Vector3 val4 = center + rotation * val2; Vector3 val5 = val4 - val3; Vector3 worldDirection = ((part.Role == UndertowPartRole.Shank) ? (-((Vector3)(ref val5)).normalized) : ((Vector3)(ref val5)).normalized); Quaternion val6 = ((((Vector3)(ref val5)).sqrMagnitude > 0.0001f) ? AlignLongAxis(part.Spawned.LongAxisLocal, worldDirection, rotation * Vector3.up) : rotation); if (part.Role == UndertowPartRole.Ring) { val6 = rotation; } Vector3 val7 = (val3 + val4) * 0.5f - val6 * part.Spawned.VisualCenterOffset; part.Spawned.ImpactDetector.destroyDisable = true; part.Spawned.Phys.OverrideGrabDisable(0.3f); part.Spawned.Phys.OverrideKinematic(0.3f); part.Spawned.Phys.OverrideIndestructible(0.3f); if ((Object)(object)part.Spawned.Phys.rb != (Object)null && !part.Spawned.Phys.rb.isKinematic) { part.Spawned.Phys.rb.velocity = Vector3.zero; part.Spawned.Phys.rb.angularVelocity = Vector3.zero; } part.Spawned.Phys.SetPositionLogic(val7, val6); } private static Quaternion AlignLongAxis(Vector3 localAxis, Vector3 worldDirection, Vector3 desiredNormal) { //IL_0017: 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_001c: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0056: 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_005c: 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_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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((((Vector3)(ref localAxis)).sqrMagnitude > 0.001f) ? ((Vector3)(ref localAxis)).normalized : Vector3.up); Quaternion val2 = Quaternion.FromToRotation(val, worldDirection); Vector3 val3 = ((Mathf.Abs(Vector3.Dot(val, Vector3.up)) < 0.92f) ? Vector3.up : Vector3.forward); Vector3 val4 = Vector3.ProjectOnPlane(val2 * val3, worldDirection); Vector3 val5 = Vector3.ProjectOnPlane(desiredNormal, worldDirection); if (((Vector3)(ref val4)).sqrMagnitude < 0.0001f || ((Vector3)(ref val5)).sqrMagnitude < 0.0001f) { return val2; } return Quaternion.AngleAxis(Vector3.SignedAngle(val4, val5, worldDirection), worldDirection) * val2; } private void PinWaterline() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) float radius = (Mathf.Max(3.5f, Plugin.Settings.UndertowMooringRadius.Value) + 3f) / Mathf.Cos(MathF.PI / 8f); Vector3 center = default(Vector3); ((Vector3)(ref center))..ctor(_mooringPosition.x, _mooringPosition.y + 0.12f, _mooringPosition.z); PinWaterBeamRing(_spawned.WaterBeams, center, radius, (0f - Time.time) * 0.34f, 0.018f, ref _waterBeamsWarm, ref _waterBeamsReady, ref _waterBeamRetry); float radius2 = 1.04f + Mathf.Sin(Time.time * 4.2f) * 0.035f; Vector3 center2 = default(Vector3); ((Vector3)(ref center2))..ctor(_mooringPosition.x, _waterY, _mooringPosition.z); PinWaterBeamRing(_spawned.CountdownBeams, center2, radius2, Time.time * 0.78f, 0.025f, ref _countdownBeamsWarm, ref _countdownBeamsReady, ref _countdownBeamRetry); } private void HideWaterline() { HideBeamRing(_spawned?.WaterBeams, ref _waterBeamsWarm, ref _waterBeamsReady, ref _waterBeamRetry); HideBeamRing(_spawned?.CountdownBeams, ref _countdownBeamsWarm, ref _countdownBeamsReady, ref _countdownBeamRetry); } private void HideBeamRing(List beams, ref bool warm, ref bool ready, ref float retry) { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) if (beams == null) { return; } if (warm | ready) { foreach (MarionetteDronePart beam in beams) { if ((Object)(object)beam?.Drone != (Object)null) { beam.Drone.MagnetActiveToggle(false); beam.Drone.StateSet((State)0); } try { if ((Object)(object)beam?.Toggle != (Object)null && beam.Toggle.toggleState) { beam.Toggle.ToggleItem(false, -1); } } catch { } } warm = false; ready = false; retry = 0f; } Vector3 val = default(Vector3); for (int i = 0; i < beams.Count; i++) { MarionetteDronePart marionetteDronePart = beams[i]; if (!((Object)(object)marionetteDronePart?.Phys == (Object)null)) { ((Vector3)(ref val))..ctor(((Component)this).transform.position.x + (float)i * 0.08f, 3000f, ((Component)this).transform.position.z); Vector3 val2 = ((Component)marionetteDronePart.Phys).transform.position - val; if (((Vector3)(ref val2)).sqrMagnitude > 0.25f) { marionetteDronePart.Phys.SetPositionLogic(val, Quaternion.identity); } } } } private void PinWaterBeamRing(List beams, Vector3 center, float radius, float spinRadians, float verticalWave, ref bool warm, ref bool ready, ref float retry) { //IL_0034: 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) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_015e: Unknown result type (might be due to invalid IL or missing references) int num = beams?.Count ?? 0; if (num < 3) { return; } Vector3[] array = (Vector3[])(object)new Vector3[num]; for (int i = 0; i < num; i++) { float num2 = spinRadians + (float)i * MathF.PI * 2f / (float)num; array[i] = center + new Vector3(Mathf.Cos(num2) * radius, Mathf.Sin(Time.time * 2.2f + (float)i * 0.9f) * verticalWave, Mathf.Sin(num2) * radius); } for (int j = 0; j < num; j++) { MarionetteDronePart marionetteDronePart = beams[j]; if (!((Object)(object)marionetteDronePart?.Phys == (Object)null)) { Vector3 val = array[(j + 1) % num] - array[j]; Quaternion val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.001f) ? Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up) : Quaternion.identity); marionetteDronePart.Impact.destroyDisable = true; marionetteDronePart.Phys.OverrideGrabDisable(0.3f); marionetteDronePart.Phys.OverrideIndestructible(0.3f); if ((Object)(object)marionetteDronePart.Phys.rb != (Object)null && !marionetteDronePart.Phys.rb.isKinematic) { marionetteDronePart.Phys.rb.velocity = Vector3.zero; marionetteDronePart.Phys.rb.angularVelocity = Vector3.zero; } marionetteDronePart.Phys.SetPositionLogic(array[j] - val2 * marionetteDronePart.BeamStartOffset, val2); } } EnsureWaterBeamRing(beams, array, ref warm, ref ready, ref retry); } private void EnsureWaterBeamRing(List beams, Vector3[] points, ref bool warm, ref bool ready, ref float retry) { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Invalid comparison between Unknown and I4 //IL_0204: Unknown result type (might be due to invalid IL or missing references) if (NewRayHitPointMethod == null || beams == null) { return; } if (!warm || beams.Exists((MarionetteDronePart beam) => (Object)(object)beam?.Toggle == (Object)null || !beam.Toggle.toggleState)) { foreach (MarionetteDronePart beam in beams) { try { if ((Object)(object)beam?.Toggle != (Object)null && !beam.Toggle.toggleState) { beam.Toggle.ToggleItem(true, -1); } } catch { } } warm = true; ready = false; retry = 0.28f; return; } if (ready) { foreach (MarionetteDronePart beam2 in beams) { if ((Object)(object)beam2?.Drone == (Object)null || (int)beam2.Drone.currentState != 3) { ready = false; retry = 0f; break; } } if (ready) { return; } } if (retry > 0f) { return; } bool flag = true; int count = beams.Count; for (int num = 0; num < count; num++) { MarionetteDronePart marionetteDronePart = beams[num]; MarionetteDronePart marionetteDronePart2 = beams[(num + 1) % count]; object obj2 = marionetteDronePart2?.View; if (obj2 == null) { if (marionetteDronePart2 == null) { obj2 = null; } else { PhysGrabObject phys = marionetteDronePart2.Phys; obj2 = ((phys != null) ? ((Component)phys).GetComponentInParent() : null); } } PhotonView val = (PhotonView)obj2; object obj3; if (marionetteDronePart2 == null) { obj3 = null; } else { PhysGrabObject phys2 = marionetteDronePart2.Phys; obj3 = ((phys2 != null) ? ((Component)phys2).GetComponentInChildren(true) : null); } PhysGrabObjectCollider val2 = (PhysGrabObjectCollider)obj3; if ((Object)(object)marionetteDronePart?.Drone == (Object)null || (Object)(object)marionetteDronePart2?.Phys == (Object)null || (Object)(object)val == (Object)null || (GameManager.Multiplayer() && val.ViewID == 0) || (Object)(object)val2 == (Object)null) { flag = false; continue; } try { NewRayHitPointMethod.Invoke(marionetteDronePart.Drone, new object[4] { points[(num + 1) % count], val.ViewID, val2.colliderID, ((Component)marionetteDronePart2.Phys).transform }); marionetteDronePart.Drone.MagnetActiveToggle(true); marionetteDronePart.Drone.StateSet((State)3); } catch (Exception ex) { flag = false; Plugin.Log.LogDebug((object)($"The Undertow could not attach water beam {num}: " + ex.GetBaseException().Message)); } } ready = flag; retry = (flag ? 0.8f : 0.45f); if (flag) { Plugin.Log.LogInfo((object)"The Undertow attached its eight native Zero Gravity Drone beams as the warning ring."); } } private void UpdateAudio() { if (!(_soundTimer > 0f)) { _soundTimer = ((_state == UndertowState.Moored) ? Random.Range(0.55f, 0.85f) : Random.Range(1.1f, 1.8f)); _bodyImpact((_state == UndertowState.Moored) ? 42f : 20f); } } private void _bodyImpact(float force) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) SpawnedDeadAirPart spawnedDeadAirPart = ((_anchorParts.Count > 0) ? _anchorParts[0].Spawned : null); if (spawnedDeadAirPart != null) { PhysGrabObjectImpactDetector impactDetector = spawnedDeadAirPart.ImpactDetector; if (impactDetector != null) { impactDetector.ImpactLight(force, spawnedDeadAirPart.Phys.centerPoint); } } } private bool HasLineOfSight(PlayerAvatar player) { //IL_003c: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return false; } float[] array = new float[3] { 0.48f, 0.9f, 1.18f }; float[] array2 = new float[3] { 0.3f, 0.72f, 1.12f }; for (int i = 0; i < array.Length; i++) { Vector3 val = ((Component)this).transform.position + Vector3.up * array[i]; Vector3 val2 = ((Component)player).transform.position + Vector3.up * array2[i] - val; if (((Vector3)(ref val2)).sqrMagnitude <= 0.001f) { return true; } RaycastHit[] array3 = Physics.RaycastAll(val, ((Vector3)(ref val2)).normalized, ((Vector3)(ref val2)).magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); Array.Sort(array3, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); bool flag = false; RaycastHit[] array4 = array3; for (int num = 0; num < array4.Length; num++) { RaycastHit val3 = array4[num]; if (!((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null) && !IsOwnCollider(((RaycastHit)(ref val3)).collider)) { if ((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() == (Object)(object)player) { return true; } if (IsUndertowVisionBlocker(((RaycastHit)(ref val3)).collider)) { flag = true; break; } } } if (!flag) { return true; } } return false; } private static bool IsUndertowVisionBlocker(Collider collider) { if ((Object)(object)collider == (Object)null || collider.isTrigger) { return false; } Transform transform = ((Component)collider).transform; Transform root = transform.root; string obj = (((Object)(object)root != (Object)null) ? ((Object)root).name : string.Empty); string text = ((Object)transform).name ?? string.Empty; if (obj.IndexOf("Level Generator", StringComparison.OrdinalIgnoreCase) >= 0 && text.StartsWith("Extra", StringComparison.OrdinalIgnoreCase)) { return false; } if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null || (Object)(object)((Component)collider).GetComponentInParent() != (Object)null || (Object)(object)((Component)collider).GetComponentInParent() != (Object)null || (Object)(object)((Component)collider).GetComponentInParent() != (Object)null || (Object)(object)((Component)collider).GetComponentInParent() != (Object)null || (Object)(object)((Component)collider).GetComponentInParent() != (Object)null) { return false; } PhysGrabObject componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { Rigidbody val = ((Component)componentInParent).GetComponent(); if ((Object)(object)val == (Object)null) { val = collider.attachedRigidbody; } if ((Object)(object)val != (Object)null) { return val.isKinematic; } return false; } Rigidbody attachedRigidbody = collider.attachedRigidbody; if ((Object)(object)attachedRigidbody != (Object)null) { return attachedRigidbody.isKinematic; } if (!((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) && !((Component)collider).gameObject.isStatic) { return (Object)(object)attachedRigidbody == (Object)null; } return true; } private bool IsOwnCollider(Collider collider) { if ((Object)(object)collider == (Object)null || _spawned?.Parts == null) { return false; } Transform transform = ((Component)collider).transform; foreach (UndertowPart part in _spawned.Parts) { if ((Object)(object)part?.Spawned?.Root != (Object)null && transform.IsChildOf(part.Spawned.Root.transform)) { return true; } } foreach (MarionetteDronePart waterBeam in _spawned.WaterBeams) { if ((Object)(object)waterBeam?.Root != (Object)null && ((Object)(object)transform == (Object)(object)waterBeam.Root.transform || transform.IsChildOf(waterBeam.Root.transform))) { return true; } } foreach (MarionetteDronePart countdownBeam in _spawned.CountdownBeams) { if ((Object)(object)countdownBeam?.Root != (Object)null && ((Object)(object)transform == (Object)(object)countdownBeam.Root.transform || transform.IsChildOf(countdownBeam.Root.transform))) { return true; } } return false; } private void SetState(UndertowState state) { _state = state; _stateTimer = 0f; } internal void ForceHostileByMarionette(PlayerAvatar player) { if (!_dead && GunAccess.IsLiving(player)) { _target = player; if (_state != UndertowState.Dive && _state != UndertowState.Moored) { SetState(UndertowState.Approach); _destinationTimer = 0f; _attackCooldown = 0f; } } } private void StopAgent() { if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } } private static float HorizontalDistance(Vector3 left, Vector3 right) { //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) //IL_0002: 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) Vector3 val = left - right; val.y = 0f; return ((Vector3)(ref val)).magnitude; } internal bool TryClaimWeaponHit(int sourceId) { if (_dead || !ModEnemyWeaponDamage.TryClaim((Object)(object)this, sourceId) || Time.time - _lastClaimedHit < 0.055f) { return false; } _lastClaimedHit = Time.time; return true; } internal void ReceiveWeaponHit(int partIndex, Vector3 point, int damage) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (_dead || damage <= 0) { return; } _health -= damage; if (_state == UndertowState.Dive || _state == UndertowState.Moored) { _mooringBreakDamage += damage; } UndertowPart undertowPart = ((partIndex >= 0 && partIndex < _anchorParts.Count) ? _anchorParts[partIndex] : _anchorParts[0]); if ((Object)(object)undertowPart?.Spawned?.ImpactDetector != (Object)null) { ModEnemyFeedback.DamageHit(undertowPart.Spawned.ImpactDetector, undertowPart.Spawned.Phys, point, 96f); } if (_health <= 0) { Die(); return; } int num = Mathf.Max(1, Plugin.Settings.UndertowMooringBreakDamage.Value); if ((_state == UndertowState.Dive || _state == UndertowState.Moored) && _mooringBreakDamage >= num) { CancelMooring(2.6f); _bodyImpact(165f); Plugin.Log.LogInfo((object)$"Players dealt {_mooringBreakDamage} damage and broke The Undertow's mooring."); } } internal void ExecuteForLab() { if (!_dead) { _health = 0; Die(); } } public void ReceiveTumbleAttack(int partIndex, int damage, Vector3 hitPosition, Vector3 direction) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ReceiveWeaponHit(partIndex, hitPosition, Mathf.Max(1, damage)); } private void Die() { if (_dead) { return; } _dead = true; SetState(UndertowState.Dead); StopAgent(); HideWaterline(); if (_spawned?.Parts != null) { foreach (UndertowPart part in _spawned.Parts) { if (part != null && part.Spawned?.Alive == true) { part.Spawned.Alive = false; } } UndertowSpawner.Destroy(_spawned); _spawned = null; } _rewardTimer = 0.08f; } private void UpdateDeath() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (_rewardDropped) { return; } _rewardTimer -= Time.deltaTime; if (_rewardTimer > 0f) { return; } _rewardDropped = true; if (Plugin.Settings.UndertowDropEnemyValuable.Value && !((Object)(object)AssetManager.instance?.enemyValuableMedium == (Object)null)) { GameObject enemyValuableMedium = AssetManager.instance.enemyValuableMedium; Vector3 val = ((Component)this).transform.position + Vector3.up * 0.42f; if (GameManager.Multiplayer()) { PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)enemyValuableMedium).name, val, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate(enemyValuableMedium, val, Quaternion.identity); } } } private void OnDestroy() { if (_initialized && !_cleaning && SemiFunc.IsMasterClientOrSingleplayer()) { _cleaning = true; if (!_dead) { UndertowSpawner.Destroy(_spawned); } } } } internal sealed class UndertowManager : MonoBehaviour { private int _levelId; private float _spawnTimer; private bool _attemptFinished; private bool _probed; private bool _available; private UndertowController _encounter; internal void Tick() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (!IsHostReady()) { return; } Probe(); int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } if (!ModEnemyLevelRules.IsPlayableLevel()) { DestroyCurrent(); return; } LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null || !instance.Generated || _attemptFinished) { return; } _spawnTimer -= Time.deltaTime; if (!(_spawnTimer > 0f)) { _attemptFinished = true; if (Random.value <= Mathf.Clamp01(Plugin.Settings.UndertowSpawnChance.Value) && TryFindSpawn(out var position)) { Create(position, "automatic"); } } } private void ResetForLevel(int levelId) { DestroyCurrent(); _levelId = levelId; _spawnTimer = Mathf.Max(0f, Plugin.Settings.UndertowSpawnDelay.Value); _attemptFinished = false; } private bool Create(Vector3 position, string source) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0085: Unknown result type (might be due to invalid IL or missing references) if (!_available && !UndertowSpawner.PrefabsAvailable()) { Plugin.Log.LogWarning((object)"The Undertow could not resolve its vanilla telescope, watch and waterline resources."); return false; } DestroyCurrent(); GameObject val = new GameObject("The Undertow Encounter (Host Logic)"); val.SetActive(false); val.transform.position = position; UndertowController undertowController = val.AddComponent(); if (!undertowController.Initialize(position)) { Object.Destroy((Object)(object)val); return false; } val.SetActive(true); if (!undertowController.ActivateNavigation(position)) { Object.Destroy((Object)(object)val); return false; } _encounter = undertowController; Plugin.Log.LogInfo((object)$"The Undertow spawned at {position} ({source}); guests see its swimming anchor and descending waterline."); return true; } internal bool DebugSpawnAt(Vector3 requestedPosition) { //IL_0039: 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) if (!IsHostReady() || (!ModEnemySpawnCoordinator.IsDirectorRequestActive && (Object)(object)PlayerAvatar.instance == (Object)null) || !ModEnemyLevelRules.IsPlayableLevel()) { Plugin.Log.LogWarning((object)"Enemy Lab rejected The Undertow because no playable host level is active."); return false; } Probe(); NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requestedPosition, ref val, 12f, -1)) { return false; } _attemptFinished = true; return Create(((NavMeshHit)(ref val)).position, ModEnemySpawnCoordinator.CurrentSpawnSource); } internal void MarkAutomaticAttemptFinished() { int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelId) { ResetForLevel(num); } _attemptFinished = true; } internal void DebugDespawn() { if (IsHostReady()) { _attemptFinished = true; DestroyCurrent(); } } private void DestroyCurrent() { if ((Object)(object)_encounter != (Object)null) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); _encounter = null; } } private void Probe() { if (!_probed && !((Object)(object)RunManager.instance == (Object)null)) { _probed = true; _available = UndertowSpawner.PrefabsAvailable(); Plugin.Log.LogInfo((object)string.Format("The Undertow prefab probe: available={0}, body={1}, claws={2}, eye={3}, waterBeam={4}.", _available, UndertowSpawner.ShaftResource, UndertowSpawner.ClawResource, UndertowSpawner.RingResource, "Items/Item Drone Zero Gravity")); } } private static bool TryFindSpawn(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; PlayerAvatar val = null; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { val = item; break; } } Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(val2, 20f, 64f, false) ?? SemiFunc.LevelPointGetFurthestFromPlayer(val2, 8f); return ModEnemyNavigation.TryFindClearSpawn(((Object)(object)val3 != (Object)null) ? ((Component)val3).transform.position : (val2 + Vector3.forward * 20f), 7f, out position); } private static bool IsHostReady() { try { return (Object)(object)GameManager.instance != (Object)null && (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient); } catch { return false; } } } internal sealed class UndertowPartHitProxy : MonoBehaviour { private UndertowController _controller; private SpawnedDeadAirPart _part; private int _partIndex; private float _cooldown; internal void Initialize(UndertowController controller, SpawnedDeadAirPart part, int partIndex) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown _controller = controller; _part = part; _partIndex = partIndex; SpawnedDeadAirPart part2 = _part; if (part2 == null) { return; } PhysGrabObjectImpactDetector impactDetector = part2.ImpactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.AddListener(new UnityAction(OnHurtColliderHit)); } } } private void Update() { _cooldown = Mathf.Max(0f, _cooldown - Time.deltaTime); } private void OnDestroy() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown SpawnedDeadAirPart part = _part; if (part == null) { return; } PhysGrabObjectImpactDetector impactDetector = part.ImpactDetector; if (impactDetector != null) { UnityEvent onHurtColliderHit = impactDetector.onHurtColliderHit; if (onHurtColliderHit != null) { onHurtColliderHit.RemoveListener(new UnityAction(OnHurtColliderHit)); } } } private void OnHurtColliderHit() { //IL_0072: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_controller == (Object)null || _cooldown > 0f || !SemiFunc.IsMasterClientOrSingleplayer() || !_controller.TryClaimWeaponHit(ModEnemyWeaponDamage.CurrentClaimId)) { return; } _cooldown = 0.12f; Vector3 val = (((Object)(object)_part?.Phys != (Object)null) ? _part.Phys.centerPoint : ((Component)this).transform.position); if (EnemyLabBridge.IsExecutionHitNear(val)) { _controller.ExecuteForLab(); return; } int num = ModEnemyWeaponDamage.Resolve(ModEnemyWeaponDamage.Current, Plugin.Settings.UndertowDamagePerHit.Value); if (num > 0) { _controller.ReceiveWeaponHit(_partIndex, val, num); } } } internal enum UndertowPartRole { Shank, LeftStock, RightStock, Crown, LeftArm, RightArm, LeftMidArm, RightMidArm, LeftFluke, RightFluke, Ring, WaterMarker } internal sealed class UndertowPart { internal SpawnedDeadAirPart Spawned; internal UndertowPartRole Role; internal bool IsWaterMarker => Role == UndertowPartRole.WaterMarker; } internal sealed class SpawnedUndertow { internal readonly List Parts = new List(); internal readonly List WaterBeams = new List(); internal readonly List CountdownBeams = new List(); } internal static class UndertowSpawner { private static readonly string[] SizeFolders = new string[7] { "01 Tiny", "02 Small", "03 Medium", "04 Big", "05 Wide", "06 Tall", "07 Very Tall" }; private static string _shaftResource; private static string _clawResource; private static string _ringResource; internal const string WaterBeamResource = "Items/Item Drone Zero Gravity"; internal static string ShaftResource { get { Resolve(); return _shaftResource; } } internal static string RingResource { get { Resolve(); return _ringResource; } } internal static string ClawResource { get { Resolve(); return _clawResource; } } internal static bool PrefabsAvailable() { Resolve(); if (!string.IsNullOrEmpty(_shaftResource) && !string.IsNullOrEmpty(_clawResource) && !string.IsNullOrEmpty(_ringResource)) { return (Object)(object)Resources.Load("Items/Item Drone Zero Gravity") != (Object)null; } return false; } private static void Resolve() { if (_shaftResource == null) { _shaftResource = FindValuable("Valuable Manor Vase") ?? "Valuables/07 Very Tall/Valuable Wizard Broom"; } if (_clawResource == null) { _clawResource = FindValuable("Valuable Wizard Levitation Potion") ?? _shaftResource; } if (_ringResource == null) { _ringResource = FindValuable("Valuable Manor Vase Small") ?? _shaftResource; } } private static string FindValuable(string prefabName) { string[] sizeFolders = SizeFolders; foreach (string text in sizeFolders) { string text2 = "Valuables/" + text + "/" + prefabName; if ((Object)(object)Resources.Load(text2) != (Object)null) { return text2; } } return null; } internal static SpawnedUndertow Spawn(Vector3 position) { //IL_0015: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0069: 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_008b: 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_00ad: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_016a: 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_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: 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) if (!PrefabsAvailable()) { return null; } SpawnedUndertow spawnedUndertow = new SpawnedUndertow(); Add(spawnedUndertow, ClawResource, position, new Vector3(0.74f, 1.56f, 0.74f), UndertowPartRole.Shank); Add(spawnedUndertow, ShaftResource, position, new Vector3(0.35f, 0.35f, 0.35f), UndertowPartRole.LeftStock); Add(spawnedUndertow, ShaftResource, position, new Vector3(0.35f, 0.35f, 0.35f), UndertowPartRole.RightStock); Add(spawnedUndertow, RingResource, position, new Vector3(0.36f, 0.36f, 0.36f), UndertowPartRole.Crown); Add(spawnedUndertow, ClawResource, position, new Vector3(0.48f, 0.48f, 0.48f), UndertowPartRole.LeftArm); Add(spawnedUndertow, ClawResource, position, new Vector3(0.48f, 0.48f, 0.48f), UndertowPartRole.RightArm); Add(spawnedUndertow, ClawResource, position, new Vector3(0.44f, 0.44f, 0.44f), UndertowPartRole.LeftMidArm); Add(spawnedUndertow, ClawResource, position, new Vector3(0.44f, 0.44f, 0.44f), UndertowPartRole.RightMidArm); Add(spawnedUndertow, ClawResource, position, new Vector3(0.48f, 0.48f, 0.48f), UndertowPartRole.LeftFluke); Add(spawnedUndertow, ClawResource, position, new Vector3(0.48f, 0.48f, 0.48f), UndertowPartRole.RightFluke); Add(spawnedUndertow, RingResource, position, new Vector3(0.38f, 0.38f, 0.38f), UndertowPartRole.Ring); int count = spawnedUndertow.Parts.Count; Vector3 staging = default(Vector3); ((Vector3)(ref staging))..ctor(position.x, 3000f, position.z); if (!SpawnBeamRing(spawnedUndertow.WaterBeams, staging) || !SpawnBeamRing(spawnedUndertow.CountdownBeams, staging)) { Destroy(spawnedUndertow); return null; } if (count < 11) { Destroy(spawnedUndertow); return null; } return spawnedUndertow; } private static bool SpawnBeamRing(List destination, Vector3 staging) { //IL_0004: 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_000c: 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) for (int i = 0; i < 8; i++) { MarionetteDronePart marionetteDronePart = MarionetteSpawner.SpawnBeamEmitter(staging + Vector3.right * (float)i * 0.03f, "Items/Item Drone Zero Gravity"); if (marionetteDronePart == null) { return false; } destination.Add(marionetteDronePart); } return true; } private static UndertowPart Add(SpawnedUndertow result, string resource, Vector3 position, Vector3 scale, UndertowPartRole role) { //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) //IL_0007: Unknown result type (might be due to invalid IL or missing references) SpawnedDeadAirPart spawnedDeadAirPart = DeadAirSpawner.Spawn(resource, position, Quaternion.identity, scale, role == UndertowPartRole.Shank, grabbable: false, (role == UndertowPartRole.WaterMarker) ? 112f : 2f); if (spawnedDeadAirPart == null) { return null; } try { spawnedDeadAirPart.ImpactDetector.destroyDisable = true; spawnedDeadAirPart.ImpactDetector.playerHurtDisable = true; spawnedDeadAirPart.Phys.OverrideGrabDisable(1f); spawnedDeadAirPart.Phys.OverrideKinematic(1f); spawnedDeadAirPart.Phys.OverrideIndestructible(1f); DisableNativeItemBehaviour(spawnedDeadAirPart); if (role == UndertowPartRole.WaterMarker) { Collider[] array = spawnedDeadAirPart.Colliders ?? Array.Empty(); foreach (Collider val in array) { if ((Object)(object)val != (Object)null) { val.enabled = false; } } ((Behaviour)spawnedDeadAirPart.ImpactDetector).enabled = false; } } catch (Exception ex) { Plugin.Log.LogWarning((object)$"The Undertow rejected one {role} part during safe setup: {ex.Message}"); DeadAirSpawner.Destroy(spawnedDeadAirPart); return null; } UndertowPart undertowPart = new UndertowPart { Spawned = spawnedDeadAirPart, Role = role }; result.Parts.Add(undertowPart); return undertowPart; } private static void DisableNativeItemBehaviour(SpawnedDeadAirPart spawned) { if ((Object)(object)spawned?.Root == (Object)null) { return; } ValuableLevitationPotion[] componentsInChildren = spawned.Root.GetComponentsInChildren(true); foreach (ValuableLevitationPotion val in componentsInChildren) { if ((Object)(object)val != (Object)null) { ((Behaviour)val).enabled = false; } } LevitationSphere[] componentsInChildren2 = spawned.Root.GetComponentsInChildren(true); foreach (LevitationSphere val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)null) { ((Behaviour)val2).enabled = false; } } LevitationSphereEffect[] componentsInChildren3 = spawned.Root.GetComponentsInChildren(true); foreach (LevitationSphereEffect val3 in componentsInChildren3) { if ((Object)(object)val3 != (Object)null) { ((Behaviour)val3).enabled = false; } } ItemOrbZeroGravity[] componentsInChildren4 = spawned.Root.GetComponentsInChildren(true); foreach (ItemOrbZeroGravity val4 in componentsInChildren4) { if ((Object)(object)val4 != (Object)null) { ((Behaviour)val4).enabled = false; } } SemiAffectZeroGravity[] componentsInChildren5 = spawned.Root.GetComponentsInChildren(true); foreach (SemiAffectZeroGravity val5 in componentsInChildren5) { if ((Object)(object)val5 != (Object)null) { ((Behaviour)val5).enabled = false; } } HurtCollider[] componentsInChildren6 = spawned.Root.GetComponentsInChildren(true); foreach (HurtCollider val6 in componentsInChildren6) { if ((Object)(object)val6 != (Object)null) { ((Behaviour)val6).enabled = false; } } } internal static void Destroy(SpawnedUndertow undertow) { if (undertow == null) { return; } foreach (UndertowPart part in undertow.Parts) { DeadAirSpawner.Destroy(part?.Spawned); } foreach (MarionetteDronePart waterBeam in undertow.WaterBeams) { MarionetteSpawner.DestroyDrone(waterBeam); } foreach (MarionetteDronePart countdownBeam in undertow.CountdownBeams) { MarionetteSpawner.DestroyDrone(countdownBeam); } undertow.Parts.Clear(); undertow.WaterBeams.Clear(); undertow.CountdownBeams.Clear(); } } internal sealed class SpawnedGun { internal GameObject Root; internal PhysGrabObject Phys; internal PhysGrabObjectImpactDetector ImpactDetector; internal ItemGun Gun; internal ItemGunTranq Tranq; internal ItemBattery Battery; internal ItemAttributes Attributes; } internal static class VanillaGunSpawner { internal static Item FindTranqGunItem() { if (StatsManager.instance?.itemDictionary == null) { return null; } foreach (Item item in from item in StatsManager.instance.itemDictionary.Values where (Object)(object)item != (Object)null && item.prefab != null && ((PrefabRef)(object)item.prefab).IsValid() orderby (item.itemName ?? string.Empty).IndexOf("tranq", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)item).name.IndexOf("tranq", StringComparison.OrdinalIgnoreCase) >= 0 descending select item) { try { GameObject prefab = ((PrefabRef)(object)item.prefab).Prefab; if ((Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponentInChildren(true) != (Object)null && (Object)(object)prefab.GetComponentInChildren(true) != (Object)null) { return item; } } catch (Exception ex) { Plugin.Log.LogDebug((object)("TRANQ GUN prefab probe failed for " + ((Object)item).name + ": " + ex.Message)); } } return null; } internal static SpawnedGun Spawn(Item item, Vector3 position, Quaternion rotation, float scaleMultiplier, bool guestMapDecoy = false) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) if (item?.prefab == null || !((PrefabRef)(object)item.prefab).IsValid()) { return null; } GameObject prefab = ((PrefabRef)(object)item.prefab).Prefab; if ((Object)(object)prefab == (Object)null) { return null; } scaleMultiplier = (guestMapDecoy ? Mathf.Clamp(scaleMultiplier, 0.015f, 0.05f) : Mathf.Clamp(scaleMultiplier, 1f, 1.3f)); Vector3 val = prefab.transform.localScale * scaleMultiplier; object[] array = new object[3] { val.x, val.y, val.z }; GameObject val2 = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject(((PrefabRef)(object)item.prefab).ResourcePath, position, rotation, (byte)0, array) : Object.Instantiate(prefab, position, rotation)); if ((Object)(object)val2 == (Object)null) { return null; } ModEnemyInventoryBlocker.Attach(val2); if (!GameManager.Multiplayer()) { val2.transform.localScale = val; } SpawnedGun spawnedGun = new SpawnedGun { Root = val2, Phys = val2.GetComponentInChildren(true), ImpactDetector = val2.GetComponentInChildren(true), Gun = val2.GetComponentInChildren(true), Tranq = val2.GetComponentInChildren(true), Battery = val2.GetComponentInChildren(true), Attributes = val2.GetComponentInChildren(true) }; if ((Object)(object)spawnedGun.Phys == (Object)null || (Object)(object)spawnedGun.ImpactDetector == (Object)null || (Object)(object)spawnedGun.Gun == (Object)null || (Object)(object)spawnedGun.Tranq == (Object)null) { Plugin.Log.LogError((object)"A spawned TRANQ GUN did not contain its expected vanilla components."); Destroy(val2); return null; } ItemAttributes attributes = spawnedGun.Attributes; if (attributes != null) { attributes.DisableUI(true); } MapIconSuppressor.Attach(val2); if (guestMapDecoy) { spawnedGun.Phys.OverrideKinematic(1f); spawnedGun.Phys.OverrideGrabDisable(1f); spawnedGun.Phys.OverrideIndestructible(1f); } GunAccess.Refill(spawnedGun.Battery); return spawnedGun; } private static void Destroy(GameObject root) { if (!((Object)(object)root == (Object)null)) { if (GameManager.Multiplayer()) { PhotonNetwork.Destroy(root); } else { Object.Destroy((Object)(object)root); } } } } internal sealed class VoodooController : MonoBehaviour { private readonly List _parts = new List(); private NavMeshAgent _agent; private VoodooDollController _doll; private PlayerAvatar _target; private PlayerAvatar _poseDeliveredTarget; private PlayerAvatar _lastHolder; private float _destinationTimer; private float _sendTimer; private float _stepTimer; private float _attackCooldown; private float _switchReadyTime; private float _targetAttackReadyTime; private float _rewardTimer; private float _walkPhase; private float _shuffleTimer; private float _gaitBlend; private bool _sendPoseThisFrame; private bool _shuffleMoving = true; private bool _initialized; private bool _dead; private bool _rewardDropped; private bool _firstAttackLogged; internal bool IsEncounterAlive { get { if (_initialized) { return !_dead; } return false; } } internal bool Initialize(Vector3 enemyPosition, Vector3 dollPosition) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0341: 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_03be: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Expected O, but got Unknown //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = enemyPosition; _agent = ((Component)this).gameObject.AddComponent(); ((Behaviour)_agent).enabled = false; _agent.speed = Mathf.Clamp(Plugin.Settings.VoodooMoveSpeed.Value, 0.35f, 4f); _agent.acceleration = 7f; _agent.angularSpeed = 150f; _agent.radius = 0.38f; _agent.height = 2.05f; _agent.stoppingDistance = 0.16f; _agent.autoBraking = true; if (!SpawnVisual(VoodooSpawner.BodyResourcePath, new Vector3(0.4f, 0.62f, 0.27f), VoodooPartRole.Body, Quaternion.Euler(0f, 180f, 0f)) || !SpawnVisual(VoodooSpawner.HeadResourcePath, new Vector3(0.56f, 0.42f, 0.24f), VoodooPartRole.Head, Quaternion.Euler(0f, 180f, 0f)) || !SpawnVisual(VoodooSpawner.PatchResourcePath, new Vector3(0.56f, 0.22f, 0.66f), VoodooPartRole.BodyUpper, Quaternion.Euler(90f, 0f, -10f)) || !SpawnVisual(VoodooSpawner.PatchResourcePath, new Vector3(0.56f, 0.22f, 0.66f), VoodooPartRole.BodyMiddle, Quaternion.Euler(90f, 0f, 8f)) || !SpawnVisual(VoodooSpawner.PatchResourcePath, new Vector3(0.56f, 0.22f, 0.66f), VoodooPartRole.BodyLower, Quaternion.Euler(90f, 0f, 7f)) || !SpawnVisual(VoodooSpawner.PatchResourcePath, new Vector3(0.56f, 0.22f, 0.66f), VoodooPartRole.BodyFourth, Quaternion.Euler(90f, 0f, -9f))) { CleanupEnemyParts(); return false; } VoodooPartRole[] array = new VoodooPartRole[4] { VoodooPartRole.UpperArmLeft, VoodooPartRole.LowerArmLeft, VoodooPartRole.UpperArmRight, VoodooPartRole.LowerArmRight }; foreach (VoodooPartRole role in array) { if (!SpawnVisual(VoodooSpawner.ArmResourcePath, new Vector3(0.118f, 0.152f, 0.148f), role)) { CleanupEnemyParts(); return false; } } array = new VoodooPartRole[4] { VoodooPartRole.UpperLegLeft, VoodooPartRole.LowerLegLeft, VoodooPartRole.UpperLegRight, VoodooPartRole.LowerLegRight }; foreach (VoodooPartRole role2 in array) { if (!SpawnVisual(VoodooSpawner.LegResourcePath, new Vector3(0.145f, 0.19f, 0.165f), role2)) { CleanupEnemyParts(); return false; } } array = new VoodooPartRole[2] { VoodooPartRole.LeftFoot, VoodooPartRole.RightFoot }; foreach (VoodooPartRole role3 in array) { if (!SpawnVisual(VoodooSpawner.LegResourcePath, new Vector3(0.112f, 0.082f, 0.142f), role3)) { CleanupEnemyParts(); return false; } } if (!SpawnVisual(VoodooSpawner.PupilResourcePath, new Vector3(0.092f, 0.128f, 0.024f), VoodooPartRole.LeftPupil) || !SpawnVisual(VoodooSpawner.PupilResourcePath, new Vector3(0.092f, 0.128f, 0.024f), VoodooPartRole.RightPupil)) { CleanupEnemyParts(); return false; } array = new VoodooPartRole[6] { VoodooPartRole.PinTop, VoodooPartRole.PinUpperLeft, VoodooPartRole.PinUpperRight, VoodooPartRole.PinSideLeft, VoodooPartRole.PinSideRight, VoodooPartRole.PinBack }; foreach (VoodooPartRole role4 in array) { if (!SpawnVisual(VoodooSpawner.PinResourcePath, new Vector3(0.014f, 0.082f, 0.014f), role4)) { CleanupEnemyParts(); return false; } } array = new VoodooPartRole[6] { VoodooPartRole.LeftClawOuter, VoodooPartRole.LeftClawMiddle, VoodooPartRole.LeftClawInner, VoodooPartRole.RightClawOuter, VoodooPartRole.RightClawMiddle, VoodooPartRole.RightClawInner }; foreach (VoodooPartRole role5 in array) { if (!SpawnVisual(VoodooSpawner.PinResourcePath, new Vector3(0.016f, 0.055f, 0.016f), role5)) { CleanupEnemyParts(); return false; } } array = new VoodooPartRole[3] { VoodooPartRole.ChestStitchUpper, VoodooPartRole.ChestStitchMiddle, VoodooPartRole.ChestStitchLower }; foreach (VoodooPartRole role6 in array) { if (!SpawnVisual(VoodooSpawner.PinResourcePath, new Vector3(0.02f, 0.065f, 0.02f), role6)) { CleanupEnemyParts(); return false; } } array = new VoodooPartRole[5] { VoodooPartRole.PinHeadTop, VoodooPartRole.PinHeadUpperLeft, VoodooPartRole.PinHeadUpperRight, VoodooPartRole.PinHeadSideLeft, VoodooPartRole.PinHeadSideRight }; foreach (VoodooPartRole role7 in array) { if (!SpawnVisual(VoodooSpawner.PinHeadResourcePath, new Vector3(0.105f, 0.105f, 0.105f), role7)) { CleanupEnemyParts(); return false; } } IgnoreSelfCollisions(); GameObject val = new GameObject("The Voodoo Doll (Host Logic)"); val.transform.position = dollPosition; _doll = val.AddComponent(); if (!_doll.Initialize(this, dollPosition)) { CleanupEnemyParts(); Object.Destroy((Object)(object)val); return false; } _target = SelectRandomLivingPlayer(); ArmTargetVisibilityGrace(); _stepTimer = 0.3f; _shuffleTimer = Random.Range(0.42f, 0.56f); _initialized = true; SendHiddenToEveryoneExceptTarget(); Plugin.Log.LogInfo((object)$"The Voodoo selected {TargetLabel(_target)}; its {_parts.Count}-piece restored patchwork silhouette (with the baby-head shell restored and the two eye-backing shells removed) will be positioned only for that victim, together with its dedicated breakable doll."); return true; } private bool SpawnVisual(string resourcePath, Vector3 scale, VoodooPartRole role, Quaternion? localRotation = null) { //IL_0001: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0066: 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_0086: Unknown result type (might be due to invalid IL or missing references) SpawnedVoodooPart spawnedVoodooPart = VoodooSpawner.SpawnEnemyPart(resourcePath, scale, role); if (spawnedVoodooPart == null) { return false; } spawnedVoodooPart.LocalRotation = (Quaternion)(((??)localRotation) ?? Quaternion.identity); _parts.Add(spawnedVoodooPart); Plugin.Log.LogInfo((object)($"The Voodoo spawned {role}: resource={resourcePath}, " + $"requestedScale={scale}, networkScale={spawnedVoodooPart.Root.transform.localScale}, " + $"initialRenderedSize={spawnedVoodooPart.VisualSize}, longAxis={spawnedVoodooPart.LongAxisLocal}.")); return true; } internal bool ActivateNavigation(Vector3 requestedPosition) { //IL_000e: 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_0053: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if ((Object)(object)_agent == (Object)null || !NavMesh.SamplePosition(requestedPosition, ref val, 6f, -1)) { return false; } ((Component)this).transform.position = ((NavMeshHit)(ref val)).position; ((Behaviour)_agent).enabled = true; if (!_agent.isOnNavMesh) { return _agent.Warp(((NavMeshHit)(ref val)).position); } return true; } private void Update() { if (_initialized && SemiFunc.IsMasterClientOrSingleplayer()) { if (_dead) { UpdateDeath(); return; } _attackCooldown = Mathf.Max(0f, _attackCooldown - Time.deltaTime); UpdateTargetFromDoll(); EnsureLivingTarget(); UpdateNavigation(); UpdatePoseDelivery(); UpdateVictimOnlySteps(); UpdateHostNearMusic(); } } private void UpdateTargetFromDoll() { PlayerAvatar val = (((Object)(object)_doll != (Object)null) ? _doll.CurrentHolder : null); if ((Object)(object)val == (Object)(object)_lastHolder) { return; } _lastHolder = val; if (GunAccess.IsLiving(val)) { if ((Object)(object)val == (Object)(object)_target) { TeleportAround(val, smoke: true); return; } if (Time.time < _switchReadyTime) { Plugin.Log.LogInfo((object)$"The Voodoo ignored a rapid doll hand-off; target switching unlocks in {_switchReadyTime - Time.time:F1}s."); return; } SetTarget(val, teleport: true); _switchReadyTime = Time.time + Mathf.Clamp(Plugin.Settings.VoodooTargetSwitchCooldown.Value, 5f, 300f); } } private void EnsureLivingTarget() { if (!GunAccess.IsLiving(_target)) { SetTarget(SelectRandomLivingPlayer(), teleport: false); } } private void SetTarget(PlayerAvatar next, bool teleport) { if ((Object)(object)next == (Object)(object)_target) { if (teleport && (Object)(object)next != (Object)null) { TeleportAround(next, smoke: true); } return; } PlayerAvatar target = _target; HideFrom(target); _target = next; ArmTargetVisibilityGrace(); if ((Object)(object)_target != (Object)null && teleport) { TeleportAround(_target, smoke: true); } Plugin.Log.LogInfo((object)("The Voodoo changed its private victim from " + TargetLabel(target) + " to " + TargetLabel(_target) + ".")); } private void UpdateNavigation() { //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(_target) || !ModEnemyNavigation.EnsureOnNavMesh(_agent, ((Component)this).transform, 6f)) { if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.isStopped = true; } return; } bool flag = (Object)(object)_doll != (Object)null && (Object)(object)_doll.CurrentHolder == (Object)(object)_target; float num = Mathf.Clamp(Plugin.Settings.VoodooMoveSpeed.Value, 0.35f, 4f); float num2 = Mathf.Clamp(Plugin.Settings.VoodooHeldSpeedMultiplier.Value, 1f, 2f); _agent.speed = num * (flag ? num2 : 1f); _shuffleTimer -= Time.deltaTime; if (_shuffleTimer <= 0f) { _shuffleMoving = !_shuffleMoving; _shuffleTimer = (_shuffleMoving ? Random.Range(0.42f, 0.56f) : Random.Range(0.16f, 0.24f)); } Vector3 position = ((Component)_target).transform.position; float configuredRange = Mathf.Clamp(Plugin.Settings.VoodooAttackRange.Value, 0.5f, 1.6f); if ((Object)(object)_poseDeliveredTarget == (Object)(object)_target && Time.time >= _targetAttackReadyTime && IsVictimWithinTouchRange(_target, configuredRange) && _attackCooldown <= 0f && HasClearAttackLine(_target)) { _attackCooldown = 1.05f; PlayerHealth playerHealth = _target.playerHealth; if (playerHealth != null) { playerHealth.HurtOther(Mathf.Max(1, Plugin.Settings.VoodooAttackDamage.Value), ((Component)_target).transform.position, false, -1, false); } TargetedImpact("ImpactHeavyRPC", 100f, ((Component)_target).transform.position); if (!_firstAttackLogged) { _firstAttackLogged = true; Plugin.Log.LogInfo((object)$"The Voodoo landed its first {Plugin.Settings.VoodooAttackDamage.Value}-damage touch on its visible private victim {TargetLabel(_target)}."); } } _destinationTimer -= Time.deltaTime; if (_destinationTimer <= 0f) { _destinationTimer = 0.12f; ModEnemyNavigation.TrySetDestination(_agent, ((Component)this).transform, position, 4f); } _agent.isStopped = !_shuffleMoving; } private bool IsVictimWithinTouchRange(PlayerAvatar player, float configuredRange) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //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_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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00f7: 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_0140: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return false; } Vector3 val = ((Component)this).transform.position + ((Component)this).transform.forward * 0.42f + Vector3.up * 0.95f; float num = Mathf.Clamp(configuredRange * 1.12f, 0.82f, 1.16f); float num2 = Mathf.Clamp(configuredRange + 0.46f, 0.94f, 1.62f); Vector3 val2 = ((Component)player).transform.position - ((Component)this).transform.position; val2.y = 0f; float num3 = num2 + 1.25f; if (((Vector3)(ref val2)).sqrMagnitude > num3 * num3) { return false; } float num4 = float.PositiveInfinity; Collider[] componentsInChildren = ((Component)player).GetComponentsInChildren(true); foreach (Collider val3 in componentsInChildren) { if (!((Object)(object)val3 == (Object)null) && val3.enabled) { Vector3 val4 = val3.ClosestPoint(val); float num5 = num4; Vector3 val5 = val4 - val; num4 = Mathf.Min(num5, ((Vector3)(ref val5)).sqrMagnitude); } } if (num4 <= num * num) { return true; } if (((Vector3)(ref val2)).sqrMagnitude <= num2 * num2) { return Mathf.Abs(((Component)player).transform.position.y - ((Component)this).transform.position.y) <= 1.45f; } return false; } private bool HasClearAttackLine(PlayerAvatar player) { //IL_0006: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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) Vector3 start = ((Component)this).transform.position + ((Component)this).transform.forward * 0.42f + Vector3.up * 0.95f; if (!IsAttackRayClear(start, ((Component)player).transform.position + Vector3.up * 0.65f)) { return IsAttackRayClear(start, ((Component)player).transform.position + Vector3.up * 1.15f); } return true; } private static bool IsAttackRayClear(Vector3 start, Vector3 end) { //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) //IL_0002: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.05f) { return true; } RaycastHit[] array = Physics.RaycastAll(start, val / magnitude, magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val2 = array[i]; if (!((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent() != (Object)null)) { return false; } } return true; } private void UpdatePoseDelivery() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: 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_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: 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_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: 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_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: 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_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0259: 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_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028e: 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_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: 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_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0331: 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_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_0513: 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_0542: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_0580: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_059d: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Unknown result type (might be due to invalid IL or missing references) //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_05ab: Unknown result type (might be due to invalid IL or missing references) //IL_05b2: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_05e9: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Unknown result type (might be due to invalid IL or missing references) //IL_0603: Unknown result type (might be due to invalid IL or missing references) //IL_0608: Unknown result type (might be due to invalid IL or missing references) //IL_061d: Unknown result type (might be due to invalid IL or missing references) //IL_0622: Unknown result type (might be due to invalid IL or missing references) //IL_0627: Unknown result type (might be due to invalid IL or missing references) //IL_0657: Unknown result type (might be due to invalid IL or missing references) //IL_065c: Unknown result type (might be due to invalid IL or missing references) //IL_0661: Unknown result type (might be due to invalid IL or missing references) //IL_0691: Unknown result type (might be due to invalid IL or missing references) //IL_0696: Unknown result type (might be due to invalid IL or missing references) //IL_069b: Unknown result type (might be due to invalid IL or missing references) //IL_06a0: Unknown result type (might be due to invalid IL or missing references) //IL_06a2: Unknown result type (might be due to invalid IL or missing references) //IL_06ac: Unknown result type (might be due to invalid IL or missing references) //IL_06ae: Unknown result type (might be due to invalid IL or missing references) //IL_06b8: Unknown result type (might be due to invalid IL or missing references) //IL_06ba: Unknown result type (might be due to invalid IL or missing references) //IL_06c4: Unknown result type (might be due to invalid IL or missing references) //IL_06c6: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_06d2: Unknown result type (might be due to invalid IL or missing references) //IL_06da: Unknown result type (might be due to invalid IL or missing references) //IL_06f7: Unknown result type (might be due to invalid IL or missing references) //IL_06fc: Unknown result type (might be due to invalid IL or missing references) //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_0711: Unknown result type (might be due to invalid IL or missing references) //IL_0716: Unknown result type (might be due to invalid IL or missing references) //IL_0723: Unknown result type (might be due to invalid IL or missing references) //IL_0725: Unknown result type (might be due to invalid IL or missing references) //IL_072d: Unknown result type (might be due to invalid IL or missing references) //IL_074a: Unknown result type (might be due to invalid IL or missing references) //IL_074f: Unknown result type (might be due to invalid IL or missing references) //IL_075a: Unknown result type (might be due to invalid IL or missing references) //IL_0764: Unknown result type (might be due to invalid IL or missing references) //IL_0769: Unknown result type (might be due to invalid IL or missing references) //IL_0776: Unknown result type (might be due to invalid IL or missing references) //IL_0778: Unknown result type (might be due to invalid IL or missing references) //IL_0780: Unknown result type (might be due to invalid IL or missing references) //IL_078a: Unknown result type (might be due to invalid IL or missing references) //IL_078f: Unknown result type (might be due to invalid IL or missing references) //IL_079a: Unknown result type (might be due to invalid IL or missing references) //IL_07a4: Unknown result type (might be due to invalid IL or missing references) //IL_07a9: Unknown result type (might be due to invalid IL or missing references) //IL_07b4: Unknown result type (might be due to invalid IL or missing references) //IL_07be: Unknown result type (might be due to invalid IL or missing references) //IL_07c3: Unknown result type (might be due to invalid IL or missing references) //IL_07d0: Unknown result type (might be due to invalid IL or missing references) //IL_07d2: Unknown result type (might be due to invalid IL or missing references) //IL_07da: Unknown result type (might be due to invalid IL or missing references) //IL_07e4: Unknown result type (might be due to invalid IL or missing references) //IL_07e9: Unknown result type (might be due to invalid IL or missing references) //IL_07f4: Unknown result type (might be due to invalid IL or missing references) //IL_07fe: Unknown result type (might be due to invalid IL or missing references) //IL_0803: Unknown result type (might be due to invalid IL or missing references) //IL_0810: Unknown result type (might be due to invalid IL or missing references) //IL_0812: Unknown result type (might be due to invalid IL or missing references) //IL_081a: Unknown result type (might be due to invalid IL or missing references) //IL_0824: Unknown result type (might be due to invalid IL or missing references) //IL_0829: Unknown result type (might be due to invalid IL or missing references) //IL_0834: Unknown result type (might be due to invalid IL or missing references) //IL_083e: Unknown result type (might be due to invalid IL or missing references) //IL_0843: Unknown result type (might be due to invalid IL or missing references) //IL_084e: Unknown result type (might be due to invalid IL or missing references) //IL_0858: Unknown result type (might be due to invalid IL or missing references) //IL_085d: Unknown result type (might be due to invalid IL or missing references) //IL_086a: Unknown result type (might be due to invalid IL or missing references) //IL_086c: Unknown result type (might be due to invalid IL or missing references) //IL_0874: Unknown result type (might be due to invalid IL or missing references) //IL_087e: Unknown result type (might be due to invalid IL or missing references) //IL_0883: Unknown result type (might be due to invalid IL or missing references) //IL_088e: Unknown result type (might be due to invalid IL or missing references) //IL_0898: Unknown result type (might be due to invalid IL or missing references) //IL_089d: Unknown result type (might be due to invalid IL or missing references) //IL_08a8: Unknown result type (might be due to invalid IL or missing references) //IL_08b2: Unknown result type (might be due to invalid IL or missing references) //IL_08b7: Unknown result type (might be due to invalid IL or missing references) //IL_08c4: Unknown result type (might be due to invalid IL or missing references) //IL_08c6: Unknown result type (might be due to invalid IL or missing references) //IL_08ce: Unknown result type (might be due to invalid IL or missing references) //IL_08d8: Unknown result type (might be due to invalid IL or missing references) //IL_08dd: Unknown result type (might be due to invalid IL or missing references) //IL_08e8: Unknown result type (might be due to invalid IL or missing references) //IL_08f2: Unknown result type (might be due to invalid IL or missing references) //IL_08f7: Unknown result type (might be due to invalid IL or missing references) //IL_0904: Unknown result type (might be due to invalid IL or missing references) //IL_0906: Unknown result type (might be due to invalid IL or missing references) //IL_090e: Unknown result type (might be due to invalid IL or missing references) //IL_0918: Unknown result type (might be due to invalid IL or missing references) //IL_091d: Unknown result type (might be due to invalid IL or missing references) //IL_0928: Unknown result type (might be due to invalid IL or missing references) //IL_0932: Unknown result type (might be due to invalid IL or missing references) //IL_0937: Unknown result type (might be due to invalid IL or missing references) //IL_0942: Unknown result type (might be due to invalid IL or missing references) //IL_094c: Unknown result type (might be due to invalid IL or missing references) //IL_0951: Unknown result type (might be due to invalid IL or missing references) //IL_095b: Unknown result type (might be due to invalid IL or missing references) //IL_095d: Unknown result type (might be due to invalid IL or missing references) //IL_0964: Unknown result type (might be due to invalid IL or missing references) //IL_0969: Unknown result type (might be due to invalid IL or missing references) //IL_096e: Unknown result type (might be due to invalid IL or missing references) //IL_0973: Unknown result type (might be due to invalid IL or missing references) //IL_0975: Unknown result type (might be due to invalid IL or missing references) //IL_097c: Unknown result type (might be due to invalid IL or missing references) //IL_0981: Unknown result type (might be due to invalid IL or missing references) //IL_0986: Unknown result type (might be due to invalid IL or missing references) //IL_0988: Unknown result type (might be due to invalid IL or missing references) //IL_098f: Unknown result type (might be due to invalid IL or missing references) //IL_0994: Unknown result type (might be due to invalid IL or missing references) //IL_09a1: Unknown result type (might be due to invalid IL or missing references) //IL_09a3: Unknown result type (might be due to invalid IL or missing references) //IL_09aa: Unknown result type (might be due to invalid IL or missing references) //IL_09af: Unknown result type (might be due to invalid IL or missing references) //IL_09b4: Unknown result type (might be due to invalid IL or missing references) //IL_09b6: Unknown result type (might be due to invalid IL or missing references) //IL_09bd: Unknown result type (might be due to invalid IL or missing references) //IL_09c2: Unknown result type (might be due to invalid IL or missing references) //IL_09cf: Unknown result type (might be due to invalid IL or missing references) //IL_09d1: Unknown result type (might be due to invalid IL or missing references) //IL_09d8: Unknown result type (might be due to invalid IL or missing references) //IL_09dd: Unknown result type (might be due to invalid IL or missing references) //IL_09e2: Unknown result type (might be due to invalid IL or missing references) //IL_09e4: Unknown result type (might be due to invalid IL or missing references) //IL_09eb: Unknown result type (might be due to invalid IL or missing references) //IL_09f0: Unknown result type (might be due to invalid IL or missing references) //IL_0a12: Unknown result type (might be due to invalid IL or missing references) //IL_0a14: Unknown result type (might be due to invalid IL or missing references) //IL_0a1b: Unknown result type (might be due to invalid IL or missing references) //IL_0a20: Unknown result type (might be due to invalid IL or missing references) //IL_0a25: Unknown result type (might be due to invalid IL or missing references) //IL_0a2c: Unknown result type (might be due to invalid IL or missing references) //IL_0a31: Unknown result type (might be due to invalid IL or missing references) //IL_0a36: Unknown result type (might be due to invalid IL or missing references) //IL_0a41: Unknown result type (might be due to invalid IL or missing references) //IL_0a43: Unknown result type (might be due to invalid IL or missing references) //IL_0a4d: Unknown result type (might be due to invalid IL or missing references) //IL_0a52: Unknown result type (might be due to invalid IL or missing references) //IL_0a57: Unknown result type (might be due to invalid IL or missing references) //IL_0a67: Unknown result type (might be due to invalid IL or missing references) //IL_0a69: Unknown result type (might be due to invalid IL or missing references) //IL_0a73: Unknown result type (might be due to invalid IL or missing references) //IL_0a78: Unknown result type (might be due to invalid IL or missing references) //IL_0a7d: Unknown result type (might be due to invalid IL or missing references) //IL_0a84: Unknown result type (might be due to invalid IL or missing references) //IL_0a86: Unknown result type (might be due to invalid IL or missing references) //IL_0a8d: Unknown result type (might be due to invalid IL or missing references) //IL_0a92: Unknown result type (might be due to invalid IL or missing references) //IL_0a97: Unknown result type (might be due to invalid IL or missing references) //IL_0a9e: Unknown result type (might be due to invalid IL or missing references) //IL_0aa3: Unknown result type (might be due to invalid IL or missing references) //IL_0aa8: Unknown result type (might be due to invalid IL or missing references) //IL_0aad: Unknown result type (might be due to invalid IL or missing references) //IL_0aaf: Unknown result type (might be due to invalid IL or missing references) //IL_0ab6: Unknown result type (might be due to invalid IL or missing references) //IL_0abb: Unknown result type (might be due to invalid IL or missing references) //IL_0ac0: Unknown result type (might be due to invalid IL or missing references) //IL_0ac2: Unknown result type (might be due to invalid IL or missing references) //IL_0ac9: Unknown result type (might be due to invalid IL or missing references) //IL_0ace: Unknown result type (might be due to invalid IL or missing references) //IL_0adb: Unknown result type (might be due to invalid IL or missing references) //IL_0add: Unknown result type (might be due to invalid IL or missing references) //IL_0ae4: Unknown result type (might be due to invalid IL or missing references) //IL_0ae9: Unknown result type (might be due to invalid IL or missing references) //IL_0aee: Unknown result type (might be due to invalid IL or missing references) //IL_0af5: Unknown result type (might be due to invalid IL or missing references) //IL_0afa: Unknown result type (might be due to invalid IL or missing references) //IL_0aff: Unknown result type (might be due to invalid IL or missing references) //IL_0b01: Unknown result type (might be due to invalid IL or missing references) //IL_0b08: Unknown result type (might be due to invalid IL or missing references) //IL_0b0d: Unknown result type (might be due to invalid IL or missing references) //IL_0b12: Unknown result type (might be due to invalid IL or missing references) //IL_0b19: Unknown result type (might be due to invalid IL or missing references) //IL_0b1e: Unknown result type (might be due to invalid IL or missing references) //IL_0b2b: Unknown result type (might be due to invalid IL or missing references) //IL_0b2d: Unknown result type (might be due to invalid IL or missing references) //IL_0b34: Unknown result type (might be due to invalid IL or missing references) //IL_0b39: Unknown result type (might be due to invalid IL or missing references) //IL_0b3e: Unknown result type (might be due to invalid IL or missing references) //IL_0b45: Unknown result type (might be due to invalid IL or missing references) //IL_0b4a: Unknown result type (might be due to invalid IL or missing references) //IL_0b4f: Unknown result type (might be due to invalid IL or missing references) //IL_0b51: Unknown result type (might be due to invalid IL or missing references) //IL_0b58: Unknown result type (might be due to invalid IL or missing references) //IL_0b5d: Unknown result type (might be due to invalid IL or missing references) //IL_0b62: Unknown result type (might be due to invalid IL or missing references) //IL_0b69: Unknown result type (might be due to invalid IL or missing references) //IL_0b6e: Unknown result type (might be due to invalid IL or missing references) //IL_0b7b: Unknown result type (might be due to invalid IL or missing references) //IL_0b7d: Unknown result type (might be due to invalid IL or missing references) //IL_0b84: Unknown result type (might be due to invalid IL or missing references) //IL_0b89: Unknown result type (might be due to invalid IL or missing references) //IL_0b8e: Unknown result type (might be due to invalid IL or missing references) //IL_0b90: Unknown result type (might be due to invalid IL or missing references) //IL_0b97: Unknown result type (might be due to invalid IL or missing references) //IL_0b9c: Unknown result type (might be due to invalid IL or missing references) //IL_0ba1: Unknown result type (might be due to invalid IL or missing references) //IL_0ba8: Unknown result type (might be due to invalid IL or missing references) //IL_0bad: Unknown result type (might be due to invalid IL or missing references) //IL_0bba: Unknown result type (might be due to invalid IL or missing references) //IL_0bbc: Unknown result type (might be due to invalid IL or missing references) //IL_0bc3: Unknown result type (might be due to invalid IL or missing references) //IL_0bc8: Unknown result type (might be due to invalid IL or missing references) //IL_0bcd: Unknown result type (might be due to invalid IL or missing references) //IL_0bcf: Unknown result type (might be due to invalid IL or missing references) //IL_0bd6: Unknown result type (might be due to invalid IL or missing references) //IL_0bdb: Unknown result type (might be due to invalid IL or missing references) //IL_0be0: Unknown result type (might be due to invalid IL or missing references) //IL_0be7: Unknown result type (might be due to invalid IL or missing references) //IL_0bec: Unknown result type (might be due to invalid IL or missing references) //IL_0bf9: Unknown result type (might be due to invalid IL or missing references) //IL_0bfb: Unknown result type (might be due to invalid IL or missing references) //IL_0c02: Unknown result type (might be due to invalid IL or missing references) //IL_0c07: Unknown result type (might be due to invalid IL or missing references) //IL_0c0c: Unknown result type (might be due to invalid IL or missing references) //IL_0c13: Unknown result type (might be due to invalid IL or missing references) //IL_0c18: Unknown result type (might be due to invalid IL or missing references) //IL_0c1d: Unknown result type (might be due to invalid IL or missing references) //IL_0c1f: Unknown result type (might be due to invalid IL or missing references) //IL_0c26: Unknown result type (might be due to invalid IL or missing references) //IL_0c2b: Unknown result type (might be due to invalid IL or missing references) //IL_0c30: Unknown result type (might be due to invalid IL or missing references) //IL_0c37: Unknown result type (might be due to invalid IL or missing references) //IL_0c3c: Unknown result type (might be due to invalid IL or missing references) //IL_0c4f: Unknown result type (might be due to invalid IL or missing references) //IL_0c51: Unknown result type (might be due to invalid IL or missing references) //IL_0c58: Unknown result type (might be due to invalid IL or missing references) //IL_0c5d: Unknown result type (might be due to invalid IL or missing references) //IL_0c62: Unknown result type (might be due to invalid IL or missing references) //IL_0c72: Unknown result type (might be due to invalid IL or missing references) //IL_0c74: Unknown result type (might be due to invalid IL or missing references) //IL_0c7b: Unknown result type (might be due to invalid IL or missing references) //IL_0c80: Unknown result type (might be due to invalid IL or missing references) //IL_0c85: Unknown result type (might be due to invalid IL or missing references) //IL_0c8c: Unknown result type (might be due to invalid IL or missing references) //IL_0c91: Unknown result type (might be due to invalid IL or missing references) //IL_0c96: Unknown result type (might be due to invalid IL or missing references) //IL_0ca6: Unknown result type (might be due to invalid IL or missing references) //IL_0ca8: Unknown result type (might be due to invalid IL or missing references) //IL_0caf: Unknown result type (might be due to invalid IL or missing references) //IL_0cb4: Unknown result type (might be due to invalid IL or missing references) //IL_0cb9: Unknown result type (might be due to invalid IL or missing references) //IL_0cc0: Unknown result type (might be due to invalid IL or missing references) //IL_0cc5: Unknown result type (might be due to invalid IL or missing references) //IL_0cca: Unknown result type (might be due to invalid IL or missing references) //IL_0cda: Unknown result type (might be due to invalid IL or missing references) //IL_0cdc: Unknown result type (might be due to invalid IL or missing references) //IL_0ce3: Unknown result type (might be due to invalid IL or missing references) //IL_0ce8: Unknown result type (might be due to invalid IL or missing references) //IL_0ced: Unknown result type (might be due to invalid IL or missing references) //IL_0cf4: Unknown result type (might be due to invalid IL or missing references) //IL_0cf9: Unknown result type (might be due to invalid IL or missing references) //IL_0cfe: Unknown result type (might be due to invalid IL or missing references) //IL_0d0e: Unknown result type (might be due to invalid IL or missing references) //IL_0d10: Unknown result type (might be due to invalid IL or missing references) //IL_0d17: Unknown result type (might be due to invalid IL or missing references) //IL_0d1c: Unknown result type (might be due to invalid IL or missing references) //IL_0d21: Unknown result type (might be due to invalid IL or missing references) //IL_0d28: Unknown result type (might be due to invalid IL or missing references) //IL_0d2d: Unknown result type (might be due to invalid IL or missing references) //IL_0d32: Unknown result type (might be due to invalid IL or missing references) _sendTimer -= Time.deltaTime; _sendPoseThisFrame = _sendTimer <= 0f; Vector3 velocity; int num; if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh && !_agent.isStopped) { velocity = _agent.velocity; num = ((((Vector3)(ref velocity)).sqrMagnitude > 0.02f) ? 1 : 0); } else { num = 0; } bool flag = (byte)num != 0; _gaitBlend = Mathf.MoveTowards(_gaitBlend, flag ? 1f : 0f, Time.deltaTime * (flag ? 3.8f : 5.2f)); float num2; if (!flag) { num2 = 0f; } else { velocity = _agent.velocity; num2 = Mathf.Max(0.3f, ((Vector3)(ref velocity)).magnitude); } float num3 = num2; _walkPhase += Time.deltaTime * (3.15f + num3 * 0.62f) * Mathf.Lerp(0.15f, 1f, _gaitBlend); float num4 = Mathf.Sin(_walkPhase) * _gaitBlend; float num5 = Mathf.Cos(_walkPhase) * _gaitBlend; float num6 = Mathf.Sin(Time.time * 1.35f); float num7 = Mathf.Abs(num5) * 0.026f + num6 * 0.007f; float num8 = num4 * 0.022f + num6 * 0.004f; float num9 = 0.188f + Mathf.Abs(num4) * 0.02f + num6 * 0.006f; Vector3 val = Local(new Vector3(num8, 0.755f + num7, 0.01f)); Vector3 val2 = Local(new Vector3(num8 * 0.72f, 1.165f + num7, num9)); Quaternion val3 = ((Component)this).transform.rotation * Quaternion.Euler(22.5f + num6 * 0.9f + num5 * 1.25f, num4 * 1.75f, (0f - num4) * 1.85f); Vector3 val4 = val3 * Vector3.right; Vector3 val5 = val3 * Vector3.up; Vector3 val6 = val3 * Vector3.forward; PosePart(Part(VoodooPartRole.Body), val2, val3 * Quaternion.Euler(0f, 0f, 1.2f)); Vector3 val7 = val2 + val6 * 0.235f; PosePart(Part(VoodooPartRole.BodyUpper), val7 + val6 * 0.012f - val4 * 0.105f + val5 * 0.165f, val3); PosePart(Part(VoodooPartRole.BodyMiddle), val7 + val6 * 0.018f + val4 * 0.105f + val5 * 0.16f, val3); PosePart(Part(VoodooPartRole.BodyLower), val7 + val6 * 0.024f - val4 * 0.1f - val5 * 0.16f, val3); PosePart(Part(VoodooPartRole.BodyFourth), val7 + val6 * 0.03f + val4 * 0.1f - val5 * 0.165f, val3); Vector3 val8 = Local(new Vector3(num8 * 0.86f, 1.685f + num7, num9 + 0.145f)); Quaternion val9 = ((Component)this).transform.rotation * Quaternion.Euler(15.5f + num6 * 0.85f + num5 * 1.3f, num4 * 1.95f, (0f - num4) * 1.4f); Vector3 val10 = val9 * Vector3.right; Vector3 val11 = val9 * Vector3.up; Vector3 val12 = val9 * Vector3.forward; PosePart(Part(VoodooPartRole.Head), val8, val9 * Quaternion.Euler(0f, 0f, -1.5f)); float num10 = num4 * 0.285f; float num11 = 0f - num10; float num12 = Mathf.Max(0f, num4) * 0.095f; float num13 = Mathf.Max(0f, 0f - num4) * 0.095f; Vector3 start = Local(new Vector3(-0.235f + num8, 1.405f + num7, num9 * 0.86f)); Vector3 start2 = Local(new Vector3(0.235f + num8, 1.395f + num7, num9 * 0.84f)); Vector3 val13 = Local(new Vector3(-0.295f + num8, 0.565f + num7 + num13 * 0.22f, (0f - num10) * 0.82f + 0.125f)); Vector3 val14 = Local(new Vector3(0.285f + num8, 0.545f + num7 + num12 * 0.22f, (0f - num11) * 0.82f + 0.115f)); Vector3 val15 = Local(new Vector3(-0.335f + num8, 1f + num7 * 0.72f, num10 * 0.26f + num9 * 0.83f)); Vector3 val16 = Local(new Vector3(0.195f + num8, 0.97f + num7 * 0.72f, num11 * 0.26f + num9 * 0.85f)); PoseSegment(VoodooPartRole.UpperArmLeft, start, val15); PoseSegment(VoodooPartRole.LowerArmLeft, val15, val13); PoseSegment(VoodooPartRole.UpperArmRight, start2, val16); PoseSegment(VoodooPartRole.LowerArmRight, val16, val14); Vector3 start3 = val - ((Component)this).transform.right * 0.105f; Vector3 start4 = val + ((Component)this).transform.right * 0.105f; Vector3 val17 = Local(new Vector3(-0.105f + num8, 0.075f + num12, num10)); Vector3 val18 = Local(new Vector3(0.105f + num8, 0.075f + num13, num11)); Vector3 val19 = Local(new Vector3(-0.102f + num8, 0.395f + num7 * 0.42f + num12 * 0.3f, num10 * 0.43f + 0.165f)); Vector3 val20 = Local(new Vector3(0.102f + num8, 0.395f + num7 * 0.42f + num13 * 0.3f, num11 * 0.43f + 0.165f)); PoseSegment(VoodooPartRole.UpperLegLeft, start3, val19); PoseSegment(VoodooPartRole.LowerLegLeft, val19, val17); PoseSegment(VoodooPartRole.UpperLegRight, start4, val20); PoseSegment(VoodooPartRole.LowerLegRight, val20, val18); PoseSegment(VoodooPartRole.LeftFoot, val17, val17 + ((Component)this).transform.forward * (0.19f + Mathf.Max(0f, num10) * 0.24f) - ((Component)this).transform.up * 0.042f); PoseSegment(VoodooPartRole.RightFoot, val18, val18 + ((Component)this).transform.forward * (0.19f + Mathf.Max(0f, num11) * 0.24f) - ((Component)this).transform.up * 0.042f); PoseSegment(VoodooPartRole.LeftClawOuter, val13, val13 - ((Component)this).transform.up * 0.17f - ((Component)this).transform.right * 0.085f + ((Component)this).transform.forward * 0.055f); PoseSegment(VoodooPartRole.LeftClawMiddle, val13, val13 - ((Component)this).transform.up * 0.19f + ((Component)this).transform.forward * 0.07f); PoseSegment(VoodooPartRole.LeftClawInner, val13, val13 - ((Component)this).transform.up * 0.16f + ((Component)this).transform.right * 0.08f + ((Component)this).transform.forward * 0.045f); PoseSegment(VoodooPartRole.RightClawOuter, val14, val14 - ((Component)this).transform.up * 0.17f + ((Component)this).transform.right * 0.085f + ((Component)this).transform.forward * 0.055f); PoseSegment(VoodooPartRole.RightClawMiddle, val14, val14 - ((Component)this).transform.up * 0.19f + ((Component)this).transform.forward * 0.07f); PoseSegment(VoodooPartRole.RightClawInner, val14, val14 - ((Component)this).transform.up * 0.16f - ((Component)this).transform.right * 0.08f + ((Component)this).transform.forward * 0.045f); Vector3 val21 = val2 + val6 * 0.29f; PoseSegment(VoodooPartRole.ChestStitchUpper, val21 + val5 * 0.28f, val21 + val5 * 0.08f); PoseSegment(VoodooPartRole.ChestStitchMiddle, val21 + val5 * 0.09f, val21 - val5 * 0.11f); PoseSegment(VoodooPartRole.ChestStitchLower, val21 - val5 * 0.1f, val21 - val5 * 0.3f); float num14 = Mathf.Sin(Time.time * 3.2f) * 0.008f; Vector3 val22 = val8 + val12 * 0.17f + val11 * 0.03f; PosePart(Part(VoodooPartRole.LeftPupil), val22 - val10 * (0.132f + num14), val9); PosePart(Part(VoodooPartRole.RightPupil), val22 + val10 * (0.132f + num14), val9); Vector3 val23 = val8 - val12 * 0.015f + val11 * 0.035f; PoseSegment(VoodooPartRole.PinTop, val23 + val11 * 0.18f, val23 + val11 * 0.41f); PoseSegment(VoodooPartRole.PinUpperLeft, val23 - val10 * 0.15f + val11 * 0.11f, val23 - val10 * 0.36f + val11 * 0.29f); PoseSegment(VoodooPartRole.PinUpperRight, val23 + val10 * 0.15f + val11 * 0.11f, val23 + val10 * 0.36f + val11 * 0.29f); PoseSegment(VoodooPartRole.PinSideLeft, val23 - val10 * 0.19f, val23 - val10 * 0.42f - val11 * 0.015f); PoseSegment(VoodooPartRole.PinSideRight, val23 + val10 * 0.19f, val23 + val10 * 0.42f - val11 * 0.015f); PoseSegment(VoodooPartRole.PinBack, val23 - val12 * 0.12f + val11 * 0.08f, val23 - val12 * 0.35f + val11 * 0.18f); PosePart(Part(VoodooPartRole.PinHeadTop), val23 + val11 * 0.41f, val9); PosePart(Part(VoodooPartRole.PinHeadUpperLeft), val23 - val10 * 0.36f + val11 * 0.29f, val9); PosePart(Part(VoodooPartRole.PinHeadUpperRight), val23 + val10 * 0.36f + val11 * 0.29f, val9); PosePart(Part(VoodooPartRole.PinHeadSideLeft), val23 - val10 * 0.42f - val11 * 0.015f, val9); PosePart(Part(VoodooPartRole.PinHeadSideRight), val23 + val10 * 0.42f - val11 * 0.015f, val9); if (_sendPoseThisFrame) { _sendTimer = 1f / 30f; if ((Object)(object)_target != (Object)null && (Object)(object)_poseDeliveredTarget != (Object)(object)_target) { _poseDeliveredTarget = _target; _targetAttackReadyTime = Mathf.Max(_targetAttackReadyTime, Time.time + 0.75f); } } } private void ArmTargetVisibilityGrace() { _poseDeliveredTarget = null; _sendTimer = 0f; _attackCooldown = Mathf.Max(_attackCooldown, 0.85f); _targetAttackReadyTime = Time.time + 0.85f; } private Vector3 Local(Vector3 point) { //IL_0006: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) return ((Component)this).transform.position + ((Component)this).transform.rotation * point; } private SpawnedVoodooPart Part(VoodooPartRole role) { return _parts.Find((SpawnedVoodooPart part) => part != null && part.Role == role); } private void PoseSegment(VoodooPartRole role, Vector3 start, Vector3 end) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_003d: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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) SpawnedVoodooPart spawnedVoodooPart = Part(role); if (spawnedVoodooPart != null) { Vector3 val = end - start; Quaternion rotation = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? StableSegmentRotation(spawnedVoodooPart, ((Vector3)(ref val)).normalized) : ((Component)this).transform.rotation); PosePart(spawnedVoodooPart, (start + end) * 0.5f, rotation); } } private Quaternion StableSegmentRotation(SpawnedVoodooPart part, Vector3 direction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_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_0035: 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_003a: 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_003c: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.FromToRotation(part.LongAxisLocal, direction); Vector3 val2 = ((Mathf.Abs(Vector3.Dot(((Vector3)(ref part.LongAxisLocal)).normalized, Vector3.forward)) < 0.92f) ? Vector3.forward : Vector3.right); Vector3 val3 = Vector3.ProjectOnPlane(val * val2, direction); Vector3 val4 = Vector3.ProjectOnPlane(((Component)this).transform.forward, direction); if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f || ((Vector3)(ref val4)).sqrMagnitude < 0.0001f) { val4 = Vector3.ProjectOnPlane(((Component)this).transform.right, direction); } if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f || ((Vector3)(ref val4)).sqrMagnitude < 0.0001f) { return val; } return Quaternion.AngleAxis(Vector3.SignedAngle(((Vector3)(ref val3)).normalized, ((Vector3)(ref val4)).normalized, direction), direction) * val; } private void PosePart(SpawnedVoodooPart part, Vector3 visualCenter, Quaternion rotation) { //IL_0015: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0267: 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) if ((Object)(object)part?.Phys == (Object)null) { return; } rotation *= part.LocalRotation; if (part.GeometryCalibrationFrames > 0) { VoodooSpawner.RefreshGeometry(part, refreshLongAxis: false); part.GeometryCalibrationFrames--; if (part.GeometryCalibrationFrames == 0 && !part.GeometryLogged && ShouldLogGeometry(part.Role)) { part.GeometryLogged = true; Plugin.Log.LogInfo((object)($"Voodoo geometry {part.Role}: resource={part.ResourcePath}, " + $"scale={part.Root.transform.localScale}, rendered={part.VisualSize}, " + $"centerOffset={part.VisualCenterOffset}, axis={part.LongAxisLocal}.")); } } if (!part.PoseInitialized) { part.SmoothedVisualCenter = visualCenter; part.SmoothedRotation = rotation; part.PoseInitialized = true; } else { float num = 1f - Mathf.Exp(-9.2f * Time.deltaTime); float num2 = 1f - Mathf.Exp(-7.8f * Time.deltaTime); part.SmoothedVisualCenter = Vector3.Lerp(part.SmoothedVisualCenter, visualCenter, num); part.SmoothedRotation = Quaternion.Slerp(part.SmoothedRotation, rotation, num2); } visualCenter = part.SmoothedVisualCenter; rotation = part.SmoothedRotation; Vector3 val = visualCenter - rotation * part.VisualCenterOffset; part.Phys.OverrideKinematic(0.35f); part.Phys.OverrideGrabDisable(0.35f); part.Phys.OverrideIndestructible(0.35f); bool flag = !GameManager.Multiplayer() || ((Object)(object)_target?.photonView != (Object)null && _target.photonView.IsMine); VoodooSpawner.SetLocalRenderers(part, flag); if (flag) { part.Phys.SetPositionLogic(val, rotation); return; } part.Phys.SetPositionLogic(VoodooSpawner.HiddenPosition, Quaternion.identity); if (_sendPoseThisFrame) { PlayerAvatar target = _target; object obj; if (target == null) { obj = null; } else { PhotonView photonView = target.photonView; obj = ((photonView != null) ? photonView.Owner : null); } if (obj != null && !((Object)(object)part.View == (Object)null)) { part.View.RPC("SetPositionRPC", _target.photonView.Owner, new object[2] { val, rotation }); } } } private void UpdateVictimOnlySteps() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_agent == (Object)null || !((Behaviour)_agent).enabled || !_agent.isOnNavMesh) { return; } Vector3 velocity = _agent.velocity; if (!(((Vector3)(ref velocity)).sqrMagnitude < 0.03f) && GunAccess.IsLiving(_target)) { _stepTimer -= Time.deltaTime; if (!(_stepTimer > 0f)) { _stepTimer = Mathf.Clamp(0.78f / Mathf.Max(0.65f, _agent.speed), 0.28f, 0.8f); TargetedImpact("ImpactLightRPC", 24f, ((Component)this).transform.position + Vector3.up * 0.05f); } } } private void TargetedImpact(string rpc, float force, Vector3 position) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) SpawnedVoodooPart spawnedVoodooPart = ((_parts.Count > 0) ? _parts[0] : null); if ((Object)(object)spawnedVoodooPart?.ImpactDetector == (Object)null) { return; } if (!GameManager.Multiplayer() || ((Object)(object)_target?.photonView != (Object)null && _target.photonView.IsMine)) { if (rpc == "ImpactHeavyRPC") { spawnedVoodooPart.ImpactDetector.ImpactHeavy(force, position); } else { spawnedVoodooPart.ImpactDetector.ImpactLight(force, position); } return; } PlayerAvatar target = _target; object obj; if (target == null) { obj = null; } else { PhotonView photonView = target.photonView; obj = ((photonView != null) ? photonView.Owner : null); } Player val = (Player)obj; PhotonView view = spawnedVoodooPart.View; if (view != null) { view.RPC(rpc, val, new object[2] { force, position }); } } private void TeleportAround(PlayerAvatar player, bool smoke) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_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_010b: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) if (!GunAccess.IsLiving(player) || (Object)(object)_agent == (Object)null) { return; } if (smoke) { TargetedSmoke(((Component)this).transform.position + Vector3.up * 1f); } Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(3.2f, 5.2f); NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(((Component)player).transform.position + new Vector3(val.x, 0f, val.y), ref val2, 5f, -1)) { ((Component)this).transform.position = ((NavMeshHit)(ref val2)).position; if (((Behaviour)_agent).enabled) { _agent.Warp(((NavMeshHit)(ref val2)).position); } foreach (SpawnedVoodooPart part in _parts) { if (part != null) { part.PoseInitialized = false; } } } Vector3 val3 = ((Component)player).transform.position - ((Component)this).transform.position; val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude > 0.01f) { ((Component)this).transform.rotation = Quaternion.LookRotation(((Vector3)(ref val3)).normalized, Vector3.up); } if (smoke) { TargetedSmoke(((Component)this).transform.position + Vector3.up * 1f); } } private static bool ShouldLogGeometry(VoodooPartRole role) { if (role != VoodooPartRole.Body && role != VoodooPartRole.BodyUpper && role != VoodooPartRole.BodyMiddle && role != VoodooPartRole.BodyLower && role != VoodooPartRole.BodyFourth && role != VoodooPartRole.Head && role != VoodooPartRole.UpperArmLeft && role != VoodooPartRole.UpperLegLeft && role != VoodooPartRole.LeftFoot && role != VoodooPartRole.LeftEye && role != VoodooPartRole.LeftPupil) { return role == VoodooPartRole.PinTop; } return true; } private void TargetedSmoke(Vector3 position) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) SpawnedVoodooPart spawnedVoodooPart = ((_parts.Count > 0) ? _parts[0] : null); if ((Object)(object)spawnedVoodooPart?.ImpactDetector == (Object)null) { return; } if (!GameManager.Multiplayer() || ((Object)(object)_target?.photonView != (Object)null && _target.photonView.IsMine)) { AssetManager instance = AssetManager.instance; if (instance != null) { instance.PhysImpactEffect(position); } AssetManager instance2 = AssetManager.instance; if (instance2 != null) { instance2.PhysImpactEffect(position + Vector3.up * 0.35f); } return; } PlayerAvatar target = _target; object obj; if (target == null) { obj = null; } else { PhotonView photonView = target.photonView; obj = ((photonView != null) ? photonView.Owner : null); } Player val = (Player)obj; PhotonView view = spawnedVoodooPart.View; if (view != null) { view.RPC("ImpactEffectRPC", val, new object[1] { position }); } PhotonView view2 = spawnedVoodooPart.View; if (view2 != null) { view2.RPC("ImpactEffectRPC", val, new object[1] { position + Vector3.up * 0.35f }); } } private void HideFrom(PlayerAvatar player) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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) if ((Object)(object)player == (Object)null) { return; } bool flag = !GameManager.Multiplayer() || ((Object)(object)player.photonView != (Object)null && player.photonView.IsMine); foreach (SpawnedVoodooPart part in _parts) { if (flag) { VoodooSpawner.SetLocalRenderers(part, enabled: false); PhysGrabObject phys = part.Phys; if (phys != null) { phys.SetPositionLogic(VoodooSpawner.HiddenPosition, Quaternion.identity); } continue; } PhotonView photonView = player.photonView; if (((photonView != null) ? photonView.Owner : null) != null && (Object)(object)part?.View != (Object)null) { part.View.RPC("SetPositionRPC", player.photonView.Owner, new object[2] { VoodooSpawner.HiddenPosition, Quaternion.identity }); } } } private void SendHiddenToEveryoneExceptTarget() { if (!GameManager.Multiplayer()) { return; } foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if ((Object)(object)item != (Object)null && (Object)(object)item != (Object)(object)_target) { HideFrom(item); } } } private void UpdateHostNearMusic() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_target != (Object)(object)PlayerAvatar.instance) && !((Object)(object)MusicEnemyNear.instance == (Object)null) && GunAccess.IsLiving(PlayerAvatar.instance)) { Vector3 val = ((Component)PlayerAvatar.instance).transform.position - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude <= 256f) { MusicEnemyNear.instance.OverrideActive(0.35f); } } } internal void OnDollDestroyed() { //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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (!_dead) { _dead = true; _doll = null; if ((Object)(object)_agent != (Object)null && ((Behaviour)_agent).enabled && _agent.isOnNavMesh) { _agent.isStopped = true; _agent.ResetPath(); } TargetedSmoke(((Component)this).transform.position + Vector3.up * 1f); CleanupEnemyParts(); _rewardTimer = 0.08f; Plugin.Log.LogInfo((object)$"The Voodoo's doll was destroyed; its medium orb will drop after {0.08f:F2}s."); } } private void UpdateDeath() { _rewardTimer -= Time.deltaTime; if (_rewardTimer <= 0f && !_rewardDropped) { DropReward(); } } private void DropReward() { //IL_0078: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) _rewardDropped = true; if (!Plugin.Settings.VoodooDropEnemyValuable.Value || (Object)(object)AssetManager.instance == (Object)null) { return; } GameObject val = (GameObject)(Mathf.Clamp(Plugin.Settings.VoodooRewardTier.Value, 1, 3) switch { 2 => AssetManager.instance.enemyValuableMedium, 1 => AssetManager.instance.enemyValuableSmall, _ => AssetManager.instance.enemyValuableBig, }); if (!((Object)(object)val == (Object)null)) { Vector3 val2 = ((Component)this).transform.position + Vector3.up * 0.45f; if (GameManager.Multiplayer()) { PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)val).name, val2, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate(val, val2, Quaternion.identity); } } } private PlayerAvatar SelectRandomLivingPlayer() { List list = new List(); foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { list.Add(item); } } if (list.Count != 0) { return list[Random.Range(0, list.Count)]; } return null; } private static string TargetLabel(PlayerAvatar player) { if ((Object)(object)player == (Object)null) { return "nobody"; } PhotonView photonView = player.photonView; object obj; if (photonView == null) { obj = null; } else { Player owner = photonView.Owner; obj = ((owner != null) ? owner.NickName : null); } if (obj == null) { obj = ((Object)player).name; } return (string)obj; } private void IgnoreSelfCollisions() { for (int i = 0; i < _parts.Count; i++) { for (int j = i + 1; j < _parts.Count; j++) { Collider[] array = _parts[i].Colliders ?? Array.Empty(); foreach (Collider val in array) { Collider[] array2 = _parts[j].Colliders ?? Array.Empty(); foreach (Collider val2 in array2) { if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { Physics.IgnoreCollision(val, val2, true); } } } } } } private void CleanupEnemyParts() { foreach (SpawnedVoodooPart part in _parts) { VoodooSpawner.Destroy(part); } _parts.Clear(); } private void OnDestroy() { if (!_dead) { HideFrom(_target); CleanupEnemyParts(); _doll?.ForceDestroy(notifyOwner: false); _doll = null; } } } internal sealed class VoodooDollController : MonoBehaviour { private readonly List _parts = new List(); private SpawnedVoodooPart _core; private VoodooController _owner; private float _valueSyncTimer; private float _settleTimer; private float _airborneTimer; private Vector3 _lastSafePosition; private Quaternion _lastSafeRotation; private bool _valueSynced; private bool _initialized; private bool _cleaningUp; internal PlayerAvatar CurrentHolder { get { if (_core?.Phys?.playerGrabbing == null) { return null; } foreach (PhysGrabber item in _core.Phys.playerGrabbing) { if ((Object)(object)item?.playerAvatar != (Object)null) { return item.playerAvatar; } } return null; } } internal bool Initialize(VoodooController owner, Vector3 position) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_0056: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_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_018a: 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) _owner = owner; ((Component)this).transform.position = position; VoodooPartRole[] array = new VoodooPartRole[5] { VoodooPartRole.DollTorso, VoodooPartRole.DollLeftArm, VoodooPartRole.DollRightArm, VoodooPartRole.DollLeftLeg, VoodooPartRole.DollRightLeg }; for (int i = 0; i < array.Length; i++) { Vector3 scaleMultiplier = ((i == 0) ? new Vector3(0.42f, 0.46f, 0.34f) : new Vector3(0.035f, 0.072f, 0.035f)); SpawnedVoodooPart spawnedVoodooPart = VoodooSpawner.SpawnDollPart(position + Vector3.up * 0.45f, scaleMultiplier, array[i], i == 0); if (spawnedVoodooPart == null) { ForceDestroy(notifyOwner: false); return false; } if (i == 0) { _core = spawnedVoodooPart; } _parts.Add(spawnedVoodooPart); } ConfigureStickPose(); _core.ImpactDetector.destroyDisable = false; _core.ImpactDetector.durability = 450f; UnityEvent onDestroy = _core.ImpactDetector.onDestroy; if (onDestroy != null) { onDestroy.AddListener(new UnityAction(OnCoreDestroyed)); } if ((Object)(object)_core.Phys.rb != (Object)null) { _core.Phys.rb.mass = 0.35f; _core.Phys.rb.collisionDetectionMode = (CollisionDetectionMode)2; _core.Phys.rb.interpolation = (RigidbodyInterpolation)1; } PoseInitial(position); _lastSafePosition = ((Component)_core.Phys).transform.position; _lastSafeRotation = ((Component)_core.Phys).transform.rotation; _settleTimer = 0.75f; _valueSyncTimer = 0.15f; _initialized = true; Plugin.Log.LogInfo((object)$"The Voodoo placed a centered compact wooden five-stick ${Plugin.Settings.VoodooDollValue.Value:F0} valuable doll (durability 450, mass 0.35)."); return true; } private void ConfigureStickPose() { //IL_001b: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) SetSegment(_parts[0], new Vector3(0f, 0.09f, 0f), new Vector3(0f, 0.34f, 0f)); SetSegment(_parts[1], new Vector3(-0.012f, 0.29f, 0f), new Vector3(-0.14f, 0.17f, 0f)); SetSegment(_parts[2], new Vector3(0.012f, 0.29f, 0f), new Vector3(0.14f, 0.17f, 0f)); SetSegment(_parts[3], new Vector3(-0.01f, 0.12f, 0f), new Vector3(-0.085f, -0.04f, 0f)); SetSegment(_parts[4], new Vector3(0.01f, 0.12f, 0f), new Vector3(0.085f, -0.04f, 0f)); } private static void SetSegment(SpawnedVoodooPart part, Vector3 start, Vector3 end) { //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) //IL_0002: 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_0009: 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_000b: 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_001a: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; part.LocalOffset = (start + end) * 0.5f; part.LocalRotation = Quaternion.FromToRotation(part.LongAxisLocal, ((Vector3)(ref val)).normalized); } private void PoseInitial(Vector3 anchor) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0042: Unknown result type (might be due to invalid IL or missing references) foreach (SpawnedVoodooPart part in _parts) { Quaternion localRotation = part.LocalRotation; Vector3 val = anchor + part.LocalOffset; part.Phys.SetPositionLogic(val - localRotation * part.VisualCenterOffset, localRotation); } } private void Update() { if (!_initialized || _cleaningUp || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if ((Object)(object)_core?.Root == (Object)null || (Object)(object)_core.Phys == (Object)null || _core.Phys.dead) { OnCoreDestroyed(); return; } _core.Phys.OverrideMass(0.35f, 0.35f); if ((Object)(object)_core.Phys.rb != (Object)null) { _core.Phys.rb.mass = 0.35f; } SyncValue(); PinAccessories(); KeepCoreOutOfTheFloor(); } private void KeepCoreOutOfTheFloor() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_core?.Phys?.rb == (Object)null) { return; } bool flag = (Object)(object)CurrentHolder != (Object)null; if (_settleTimer > 0f) { _settleTimer -= Time.deltaTime; _core.ImpactDetector.ImpactDisable(0.25f); } RaycastHit val = default(RaycastHit); bool flag2 = Physics.Raycast(_core.Phys.centerPoint + Vector3.up * 0.12f, Vector3.down, ref val, 1.35f, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); if (flag || flag2) { _airborneTimer = 0f; if (!flag && flag2) { Vector3 velocity = _core.Phys.rb.velocity; if (((Vector3)(ref velocity)).sqrMagnitude < 4f) { _lastSafePosition = ((Component)_core.Phys).transform.position; _lastSafeRotation = ((Component)_core.Phys).transform.rotation; } } return; } _airborneTimer += Time.deltaTime; if (((Component)_core.Phys).transform.position.y < _lastSafePosition.y - 2.2f || !(_airborneTimer < 3.5f)) { if (!_core.Phys.rb.isKinematic) { _core.Phys.rb.velocity = Vector3.zero; _core.Phys.rb.angularVelocity = Vector3.zero; } _core.Phys.Teleport(_lastSafePosition, _lastSafeRotation); _core.ImpactDetector.ImpactDisable(0.5f); _airborneTimer = 0f; Plugin.Log.LogWarning((object)"The Voodoo doll was recovered from a floor fall-through at its last safe grounded position."); } } private void SyncValue() { //IL_00b1: 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) if ((Object)(object)_core?.Valuable == (Object)null || _valueSynced) { return; } _valueSyncTimer -= Time.deltaTime; if (!(_valueSyncTimer > 0f)) { float num = Mathf.Clamp(Plugin.Settings.VoodooDollValue.Value, 100f, 50000f); if (GameManager.Multiplayer() && (Object)(object)_core.View != (Object)null) { _core.View.RPC("DollarValueSetRPC", (RpcTarget)0, new object[1] { num }); } else { _core.Valuable.DollarValueSetRPC(num, default(PhotonMessageInfo)); } _valueSynced = true; } } private void PinAccessories() { //IL_0012: 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_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_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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_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_004e: 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_005f: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00dd: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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) Transform transform = ((Component)_core.Phys).transform; Quaternion val = transform.rotation * Quaternion.Inverse(_core.LocalRotation); Vector3 val2 = transform.position + transform.rotation * _core.VisualCenterOffset - val * _core.LocalOffset; for (int i = 1; i < _parts.Count; i++) { SpawnedVoodooPart spawnedVoodooPart = _parts[i]; if (!((Object)(object)spawnedVoodooPart?.Phys == (Object)null)) { spawnedVoodooPart.Phys.OverrideKinematic(0.35f); spawnedVoodooPart.Phys.OverrideGrabDisable(0.35f); Quaternion val3 = val * spawnedVoodooPart.LocalRotation; Vector3 val4 = val2 + val * spawnedVoodooPart.LocalOffset; spawnedVoodooPart.Phys.SetPositionLogic(val4 - val3 * spawnedVoodooPart.VisualCenterOffset, val3); } } } private void OnCoreDestroyed() { if (!_cleaningUp) { _cleaningUp = true; CleanupParts(includeCore: false); _owner?.OnDollDestroyed(); Object.Destroy((Object)(object)((Component)this).gameObject); } } internal void ForceDestroy(bool notifyOwner) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if (_cleaningUp) { return; } _cleaningUp = true; if ((Object)(object)_core?.ImpactDetector != (Object)null) { UnityEvent onDestroy = _core.ImpactDetector.onDestroy; if (onDestroy != null) { onDestroy.RemoveListener(new UnityAction(OnCoreDestroyed)); } } CleanupParts(includeCore: true); if (notifyOwner) { _owner?.OnDollDestroyed(); } Object.Destroy((Object)(object)((Component)this).gameObject); } private void CleanupParts(bool includeCore) { foreach (SpawnedVoodooPart part in _parts) { if (part != null && (includeCore || !part.IsDollCore)) { VoodooSpawner.Destroy(part); } } _parts.Clear(); } private void OnDestroy() { if (!_cleaningUp) { ForceDestroy(notifyOwner: false); } } } [HarmonyPatch(typeof(PhysGrabObject), "GrabStartedRPC")] internal static class VoodooGrabProtection { [HarmonyPrefix] private static bool Prefix(PhysGrabObject __instance) { if (!((Object)(object)__instance == (Object)null)) { return (Object)(object)((Component)__instance).GetComponentInChildren(true) == (Object)null; } return true; } } internal static class VoodooCollisionProtection { internal static bool IsPrivateVoodooPart(PhysGrabObjectImpactDetector detector) { if ((Object)(object)detector == (Object)null) { return false; } if (!((Object)(object)((Component)detector).GetComponentInParent(true) != (Object)null)) { return (Object)(object)((Component)detector).GetComponentInChildren(true) != (Object)null; } return true; } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "OnCollisionStay")] internal static class VoodooCollisionStayProtection { [HarmonyPrefix] private static bool Prefix(PhysGrabObjectImpactDetector __instance) { return !VoodooCollisionProtection.IsPrivateVoodooPart(__instance); } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "OnTriggerStay")] internal static class VoodooTriggerStayProtection { [HarmonyPrefix] private static bool Prefix(PhysGrabObjectImpactDetector __instance) { return !VoodooCollisionProtection.IsPrivateVoodooPart(__instance); } } internal sealed class VoodooManager : MonoBehaviour { private int _levelInstanceId; private float _spawnTimer; private bool _attemptFinished; private bool _prefabProbeFinished; private bool _prefabsAvailable; private VoodooController _encounter; internal void Tick() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) if (!IsHostReady()) { return; } ProbePrefabs(); LevelGenerator instance = LevelGenerator.Instance; int num = (((Object)(object)instance != (Object)null) ? ((Object)instance).GetInstanceID() : 0); if (num != _levelInstanceId) { ResetForLevel(num); } if (!ModEnemyLevelRules.IsPlayableLevel()) { DestroyCurrentEncounter(); } else { if ((Object)(object)instance == (Object)null || !instance.Generated || _attemptFinished) { return; } _spawnTimer -= Time.deltaTime; if (!(_spawnTimer > 0f)) { _attemptFinished = true; if (Random.value <= Mathf.Clamp01(Plugin.Settings.VoodooSpawnChance.Value) && TryFindEnemyPosition(out var position)) { CreateEncounter(position, "automatic"); } } } } private void ResetForLevel(int levelId) { DestroyCurrentEncounter(); _levelInstanceId = levelId; _spawnTimer = Mathf.Max(0f, Plugin.Settings.VoodooSpawnDelay.Value); _attemptFinished = false; } private bool CreateEncounter(Vector3 enemyPosition, string source) { //IL_00d8: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_00b1: 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) GameObject val = null; try { if (!_prefabsAvailable && !VoodooSpawner.PrefabsAvailable()) { Plugin.Log.LogWarning((object)"The Voodoo could not resolve its black vinyl boards or doll rods."); return false; } if (!TryFindDollPosition(enemyPosition, out var position)) { Plugin.Log.LogWarning((object)"The Voodoo could not find a remote floor point for its doll."); return false; } DestroyCurrentEncounter(); val = new GameObject("The Voodoo Encounter (Host Logic)"); val.SetActive(false); val.transform.position = enemyPosition; VoodooController voodooController = val.AddComponent(); if (!voodooController.Initialize(enemyPosition, position)) { Object.Destroy((Object)(object)val); return false; } val.SetActive(true); if (!voodooController.ActivateNavigation(enemyPosition)) { Object.Destroy((Object)(object)val); return false; } _encounter = voodooController; Plugin.Log.LogInfo((object)$"The Voodoo spawned at {enemyPosition}; its doll waits at {position} ({source})."); return true; } catch (Exception arg) { Plugin.Log.LogError((object)$"The Voodoo encounter creation crashed at enemy={enemyPosition}, source={source}: {arg}"); DestroyCurrentEncounter(); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } return false; } } internal bool DebugSpawnAt(Vector3 requestedPosition) { //IL_0039: 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) if (!IsHostReady() || (!ModEnemySpawnCoordinator.IsDirectorRequestActive && (Object)(object)PlayerAvatar.instance == (Object)null) || !ModEnemyLevelRules.IsPlayableLevel()) { Plugin.Log.LogWarning((object)"Enemy Lab rejected The Voodoo because no playable host level is active."); return false; } ProbePrefabs(); NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requestedPosition, ref val, 12f, -1)) { return false; } _attemptFinished = true; return CreateEncounter(((NavMeshHit)(ref val)).position, ModEnemySpawnCoordinator.CurrentSpawnSource); } internal void MarkAutomaticAttemptFinished() { int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num != _levelInstanceId) { ResetForLevel(num); } _attemptFinished = true; } internal void DebugDespawn() { if (IsHostReady()) { _attemptFinished = true; DestroyCurrentEncounter(); } } private void DestroyCurrentEncounter() { if ((Object)(object)_encounter != (Object)null) { Object.Destroy((Object)(object)((Component)_encounter).gameObject); _encounter = null; } } private void ProbePrefabs() { if (!_prefabProbeFinished && !((Object)(object)RunManager.instance == (Object)null)) { _prefabProbeFinished = true; _prefabsAvailable = VoodooSpawner.PrefabsAvailable(); Plugin.Log.LogInfo((object)$"The Voodoo prefab probe: available={_prefabsAvailable}, body={VoodooSpawner.BodyResourcePath}, head={VoodooSpawner.HeadResourcePath}, limbs={VoodooSpawner.ArmResourcePath}, eyes={VoodooSpawner.EyeResourcePath}, pupils={VoodooSpawner.PupilResourcePath}, dollCore={VoodooSpawner.DollCoreResourcePath}, dollRods={VoodooSpawner.DollRodResourcePath}."); } } private static bool TryFindEnemyPosition(out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; PlayerAvatar val = null; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (GunAccess.IsLiving(item)) { val = item; break; } } Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); LevelPoint val3 = SemiFunc.LevelPointGetPlayerDistance(val2, 24f, 65f, false) ?? SemiFunc.LevelPointGetFurthestFromPlayer(val2, 8f); return ModEnemyNavigation.TryFindClearSpawn(((Object)(object)val3 != (Object)null) ? ((Component)val3).transform.position : (val2 + Vector3.forward * 22f), 8f, out position); } private static bool TryFindDollPosition(Vector3 enemyPosition, out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; NavMeshHit val2 = default(NavMeshHit); for (int i = 0; i < 10; i++) { LevelPoint val = SemiFunc.LevelPointGetPlayerDistance(enemyPosition, 18f, 75f, false); if ((Object)(object)val != (Object)null && NavMesh.SamplePosition(((Component)val).transform.position, ref val2, 5f, -1) && Vector3.Distance(((NavMeshHit)(ref val2)).position, enemyPosition) >= 12f) { position = ((NavMeshHit)(ref val2)).position + Vector3.up * 0.12f; return true; } } LevelPoint val3 = SemiFunc.LevelPointGetFurthestFromPlayer(enemyPosition, 6f); NavMeshHit val4 = default(NavMeshHit); if ((Object)(object)val3 != (Object)null && NavMesh.SamplePosition(((Component)val3).transform.position, ref val4, 6f, -1)) { position = ((NavMeshHit)(ref val4)).position + Vector3.up * 0.12f; return true; } return false; } private static bool IsHostReady() { try { return (Object)(object)GameManager.instance != (Object)null && (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient); } catch { return false; } } } internal enum VoodooPartRole { Body, BodyUpper, BodyMiddle, BodyLower, BodyFourth, Head, HeadUpper, HeadRight, HeadLower, UpperArmLeft, LowerArmLeft, UpperArmRight, LowerArmRight, UpperLegLeft, LowerLegLeft, UpperLegRight, LowerLegRight, LeftFoot, RightFoot, LeftClawOuter, LeftClawMiddle, LeftClawInner, RightClawOuter, RightClawMiddle, RightClawInner, ChestStitchUpper, ChestStitchMiddle, ChestStitchLower, LeftEye, RightEye, LeftPupil, RightPupil, Mouth, PinTop, PinUpperLeft, PinUpperRight, PinSideLeft, PinSideRight, PinBack, PinHeadTop, PinHeadUpperLeft, PinHeadUpperRight, PinHeadSideLeft, PinHeadSideRight, DollTorso, DollLeftArm, DollRightArm, DollLeftLeg, DollRightLeg } internal sealed class SpawnedVoodooPart { internal string ResourcePath; internal GameObject Root; internal PhysGrabObject Phys; internal PhysGrabObjectImpactDetector ImpactDetector; internal ItemAttributes Attributes; internal ValuableObject Valuable; internal PhotonView View; internal Renderer[] Renderers; internal Collider[] Colliders; internal VoodooPartRole Role; internal Vector3 LocalOffset; internal Quaternion LocalRotation = Quaternion.identity; internal Vector3 VisualCenterOffset; internal Vector3 VisualSize; internal Vector3 LongAxisLocal = Vector3.up; internal int GeometryCalibrationFrames = 6; internal Vector3 SmoothedVisualCenter; internal Quaternion SmoothedRotation = Quaternion.identity; internal bool GeometryLogged; internal bool PoseInitialized; internal bool IsDollCore; internal bool Alive = true; } internal static class VoodooSpawner { private static readonly string[] SizeFolders = new string[7] { "01 Tiny", "02 Small", "03 Medium", "04 Big", "05 Wide", "06 Tall", "07 Very Tall" }; internal static readonly Vector3 HiddenPosition = new Vector3(0f, -720f, 0f); private static string _bodyResourcePath; private static string _headResourcePath; private static string _armResourcePath; private static string _legResourcePath; private static string _pinResourcePath; private static string _eyeResourcePath; private static string _pupilResourcePath; private static string _patchResourcePath; private static string _pinHeadResourcePath; private static string _dollRodResourcePath; private static string _dollCoreResourcePath; private static string _slabResourcePath; private static string _phoneResourcePath; internal static string BodyResourcePath { get { object obj = _bodyResourcePath; if (obj == null) { obj = FindValuable("Valuable Museum Baby Head") ?? FindValuable("Valuable Museum Egg") ?? "Valuables/07 Very Tall/Valuable Manor Golden Statue"; _bodyResourcePath = (string)obj; } return (string)obj; } } internal static string HeadResourcePath { get { object obj = _headResourcePath; if (obj == null) { obj = FindValuable("Valuable Museum Baby Head") ?? BodyResourcePath; _headResourcePath = (string)obj; } return (string)obj; } } internal static string ArmResourcePath => _armResourcePath ?? (_armResourcePath = "Valuables/07 Very Tall/Valuable Wizard Broom"); internal static string LegResourcePath => _legResourcePath ?? (_legResourcePath = "Valuables/07 Very Tall/Valuable Wizard Broom"); internal static string PinResourcePath => _pinResourcePath ?? (_pinResourcePath = "Valuables/07 Very Tall/Valuable Wizard Broom"); internal static string EyeResourcePath { get { object obj = _eyeResourcePath; if (obj == null) { obj = FindValuable("Valuable Wizard Eye Ball") ?? FindValuable("Valuable Manor Pocket Watch") ?? BodyResourcePath; _eyeResourcePath = (string)obj; } return (string)obj; } } internal static string PupilResourcePath { get { object obj = _pupilResourcePath; if (obj == null) { obj = FindValuable("Valuable Museum Vinyl") ?? FindValuable("Valuable Manor Pocket Watch") ?? EyeResourcePath; _pupilResourcePath = (string)obj; } return (string)obj; } } internal static string PatchResourcePath { get { object obj = _patchResourcePath; if (obj == null) { obj = FindValuable("Valuable Wizard Fortune Card") ?? FindValuable("Valuable Arctic HDD") ?? PupilResourcePath; _patchResourcePath = (string)obj; } return (string)obj; } } internal static string PinHeadResourcePath { get { object obj = _pinHeadResourcePath; if (obj == null) { obj = FindValuable("Valuable Wizard Red Mushroom") ?? FindValuable("Valuable Manor Pocket Watch") ?? EyeResourcePath; _pinHeadResourcePath = (string)obj; } return (string)obj; } } internal static string DollRodResourcePath => _dollRodResourcePath ?? (_dollRodResourcePath = "Valuables/07 Very Tall/Valuable Wizard Broom"); internal static string DollCoreResourcePath { get { object obj = _dollCoreResourcePath; if (obj == null) { obj = FindValuable("Valuable Arctic Eraser") ?? FindValuable("Valuable Arctic Usb stick") ?? DollRodResourcePath; _dollCoreResourcePath = (string)obj; } return (string)obj; } } internal static string SlabResourcePath { get { object obj = _slabResourcePath; if (obj == null) { obj = FindValuable("Valuable Wizard Cube of Knowledge") ?? FindValuable("Valuable Cube of Knowledge") ?? FindValuable("Valuable Wizard Magic Cube") ?? FindValuable("Valuable Museum Cube ball") ?? FindValuable("Valuable Arctic HDD") ?? BodyResourcePath; _slabResourcePath = (string)obj; } return (string)obj; } } internal static string PhoneResourcePath { get { object obj = _phoneResourcePath; if (obj == null) { obj = FindValuable("Valuable Arctic Phone") ?? FindValuable("Valuable Phone") ?? FindValuable("Valuable Arctic Cell Phone") ?? FindValuable("Valuable Arctic HDD") ?? FindValuable("Valuable Arctic Usb stick") ?? DollRodResourcePath; _phoneResourcePath = (string)obj; } return (string)obj; } } internal static bool PrefabsAvailable() { if ((Object)(object)Resources.Load(BodyResourcePath) != (Object)null && (Object)(object)Resources.Load(HeadResourcePath) != (Object)null && (Object)(object)Resources.Load(ArmResourcePath) != (Object)null && (Object)(object)Resources.Load(LegResourcePath) != (Object)null && (Object)(object)Resources.Load(PinResourcePath) != (Object)null && (Object)(object)Resources.Load(PupilResourcePath) != (Object)null && (Object)(object)Resources.Load(PatchResourcePath) != (Object)null && (Object)(object)Resources.Load(PinHeadResourcePath) != (Object)null) { return (Object)(object)Resources.Load(DollRodResourcePath) != (Object)null; } return false; } private static string FindValuable(string prefabName) { string[] sizeFolders = SizeFolders; foreach (string text in sizeFolders) { string text2 = "Valuables/" + text + "/" + prefabName; if ((Object)(object)Resources.Load(text2) != (Object)null) { return text2; } } return null; } internal static SpawnedVoodooPart SpawnEnemyPart(string resourcePath, Vector3 scaleMultiplier, VoodooPartRole role) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) SpawnedVoodooPart spawnedVoodooPart = Spawn(resourcePath, HiddenPosition, Quaternion.identity, scaleMultiplier, role); if (spawnedVoodooPart == null) { return null; } try { EncounterValuableNeutralizer.Apply(spawnedVoodooPart.Root); ModEnemyInventoryBlocker.Attach(spawnedVoodooPart.Root); ItemAttributes attributes = spawnedVoodooPart.Attributes; if (attributes != null) { attributes.DisableUI(true); } spawnedVoodooPart.ImpactDetector.destroyDisable = true; spawnedVoodooPart.ImpactDetector.playerHurtDisable = true; try { spawnedVoodooPart.ImpactDetector.PlayerHitDisableSet(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Skipped PlayerHitDisableSet for '" + resourcePath + "': " + ex.GetType().Name + ".")); } spawnedVoodooPart.Phys.OverrideIndestructible(1f); spawnedVoodooPart.Phys.OverrideGrabDisable(1f); spawnedVoodooPart.Phys.OverrideKinematic(1f); MapIconSuppressor.Attach(spawnedVoodooPart.Root); ((Component)spawnedVoodooPart.Phys).gameObject.AddComponent(); DisableOrdinaryTransformStream(spawnedVoodooPart); } catch (Exception arg) { Plugin.Log.LogError((object)$"The Voodoo could not initialize '{resourcePath}'; removing partial room object: {arg}"); Destroy(spawnedVoodooPart); return null; } Collider[] array = spawnedVoodooPart.Colliders ?? Array.Empty(); foreach (Collider val in array) { if ((Object)(object)val != (Object)null) { val.enabled = false; } } if ((Object)(object)spawnedVoodooPart.Phys.rb != (Object)null) { spawnedVoodooPart.Phys.rb.detectCollisions = false; spawnedVoodooPart.Phys.rb.isKinematic = true; } SetLocalRenderers(spawnedVoodooPart, enabled: false); DisablePhoneGimmick(spawnedVoodooPart.Root); return spawnedVoodooPart; } internal static SpawnedVoodooPart SpawnDollPart(Vector3 position, Vector3 scaleMultiplier, VoodooPartRole role, bool isCore) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) SpawnedVoodooPart spawnedVoodooPart = Spawn(isCore ? DollCoreResourcePath : DollRodResourcePath, position, Quaternion.identity, scaleMultiplier, role); if (spawnedVoodooPart == null) { return null; } spawnedVoodooPart.IsDollCore = isCore; if (isCore) { spawnedVoodooPart.Phys.clientNonKinematic = true; spawnedVoodooPart.ImpactDetector.destroyDisable = false; spawnedVoodooPart.Phys.OverrideMass(0.35f, 1f); } else { spawnedVoodooPart.ImpactDetector.destroyDisable = true; spawnedVoodooPart.Phys.OverrideIndestructible(1f); EncounterValuableNeutralizer.Apply(spawnedVoodooPart.Root); ItemAttributes attributes = spawnedVoodooPart.Attributes; if (attributes != null) { attributes.DisableUI(true); } spawnedVoodooPart.Phys.OverrideGrabDisable(1f); spawnedVoodooPart.Phys.OverrideKinematic(1f); MapIconSuppressor.Attach(spawnedVoodooPart.Root); Collider[] array = spawnedVoodooPart.Colliders ?? Array.Empty(); foreach (Collider val in array) { if ((Object)(object)val != (Object)null) { val.enabled = false; } } if ((Object)(object)spawnedVoodooPart.Phys.rb != (Object)null) { spawnedVoodooPart.Phys.rb.detectCollisions = false; spawnedVoodooPart.Phys.rb.isKinematic = true; } } return spawnedVoodooPart; } private static void DisablePhoneGimmick(GameObject root) { if ((Object)(object)root == (Object)null) { return; } PhoneValuable[] componentsInChildren = root.GetComponentsInChildren(true); foreach (PhoneValuable val in componentsInChildren) { if ((Object)(object)val != (Object)null) { ((Behaviour)val).enabled = false; } } } private static SpawnedVoodooPart Spawn(string resourcePath, Vector3 position, Quaternion rotation, Vector3 scaleMultiplier, VoodooPartRole role) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00a8: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) GameObject val = Resources.Load(resourcePath); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("The Voodoo could not load vanilla resource '" + resourcePath + "'.")); return null; } ((Vector3)(ref scaleMultiplier))..ctor(Mathf.Clamp(scaleMultiplier.x, 0.025f, 2f), Mathf.Clamp(scaleMultiplier.y, 0.025f, 2f), Mathf.Clamp(scaleMultiplier.z, 0.025f, 2f)); Vector3 val2 = Vector3.Scale(val.transform.localScale, scaleMultiplier); object[] array = new object[3] { val2.x, val2.y, val2.z }; GameObject val3; try { val3 = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject(resourcePath, position, rotation, (byte)0, array) : Object.Instantiate(val, position, rotation)); } catch (Exception arg) { Plugin.Log.LogError((object)$"The Voodoo failed to network-spawn '{resourcePath}': {arg}"); return null; } if ((Object)(object)val3 == (Object)null) { return null; } val3.transform.localScale = val2; SpawnedVoodooPart spawnedVoodooPart = new SpawnedVoodooPart { ResourcePath = resourcePath, Root = val3, Phys = val3.GetComponentInChildren(true), ImpactDetector = val3.GetComponentInChildren(true), Attributes = val3.GetComponentInChildren(true), Valuable = val3.GetComponentInChildren(true), View = val3.GetComponentInChildren(true), Renderers = val3.GetComponentsInChildren(true), Colliders = val3.GetComponentsInChildren(true), Role = role }; if ((Object)(object)spawnedVoodooPart.Phys == (Object)null || (Object)(object)spawnedVoodooPart.ImpactDetector == (Object)null) { Plugin.Log.LogError((object)("The Voodoo resource '" + resourcePath + "' lacks vanilla physical components.")); Destroy(spawnedVoodooPart); return null; } SpawnedVoodooPart spawnedVoodooPart2 = spawnedVoodooPart; if (spawnedVoodooPart2.View == null) { spawnedVoodooPart2.View = ((Component)spawnedVoodooPart.Phys).GetComponentInParent(); } RefreshGeometry(spawnedVoodooPart); if (resourcePath == "Valuables/07 Very Tall/Valuable Wizard Broom") { spawnedVoodooPart.LongAxisLocal = Vector3.up; } return spawnedVoodooPart; } internal static void DisableOrdinaryTransformStream(SpawnedVoodooPart part) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (GameManager.Multiplayer() && !((Object)(object)part?.View == (Object)null)) { part.View.Synchronization = (ViewSynchronization)0; part.View.ObservedComponents?.Clear(); } } internal static void RefreshGeometry(SpawnedVoodooPart part, bool refreshLongAxis = true) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_0172: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: 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_008d: 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_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)part?.Phys == (Object)null || part.Renderers == null) { return; } bool flag = false; Bounds val = default(Bounds); Renderer[] renderers = part.Renderers; foreach (Renderer val2 in renderers) { if ((Object)(object)val2 == (Object)null || (!(val2 is MeshRenderer) && !(val2 is SkinnedMeshRenderer))) { continue; } Bounds bounds = val2.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!(((Vector3)(ref size)).sqrMagnitude < 1E-06f) && !(((Bounds)(ref bounds)).size.x > 12f) && !(((Bounds)(ref bounds)).size.y > 12f) && !(((Bounds)(ref bounds)).size.z > 12f)) { if (!flag) { val = bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(bounds); } } } if (flag) { Transform transform = ((Component)part.Phys).transform; part.VisualCenterOffset = Quaternion.Inverse(transform.rotation) * (((Bounds)(ref val)).center - transform.position); part.VisualSize = ((Bounds)(ref val)).size; if (refreshLongAxis) { Vector3 val3 = transform.InverseTransformVector(new Vector3(((Bounds)(ref val)).size.x, 0f, 0f)); Vector3 val4 = transform.InverseTransformVector(new Vector3(0f, ((Bounds)(ref val)).size.y, 0f)); Vector3 val5 = transform.InverseTransformVector(new Vector3(0f, 0f, ((Bounds)(ref val)).size.z)); float magnitude = ((Vector3)(ref val3)).magnitude; float magnitude2 = ((Vector3)(ref val4)).magnitude; float magnitude3 = ((Vector3)(ref val5)).magnitude; part.LongAxisLocal = ((magnitude >= magnitude2 && magnitude >= magnitude3) ? Vector3.right : ((magnitude2 >= magnitude3) ? Vector3.up : Vector3.forward)); } } } internal static void SetLocalRenderers(SpawnedVoodooPart part, bool enabled) { if (part?.Renderers == null) { return; } Renderer[] renderers = part.Renderers; foreach (Renderer val in renderers) { if ((Object)(object)val != (Object)null) { val.enabled = enabled; } } } internal static void Destroy(SpawnedVoodooPart part) { if (!((Object)(object)part?.Root == (Object)null)) { if (GameManager.Multiplayer()) { PhotonNetwork.Destroy(part.Root); } else { Object.Destroy((Object)(object)part.Root); } part.Alive = false; } } } internal sealed class VoodooPhasePart : MonoBehaviour { } }