separate blocks into common

This commit is contained in:
griffi-gh 2023-01-30 02:45:35 +01:00
parent 59b91bc23d
commit db6c50ad8d
7 changed files with 21 additions and 28 deletions

View file

@ -1,3 +1,3 @@
fn main() {
println!("Hello, world!");
}

View file

@ -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"] }

11
kubi-shared/src/blocks.rs Normal file
View file

@ -0,0 +1,11 @@
use strum::EnumIter;
#[derive(Clone, Copy, Debug, PartialEq, Eq, EnumIter)]
#[repr(u8)]
pub enum Block {
Air,
Stone,
Dirt,
Grass,
Sand,
}

View file

@ -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;

View file

@ -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",

View file

@ -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;

View file

@ -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;