protected boolean headToNextNode ( Pathable pable , long startstamp , long now ) { if ( _niter == null ) { throw new IllegalStateException ( "headToNextNode() called before init()" ) ; } // check to see if we've completed our path if ( ! _niter . hasNext ( ) ) { // move the pathable to the location of our last destination pable . setLocation ( _dest . loc . x , _dest . loc . y ) ; pable . pathCompleted ( now ) ; return true ; } // our previous destination is now our source _src = _dest ; // pop the next node off the path _dest = getNextNode ( ) ; // adjust the pathable's orientation if ( _dest . dir != NONE ) { pable . setOrientation ( _dest . dir ) ; } // make a note of when we started traversing this node _nodestamp = startstamp ; // figure out the distance from source to destination _seglength = MathUtil . distance ( _src . loc . x , _src . loc . y , _dest . loc . x , _dest . loc . y ) ; // if we're already there (the segment length is zero), we skip to // the next segment if ( _seglength == 0 ) { return headToNextNode ( pable , startstamp , now ) ; } // now update the pathable's position based on our progress thus far return tick ( pable , now ) ; }
Place the pathable moving along the path at the end of the previous path node face it appropriately for the next node and start it on its way . Returns whether the pathable position moved .