mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-25 00:08:42 -06:00
separate blocks into common
This commit is contained in:
parent
59b91bc23d
commit
db6c50ad8d
|
@ -1,3 +1,3 @@
|
||||||
fn main() {
|
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
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[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 {
|
pub mod blocks;
|
||||||
left + right
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn it_works() {
|
|
||||||
let result = add(2, 2);
|
|
||||||
assert_eq!(result, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
use strum::EnumIter;
|
use strum::EnumIter;
|
||||||
use crate::prefabs::BlockTexture;
|
use crate::prefabs::BlockTexture;
|
||||||
|
pub use kubi_shared::blocks::Block;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, EnumIter)]
|
pub trait BlockDescriptorSource {
|
||||||
#[repr(u8)]
|
fn descriptor(self) -> BlockDescriptor;
|
||||||
pub enum Block {
|
|
||||||
Air,
|
|
||||||
Stone,
|
|
||||||
Dirt,
|
|
||||||
Grass,
|
|
||||||
Sand,
|
|
||||||
}
|
}
|
||||||
impl Block {
|
impl BlockDescriptorSource for Block {
|
||||||
pub const fn descriptor(self) -> BlockDescriptor {
|
fn descriptor(self) -> BlockDescriptor {
|
||||||
match self {
|
match self {
|
||||||
Self::Air => BlockDescriptor {
|
Self::Air => BlockDescriptor {
|
||||||
name: "air",
|
name: "air",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use strum::{EnumIter, IntoEnumIterator};
|
use strum::{EnumIter, IntoEnumIterator};
|
||||||
use glam::{Vec3A, vec3a, IVec3, ivec3};
|
use glam::{Vec3A, vec3a, IVec3, ivec3};
|
||||||
use std::mem::discriminant;
|
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;
|
use crate::rendering::world::ChunkVertex;
|
||||||
|
|
||||||
pub mod data;
|
pub mod data;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use glam::{Vec3, IVec3};
|
use glam::{Vec3, IVec3};
|
||||||
use shipyard::{View, Component, ViewMut, IntoIter, UniqueView};
|
use shipyard::{View, Component, ViewMut, IntoIter, UniqueView};
|
||||||
use crate::transform::Transform;
|
use crate::{transform::Transform, world::block::BlockDescriptorSource};
|
||||||
|
|
||||||
use super::{ChunkStorage, block::Block};
|
use super::{ChunkStorage, block::Block};
|
||||||
|
|
||||||
const RAYCAST_STEP: f32 = 0.25;
|
const RAYCAST_STEP: f32 = 0.25;
|
||||||
|
|
Loading…
Reference in a new issue