From 1952785af251b1a3a1edfd73ba9e1d777d154c95 Mon Sep 17 00:00:00 2001 From: Imbris Date: Fri, 13 Nov 2020 19:43:32 -0500 Subject: [PATCH] Remove randomization of species and body_type with the randomize button in char creation --- common/src/comp/body/humanoid.rs | 6 +++--- voxygen/src/menu/char_selection/ui/mod.rs | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/common/src/comp/body/humanoid.rs b/common/src/comp/body/humanoid.rs index 2658672127..f00eefa529 100644 --- a/common/src/comp/body/humanoid.rs +++ b/common/src/comp/body/humanoid.rs @@ -42,9 +42,9 @@ impl Body { hair_style: rng.gen_range(0, species.num_hair_styles(body_type)), beard: rng.gen_range(0, species.num_beards(body_type)), accessory: rng.gen_range(0, species.num_accessories(body_type)), - hair_color: rng.gen_range(0, species.num_hair_colors()) as u8, - skin: rng.gen_range(0, species.num_skin_colors()) as u8, - eye_color: rng.gen_range(0, species.num_eye_colors()) as u8, + hair_color: rng.gen_range(0, species.num_hair_colors()), + skin: rng.gen_range(0, species.num_skin_colors()), + eye_color: rng.gen_range(0, species.num_eye_colors()), eyes: rng.gen_range(0, 1), /* TODO Add a way to set specific head-segments for NPCs * with the default being a random one */ } diff --git a/voxygen/src/menu/char_selection/ui/mod.rs b/voxygen/src/menu/char_selection/ui/mod.rs index f885664397..cc7325e3f2 100644 --- a/voxygen/src/menu/char_selection/ui/mod.rs +++ b/voxygen/src/menu/char_selection/ui/mod.rs @@ -1257,7 +1257,17 @@ impl Controls { Message::RandomizeCharacter => { if let Mode::Create { name, body, .. } = &mut self.mode { use common::npc; - *body = comp::humanoid::Body::random(); + use rand::Rng; + let body_type = body.body_type; + let species = body.species; + let mut rng = rand::thread_rng(); + body.hair_style = rng.gen_range(0, species.num_hair_styles(body_type)); + body.beard = rng.gen_range(0, species.num_beards(body_type)); + body.accessory = rng.gen_range(0, species.num_accessories(body_type)); + body.hair_color = rng.gen_range(0, species.num_hair_colors()); + body.skin = rng.gen_range(0, species.num_skin_colors()); + body.eye_color = rng.gen_range(0, species.num_eye_colors()); + body.eyes = rng.gen_range(0, species.num_eyes(body_type)); *name = npc::get_npc_name(npc::NpcKind::Humanoid).to_string(); } },