mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-24 15:58:43 -06:00
separate blocks into common
This commit is contained in:
parent
59b91bc23d
commit
db6c50ad8d
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
|
||||
}
|
||||
|
|
|
@ -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
11
kubi-shared/src/blocks.rs
Normal 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,
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue