Move equipment from loadout into body

This commit is contained in:
timokoesters
2020-03-15 19:44:47 +01:00
parent 817cd24d54
commit 1f78344d6f
11 changed files with 258 additions and 169 deletions

View File

@ -1,8 +0,0 @@
Item(
name: "Assassin Chest",
description: "Only the best for a member of the creed.",
kind: Armor(
kind: Chest(Assassin),
stats: 20,
),
)

View File

@ -1,8 +0,0 @@
Item(
name: "Iron Chestplate",
description: "Arrows to the stomach are soooo last update.",
kind: Armor(
kind: Chest(PlateGreen0),
stats: 20,
),
)

View File

@ -26,7 +26,7 @@ impl Component for CharacterAbility {
type Storage = DenseVecStorage<Self>; type Storage = DenseVecStorage<Self>;
} }
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, PartialEq, Eq, Hash, Debug, Serialize, Deserialize)]
pub struct ItemConfig { pub struct ItemConfig {
pub item: Item, pub item: Item,
pub primary_ability: Option<CharacterAbility>, pub primary_ability: Option<CharacterAbility>,
@ -35,7 +35,7 @@ pub struct ItemConfig {
pub dodge_ability: Option<CharacterAbility>, pub dodge_ability: Option<CharacterAbility>,
} }
#[derive(Clone, Default, Debug, Serialize, Deserialize)] #[derive(Clone, PartialEq, Eq, Hash, Default, Debug, Serialize, Deserialize)]
pub struct Loadout { pub struct Loadout {
pub active_item: Option<ItemConfig>, pub active_item: Option<ItemConfig>,
pub second_item: Option<ItemConfig>, pub second_item: Option<ItemConfig>,

View File

@ -5,12 +5,6 @@ use vek::Rgb;
pub struct Body { pub struct Body {
pub race: Race, pub race: Race,
pub body_type: BodyType, pub body_type: BodyType,
pub chest: Chest,
pub belt: Belt,
pub pants: Pants,
pub hand: Hand,
pub foot: Foot,
pub shoulder: Shoulder,
pub hair_style: u8, pub hair_style: u8,
pub beard: u8, pub beard: u8,
pub eyebrows: Eyebrows, pub eyebrows: Eyebrows,
@ -33,12 +27,6 @@ impl Body {
Self { Self {
race, race,
body_type, body_type,
chest: *(&ALL_CHESTS).choose(rng).unwrap(),
belt: *(&ALL_BELTS).choose(rng).unwrap(),
pants: *(&ALL_PANTS).choose(rng).unwrap(),
hand: *(&ALL_HANDS).choose(rng).unwrap(),
foot: *(&ALL_FEET).choose(rng).unwrap(),
shoulder: *(&ALL_SHOULDERS).choose(rng).unwrap(),
hair_style: rng.gen_range(0, race.num_hair_styles(body_type)), hair_style: rng.gen_range(0, race.num_hair_styles(body_type)),
beard: rng.gen_range(0, race.num_beards(body_type)), beard: rng.gen_range(0, race.num_beards(body_type)),
eyebrows: *(&ALL_EYEBROWS).choose(rng).unwrap(), eyebrows: *(&ALL_EYEBROWS).choose(rng).unwrap(),

View File

@ -128,36 +128,15 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
comp::ItemKind::Armor { kind, .. } => { comp::ItemKind::Armor { kind, .. } => {
if let Some(loadout) = if let Some(loadout) =
state.ecs().write_storage::<comp::Loadout>().get_mut(entity) state.ecs().write_storage::<comp::Loadout>().get_mut(entity)
{
if let Some(comp::Body::Humanoid(body)) =
state.ecs().write_storage::<comp::Body>().get_mut(entity)
{ {
use comp::item::Armor::*; use comp::item::Armor::*;
let slot = match kind.clone() { let slot = match kind.clone() {
Shoulder(shoulder) => { Shoulder(_) => &mut loadout.shoulder,
body.shoulder = shoulder; Chest(_) => &mut loadout.chest,
&mut loadout.shoulder Belt(_) => &mut loadout.belt,
}, Hand(_) => &mut loadout.hand,
Chest(chest) => { Pants(_) => &mut loadout.pants,
body.chest = chest; Foot(_) => &mut loadout.foot,
&mut loadout.chest
},
Belt(belt) => {
body.belt = belt;
&mut loadout.belt
},
Hand(hand) => {
body.hand = hand;
&mut loadout.hand
},
Pants(pants) => {
body.pants = pants;
&mut loadout.pants
},
Foot(foot) => {
body.foot = foot;
&mut loadout.foot
},
}; };
// Insert old item into inventory // Insert old item into inventory
@ -171,7 +150,6 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
*slot = Some(item); *slot = Some(item);
} }
}
}, },
comp::ItemKind::Utility { kind } => match kind { comp::ItemKind::Utility { kind } => match kind {

View File

@ -112,18 +112,12 @@ impl PlayState for CharSelectionState {
} }
// Render the scene. // Render the scene.
let item = self let loadout = self.char_selection_ui.get_loadout();
.char_selection_ui
.get_character_data()
.and_then(|data| data.tool)
.and_then(|tool| assets::load_cloned::<comp::Item>(&tool).ok());
let item_kind = item.map(|i| i.kind);
self.scene.render( self.scene.render(
global_state.window.renderer_mut(), global_state.window.renderer_mut(),
self.client.borrow().get_tick(), self.client.borrow().get_tick(),
humanoid_body.clone(), humanoid_body.clone(),
item_kind.as_ref(), loadout,
); );
// Draw the UI to the screen. // Draw the UI to the screen.

View File

@ -12,7 +12,7 @@ use crate::{
}; };
use client::Client; use client::Client;
use common::{ use common::{
assets::load_expect, assets::{load_expect, load_glob},
comp::{self, humanoid}, comp::{self, humanoid},
}; };
use conrod_core::{ use conrod_core::{
@ -22,6 +22,7 @@ use conrod_core::{
widget::{text_box::Event as TextBoxEvent, Button, Image, Rectangle, Scrollbar, Text, TextBox}, widget::{text_box::Event as TextBoxEvent, Button, Image, Rectangle, Scrollbar, Text, TextBox},
widget_ids, Borderable, Color, Colorable, Labelable, Positionable, Sizeable, UiCell, Widget, widget_ids, Borderable, Color, Colorable, Labelable, Positionable, Sizeable, UiCell, Widget,
}; };
use std::{borrow::Borrow, sync::Arc};
const STARTER_HAMMER: &str = "common.items.weapons.starter_hammer"; const STARTER_HAMMER: &str = "common.items.weapons.starter_hammer";
const STARTER_BOW: &str = "common.items.weapons.starter_bow"; const STARTER_BOW: &str = "common.items.weapons.starter_bow";
@ -251,6 +252,7 @@ pub enum Mode {
Create { Create {
name: String, name: String,
body: humanoid::Body, body: humanoid::Body,
loadout: comp::Loadout,
tool: Option<&'static str>, tool: Option<&'static str>,
}, },
} }
@ -263,7 +265,7 @@ pub struct CharSelectionUi {
fonts: ConrodVoxygenFonts, fonts: ConrodVoxygenFonts,
//character_creation: bool, //character_creation: bool,
info_content: InfoContent, info_content: InfoContent,
voxygen_i18n: std::sync::Arc<VoxygenLocalization>, voxygen_i18n: Arc<VoxygenLocalization>,
//deletion_confirmation: bool, //deletion_confirmation: bool,
/* /*
pub character_name: String, pub character_name: String,
@ -317,7 +319,12 @@ impl CharSelectionUi {
pub fn get_character_data(&self) -> Option<CharacterData> { pub fn get_character_data(&self) -> Option<CharacterData> {
match &self.mode { match &self.mode {
Mode::Select(data) => data.clone(), Mode::Select(data) => data.clone(),
Mode::Create { name, body, tool } => Some(CharacterData { Mode::Create {
name,
body,
loadout,
tool,
} => Some(CharacterData {
name: name.clone(), name: name.clone(),
body: comp::Body::Humanoid(body.clone()), body: comp::Body::Humanoid(body.clone()),
tool: tool.map(|specifier| specifier.to_string()), tool: tool.map(|specifier| specifier.to_string()),
@ -325,6 +332,27 @@ impl CharSelectionUi {
} }
} }
pub fn get_loadout(&mut self) -> Option<&comp::Loadout> {
match &mut self.mode {
Mode::Select(_) => None,
Mode::Create {
name,
body,
loadout,
tool,
} => {
loadout.active_item = tool.map(|tool| comp::ItemConfig {
item: (*load_expect::<comp::Item>(tool)).clone(),
primary_ability: None,
secondary_ability: None,
block_ability: None,
dodge_ability: None,
});
Some(loadout)
},
}
}
// TODO: Split this into multiple modules or functions. // TODO: Split this into multiple modules or functions.
fn update_layout(&mut self, global_state: &mut GlobalState, client: &Client) -> Vec<Event> { fn update_layout(&mut self, global_state: &mut GlobalState, client: &Client) -> Vec<Event> {
let mut events = Vec::new(); let mut events = Vec::new();
@ -646,13 +674,19 @@ impl CharSelectionUi {
self.mode = Mode::Create { self.mode = Mode::Create {
name: "Character Name".to_string(), name: "Character Name".to_string(),
body: humanoid::Body::random(), body: humanoid::Body::random(),
loadout: comp::Loadout::default(),
tool: Some(STARTER_SWORD), tool: Some(STARTER_SWORD),
}; };
} }
}, },
// Character_Creation // Character_Creation
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
Mode::Create { name, body, tool } => { Mode::Create {
name,
body,
loadout,
tool,
} => {
let mut to_select = false; let mut to_select = false;
// Back Button // Back Button
if Button::image(self.imgs.button) if Button::image(self.imgs.button)
@ -1266,20 +1300,27 @@ impl CharSelectionUi {
.set(self.ids.beard_slider, ui_widgets); .set(self.ids.beard_slider, ui_widgets);
} }
// Chest // Chest
let current_chest = body.chest; let armor = load_glob::<comp::Item>("common.items.armor.chest.*")
.expect("Unable to load armor!");
if let Some(new_val) = char_slider( if let Some(new_val) = char_slider(
self.ids.beard_slider, self.ids.beard_slider,
self.voxygen_i18n.get("char_selection.chest_color"), self.voxygen_i18n.get("char_selection.chest_color"),
self.ids.chest_text, self.ids.chest_text,
humanoid::ALL_CHESTS.len() - 1, armor.len() - 1,
humanoid::ALL_CHESTS armor
.iter() .iter()
.position(|&c| c == current_chest) .position(|c| {
loadout
.chest
.as_ref()
.map(|lc| lc == c.borrow())
.unwrap_or_default()
})
.unwrap_or(0), .unwrap_or(0),
self.ids.chest_slider, self.ids.chest_slider,
ui_widgets, ui_widgets,
) { ) {
body.chest = humanoid::ALL_CHESTS[new_val]; loadout.chest = Some((*armor[new_val]).clone());
} }
// Pants // Pants
/*let current_pants = body.pants; /*let current_pants = body.pants;

View File

@ -6,7 +6,7 @@ use crate::{
}; };
use common::{ use common::{
assets::watch::ReloadIndicator, assets::watch::ReloadIndicator,
comp::{Body, CharacterState, ItemKind}, comp::{Body, CharacterState, ItemKind, Loadout},
}; };
use hashbrown::{hash_map::Entry, HashMap}; use hashbrown::{hash_map::Entry, HashMap};
use std::{ use std::{
@ -19,7 +19,7 @@ enum FigureKey {
Simple(Body), Simple(Body),
Complex( Complex(
Body, Body,
Option<ItemKind>, Option<Loadout>,
CameraMode, CameraMode,
Option<CharacterStateCacheKey>, Option<CharacterStateCacheKey>,
), ),
@ -58,7 +58,7 @@ impl<Skel: Skeleton> FigureModelCache<Skel> {
&mut self, &mut self,
renderer: &mut Renderer, renderer: &mut Renderer,
body: Body, body: Body,
item_kind: Option<&ItemKind>, loadout: Option<&Loadout>,
tick: u64, tick: u64,
camera_mode: CameraMode, camera_mode: CameraMode,
character_state: Option<&CharacterState>, character_state: Option<&CharacterState>,
@ -67,10 +67,10 @@ impl<Skel: Skeleton> FigureModelCache<Skel> {
for<'a> &'a common::comp::Body: std::convert::TryInto<Skel::Attr>, for<'a> &'a common::comp::Body: std::convert::TryInto<Skel::Attr>,
Skel::Attr: Default, Skel::Attr: Default,
{ {
let key = if item_kind.is_some() { let key = if loadout.is_some() {
FigureKey::Complex( FigureKey::Complex(
body, body,
item_kind.cloned(), loadout.cloned(),
camera_mode, camera_mode,
character_state.map(|cs| CharacterStateCacheKey::from(cs)), character_state.map(|cs| CharacterStateCacheKey::from(cs)),
) )
@ -106,6 +106,10 @@ impl<Skel: Skeleton> FigureModelCache<Skel> {
let humanoid_armor_foot_spec = let humanoid_armor_foot_spec =
HumArmorFootSpec::load_watched(&mut self.manifest_indicator); HumArmorFootSpec::load_watched(&mut self.manifest_indicator);
// TODO: This is bad code, maybe this method should return Option<_>
let default_loadout = Loadout::default();
let loadout = loadout.unwrap_or(&default_loadout);
[ [
match camera_mode { match camera_mode {
CameraMode::ThirdPerson => { CameraMode::ThirdPerson => {
@ -124,21 +128,21 @@ impl<Skel: Skeleton> FigureModelCache<Skel> {
CameraMode::FirstPerson => None, CameraMode::FirstPerson => None,
}, },
match camera_mode { match camera_mode {
CameraMode::ThirdPerson => { CameraMode::ThirdPerson => Some(
Some(humanoid_armor_chest_spec.mesh_chest(&body)) humanoid_armor_chest_spec.mesh_chest(&body, loadout),
}, ),
CameraMode::FirstPerson => None, CameraMode::FirstPerson => None,
}, },
match camera_mode { match camera_mode {
CameraMode::ThirdPerson => { CameraMode::ThirdPerson => {
Some(humanoid_armor_belt_spec.mesh_belt(&body)) Some(humanoid_armor_belt_spec.mesh_belt(&body, loadout))
}, },
CameraMode::FirstPerson => None, CameraMode::FirstPerson => None,
}, },
match camera_mode { match camera_mode {
CameraMode::ThirdPerson => { CameraMode::ThirdPerson => Some(
Some(humanoid_armor_pants_spec.mesh_pants(&body)) humanoid_armor_pants_spec.mesh_pants(&body, loadout),
}, ),
CameraMode::FirstPerson => None, CameraMode::FirstPerson => None,
}, },
if camera_mode == CameraMode::FirstPerson if camera_mode == CameraMode::FirstPerson
@ -148,34 +152,42 @@ impl<Skel: Skeleton> FigureModelCache<Skel> {
{ {
None None
} else { } else {
Some(humanoid_armor_hand_spec.mesh_left_hand(&body)) Some(
humanoid_armor_hand_spec.mesh_left_hand(&body, loadout),
)
}, },
if character_state.map(|cs| cs.is_dodge()).unwrap_or_default() { if character_state.map(|cs| cs.is_dodge()).unwrap_or_default() {
None None
} else { } else {
Some(humanoid_armor_hand_spec.mesh_right_hand(&body)) Some(
}, humanoid_armor_hand_spec
match camera_mode { .mesh_right_hand(&body, loadout),
CameraMode::ThirdPerson => { )
Some(humanoid_armor_foot_spec.mesh_left_foot(&body))
},
CameraMode::FirstPerson => None,
},
match camera_mode {
CameraMode::ThirdPerson => {
Some(humanoid_armor_foot_spec.mesh_right_foot(&body))
},
CameraMode::FirstPerson => None,
}, },
match camera_mode { match camera_mode {
CameraMode::ThirdPerson => Some( CameraMode::ThirdPerson => Some(
humanoid_armor_shoulder_spec.mesh_left_shoulder(&body), humanoid_armor_foot_spec.mesh_left_foot(&body, loadout),
), ),
CameraMode::FirstPerson => None, CameraMode::FirstPerson => None,
}, },
match camera_mode { match camera_mode {
CameraMode::ThirdPerson => Some( CameraMode::ThirdPerson => Some(
humanoid_armor_shoulder_spec.mesh_right_shoulder(&body), humanoid_armor_foot_spec
.mesh_right_foot(&body, loadout),
),
CameraMode::FirstPerson => None,
},
match camera_mode {
CameraMode::ThirdPerson => Some(
humanoid_armor_shoulder_spec
.mesh_left_shoulder(&body, loadout),
),
CameraMode::FirstPerson => None,
},
match camera_mode {
CameraMode::ThirdPerson => Some(
humanoid_armor_shoulder_spec
.mesh_right_shoulder(&body, loadout),
), ),
CameraMode::FirstPerson => None, CameraMode::FirstPerson => None,
}, },
@ -187,7 +199,9 @@ impl<Skel: Skeleton> FigureModelCache<Skel> {
}) })
.unwrap_or_default() .unwrap_or_default()
{ {
Some(mesh_main(item_kind)) Some(mesh_main(
loadout.active_item.as_ref().map(|i| &i.item.kind),
))
} else { } else {
None None
}, },

View File

@ -14,11 +14,11 @@ use common::{
Belt, Body, BodyType, Chest, EyeColor, Eyebrows, Foot, Hand, Pants, Race, Shoulder, Belt, Body, BodyType, Chest, EyeColor, Eyebrows, Foot, Hand, Pants, Race, Shoulder,
Skin, Skin,
}, },
item::{ToolData, ToolKind}, item::{Armor, ToolData, ToolKind},
object, object,
quadruped_medium::{BodyType as QMBodyType, Species as QMSpecies}, quadruped_medium::{BodyType as QMBodyType, Species as QMSpecies},
quadruped_small::{BodyType as QSBodyType, Species as QSSpecies}, quadruped_small::{BodyType as QSBodyType, Species as QSSpecies},
Item, ItemKind, Item, ItemKind, Loadout,
}, },
figure::{DynaUnionizer, MatSegment, Material, Segment}, figure::{DynaUnionizer, MatSegment, Material, Segment},
}; };
@ -293,11 +293,21 @@ impl HumArmorShoulderSpec {
.unwrap() .unwrap()
} }
pub fn mesh_left_shoulder(&self, body: &Body) -> Mesh<FigurePipeline> { pub fn mesh_left_shoulder(&self, body: &Body, loadout: &Loadout) -> Mesh<FigurePipeline> {
let spec = match self.0.get(&body.shoulder) { let shoulder = if let Some(ItemKind::Armor {
kind: Armor::Shoulder(shoulder),
..
}) = loadout.shoulder.as_ref().map(|i| &i.kind)
{
shoulder
} else {
&Shoulder::None
};
let spec = match self.0.get(&shoulder) {
Some(spec) => spec, Some(spec) => spec,
None => { None => {
error!("No shoulder specification exists for {:?}", body.shoulder); error!("No shoulder specification exists for {:?}", shoulder);
return load_mesh("not_found", Vec3::new(-3.0, -3.5, 0.1)); return load_mesh("not_found", Vec3::new(-3.0, -3.5, 0.1));
}, },
}; };
@ -312,11 +322,21 @@ impl HumArmorShoulderSpec {
generate_mesh(&shoulder_segment, Vec3::from(spec.left.vox_spec.1)) generate_mesh(&shoulder_segment, Vec3::from(spec.left.vox_spec.1))
} }
pub fn mesh_right_shoulder(&self, body: &Body) -> Mesh<FigurePipeline> { pub fn mesh_right_shoulder(&self, body: &Body, loadout: &Loadout) -> Mesh<FigurePipeline> {
let spec = match self.0.get(&body.shoulder) { let shoulder = if let Some(ItemKind::Armor {
kind: Armor::Shoulder(shoulder),
..
}) = loadout.shoulder.as_ref().map(|i| &i.kind)
{
shoulder
} else {
&Shoulder::None
};
let spec = match self.0.get(&shoulder) {
Some(spec) => spec, Some(spec) => spec,
None => { None => {
error!("No shoulder specification exists for {:?}", body.shoulder); error!("No shoulder specification exists for {:?}", shoulder);
return load_mesh("not_found", Vec3::new(-2.0, -3.5, 0.1)); return load_mesh("not_found", Vec3::new(-2.0, -3.5, 0.1));
}, },
}; };
@ -338,11 +358,21 @@ impl HumArmorChestSpec {
.unwrap() .unwrap()
} }
pub fn mesh_chest(&self, body: &Body) -> Mesh<FigurePipeline> { pub fn mesh_chest(&self, body: &Body, loadout: &Loadout) -> Mesh<FigurePipeline> {
let spec = match self.0.get(&body.chest) { let chest = if let Some(ItemKind::Armor {
kind: Armor::Chest(chest),
..
}) = loadout.chest.as_ref().map(|i| &i.kind)
{
chest
} else {
&Chest::Blue
};
let spec = match self.0.get(&chest) {
Some(spec) => spec, Some(spec) => spec,
None => { None => {
error!("No chest specification exists for {:?}", body.chest); error!("No chest specification exists for {:?}", loadout.chest);
return load_mesh("not_found", Vec3::new(-7.0, -3.5, 2.0)); return load_mesh("not_found", Vec3::new(-7.0, -3.5, 2.0));
}, },
}; };
@ -381,11 +411,21 @@ impl HumArmorHandSpec {
.unwrap() .unwrap()
} }
pub fn mesh_left_hand(&self, body: &Body) -> Mesh<FigurePipeline> { pub fn mesh_left_hand(&self, body: &Body, loadout: &Loadout) -> Mesh<FigurePipeline> {
let spec = match self.0.get(&body.hand) { let hand = if let Some(ItemKind::Armor {
kind: Armor::Hand(hand),
..
}) = loadout.hand.as_ref().map(|i| &i.kind)
{
hand
} else {
&Hand::Bare
};
let spec = match self.0.get(&hand) {
Some(spec) => spec, Some(spec) => spec,
None => { None => {
error!("No hand specification exists for {:?}", body.hand); error!("No hand specification exists for {:?}", hand);
return load_mesh("not_found", Vec3::new(-1.5, -1.5, -7.0)); return load_mesh("not_found", Vec3::new(-1.5, -1.5, -7.0));
}, },
}; };
@ -400,11 +440,21 @@ impl HumArmorHandSpec {
generate_mesh(&hand_segment, Vec3::from(spec.left.vox_spec.1)) generate_mesh(&hand_segment, Vec3::from(spec.left.vox_spec.1))
} }
pub fn mesh_right_hand(&self, body: &Body) -> Mesh<FigurePipeline> { pub fn mesh_right_hand(&self, body: &Body, loadout: &Loadout) -> Mesh<FigurePipeline> {
let spec = match self.0.get(&body.hand) { let hand = if let Some(ItemKind::Armor {
kind: Armor::Hand(hand),
..
}) = loadout.hand.as_ref().map(|i| &i.kind)
{
hand
} else {
&Hand::Bare
};
let spec = match self.0.get(&hand) {
Some(spec) => spec, Some(spec) => spec,
None => { None => {
error!("No hand specification exists for {:?}", body.hand); error!("No hand specification exists for {:?}", hand);
return load_mesh("not_found", Vec3::new(-1.5, -1.5, -7.0)); return load_mesh("not_found", Vec3::new(-1.5, -1.5, -7.0));
}, },
}; };
@ -426,11 +476,21 @@ impl HumArmorBeltSpec {
.unwrap() .unwrap()
} }
pub fn mesh_belt(&self, body: &Body) -> Mesh<FigurePipeline> { pub fn mesh_belt(&self, body: &Body, loadout: &Loadout) -> Mesh<FigurePipeline> {
let spec = match self.0.get(&body.belt) { let belt = if let Some(ItemKind::Armor {
kind: Armor::Belt(belt),
..
}) = loadout.belt.as_ref().map(|i| &i.kind)
{
belt
} else {
&Belt::Dark
};
let spec = match self.0.get(&belt) {
Some(spec) => spec, Some(spec) => spec,
None => { None => {
error!("No belt specification exists for {:?}", body.belt); error!("No belt specification exists for {:?}", belt);
return load_mesh("not_found", Vec3::new(-4.0, -3.5, 2.0)); return load_mesh("not_found", Vec3::new(-4.0, -3.5, 2.0));
}, },
}; };
@ -452,11 +512,21 @@ impl HumArmorPantsSpec {
.unwrap() .unwrap()
} }
pub fn mesh_pants(&self, body: &Body) -> Mesh<FigurePipeline> { pub fn mesh_pants(&self, body: &Body, loadout: &Loadout) -> Mesh<FigurePipeline> {
let spec = match self.0.get(&body.pants) { let pants = if let Some(ItemKind::Armor {
kind: Armor::Pants(pants),
..
}) = loadout.pants.as_ref().map(|i| &i.kind)
{
pants
} else {
&Pants::Dark
};
let spec = match self.0.get(&pants) {
Some(spec) => spec, Some(spec) => spec,
None => { None => {
error!("No pants specification exists for {:?}", body.pants); error!("No pants specification exists for {:?}", pants);
return load_mesh("not_found", Vec3::new(-5.0, -3.5, 1.0)); return load_mesh("not_found", Vec3::new(-5.0, -3.5, 1.0));
}, },
}; };
@ -495,11 +565,21 @@ impl HumArmorFootSpec {
.unwrap() .unwrap()
} }
pub fn mesh_left_foot(&self, body: &Body) -> Mesh<FigurePipeline> { pub fn mesh_left_foot(&self, body: &Body, loadout: &Loadout) -> Mesh<FigurePipeline> {
let spec = match self.0.get(&body.foot) { let foot = if let Some(ItemKind::Armor {
kind: Armor::Foot(foot),
..
}) = loadout.foot.as_ref().map(|i| &i.kind)
{
foot
} else {
&Foot::Bare
};
let spec = match self.0.get(&foot) {
Some(spec) => spec, Some(spec) => spec,
None => { None => {
error!("No foot specification exists for {:?}", body.foot); error!("No foot specification exists for {:?}", foot);
return load_mesh("not_found", Vec3::new(-2.5, -3.5, -9.0)); return load_mesh("not_found", Vec3::new(-2.5, -3.5, -9.0));
}, },
}; };
@ -514,11 +594,21 @@ impl HumArmorFootSpec {
generate_mesh(&foot_segment, Vec3::from(spec.vox_spec.1)) generate_mesh(&foot_segment, Vec3::from(spec.vox_spec.1))
} }
pub fn mesh_right_foot(&self, body: &Body) -> Mesh<FigurePipeline> { pub fn mesh_right_foot(&self, body: &Body, loadout: &Loadout) -> Mesh<FigurePipeline> {
let spec = match self.0.get(&body.foot) { let foot = if let Some(ItemKind::Armor {
kind: Armor::Foot(foot),
..
}) = loadout.foot.as_ref().map(|i| &i.kind)
{
foot
} else {
&Foot::Bare
};
let spec = match self.0.get(&foot) {
Some(spec) => spec, Some(spec) => spec,
None => { None => {
error!("No foot specification exists for {:?}", body.foot); error!("No foot specification exists for {:?}", foot);
return load_mesh("not_found", Vec3::new(-2.5, -3.5, -9.0)); return load_mesh("not_found", Vec3::new(-2.5, -3.5, -9.0));
}, },
}; };

View File

@ -400,7 +400,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
CameraMode::default(), CameraMode::default(),
None, None,
@ -580,7 +580,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
CameraMode::default(), CameraMode::default(),
None, None,
@ -661,7 +661,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
CameraMode::default(), CameraMode::default(),
None, None,
@ -744,7 +744,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
CameraMode::default(), CameraMode::default(),
None, None,
@ -819,7 +819,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
CameraMode::default(), CameraMode::default(),
None, None,
@ -894,7 +894,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
CameraMode::default(), CameraMode::default(),
None, None,
@ -969,7 +969,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
CameraMode::default(), CameraMode::default(),
None, None,
@ -1044,7 +1044,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
CameraMode::default(), CameraMode::default(),
None, None,
@ -1119,7 +1119,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
CameraMode::default(), CameraMode::default(),
None, None,
@ -1194,7 +1194,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
CameraMode::default(), CameraMode::default(),
None, None,
@ -1386,7 +1386,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
player_camera_mode, player_camera_mode,
character_state, character_state,
@ -1402,7 +1402,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
player_camera_mode, player_camera_mode,
character_state, character_state,
@ -1418,7 +1418,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
player_camera_mode, player_camera_mode,
character_state, character_state,
@ -1434,7 +1434,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
player_camera_mode, player_camera_mode,
character_state, character_state,
@ -1450,7 +1450,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
player_camera_mode, player_camera_mode,
character_state, character_state,
@ -1466,7 +1466,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
player_camera_mode, player_camera_mode,
character_state, character_state,
@ -1482,7 +1482,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
player_camera_mode, player_camera_mode,
character_state, character_state,
@ -1498,7 +1498,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
player_camera_mode, player_camera_mode,
character_state, character_state,
@ -1514,7 +1514,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
player_camera_mode, player_camera_mode,
character_state, character_state,
@ -1530,7 +1530,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
player_camera_mode, player_camera_mode,
character_state, character_state,
@ -1546,7 +1546,7 @@ impl FigureMgr {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
*body, *body,
active_item_kind, loadout,
tick, tick,
player_camera_mode, player_camera_mode,
character_state, character_state,

View File

@ -15,7 +15,7 @@ use crate::{
window::{Event, PressState}, window::{Event, PressState},
}; };
use common::{ use common::{
comp::{humanoid, Body, ItemKind}, comp::{humanoid, Body, ItemKind, Loadout},
terrain::BlockKind, terrain::BlockKind,
vol::{BaseVol, ReadVol, Vox}, vol::{BaseVol, ReadVol, Vox},
}; };
@ -208,7 +208,7 @@ impl Scene {
renderer: &mut Renderer, renderer: &mut Renderer,
tick: u64, tick: u64,
body: Option<humanoid::Body>, body: Option<humanoid::Body>,
active_item_kind: Option<&ItemKind>, loadout: Option<&Loadout>,
) { ) {
renderer.render_skybox(&self.skybox.model, &self.globals, &self.skybox.locals); renderer.render_skybox(&self.skybox.model, &self.globals, &self.skybox.locals);
@ -218,7 +218,7 @@ impl Scene {
.get_or_create_model( .get_or_create_model(
renderer, renderer,
Body::Humanoid(body), Body::Humanoid(body),
active_item_kind, loadout,
tick, tick,
CameraMode::default(), CameraMode::default(),
None, None,