예제 #1
0
 public void followSetup(EntityHandle target, int speed) {
   followTarget = target;
   mobSpeed = speed;
   InterpolatedWorldNode node = obj.getWorldNode();
   Point myLoc = node.getLoc();
   long oid = obj.getOid();
   ObjectStub followObj = (ObjectStub) followTarget.getEntity(Namespace.MOB);
   Point followLoc = followObj.getWorldNode().getLoc();
   destLoc = followLoc;
   scheduleMe(setupPathInterpolator(oid, myLoc, followLoc, true, node.getFollowsTerrain()));
 }
예제 #2
0
 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());
 }
 public PerceiverData(long perceiverOid, Integer reactionRadius, InterpolatedWorldNode wnode) {
   this.perceiverOid = perceiverOid;
   this.reactionRadius = reactionRadius;
   this.wnode = wnode;
   this.lastLoc = wnode.getLoc();
 }