Ejemplo n.º 1
0
        private bool SetDestination(Vector3 destination)
        {
            bool         flag         = false;
            NavMeshAgent navMeshAgent = this.Agent.NavMeshAgent;

            if (!navMeshAgent.get_isOnNavMesh() || !navMeshAgent.get_path().get_corners().IsNullOrEmpty <Vector3>())
            {
                return(flag);
            }
            if (this._path == null)
            {
                this._path = new NavMeshPath();
            }
            if (navMeshAgent.CalculatePath(destination, this._path))
            {
                if (this._path.get_status() != null)
                {
                    this._rejected = true;
                }
                if (!navMeshAgent.SetPath(this._path))
                {
                    ;
                }
            }
            return(flag);
        }
Ejemplo n.º 2
0
 public bool TryGetRemainingDistance(
     NavMeshAgent agent,
     Actor actor,
     out float remainingDistance)
 {
     remainingDistance = float.MaxValue;
     if (Object.op_Equality((Object)agent, (Object)null) || !((Behaviour)agent).get_isActiveAndEnabled() || !agent.get_isOnNavMesh())
     {
         return(false);
     }
     if (!agent.get_hasPath())
     {
         return(agent.get_pathPending());
     }
     Vector3[] corners = agent.get_path().get_corners();
     remainingDistance = 0.0f;
     for (int index = 0; index < corners.Length - 1; ++index)
     {
         remainingDistance += Vector3.Distance(corners[index], corners[index + 1]);
     }
     return(true);
 }