Set PlayerEntity in Client::clean_state. This fixes several issues where interpolation would kick in after changing characters, causing the player to be locked in place or shoot into the sky on respawn or teleport.

This commit is contained in:
Avi Weinstock 2021-03-19 19:02:39 -04:00
parent bf5be892d8
commit 03d0748d40

View File

@ -1808,7 +1808,13 @@ impl Client {
Ok(frontend_events)
}
pub fn entity(&self) -> EcsEntity { self.entity }
pub fn entity(&self) -> EcsEntity {
debug_assert_eq!(
self.state.ecs().read_resource::<PlayerEntity>().0,
Some(self.entity)
);
self.entity
}
pub fn uid(&self) -> Option<Uid> { self.state.read_component_copied(self.entity) }
@ -1891,6 +1897,7 @@ impl Client {
.allocate(entity_builder.entity, Some(client_uid));
self.entity = entity_builder.with(uid).build();
self.state.ecs().write_resource::<PlayerEntity>().0 = Some(self.entity);
}
/// Change player alias to "You" if client belongs to matching player