WaitForPath() public static method

public static WaitForPath ( Path p ) : void
p Path
return void
Example #1
0
    private bool AllObjectivesReachable()
    {
        bool result = false;

        if (AstarPath.active != null)
        {
            //Add our test to the graph
            _collider.enabled = true;
            AstarPath.active.UpdateGraphs(_collider.bounds);

            //Check if we can still reach each objective
            Path path = null;
            bool allPathsSuccessful = true;
            foreach (var spawner in Spawner.Instances)
            {
                foreach (var objective in Objective.Instances)
                {
                    path = ABPath.Construct(spawner.transform.position, objective.transform.position);
                    AstarPath.StartPath(path, true);
                    AstarPath.WaitForPath(path);

                    allPathsSuccessful = path.error == false && Vector3.Distance(objective.transform.position, path.vectorPath.Last()) < SAME_POSITION_EPSILON;

                    if (allPathsSuccessful == false)
                    {
                        break;
                    }
                }

                if (allPathsSuccessful == false)
                {
                    break;
                }
            }

            //Remove our test from the graph
            _collider.enabled = false;
            AstarPath.active.UpdateGraphs(_collider.bounds);

            result = allPathsSuccessful;
        }

        return(result);
    }
Example #2
0
    public void SearchPath(VInt3 target)
    {
        if (this.path != null)
        {
            bool flag = true;
            long num  = this.targetSearchPos.XZSqrMagnitude(ref target);
            if (num < 1L)
            {
                if (this.targetReached)
                {
                    num = this.actor.get_handle().location.XZSqrMagnitude(ref this.targetPos);
                    if (num < 100L)
                    {
                        flag = false;
                    }
                }
                else
                {
                    flag = false;
                }
            }
            if (!flag)
            {
                return;
            }
        }
        int num2;

        this.targetPosIsValid = PathfindingUtility.ValidateTarget(this.GetFeetPosition(), target, out this.targetPos, out num2);
        VInt3 feetPosition = this.GetFeetPosition();
        int   actorCamp    = this.actor.get_handle().TheActorMeta.ActorCamp;

        this.seeker.RecyclePath();
        this.path = null;
        this.path = this.seeker.StartPathEx(ref feetPosition, ref this.targetPos, actorCamp, null, -1);
        if (this.path == null)
        {
            return;
        }
        this.targetSearchPos = target;
        this.canMove         = false;
        AstarPath.WaitForPath(this.path);
    }