Exemplo n.º 1
0
 private void updateObserver() {
   // Player view distance is handled in the network synchronizer
   if (controllerLive.get() instanceof PlayerController) {
     return;
   }
   int viewDistance = (getViewDistance() + 15) / Chunk.CHUNK_SIZE; // round up
   World w = transform.getPosition().getWorld();
   int cx = chunkLive.get().getX();
   int cy = chunkLive.get().getY();
   int cz = chunkLive.get().getZ();
   HashSet<SpoutChunk> observing =
       new HashSet<SpoutChunk>(viewDistance * viewDistance * viewDistance);
   for (int dx = -viewDistance; dx < viewDistance; dx++) {
     for (int dy = -viewDistance; dy < viewDistance; dy++) {
       for (int dz = -viewDistance; dz < viewDistance; dz++) {
         Chunk chunk = w.getChunk(cx + dx, cy + dy, cz + dz, true);
         chunk.refreshObserver(this);
         observing.add((SpoutChunk) chunk);
       }
     }
   }
   observingChunks.removeAll(observing);
   for (SpoutChunk chunk : observingChunks) {
     if (chunk.isLoaded()) {
       chunk.removeObserver(this);
     }
   }
   observingChunks.clear();
   observingChunks.addAll(observing);
 }
Exemplo n.º 2
0
 private void removeObserver() {
   // Player view distance is handled in the network synchronizer
   if (controllerLive.get() instanceof PlayerController) {
     return;
   }
   for (SpoutChunk chunk : observingChunks) {
     if (chunk.isLoaded()) {
       chunk.removeObserver(this);
     }
   }
   observingChunks.clear();
 }