mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-04-20 19:35:08 +02:00
minedmap/tile_renderer: add biome_at() helper
Retrieve the biome at a given coordinate, possibly offset by a number of blocks.
This commit is contained in:
parent
dee00e7a02
commit
8e848394cd
1 changed files with 22 additions and 1 deletions
|
@ -8,7 +8,7 @@ use num_integer::div_mod_floor;
|
||||||
|
|
||||||
use minedmap::{
|
use minedmap::{
|
||||||
io::{fs, storage},
|
io::{fs, storage},
|
||||||
resource::block_color,
|
resource::{block_color, Biome},
|
||||||
types::*,
|
types::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,6 +37,27 @@ fn coord_offset<const AXIS: u8>(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn biome_at(
|
||||||
|
region_group: &RegionGroup<ProcessedRegion>,
|
||||||
|
chunk: ChunkCoords,
|
||||||
|
block: LayerBlockCoords,
|
||||||
|
dx: i32,
|
||||||
|
dz: i32,
|
||||||
|
) -> Option<&Biome> {
|
||||||
|
let (region_x, chunk_x, block_x) = coord_offset(chunk.x, block.x, dx);
|
||||||
|
let (region_z, chunk_z, block_z) = coord_offset(chunk.z, block.z, dz);
|
||||||
|
let chunk = ChunkCoords {
|
||||||
|
x: chunk_x,
|
||||||
|
z: chunk_z,
|
||||||
|
};
|
||||||
|
let block = LayerBlockCoords {
|
||||||
|
x: block_x,
|
||||||
|
z: block_z,
|
||||||
|
};
|
||||||
|
let region = region_group.get(region_x, region_z)?;
|
||||||
|
region[chunk].as_ref()?.biomes[block].as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
pub struct TileRenderer<'a> {
|
pub struct TileRenderer<'a> {
|
||||||
config: &'a Config,
|
config: &'a Config,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue