Simplify code

Former-commit-id: c8bdf4199c913ab43ba08fdb19384bf7fcc6653d
This commit is contained in:
timokoesters 2019-04-17 20:06:06 +02:00
parent abf32d6229
commit 5044fe8cb5
2 changed files with 11 additions and 17 deletions

View File

@ -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));
}
}

View File

@ -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