mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-16 12:25:02 +01:00
Merge World impl blocks
This commit is contained in:
parent
0e484b92f3
commit
7c4af574cd
1 changed files with 11 additions and 14 deletions
25
src/world.rs
25
src/world.rs
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue