コード例 #1
0
  /** Find objects that are in visibility range. */
  protected void findVisibleObjects() {
    if (owner == null || !owner.isSpawned()) {
      return;
    }

    MapRegion[] regions = owner.getActiveRegion().getNeighbours();
    for (int i = 0; i < regions.length; i++) {
      MapRegion r = regions[i];
      FastMap<Integer, VisibleObject> objects = r.getObjects();
      for (FastMap.Entry<Integer, VisibleObject> e = objects.head(), mapEnd = objects.tail();
          (e = e.getNext()) != mapEnd; ) {
        VisibleObject newObject = e.getValue();
        if (newObject == owner || newObject == null) {
          continue;
        }

        if (!isAwareOf(newObject)) {
          continue;
        }
        if (knownObjects.containsKey(newObject.getObjectId())) {
          continue;
        }

        if (!checkObjectInRange(newObject)
            && !newObject.getKnownList().checkReversedObjectInRange(owner)) {
          continue;
        }

        /** New object is not known. */
        if (add(newObject)) {
          newObject.getKnownList().add(owner);
        }
      }
    }
  }
コード例 #2
0
ファイル: ThreadLocal.java プロジェクト: KosBeg/jwebsocket
 private FastMap newLocalMap() {
   // First, do some cleanup (remove dead threads).
   for (FastMap.Entry e = THREAD_TO_LOCAL_MAP.head(), end = THREAD_TO_LOCAL_MAP.tail();
       (e = (FastMap.Entry) e.getNext()) != end; ) {
     Thread thread = (Thread) e.getKey();
     if (!thread.isAlive()) {
       THREAD_TO_LOCAL_MAP.remove(thread);
     }
   }
   FastMap localMap = new FastMap();
   THREAD_TO_LOCAL_MAP.put(Thread.currentThread(), localMap);
   return localMap;
 }
コード例 #3
0
 public void doOnAllObjects(Visitor<VisibleObject> visitor) {
   try {
     for (FastMap.Entry<Integer, VisibleObject> e = knownObjects.head(),
             mapEnd = knownObjects.tail();
         (e = e.getNext()) != mapEnd; ) {
       VisibleObject newObject = e.getValue();
       if (newObject != null) {
         visitor.visit(newObject);
       }
     }
   } catch (Exception ex) {
     // log.error("Exception when running visitor on all objects" + ex);
   }
 }
コード例 #4
0
 public void doOnAllPlayers(Visitor<Player> visitor) {
   if (knownPlayers == null) {
     return;
   }
   try {
     for (FastMap.Entry<Integer, Player> e = knownPlayers.head(), mapEnd = knownPlayers.tail();
         (e = e.getNext()) != mapEnd; ) {
       Player player = e.getValue();
       if (player != null) {
         visitor.visit(player);
       }
     }
   } catch (Exception ex) {
     // log.error("Exception when running visitor on all players" + ex);
   }
 }
コード例 #5
0
 public int doOnAllNpcs(Visitor<Npc> visitor, int iterationLimit) {
   int counter = 0;
   try {
     for (FastMap.Entry<Integer, VisibleObject> e = knownObjects.head(),
             mapEnd = knownObjects.tail();
         (e = e.getNext()) != mapEnd; ) {
       VisibleObject newObject = e.getValue();
       if (newObject instanceof Npc) {
         if ((++counter) == iterationLimit) {
           break;
         }
         visitor.visit((Npc) newObject);
       }
     }
   } catch (Exception ex) {
     // log.error("Exception when running visitor on all npcs" + ex);
   }
   return counter;
 }