コード例 #1
0
  /** for client display: current state */
  public List<String> getObjectiveStatus() {
    lock.lock();
    try {
      List<String> l = new LinkedList<String>();

      Iterator<CollectionGoalStatus> iter = goalsStatus.iterator();
      while (iter.hasNext()) {
        CollectionGoalStatus status = iter.next();
        String itemName = status.getTemplateName();
        int numNeeded = status.targetCount;
        int cur = Math.min(status.currentCount, numNeeded);

        String objective = itemName + ": " + cur + "/" + numNeeded;
        l.add(objective);
      }
      return l;
    } finally {
      lock.unlock();
    }
  }
コード例 #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());
 }
コード例 #3
0
 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);
 }