mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Don't sync animations, just sync components used to construct them
This commit is contained in:
parent
8dd1e46883
commit
f0e6e76423
@ -292,19 +292,6 @@ impl Client {
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// Update the server about the player's current animation.
|
||||
if let Some(animation_info) = self
|
||||
.state
|
||||
.ecs_mut()
|
||||
.write_storage::<comp::AnimationInfo>()
|
||||
.get_mut(self.entity)
|
||||
{
|
||||
if animation_info.changed {
|
||||
self.postbox
|
||||
.send_message(ClientMsg::PlayerAnimation(animation_info.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
// Output debug metrics
|
||||
if log_enabled!(log::Level::Info) && self.tick % 600 == 0 {
|
||||
let metrics = self
|
||||
|
@ -71,5 +71,5 @@ impl Component for Jumping {
|
||||
}
|
||||
|
||||
impl Component for Gliding {
|
||||
type Storage = NullStorage<Self>;
|
||||
type Storage = FlaggedStorage<Self, NullStorage<Self>>;
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ pub enum ClientMsg {
|
||||
Ping,
|
||||
Pong,
|
||||
Chat(String),
|
||||
PlayerAnimation(comp::AnimationInfo),
|
||||
PlayerPhysics {
|
||||
pos: comp::Pos,
|
||||
vel: comp::Vel,
|
||||
|
@ -25,7 +25,7 @@ sphynx::sum_type! {
|
||||
Stats(comp::Stats),
|
||||
Attacking(comp::Attacking),
|
||||
Rolling(comp::Rolling),
|
||||
|
||||
Gliding(comp::Gliding),
|
||||
}
|
||||
}
|
||||
// Automatically derive From<T> for EcsCompPhantom
|
||||
@ -41,7 +41,7 @@ sphynx::sum_type! {
|
||||
Stats(PhantomData<comp::Stats>),
|
||||
Attacking(PhantomData<comp::Attacking>),
|
||||
Rolling(PhantomData<comp::Rolling>),
|
||||
|
||||
Gliding(PhantomData<comp::Gliding>),
|
||||
}
|
||||
}
|
||||
impl sphynx::CompPacket for EcsCompPacket {
|
||||
|
@ -98,13 +98,13 @@ impl State {
|
||||
|
||||
// Create a new Sphynx ECS world.
|
||||
fn setup_sphynx_world(ecs: &mut sphynx::World<EcsCompPacket, EcsResPacket>) {
|
||||
// Register synced components.
|
||||
// Register server->client synced components.
|
||||
ecs.register_synced::<comp::Actor>();
|
||||
ecs.register_synced::<comp::Player>();
|
||||
ecs.register_synced::<comp::Stats>();
|
||||
ecs.register_synced::<comp::Attacking>(); // TODO: Don't send this to the client?
|
||||
ecs.register_synced::<comp::Rolling>(); // TODO: Don't send this to the client?
|
||||
ecs.register::<comp::ForceUpdate>();
|
||||
ecs.register_synced::<comp::Attacking>();
|
||||
ecs.register_synced::<comp::Rolling>();
|
||||
ecs.register_synced::<comp::Gliding>();
|
||||
|
||||
// Register components synced by other means
|
||||
ecs.register::<comp::Pos>();
|
||||
@ -121,8 +121,8 @@ impl State {
|
||||
// Register server-local components
|
||||
ecs.register::<comp::Agent>();
|
||||
ecs.register::<comp::Respawning>();
|
||||
ecs.register::<comp::Gliding>();
|
||||
ecs.register::<comp::Dying>();
|
||||
ecs.register::<comp::ForceUpdate>();
|
||||
ecs.register::<inventory::Inventory>();
|
||||
|
||||
// Register synced resources used by the ECS.
|
||||
|
@ -99,13 +99,10 @@ impl<'a> System<'a> for Sys {
|
||||
|
||||
// Jump
|
||||
if controller.jump
|
||||
&& jumpings.get(entity).is_none()
|
||||
&& on_ground.is_some()
|
||||
&& vel.0.z <= 0.0
|
||||
{
|
||||
jumpings.insert(entity, Jumping);
|
||||
} else {
|
||||
jumpings.remove(entity);
|
||||
}
|
||||
|
||||
// Roll
|
||||
|
@ -51,9 +51,9 @@ impl<'a> System<'a> for Sys {
|
||||
ReadExpect<'a, TerrainMap>,
|
||||
Read<'a, DeltaTime>,
|
||||
ReadStorage<'a, MoveDir>,
|
||||
ReadStorage<'a, Jumping>,
|
||||
ReadStorage<'a, Gliding>,
|
||||
ReadStorage<'a, Stats>,
|
||||
WriteStorage<'a, Jumping>,
|
||||
WriteStorage<'a, Rolling>,
|
||||
WriteStorage<'a, OnGround>,
|
||||
WriteStorage<'a, Pos>,
|
||||
@ -68,9 +68,9 @@ impl<'a> System<'a> for Sys {
|
||||
terrain,
|
||||
dt,
|
||||
move_dirs,
|
||||
jumpings,
|
||||
glidings,
|
||||
stats,
|
||||
mut jumpings,
|
||||
mut rollings,
|
||||
mut on_grounds,
|
||||
mut positions,
|
||||
@ -79,11 +79,10 @@ impl<'a> System<'a> for Sys {
|
||||
): Self::SystemData,
|
||||
) {
|
||||
// Apply movement inputs
|
||||
for (entity, stats, move_dir, jumping, gliding, mut pos, mut vel, mut ori) in (
|
||||
for (entity, stats, move_dir, gliding, mut pos, mut vel, mut ori) in (
|
||||
&entities,
|
||||
&stats,
|
||||
move_dirs.maybe(),
|
||||
jumpings.maybe(),
|
||||
glidings.maybe(),
|
||||
&mut positions,
|
||||
&mut velocities,
|
||||
@ -119,8 +118,9 @@ impl<'a> System<'a> for Sys {
|
||||
}
|
||||
|
||||
// Jump
|
||||
if jumping.is_some() {
|
||||
if jumpings.get(entity).is_some() {
|
||||
vel.0.z = HUMANOID_JUMP_ACCEL;
|
||||
jumpings.remove(entity);
|
||||
}
|
||||
|
||||
// Glide
|
||||
|
@ -512,15 +512,6 @@ impl Server {
|
||||
| ClientState::Character => new_chat_msgs.push((Some(entity), msg)),
|
||||
ClientState::Pending => {}
|
||||
},
|
||||
ClientMsg::PlayerAnimation(animation_info) => {
|
||||
match client.client_state {
|
||||
ClientState::Character => {
|
||||
state.write_component(entity, animation_info)
|
||||
}
|
||||
// Only characters can send animations.
|
||||
_ => client.error_state(RequestStateError::Impossible),
|
||||
}
|
||||
}
|
||||
ClientMsg::PlayerPhysics { pos, vel, ori } => match client.client_state {
|
||||
ClientState::Character => {
|
||||
state.write_component(entity, pos);
|
||||
|
Loading…
Reference in New Issue
Block a user