Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Offline Companions Reborn v1.5.8
Companions.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [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 Companions { public class CompanionAI : BaseAI { [Header("Sleep")] public bool m_sleeping; public float m_wakeupRange = 5f; public bool m_noiseWakeup; public float m_maxNoiseWakeupRange = 50f; public EffectList m_wakeupEffects = new EffectList(); public EffectList m_sleepEffects = new EffectList(); public float m_wakeUpDelayMin; public float m_wakeUpDelayMax; public float m_fallAsleepDistance; private float m_sleepDelay = 0.5f; private float m_sleepTimer; private static readonly int s_sleeping = ZSyncAnimation.GetHash("sleeping"); private static readonly int s_crouching = ZSyncAnimation.GetHash("crouching"); internal Character m_targetCreature; internal StaticTarget m_targetStatic; internal Vector3 m_lastKnownTargetPos = Vector3.zero; internal bool m_beenAtLastPos; private GameObject m_follow; internal float FreezeTimer; private bool _isDvergerSupport; private Character _healTarget; private float _healScanTimer; private float _healEquipTimer; private float _healLogTimer; private float _healUnreachableTimer; private float _healLastDistance = -1f; private const float HealThreshold = 0.7f; private const float HealScanInterval = 1f; private const float HealLogInterval = 3f; private const float HealRange = 50f; private const float HealUnreachableTimeout = 6f; private bool _isOnShip; private Ship _attachedShip; private Chair _attachedChair; private Vector3 _shipLocalPos; private Quaternion _shipLocalRot; private Collider[] _shipColliders; private ZSyncAnimation _zanim; internal Vagon PendingCartAttach; internal Humanoid PendingCartHumanoid; private float _pendingCartTimeout; internal Vector3? PendingMoveTarget; private float _pendingMoveTimeout; internal Container PendingDepositContainer; internal Humanoid PendingDepositHumanoid; private float _pendingDepositTimeout; private bool _depositChestOpen; private float _depositWorkTimer; private int _depositCount; private readonly List<ItemData> _depositQueue = new List<ItemData>(); private const float DepositItemInterval = 0.6f; private TombStone _pendingTombstone; private float _tombstoneScanTimer; private float _tombstoneNavTimeout; private float _tombstoneNavStuckTime; private float _tombRecoverSnooze; private const float TombstoneLootRange = 3f; private int _autoPickupMask; private readonly Collider[] _autoPickupBuffer = (Collider[])(object)new Collider[32]; private const float AutoPickupPullSpeed = 15f; internal static EffectList DrownEffects; private CompanionStamina _companionStamina; private float _drownDamageTimer; private float _hazardRecoveryTimer; private static readonly int s_taredHash = StringExtensionMethods.GetStableHashCode("Tared"); private bool _wasInFormation; private int _lastFollowMode; private int _formationSlot = -1; private CompanionSetup _setup; private CompanionCombatAI _combatAI; private HarvestController _harvest; private RepairController _repair; private SmeltController _smelt; private FarmController _farm; private HuntController _hunt; private FishController _fish; private UpkeepController _upkeep; private IdleController _idle; private CookController _cook; private DoorHandler _doorHandler; private CompanionRest _rest; private CompanionTalk _talk; private Rigidbody _body; private float _torchCheckTimer; private const float TorchCheckInterval = 3f; private bool _torchWanted; private float _torchDrainAt; private bool _torchBurnedOut; private string _lightLogKey; private const float SuppressedMoveInterval = 9999f; private float _furnitureStuckTimer; private const float FurnitureStuckThreshold = 3f; private float _continuousSwimTimer; private readonly Dictionary<Vector3Int, float> _targetBlacklist = new Dictionary<Vector3Int, float>(); private const float BlacklistDuration = 30f; private const float BlacklistCellSize = 2f; private float _blacklistCleanupTimer; private const float RSItemTransferDelay = 0.6f; private const float RSMoveTimeout = 15f; internal bool WantsTorch => _torchWanted; internal bool IsOnShip => _isOnShip; internal bool IsBoardingShip => MHR_Board.Active(this); private static float TombstoneScanInterval => ModConfig.TombstoneScanInterval.Value; private static float TombstoneNavTimeoutMax => ModConfig.TombstoneNavTimeout.Value; private static float AutoPickupRange => ModConfig.AutoPickupRange.Value; private static float FollowTeleportDist => ModConfig.FollowTeleportDistance.Value; private static float FormationOffset => ModConfig.FormationOffset.Value; private static float FormationCatchupDist => ModConfig.FormationCatchupDist.Value; internal bool IsInCombat { get { if ((Object)(object)_combatAI != (Object)null) { return _combatAI.IsEngaged; } return false; } } internal bool IsRecoveringTombstone => (Object)(object)_pendingTombstone != (Object)null; internal bool HasOrder { get { if (!MHR_Hive.Active(this) && !MHR_Board.Active(this) && !PendingMoveTarget.HasValue && !((Object)(object)PendingCartAttach != (Object)null) && !((Object)(object)PendingDepositContainer != (Object)null)) { return (Object)(object)_pendingTombstone != (Object)null; } return true; } } internal void SetPatrolPointAt(Vector3 point) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) ZNetView nview = base.m_nview; if (((nview != null) ? nview.GetZDO() : null) != null) { base.m_nview.GetZDO().Set(ZDOVars.s_patrol, true); base.m_nview.GetZDO().Set(ZDOVars.s_patrolPoint, point); } } public void SetFollowTarget(GameObject go) { m_follow = go; if ((Object)(object)go == (Object)null) { _formationSlot = -1; } } internal void IgnorePlayerCollision() { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { Collider component = ((Component)this).GetComponent<Collider>(); Collider component2 = ((Component)localPlayer).GetComponent<Collider>(); if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null) { Physics.IgnoreCollision(component, component2, true); } } } internal void CancelMoveTarget() { if (PendingMoveTarget.HasValue) { PendingMoveTarget = null; RestoreFollowOrPatrol(); } } internal void CancelPendingCart() { if (!((Object)(object)PendingCartAttach == (Object)null)) { PendingCartAttach = null; PendingCartHumanoid = null; RestoreFollowOrPatrol(); } } internal void CancelPendingShipBoard() { if (MHR_Board.Active(this)) { MHR_Board.Cancel(this); RestoreFollowOrPatrol(); } } internal void SetHiveOrder(Beehive hive) { SetFollowTarget(null); MHR_Hive.Start(this, hive); } internal void CancelHiveOrder() { if (MHR_Hive.Active(this)) { MHR_Hive.Cancel(this); RestoreFollowOrPatrol(); } } internal void BoardingEnded() { RestoreFollowOrPatrol(); } internal void CancelPendingDeposit() { if (!((Object)(object)PendingDepositContainer == (Object)null)) { if (_depositChestOpen && (Object)(object)PendingDepositContainer != (Object)null) { PendingDepositContainer.SetInUse(false); _depositChestOpen = false; } PendingDepositContainer = null; PendingDepositHumanoid = null; _depositQueue.Clear(); _depositCount = 0; RestoreFollowOrPatrol(); } } internal void CancelTombstoneRecovery() { bool num = (Object)(object)_pendingTombstone != (Object)null || _pendingTombstone != null; bool flag = false; ZNetView nview = base.m_nview; ZDO val = ((nview != null) ? nview.GetZDO() : null); if (val != null) { flag = val.GetLong(CompanionSetup.TombstoneIdHash, 0L) != 0; } if (num || flag) { _tombRecoverSnooze = 30f; _pendingTombstone = null; ClearTombstoneId(); RestoreFollowOrPatrol(); } } protected override void Awake() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) ((BaseAI)this).Awake(); base.m_pathAgentType = (AgentType)1; base.m_avoidWater = false; _setup = ((Component)this).GetComponent<CompanionSetup>(); _combatAI = ((Component)this).GetComponent<CompanionCombatAI>(); _harvest = ((Component)this).GetComponent<HarvestController>(); _repair = ((Component)this).GetComponent<RepairController>(); _smelt = ((Component)this).GetComponent<SmeltController>(); _farm = ((Component)this).GetComponent<FarmController>(); _hunt = ((Component)this).GetComponent<HuntController>(); _fish = ((Component)this).GetComponent<FishController>(); _upkeep = ((Component)this).GetComponent<UpkeepController>(); _idle = ((Component)this).GetComponent<IdleController>(); _cook = ((Component)this).GetComponent<CookController>(); _doorHandler = ((Component)this).GetComponent<DoorHandler>(); _rest = ((Component)this).GetComponent<CompanionRest>(); _talk = ((Component)this).GetComponent<CompanionTalk>(); _body = ((Component)this).GetComponent<Rigidbody>(); _zanim = ((Component)this).GetComponent<ZSyncAnimation>(); _autoPickupMask = LayerMask.GetMask(new string[1] { "item" }); _companionStamina = ((Component)this).GetComponent<CompanionStamina>(); ZDO zDO = base.m_nview.GetZDO(); if (zDO != null) { m_sleeping = zDO.GetBool(ZDOVars.s_sleeping, m_sleeping); if ((Object)(object)base.m_animator != (Object)null) { base.m_animator.SetBool(s_sleeping, ((BaseAI)this).IsSleeping()); } } if (m_wakeUpDelayMin > 0f || m_wakeUpDelayMax > 0f) { m_sleepDelay = Random.Range(m_wakeUpDelayMin, m_wakeUpDelayMax); } base.m_nview.Register("RPC_Wakeup", (Action<long>)RPC_Wakeup); base.m_nview.Register("RPC_Sleep", (Action<long>)RPC_Sleep); Animator componentInChildren = ((Component)this).GetComponentInChildren<Animator>(); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.runtimeAnimatorController != (Object)null) { _ = ((Object)componentInChildren.runtimeAnimatorController).name; } if ((Object)(object)componentInChildren != (Object)null) { _ = componentInChildren.parameterCount; } ((Object)((Component)this).gameObject).name.Contains("Dverger"); _isDvergerSupport = ((Object)((Component)this).gameObject).name.Contains("DvergerSupport"); IgnorePlayerCollision(); } private void RPC_Wakeup(long sender) { if (!base.m_nview.GetZDO().IsOwner()) { m_sleeping = false; } } private void RPC_Sleep(long sender) { if (!base.m_nview.GetZDO().IsOwner()) { m_sleeping = true; } } private static bool IsTorch(ItemData it) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 if (it != null && it.m_shared != null) { return (int)it.m_shared.m_itemType == 15; } return false; } private void UpdateTorch() { Character character = base.m_character; Humanoid val = (Humanoid)(object)((character is Humanoid) ? character : null); if ((Object)(object)val == (Object)null) { return; } float time = Time.time; ItemData rightItem = ReflectionHelper.GetRightItem(val); ItemData leftItem = ReflectionHelper.GetLeftItem(val); ItemData val2 = (IsTorch(rightItem) ? rightItem : (IsTorch(leftItem) ? leftItem : null)); if (IsTorch(val2) && val2.m_shared.m_useDurability) { ConfigEntry<bool> torchBurnsDown = ModConfig.TorchBurnsDown; if (torchBurnsDown == null || torchBurnsDown.Value) { float num = ((_torchDrainAt > 0f) ? Mathf.Min(time - _torchDrainAt, 5f) : 0f); _torchDrainAt = time; ItemData obj = val2; obj.m_durability -= val2.m_shared.m_durabilityDrain * num * Game.m_durabilityRate; if (val2.m_durability <= 0f) { val.UnequipItem(val2, false); if (val2.m_shared.m_destroyBroken) { Inventory inventory = val.GetInventory(); if (inventory != null) { inventory.RemoveItem(val2); } } if (CompanionsPlugin.LogNormal) { CompanionsPlugin.Log.LogInfo((object)("[Torch] \"" + base.m_character.m_name + "\": the torch burned out")); } _torchBurnedOut = true; _torchCheckTimer = 0f; val2 = null; } goto IL_014e; } } _torchDrainAt = 0f; goto IL_014e; IL_014e: _torchCheckTimer -= Time.deltaTime; if (_torchCheckTimer > 0f) { return; } _torchCheckTimer = 1f; Inventory inventory2 = val.GetInventory(); if (inventory2 != null) { List<ItemData> list = null; foreach (ItemData allItem in inventory2.GetAllItems()) { if (IsTorch(allItem) && allItem.m_shared.m_useDurability && allItem.m_shared.m_destroyBroken && allItem.m_durability <= 0f) { (list ?? (list = new List<ItemData>())).Add(allItem); } } if (list != null) { foreach (ItemData item in list) { if (item == val2) { val2 = null; } val.UnequipItem(item, false); inventory2.RemoveItem(item); } if (CompanionsPlugin.LogNormal) { CompanionsPlugin.Log.LogInfo((object)("[Torch] \"" + base.m_character.m_name + "\": the torch was used up")); } _torchBurnedOut = true; } } bool flag = (Object)(object)_combatAI != (Object)null && _combatAI.IsEngaged; bool flag2 = val2 != null && val2 == leftItem; bool flag3 = (_torchWanted = (!flag || flag2) && IsDarkHere() && !LitBaseNear() && !YouHoldTorchNear()); if (TorchOpener.IsActive(val) || ((Character)val).InAttack()) { return; } bool flag4 = (Object)(object)_setup != (Object)null && _setup.SuppressAutoEquip; if (flag3 && !flag && !flag4 && !IsTorch(val2) && !base.m_character.IsSwimming()) { ItemData val3 = null; Inventory inventory3 = val.GetInventory(); if (inventory3 != null) { foreach (ItemData allItem2 in inventory3.GetAllItems()) { if (IsTorch(allItem2) && (!allItem2.m_shared.m_useDurability || allItem2.m_durability > 0f) && (val3 == null || allItem2.m_durability > val3.m_durability)) { val3 = allItem2; } } } bool flag5 = rightItem == null && inventory3 != null && inventory3.GetAllItems().Exists((ItemData it) => it.m_shared != null && ((int)it.m_shared.m_itemType == 3 || (int)it.m_shared.m_itemType == 14 || (int)it.m_shared.m_itemType == 22 || (int)it.m_shared.m_itemType == 4) && (!it.m_shared.m_useDurability || it.m_durability > 0f)); if (val3 != null) { if (!flag5) { val.EquipItem(val3, true); _torchBurnedOut = false; if (CompanionsPlugin.LogDetailed) { CompanionsPlugin.Log.LogDebug((object)("[Torch] \"" + base.m_character.m_name + "\" lit a torch (" + (val3.m_shared.m_useDurability ? ((val3.m_durability / Mathf.Max(1f, val3.GetMaxDurability()) * 100f).ToString("F0") + "% left") : "no wear") + ")")); } } } else if (_torchBurnedOut) { _torchBurnedOut = false; ((Component)this).GetComponent<CompanionTalk>()?.SayProblem("no_torches", ModLocalization.Loc("hc_say_no_torches")); } } else if (!flag3 && IsTorch(val2)) { val.UnequipItem(val2, false); if (CompanionsPlugin.LogDetailed) { CompanionsPlugin.Log.LogDebug((object)("[Torch] \"" + base.m_character.m_name + "\" put the torch away")); } _setup?.SyncEquipmentToInventory(); } } private bool IsDarkHere() { //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_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_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) Vector3 position = ((Component)this).transform.position; if (!Character.InInterior(position)) { return EnvMan.IsNight(); } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || !((Character)localPlayer).InInterior() || Vector3.Distance(((Component)localPlayer).transform.position, position) > 100f) { return true; } Color ambientLight = RenderSettings.ambientLight; float grayscale = ((Color)(ref ambientLight)).grayscale; float num = ModConfig.TorchDarkThreshold?.Value ?? 0.4f; bool flag = grayscale < num; EnvMan instance = EnvMan.instance; string text = ((instance == null) ? null : instance.GetCurrentEnvironment()?.m_name) ?? "?"; string text2 = text + (flag ? "/dark" : "/lit"); if (text2 != _lightLogKey) { _lightLogKey = text2; if (CompanionsPlugin.LogNormal) { CompanionsPlugin.Log.LogInfo((object)string.Format("[Torch] \"{0}\" in {1}, light {2:F2} ({3}, DarkLevel {4:F2})", base.m_character.m_name, text, grayscale, flag ? "dark" : "light enough", num)); } } return flag; } private bool LitBaseNear() { //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_0024: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)this).transform.position; try { if ((Object)(object)EffectArea.IsPointInsideArea(position, (Type)4, 0f) == (Object)null) { return false; } Collider[] array = Physics.OverlapSphere(position, 8f); foreach (Collider val in array) { Fireplace val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponentInParent<Fireplace>() : null); if ((Object)(object)val2 != (Object)null && val2.IsBurning()) { return true; } } } catch { } return false; } private bool YouHoldTorchNear() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && IsTorch(ReflectionHelper.GetRightItem((Humanoid)(object)localPlayer))) { return Vector3.Distance(((Component)localPlayer).transform.position, ((Component)this).transform.position) < 5f; } return false; } public GameObject GetFollowTarget() { return m_follow; } public override Character GetTargetCreature() { return m_targetCreature; } public StaticTarget GetStaticTarget() { return m_targetStatic; } public void ClearTargets() { if (!((Object)(object)m_targetCreature != (Object)null)) { _ = (Object)(object)m_targetStatic != (Object)null; } m_targetCreature = null; m_targetStatic = null; } private void ClearCreatureTarget() { m_targetCreature = null; } internal bool GameMoveTo(float dt, Vector3 point, float dist, bool run) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return ((BaseAI)this).MoveTo(dt, point, dist, run); } internal bool MHR_Go(float dt, Vector3 point, float dist, bool run, string tag) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return MHR_Mover.Go(this, dt, point, dist, run, tag, run ? 3 : 2); } internal void LookAtPoint(Vector3 point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((BaseAI)this).LookAt(point); } internal bool IsLookingAtPoint(Vector3 point, float angle, bool invert = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return ((BaseAI)this).IsLookingAt(point, angle, invert); } internal void SetAlerted(bool alert) { ((BaseAI)this).SetAlerted(alert); } internal Character FindNearbyEnemy() { return ((BaseAI)this).FindEnemy(); } private static bool IsPassiveAnimal(Character c) { return MHR_Threat.IsPassive(c); } internal void FollowObject(GameObject go, float dt) { ((BaseAI)this).Follow(go, dt); } internal void PushDirection(Vector3 dir, bool run) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((BaseAI)this).MoveTowards(dir, run); } internal void RandomMovement(float dt, Vector3 center) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ((BaseAI)this).RandomMovement(dt, center, false); } internal void RandomMovementAroundPoint(float dt, Vector3 point, float distance, bool run) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ((BaseAI)this).RandomMovementArroundPoint(dt, point, distance, run); } internal bool FleeFrom(float dt, Vector3 from) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return ((BaseAI)this).Flee(dt, from); } internal bool GetPatrolPoint(out Vector3 point) { return ((BaseAI)this).GetPatrolPoint(ref point); } internal Character HaveFriendInRange(float range) { return ((BaseAI)this).HaveFriendInRange(range); } internal Character HaveHurtFriendInRange(float range) { return ((BaseAI)this).HaveHurtFriendInRange(range); } internal void HaveFriendsInRange(float range, out Character hurtFriend, out Character friend) { ((BaseAI)this).HaveFriendsInRange(range, ref hurtFriend, ref friend); } internal bool IsTakingOff() { return ((BaseAI)this).IsTakingOff(); } internal void SetFormationSlot(int slot) { _formationSlot = slot; } internal void SetPendingCart(Vagon vagon, Humanoid humanoid) { PendingCartAttach = vagon; PendingCartHumanoid = humanoid; _pendingCartTimeout = 20f; SetFollowTarget(null); } private void RestoreFollowOrPatrol() { if ((Object)(object)_setup != (Object)null && _setup.GetFollow() && (Object)(object)MHR_Owner.Of((Component)(object)this) != (Object)null) { SetFollowTarget(MHR_Owner.Go((Component)(object)this)); } else { SetFollowTarget(null); } } internal void AttachToShip(Ship ship, Chair chair) { //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_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_0093: 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_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_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_00ce: 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_00f3: Unknown result type (might be due to invalid IL or missing references) if (_isOnShip) { DetachFromShip(); } _attachedShip = ship; _attachedChair = chair; _isOnShip = true; WaterSafety.Clear(base.m_character); CapsuleCollider component = ((Component)this).GetComponent<CapsuleCollider>(); if ((Object)(object)component != (Object)null) { _shipColliders = ((Component)ship).GetComponentsInChildren<Collider>(); Collider[] shipColliders = _shipColliders; foreach (Collider val in shipColliders) { Physics.IgnoreCollision((Collider)(object)component, val, true); } } Vector3 position = chair.m_attachPoint.position; Quaternion rotation = chair.m_attachPoint.rotation; ((Component)this).transform.position = position; ((Component)this).transform.rotation = rotation; _shipLocalPos = ((Component)ship).transform.InverseTransformPoint(position); _shipLocalRot = Quaternion.Inverse(((Component)ship).transform.rotation) * rotation; if ((Object)(object)_body != (Object)null) { _body.position = position; _body.linearVelocity = Vector3.zero; ResetLiquidState(); _body.isKinematic = false; _body.useGravity = false; } bool flag = (Object)(object)_setup != (Object)null && _setup.CanWearArmor(); if ((Object)(object)_zanim != (Object)null && flag) { _zanim.SetBool("attach_chair", true); } Character character = base.m_character; Humanoid val2 = (Humanoid)(object)((character is Humanoid) ? character : null); if ((Object)(object)val2 != (Object)null) { val2.HideHandItems(false, true); } SetFollowTarget(null); } internal void DetachFromShip() { //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_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_00d1: 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_01c6: 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_0153: 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_0174: 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_018a: 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_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_01f0: 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) if (!_isOnShip) { return; } Ship attachedShip = _attachedShip; bool flag = (Object)(object)_setup != (Object)null && _setup.CanWearArmor(); if ((Object)(object)_zanim != (Object)null && flag) { _zanim.SetBool("attach_chair", false); } if (_shipColliders != null) { CapsuleCollider component = ((Component)this).GetComponent<CapsuleCollider>(); if ((Object)(object)component != (Object)null) { Collider[] shipColliders = _shipColliders; foreach (Collider val in shipColliders) { if ((Object)(object)val != (Object)null) { Physics.IgnoreCollision((Collider)(object)component, val, false); } } } _shipColliders = null; } if ((Object)(object)_body != (Object)null) { _body.isKinematic = false; _body.useGravity = true; _body.linearVelocity = Vector3.zero; } _isOnShip = false; _attachedShip = null; Chair attachedChair = _attachedChair; _attachedChair = null; Vector3 val2 = ((Component)this).transform.position + Vector3.up * 0.5f; if ((Object)(object)attachedChair != (Object)null && (Object)(object)attachedChair.m_attachPoint != (Object)null) { val2 = attachedChair.m_attachPoint.TransformPoint(attachedChair.m_detachOffset); if ((Object)(object)attachedShip != (Object)null && MHR_Deck.SpotNear(attachedShip, attachedChair.m_attachPoint.position, out var local)) { Vector3 val3 = ((Component)attachedShip).transform.TransformPoint(local) + ((Component)attachedShip).transform.up * 0.05f; if (Vector3.Distance(val3, attachedChair.m_attachPoint.position) < 2f) { val2 = val3; } } } ((Component)this).transform.position = val2; if ((Object)(object)_body != (Object)null) { _body.position = val2; Rigidbody val4 = (((Object)(object)attachedShip != (Object)null) ? ((Component)attachedShip).GetComponent<Rigidbody>() : null); _body.linearVelocity = (((Object)(object)val4 != (Object)null) ? val4.GetPointVelocity(val2) : Vector3.zero); ResetLiquidState(); } RestoreFollowOrPatrol(); } private void ResetLiquidState() { Character character = base.m_character; if (character != null) { ((IWaterInteractable)character).SetLiquidLevel(-10000f, (LiquidType)0, (Component)null); } } private void UpdateShipAttach() { if ((Object)(object)_attachedShip == (Object)null) { DetachFromShip(); } else { PinToShip(); } } private void PinToShip() { //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_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_006b: 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_009e: 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_00d4: 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) if (_isOnShip && !((Object)(object)_attachedShip == (Object)null) && !((Object)(object)base.m_nview == (Object)null) && base.m_nview.IsOwner()) { Vector3 val = ((Component)_attachedShip).transform.TransformPoint(_shipLocalPos); Quaternion rotation = ((Component)_attachedShip).transform.rotation * _shipLocalRot; ((Component)this).transform.position = val; ((Component)this).transform.rotation = rotation; if ((Object)(object)_body != (Object)null && !_body.isKinematic) { _body.position = val; _body.useGravity = false; Rigidbody component = ((Component)_attachedShip).GetComponent<Rigidbody>(); _body.linearVelocity = (((Object)(object)component != (Object)null) ? component.GetPointVelocity(val) : Vector3.zero); } } } private void FixedUpdate() { PinToShip(); } private void LateUpdate() { PinToShip(); } internal void SetPendingShipBoard(Ship ship, Chair chair) { SetFollowTarget(null); MHR_Board.Start(this, ship, chair, auto: false); } internal void SetMoveTarget(Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) PendingMoveTarget = pos; _pendingMoveTimeout = 30f; SetFollowTarget(null); } internal void SetPendingDeposit(Container chest, Humanoid humanoid) { PendingDepositContainer = chest; PendingDepositHumanoid = humanoid; _pendingDepositTimeout = 20f; SetFollowTarget(null); } private bool UpdateTombstoneRecovery(float dt) { //IL_0034: 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_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_012a: 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_0183: 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_0330: 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_03b8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_pendingTombstone != (Object)null) { if (IsInCombat) { return false; } if (MHR_Recover.IsRecovering((Component)(object)this) && !MHR_Recover.SafeToGo(base.m_character, ((Component)_pendingTombstone).transform.position, out var _, MHR_Owner.Go((Component)(object)this), committed: true) && RecoverWait(dt)) { _tombstoneNavTimeout = Mathf.Max(_tombstoneNavTimeout, 10f); return true; } if ((Object)(object)m_follow != (Object)null) { SetFollowTarget(null); } _tombstoneNavTimeout -= dt; if (_tombstoneNavTimeout <= 0f) { _pendingTombstone = null; ClearTombstoneId(); RestoreFollowOrPatrol(); _tombRecoverSnooze = 60f; if (CompanionsPlugin.LogNormal) { CompanionsPlugin.Log.LogInfo((object)"[Recovery] Couldn't reach its tombstone in time; will try again in a minute"); } return false; } Vector3 position = ((Component)_pendingTombstone).transform.position; float num = Vector3.Distance(((Component)this).transform.position, position); if (num < 3f) { Container component = ((Component)_pendingTombstone).GetComponent<Container>(); if ((Object)(object)component != (Object)null && component.IsInUse()) { ((BaseAI)this).StopMoving(); return true; } ((BaseAI)this).StopMoving(); LookAtPoint(position); LootTombstone(_pendingTombstone); _pendingTombstone = null; ClearTombstoneId(); RestoreFollowOrPatrol(); return false; } if (!((BaseAI)this).FoundPath() && num < 6f) { _tombstoneNavStuckTime += dt; if (_tombstoneNavStuckTime > 5f) { ((BaseAI)this).StopMoving(); LookAtPoint(position); LootTombstone(_pendingTombstone); _pendingTombstone = null; ClearTombstoneId(); RestoreFollowOrPatrol(); _tombstoneNavStuckTime = 0f; return false; } } else { _tombstoneNavStuckTime = 0f; } _tombstoneScanTimer -= dt; if (_tombstoneScanTimer <= 0f) { _tombstoneScanTimer = TombstoneScanInterval; } bool run = num > 10f; MHR_Go(dt, position, 2.5f, run, "Tombstone"); return true; } if (_pendingTombstone != null) { _pendingTombstone = null; ClearTombstoneId(); RestoreFollowOrPatrol(); return false; } ZNetView nview = base.m_nview; ZDO val = ((nview != null) ? nview.GetZDO() : null); if (val == null) { return false; } if (_tombRecoverSnooze > 0f) { _tombRecoverSnooze -= dt; return false; } _tombstoneScanTimer -= dt; if (_tombstoneScanTimer > 0f) { return false; } _tombstoneScanTimer = (MHR_Recover.IsRecovering((Component)(object)this) ? 1f : TombstoneScanInterval); TombStone[] array = Object.FindObjectsByType<TombStone>((FindObjectsSortMode)0); foreach (TombStone val2 in array) { if ((Object)(object)val2 == (Object)null) { continue; } ZNetView component2 = ((Component)val2).GetComponent<ZNetView>(); if ((Object)(object)component2 == (Object)null) { continue; } ZDO zDO = component2.GetZDO(); if (zDO == null || !MHR_IsOwnGrave(zDO, val, base.m_character)) { continue; } Container component3 = ((Component)val2).GetComponent<Container>(); if ((Object)(object)component3 == (Object)null) { continue; } Inventory inventory = component3.GetInventory(); if (inventory == null || inventory.NrOfItems() <= 0) { continue; } float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val2).transform.position); if (num2 <= ModConfig.TombstoneRecoveryRange.Value || MHR_Recover.IsRecovering((Component)(object)this)) { if (CompanionsPlugin.LogNormal) { CompanionsPlugin.Log.LogInfo((object)$"[Recovery] Found its own tombstone {num2:F0}m away with {component3.GetInventory().NrOfItems()} item(s); going to collect them"); } _pendingTombstone = val2; _tombstoneNavTimeout = TombstoneNavTimeoutMax; _tombstoneNavStuckTime = 0f; Vector3.Distance(((Component)this).transform.position, ((Component)val2).transform.position); if ((Object)(object)_talk != (Object)null) { _talk.Say(ModLocalization.Loc("hc_speech_tomb_found")); } SetFollowTarget(null); return true; } } return false; } private bool RecoverWait(float dt) { //IL_0018: 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_003c: Unknown result type (might be due to invalid IL or missing references) GameObject val = MHR_Owner.Go((Component)(object)this); if ((Object)(object)val == (Object)null) { return false; } if (Vector3.Distance(((Component)this).transform.position, val.transform.position) > 3f) { MHR_Go(dt, val.transform.position, 2.5f, run: true, "Recover"); } else { ((BaseAI)this).StopMoving(); } return true; } private void ClearTombstoneId() { ZNetView nview = base.m_nview; ZDO obj = ((nview != null) ? nview.GetZDO() : null); if (obj != null) { obj.Set(CompanionSetup.TombstoneIdHash, 0L); } } private void LootTombstone(TombStone tombstone) { //IL_0145: 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) Container component = ((Component)tombstone).GetComponent<Container>(); if ((Object)(object)component == (Object)null) { return; } Inventory inventory = component.GetInventory(); Character character = base.m_character; Humanoid val = (Humanoid)(object)((character is Humanoid) ? character : null); if (inventory == null || (Object)(object)val == (Object)null) { return; } Inventory inventory2 = val.GetInventory(); if (inventory2 == null) { return; } inventory.NrOfItems(); List<ItemData> list = new List<ItemData>(inventory.GetAllItems()); int num = 0; int num2 = 0; foreach (ItemData item in list) { if (inventory2.AddItem(item)) { inventory.RemoveItem(item); num++; } else { num2++; } } if (num > 0) { int width = inventory2.GetWidth(); int num3 = 0; foreach (ItemData allItem in inventory2.GetAllItems()) { allItem.m_gridPos = new Vector2i(num3 % width, num3 / width); num3++; } inventory2.m_onChanged?.Invoke(); } if (CompanionsPlugin.LogNormal) { CompanionsPlugin.Log.LogInfo((object)$"[Recovery] Collected {num} item(s) from its tombstone, {inventory.NrOfItems()} left"); } if (inventory.NrOfItems() == 0) { CompanionTombstoneResurrect.MHR_RemoveGravePinNear(((Component)tombstone).transform.position); } if ((Object)(object)_talk != (Object)null) { _talk.Say((num > 0) ? ModLocalization.Loc("hc_speech_tomb_recovered") : ModLocalization.Loc("hc_speech_tomb_empty")); } } internal static bool MHR_IsOwnGrave(ZDO tomb, ZDO me, Character ch) { if (tomb != null && me != null && tomb.GetLong(CompanionSetup.TombstoneIdHash, 0L) != 0L) { string text = tomb.GetString(CompanionSetup.MHR_TombCompanionIdHash, ""); if (!string.IsNullOrEmpty(text)) { return text == me.GetString(CompanionSetup.MHR_CompanionIdHash, ""); } string text2 = me.GetString(CompanionSetup.NameHash, ""); if (string.IsNullOrEmpty(text2)) { if ((Object)(object)ch == (Object)null) { goto IL_00c1; } text2 = ch.m_name; } if (tomb.GetString(ZDOVars.s_ownerName, "") == text2) { text = tomb.GetString(CompanionSetup.MHR_TombOwnerHash, ""); if (!string.IsNullOrEmpty(text)) { return text == me.GetString(CompanionSetup.OwnerHash, ""); } return true; } } goto IL_00c1; IL_00c1: return false; } internal string MHR_DiagFollowName() { GameObject follow = m_follow; if ((Object)(object)follow == (Object)null) { return "none"; } return ((Object)follow).name; } internal bool MHR_DiagFoundPath() { return ((BaseAI)this).FoundPath(); } public void DirectEngage(Character target) { SetAlerted(alert: true); CompanionCombatAI combatAI = _combatAI; if (combatAI == null) { CompanionsPlugin.Log.LogWarning((object)"[Direct] DirectEngage -> no CompanionCombatAI component; direct-order attack cannot use normal weapon/shield/flee logic"); return; } if (MHR_Threat.IsPassive(target)) { combatAI.EngagePrey(target); return; } combatAI.Order(target); combatAI.Engage(target); } internal void SetDirectedTombstoneRecovery(TombStone tombstone) { _pendingTombstone = tombstone; _tombstoneNavTimeout = TombstoneNavTimeoutMax; _tombstoneScanTimer = TombstoneScanInterval; _tombstoneNavStuckTime = 0f; SetFollowTarget(null); if ((Object)(object)_talk != (Object)null) { _talk.Say(ModLocalization.Loc("hc_speech_tomb_found")); } } public override bool UpdateAI(float dt) { //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_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_0258: 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_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_02fa: 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_04e8: 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_0385: 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_03a4: 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_0523: Unknown result type (might be due to invalid IL or missing references) //IL_049c: 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_0412: Unknown result type (might be due to invalid IL or missing references) //IL_041d: 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_03f0: 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_06fb: Unknown result type (might be due to invalid IL or missing references) //IL_0700: Unknown result type (might be due to invalid IL or missing references) //IL_0708: Unknown result type (might be due to invalid IL or missing references) //IL_070d: 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_0559: 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_0855: 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_0a8d: Unknown result type (might be due to invalid IL or missing references) //IL_0a9d: Unknown result type (might be due to invalid IL or missing references) if (!((BaseAI)this).UpdateAI(dt)) { AIGateDiag.Report((Component)(object)_setup, "vanilla BaseAI.UpdateAI() false"); return false; } if (WaterSafety.Tick((BaseAI)(object)this, dt)) { AIGateDiag.Report((Component)(object)_setup, "WaterSafety"); return true; } if (MHR_Mover.EscapeLava(this)) { AIGateDiag.Report((Component)(object)_setup, "Lava"); return true; } UpdateSleep(dt); if (((BaseAI)this).IsSleeping()) { AIGateDiag.Report((Component)(object)_setup, "Sleeping"); return true; } if (FreezeTimer > 0f) { FreezeTimer -= dt; AIGateDiag.Report((Component)(object)_setup, "FreezeTimer"); return true; } if ((Object)(object)_rest != (Object)null && _rest.IsResting) { AIGateDiag.Report((Component)(object)_setup, "Resting"); return true; } if (_isOnShip) { if ((Object)(object)_attachedShip != (Object)null && MHR_Board.ShouldLeaveSeat(this, _attachedShip)) { DetachFromShip(); return true; } UpdateShipAttach(); AIGateDiag.Report((Component)(object)_setup, "OnShip"); return true; } if ((Object)(object)_setup != (Object)null && (CompanionInteractPanel.IsOpenFor(_setup) || CompanionRadialMenu.IsOpenFor(_setup))) { ((BaseAI)this).StopMoving(); AIGateDiag.Report((Component)(object)_setup, "UI open (panel/radial)"); return true; } UpdateDrowning(dt); if (UpdateHazardRecovery(dt)) { AIGateDiag.Report((Component)(object)_setup, "HazardRecovery"); return true; } ReturnLogic.Tick((Component)(object)_setup); AIGateDiag.Report((Component)(object)_setup, null); bool lowStamina = (Object)(object)_companionStamina != (Object)null && _companionStamina.MaxStamina > 0f && _companionStamina.Stamina / _companionStamina.MaxStamina < 0.5f; MHR_Water.ApplyAgent(this, lowStamina); if ((Object)(object)base.m_character != (Object)null && base.m_character.IsSwimming()) { _continuousSwimTimer += dt; } else { _continuousSwimTimer = 0f; } CleanupBlacklist(dt); AutoPickup(dt); if (!MHR_Mover.OwnsMovement((Component)(object)this)) { UpdateFurnitureUnstuck(dt); } if ((Object)(object)m_follow != (Object)null && (Object)(object)_setup != (Object)null && _setup.GetFollow()) { Vector3 position = m_follow.transform.position; float num = Vector3.Distance(((Component)this).transform.position, position); if (num > FollowTeleportDist && (num > FollowTeleportDist * 1.5f || (!MHR_Mover.CanSee(((Component)this).transform.position, position) && !MHR_Mover.Progressing(this)))) { TeleportToFollowTarget(); } } if ((Object)(object)_rest != (Object)null && _rest.IsNavigating) { Vector3 navTarget = _rest.NavTarget; if (Vector3.Distance(((Component)this).transform.position, navTarget) < 2f) { _rest.ArriveAtNavTarget(); } else { MHR_Mover.Go(this, dt, navTarget, 1.2f, allowRun: true, "Bed"); } return true; } if (MHR_Hive.Active(this) && MHR_Hive.Update(this, dt)) { return true; } if (MHR_Board.Active(this) && MHR_Board.Update(this, dt)) { return true; } if ((Object)(object)PendingCartAttach != (Object)null) { _pendingCartTimeout -= dt; if (_pendingCartTimeout <= 0f || (Object)(object)PendingCartAttach == (Object)null) { CancelPendingCart(); } else { Vector3 val = PendingCartAttach.m_attachPoint.position - PendingCartAttach.m_attachOffset; val.y = ((Component)this).transform.position.y; if (Vector3.Distance(((Component)this).transform.position, val) < 2f) { ((Component)this).transform.position = val; if ((Object)(object)_body != (Object)null) { _body.position = val; _body.linearVelocity = Vector3.zero; } Vector3 val2 = ((Component)PendingCartAttach).transform.position - ((Component)this).transform.position; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude > 0.01f) { ((Component)this).transform.rotation = Quaternion.LookRotation(((Vector3)(ref val2)).normalized); } FreezeTimer = 1f; SetFollowTarget(((Component)PendingCartAttach).gameObject); PendingCartAttach.Interact(PendingCartHumanoid, false, false); PendingCartAttach = null; PendingCartHumanoid = null; } else { ((BaseAI)this).MoveTo(dt, val, 1f, true); } } return true; } if (PendingMoveTarget.HasValue) { _pendingMoveTimeout -= dt; if (_pendingMoveTimeout <= 0f) { CancelMoveTarget(); } else { float num2 = Vector3.Distance(((Component)this).transform.position, PendingMoveTarget.Value); if (num2 < 2f) { CancelMoveTarget(); } else { bool run = num2 > 10f; MHR_Go(dt, PendingMoveTarget.Value, 1f, run, "Command"); if (MHR_Mover.GaveUp(this)) { if (CompanionsPlugin.LogNormal) { CompanionsPlugin.Log.LogInfo((object)$"[Direct] Can't find a way to {PendingMoveTarget.Value:F1} - stopping here"); } CancelMoveTarget(); } } } return true; } if ((Object)(object)PendingDepositContainer != (Object)null) { _pendingDepositTimeout -= dt; if (_pendingDepositTimeout <= 0f || (Object)(object)PendingDepositContainer == (Object)null) { CancelPendingDeposit(); } else if (_depositChestOpen) { ((BaseAI)this).StopMoving(); LookAtPoint(((Component)PendingDepositContainer).transform.position); _depositWorkTimer -= dt; if (_depositWorkTimer <= 0f && _depositQueue.Count > 0) { _depositWorkTimer = 0.6f; ItemData val3 = _depositQueue[0]; _depositQueue.RemoveAt(0); Inventory inventory = PendingDepositContainer.GetInventory(); Humanoid pendingDepositHumanoid = PendingDepositHumanoid; Inventory val4 = ((pendingDepositHumanoid != null) ? pendingDepositHumanoid.GetInventory() : null); if (inventory != null && val4 != null && val4.ContainsItem(val3) && inventory.AddItem(val3)) { val4.RemoveItem(val3); _depositCount++; } } if (_depositQueue.Count == 0) { PendingDepositContainer.SetInUse(false); _depositChestOpen = false; if ((Object)(object)_talk != (Object)null) { _talk.Say((_depositCount > 0) ? ModLocalization.Loc("hc_speech_deposit_done") : ModLocalization.Loc("hc_speech_deposit_empty")); } CancelPendingDeposit(); } } else { Vector3 position2 = ((Component)PendingDepositContainer).transform.position; float num3 = Vector3.Distance(((Component)this).transform.position, position2); if (num3 < 2f && !_depositChestOpen && !MHR_Chests.Open(PendingDepositContainer)) { if (CompanionsPlugin.LogNormal) { CompanionsPlugin.Log.LogInfo((object)"[Deposit] Someone has the chest open - trying again later"); } CancelPendingDeposit(); } else if (num3 < 2f) { ((BaseAI)this).StopMoving(); LookAtPoint(position2); _depositChestOpen = true; _depositCount = 0; _depositWorkTimer = 0.6f; _depositQueue.Clear(); Humanoid pendingDepositHumanoid2 = PendingDepositHumanoid; if ((Object)(object)pendingDepositHumanoid2 != (Object)null) { Inventory inventory2 = pendingDepositHumanoid2.GetInventory(); if (inventory2 != null) { foreach (ItemData allItem in inventory2.GetAllItems()) { if (!CompanionInteract.ShouldKeep(allItem, pendingDepositHumanoid2)) { _depositQueue.Add(allItem); } } } } if (_depositQueue.Count == 0) { PendingDepositContainer.SetInUse(false); _depositChestOpen = false; if ((Object)(object)_talk != (Object)null) { _talk.Say(ModLocalization.Loc("hc_speech_deposit_empty")); } CancelPendingDeposit(); } } else { bool run2 = num3 > 10f; MHR_Go(dt, position2, 1.5f, run2, "Deposit"); } } return true; } if (UpdateTombstoneRecovery(dt)) { return true; } Character character = base.m_character; Humanoid val5 = (Humanoid)(object)((character is Humanoid) ? character : null); if (_isDvergerSupport && (Object)(object)val5 != (Object)null) { _healScanTimer -= dt; Character healTarget = _healTarget; if (_healScanTimer <= 0f) { _healScanTimer = 1f; _healTarget = FindHurtAlly(); } if ((Object)(object)_healTarget != (Object)null) { float maxHealth = _healTarget.GetMaxHealth(); if (_healTarget.GetHealth() <= 0f || maxHealth <= 0f || _healTarget.GetHealth() / maxHealth >= 0.7f) { _healTarget = null; ResetHealReachabilityTracking(); } } if ((Object)(object)_healTarget != (Object)(object)healTarget) { ResetHealReachabilityTracking(); } if ((Object)(object)_healTarget != (Object)null) { _healEquipTimer -= dt; if (_healEquipTimer <= 0f && !base.m_character.InAttack()) { _healEquipTimer = 1f; val5.EquipBestWeapon((Character)null, (StaticTarget)null, _healTarget, (Character)null); } UpdateHealBehavior(val5, dt); return true; } if ((_setup?.GetCombatStance() ?? 0) != 2) { _healEquipTimer -= dt; if (_healEquipTimer <= 0f && !base.m_character.InAttack()) { _healEquipTimer = 1f; val5.EquipBestWeapon(m_targetCreature, m_targetStatic, (Character)null, (Character)null); } } } UpdateDebugLog(dt); if ((Object)(object)m_follow != (Object)null && (Object)(object)_setup != (Object)null && _setup.GetFollow() && (Object)(object)base.m_character != (Object)null) { Character component = m_follow.GetComponent<Character>(); if ((Object)(object)component != (Object)null) { Player val6 = (Player)(object)((component is Player) ? component : null); if ((val6 == null || !((Character)val6).IsTeleporting()) && component.InInterior() != base.m_character.InInterior() && Vector3.Distance(((Component)this).transform.position, m_follow.transform.position) > 30f) { if (CompanionsPlugin.LogNormal) { CompanionsPlugin.Log.LogInfo((object)("[Follow] You went " + (component.InInterior() ? "into" : "out of") + " the dungeon - following you through")); } _combatAI?.Disengage(); TeleportToFollowTarget(); return true; } } } if ((Object)(object)_combatAI != (Object)null) { if (_combatAI.IsEngaged) { if (_combatAI.UpdateCombat(dt)) { return true; } } else { int num4 = _setup?.GetCombatStance() ?? 0; bool flag = (Object)(object)_combatAI != (Object)null && false; if (num4 != 1 && !flag) { Character val7 = _combatAI.PickTarget(); if ((Object)(object)val7 != (Object)null && IsPassiveAnimal(val7)) { val7 = null; } if ((Object)(object)val7 != (Object)null && (!MHR_Threat.IsAfterUs(val7) || MHR_Threat.IgnoredInWater(val7))) { val7 = null; } if ((Object)(object)val7 != (Object)null) { SetAlerted(alert: true); _combatAI.Engage(val7); if (_combatAI.UpdateCombat(dt)) { return true; } } else if ((Object)(object)m_targetCreature != (Object)null && !_combatAI.Holding && !MHR_Threat.IsPassive(m_targetCreature) && !MHR_Threat.IgnoredInWater(m_targetCreature) && _combatAI.CanGetAt(m_targetCreature)) { SetAlerted(alert: true); _combatAI.Engage(m_targetCreature); m_targetCreature = null; m_targetStatic = null; if (_combatAI.UpdateCombat(dt)) { return true; } } } else if (flag) { m_targetCreature = null; m_targetStatic = null; } } } if ((Object)(object)_companionStamina != (Object)null && _companionStamina.IsCrouching && base.m_character.IsSwimming()) { MHR_SetCrouch(sneak: false); } UpdateTorch(); if (MHR_SpearThrow.Drive(this, dt, (Object)(object)_combatAI != (Object)null && _combatAI.IsEngaged)) { ClearFollowMovementOverrides(); return true; } if (MHR_ToolKeeper.Drive(this, dt)) { return true; } if (MHR_Loot.Drive(this, dt)) { ClearFollowMovementOverrides(); return true; } ZNetView nview = base.m_nview; ZDO val8 = ((nview != null) ? nview.GetZDO() : null); if (((Object)(object)_harvest != (Object)null && _harvest.IsActive) || ((Object)(object)_repair != (Object)null && _repair.IsActive) || ((Object)(object)_smelt != (Object)null && _smelt.IsActive) || ((Object)(object)_farm != (Object)null && _farm.IsActive) || ((Object)(object)_upkeep != (Object)null && _upkeep.IsActive) || ((Object)(object)_cook != (Object)null && _cook.IsActive) || ((Object)(object)_doorHandler != (Object)null && _doorHandler.IsActive) || ((Object)(object)_hunt != (Object)null && _hunt.IsActive) || ((Object)(object)_fish != (Object)null && _fish.IsActive) || ((Object)(object)_idle != (Object)null && _idle.IsActive)) { ClearFollowMovementOverrides(); return true; } if ((Object)(object)m_follow != (Object)null) { MHR_Mover.FollowWatch(this, m_follow); if (MHR_Board.FollowHook(this, m_follow, dt)) { return true; } if (!MHR_Follow.Update(this, m_follow, dt)) { FollowWithFormation(m_follow, dt); } } else { ClearFollowMovementOverrides(); if (val8 != null && MHR_JobRules.IsJobMode(val8.GetInt(CompanionSetup.ActionModeHash, 0))) { ((BaseAI)this).StopMoving(); return true; } ((BaseAI)this).StopMoving(); } return true; } private void UpdateSleep(float dt) { //IL_0022: 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_007d: 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) Player val = null; if (m_wakeupRange > 0f || m_fallAsleepDistance > 0f) { val = Player.GetClosestPlayer(((Component)this).transform.position, m_wakeupRange); if ((Object)(object)val != (Object)null && (((Character)val).InGhostMode() || ((Character)val).IsDebugFlying())) { val = null; } } if (!((BaseAI)this).IsSleeping()) { if (m_fallAsleepDistance > 0f && ((Object)(object)val == (Object)null || Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position) > m_fallAsleepDistance)) { Sleep(); } return; } m_sleepTimer += dt; if (m_sleepTimer < m_sleepDelay) { return; } if (m_wakeupRange > 0f && (Object)(object)val != (Object)null) { Wakeup(); } else if (m_noiseWakeup) { Player playerNoiseRange = Player.GetPlayerNoiseRange(((Component)this).transform.position, m_maxNoiseWakeupRange); if ((Object)(object)playerNoiseRange != (Object)null && !((Character)playerNoiseRange).InGhostMode() && !((Character)playerNoiseRange).IsDebugFlying()) { Wakeup(); } } } private void UpdateDrowning(float dt) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //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_00c0: 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_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_010e: Unknown result type (might be due to invalid IL or missing references) if (!base.m_character.IsSwimming()) { _drownDamageTimer = 0f; return; } if ((Object)(object)_companionStamina == (Object)null || _companionStamina.Stamina > 0f) { _drownDamageTimer = 0f; return; } _drownDamageTimer += dt; if (_drownDamageTimer > 1f) { _drownDamageTimer = 0f; float damage = Mathf.Ceil(base.m_character.GetMaxHealth() / 20f); HitData val = new HitData(); val.m_damage.m_damage = damage; val.m_point = base.m_character.GetCenterPoint(); val.m_dir = Vector3.down; val.m_pushForce = 10f; val.m_hitType = (HitType)4; base.m_character.Damage(val); if (DrownEffects != null) { Vector3 position = ((Component)this).transform.position; position.y = base.m_character.GetLiquidLevel(); DrownEffects.Create(position, ((Component)this).transform.rotation, (Transform)null, 1f, -1, ZDOID.None); } } } private bool UpdateHazardRecovery(float dt) { //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_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_0258: 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_0267: 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_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_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_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_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_0291: 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_029a: 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_02a2: 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_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_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_019a: 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_01c1: 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_01d1: 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_01e6: 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_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_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) bool flag = base.m_character.GetSEMan().HaveStatusEffect(s_taredHash); bool flag2 = base.m_character.InLava(); bool flag3 = base.m_character.IsSwimming(); bool flag4 = false; string text = null; if (flag3 && (Object)(object)_companionStamina != (Object)null && _companionStamina.Stamina <= 0f) { flag4 = true; text = "DROWNING(no stamina)"; } if (!flag && !flag4 && !flag2) { _hazardRecoveryTimer = 0f; return false; } _hazardRecoveryTimer += dt; if ((!(_hazardRecoveryTimer < 0.1f) && (int)(_hazardRecoveryTimer * 10f) % 20 != 0) || !flag) { } if ((Object)(object)m_targetCreature != (Object)null) { ClearTargets(); } Vector3 val = Vector3.zero; float num = float.MaxValue; Vector3 position = ((Component)this).transform.position; float liquidLevel = base.m_character.GetLiquidLevel(); float[] array = new float[3] { 5f, 10f, 20f }; foreach (float num2 in array) { for (int j = 0; j < 12; j++) { float num3 = (float)j * 30f; Vector3 val2 = Quaternion.Euler(0f, num3, 0f) * Vector3.forward; Vector3 val3 = position + val2 * num2; if (!((Object)(object)ZoneSystem.instance != (Object)null)) { continue; } float solidHeight = ZoneSystem.instance.GetSolidHeight(val3); float num4 = Mathf.Max(liquidLevel, 30f); bool flag5 = ZoneSystem.instance.GetSolidHeight(val3 + val2 * 1.5f) < solidHeight - 3f || (Object)(object)MHR_Mover.FireArea(new Vector3(val3.x, solidHeight, val3.z), 0.5f) != (Object)null || MHR_Mover.Lava(new Vector3(val3.x, solidHeight, val3.z)) || (Object)(object)MHR_Mover.SpikeNear(new Vector3(val3.x, solidHeight, val3.z), 0.7f) != (Object)null; if (solidHeight > num4 && !flag5) { float num5 = Vector3.Distance(position, val3); if (num5 < num) { num = num5; val = val2; } } } if (val != Vector3.zero) { break; } } if (val != Vector3.zero) { ((BaseAI)this).MoveTowards(val, true); } else if ((Object)(object)m_follow != (Object)null) { Vector3 val4 = m_follow.transform.position - position; Vector3 normalized = ((Vector3)(ref val4)).normalized; ((BaseAI)this).MoveTowards(normalized, true); } float num6 = ((flag3 && (Object)(object)_companionStamina != (Object)null && _companionStamina.Stamina <= 0f) ? 6f : 10f); if (_hazardRecoveryTimer > num6 && (Object)(object)m_follow != (Object)null && (Object)(object)_setup != (Object)null && _setup.GetFollow()) { TeleportToFollowTarget(); _hazardRecoveryTimer = 0f; _continuousSwimTimer = 0f; } return true; } private void CleanupBlacklist(float dt) { //IL_006f: 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) _blacklistCleanupTimer += dt; if (_blacklistCleanupTimer < 30f) { return; } _blacklistCleanupTimer = 0f; if (_targetBlacklist.Count == 0) { return; } float time = Time.time; List<Vector3Int> list = null; foreach (KeyValuePair<Vector3Int, float> item in _targetBlacklist) { if (time - item.Value >= 30f) { if (list == null) { list = new List<Vector3Int>(); } list.Add(item.Key); } } if (list != null) { for (int i = 0; i < list.Count; i++) { _targetBlacklist.Remove(list[i]); } } } private void AutoPickup(float dt) { //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_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_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_016d: 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_017f: 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_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_019e: 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_01a9: Unknown result type (might be due to invalid IL or missing references) Character character = base.m_character; Humanoid val = (Humanoid)(object)((character is Humanoid) ? character : null); if ((Object)(object)val == (Object)null) { return; } Inventory inventory = val.GetInventory(); if (inventory == null) { return; } Vector3 val2 = ((Component)this).transform.position + Vector3.up; int num = Physics.OverlapSphereNonAlloc(val2, AutoPickupRange, _autoPickupBuffer, _autoPickupMask); for (int i = 0; i < num; i++) { Collider val3 = _autoPickupBuffer[i]; if ((Object)(object)val3 == (Object)null || (Object)(object)val3.attachedRigidbody == (Object)null) { continue; } ItemDrop component = ((Component)val3.attachedRigidbody).GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null || !component.m_autoPickup) { continue; } ZNetView component2 = ((Component)component).GetComponent<ZNetView>(); if ((Object)(object)component2 == (Object)null || !component2.IsValid()) { continue; } if (!component.CanPickup(true)) { component.RequestOwn(); } else { if (component.InTar()) { continue; } component.Load(); _ = component.m_itemData?.m_shared?.m_name; if (inventory.CanAddItem(component.m_itemData, -1) && !(inventory.GetTotalWeight() + component.m_itemData.GetWeight(-1) > CompanionTierData.CarryLimit((Component)(object)this))) { if (Vector3.Distance(((Component)component).transform.position, val2) < 0.3f) { val.Pickup(((Component)component).gameObject, false, false); continue; } Vector3 val4 = val2 - ((Component)component).transform.position; Vector3 normalized = ((Vector3)(ref val4)).normalized; Transform transform = ((Component)component).transform; transform.position += normalized * 15f * dt; } } } } private void UpdateFurnitureUnstuck(float dt) { //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_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_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_012e: 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_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_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_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_01c2: 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_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_01d8: 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_020a: 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_0225: 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_024d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.m_character == (Object)null) { return; } Vector3 velocity = base.m_character.GetVelocity(); float magnitude = ((Vector3)(ref velocity)).magnitude; bool flag = (Object)(object)m_follow != (Object)null || PendingMoveTarget.HasValue || (Object)(object)PendingCartAttach != (Object)null || MHR_Board.Active(this) || MHR_Hive.Active(this) || ((Object)(object)_rest != (Object)null && _rest.IsNavigating); if (magnitude < 0.1f && flag) { _furnitureStuckTimer += dt; } else { _furnitureStuckTimer = 0f; } if (_furnitureStuckTimer < 3f) { return; } Vector3 val = ((Component)this).transform.position + Vector3.up * 0.5f; int mask = LayerMask.GetMask(new string[2] { "piece", "piece_nonsolid" }); RaycastHit val2 = default(RaycastHit); if (!Physics.Raycast(val, Vector3.down, ref val2, 1.5f, mask)) { return; } Bed componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Bed>(); if (!((Object)(object)componentInParent == (Object)null)) { _furnitureStuckTimer = 0f; Vector3 val3 = ((Component)this).transform.position - ((Component)componentInParent).transform.position; val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = ((Component)this).transform.forward; } val3 = ((Vector3)(ref val3)).normalized; Vector3 val4 = ((Component)componentInParent).transform.position + val3 * 2.5f; int mask2 = LayerMask.GetMask(new string[4] { "Default", "static_solid", "terrain", "piece" }); RaycastHit val5 = default(RaycastHit); if (Physics.Raycast(val4 + Vector3.up * 5f, Vector3.down, ref val5, 10f, mask2)) { val4.y = ((RaycastHit)(ref val5)).point.y; } else { val4.y = ((Component)this).transform.position.y - 0.5f; } ((Component)this).transform.position = val4; if ((Object)(object)_body != (Object)null) { _body.position = val4; _body.linearVelocity = Vector3.zero; ResetLiquidState(); } } } internal void TeleportToFollowTarget() { //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_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_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_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_006b: 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_0089: 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)m_follow == (Object)null)) { Vector3 position = m_follow.transform.position; Vector3 preferDir = -m_follow.transform.forward; preferDir.y = 0f; if (((Vector3)(ref preferDir)).sqrMagnitude < 0.01f) { preferDir = Vector3.back; } else { ((Vector3)(ref preferDir)).Normalize(); } Vector3 position2 = MHR_SafeSpotNear(position, preferDir); ((Component)this).transform.position = position2; Rigidbody body = _body; if ((Object)(object)body != (Object)null) { body.position = position2; body.linearVelocity = Vector3.zero; } ZNetView nview = base.m_nview; if (((nview != null) ? nview.GetZDO() : null) != null) { base.m_nview.GetZDO().SetPosition(position2); } } } internal static Vector3 MHR_SafeSpotNear(Vector3 at, Vector3 preferDir) { //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_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_01ad: 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_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_00de: 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) //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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_013b: 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_0167: 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) Vector3 val = at + Vector3.up * 1.2f; int mask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "terrain", "piece", "vehicle" }); float num = ((((Vector3)(ref preferDir)).sqrMagnitude > 0.01f) ? (Mathf.Atan2(preferDir.z, preferDir.x) * 57.29578f) : 0f); RaycastHit val3 = default(RaycastHit); for (int i = 0; i < 2; i++) { float num2 = ((i == 0) ? 2f : 1.2f); for (int j = 0; j < 8; j++) { float num3 = (num + (float)(((j % 2 == 0) ? 1 : (-1)) * ((j + 1) / 2)) * 45f) * ((float)Math.PI / 180f); Vector3 val2 = at + new Vector3(Mathf.Cos(num3), 0f, Mathf.Sin(num3)) * num2 + Vector3.up * 1.2f; if (!Physics.Linecast(val, val2, mask, (QueryTriggerInteraction)1) && Physics.Raycast(val2, Vector3.down, ref val3, 3f, mask, (QueryTriggerInteraction)1) && !(Mathf.Abs(((RaycastHit)(ref val3)).point.y - at.y) > 1.2f) && !(MHR_Water.DepthAt(((RaycastHit)(ref val3)).point) > 0.4f) && !((Object)(object)MHR_Mover.FireArea(((RaycastHit)(ref val3)).point, 0.5f) != (Object)null) && !((Object)(object)MHR_Mover.SpikeNear(((RaycastHit)(ref val3)).point, 0.7f) != (Object)null) && !MHR_Mover.Lava(((RaycastHit)(ref val3)).point)) { return ((RaycastHit)(ref val3)).point; } } } return at; } internal void MHR_PlaceAt(Vector3 position) { //IL_0006: 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_002c: 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) ((Component)this).transform.position = position; if ((Object)(object)_body != (Object)null) { _body.position = position; _body.linearVelocity = Vector3.zero; } ((BaseAI)this).StopMoving(); ZNetView nview = base.m_nview; if (((nview != null) ? nview.GetZDO() : null) != null) { base.m_nview.GetZDO().SetPosition(position); } } private Character FindHurtAlly() { //IL_009b: 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) Character result = null; float num = 0.7f; string text = GetCompanionOwnerId(); if (string.IsNullOrEmpty(text) && (Object)(object)Player.m_localPlayer != (Object)null) { text = Player.m_localPlayer.GetPlayerID().ToString(); } foreach (Character allCharacter in Character.GetAllCharacters()) { if ((Object)(object)allCharacter == (Object)(object)base.m_character || allCharacter.GetHealth() <= 0f) { continue; } float maxHealth = allCharacter.GetMaxHealth(); if (!(maxHealth <= 0f)) { float num2 = allCharacter.GetHealth() / maxHealth; if (!(num2 >= 0.7f) && !(Vector3.Distance(((Component)this).transform.position, ((Component)allCharacter).transform.position) > 50f) && IsHealCandidateOwnedByCompanionOwner(allCharacter, text) && num2 < num) { num = num2; result = allCharacter; } } } return result; } private void ResetHealReachabilityTracking() { _healUnreachableTimer = 0f; _healLastDistance = -1f; } private void UpdateHealBehavior(Humanoid humanoid, float dt) { //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_0110: 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_00cd: 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) if ((Object)(object)_healTarget == (Object)null || _healTarget.GetHealth() <= 0f) { ResetHealReachabilityTracking(); return; } ItemData currentWeapon = humanoid.GetCurrentWeapon(); if (currentWeapon == null) { ResetHealReachabilityTracking(); return; } float num = Vector3.Distance(((Component)this).transform.position, ((Component)_healTarget).transform.position) - _healTarget.GetRadius(); float aiAttackRange = currentWeapon.m_shared.m_aiAttackRange; _healLogTimer -= dt; if (_healLogTimer <= 0f) { _healLogTimer = 3f; } if (num < aiAttackRange) { ResetHealReachabilityTracking(); ((BaseAI)this).StopMoving(); ((BaseAI)this).LookAt(_healTarget.GetTopPoint()); if (CanAttackNow(currentWeapon) && ((BaseAI)this).IsLookingAt(((Component)_healTarget).transform.position, currentWeapon.m_shared.m_aiAttackMaxAngle, currentWeapon.m_shared.m_aiInvertAngleCheck)) { base.m_character.StartAttack(_healTarget, false); } return; } MHR_Go(dt, ((Component)_healTarget).transform.position, 1f, num > 10f, "Heal"); bool num2 = ((BaseAI)this).FoundPath(); bool flag = _healLastDistance < 0f || num < _healLastDistance - 0.2f; Vector3 velocity = base.m_character.GetVelocity(); float magnitude = ((Vector3)(ref velocity)).magnitude; _healLastDistance = num; if (!num2 || (magnitude < 0.3f && !flag)) { _healUnreachableTimer += dt; } else { _healUnreachableTimer = 0f; } if (_healUnreachableTimer >= 6f) { _healTarget = null; ResetHealReachabilityTracking(); } } private void UpdateDebugLog(float dt) { } private void ClearFollowMovementOverrides() { base.m_character.SetWalk(false); if ((Object)(object)_zanim != (Object)null) { _zanim.SetBool(s_crouching, false); } if ((Object)(object)_companionStamina != (Object)null) { _companionStamina.IsCrouching = false; } } private void FollowWithFormation(GameObject target, float dt) { //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_0114: 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_00a4: 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_00cf: 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_0276: 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_028a: 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_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0295: 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_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_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_02b6: 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) //IL_01d8: 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_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_0216: 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) if ((Object)(object)target == (Object)null) { ((BaseAI)this).StopMoving(); return; } bool flag = !base.m_character.IsSwimming() && (Object)(object)_companionStamina != (Object)null && _companionStamina.MaxStamina > 0f && _companionStamina.Stamina / _companionStamina.MaxStamina < 0.5f; if ((base.m_character.IsSwimming() || base.m_character.InWater()) && !flag) { if (Vector3.Distance(((Component)this).transform.position, target.transform.position) > 3f) { Vector3 val = target.transform.position - ((Component)this).transform.position; val.y = 0f; ((Vector3)(ref val)).Normalize(); ((BaseAI)this).MoveTowards(val, false); } else { ((BaseAI)this).StopMoving(); } ClearFollowMovementOverrides(); return; } if (_formationSlot < 0 && (Object)(object)_setup != (Object)null) { _formationSlot = _setup.AssignFormationSlot(); } float num = Vector3.Distance(((Component)this).transform.position, target.transform.position); Player component = target.GetComponent<Player>(); bool flag2 = (Object)(object)component != (Object)null && ((Character)component).IsCrouching(); bool flag3 = (Object)(object)component != (Object)null && ((Character)component).GetWalk() && !((Character)component).IsRunning(); bool flag4 = (Object)(object)component != (Object)null && ((Character)component).IsRunning(); float num2 = (_wasInFormation ? FormationCatchupDist : (FormationCatchupDist - 2f)); if (num > num2 || _formationSlot < 0) { if (_lastFollowMode != 0) { _lastFollowMode = 0; } _wasInFormation = false; ((BaseAI)this).Follow(target, dt); if (!((BaseAI)this).FoundPath() && num > 5f) { Vector3 moveDir = target.transform.position - ((Component)this).transform.position; moveDir.y = 0f; if (((Vector3)(ref moveDir)).sqrMagnitude > 0.01f) { ((Vector3)(ref moveDir)).Normalize(); base.m_character.SetMoveDir(moveDir); base.m_character.SetRun(true); } } ClearFollowMovementOverrides(); return; } _wasInFormation = true; if (num < 5f) { if (_lastFollowMode != 1) { _lastFollowMode = 1; } ((BaseAI)this).Follow(target, dt); ApplyPlayerMovementMatch(flag2, flag3, flag4); return; } Vector3 forward = target.transform.forward; Vector3 right = target.transform.right; float num3 = 1f; Vector3 val2 = GetFormationOffset(_formationSlot, forward, right) * num3; Vector3 val3 = target.transform.position + val2; if (Vector3.Distance(((Component)this).transform.position, val3) < 2f) { if (_lastFollowMode != 2) { _lastFollowMode = 2; } ((BaseAI)this).Follow(target, dt); ApplyPlayerMovementMatch(flag2, flag3, flag4); } else { bool run = !(flag2 || flag3) && (flag4 || num > 10f); MHR_Go(dt, val3, 1f, run, "Formation"); ApplyPlayerMovementMatch(flag2, flag3, flag4); } } private bool CanAttackNow(ItemData weapon) { if (weapon == null) { return false; } if (Time.time - weapon.m_lastAttackTime > weapon.m_shared.m_aiAttackInterval && ((BaseAI)this).CanUseAttack(weapon)) { return !IsTakingOff(); } return false; } internal void MHR_SetCrouch(bool sneak) { if (sneak && (((Object)(object)_companionStamina != (Object)null && _companionStamina.Stamina <= 0f) || base.m_character.IsSwimming())) { sneak = false; } if ((Object)(object)_companionStamina != (Object)null) { _companionStamina.IsCrouching = sneak; } if ((Object)(object)_zanim != (Object)null) { _zanim.SetBool(s_crouching, sneak); } } internal void MHR_FollowFallback(GameObject target, float dt) { ((BaseAI)this).Follow(target, dt); } private void ApplyPlayerMovementMatch(bool sneak, bool walk, bool run) { if (sneak && (Object)(object)_companionStamina != (Object)null && _companionStamina.Stamina <= 0f) { sneak = false; } if ((Object)(object)_companionStamina != (Object)null) { _companionStamina.IsCrouching = sneak; } if (sneak) { base.m_character.SetRun(false); base.m_character.SetWalk(true); if ((Object)(object)_zanim != (Object)null) { _zanim.SetBool(s_crouching, true); } } else if (walk) { base.m_character.SetRun(false); base.m_character.SetWalk(true); if ((Object)(object)_zanim != (Object)null) { _zanim.SetBool(s_crouching, false); } } else { base.m_character.SetWalk(false); if ((Object)(object)_zanim != (Object)null) { _zanim.SetBool(s_crouching, false); } } } private static Vector3 GetFormationOffset(int slot, Vector3 fwd, Vector3 right) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_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_0037: 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_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_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_0069: 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_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_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_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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_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_00da: Unknown result type (might be due to invalid IL or missing references) switch (slot) { case 0: return right * FormationOffset - fwd * 1f; case 1: return -right * FormationOffset - fwd * 1f; case 2: return right * (FormationOffset * 0.67f) - fwd * 3f; case 3: return -right * (FormationOffset * 0.67f) - fwd * 3f; default: { float num = ((float)(slot - 4) * 45f + 135f) * ((float)Math.PI / 180f); return (right * Mathf.Cos(num) + fwd * Mathf.Sin(num)) * FormationOffset; } } } private string GetCompanionOwnerId() { ZNetView nview = base.m_nview; ZDO val = ((nview != null) ? nview.GetZDO() : null); if (val == null) { return string.Empty; } return val.GetString(CompanionSetup.OwnerHash, string.Empty); } private bool IsHealCandidateOwnedByCompanionOwner(Character candidate, string ownerId) { if ((Object)(object)candidate == (Object)null || string.IsNullOrEmpty(ownerId)) { return false; } if (candidate.IsPlayer()) { Player val = (Player)(object)((candidate is Player) ? candidate : null);