Пример #1
0
        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);
        }
Пример #2
0
        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;
                    }
                }
            }
        }
Пример #3
0
 public override float GetScore(BaseContext c, Vector3 option)
 {
     if (c.AIAgent.IsNavRunning())
     {
         NavMeshAgent getNavAgent = c.AIAgent.GetNavAgent;
         if (Object.op_Inequality((Object)getNavAgent, (Object)null) && (!getNavAgent.get_hasPath() || getNavAgent.get_isPathStale() || (getNavAgent.get_pathStatus() == 1 || getNavAgent.get_pathStatus() == 2)))
         {
             Vector3 vector3 = Vector3.op_Subtraction(c.lastSampledPosition, option);
             if ((double)((Vector3) ref vector3).get_sqrMagnitude() < 0.100000001490116)
             {
                 return(0.0f);
             }
         }
     }
     return(1f);
 }