diff --git a/server/src/cmd.rs b/server/src/cmd.rs index cbd5b2b99f..e03e28bdc1 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -411,7 +411,7 @@ fn handle_spawn(server: &mut Server, entity: EcsEntity, args: String, action: &C let body = kind_to_body(id); server - .create_npc(pos, get_npc_name(id), body) + .create_npc(pos, comp::Stats::new(get_npc_name(id)), body) .with(comp::Vel(vel)) .with(agent) .build(); diff --git a/server/src/lib.rs b/server/src/lib.rs index 60eb1c42e2..8eb3cbd0e1 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -142,7 +142,7 @@ impl Server { pub fn create_npc( &mut self, pos: comp::Pos, - name: String, + stats: comp::Stats, body: comp::Body, ) -> EcsEntityBuilder { self.state @@ -153,7 +153,7 @@ impl Server { .with(comp::Ori(Vec3::unit_y())) .with(comp::Controller::default()) .with(body) - .with(comp::Stats::new(name)) + .with(stats) .with(comp::CharacterState::default()) } @@ -174,8 +174,7 @@ impl Server { offset: Vec3::unit_z(), ..comp::LightEmitter::default() }) - //.with(comp::LightEmitter::default()) - .with(comp::CharacterState::default()) + //.with(comp::LightEmitter::default()) } pub fn create_player_character( @@ -421,16 +420,7 @@ impl Server { scale = 2.5 + rand::random::(); } - self.state - .ecs_mut() - .create_entity_synced() - .with(comp::Pos(npc.pos)) - .with(comp::Vel(Vec3::zero())) - .with(comp::Ori(Vec3::unit_y())) - .with(comp::Controller::default()) - .with(body) - .with(stats) - .with(comp::CharacterState::default()) + self.create_npc(comp::Pos(npc.pos), stats, body) .with(comp::Agent::enemy()) .with(comp::Scale(scale)) .build();