diff options
author | Henauxg <19689618+Henauxg@users.noreply.github.com> | 2022-11-03 18:11:37 +0100 |
---|---|---|
committer | Henauxg <19689618+Henauxg@users.noreply.github.com> | 2022-11-03 18:11:37 +0100 |
commit | 39faea4d08d006508842f8ceddecd9e4e3ad4d19 (patch) | |
tree | e6b7f25e38c328ce10c4ef602241adcd5af24ab2 /examples/breakout/server.rs | |
parent | e104ce1299a64fb2b575a2193ec2151b48667165 (diff) |
[example:breakout] Use owner_client_id to visualize balls ownership
Diffstat (limited to 'examples/breakout/server.rs')
-rw-r--r-- | examples/breakout/server.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/breakout/server.rs b/examples/breakout/server.rs index 8ab796a..9aa43f0 100644 --- a/examples/breakout/server.rs +++ b/examples/breakout/server.rs @@ -232,6 +232,7 @@ pub(crate) fn check_for_collisions( server .broadcast_message(ServerMessage::BallCollided { + owner_client_id: ball.last_hit_by, entity: ball_entity, position: ball_transform.translation, velocity: ball_velocity.0, @@ -250,6 +251,18 @@ pub(crate) fn apply_velocity(mut query: Query<(&mut Transform, &Velocity), With< } fn start_game(commands: &mut Commands, server: &mut ResMut<Server>, players: &ResMut<Players>) { + // Assign ids + for client_id in players.map.keys().into_iter() { + server + .send_message( + *client_id, + ServerMessage::InitClient { + client_id: *client_id, + }, + ) + .unwrap(); + } + // Spawn paddles for (position, client_id) in PADDLES_STARTING_POSITION .iter() @@ -279,6 +292,7 @@ fn start_game(commands: &mut Commands, server: &mut ResMut<Server>, players: &Re .send_group_message( players.map.keys().into_iter(), ServerMessage::SpawnBall { + owner_client_id: *client_id, entity: ball, position: *position, direction: *direction, |