From d93743c1a659def88324e59a63c0bc05c34908c4 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Tue, 21 May 2019 23:04:39 +0100 Subject: [PATCH] Added spawn point Former-commit-id: 04ea38df61d3610d679368166de220243ef1bfba --- common/src/terrain/chonk.rs | 2 +- server/src/lib.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/common/src/terrain/chonk.rs b/common/src/terrain/chonk.rs index 23d0c74bc3..554f01d804 100644 --- a/common/src/terrain/chonk.rs +++ b/common/src/terrain/chonk.rs @@ -12,7 +12,7 @@ pub enum ChonkError { OutOfBounds, } -const SUB_CHUNK_HEIGHT: u32 = 32; +const SUB_CHUNK_HEIGHT: u32 = 16; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Chonk { diff --git a/server/src/lib.rs b/server/src/lib.rs index 896428df6c..cf7c0065d9 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -38,6 +38,9 @@ pub enum Event { Chat { entity: EcsEntity, msg: String }, } +#[derive(Copy, Clone)] +struct SpawnPoint(Vec3); + pub struct Server { state: State, world: Arc, @@ -65,6 +68,7 @@ impl Server { let mut state = State::new(); state.ecs_mut().register::(); + state.ecs_mut().add_resource(SpawnPoint(Vec3::new(16_384.0, 16_384.0, 150.0))); let mut this = Self { state, @@ -81,6 +85,7 @@ impl Server { pending_chunks: HashSet::new(), }; + /* for i in 0..4 { this.create_npc( "Tobermory".to_owned(), @@ -90,6 +95,7 @@ impl Server { .with(comp::Agent::Wanderer(Vec2::zero())) .build(); } + */ Ok(this) } @@ -132,8 +138,10 @@ impl Server { name: String, body: comp::Body, ) { + let spawn_point = state.ecs().read_resource::().0; + state.write_component(entity, comp::Actor::Character { name, body }); - state.write_component(entity, comp::phys::Pos(Vec3::new(0.0, 0.0, 64.0))); + state.write_component(entity, comp::phys::Pos(spawn_point)); state.write_component(entity, comp::phys::Vel(Vec3::zero())); state.write_component(entity, comp::phys::Dir(Vec3::unit_y())); // Make sure everything is accepted.