Search in sources :

Example 1 with OnChunkLoaded

use of org.terasology.world.chunks.event.OnChunkLoaded in project Terasology by MovingBlocks.

the class RemoteChunkProvider method completeUpdate.

@Override
public void completeUpdate() {
    Chunk chunk = lightMerger.completeMerge();
    if (chunk != null) {
        chunk.markReady();
        listener.onChunkReady(chunk.getPosition());
        worldEntity.send(new OnChunkLoaded(chunk.getPosition()));
    }
}
Also used : OnChunkLoaded(org.terasology.world.chunks.event.OnChunkLoaded) Chunk(org.terasology.world.chunks.Chunk)

Example 2 with OnChunkLoaded

use of org.terasology.world.chunks.event.OnChunkLoaded in project Terasology by MovingBlocks.

the class SectorSimulationSystem method chunkLoad.

/**
 * Handles the OnChunkLoaded event for sector entities.
 *
 * Forwards the event to the appropriate sector-scope entities, if they are watching that chunk, and sends a
 * {@link SectorEntityLoad} event if this is the first watched chunk to be loaded for that entity.
 *
 * @param event the event sent when any chunk is loaded
 * @param worldEntity ignored
 */
@ReceiveEvent(components = WorldComponent.class)
public void chunkLoad(OnChunkLoaded event, EntityRef worldEntity) {
    for (EntityRef entity : entityManager.getEntitiesWith(SectorSimulationComponent.class)) {
        if (SectorUtil.getWatchedChunks(entity).contains(event.getChunkPos())) {
            entity.send(new OnChunkLoaded(event.getChunkPos()));
            if (SectorUtil.onlyWatchedChunk(entity, event.getChunkPos(), chunkProvider)) {
                entity.send(new SectorEntityLoad());
            }
            sendLoadedSectorUpdateEvent(entity, simulationDelta(entity));
        }
    }
}
Also used : OnChunkLoaded(org.terasology.world.chunks.event.OnChunkLoaded) BaseEntityRef(org.terasology.entitySystem.entity.internal.BaseEntityRef) EntityRef(org.terasology.entitySystem.entity.EntityRef) ReceiveEvent(org.terasology.entitySystem.event.ReceiveEvent)

Aggregations

OnChunkLoaded (org.terasology.world.chunks.event.OnChunkLoaded)2 EntityRef (org.terasology.entitySystem.entity.EntityRef)1 BaseEntityRef (org.terasology.entitySystem.entity.internal.BaseEntityRef)1 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)1 Chunk (org.terasology.world.chunks.Chunk)1