public override bool Update(ref PathFinderMove move)
        {
            if (!SpatialGraphManager.Instance.IsInPathableSpace(CurrentPosition))
            {
                SetNewState(PathFinder.MoveState.StartRecover);
                return true;
            }
            //find path
            List<Vector2> path = CurrentPath;
            path.Clear();
            bool retVal = SpatialGraphManager.Instance.GetPath(CurrentPosition, CurrentDestination, ref path);

            if( retVal )
            {
                move.LastResult = PathFinder.MoveResult.PathFound;
                CurrentPathIndex = 0;

                SetNewState( PathFinder.MoveState.Follow );
                //Keep ticking
                return true;
            }
            else
            {
                move.LastResult = PathFinder.MoveResult.PathNotFound;
            }

            //We're done if path failed
            return false;
        }
        public override bool Update(ref PathFinderMove move)
        {
            //Make sure we can keep heading to our current subgoal
            List<Vector2> currentPath = CurrentPath;
            int currentPathIndex = CurrentPathIndex;

            //has the destination changed
            Vector2 vDest = currentPath[currentPath.Count-1];
            if( vDest == CurrentDestination )
            {
                if( SpatialGraphManager.Instance.CanGo( CurrentPosition, currentPath[currentPathIndex] ) )
                {
                    SetNewState( PathFinder.MoveState.Follow );
                    return true;
                }
                else if (!SpatialGraphManager.Instance.CanGo(CurrentPosition, CurrentPosition))
                {
                    //are we blocked
                    SetNewState( PathFinder.MoveState.Recover );
                    return true;
                }
            }

            //otherwise, try again
            SetNewState(PathFinder.MoveState.Start);
            return true;
        }
        public void FindNextMove(ref Vector2 from, ref Vector2 to, float arrivalDist, ref PathFinderMove move)
        {
            _currentPos = from;
            _currentDest = to;
            _arrivalDist = arrivalDist;

            move.LastResult = MoveResult.PathFound;
            while (true)
            {
                if (!GetCurrentState().Update(ref move))
                    break;
            }
        }
        public override bool Update(ref PathFinderMove move)
        {
            //are we back in pathable space?
            if( SpatialGraphManager.Instance.IsInPathableSpace( CurrentPosition ) )
            {
                SetNewState( PathFinder.MoveState.Follow );
                return true;
            }

            List<Vector2> currentPath = CurrentPath;
            int currentPathIndex = CurrentPathIndex;

            //otherwise, head toward our current pathnode
            move.MoveDir = Vector2.Normalize( currentPath[currentPathIndex] - CurrentPosition );

            return false;
        }
        public override bool Update(ref PathFinderMove move)
        {
            //check our current path index
            const int iLookAheadCount = 3;

            List<Vector2> currentPath = CurrentPath;
            int nextPathIndex = CurrentPathIndex;

            //Are we at our goal index
            if( nextPathIndex == currentPath.Count - 1 )
            {
                move.NextSubgoalPos = currentPath[nextPathIndex];
                //check distance to goal
                float sqDist = Vector2.DistanceSquared( CurrentPosition, move.NextSubgoalPos );
                float arrivalDistSq = CurrentArrivalDist;
                arrivalDistSq *= arrivalDistSq;
                if( sqDist <= arrivalDistSq )
                {
                    //don't set move dir (we've arrived)
                    move.LastResult = PathFinder.MoveResult.Arrived;
                    SetNewState( PathFinder.MoveState.Validate );
                    return false;
                }
            }
            else
            {
                //otherwise, see if we can advance our next subgoal
                for( int i = 0 ; i < iLookAheadCount && (nextPathIndex+1) < currentPath.Count; i++ )
                {
                    if (SpatialGraphManager.Instance.CanGo(CurrentPosition, currentPath[nextPathIndex + 1]))
                    {
                        ++nextPathIndex;
                    }
                }

                CurrentPathIndex = nextPathIndex;
                move.NextSubgoalPos = currentPath[nextPathIndex];
            }

            //Move dir is normalized towards next subgoal
            move.MoveDir = Vector2.Normalize( move.NextSubgoalPos - CurrentPosition );
            //we're done this round
            SetNewState( PathFinder.MoveState.Validate );
            return false;
        }
        public override bool Update(ref PathFinderMove move)
        {
            //are we back in pathable space?
            if( SpatialGraphManager.Instance.IsInPathableSpace( CurrentPosition ) )
            {
                SetNewState( PathFinder.MoveState.Start );
                return true;
            }

            //find the nearest non-blocked neighbor I can move to
            Vector2 vGoTo;
            if( SpatialGraphManager.Instance.FindNearestNonBlocked( CurrentPosition, out vGoTo) )
            {
                move.MoveDir = Vector2.Normalize( vGoTo - CurrentPosition );
            }
            else
            {
                move.LastResult = PathFinder.MoveResult.PathNotFound;
            }

            return false;
        }
 public abstract bool Update(ref PathFinderMove move);