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