mirror of
https://git.kittycat.homes/zoe/codename-routes.git
synced 2024-08-15 03:18:26 +00:00
internally use enum instead of u16
This commit is contained in:
parent
93fa683319
commit
3c5bbd204e
3 changed files with 10 additions and 10 deletions
Binary file not shown.
|
@ -6,13 +6,13 @@ pub struct World {
|
||||||
xsize: usize,
|
xsize: usize,
|
||||||
ysize: usize,
|
ysize: usize,
|
||||||
zsize: usize,
|
zsize: usize,
|
||||||
tiles: Vec<Vec<Vec<u16>>>,
|
tiles: Vec<Vec<Vec<tiles::Tiletypes>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl World {
|
impl World {
|
||||||
pub fn get_tile_at(&self, x: usize, y: usize, z: usize) -> u16{
|
pub fn get_tile_at(&self, x: usize, y: usize, z: usize) -> u16{
|
||||||
//TODO: error handling, or maybe just do that in godot
|
//TODO: error handling, or maybe just do that in godot
|
||||||
self.tiles[x][y][z]
|
self.tiles[x][y][z] as u16
|
||||||
}
|
}
|
||||||
pub fn generate(&mut self) -> Vector3Array{
|
pub fn generate(&mut self) -> Vector3Array{
|
||||||
self.tiles = get_vec3(self.xsize, self.ysize, self.zsize);
|
self.tiles = get_vec3(self.xsize, self.ysize, self.zsize);
|
||||||
|
@ -21,7 +21,7 @@ impl World {
|
||||||
for y in 0..self.ysize {
|
for y in 0..self.ysize {
|
||||||
for z in 0..self.zsize {
|
for z in 0..self.zsize {
|
||||||
ret.push(Vector3::new(x as f32, y as f32, z as f32));
|
ret.push(Vector3::new(x as f32, y as f32, z as f32));
|
||||||
self.tiles[x][y][z] = tiles::Tiletypes::Dirt as u16;
|
self.tiles[x][y][z] = tiles::Tiletypes::Dirt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,14 +37,14 @@ impl World {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_vec3(xsize: usize, ysize: usize, zsize: usize) -> Vec<Vec<Vec<u16>>> {
|
fn get_vec3(xsize: usize, ysize: usize, zsize: usize) -> Vec<Vec<Vec<tiles::Tiletypes>>> {
|
||||||
let mut zvec: Vec<u16> = Vec::with_capacity(zsize);
|
let mut zvec: Vec<tiles::Tiletypes> = Vec::with_capacity(zsize);
|
||||||
zvec.resize(zsize, 0);
|
zvec.resize(zsize, tiles::Tiletypes::Air);
|
||||||
|
|
||||||
let mut yvec: Vec<Vec<u16>> = Vec::with_capacity(ysize);
|
let mut yvec: Vec<Vec<tiles::Tiletypes>> = Vec::with_capacity(ysize);
|
||||||
yvec.resize(ysize, zvec.clone());
|
yvec.resize(ysize, zvec.clone());
|
||||||
|
|
||||||
let mut xvec: Vec<Vec<Vec<u16>>> = Vec::with_capacity(xsize);
|
let mut xvec: Vec<Vec<Vec<tiles::Tiletypes>>> = Vec::with_capacity(xsize);
|
||||||
xvec.resize(ysize, yvec.clone());
|
xvec.resize(ysize, yvec.clone());
|
||||||
|
|
||||||
yvec.push(zvec);
|
yvec.push(zvec);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use derive_builder::Builder;
|
use derive_builder::Builder;
|
||||||
use strum::{AsRefStr, EnumDiscriminants, EnumIter, FromRepr};
|
use strum::{AsRefStr, EnumDiscriminants, EnumIter, FromRepr};
|
||||||
|
|
||||||
#[derive(AsRefStr, EnumIter, FromRepr, EnumDiscriminants, Clone)]
|
#[derive(AsRefStr, EnumIter, FromRepr, EnumDiscriminants, Clone, Copy)]
|
||||||
#[repr(u16)]
|
#[repr(u8)]
|
||||||
pub enum Tiletypes {
|
pub enum Tiletypes {
|
||||||
Air,
|
Air,
|
||||||
Water,
|
Water,
|
||||||
|
|
Loading…
Reference in a new issue