public void followUpdate() { ObjectStub followObj = (ObjectStub) followTarget.getEntity(Namespace.MOB); Point followLoc = followObj.getWorldNode().getLoc(); InterpolatedWorldNode node = obj.getWorldNode(); Point myLoc = node.getLoc(); long oid = obj.getOid(); float fdist = Point.distanceTo(followLoc, destLoc); float dist = Point.distanceTo(followLoc, myLoc); if (Log.loggingDebug) Log.debug( "BaseBehavior.followUpdate: oid = " + oid + "; myLoc = " + myLoc + "; followLoc = " + followLoc + "; fdist = " + fdist + "; dist = " + dist); long msToSleep = (long) 500; // If the new target location is more than a meter from // the old one, create a new path. if (fdist > 1000) { long msToDest = setupPathInterpolator(oid, myLoc, followLoc, true, node.getFollowsTerrain()); destLoc = followLoc; msToSleep = msToDest == 0 ? (long) 500 : Math.min((long) 500, msToDest); } // Else if we're interpolating, interpolate the current path else if (interpolatingPath) { interpolatePath(); if (Log.loggingDebug) Log.debug( "baseBehavior.followUpdate: oid = " + oid + "; interpolated myLoc = " + obj.getWorldNode().getLoc()); } scheduleMe(interpolatingPath ? msToSleep : pathState.pathTimeRemaining()); }
protected void scheduleMe(long timeToDest) { long ms = Math.min((long) 500, timeToDest); // if (Log.loggingDebug) // Log.debug("BaseBehavior.scheduleMe: ms = " + ms); Engine.getExecutor().schedule(this, ms, TimeUnit.MILLISECONDS); }