Search in sources :

Example 6 with Task

use of io.xol.chunkstories.api.workers.Task in project chunkstories by Hugobros3.

the class ChunkRenderDataHolder method requestMeshUpdate.

@Override
public Fence requestMeshUpdate() {
    unbakedUpdates.incrementAndGet();
    // System.out.println("who did dis");
    // Thread.dumpStack();
    Task fence;
    taskLock.lock();
    if (task == null || task.isDone() || task.isCancelled()) {
        task = new TaskBakeChunk((ClientChunk) chunk);
        chunk.getWorld().getGameContext().tasks().scheduleTask(task);
    }
    fence = task;
    taskLock.unlock();
    return fence;
}
Also used : Task(io.xol.chunkstories.api.workers.Task) ClientChunk(io.xol.chunkstories.world.chunk.ClientChunk)

Example 7 with Task

use of io.xol.chunkstories.api.workers.Task in project chunkstories by Hugobros3.

the class ChunkLightBaker method requestLightningUpdate.

@Override
public Fence requestLightningUpdate() {
    unbakedUpdates.incrementAndGet();
    if (world instanceof WorldTool) {
        WorldTool tool = (WorldTool) world;
        if (!tool.isLightningEnabled()) {
            // System.out.println("too soon");
            return new TrivialFence();
        }
    }
    Task fence;
    taskLock.lock();
    if (task == null || task.isDone() || task.isCancelled()) {
        task = new TaskLightChunk(chunk, true);
        chunk.getWorld().getGameContext().tasks().scheduleTask(task);
    }
    fence = task;
    taskLock.unlock();
    return fence;
}
Also used : TrivialFence(io.xol.chunkstories.util.concurrency.TrivialFence) Task(io.xol.chunkstories.api.workers.Task) WorldTool(io.xol.chunkstories.world.WorldTool)

Aggregations

Task (io.xol.chunkstories.api.workers.Task)7 TaskExecutor (io.xol.chunkstories.api.workers.TaskExecutor)1 ChunkHolder (io.xol.chunkstories.api.world.chunk.ChunkHolder)1 Heightmap (io.xol.chunkstories.api.world.heightmap.Heightmap)1 CompoundFence (io.xol.chunkstories.util.concurrency.CompoundFence)1 SimpleFence (io.xol.chunkstories.util.concurrency.SimpleFence)1 TrivialFence (io.xol.chunkstories.util.concurrency.TrivialFence)1 WorldTool (io.xol.chunkstories.world.WorldTool)1 ClientChunk (io.xol.chunkstories.world.chunk.ClientChunk)1