blob: 7913d2221bb4da04165df2935c9045079b564513 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
pub mod herringbone;
pub mod tileset_loader;
use glam::IVec2;
use crate::{
config::CHUNK_SIZE,
proc_gen::{
herringbone::get_cell_at_position,
tileset_loader::{Tileset, load_tileset},
},
sim::cell_manager::chunk::Chunk,
};
pub struct TilesetWorldGenerator {
tileset: Tileset,
}
impl TilesetWorldGenerator {
pub fn generate_chunk(&self, chunk_position: IVec2) -> Chunk {
let mut chunk = Chunk::void();
for x in 0..CHUNK_SIZE {
for y in 0..CHUNK_SIZE {
let cell = get_cell_at_position(
chunk_position * CHUNK_SIZE + IVec2::new(x, y),
&self.tileset,
);
chunk.set_cell_at_local_position(x as u8, y as u8, cell);
}
}
chunk
}
pub fn new(tileset_path: &str) -> Self {
let tileset = load_tileset(tileset_path);
TilesetWorldGenerator { tileset }
}
}
|