mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-22 14:58:44 -06:00
move block to shared
This commit is contained in:
parent
0de70ed1b7
commit
c865835e8d
|
@ -1,5 +1,35 @@
|
||||||
use crate::prefabs::BlockTexture;
|
use bincode::{Encode, Decode};
|
||||||
pub use kubi_shared::blocks::Block;
|
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 {
|
pub trait BlockDescriptorSource {
|
||||||
fn descriptor(self) -> BlockDescriptor;
|
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)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
pub enum CollisionType {
|
pub enum CollisionType {
|
||||||
None,
|
None,
|
||||||
|
@ -101,5 +138,6 @@ pub enum CollisionType {
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub enum RenderType {
|
pub enum RenderType {
|
||||||
None,
|
None,
|
||||||
SolidBlock(CubeTexture)
|
SolidBlock(CubeTexture),
|
||||||
|
CrossShape,
|
||||||
}
|
}
|
|
@ -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,
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::blocks::Block;
|
use crate::block::Block;
|
||||||
|
|
||||||
pub const CHUNK_SIZE: usize = 32;
|
pub const CHUNK_SIZE: usize = 32;
|
||||||
pub type BlockData = Box<[[[Block; CHUNK_SIZE]; CHUNK_SIZE]; CHUNK_SIZE]>;
|
pub type BlockData = Box<[[[Block; CHUNK_SIZE]; CHUNK_SIZE]; CHUNK_SIZE]>;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pub mod blocks;
|
pub mod block;
|
||||||
pub mod networking;
|
pub mod networking;
|
||||||
pub mod worldgen;
|
pub mod worldgen;
|
||||||
pub mod chunk;
|
pub mod chunk;
|
||||||
|
|
|
@ -2,7 +2,7 @@ use glam::{IVec3, ivec3};
|
||||||
use bracket_noise::prelude::*;
|
use bracket_noise::prelude::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
chunk::{BlockData, CHUNK_SIZE},
|
chunk::{BlockData, CHUNK_SIZE},
|
||||||
blocks::Block
|
block::Block
|
||||||
};
|
};
|
||||||
|
|
||||||
fn mountain_ramp(mut x: f32) -> f32 {
|
fn mountain_ramp(mut x: f32) -> f32 {
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
use shipyard::{UniqueViewMut, UniqueView, View, IntoIter, ViewMut, EntitiesViewMut};
|
use shipyard::{UniqueViewMut, UniqueView, View, IntoIter, ViewMut, EntitiesViewMut};
|
||||||
|
use kubi_shared::block::Block;
|
||||||
use crate::{
|
use crate::{
|
||||||
player::MainPlayer,
|
player::MainPlayer,
|
||||||
world::{raycast::LookingAtBlock, block::Block, queue::{BlockUpdateQueue, BlockUpdateEvent}},
|
world::{raycast::LookingAtBlock, queue::{BlockUpdateQueue, BlockUpdateEvent}},
|
||||||
input::{Inputs, PrevInputs},
|
input::{Inputs, PrevInputs},
|
||||||
events::{EventComponent, player_actions::PlayerActionEvent},
|
events::{EventComponent, player_actions::PlayerActionEvent},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use shipyard::{Component, View, ViewMut, EntitiesViewMut, IntoIter, track};
|
use shipyard::{Component, View, ViewMut, EntitiesViewMut, IntoIter, track};
|
||||||
use glam::{IVec3, Quat, Vec3};
|
use glam::{IVec3, Quat, Vec3};
|
||||||
|
use kubi_shared::block::Block;
|
||||||
use crate::{
|
use crate::{
|
||||||
world::block::Block,
|
|
||||||
player::MainPlayer,
|
player::MainPlayer,
|
||||||
transform::Transform
|
transform::Transform
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use shipyard::{NonSendSync, UniqueView, Unique, AllStoragesView};
|
use shipyard::{NonSendSync, UniqueView, Unique, AllStoragesView};
|
||||||
use glium::{texture::{SrgbTexture2dArray, MipmapsOption}, Program};
|
use glium::{texture::{SrgbTexture2dArray, MipmapsOption}, Program};
|
||||||
use strum::EnumIter;
|
use kubi_shared::block::{Block, BlockTexture};
|
||||||
use crate::rendering::Renderer;
|
use crate::rendering::Renderer;
|
||||||
|
|
||||||
mod texture;
|
mod texture;
|
||||||
|
@ -13,24 +13,6 @@ pub trait AssetPaths {
|
||||||
fn file_name(self) -> &'static str;
|
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 {
|
impl AssetPaths for BlockTexture {
|
||||||
fn file_name(self) -> &'static str {
|
fn file_name(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
|
|
|
@ -110,7 +110,6 @@ pub fn draw_world(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//this doesn't use culling!
|
|
||||||
pub fn draw_current_chunk_border(
|
pub fn draw_current_chunk_border(
|
||||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||||
player: View<MainPlayer>,
|
player: View<MainPlayer>,
|
||||||
|
|
|
@ -4,10 +4,9 @@ use glam::IVec3;
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use anyhow::{Result, Context};
|
use anyhow::{Result, Context};
|
||||||
|
|
||||||
pub use kubi_shared::worldgen;
|
pub use kubi_shared::{worldgen, block::Block};
|
||||||
|
|
||||||
pub mod chunk;
|
pub mod chunk;
|
||||||
pub mod block;
|
|
||||||
pub mod tasks;
|
pub mod tasks;
|
||||||
pub mod loading;
|
pub mod loading;
|
||||||
pub mod mesh;
|
pub mod mesh;
|
||||||
|
@ -15,7 +14,6 @@ pub mod neighbors;
|
||||||
pub mod raycast;
|
pub mod raycast;
|
||||||
pub mod queue;
|
pub mod queue;
|
||||||
|
|
||||||
use block::Block;
|
|
||||||
use chunk::{Chunk, ChunkMesh, CHUNK_SIZE};
|
use chunk::{Chunk, ChunkMesh, CHUNK_SIZE};
|
||||||
use tasks::ChunkTaskManager;
|
use tasks::ChunkTaskManager;
|
||||||
use queue::BlockUpdateQueue;
|
use queue::BlockUpdateQueue;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
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, BlockDescriptorSource}};
|
use kubi_shared::block::{Block, RenderType, BlockDescriptorSource};
|
||||||
|
use super::{chunk::CHUNK_SIZE, };
|
||||||
use crate::rendering::world::ChunkVertex;
|
use crate::rendering::world::ChunkVertex;
|
||||||
|
|
||||||
pub mod data;
|
pub mod data;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use glam::{IVec3, ivec3};
|
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 shipyard::{UniqueViewMut, Unique};
|
||||||
|
|
||||||
use super::ChunkStorage;
|
use super::ChunkStorage;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
use glam::{Vec3, IVec3};
|
use glam::{Vec3, IVec3};
|
||||||
use shipyard::{View, Component, ViewMut, IntoIter, UniqueView, track};
|
use shipyard::{View, Component, ViewMut, IntoIter, UniqueView, track};
|
||||||
use crate::{transform::Transform, world::block::BlockDescriptorSource};
|
use kubi_shared::block::{Block, BlockDescriptorSource};
|
||||||
use super::{ChunkStorage, block::Block};
|
use crate::transform::Transform;
|
||||||
|
use super::ChunkStorage;
|
||||||
|
|
||||||
const RAYCAST_STEP: f32 = 0.25;
|
const RAYCAST_STEP: f32 = 0.25;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue