mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'pfau/fix-char-creation' into 'master'
Fixed char select bugs, improved code quality See merge request veloren/veloren!739
This commit is contained in:
commit
2ddb6d362e
@ -65,12 +65,14 @@ impl PlayState for CharSelectionState {
|
|||||||
return PlayStateResult::Pop;
|
return PlayStateResult::Pop;
|
||||||
}
|
}
|
||||||
ui::Event::Play => {
|
ui::Event::Play => {
|
||||||
|
let char_data = self
|
||||||
|
.char_selection_ui
|
||||||
|
.get_character_data()
|
||||||
|
.expect("Character data is required to play");
|
||||||
self.client.borrow_mut().request_character(
|
self.client.borrow_mut().request_character(
|
||||||
self.char_selection_ui.character_name.clone(),
|
char_data.name,
|
||||||
comp::Body::Humanoid(self.char_selection_ui.character_body),
|
char_data.body,
|
||||||
self.char_selection_ui
|
char_data.tool,
|
||||||
.character_tool
|
|
||||||
.map(|specifier| specifier.to_owned()),
|
|
||||||
);
|
);
|
||||||
return PlayStateResult::Push(Box::new(SessionState::new(
|
return PlayStateResult::Push(Box::new(SessionState::new(
|
||||||
global_state,
|
global_state,
|
||||||
@ -83,23 +85,32 @@ impl PlayState for CharSelectionState {
|
|||||||
// Maintain global state.
|
// Maintain global state.
|
||||||
global_state.maintain(clock.get_last_delta().as_secs_f32());
|
global_state.maintain(clock.get_last_delta().as_secs_f32());
|
||||||
|
|
||||||
|
let humanoid_body = self
|
||||||
|
.char_selection_ui
|
||||||
|
.get_character_data()
|
||||||
|
.and_then(|data| match data.body {
|
||||||
|
comp::Body::Humanoid(body) => Some(body),
|
||||||
|
_ => None,
|
||||||
|
});
|
||||||
|
|
||||||
// Maintain the scene.
|
// Maintain the scene.
|
||||||
self.scene.maintain(
|
self.scene.maintain(
|
||||||
global_state.window.renderer_mut(),
|
global_state.window.renderer_mut(),
|
||||||
&self.client.borrow(),
|
&self.client.borrow(),
|
||||||
self.char_selection_ui.character_body,
|
humanoid_body.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Render the scene.
|
// Render the scene.
|
||||||
self.scene.render(
|
self.scene.render(
|
||||||
global_state.window.renderer_mut(),
|
global_state.window.renderer_mut(),
|
||||||
&self.client.borrow(),
|
&self.client.borrow(),
|
||||||
self.char_selection_ui.character_body,
|
humanoid_body.clone(),
|
||||||
&comp::Equipment {
|
&comp::Equipment {
|
||||||
main: self
|
main: self
|
||||||
.char_selection_ui
|
.char_selection_ui
|
||||||
.character_tool
|
.get_character_data()
|
||||||
.and_then(|specifier| assets::load_cloned(&specifier).ok()),
|
.and_then(|data| data.tool)
|
||||||
|
.and_then(|tool| assets::load_cloned(&tool).ok()),
|
||||||
alt: None,
|
alt: None,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -115,7 +115,12 @@ impl Scene {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn maintain(&mut self, renderer: &mut Renderer, client: &Client, body: humanoid::Body) {
|
pub fn maintain(
|
||||||
|
&mut self,
|
||||||
|
renderer: &mut Renderer,
|
||||||
|
client: &Client,
|
||||||
|
body: Option<humanoid::Body>,
|
||||||
|
) {
|
||||||
self.camera.set_focus_pos(Vec3::unit_z() * 1.5);
|
self.camera.set_focus_pos(Vec3::unit_z() * 1.5);
|
||||||
self.camera.update(client.state().get_time());
|
self.camera.update(client.state().get_time());
|
||||||
self.camera.set_distance(3.0); // 4.2
|
self.camera.set_distance(3.0); // 4.2
|
||||||
@ -147,17 +152,19 @@ impl Scene {
|
|||||||
|
|
||||||
self.figure_model_cache.clean(client.get_tick());
|
self.figure_model_cache.clean(client.get_tick());
|
||||||
|
|
||||||
let tgt_skeleton = IdleAnimation::update_skeleton(
|
if let Some(body) = body {
|
||||||
self.figure_state.skeleton_mut(),
|
let tgt_skeleton = IdleAnimation::update_skeleton(
|
||||||
client.state().get_time(),
|
self.figure_state.skeleton_mut(),
|
||||||
client.state().get_time(),
|
client.state().get_time(),
|
||||||
&mut 0.0,
|
client.state().get_time(),
|
||||||
&SkeletonAttr::from(&body),
|
&mut 0.0,
|
||||||
);
|
&SkeletonAttr::from(&body),
|
||||||
self.figure_state.skeleton_mut().interpolate(
|
);
|
||||||
&tgt_skeleton,
|
self.figure_state.skeleton_mut().interpolate(
|
||||||
client.state().ecs().read_resource::<DeltaTime>().0,
|
&tgt_skeleton,
|
||||||
);
|
client.state().ecs().read_resource::<DeltaTime>().0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
self.figure_state.update(
|
self.figure_state.update(
|
||||||
renderer,
|
renderer,
|
||||||
@ -178,31 +185,33 @@ impl Scene {
|
|||||||
&mut self,
|
&mut self,
|
||||||
renderer: &mut Renderer,
|
renderer: &mut Renderer,
|
||||||
client: &Client,
|
client: &Client,
|
||||||
body: humanoid::Body,
|
body: Option<humanoid::Body>,
|
||||||
equipment: &Equipment,
|
equipment: &Equipment,
|
||||||
) {
|
) {
|
||||||
renderer.render_skybox(&self.skybox.model, &self.globals, &self.skybox.locals);
|
renderer.render_skybox(&self.skybox.model, &self.globals, &self.skybox.locals);
|
||||||
|
|
||||||
let model = &self
|
if let Some(body) = body {
|
||||||
.figure_model_cache
|
let model = &self
|
||||||
.get_or_create_model(
|
.figure_model_cache
|
||||||
renderer,
|
.get_or_create_model(
|
||||||
Body::Humanoid(body),
|
renderer,
|
||||||
Some(equipment),
|
Body::Humanoid(body),
|
||||||
client.get_tick(),
|
Some(equipment),
|
||||||
CameraMode::default(),
|
client.get_tick(),
|
||||||
None,
|
CameraMode::default(),
|
||||||
)
|
None,
|
||||||
.0;
|
)
|
||||||
|
.0;
|
||||||
|
|
||||||
renderer.render_figure(
|
renderer.render_figure(
|
||||||
model,
|
model,
|
||||||
&self.globals,
|
&self.globals,
|
||||||
self.figure_state.locals(),
|
self.figure_state.locals(),
|
||||||
self.figure_state.bone_consts(),
|
self.figure_state.bone_consts(),
|
||||||
&self.lights,
|
&self.lights,
|
||||||
&self.shadows,
|
&self.shadows,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
renderer.render_figure(
|
renderer.render_figure(
|
||||||
&self.backdrop_model,
|
&self.backdrop_model,
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,7 @@ use std::{fs, io, path::PathBuf};
|
|||||||
pub struct CharacterData {
|
pub struct CharacterData {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub body: comp::Body,
|
pub body: comp::Body,
|
||||||
|
pub tool: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||||
|
Loading…
Reference in New Issue
Block a user