mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add character select network event
This commit is contained in:
parent
136bf271b8
commit
730399b5f4
@ -750,18 +750,35 @@ impl Client {
|
||||
uid,
|
||||
char_info,
|
||||
)) => {
|
||||
warn!(
|
||||
"ServerMsg::PlayerListUpdate PlayerListUpdate::LevelChange not \
|
||||
implemented: {} {:?}",
|
||||
uid, char_info
|
||||
);
|
||||
if let Some(player_info) = self.player_list.get_mut(&uid) {
|
||||
player_info.character = Some(char_info);
|
||||
} else {
|
||||
warn!(
|
||||
"Received msg to update character info for uid {}, but they were \
|
||||
not in the list.",
|
||||
uid
|
||||
);
|
||||
}
|
||||
},
|
||||
ServerMsg::PlayerListUpdate(PlayerListUpdate::LevelChange(uid, next_level)) => {
|
||||
warn!(
|
||||
"ServerMsg::PlayerListUpdate PlayerListUpdate::LevelChange not \
|
||||
implemented: {} {}",
|
||||
uid, next_level
|
||||
);
|
||||
if let Some(player_info) = self.player_list.get_mut(&uid) {
|
||||
if let Some(character) = &player_info.character {
|
||||
// TODO: assign next value
|
||||
// &character.level = next_level;
|
||||
} else {
|
||||
warn!(
|
||||
"Received msg to update character level info to {} for uid \
|
||||
{}, but this player's character is None.",
|
||||
next_level, uid
|
||||
);
|
||||
}
|
||||
} else {
|
||||
warn!(
|
||||
"Received msg to update character level info to {} for uid {}, \
|
||||
but they were not in the list.",
|
||||
next_level, uid
|
||||
);
|
||||
}
|
||||
},
|
||||
ServerMsg::PlayerListUpdate(PlayerListUpdate::Remove(uid)) => {
|
||||
if self.player_list.remove(&uid).is_none() {
|
||||
|
@ -6,7 +6,9 @@ use common::{
|
||||
assets,
|
||||
comp::{self, item},
|
||||
effect::Effect,
|
||||
msg::{ClientState, RegisterError, RequestStateError, ServerMsg},
|
||||
msg::{
|
||||
CharacterInfo, ClientState, PlayerListUpdate, RegisterError, RequestStateError, ServerMsg,
|
||||
},
|
||||
state::State,
|
||||
sync::{Uid, WorldSyncExt},
|
||||
util::Dir,
|
||||
@ -279,6 +281,24 @@ impl StateExt for State {
|
||||
self.write_component(entity, comp::Admin);
|
||||
}
|
||||
|
||||
let uids = &self.ecs().read_storage::<Uid>();
|
||||
let uid = uids
|
||||
.get(entity)
|
||||
.expect("Failed to fetch uid component for entity.")
|
||||
.0;
|
||||
|
||||
let stats = &self.ecs().read_storage::<comp::Stats>();
|
||||
let stat = stats
|
||||
.get(entity)
|
||||
.expect("Failed to fetch stats component for entity.");
|
||||
|
||||
self.notify_registered_clients(ServerMsg::PlayerListUpdate(
|
||||
PlayerListUpdate::SelectedCharacter(uid, CharacterInfo {
|
||||
name: stat.name.to_string(),
|
||||
level: stat.level.level(),
|
||||
}),
|
||||
));
|
||||
|
||||
// Tell the client its request was successful.
|
||||
if let Some(client) = self.ecs().write_storage::<Client>().get_mut(entity) {
|
||||
client.allow_state(ClientState::Character);
|
||||
|
Loading…
Reference in New Issue
Block a user