Decompiled source of Medi Gun v1.0.0
Mods/DellSpencerMediGun.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BoneLib; using BoneLib.BoneMenu; using DellSpencerMediGun; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppPuppetMasta; using Il2CppSLZ.Bonelab; using Il2CppSLZ.MLAgents; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.AI; using Il2CppSLZ.Marrow.Combat; using Il2CppSLZ.Marrow.Data; using Il2CppSLZ.Marrow.Interaction; using Il2CppSLZ.Marrow.Pool; using Il2CppSLZ.Marrow.PuppetMasta; using Il2CppSLZ.Marrow.SceneStreaming; using Il2CppSLZ.Marrow.Warehouse; using Il2CppSystem.Collections.Generic; using LabFusion.Entities; using LabFusion.Marrow.Integration; using LabFusion.Network; using LabFusion.Player; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.AI; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(Main), "Dell Spencer Medi-Gun", "1.0.0", "TheHolyEnd", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: MelonOptionalDependencies(new string[] { "LabFusion" })] [assembly: MelonAdditionalDependencies(new string[] { "BoneLib" })] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("DellSpencerMediGun")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("DellSpencerMediGun")] [assembly: AssemblyTitle("DellSpencerMediGun")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace DellSpencerMediGun { public static class BeamController { public const string AnchorName = "MediGunBeamAnchor"; public const string HealingParam = "Healing"; public const string AnchorGlowName = "TF2_HealingGlow"; public const float AnchorLerp = 25f; public const float MaxLag = 0.05f; public const bool Verbose = false; private static ParticleSystem _ps; private static Transform _anchor; private static Transform _boundRoot; private static Animator _beamAnim; private static ParticleSystem _glow; private static Vector3 _smoothed; private static Transform _frame; private static Vector3 _offset; public static bool IsActive { get; private set; } public static Vector3 Target { get; private set; } public static bool IsBound { get; private set; } public static Transform Anchor => _anchor; public static void ForceAnchorTo(Vector3 world) { //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_0019: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_anchor == (Object)null)) { _smoothed = world; _anchor.position = world; _frame = null; } } public static void Bind(Transform avatarRoot, Transform muzzle, Instance log) { if ((Object)(object)avatarRoot == (Object)null || (Object)(object)muzzle == (Object)null) { Unbind(); } else { if (IsBound && (Object)(object)_boundRoot != (Object)null && ((Object)_boundRoot).GetInstanceID() == ((Object)avatarRoot).GetInstanceID()) { return; } _boundRoot = avatarRoot; _ps = ((Component)muzzle).GetComponentInChildren<ParticleSystem>(true); try { _beamAnim = ((Component)muzzle).GetComponentInChildren<Animator>(true); } catch { _beamAnim = null; } _anchor = FindDeep(avatarRoot, "MediGunBeamAnchor"); _glow = null; if ((Object)(object)_anchor != (Object)null) { try { Transform val = _anchor.Find("TF2_HealingGlow"); if ((Object)(object)val != (Object)null) { _glow = ((Component)val).GetComponent<ParticleSystem>(); } } catch { _glow = null; } } IsBound = (Object)(object)_ps != (Object)null && (Object)(object)_anchor != (Object)null; if ((Object)(object)_ps == (Object)null) { log.Warning("No ParticleSystem under " + ((Object)muzzle).name + " - the beam cannot play. Check the pallet."); } IsActive = false; if ((Object)(object)_ps != (Object)null) { _ps.Stop(); } SetHealing(on: false, log); } } private static void SetHealing(bool on, Instance log) { if ((Object)(object)_beamAnim != (Object)null) { try { _beamAnim.SetBool("Healing", on); } catch { } } if (!((Object)(object)_glow != (Object)null)) { return; } try { if (on) { _glow.Play(); } else { _glow.Stop(); } } catch { } } public static void Unbind() { if (IsActive) { SafeStop(); SetHealing(on: false, null); } _ps = null; _beamAnim = null; _glow = null; _anchor = null; _boundRoot = null; IsActive = false; IsBound = false; } public static void Tick(Instance log) { //IL_0040: 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_0066: Unknown result type (might be due to invalid IL or missing references) if (!IsBound) { return; } if ((Object)(object)_ps == (Object)null || (Object)(object)_anchor == (Object)null) { Unbind(); return; } if (MediGunCore.IsFiring && BeamTarget.HasTarget && DellHandMount.IsEquipped) { Target = BeamTarget.AimPoint; if (!IsActive) { IsActive = true; _smoothed = Target; _anchor.position = _smoothed; _frame = null; _ps.Play(); SetHealing(on: true, log); MediGunSfx.BeamOn(); } } else if (IsActive) { IsActive = false; SafeStop(); SetHealing(on: false, log); MediGunSfx.BeamOff(); } SmoothAnchor(); } private static void SafeStop() { if ((Object)(object)_ps == (Object)null) { return; } try { _ps.Stop(); } catch { } } private static void SmoothAnchor() { //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) //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_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_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_005b: 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_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_00b8: 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_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_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) //IL_00fc: 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_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) //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) if ((Object)(object)_anchor == (Object)null || !IsActive) { return; } Transform val = FollowFrame(); if ((Object)(object)val == (Object)null) { _frame = null; float num = 1f - Mathf.Exp(-25f * Time.deltaTime); _smoothed = Vector3.Lerp(_smoothed, Target, num); _anchor.position = _smoothed; return; } Vector3 val2 = Target - val.position; if (val != _frame) { _frame = val; _offset = val2; } float num2 = 1f - Mathf.Exp(-25f * Time.deltaTime); _offset = Vector3.Lerp(_offset, val2, num2); Vector3 val3 = _offset - val2; float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude > 0.05f) { _offset = val2 + val3 * (0.05f / magnitude); } _smoothed = val.position + _offset; _anchor.position = _smoothed; } private static Transform FollowFrame() { try { if (BeamTarget.IsPlayer) { return ((Object)(object)PlayerFinder.Chest != (Object)null) ? ((Component)PlayerFinder.Chest).transform : null; } if (BeamTarget.IsNpc) { return ((Object)(object)TargetFinder.Current != (Object)null) ? ChestFinder.Of(TargetFinder.Current) : null; } } catch { } return null; } private static Transform FindDeep(Transform parent, string name) { if (((Object)parent).name == name && ((Component)parent).gameObject.activeInHierarchy) { return parent; } for (int i = 0; i < parent.childCount; i++) { Transform val = FindDeep(parent.GetChild(i), name); if ((Object)(object)val != (Object)null) { return val; } } return null; } } public static class BeamRenderer { public const bool Enabled = false; public const float Width = 0.04f; public const bool DimInGrace = true; private static readonly Color RedTeam = new Color(1f, 0.35f, 0.28f); private static readonly Color BluTeam = new Color(0.38f, 0.62f, 1f); private static readonly string[] ShaderCandidates = new string[6] { "Sprites/Default", "Universal Render Pipeline/Unlit", "Unlit/Color", "Particles/Standard Unlit", "Legacy Shaders/Particles/Additive", "Hidden/Internal-Colored" }; private static GameObject _obj; private static LineRenderer _line; private static bool _failed; public static void Tick(Instance log) { //IL_002a: 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_0053: 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_0058: 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) if (0 == 0) { Hide(); } else if (!((Object)(object)_line == (Object)null) || Create(log)) { _line.SetPosition(0, DellHandMount.Muzzle.position); _line.SetPosition(1, BeamTarget.AimPoint); Color val = ((DellHandMount.Team == TeamColor.Red) ? RedTeam : BluTeam); if (BeamTarget.InGrace) { val.a = 0.35f; } _line.startColor = val; _line.endColor = val; if (!_obj.activeSelf) { _obj.SetActive(true); } } } private static bool Create(Instance log) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown if (_failed) { return false; } Shader val = null; string text = null; for (int i = 0; i < ShaderCandidates.Length; i++) { val = Shader.Find(ShaderCandidates[i]); if ((Object)(object)val != (Object)null) { text = ShaderCandidates[i]; break; } } if ((Object)(object)val == (Object)null) { _failed = true; log.Error("BeamRenderer: none of the " + ShaderCandidates.Length + " candidate shaders resolved. No beam will draw."); return false; } log.Msg("BeamRenderer: using shader [" + text + "]"); _obj = new GameObject("DellMediGunBeam"); Object.DontDestroyOnLoad((Object)(object)_obj); _line = _obj.AddComponent<LineRenderer>(); ((Renderer)_line).material = new Material(val); _line.positionCount = 2; _line.useWorldSpace = true; _line.startWidth = 0.04f; _line.endWidth = 0.04f; _line.numCapVertices = 4; ((Renderer)_line).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)_line).receiveShadows = false; ((Renderer)_line).lightProbeUsage = (LightProbeUsage)0; ((Renderer)_line).reflectionProbeUsage = (ReflectionProbeUsage)0; return true; } private static void Hide() { if ((Object)(object)_obj != (Object)null && _obj.activeSelf) { _obj.SetActive(false); } } public static void Cleanup() { if ((Object)(object)_obj != (Object)null) { Object.Destroy((Object)(object)_obj); } _obj = null; _line = null; _failed = false; } } public static class BeamTarget { public enum Kind { None, Npc, Player } public const bool Verbose = false; public static Kind Held { get; private set; } public static bool HasTarget => Held != Kind.None; public static bool IsPlayer => Held == Kind.Player; public static bool IsNpc => Held == Kind.Npc; public static Vector3 AimPoint { get; private set; } public static bool InGrace { get; private set; } public static void Tick(Instance log) { //IL_0051: 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) _ = Held; if (Held == Kind.Npc && !TargetFinder.HasTarget) { Held = Kind.None; } if (Held == Kind.Player && !PlayerFinder.HasTarget) { Held = Kind.None; } if (Held == Kind.None) { Held = Choose(); } switch (Held) { case Kind.Npc: AimPoint = TargetFinder.AimPoint; InGrace = TargetFinder.InGrace; break; case Kind.Player: AimPoint = PlayerFinder.AimPoint; InGrace = PlayerFinder.InGrace; break; default: InGrace = false; break; } } private static Kind Choose() { //IL_0036: 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) bool hasTarget = TargetFinder.HasTarget; bool hasTarget2 = PlayerFinder.HasTarget; if (!hasTarget && !hasTarget2) { return Kind.None; } if (hasTarget && !hasTarget2) { return Kind.Npc; } if (hasTarget2 && !hasTarget) { return Kind.Player; } Transform muzzle = DellHandMount.Muzzle; if ((Object)(object)muzzle == (Object)null) { return Kind.Player; } float num = AngleTo(muzzle, TargetFinder.AimPoint); if (!(AngleTo(muzzle, PlayerFinder.AimPoint) <= num)) { return Kind.Npc; } return Kind.Player; } private static float AngleTo(Transform muzzle, Vector3 point) { //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_0008: 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) return Vector3.Angle(muzzle.forward, point - muzzle.position); } public static void Clear() { Held = Kind.None; InGrace = false; } } public static class Bodyguard { private sealed class Helper { public AIBrain Brain; public BehaviourBaseNav Nav; public int Id; public TriggerRefProxy Threat; public int OrigMode = -1; public int OrigOmni = -1; public bool Fleeing; public float FleeStart; public float LastFull = -999f; public int AggroId; public float StuckSince = -1f; public float NextOrder; public float NextPurge; public float NextOwn; public float FarSince = -1f; } private sealed class Pristine { public AIBrain Brain; public int Mode; public int OmniMode; public float Desired; public float Melee; public float[] Speeds; } public const float HelpRadius = 30f; public const float NoDellMin = 3f; public const float FleeMax = 10f; public const float FleeDistance = 20f; public const float ExcuseSeconds = 10f; public const float OwnRetry = 1f; public const float GiveUpDistance = 10f; public const float GiveUpSeconds = 30f; public const float FledCooldown = 15f; private static readonly List<Helper> _helpers = new List<Helper>(); private static readonly Dictionary<int, float> _excusedUntil = new Dictionary<int, float>(); private static readonly Dictionary<int, float> _fledUntil = new Dictionary<int, float>(); private static Instance _helpLog; private static readonly HashSet<int> _helpSeen = new HashSet<int>(); public const float ThreatRadius = 15f; public const float RememberedRadius = 30f; public const float ScanInterval = 0.3f; public const float SwitchMargin = 1f; public const float EscortRadius = 2.5f; public const float OrderInterval = 0.25f; public const float LeashGrace = 5f; public const float RegroupSeconds = 5f; public const float RegroupRadius = 2f; public const float ThreatBoost = 1000f; public const float StuckMargin = 0.4f; public const float StuckDelay = 0.25f; public const float AfterglowFightCap = 30f; public const float AfterglowFightRange = 30f; public const bool Verbose = false; public const bool Diagnostics = false; private static AIBrain _guard; private static BehaviourBaseNav _nav; private static int _guardId; private static int _origMode = -1; private static float _origDesired = float.NaN; private static float _origDesiredMelee = float.NaN; private static float[] _origSpeeds; private static int _origOmniMode = -1; private static TriggerRefProxy _threat; private static Vector3 _homeBefore; private static bool _homeWasPost; private static bool _leashing; private static float _nextScan; private static float _nextOrder; private static float _nextDiag; private static float _stuckSince = -1f; private static bool _hadGun; private static float _regroupStart = -1f; private static float _lastFullAggro = -999f; private static int _aggroId; private static float _idleInRangeSince = -1f; private static float _lastForcedSwing; private static int _forcedSwings; private static bool _contextOn; private static float _lastLunge; private static bool _lungedOnce; private static float _lastLungePunch; private static int _lungePunches; private static float _lungeAt = -1f; private static Vector3 _threatLastPos; private static float _threatLastTime = -1f; private static Vector3 _threatVel; private static int _hitsLanded; private static float _lastTauntShout = -999f; private static Instance _log; private static readonly HashSet<int> _seen = new HashSet<int>(); public const float GunPostRadius = 3f; public const float GunPostSettle = 1.5f; private static bool _gunWalking; private static readonly Dictionary<int, float> _shooters = new Dictionary<int, float>(); private static readonly Dictionary<int, float[]> _gunSaved = new Dictionary<int, float[]>(); private static readonly Dictionary<int, float[]> _rangedSaved = new Dictionary<int, float[]>(); private static readonly HashSet<string> _rangedLogged = new HashSet<string>(); private static readonly Dictionary<int, Pristine> _pristine = new Dictionary<int, Pristine>(); private static string _noNavLogged; private static bool _wasInCombat; private static bool _wasOwned = true; private static int _ownerFlips; private static string _bestWhy = ""; public const float NaturalEnemyAggression = 0.5f; private static readonly HashSet<string> _kindLogged = new HashSet<string>(); public const float AggroCooldown = 3f; public const float ReAggroInterval = 0.25f; private static bool _intercepting; public const float CrabHopInterval = 0.5f; public const float CrabHopMax = 4f; public const float CrabHopStopShort = 1f; private static readonly Dictionary<int, float> _lastHop = new Dictionary<int, float>(); private static readonly List<TriggerRefProxy> _purge = new List<TriggerRefProxy>(); public const float CloseInDistance = 0.3f; public const float AttackRange = 0.7f; public const float ChaseSlack = 0.2f; public const float SwingReach = 1f; public const float BodyAllowance = 0.6f; public const float InterceptLead = 1f; public const float InterceptBehindMargin = 0.3f; public const float InterceptMinRoom = 1.2f; public const float SpeedMultiplier = 2f; private const int SpAgroed = 0; private const int SpAgroedAng = 1; private const int SpRoam = 2; private const int SpRoamAng = 3; private const int SpEngaged = 4; private const int SpCount = 5; public const float CrabLeapRange = 6f; public const float CrabSecondsPerMetre = 0.14f; public const float CrabMinFlight = 0.3f; public const float CrabMaxFlight = 0.8f; public const float CrabMinInterval = 0.4f; private static bool _detachingOnPurpose; private static float _lastLetGo = -999f; public const float GroundReach = 1.3f; public const float GroundSwingTime = 0.45f; public const float GroundSwingGap = 0.25f; public const float GroundPunchSpeed = 7f; public const float GroundHitRadius = 0.45f; public const int GroundMissLimit = 2; public const float GroundMaxSeconds = 4f; private static int _groundGuardId; private static bool _groundDone; private static int _groundMisses; private static int _groundHand; private static float _groundSwingAt = -1f; private static float _groundNextAt; private static float _groundSince = -1f; private static bool _groundLanded; public const float CrabBiteInterval = 0.5f; public const float CrabBiteNpcFraction = 0.08f; public const float CrabBitePlayerFraction = 0.06f; private static readonly Dictionary<int, float> _nextBite = new Dictionary<int, float>(); public const float RatPounceRange = 3.5f; public const float RatPounceInterval = 1.2f; public const float RatPounceFlight = 0.4f; public const float LungePunchMinGap = 0.4f; public const float LungePunchInterval = 1f; public const float LungePunchSpeed = 3f; public const float LungePunchUp = 0.5f; public const float LungeHitWindow = 0.45f; public const float LungeContactGap = 0.25f; public const float LungeHitFraction = 0.12f; private static int _lungeHits; public const float LungePunchLead = 0.35f; public const float LungeRange = 5f; public const float LungeInterval = 1.5f; public const float LungeSpeed = 6f; public const float LungeUp = 3.5f; private const int MaxAfterglow = 4; private static readonly AIBrain[] _agBrain = (AIBrain[])(object)new AIBrain[4]; private static readonly BehaviourBaseNav[] _agNav = (BehaviourBaseNav[])(object)new BehaviourBaseNav[4]; private static readonly int[] _agId = new int[4]; private static readonly TriggerRefProxy[] _agThreat = (TriggerRefProxy[])(object)new TriggerRefProxy[4]; private static readonly int[] _agOrigMode = new int[4]; private static readonly float[] _agOrigDesired = new float[4]; private static readonly float[] _agOrigDesiredMelee = new float[4]; private static readonly float[][] _agSpeeds = new float[4][]; private static readonly float[] _agRegroup = new float[4]; private static readonly int[] _agOmniMode = new int[4]; private static readonly float[] _agStart = new float[4]; private static readonly float[] _agOverhealEnds = new float[4]; private static readonly float[] _agStuck = new float[4]; private static readonly float[] _agNextOrder = new float[4]; private static readonly float[] _agLastFull = new float[4]; private static readonly int[] _agAggroId = new int[4]; private static int _proxyRigId; private static TriggerRefProxy _proxy; public static bool IsServing => (Object)(object)_guard != (Object)null; public static int GuardId { get { if (!((Object)(object)_guard != (Object)null)) { return 0; } return _guardId; } } public static bool AnyShooter => _shooters.Count > 0; public static TriggerRefProxy GuardTrp { get { if (!((Object)(object)_guard != (Object)null)) { return null; } return SelfOf(_nav); } } private static void CallForHelp(AIBrain guard, BehaviourBaseNav guardNav, TriggerRefProxy threat, Instance log) { //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_0068: 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_023b: Expected I4, but got Unknown //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected I4, but got Unknown //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_0142: 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) if (!HighAlertBridge.Present || (Object)(object)guard == (Object)null || (Object)(object)guardNav == (Object)null || (Object)(object)threat == (Object)null) { return; } try { AIBrain componentInParent = ((Component)threat).GetComponentInParent<AIBrain>(); if ((Object)(object)componentInParent != (Object)null && IsSibling(guard, guardNav, componentInParent)) { return; } Vector3 val = PositionOfBrain(guard); List<KeyValuePair<float, AIBrain>> list = new List<KeyValuePair<float, AIBrain>>(); RigManager rig = LocalRig(); TriggerRefProxy guardSelf = SelfOf(guardNav); _helpSeen.Clear(); Il2CppReferenceArray<Collider> val2 = Physics.OverlapSphere(val, 30f); if (val2 == null) { return; } for (int i = 0; i < ((Il2CppArrayBase<Collider>)(object)val2).Length; i++) { AIBrain val3; try { val3 = (((Object)(object)((Il2CppArrayBase<Collider>)(object)val2)[i] != (Object)null) ? ((Component)((Il2CppArrayBase<Collider>)(object)val2)[i]).GetComponentInParent<AIBrain>() : null); } catch { continue; } if (!((Object)(object)val3 == (Object)null)) { int instanceID = ((Object)val3).GetInstanceID(); if (_helpSeen.Add(instanceID) && instanceID != _guardId && !Reviver.IsDown(val3) && AfterglowSlot(instanceID) < 0 && (!((Object)(object)componentInParent != (Object)null) || instanceID != ((Object)componentInParent).GetInstanceID()) && (!_fledUntil.TryGetValue(instanceID, out var value) || !(Time.time < value)) && IsSibling(guard, guardNav, val3) && !HostileToDell(val3, rig, guardSelf)) { Vector3 val4 = PositionOfBrain(val3) - val; list.Add(new KeyValuePair<float, AIBrain>(((Vector3)(ref val4)).sqrMagnitude, val3)); } } } if (list.Count == 0) { return; } list.Sort((KeyValuePair<float, AIBrain> x, KeyValuePair<float, AIBrain> y) => x.Key.CompareTo(y.Key)); List<string> list2 = new List<string>(); for (int num = 0; num < list.Count; num++) { AIBrain value2 = list[num].Value; Helper helper = HelperOf(((Object)value2).GetInstanceID()); if (helper == null) { helper = new Helper { Brain = value2, Nav = NavOf(value2), Id = ((Object)value2).GetInstanceID() }; if ((Object)(object)helper.Nav == (Object)null) { continue; } try { BehaviourPowerLegs val5 = ((Il2CppObjectBase)helper.Nav).TryCast<BehaviourPowerLegs>(); if ((Object)(object)val5 != (Object)null) { helper.OrigMode = (int)val5.engagedMode; } BehaviourOmniwheel val6 = ((Il2CppObjectBase)helper.Nav).TryCast<BehaviourOmniwheel>(); if ((Object)(object)val6 != (Object)null) { helper.OrigOmni = (int)val6.engagedMode; } } catch { } _helpers.Add(helper); } helper.Threat = threat; helper.Fleeing = false; _excusedUntil.Remove(helper.Id); helper.FarSince = -1f; helper.NextOwn = 0f; ThreatBook.Forget(SelfOf(helper.Nav)); list2.Add(((Object)value2).name); } } catch { } } private static bool IsSibling(AIBrain a, BehaviourBaseNav aNav, AIBrain b) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) try { BehaviourBaseNav nav = NavOf(b); TriggerRefProxy val = SelfOf(aNav); TriggerRefProxy val2 = SelfOf(nav); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || val.npcType != val2.npcType) { return false; } return Family(aNav) == Family(nav); } catch { return false; } } private static int Family(BehaviourBaseNav nav) { if ((Object)(object)nav == (Object)null) { return -1; } if ((Object)(object)((Il2CppObjectBase)nav).TryCast<BehaviourPowerLegs>() != (Object)null) { return 1; } if ((Object)(object)((Il2CppObjectBase)nav).TryCast<BehaviourCrablet>() != (Object)null) { return 2; } if ((Object)(object)((Il2CppObjectBase)nav).TryCast<BehaviourOmniwheel>() != (Object)null) { return 3; } return 0; } private static void HelpersTick(RigManager rig, TriggerRefProxy dell, Instance log) { //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_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_01c1: Unknown result type (might be due to invalid IL or missing references) _helpLog = log; float time = Time.time; Vector3 val = DellPosition(dell, rig); for (int num = _helpers.Count - 1; num >= 0; num--) { Helper helper = _helpers[num]; if ((Object)(object)helper.Brain == (Object)null || (Object)(object)helper.Nav == (Object)null || Reviver.IsDown(helper.Brain) || helper.Id == _guardId) { if ((Object)(object)helper.Brain != (Object)null && helper.Id != _guardId) { RestoreHelper(helper); } _helpers.RemoveAt(num); } else { SubBehaviourSensors val2 = SensorsOf(helper.Nav); if (val2 == null) { _helpers.RemoveAt(num); } else if (!helper.Fleeing) { bool flag = (Object)(object)helper.Threat == (Object)null || ThreatBook.IsGonePublic(helper.Threat) || !StillWanted(helper.Threat); if (!flag && CantReach(helper, time)) { RestoreHelper(helper); _helpers.RemoveAt(num); } else if (flag) { helper.Fleeing = true; helper.FleeStart = time; _excusedUntil[helper.Id] = time + 10f; ThreatBook.Forget(SelfOf(helper.Nav)); RestoreHelper(helper); PurgeTargets(val2, null); try { val2.target = null; } catch { } } else { Help(helper, val2, rig, dell, time); } } else { float num2 = time - helper.FleeStart; float num3 = Vector3.Distance(PositionOfBrain(helper.Brain), val); if (num2 >= 10f || (num3 >= 20f && num2 >= 3f)) { _helpers.RemoveAt(num); } else { BackOff(helper, val2, rig, dell, val, time); } } } } if (_excusedUntil.Count <= 32) { return; } List<int> list = new List<int>(); foreach (KeyValuePair<int, float> item in _excusedUntil) { if (time >= item.Value) { list.Add(item.Key); } } for (int i = 0; i < list.Count; i++) { _excusedUntil.Remove(list[i]); } } private static bool StillWanted(TriggerRefProxy t) { if ((Object)(object)_guard != (Object)null && (Object)(object)_threat == (Object)(object)t) { return true; } for (int i = 0; i < 4; i++) { if (_agId[i] != 0 && (Object)(object)_agThreat[i] == (Object)(object)t) { return true; } } return false; } private static void Help(Helper h, SubBehaviourSensors s, RigManager rig, TriggerRefProxy dell, float now) { //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_00b7: Unknown result type (might be due to invalid IL or missing references) if (now >= h.NextOwn && !DellOwns(h.Brain)) { h.NextOwn = now + 1f; RequestOwnership(h.Brain); } KeepSlotClean(s, rig, dell, h.Threat); if (now >= h.NextPurge) { h.NextPurge = now + 0.3f; PurgeTargets(s, h.Threat); } SetChaseMode(h.Nav, chase: true, h.OrigMode, null); SetOmniMode(h.Nav, chase: true, h.OrigOmni); KeepOnTarget(h.Nav, s, h.Threat, ref h.LastFull, ref h.AggroId); Vector3 val = PositionOfBrain(h.Brain); Unstick(h.Nav, val, h.Threat, ref h.StuckSince, ref h.NextOrder, ref h.LastFull); } private static bool CantReach(Helper h, float now) { //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) float num; try { num = Vector3.Distance(PositionOfBrain(h.Brain), ThreatBook.PositionOf(h.Threat)); } catch { return false; } if (num < 10f) { h.FarSince = -1f; return false; } if (h.FarSince < 0f) { h.FarSince = now; } return now - h.FarSince >= 30f; } private static void BackOff(Helper h, SubBehaviourSensors s, RigManager rig, TriggerRefProxy dell, Vector3 dellPos, float now) { //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_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_00ad: 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_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_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) try { s.RemoveTarget(dell); if ((Object)(object)s.target != (Object)null) { s.RemoveTarget(s.target); s.target = null; } } catch { } if (!(now < h.NextOrder)) { h.NextOrder = now + 0.5f; if (now >= h.NextPurge) { h.NextPurge = now + 0.3f; PurgeTargets(s, null); } StandDown(h.Nav); Vector3 val = PositionOfBrain(h.Brain); Vector3 val2 = val - dellPos; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = Vector3.forward; } WalkTo(h.Nav, val + ((Vector3)(ref val2)).normalized * 15f); } } private static void RestoreHelper(Helper h) { try { SetChaseMode(h.Nav, chase: false, h.OrigMode, null); SetOmniMode(h.Nav, chase: false, h.OrigOmni); } catch { } } private static Helper HelperOf(int id) { for (int i = 0; i < _helpers.Count; i++) { if (_helpers[i].Id == id) { return _helpers[i]; } } return null; } public static void HelperFled(BehaviourBaseNav nav) { if ((Object)(object)nav == (Object)null) { return; } try { int instanceID = ((Object)nav).GetInstanceID(); for (int num = _helpers.Count - 1; num >= 0; num--) { Helper helper = _helpers[num]; if (!helper.Fleeing && !((Object)(object)helper.Nav == (Object)null) && ((Object)helper.Nav).GetInstanceID() == instanceID) { RestoreHelper(helper); _helpers.RemoveAt(num); _fledUntil[helper.Id] = Time.time + 15f; } } } catch { } } public static bool IsHelper(BehaviourBaseNav nav) { if ((Object)(object)nav == (Object)null) { return false; } try { int instanceID = ((Object)nav).GetInstanceID(); for (int i = 0; i < _helpers.Count; i++) { if (!_helpers[i].Fleeing && (Object)(object)_helpers[i].Nav != (Object)null && ((Object)_helpers[i].Nav).GetInstanceID() == instanceID) { return true; } } } catch { } return false; } private static bool IsHelperOrExcused(int brainId) { if (HelperOf(brainId) != null) { return true; } if (_excusedUntil.TryGetValue(brainId, out var value)) { return Time.time < value; } return false; } private static bool HostileToDell(AIBrain b, RigManager rig, TriggerRefProxy guardSelf) { try { BehaviourBaseNav val = NavOf(b); SubBehaviourSensors val2 = (((Object)(object)val == (Object)null) ? null : SensorsOf(val)); if (val2 == null || !IsFighting(val)) { return false; } TriggerRefProxy val3 = TargetOf(val2); return (Object)(object)val3 != (Object)null && (IsDell(val3, rig) || ((Object)(object)guardSelf != (Object)null && (Object)(object)val3 == (Object)(object)guardSelf)) && IsNaturalEnemy(b, val); } catch { return false; } } private static void Betrayed(int brainId) { DropHelper(brainId); _excusedUntil.Remove(brainId); } public static void Betrayed(TriggerRefProxy t) { try { AIBrain val = (((Object)(object)t != (Object)null) ? ((Component)t).GetComponentInParent<AIBrain>() : null); if ((Object)(object)val != (Object)null) { Betrayed(((Object)val).GetInstanceID()); } } catch { } } public static bool IsAlly(AIBrain b) { try { return (Object)(object)b != (Object)null && IsHelperOrExcused(((Object)b).GetInstanceID()); } catch { return false; } } public static bool IsAlly(TriggerRefProxy t) { return IsHelperOrExcused(t); } private static bool IsHelperOrExcused(TriggerRefProxy t) { try { AIBrain val = (((Object)(object)t != (Object)null) ? ((Component)t).GetComponentInParent<AIBrain>() : null); return (Object)(object)val != (Object)null && IsHelperOrExcused(((Object)val).GetInstanceID()); } catch { return false; } } private static void DropHelper(int id) { for (int num = _helpers.Count - 1; num >= 0; num--) { if (_helpers[num].Id == id) { RestoreHelper(_helpers[num]); _helpers.RemoveAt(num); } } } private static void HelpersReset() { for (int i = 0; i < _helpers.Count; i++) { if ((Object)(object)_helpers[i].Brain != (Object)null) { RestoreHelper(_helpers[i]); } } _helpers.Clear(); _excusedUntil.Clear(); _fledUntil.Clear(); } private static void RequestOwnership(AIBrain b) { if (!FusionDetect.IsPresent || (Object)(object)b == (Object)null) { return; } try { RequestViaFusion(b); } catch { } } [MethodImpl(MethodImplOptions.NoInlining)] private static void RequestViaFusion(AIBrain b) { NpcOwnership.RequestFor(b); } public static bool IsShooter(int navId) { if (_shooters.TryGetValue(navId, out var value)) { return Time.time < value; } return false; } private static void MarkShooter(BehaviourBaseNav nav, TriggerRefProxy t) { int num = SafeId(nav); if (num != 0) { _shooters[num] = Time.time + 0.3f; HighAlertBridge.DriveGun(nav, t); } } private static void UnmarkShooter(BehaviourBaseNav nav) { int num = SafeId(nav); if (num != 0 && _shooters.Remove(num)) { HighAlertBridge.StopGun(nav); } } private static void SilentTarget(SubBehaviourSensors s, TriggerRefProxy t) { try { if (s != null && (Object)(object)t != (Object)null && (Object)(object)s.target != (Object)(object)t) { s.AddThreat(t, 1000f); s.target = t; } } catch { } } private static void GunStance(BehaviourBaseNav nav, bool on) { int num = SafeId(nav); if (num == 0) { return; } try { BehaviourPowerLegs val = ((Il2CppObjectBase)nav).TryCast<BehaviourPowerLegs>(); if ((Object)(object)val == (Object)null) { return; } float[] value; bool flag = _gunSaved.TryGetValue(num, out value); if (on) { if (!flag) { _gunSaved[num] = new float[3] { val.breakEngagedTargetDistance, val.breakEngagedHomeDistance, val.meleeRange }; } if (val.breakEngagedTargetDistance != 999f) { val.breakEngagedTargetDistance = 999f; } if (val.breakEngagedHomeDistance != 999f) { val.breakEngagedHomeDistance = 999f; } if (val.meleeRange != 0f) { val.meleeRange = 0f; } } else if (flag) { val.breakEngagedTargetDistance = value[0]; val.breakEngagedHomeDistance = value[1]; val.meleeRange = value[2]; _gunSaved.Remove(num); } } catch { } } private static void GunHold(BehaviourBaseNav nav, SubBehaviourSensors s, TriggerRefProxy t, ref float lastFull, ref int aggroId) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 GunStance(nav, on: true); SetEngagedMode(nav, (EngagedMode)2); StopContext(nav); KeepOnTarget(nav, s, t, ref lastFull, ref aggroId); MarkShooter(nav, t); try { if ((int)nav.mentalState == 3) { nav.SwitchMentalState((MentalState)4); nav.ClearPath(); } } catch { } } private static void GunOff(BehaviourBaseNav nav) { UnmarkShooter(nav); GunStance(nav, on: false); RangedOff(nav); } private static bool IsRangedShooter(BehaviourBaseNav nav) { try { BehaviourOmniwheel val = (((Object)(object)nav != (Object)null) ? ((Il2CppObjectBase)nav).TryCast<BehaviourOmniwheel>() : null); if ((Object)(object)val == (Object)null || IsNullRat(nav)) { return false; } return (Object)(object)val.gun != (Object)null; } catch { return false; } } private static void RangedPost(SubBehaviourSensors sensors, Vector3 dellPos, float now, Instance log) { //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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Invalid comparison between Unknown and I4 //IL_00ce: 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) BehaviourOmniwheel val = ((Il2CppObjectBase)_nav).TryCast<BehaviourOmniwheel>(); if ((Object)(object)val == (Object)null) { return; } int num = SafeId(_nav); if (num != 0 && !_rangedSaved.ContainsKey(num)) { try { _rangedSaved[num] = new float[2] { _nav.desiredGunDistance, val.followDistance }; } catch { } } float num2 = Vector3.Distance(PositionOfBrain(_guard), dellPos); if (!_gunWalking && num2 > 3f) { _gunWalking = true; } else if (_gunWalking && num2 <= 1.5f) { _gunWalking = false; } if (_gunWalking) { StandDown(_nav); SilentTarget(sensors, _threat); if (now >= _nextOrder) { _nextOrder = now + 0.25f; WalkTo(_nav, dellPos); } return; } try { if ((int)val.engagedMode != 1) { val.engagedMode = (EngagedMode)1; } float num3 = Vector3.Distance(PositionOfBrain(_guard), ThreatBook.PositionOf(_threat)); if (Mathf.Abs(_nav.desiredGunDistance - num3) > 0.05f) { _nav.desiredGunDistance = num3; } if (Mathf.Abs(val.followDistance - num3) > 0.05f) { val.followDistance = num3; } } catch { } KeepOnTarget(_nav, sensors, _threat, ref _lastFullAggro, ref _aggroId); if (!(now >= _nextOrder)) { return; } _nextOrder = now + 0.1f; try { _nav.ClearPath(); } catch { } } private static void RangedOff(BehaviourBaseNav nav) { int num = SafeId(nav); if (num == 0 || !_rangedSaved.TryGetValue(num, out float[] value)) { return; } _rangedSaved.Remove(num); try { nav.desiredGunDistance = value[0]; BehaviourOmniwheel val = ((Il2CppObjectBase)nav).TryCast<BehaviourOmniwheel>(); if ((Object)(object)val != (Object)null) { val.followDistance = value[1]; } } catch { } } private static void SetEngagedMode(BehaviourBaseNav nav, EngagedMode want) { //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_001c: 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_002d: Unknown result type (might be due to invalid IL or missing references) try { BehaviourPowerLegs val = ((Il2CppObjectBase)nav).TryCast<BehaviourPowerLegs>(); if (!((Object)(object)val == (Object)null) && val.engagedMode != want) { val.SwitchEngagedState(want, true); if (val.engagedMode != want) { val.engagedMode = want; } } } catch { } } private static int SafeId(BehaviourBaseNav nav) { try { return ((Object)(object)nav != (Object)null) ? ((Object)nav).GetInstanceID() : 0; } catch { return 0; } } public static void GuardLanded(AIBrain victim) { try { if ((Object)(object)_guard == (Object)null || (Object)(object)_threat == (Object)null || (Object)(object)victim == (Object)null) { return; } BehaviourBaseNav behaviour = victim.behaviour; SubBehaviourSensors val = (((Object)(object)behaviour != (Object)null) ? behaviour.sensors : null); TriggerRefProxy val2 = SelfOf(_nav); if (val == null || (Object)(object)val2 == (Object)null || (Object)(object)val.selfTrp != (Object)(object)_threat) { return; } _hitsLanded++; try { val.AddThreat(val2, 1000f); } catch { } try { val.target = val2; } catch { } if (!(Time.time - _lastTauntShout >= 3f)) { return; } _lastTauntShout = Time.time; try { val.SetAgro(val2); } catch { } try { behaviour.SetAgro(val2); } catch { } } catch { } } public static void Tick(Instance log) { //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_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) _log = log; if (!DellHandMount.IsEquipped) { return; } AIBrain val = HealedNpc(); if ((Object)(object)_guard != (Object)null && ((Object)(object)val == (Object)null || ((Object)val).GetInstanceID() != _guardId)) { Release(log, ((Object)(object)val == (Object)null) ? "beam stopped" : "beam moved"); } RigManager val2 = LocalRig(); TriggerRefProxy val3 = DellProxy(val2); if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null) { return; } HighAlertBridge.EnsureInit(log); AfterglowTick(val2, val3, log); HelpersTick(val2, val3, log); if ((Object)(object)_guard != (Object)null) { Vector3 val4 = DellPosition(val3, val2); HighAlertBridge.WeaponTick(_guard, _nav, (Object)(object)_threat != (Object)null, val4, Vector3.Distance(PositionOfBrain(_guard), val4), log); } HighAlertBridge.IgnoresTick(); if ((Object)(object)val == (Object)null) { return; } if ((Object)(object)_guard == (Object)null) { Convert(val, log); } if (!((Object)(object)_nav == (Object)null)) { SubBehaviourSensors val5 = SensorsOf(_nav); if (val5 != null) { Serve(val5, val2, val3, log); } } } private static void Convert(AIBrain brain, Instance log) { //IL_0217: 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_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_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_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected I4, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected I4, but got Unknown BehaviourBaseNav val = NavOf(brain); if ((Object)(object)val == (Object)null) { return; } DropHelper(((Object)brain).GetInstanceID()); _guard = brain; _nav = val; _guardId = ((Object)brain).GetInstanceID(); _threat = null; _leashing = false; _nextScan = (_nextOrder = (_nextDiag = 0f)); _stuckSince = -1f; _idleInRangeSince = -1f; _lastForcedSwing = 0f; _forcedSwings = 0; _wasOwned = true; _ownerFlips = 0; _lungePunches = 0; _lungeAt = -1f; _lungeHits = 0; _gunWalking = false; _hitsLanded = 0; _threatLastTime = -1f; _threatVel = Vector3.zero; _contextOn = false; _lastLunge = 0f; _lungedOnce = false; _hadGun = false; int num = AfterglowSlot(_guardId); _lastFullAggro = -999f; _aggroId = 0; if (num >= 0) { _threat = _agThreat[num]; _lastFullAggro = _agLastFull[num]; _aggroId = _agAggroId[num]; _origMode = _agOrigMode[num]; _origDesired = _agOrigDesired[num]; _origDesiredMelee = _agOrigDesiredMelee[num]; _origSpeeds = _agSpeeds[num]; if (_agRegroup[num] >= 0f) { _leashing = true; _regroupStart = _agRegroup[num]; } DropAfterglow(num); } else { _origSpeeds = ReadSpeeds(val); _origMode = -1; _origDesired = float.NaN; _origDesiredMelee = float.NaN; try { BehaviourPowerLegs val2 = ((Il2CppObjectBase)val).TryCast<BehaviourPowerLegs>(); if ((Object)(object)val2 != (Object)null) { _origMode = (int)val2.engagedMode; _origDesired = val2.desiredDistance; _origDesiredMelee = val2.desiredMeleeDistance; } } catch { } } _origOmniMode = -1; try { BehaviourOmniwheel val3 = ((Il2CppObjectBase)val).TryCast<BehaviourOmniwheel>(); if ((Object)(object)val3 != (Object)null) { _origOmniMode = (int)val3.engagedMode; } } catch { } ApplyPristine(brain, log); try { _homeBefore = val.homePosition; _homeWasPost = val.homeIsPost; } catch { _homeBefore = PositionOfBrain(brain); _homeWasPost = false; } NavCheck(brain, log); LetGoOfDell(val, LocalRig(), log); PurgeTargets(SensorsOf(val), _threat); try { SubBehaviourSensors val4 = SensorsOf(val); if (val4 != null && (Object)(object)val4.target != (Object)null && (Object)(object)val4.target != (Object)(object)_threat) { val4.target = null; } } catch { } } private static void ApplyPristine(AIBrain brain, Instance log) { int instanceID = ((Object)brain).GetInstanceID(); if (_pristine.TryGetValue(instanceID, out Pristine value) && (Object)(object)value.Brain != (Object)null) { if (value.Mode != _origMode || value.OmniMode != _origOmniMode || !SameF(value.Desired, _origDesired) || !SameF(value.Melee, _origDesiredMelee)) { _ = 1; } else _ = !SameSpeeds(value.Speeds, _origSpeeds); _origMode = value.Mode; _origOmniMode = value.OmniMode; _origDesired = value.Desired; _origDesiredMelee = value.Melee; _origSpeeds = (float[])value.Speeds.Clone(); return; } if (_pristine.Count > 128) { List<int> list = new List<int>(); foreach (KeyValuePair<int, Pristine> item in _pristine) { if ((Object)(object)item.Value.Brain == (Object)null) { list.Add(item.Key); } } for (int i = 0; i < list.Count; i++) { _pristine.Remove(list[i]); } } _pristine[instanceID] = new Pristine { Brain = brain, Mode = _origMode, OmniMode = _origOmniMode, Desired = _origDesired, Melee = _origDesiredMelee, Speeds = ((_origSpeeds != null) ? ((float[])_origSpeeds.Clone()) : ReadSpeeds(_nav)) }; } private static bool SameF(float a, float b) { if (float.IsNaN(a) && float.IsNaN(b)) { return true; } return Mathf.Abs(a - b) < 0.001f; } private static bool SameSpeeds(float[] a, float[] b) { if (a == null || b == null) { return a == b; } for (int i = 0; i < a.Length && i < b.Length; i++) { if (!SameF(a[i], b[i])) { return false; } } return true; } public static bool IsLoyal(BehaviourBaseNav nav) { if ((Object)(object)nav == (Object)null) { return false; } try { int instanceID = ((Object)nav).GetInstanceID(); if ((Object)(object)_nav != (Object)null && ((Object)_nav).GetInstanceID() == instanceID) { return true; } for (int i = 0; i < 4; i++) { if (_agId[i] != 0 && (Object)(object)_agNav[i] != (Object)null && (Object)(object)_agThreat[i] != (Object)null && ((Object)_agNav[i]).GetInstanceID() == instanceID) { return true; } } } catch { } return false; } public static bool IsLoyalSfx(SubBehaviourSfx sfx) { if (sfx == null || ((Object)(object)_nav == (Object)null && !AnyAfterglow())) { return false; } try { IntPtr pointer = ((Il2CppObjectBase)sfx).Pointer; if ((Object)(object)_nav != (Object)null && _nav.sfx != null && ((Il2CppObjectBase)_nav.sfx).Pointer == pointer) { return true; } for (int i = 0; i < 4; i++) { if (_agId[i] != 0 && (Object)(object)_agNav[i] != (Object)null && (Object)(object)_agThreat[i] != (Object)null && _agNav[i].sfx != null && ((Il2CppObjectBase)_agNav[i].sfx).Pointer == pointer) { return true; } } } catch { } return false; } private static bool AnyAfterglow() { for (int i = 0; i < 4; i++) { if (_agId[i] != 0) { return true; } } return false; } public static bool DellOwns(AIBrain brain) { if ((Object)(object)brain == (Object)null) { return false; } if (!FusionDetect.IsPresent) { return true; } try { return OwnsViaFusion(brain); } catch { return true; } } [MethodImpl(MethodImplOptions.NoInlining)] private static void GuardLockFusion(AIBrain guard, bool owned) { FusionGuardLock.EnsureHooked(_log); FusionGuardLock.GuardEntityId = (((Object)(object)guard != (Object)null) ? NpcOwnership.EntityIdOf(guard) : 0); if ((Object)(object)guard != (Object)null && !owned) { NpcOwnership.RetakeQuiet(guard); } } [MethodImpl(MethodImplOptions.NoInlining)] private static void GuardUnlockFusion() { FusionGuardLock.GuardEntityId = 0; } [MethodImpl(MethodImplOptions.NoInlining)] private static bool OwnsViaFusion(AIBrain brain) { return NpcOwnership.Owns(brain); } private static void Serve(SubBehaviourSensors sensors, RigManager rig, TriggerRefProxy dell, Instance log) { //IL_0008: 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_00a6: 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_021f: 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_01d8: 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_0441: 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_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_0199: 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_03bb: 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_0326: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; Vector3 val = DellPosition(dell, rig); SetSpeed(_nav, on: true, _origSpeeds); GuardBody.Tick(_guard, log); bool flag = DellOwns(_guard); if (FusionDetect.IsPresent) { try { GuardLockFusion(_guard, flag); } catch { } } if (flag != _wasOwned) { _wasOwned = flag; _ownerFlips++; } KeepSlotClean(sensors, rig, dell, _threat); LetGoOfDell(_nav, rig, log); CrabBite(_nav, rig); GroundFight(time, log); if (time >= _nextScan) { _nextScan = time + 0.3f; ChooseThreat(rig, dell, val, log); PurgeTargets(sensors, _threat); } if (!_leashing && TargetFinder.InRangeGrace) { _leashing = true; _regroupStart = time; } if (_leashing) { float num = Vector3.Distance(PositionOfBrain(_guard), val); if (time - _regroupStart >= 5f && num <= 2f) { _leashing = false; } } if (_leashing) { StopForcedAttack(_nav); StandDown(_nav); GunStance(_nav, on: false); if ((Object)(object)_threat != (Object)null && !ThreatBook.IsGonePublic(_threat) && HighAlertBridge.HoldsGun(_nav)) { SilentTarget(sensors, _threat); MarkShooter(_nav, _threat); } else { ClearSlot(sensors); UnmarkShooter(_nav); } if (time >= _nextOrder) { _nextOrder = time + 0.1f; WalkTo(_nav, val); } } else if ((Object)(object)_threat != (Object)null && IsRangedShooter(_nav)) { HighAlertBridge.LookAt(_nav, null, PositionOfBrain(_guard)); RangedPost(sensors, val, time, log); } else if ((Object)(object)_threat != (Object)null) { RangedOff(_nav); SetOmniMode(_nav, chase: true, _origOmniMode); HighAlertBridge.LookAt(_nav, null, PositionOfBrain(_guard)); bool flag2 = HighAlertBridge.HoldsGun(_nav); if (flag2 != _hadGun) { _hadGun = flag2; _gunWalking = false; if (!flag2) { GunOff(_nav); _aggroId = 0; _stuckSince = -1f; _lungeAt = -1f; } } if (flag2) { StopForcedAttack(_nav); _lungeAt = -1f; float num2 = Vector3.Distance(PositionOfBrain(_guard), val); _ = _gunWalking; if (!_gunWalking && num2 > 3f) { _gunWalking = true; } else if (_gunWalking && num2 <= 1.5f) { _gunWalking = false; } if (_gunWalking) { GunStance(_nav, on: false); StandDown(_nav); SilentTarget(sensors, _threat); MarkShooter(_nav, _threat); if (time >= _nextOrder) { _nextOrder = time + 0.25f; WalkTo(_nav, val); } } else { GunHold(_nav, sensors, _threat, ref _lastFullAggro, ref _aggroId); } } else { GunOff(_nav); _gunWalking = false; SetChaseMode(_nav, chase: true, _origMode, log); SetCloseIn(_nav, on: true, _origDesired, _origDesiredMelee); KeepOnTarget(_nav, sensors, _threat, ref _lastFullAggro, ref _aggroId); Unstick(_nav, PositionOfBrain(_guard), _threat, ref _stuckSince, ref _nextOrder, ref _lastFullAggro, val); PushAttack(log); } } else { GunOff(_nav); SetChaseMode(_nav, chase: false, _origMode, log); SetOmniMode(_nav, chase: false, _origOmniMode); SetCloseIn(_nav, on: false, _origDesired, _origDesiredMelee); StopForcedAttack(_nav); StandDown(_nav); if (time >= _nextOrder) { _nextOrder = time + 0.25f; Escort(val); } HighAlertBridge.LookAt(_nav, val + Vector3.up * 0.4f, PositionOfBrain(_guard)); } } private static void ChooseThreat(RigManager rig, TriggerRefProxy dell, Vector3 dellPos, Instance log) { //IL_0002: 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_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) float bestD; TriggerRefProxy val = FindThreat(rig, dell, dellPos, out bestD); if ((Object)(object)_threat != (Object)null && !StillThreat(_threat, dellPos)) { Forget(SensorsOf(_nav), _threat); _threat = null; } if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)_threat) { if ((Object)(object)_threat == (Object)null) { _ = (Object)(object)val == (Object)null; } _wasInCombat = (Object)(object)_threat != (Object)null; return; } if ((Object)(object)_threat != (Object)null) { float num = Vector3.Distance(ThreatBook.PositionOf(_threat), dellPos); if (bestD + 1f >= num) { return; } Forget(SensorsOf(_nav), _threat); } _threat = val; _wasInCombat = true; CallForHelp(_guard, _nav, val, log); _stuckSince = -1f; _idleInRangeSince = -1f; } private static void NavCheck(AIBrain brain, Instance log) { //IL_0001: 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) try { NavMeshHit val = default(NavMeshHit); bool flag = NavMesh.SamplePosition(PositionOfBrain(brain), ref val, 3f, -1); Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; if (!flag && _noNavLogged != name) { _noNavLogged = name; log.Warning("[guard] NO NAVMESH where " + ((Object)brain).name + " stands (map: " + name + ") - NPCs can't walk on this map, so the guard can't follow, regroup or chase here. It can still fight what comes into reach. Not something the mod can add to a map."); } } catch { } } private static TriggerRefProxy FindThreat(RigManager rig, TriggerRefProxy dell, Vector3 dellPos, out float bestD) { //IL_001f: 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_023f: 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_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_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) TriggerRefProxy val = null; float num = float.MaxValue; TriggerRefProxy val2 = SelfOf(_nav); _seen.Clear(); Il2CppReferenceArray<Collider> val3 = null; try { val3 = Physics.OverlapSphere(dellPos, 15f); } catch { } Vector3 val9; if (val3 != null) { for (int i = 0; i < ((Il2CppArrayBase<Collider>)(object)val3).Length; i++) { AIBrain val4; try { val4 = (((Object)(object)((Il2CppArrayBase<Collider>)(object)val3)[i] != (Object)null) ? ((Component)((Il2CppArrayBase<Collider>)(object)val3)[i]).GetComponentInParent<AIBrain>() : null); } catch { continue; } if ((Object)(object)val4 == (Object)null) { continue; } int instanceID = ((Object)val4).GetInstanceID(); if (instanceID == _guardId || !_seen.Add(instanceID) || AfterglowSlot(instanceID) >= 0 || Reviver.IsDown(val4)) { continue; } BehaviourBaseNav val5 = NavOf(val4); SubBehaviourSensors val6 = (((Object)(object)val5 == (Object)null) ? null : SensorsOf(val5)); if (val6 == null || !IsFighting(val5)) { continue; } TriggerRefProxy val7 = TargetOf(val6); bool flag = (Object)(object)val7 != (Object)null && (IsDell(val7, rig) || ((Object)(object)val2 != (Object)null && (Object)(object)val7 == (Object)(object)val2)); bool flag2 = IsNaturalEnemy(val4, val5); if (IsHelperOrExcused(instanceID)) { if (!flag || !flag2) { continue; } Betrayed(instanceID); } if (!flag2 || !IsHostile(val7, rig, val2)) { continue; } TriggerRefProxy val8 = SelfOf(val5); if (!((Object)(object)val8 == (Object)null)) { val9 = ThreatBook.PositionOf(val8) - dellPos; float sqrMagnitude = ((Vector3)(ref val9)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val = val8; TriggerRefProxy val10 = TargetOf(val6); _bestWhy = (IsDell(val10, rig) ? "fighting Dell" : (((Object)(object)val2 != (Object)null && (Object)(object)val10 == (Object)(object)val2) ? "fighting the guard" : "fighting a player")); } } } } List<TriggerRefProxy> list = ThreatBook.Live(); float num2 = 900f; for (int j = 0; j < list.Count; j++) { TriggerRefProxy val11 = list[j]; if (!((Object)(object)val11 == (Object)null) && !((Object)(object)val11 == (Object)(object)val2) && !((Object)(object)val11 == (Object)(object)dell) && !IsDell(val11, rig) && !IsAfterglowNpc(val11) && !IsHelperOrExcused(val11)) { val9 = ThreatBook.PositionOf(val11) - dellPos; float sqrMagnitude2 = ((Vector3)(ref val9)).sqrMagnitude; if (sqrMagnitude2 <= num2 && sqrMagnitude2 < num) { num = sqrMagnitude2; val = val11; _bestWhy = "remembered attacker"; } } } bestD = (((Object)(object)val != (Object)null) ? Mathf.Sqrt(num) : float.MaxValue); return val; } private static bool CanHarm(AIBrain b, BehaviourBaseNav nav) { try { if (MeleeBoost.CanMelee(b)) { return true; } if ((Object)(object)nav != (Object)null && nav.enableThrowAttack) { return true; } if (HighAlertBridge.HoldsGun(nav)) { return true; } if ((Object)(object)nav != (Object)null && ((Object)(object)((Il2CppObjectBase)nav).TryCast<BehaviourBaseTurret>() != (Object)null || (Object)(object)((Il2CppObjectBase)nav).TryCast<BehaviourStationaryTurret>() != (Object)null)) { return true; } } catch { } return false; } private static bool IsNaturalEnemy(AIBrain b, BehaviourBaseNav nav) { float num = 0f; try { SubBehaviourHealth val = (((Object)(object)nav != (Object)null) ? nav.health : null); if (val != null) { num = val.aggression; } } catch { } if (CanHarm(b, nav)) { return num >= 0.5f; } return false; } private static string KindName(BehaviourBaseNav nav) { //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) try { TriggerRefProxy val = SelfOf(nav); return ((Object)(object)val != (Object)null) ? ((object)val.npcType/*cast due to .constrained prefix*/).ToString() : "?"; } catch { return "?"; } } private static bool IsHostile(TriggerRefProxy target, RigManager rig, TriggerRefProxy guardSelf) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 if ((Object)(object)target == (Object)null) { return false; } if (IsDell(target, rig) || ((Object)(object)guardSelf != (Object)null && (Object)(object)target == (Object)(object)guardSelf)) { return true; } if (ThreatBook.Contains(target)) { return false; } try { return (int)target.triggerType == 0; } catch { return false; } } private static bool StillThreat(TriggerRefProxy t, Vector3 dellPos) { //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) if ((Object)(object)t == (Object)null || ThreatBook.IsGonePublic(t)) { return false; } Vector3 val = ThreatBook.PositionOf(t) - dellPos; return ((Vector3)(ref val)).sqrMagnitude <= 900f; } private static void KeepOnTarget(BehaviourBaseNav nav, SubBehaviourSensors s, TriggerRefProxy t, ref float lastFull, ref int lastId) { int num = 0; try { num = ((Object)t).GetInstanceID(); } catch { } bool flag = num != lastId; bool flag2 = !IsFighting(nav) && Time.time - lastFull >= 0.25f; if (flag2 && !flag && (Object)(object)((Il2CppObjectBase)nav).TryCast<BehaviourPowerLegs>() != (Object)null && !OnItsFeet(nav)) { flag2 = false; } if (flag || flag2) { lastId = num; lastFull = Time.time; try { s.AddThreat(t, 1000f); } catch { } try { s.SetAgro(t); } catch { } try { s.target = t; } catch { } try { nav.SetAgro(t); return; } catch { return; } } try { if ((Object)(object)s.target != (Object)(object)t) { s.AddThreat(t, 1000f); s.target = t; } } catch { } } private static void Unstick(BehaviourBaseNav nav, Vector3 from, TriggerRefProxy t, ref float stuckSince, ref float nextOrder, ref float lastFull, Vector3? protect = null) { //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_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_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_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_0129: 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_0146: Invalid comparison between Unknown and I4 try { float num = 1.2f; BehaviourPowerLegs val = ((Il2CppObjectBase)nav).TryCast<BehaviourPowerLegs>(); if ((Object)(object)val != (Object)null && !OnItsFeet(nav)) { stuckSince = -1f; return; } if ((Object)(object)val != (Object)null) { num = 0.49999997f; if (val._meleeActiveUntilTime > Time.time) { stuckSince = -1f; return; } } else if ((Object)(object)((Il2CppObjectBase)nav).TryCast<BehaviourOmniwheel>() != (Object)null || (Object)(object)((Il2CppObjectBase)nav).TryCast<BehaviourCrablet>() != (Object)null || (Object)(object)((Il2CppObjectBase)nav).TryCast<BehaviourBaseTurret>() != (Object)null) { return; } Vector3 val2 = ThreatBook.PositionOf(t); float num2 = Vector3.Distance(from, val2); if ((((Object)(object)val != (Object)null) ? Mathf.Max(0f, num2 - 0.6f) : num2) <= num + 0.4f) { stuckSince = -1f; _intercepting = false; return; } if (nav.enableThrowAttack && num2 >= nav.throwMinRange && num2 <= nav.throwMaxRange) { stuckSince = -1f; return; } float time = Time.time; if (stuckSince < 0f) { stuckSince = time; } if (!(time - stuckSince < 0.25f) && !(time < nextOrder)) { nextOrder = time + 0.25f; nav.SetPath(protect.HasValue ? InterceptPoint(from, val2, protect.Value) : val2); if ((int)nav.mentalState == 4 && time - lastFull >= 3f) { lastFull = time; nav.SwitchMentalState((MentalState)3); } } } catch { } } private static Vector3 InterceptPoint(Vector3 guard, Vector3 at, Vector3 dell) { //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_001e: 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_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_0045: 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_0070: 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_0073: 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) Vector3 val = dell - at; val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; float num = magnitude; float num2 = Vector3.Distance(new Vector3(guard.x, 0f, guard.z), new Vector3(dell.x, 0f, dell.z)); if (magnitude < 1.2f || num2 < num + 0.3f) { _intercepting = false; return at; } _intercepting = true; return at + val / magnitude * Mathf.Min(1f, magnitude * 0.5f); } private static void Escort(Vector3 dellPos) { //IL_0005: 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_0037: Unknown result type (might be due to invalid IL or missing references) try { _nav.SetHomePosition(dellPos, false, false); if (!HighAlertBridge.Reaching(_nav)) { if (Vector3.Distance(PositionOfBrain(_guard), dellPos) > 2.5f) { WalkTo(_nav, dellPos); } else { _nav.ClearPath(); } } } catch { } } private static void WalkTo(BehaviourBaseNav nav, Vector3 p) { //IL_0001: 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_0025: Unknown result type (might be due to invalid IL or missing references) try { nav.SetHomePosition(p, true, false); nav.SetPath(p); } catch { } try { if ((Object)(object)((Il2CppObjectBase)nav).TryCast<BehaviourCrablet>() != (Object)null) { CrabHopTo(nav, p); } } catch { } } private static void CrabHopTo(BehaviourBaseNav nav, Vector3 p) { //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_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_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) //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_00a8: 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_00b9: 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_0102: Unknown result type (might be due to invalid IL or missing references) try { if (!OnItsFeet(nav)) { return; } AIBrain componentInParent = ((Component)nav).GetComponentInParent<AIBrain>(); if ((Object)(object)componentInParent == (Object)null) { return; } int instanceID = ((Object)componentInParent).GetInstanceID(); if (_lastHop.TryGetValue(instanceID, out var value) && Time.time - value < 0.5f) { return; } Vector3 val = PositionOfBrain(componentInParent); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(p.x - val.x, 0f, p.z - val.z); float magnitude = ((Vector3)(ref val2)).magnitude; if (!(magnitude <= 1.2f)) { float num = Mathf.Min(magnitude - 1f, 4f); Vector3 to = val + val2 / magnitude * num; float t = Mathf.Clamp(num * 0.12f, 0.3f, 0.55f); _lastHop[instanceID] = Time.time; if (_lastHop.Count > 32) { _lastHop.Clear(); } componentInParent.SetVelocity(Ballistic(val, to, t)); } } catch { } } private static void StandDown(BehaviourBaseNav nav) { //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_0009: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 try { MentalState mentalState = nav.mentalState; if ((int)mentalState == 3 || (int)mentalState == 4 || (int)mentalState == 2) { nav.SwitchMentalState((MentalState)1); } } catch { } } private static void PurgeTargets(SubBehaviourSensors s, TriggerRefProxy keep) { if (s == null) { return; } try { List<TriggerRefProxy> trpList = s.TrpList; if (trpList == null || trpList.Count == 0) { return; } _purge.Clear(); for (int i = 0; i < trpList.Count; i++) { TriggerRefProxy val = trpList[i]; if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)keep) { _purge.Add(val); } } for (int j = 0; j < _purge.Count; j++) { try { s.RemoveTarget(_purge[j]); } catch { } } _purge.Clear(); } catch { } } private static void KeepSlotClean(SubBehaviourSensors s, RigManager rig, TriggerRefProxy dell, TriggerRefProxy keep) { try { s.RemoveTarget(dell); TriggerRefProxy target = s.target; if ((Object)(object)target != (Object)null && (IsDell(target, rig) || (Object)(object)target != (Object)(object)keep)) { s.RemoveTarget(target); s.target = null; } } catch { } } private static void ClearSlot(SubBehaviourSensors s) { try { if ((Object)(object)s.target != (Object)null) { s.target = null; } } catch { } } private static void Forget(SubBehaviourSensors s, TriggerRefProxy t) { if (s == null || (Object)(object)t == (Object)null) { return; } try { s.RemoveTarget(t); } catch { } try { if ((Object)(object)s.target == (Object)(object)t) { s.target = null; } } catch { } } private static float GapTo(Vector3 from, TriggerRefProxy t) { //IL_0005: 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) return Mathf.Max(0f, Vector3.Distance(from, ThreatBook.PositionOf(t)) - 0.6f); } private static float[] ReadSpeeds(BehaviourBaseNav nav) { float[] array = new float[5]; for (int i = 0; i < 5; i++) { array[i] = float.NaN; } try { array[0] = nav.agroedSpeed; array[1] = nav.agroedAngSpeed; array[2] = nav.roamSpeed; array[3] = nav.roamAngSpeed; BehaviourPowerLegs val = ((Il2CppObjectBase)nav).TryCast<BehaviourPowerLegs>(); if ((Object)(object)val != (Object)null) { array[4] = val.engagedSpeed; } } catch { } return array; } private static void SetSpeed(BehaviourBaseNav nav, bool on, float[] orig) { if ((Object)(object)nav == (Object)null || orig == null) { return; } float num = (on ? 2f : 1f); try { if (!float.IsNaN(orig[0]) && nav.agroedSpeed != orig[0] * num) { nav.agroedSpeed = orig[0] * num; } if (!float.IsNaN(orig[1]) && nav.agroedAngSpeed != orig[1] * num) { nav.agroedAngSpeed = orig[1] * num; } if (!float.IsNaN(orig[2]) && nav.roamSpeed != orig[2] * num) { nav.roamSpeed = orig[2] * num; } if (!float.IsNaN(orig[3]) && nav.roamAngSpeed != orig[3] * num) { nav.roamAngSpeed = orig[3] * num; } if (!float.IsNaN(orig[4])) { BehaviourPowerLegs val = ((Il2CppObjectBase)nav).TryCast<BehaviourPowerLegs>(); if ((Object)(object)val != (Object)null && val.engagedSpeed != orig[4] * num) { val.engagedSpeed = orig[4] * num; } } } catch { } } private static void SetCloseIn(BehaviourBaseNav nav, bool on, float origDesired, float origMelee) { if (float.IsNaN(origDesired)) { return; } try { BehaviourPowerLegs val = ((Il2CppObjectBase)nav).TryCast<BehaviourPowerLegs>(); if (!((Object)(object)val == (Object)null)) { float num = (on ? 0.3f : origDesired); if (val.desiredDistance != num) { val.desiredDistance = num; } if (val.desiredMeleeDistance != origMelee) { val.desiredMeleeDistance = origMelee; } } } catch { } } private static void SetChaseMode(BehaviourBaseNav nav, bool chase, int origMode, Instance log) { //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_0026: 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_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_003d: Unknown result type (might be due to invalid IL or missing references) if (origMode < 0) { return; } try { BehaviourPowerLegs val = ((Il2CppObjectBase)nav).TryCast<BehaviourPowerLegs>(); if ((Object)(object)val == (Object)null) { return; } EngagedMode val2 = (EngagedMode)(chase ? 1 : origMode); if (val.engagedMode != val2) { val.SwitchEngagedState(val2, true); if (val.engagedMode != val2) { val.engagedMode = val2; } } } catch { } } private static void PushAttack(Instance log) { //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_0070: 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_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_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_018e: 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_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_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) BehaviourPowerLegs val = null; try { val = ((Il2CppObjectBase)_nav).TryCast<BehaviourPowerLegs>(); } catch { } if ((Object)(object)val == (Object)null) { BehaviourBaseNav nav = _nav; if ((Object)(object)((Il2CppObjectBase)nav).TryCast<BehaviourCrablet>() != (Object)null) { CrabLeap(_guard, nav, _threat, log); } else if (IsNullRat(nav)) { RatPounce(_guard, _threat, log); } else if (!MeleeBoost.CanMelee(_guard)) { Lunge(_guard, PositionOfBrain(_guard), _threat, log); } return; } try { float time = Time.time; Vector3 val2 = PositionOfBrain(_guard); float num = GapTo(val2, _threat); TrackThreatVelocity(time); if (_lungeAt > 0f) { if (!(time - _lungeAt > 0.45f)) { if (num <= 0.25f) { _lungeAt = -1f; LungeHit(val2, log); } return; } _lungeAt = -1f; } if (num > 1f) { _idleInRangeSince = -1f; } else { if (!OnItsFeet(_nav)) { return; } float num2 = Mathf.Max(val.meleeCooldown, 0.2f); if (val._meleeActiveUntilTime > time - num2 || time - _lastForcedSwing < num2) { return; } if (num <= 0.4f) { Swing(val, time, log); } else { if (time - _lastLungePunch < 1f) { return; } Vector3 val3 = ThreatBook.PositionOf(_threat) + _threatVel * 0.35f - val2; val3.y = 0f; if (!(((Vector3)(ref val3)).sqrMagnitude < 0.0001f)) { _lastLungePunch = time; _lungePunches++; _lungeAt = time; try { _guard.SetVelocity(((Vector3)(ref val3)).normalized * 3f + Vector3.up * 0.5f); } catch { } Swing(val, time, log); } } } } catch { } } private static void Swing(BehaviourPowerLegs legs, float now, Instance log) { _lastForcedSwing = now; _forcedSwings++; try { legs._cooldownMelee = 0f; } catch { } try { legs.ContextAttack(); _contextOn = true; } catch { } try { legs.TriggerAttack(); } catch { } } private static void StopForcedAttack(BehaviourBaseNav nav) { if (_contextOn) { _contextOn = false; StopContext(nav); } } private static void StopContext(BehaviourBaseNav nav) { try { BehaviourPowerLegs val = ((Il2CppObjectBase)nav).TryCast<BehaviourPowerLegs>(); if ((Object)(object)val != (Object)null) { val.StopContextAttack(); } } catch { } } private static Vector3 Ballistic(Vector3 from, Vector3 to, float t) { //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_0008: 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_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) return (to - from) / t - 0.5f * Physics.gravity * t; } private static void CrabLeap(AIBrain brain, BehaviourBaseNav nav, TriggerRefProxy threat, Instance log) { //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_0101: 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_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) //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_008a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)brain == (Object)null || (Object)(object)threat == (Object)null) { return; } try { BehaviourCrablet val = ((Il2CppObjectBase)nav).TryCast<BehaviourCrablet>(); if ((Object)(object)val == (Object)null || IsClinging(val) || !OnItsFeet(nav)) { return; } float num = Mathf.Max(val.jumpCooldown, 0.4f); if (Time.time - _lastLunge < num) { return; } Vector3 val2 = PositionOfBrain(brain); Vector3 val3 = HeadOf(threat); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(val3.x - val2.x, 0f, val3.z - val2.z); float magnitude = ((Vector3)(ref val4)).magnitude; if (!(magnitude > 6f) && !(magnitude < 0.2f)) { float t = Mathf.Clamp(magnitude * 0.14f, 0.3f, 0.8f); _lastLunge = Time.time; try { val.jumpType = (JumpType)2; } catch { } try { val._jumpAttacking = true; } catch { } try { val.Jump((JumpType)2); } catch { } brain.SetVelocity(Ballistic(val2, val3, t)); } } catch { } } private static bool IsClinging(BehaviourCrablet crab) { try { return crab._headMounted || (Object)(object)crab._faceJoint != (Object)null; } catch { return false; } } private static bool OnItsFeet(BehaviourBaseNav nav) { //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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 try { SubBehaviourSensors sensors = nav.sensors; if (sensors != null && !sensors.isGrounded) { return false; } LocoState locoState = nav.locoState; return (int)locoState == 0 || (int)locoState == 1; } catch { return false; } } public static bool ShouldHoldOn(BehaviourCrablet crab) { if (_detachingOnPurpose || (Object)(object)crab == (Object)null) { return false; } try { int instanceID = ((Object)crab).GetInstanceID(); bool flag = (Object)(object)_nav != (Object)null && ((Object)_nav).GetInstanceID() == instanceID; if (!flag) { for (int i = 0; i < 4; i++) { if (_agId[i] != 0 && (Object)(object)_agNav[i] != (Object)null && (Object)(object)_agThreat[i] != (Object)null && ((Object)_agNav[i]).GetInstanceID() == instanceID) { flag = true; break; } } } if (!flag) { return false; } if (!((Behaviour)crab).isActiveAndEnabled || !((Component)crab).gameObject.activeInHierarchy) { return false; } AIBrain componentInParent = ((Component)crab).GetComponentInParent<AIBrain>(); if ((Object)(object)componentInParent != (Object)null && Reviver.IsDown(componentInParent)) { return false; } TriggerRefProxy grappleTarget = crab._grappleTarget; if ((Object)(object)grappleTarget == (Object)null || IsDell(grappleTarget, LocalRig())) { return false; } return !ThreatBook.IsGonePublic(grappleTarget); } catch { return false; } } private static void LetGoOfDell(BehaviourBaseNav nav, RigManager rig, Instance log) { try { BehaviourCrablet val = ((Il2CppObjectBase)nav).TryCast<BehaviourCrablet>(); if ((Object)(object)val == (Object)null || !IsClinging(val) || !IsDell(val._grappleTarget, rig) || Time.time - _lastLetGo < 0.5f) { return; } _lastLetGo = Time.time; _detachingOnPurpose = true; try { val.DetachFromFace(); } finally { _detachingOnPurpose = false; } } catch { } } private static void GroundFight(float now, Instance log) { //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_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_022a: 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_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_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_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_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_0171: 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_0266: 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_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_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)_guard == (Object)null || (Object)(object)_nav == (Object)null) { return; } int instanceID = ((Object)_guard).GetInstanceID(); if (instanceID != _groundGuardId) { _groundGuardId = instanceID; GroundReset(); } if ((Object)(object)((Il2CppObjectBase)_nav).TryCast<BehaviourPowerLegs>() == (Object)null || !MeleeBoost.CanMelee(_guard) || HighAlertBridge.HoldsGun(_nav)) { return; } if (!GuardBody.IsLying(_guard)) { GroundReset(); return; } if (_groundDone || (Object)(object)_threat == (Object)null || ThreatBook.IsGonePublic(_threat)) { GuardBody.ReleaseStand(); return; } Vector3 val = PositionOfBrain(_guard); Vector3 val2 = ThreatBook.PositionOf(_threat); if (Vector3.Distance(val, val2) > 1.3f) { GuardBody.ReleaseStand(); return; } if (_groundSince < 0f) { _groundSince = now; } if (now - _groundSince > 4f) { GroundStop(); return; } GuardBody.HoldStand(_guard, 0.8f); Rigidbody[] array = GuardBody.Hands(_guard); if (array == null || array.Length == 0) { GroundStop(); return; } if (_groundSwingAt > 0f) { Rigidbody val3 = array[_groundHand % array.Length]; if (!_groundLanded && (Object)(object)val3 != (Object)null) { Vector3 position = val3.position; Vector3 val4 = HeadOf(_threat); if (Vector3.Distance(position, val2) <= 0.45f || Vector3.Distance(position, val4) <= 0.45f) { _groundLanded = true; LungeHit(val, log); } } if (now - _groundSwingAt < 0.45f) { return; } if (_groun