public virtual TaskStatus OnUpdate() { AgentActor agent = this.Agent; if (Object.op_Equality((Object)agent.Partner, (Object)null)) { return((TaskStatus)1); } AgentProfile agentProfile = Singleton <Resources> .Instance.AgentProfile; LocomotionProfile locomotionProfile = Singleton <Resources> .Instance.LocomotionProfile; NavMeshAgent navMeshAgent = agent.NavMeshAgent; Vector3 destination = this.DesiredPosition(agent.Partner); if ((double)Vector3.Distance(destination, agent.Position) >= (double)agentProfile.RestDistance) { this.SetDestination(destination); this._moved = true; } else { NavMeshPathStatus pathStatus = navMeshAgent.get_pathStatus(); if (pathStatus == 1 || pathStatus == 2) { if ((double)Vector3.Distance(agent.Position, agent.Partner.Position) < (double)agentProfile.RestDistance) { this.Stop(); if (agent.IsRunning) { agent.IsRunning = false; } } } else if (!navMeshAgent.get_pathPending()) { if ((double)navMeshAgent.get_remainingDistance() < (double)agentProfile.RestDistance && agent.IsRunning) { agent.IsRunning = false; } if (this._moved && (double)navMeshAgent.get_remainingDistance() < (double)navMeshAgent.get_stoppingDistance()) { this.Stop(); this._moved = false; } } } return((TaskStatus)3); }
protected override void OnUpdate(PlayerActor player, ref Actor.InputInfo info) { AgentActor agentPartner = player.AgentPartner; if (Object.op_Equality((Object)agentPartner, (Object)null)) { return; } AgentProfile agentProfile = Singleton <Resources> .Instance.AgentProfile; LocomotionProfile locomotionProfile = Singleton <Resources> .Instance.LocomotionProfile; NavMeshAgent navMeshAgent1 = player.NavMeshAgent; if (navMeshAgent1.get_isOnOffMeshLink()) { this.Stop(player); OffMeshLinkData currentOffMeshLinkData1 = navMeshAgent1.get_currentOffMeshLinkData(); if (!Object.op_Inequality((Object)((OffMeshLinkData) ref currentOffMeshLinkData1).get_offMeshLink(), (Object)null)) { return; } NavMeshAgent navMeshAgent2 = player.NavMeshAgent; M0 m0; if (navMeshAgent2 == null) { m0 = (M0)null; } else { OffMeshLinkData currentOffMeshLinkData2 = navMeshAgent2.get_currentOffMeshLinkData(); m0 = ((Component)((OffMeshLinkData) ref currentOffMeshLinkData2).get_offMeshLink())?.GetComponent <ActionPoint>(); } ActionPoint point = (ActionPoint)m0; if (!Object.op_Inequality((Object)point, (Object)null) || !point.OffMeshAvailablePoint((Actor)player)) { return; } if (point is DoorPoint) { player.CurrentPoint = point; player.PlayerController.ChangeState("DoorOpen", point, (Action)null); } else { player.CurrentPoint = point; player.PlayerController.ChangeState("Move", point, (Action)null); } } else { Vector3 destination = this.DesiredPosition((Actor)agentPartner); if ((double)Vector3.Distance(destination, player.Position) >= (double)agentProfile.RestDistance) { this.SetDestination(player, destination); this._moved = true; } else { NavMeshPathStatus pathStatus = navMeshAgent1.get_pathStatus(); if (pathStatus == 1 || pathStatus == 2) { if ((double)Vector3.Distance(player.Position, agentPartner.Position) >= (double)agentProfile.RestDistance) { return; } this.Stop(player); if (!player.IsRunning) { return; } player.IsRunning = false; } else { if (navMeshAgent1.get_pathPending()) { return; } if ((double)navMeshAgent1.get_remainingDistance() < (double)agentProfile.RestDistance && player.IsRunning) { player.IsRunning = false; } if (!this._moved || (double)navMeshAgent1.get_remainingDistance() >= (double)navMeshAgent1.get_stoppingDistance()) { return; } this.Stop(player); this._moved = false; } } } }
protected override bool HasPath() { NavMeshAgent navMeshAgent = this.Agent.NavMeshAgent; return(navMeshAgent.get_hasPath() && (double)navMeshAgent.get_remainingDistance() > (double)navMeshAgent.get_stoppingDistance()); }