diff --git a/kubi/src/world/block.rs b/kubi-shared/src/block.rs similarity index 82% rename from kubi/src/world/block.rs rename to kubi-shared/src/block.rs index 66a0905..e4e5324 100644 --- a/kubi/src/world/block.rs +++ b/kubi-shared/src/block.rs @@ -1,5 +1,35 @@ -use crate::prefabs::BlockTexture; -pub use kubi_shared::blocks::Block; +use bincode::{Encode, Decode}; +use strum::EnumIter; + +#[derive(Clone, Copy, Debug, EnumIter)] +#[repr(u8)] +pub enum BlockTexture { + Stone, + Dirt, + GrassTop, + GrassSide, + Sand, + Bedrock, + Wood, + WoodTop, + Leaf, + Torch, + TallGrass, + Snow, + GrassSideSnow, + Cobblestone, +} + +#[derive(Encode, Decode, Clone, Copy, Debug, PartialEq, Eq, EnumIter)] +#[repr(u8)] +pub enum Block { + Air, + Stone, + Dirt, + Grass, + Sand, + Cobblestone, +} pub trait BlockDescriptorSource { fn descriptor(self) -> BlockDescriptor; @@ -92,6 +122,13 @@ impl CubeTexture { } } +#[derive(Clone, Copy, Debug)] +struct CrossTexture { + pub a: BlockTexture, + pub b: BlockTexture, + +} + #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum CollisionType { None, @@ -101,5 +138,6 @@ pub enum CollisionType { #[derive(Clone, Copy, Debug)] pub enum RenderType { None, - SolidBlock(CubeTexture) + SolidBlock(CubeTexture), + CrossShape, } diff --git a/kubi-shared/src/blocks.rs b/kubi-shared/src/blocks.rs deleted file mode 100644 index 0f94b33..0000000 --- a/kubi-shared/src/blocks.rs +++ /dev/null @@ -1,13 +0,0 @@ -use bincode::{Encode, Decode}; -use strum::EnumIter; - -#[derive(Encode, Decode, Clone, Copy, Debug, PartialEq, Eq, EnumIter)] -#[repr(u8)] -pub enum Block { - Air, - Stone, - Dirt, - Grass, - Sand, - Cobblestone, -} diff --git a/kubi-shared/src/chunk.rs b/kubi-shared/src/chunk.rs index de1b357..3456db5 100644 --- a/kubi-shared/src/chunk.rs +++ b/kubi-shared/src/chunk.rs @@ -1,4 +1,4 @@ -use crate::blocks::Block; +use crate::block::Block; pub const CHUNK_SIZE: usize = 32; pub type BlockData = Box<[[[Block; CHUNK_SIZE]; CHUNK_SIZE]; CHUNK_SIZE]>; diff --git a/kubi-shared/src/lib.rs b/kubi-shared/src/lib.rs index 3817e6f..2f1da39 100644 --- a/kubi-shared/src/lib.rs +++ b/kubi-shared/src/lib.rs @@ -1,4 +1,4 @@ -pub mod blocks; +pub mod block; pub mod networking; pub mod worldgen; pub mod chunk; diff --git a/kubi-shared/src/worldgen.rs b/kubi-shared/src/worldgen.rs index 1d2cad5..ca2df3e 100644 --- a/kubi-shared/src/worldgen.rs +++ b/kubi-shared/src/worldgen.rs @@ -2,7 +2,7 @@ use glam::{IVec3, ivec3}; use bracket_noise::prelude::*; use crate::{ chunk::{BlockData, CHUNK_SIZE}, - blocks::Block + block::Block }; fn mountain_ramp(mut x: f32) -> f32 { diff --git a/kubi/src/block_placement.rs b/kubi/src/block_placement.rs index f3d7cd1..0a08390 100644 --- a/kubi/src/block_placement.rs +++ b/kubi/src/block_placement.rs @@ -1,7 +1,8 @@ use shipyard::{UniqueViewMut, UniqueView, View, IntoIter, ViewMut, EntitiesViewMut}; +use kubi_shared::block::Block; use crate::{ player::MainPlayer, - world::{raycast::LookingAtBlock, block::Block, queue::{BlockUpdateQueue, BlockUpdateEvent}}, + world::{raycast::LookingAtBlock, queue::{BlockUpdateQueue, BlockUpdateEvent}}, input::{Inputs, PrevInputs}, events::{EventComponent, player_actions::PlayerActionEvent}, }; diff --git a/kubi/src/events/player_actions.rs b/kubi/src/events/player_actions.rs index 7c086d2..7f87606 100644 --- a/kubi/src/events/player_actions.rs +++ b/kubi/src/events/player_actions.rs @@ -1,8 +1,7 @@ use shipyard::{Component, View, ViewMut, EntitiesViewMut, IntoIter, track}; use glam::{IVec3, Quat, Vec3}; - +use kubi_shared::block::Block; use crate::{ - world::block::Block, player::MainPlayer, transform::Transform }; diff --git a/kubi/src/prefabs.rs b/kubi/src/prefabs.rs index 6d1aa76..1fc81b5 100644 --- a/kubi/src/prefabs.rs +++ b/kubi/src/prefabs.rs @@ -1,6 +1,6 @@ use shipyard::{NonSendSync, UniqueView, Unique, AllStoragesView}; use glium::{texture::{SrgbTexture2dArray, MipmapsOption}, Program}; -use strum::EnumIter; +use kubi_shared::block::{Block, BlockTexture}; use crate::rendering::Renderer; mod texture; @@ -13,24 +13,6 @@ pub trait AssetPaths { fn file_name(self) -> &'static str; } -#[derive(Clone, Copy, Debug, EnumIter)] -#[repr(u8)] -pub enum BlockTexture { - Stone, - Dirt, - GrassTop, - GrassSide, - Sand, - Bedrock, - Wood, - WoodTop, - Leaf, - Torch, - TallGrass, - Snow, - GrassSideSnow, - Cobblestone, -} impl AssetPaths for BlockTexture { fn file_name(self) -> &'static str { match self { diff --git a/kubi/src/rendering/world.rs b/kubi/src/rendering/world.rs index 81d94c7..1ff8235 100644 --- a/kubi/src/rendering/world.rs +++ b/kubi/src/rendering/world.rs @@ -110,7 +110,6 @@ pub fn draw_world( } } -//this doesn't use culling! pub fn draw_current_chunk_border( mut target: NonSendSync>, player: View, diff --git a/kubi/src/world.rs b/kubi/src/world.rs index 5f94085..03d91c2 100644 --- a/kubi/src/world.rs +++ b/kubi/src/world.rs @@ -4,10 +4,9 @@ use glam::IVec3; use hashbrown::HashMap; use anyhow::{Result, Context}; -pub use kubi_shared::worldgen; +pub use kubi_shared::{worldgen, block::Block}; pub mod chunk; -pub mod block; pub mod tasks; pub mod loading; pub mod mesh; @@ -15,7 +14,6 @@ pub mod neighbors; pub mod raycast; pub mod queue; -use block::Block; use chunk::{Chunk, ChunkMesh, CHUNK_SIZE}; use tasks::ChunkTaskManager; use queue::BlockUpdateQueue; diff --git a/kubi/src/world/mesh.rs b/kubi/src/world/mesh.rs index 608fc60..b8f738e 100644 --- a/kubi/src/world/mesh.rs +++ b/kubi/src/world/mesh.rs @@ -1,7 +1,8 @@ use strum::{EnumIter, IntoEnumIterator}; use glam::{Vec3A, vec3a, IVec3, ivec3}; use std::mem::discriminant; -use super::{chunk::CHUNK_SIZE, block::{Block, RenderType, BlockDescriptorSource}}; +use kubi_shared::block::{Block, RenderType, BlockDescriptorSource}; +use super::{chunk::CHUNK_SIZE, }; use crate::rendering::world::ChunkVertex; pub mod data; diff --git a/kubi/src/world/queue.rs b/kubi/src/world/queue.rs index bfcaa63..718228c 100644 --- a/kubi/src/world/queue.rs +++ b/kubi/src/world/queue.rs @@ -1,5 +1,5 @@ use glam::{IVec3, ivec3}; -use kubi_shared::{blocks::Block, chunk::CHUNK_SIZE}; +use kubi_shared::{block::Block, chunk::CHUNK_SIZE}; use shipyard::{UniqueViewMut, Unique}; use super::ChunkStorage; diff --git a/kubi/src/world/raycast.rs b/kubi/src/world/raycast.rs index 90c98a4..a71802c 100644 --- a/kubi/src/world/raycast.rs +++ b/kubi/src/world/raycast.rs @@ -1,7 +1,8 @@ use glam::{Vec3, IVec3}; use shipyard::{View, Component, ViewMut, IntoIter, UniqueView, track}; -use crate::{transform::Transform, world::block::BlockDescriptorSource}; -use super::{ChunkStorage, block::Block}; +use kubi_shared::block::{Block, BlockDescriptorSource}; +use crate::transform::Transform; +use super::ChunkStorage; const RAYCAST_STEP: f32 = 0.25;