Fix char selection not showing tools

This commit is contained in:
timokoesters 2020-03-27 18:17:41 +01:00
parent 6fd3339b75
commit 6fe5c5724c
3 changed files with 27 additions and 5 deletions

View File

@ -28,7 +28,7 @@ impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data);
handle_move(data, &mut update, 0.2);
handle_move(data, &mut update, 0.3);
handle_jump(data, &mut update);
if self.prepare_timer < self.prepare_duration

View File

@ -117,7 +117,7 @@ impl PlayState for CharSelectionState {
global_state.window.renderer_mut(),
self.client.borrow().get_tick(),
humanoid_body.clone(),
loadout,
loadout.as_ref(),
);
// Draw the UI to the screen.

View File

@ -333,9 +333,31 @@ impl CharSelectionUi {
}
}
pub fn get_loadout(&mut self) -> Option<&comp::Loadout> {
pub fn get_loadout(&mut self) -> Option<comp::Loadout> {
match &mut self.mode {
Mode::Select(_) => None,
Mode::Select(characterdata) => {
let loadout = comp::Loadout {
active_item: characterdata
.as_ref()
.and_then(|d| d.tool.as_ref())
.map(|tool| comp::ItemConfig {
item: (*load_expect::<comp::Item>(&tool)).clone(),
ability1: None,
ability2: None,
ability3: None,
block_ability: None,
dodge_ability: None,
}),
second_item: None,
shoulder: None,
chest: None,
belt: None,
hand: None,
pants: None,
foot: None,
};
Some(loadout)
},
Mode::Create { loadout, tool, .. } => {
loadout.active_item = tool.map(|tool| comp::ItemConfig {
item: (*load_expect::<comp::Item>(tool)).clone(),
@ -345,7 +367,7 @@ impl CharSelectionUi {
block_ability: None,
dodge_ability: None,
});
Some(loadout)
Some(loadout.clone())
},
}
}