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
|
// Output debug metrics
|
||||||
if log_enabled!(log::Level::Info) && self.tick % 600 == 0 {
|
if log_enabled!(log::Level::Info) && self.tick % 600 == 0 {
|
||||||
let metrics = self
|
let metrics = self
|
||||||
|
@ -71,5 +71,5 @@ impl Component for Jumping {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Component for Gliding {
|
impl Component for Gliding {
|
||||||
type Storage = NullStorage<Self>;
|
type Storage = FlaggedStorage<Self, NullStorage<Self>>;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ pub enum ClientMsg {
|
|||||||
Ping,
|
Ping,
|
||||||
Pong,
|
Pong,
|
||||||
Chat(String),
|
Chat(String),
|
||||||
PlayerAnimation(comp::AnimationInfo),
|
|
||||||
PlayerPhysics {
|
PlayerPhysics {
|
||||||
pos: comp::Pos,
|
pos: comp::Pos,
|
||||||
vel: comp::Vel,
|
vel: comp::Vel,
|
||||||
|
@ -25,7 +25,7 @@ sphynx::sum_type! {
|
|||||||
Stats(comp::Stats),
|
Stats(comp::Stats),
|
||||||
Attacking(comp::Attacking),
|
Attacking(comp::Attacking),
|
||||||
Rolling(comp::Rolling),
|
Rolling(comp::Rolling),
|
||||||
|
Gliding(comp::Gliding),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Automatically derive From<T> for EcsCompPhantom
|
// Automatically derive From<T> for EcsCompPhantom
|
||||||
@ -41,7 +41,7 @@ sphynx::sum_type! {
|
|||||||
Stats(PhantomData<comp::Stats>),
|
Stats(PhantomData<comp::Stats>),
|
||||||
Attacking(PhantomData<comp::Attacking>),
|
Attacking(PhantomData<comp::Attacking>),
|
||||||
Rolling(PhantomData<comp::Rolling>),
|
Rolling(PhantomData<comp::Rolling>),
|
||||||
|
Gliding(PhantomData<comp::Gliding>),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl sphynx::CompPacket for EcsCompPacket {
|
impl sphynx::CompPacket for EcsCompPacket {
|
||||||
|
@ -98,13 +98,13 @@ impl State {
|
|||||||
|
|
||||||
// Create a new Sphynx ECS world.
|
// Create a new Sphynx ECS world.
|
||||||
fn setup_sphynx_world(ecs: &mut sphynx::World<EcsCompPacket, EcsResPacket>) {
|
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::Actor>();
|
||||||
ecs.register_synced::<comp::Player>();
|
ecs.register_synced::<comp::Player>();
|
||||||
ecs.register_synced::<comp::Stats>();
|
ecs.register_synced::<comp::Stats>();
|
||||||
ecs.register_synced::<comp::Attacking>(); // TODO: Don't send this to the client?
|
ecs.register_synced::<comp::Attacking>();
|
||||||
ecs.register_synced::<comp::Rolling>(); // TODO: Don't send this to the client?
|
ecs.register_synced::<comp::Rolling>();
|
||||||
ecs.register::<comp::ForceUpdate>();
|
ecs.register_synced::<comp::Gliding>();
|
||||||
|
|
||||||
// Register components synced by other means
|
// Register components synced by other means
|
||||||
ecs.register::<comp::Pos>();
|
ecs.register::<comp::Pos>();
|
||||||
@ -121,8 +121,8 @@ impl State {
|
|||||||
// Register server-local components
|
// Register server-local components
|
||||||
ecs.register::<comp::Agent>();
|
ecs.register::<comp::Agent>();
|
||||||
ecs.register::<comp::Respawning>();
|
ecs.register::<comp::Respawning>();
|
||||||
ecs.register::<comp::Gliding>();
|
|
||||||
ecs.register::<comp::Dying>();
|
ecs.register::<comp::Dying>();
|
||||||
|
ecs.register::<comp::ForceUpdate>();
|
||||||
ecs.register::<inventory::Inventory>();
|
ecs.register::<inventory::Inventory>();
|
||||||
|
|
||||||
// Register synced resources used by the ECS.
|
// Register synced resources used by the ECS.
|
||||||
|
@ -99,13 +99,10 @@ impl<'a> System<'a> for Sys {
|
|||||||
|
|
||||||
// Jump
|
// Jump
|
||||||
if controller.jump
|
if controller.jump
|
||||||
&& jumpings.get(entity).is_none()
|
|
||||||
&& on_ground.is_some()
|
&& on_ground.is_some()
|
||||||
&& vel.0.z <= 0.0
|
&& vel.0.z <= 0.0
|
||||||
{
|
{
|
||||||
jumpings.insert(entity, Jumping);
|
jumpings.insert(entity, Jumping);
|
||||||
} else {
|
|
||||||
jumpings.remove(entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Roll
|
// Roll
|
||||||
|
@ -51,9 +51,9 @@ impl<'a> System<'a> for Sys {
|
|||||||
ReadExpect<'a, TerrainMap>,
|
ReadExpect<'a, TerrainMap>,
|
||||||
Read<'a, DeltaTime>,
|
Read<'a, DeltaTime>,
|
||||||
ReadStorage<'a, MoveDir>,
|
ReadStorage<'a, MoveDir>,
|
||||||
ReadStorage<'a, Jumping>,
|
|
||||||
ReadStorage<'a, Gliding>,
|
ReadStorage<'a, Gliding>,
|
||||||
ReadStorage<'a, Stats>,
|
ReadStorage<'a, Stats>,
|
||||||
|
WriteStorage<'a, Jumping>,
|
||||||
WriteStorage<'a, Rolling>,
|
WriteStorage<'a, Rolling>,
|
||||||
WriteStorage<'a, OnGround>,
|
WriteStorage<'a, OnGround>,
|
||||||
WriteStorage<'a, Pos>,
|
WriteStorage<'a, Pos>,
|
||||||
@ -68,9 +68,9 @@ impl<'a> System<'a> for Sys {
|
|||||||
terrain,
|
terrain,
|
||||||
dt,
|
dt,
|
||||||
move_dirs,
|
move_dirs,
|
||||||
jumpings,
|
|
||||||
glidings,
|
glidings,
|
||||||
stats,
|
stats,
|
||||||
|
mut jumpings,
|
||||||
mut rollings,
|
mut rollings,
|
||||||
mut on_grounds,
|
mut on_grounds,
|
||||||
mut positions,
|
mut positions,
|
||||||
@ -79,11 +79,10 @@ impl<'a> System<'a> for Sys {
|
|||||||
): Self::SystemData,
|
): Self::SystemData,
|
||||||
) {
|
) {
|
||||||
// Apply movement inputs
|
// 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,
|
&entities,
|
||||||
&stats,
|
&stats,
|
||||||
move_dirs.maybe(),
|
move_dirs.maybe(),
|
||||||
jumpings.maybe(),
|
|
||||||
glidings.maybe(),
|
glidings.maybe(),
|
||||||
&mut positions,
|
&mut positions,
|
||||||
&mut velocities,
|
&mut velocities,
|
||||||
@ -119,8 +118,9 @@ impl<'a> System<'a> for Sys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Jump
|
// Jump
|
||||||
if jumping.is_some() {
|
if jumpings.get(entity).is_some() {
|
||||||
vel.0.z = HUMANOID_JUMP_ACCEL;
|
vel.0.z = HUMANOID_JUMP_ACCEL;
|
||||||
|
jumpings.remove(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Glide
|
// Glide
|
||||||
|
@ -512,15 +512,6 @@ impl Server {
|
|||||||
| ClientState::Character => new_chat_msgs.push((Some(entity), msg)),
|
| ClientState::Character => new_chat_msgs.push((Some(entity), msg)),
|
||||||
ClientState::Pending => {}
|
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 {
|
ClientMsg::PlayerPhysics { pos, vel, ori } => match client.client_state {
|
||||||
ClientState::Character => {
|
ClientState::Character => {
|
||||||
state.write_component(entity, pos);
|
state.write_component(entity, pos);
|
||||||
|
Loading…
Reference in New Issue
Block a user