Merge World impl blocks

This commit is contained in:
crumblingstatue 2023-04-14 17:39:33 +02:00
parent 0e484b92f3
commit 7c4af574cd

View file

@ -62,6 +62,17 @@ impl World {
name: name.to_string(),
}
}
/// Get mutable access to the tile at `pos`.
///
/// Loads or generates the containing chunk if necessary.
pub fn tile_at_mut(&mut self, pos: TilePos, worldgen: &Worldgen) -> &mut Tile {
let (chk, local) = pos.to_chunk_and_local();
let chk = self
.chunks
.entry(chk)
.or_insert_with(|| Chunk::load_or_gen(chk, worldgen, &self.name));
chk.at_mut(local)
}
pub fn save(&self) {
let result = std::fs::create_dir(&self.name);
log::info!("{result:?}");
@ -156,20 +167,6 @@ struct WorldMetaSave {
ticks: u64,
}
impl World {
/// Get mutable access to the tile at `pos`.
///
/// Loads or generates the containing chunk if necessary.
pub fn tile_at_mut(&mut self, pos: TilePos, worldgen: &Worldgen) -> &mut Tile {
let (chk, local) = pos.to_chunk_and_local();
let chk = self
.chunks
.entry(chk)
.or_insert_with(|| Chunk::load_or_gen(chk, worldgen, &self.name));
chk.at_mut(local)
}
}
#[derive(Debug, Clone, Copy)]
pub struct TilePos {
pub x: TPosSc,