Overhaul how building and ownership layers are handled at init

This commit is contained in:
2023-11-10 06:38:16 +01:00
parent 60e66bbd67
commit c8c857bdb9
3 changed files with 53 additions and 24 deletions

View File

@@ -9,6 +9,16 @@
BzTileMap BZ_TILEMAP_INVALID = {.isValid = false};
void bzTileLayerSkipRender(BzTileLayer *layer) {
}
void bzTileObjectGroupSkipRender(BzTileObjectGroup *objectGroup) {
}
BzTileLayerRenderFunc BZ_TILE_LAYER_SKIP_RENDER = bzTileLayerSkipRender;
BzTileObjectGroupRenderFunc BZ_TILE_OBJECTS_SKIP_RENDER = bzTileObjectGroupSkipRender;
bool bzTileLayerClear(BzTileLayer *layer, BzTile *data, i32 dataCount) {
return true;
}
@@ -22,6 +32,13 @@ BzTileObjectsFunc BZ_TILE_OBJECTS_CLEAR = bzTileObjectsClear;
BzTile bzTileLayerGetTile(BzTileLayer *layer, i32 x, i32 y) {
return layer->data[layer->width * y + x];
}
void bzTileLayerSetTile(BzTileLayer *layer, BzTile tile, i32 x, i32 y, i32 w, i32 h) {
for (i32 yIdx = y; yIdx < y + h; yIdx++) {
for (i32 xIdx = x; xIdx < x + w; xIdx++) {
layer->data[yIdx * layer->width + xIdx] = tile;
}
}
}
BzTileset *bzTileLayerGetTileset(BzTileMap *map, BzTileLayer *layer) {
i32 idx = layer->tilesetIdx;
if (idx < 0 || idx >= map->tilesetCount)