mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-01-13 08:15:20 +07:00
Created Chunk#flags to store aggregated flags of chunk layers
This commit is contained in:
parent
d3c47b5781
commit
466d94b6fb
@ -30,15 +30,26 @@ public class Chunk extends BBox implements Poolable, Disposable {
|
||||
.add(64 * 64)
|
||||
.build();
|
||||
|
||||
static final BucketPool<byte[]> bytePools = BucketPool
|
||||
.builder(byte[].class)
|
||||
.add(8 * 8)
|
||||
.add(16 * 16)
|
||||
.add(24 * 24)
|
||||
.add(32 * 32)
|
||||
.add(64 * 64)
|
||||
.build();
|
||||
|
||||
public int layers;
|
||||
public int numTiles;
|
||||
public final Tile[][] tiles = new Tile[MAX_LAYERS][];
|
||||
public byte[] flags;
|
||||
|
||||
public static Chunk obtain(int x, int y, int width, int height) {
|
||||
Chunk chunk = pool.obtain();
|
||||
chunk.asBox(x, y, width, height);
|
||||
chunk.layers = 0;
|
||||
chunk.numTiles = width * height / SUBTILE_SIZE;
|
||||
chunk.flags = bytePools.obtain(chunk.numTiles);
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@ -52,6 +63,8 @@ public class Chunk extends BBox implements Poolable, Disposable {
|
||||
tiles[i] = null;
|
||||
}
|
||||
}
|
||||
bytePools.free(flags);
|
||||
flags = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user