mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Simplify code
Former-commit-id: c8bdf4199c913ab43ba08fdb19384bf7fcc6653d
This commit is contained in:
parent
abf32d6229
commit
5044fe8cb5
@ -169,10 +169,8 @@ impl Client {
|
||||
|
||||
// Update the server about the player's currently playing animation and the previous one
|
||||
if let Some(animationHistory) = self.state.read_storage::<comp::AnimationHistory>().get(self.player).cloned() {
|
||||
if let Some(last) = animationHistory.last {
|
||||
if animationHistory.current != last {
|
||||
self.postbox.send_message(ClientMsg::PlayerAnimation(animationHistory));
|
||||
}
|
||||
if Some(animationHistory.current) != animationHistory.last {
|
||||
self.postbox.send_message(ClientMsg::PlayerAnimation(animationHistory));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,17 +374,15 @@ impl Server {
|
||||
&self.state.ecs().internal().read_storage::<Uid>(),
|
||||
&self.state.ecs().internal().read_storage::<comp::AnimationHistory>(),
|
||||
).join() {
|
||||
if let Some(last) = animationHistory.last {
|
||||
// Check if we need to sync
|
||||
if animationHistory.current == last {
|
||||
continue;
|
||||
}
|
||||
|
||||
self.clients.notify_connected_except(entity, ServerMsg::EntityAnimation {
|
||||
entity: uid.into(),
|
||||
animationHistory,
|
||||
});
|
||||
// Check if we need to sync
|
||||
if Some(animationHistory.current) == animationHistory.last {
|
||||
continue;
|
||||
}
|
||||
|
||||
self.clients.notify_connected_except(entity, ServerMsg::EntityAnimation {
|
||||
entity: uid.into(),
|
||||
animationHistory,
|
||||
});
|
||||
}
|
||||
|
||||
// Update animation last/current state
|
||||
@ -392,9 +390,7 @@ impl Server {
|
||||
&self.state.ecs().internal().entities(),
|
||||
&mut self.state.ecs().internal().write_storage::<comp::AnimationHistory>()
|
||||
).join() {
|
||||
animationHistory.last = None;
|
||||
let mut new = animationHistory.clone();
|
||||
new.last = Some(new.current);
|
||||
animationHistory.last = Some(animationHistory.current);
|
||||
}
|
||||
|
||||
// Remove all force flags
|
||||
|
Loading…
Reference in New Issue
Block a user