diff --git a/kubi-server/src/main.rs b/kubi-server/src/main.rs index e7a11a9..d091d78 100644 --- a/kubi-server/src/main.rs +++ b/kubi-server/src/main.rs @@ -1,3 +1,3 @@ fn main() { - println!("Hello, world!"); + } diff --git a/kubi-shared/Cargo.toml b/kubi-shared/Cargo.toml index 93a1ac2..d7a5ff3 100644 --- a/kubi-shared/Cargo.toml +++ b/kubi-shared/Cargo.toml @@ -6,3 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +strum = { version = "0.24", features = ["derive"] } diff --git a/kubi-shared/src/blocks.rs b/kubi-shared/src/blocks.rs new file mode 100644 index 0000000..ced61a8 --- /dev/null +++ b/kubi-shared/src/blocks.rs @@ -0,0 +1,11 @@ +use strum::EnumIter; + +#[derive(Clone, Copy, Debug, PartialEq, Eq, EnumIter)] +#[repr(u8)] +pub enum Block { + Air, + Stone, + Dirt, + Grass, + Sand, +} diff --git a/kubi-shared/src/lib.rs b/kubi-shared/src/lib.rs index 7d12d9a..049a8aa 100644 --- a/kubi-shared/src/lib.rs +++ b/kubi-shared/src/lib.rs @@ -1,14 +1 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} +pub mod blocks; diff --git a/kubi/src/world/block.rs b/kubi/src/world/block.rs index 92fba77..1ece14c 100644 --- a/kubi/src/world/block.rs +++ b/kubi/src/world/block.rs @@ -1,17 +1,12 @@ use strum::EnumIter; use crate::prefabs::BlockTexture; +pub use kubi_shared::blocks::Block; -#[derive(Clone, Copy, Debug, PartialEq, Eq, EnumIter)] -#[repr(u8)] -pub enum Block { - Air, - Stone, - Dirt, - Grass, - Sand, +pub trait BlockDescriptorSource { + fn descriptor(self) -> BlockDescriptor; } -impl Block { - pub const fn descriptor(self) -> BlockDescriptor { +impl BlockDescriptorSource for Block { + fn descriptor(self) -> BlockDescriptor { match self { Self::Air => BlockDescriptor { name: "air", diff --git a/kubi/src/world/mesh.rs b/kubi/src/world/mesh.rs index f991594..608fc60 100644 --- a/kubi/src/world/mesh.rs +++ b/kubi/src/world/mesh.rs @@ -1,7 +1,7 @@ use strum::{EnumIter, IntoEnumIterator}; use glam::{Vec3A, vec3a, IVec3, ivec3}; use std::mem::discriminant; -use super::{chunk::CHUNK_SIZE, block::{Block, RenderType}}; +use super::{chunk::CHUNK_SIZE, block::{Block, RenderType, BlockDescriptorSource}}; use crate::rendering::world::ChunkVertex; pub mod data; diff --git a/kubi/src/world/raycast.rs b/kubi/src/world/raycast.rs index 733a197..1485abd 100644 --- a/kubi/src/world/raycast.rs +++ b/kubi/src/world/raycast.rs @@ -1,7 +1,6 @@ use glam::{Vec3, IVec3}; use shipyard::{View, Component, ViewMut, IntoIter, UniqueView}; -use crate::transform::Transform; - +use crate::{transform::Transform, world::block::BlockDescriptorSource}; use super::{ChunkStorage, block::Block}; const RAYCAST_STEP: f32 = 0.25;