server side attack. TODO: fix origin on shooter
This commit is contained in:
@@ -167,33 +167,22 @@ fn server_update_system(
|
||||
let command: PlayerCommand = bincode::deserialize(&message).unwrap();
|
||||
|
||||
match command {
|
||||
PlayerCommand::BasicAttack { mut fired_at } => {
|
||||
println!(
|
||||
"Received basic attack from client {}: {:?}",
|
||||
client_id, fired_at
|
||||
PlayerCommand::BasicAttack { origin, direction } => {
|
||||
info!(
|
||||
"spawned attack on server at origin {} and direction {}",
|
||||
origin, direction
|
||||
);
|
||||
|
||||
if let Some(player_entity) = lobby.players.get(&client_id) {
|
||||
if let Ok((_, player)) = players.get(*player_entity) {
|
||||
fired_at = Vec2::new(
|
||||
player.transform.translation.x,
|
||||
player.transform.translation.y,
|
||||
);
|
||||
let entity = spawn_projectile(&mut commands, origin, direction);
|
||||
let message = ServerMessages::SpawnProjectile {
|
||||
entity,
|
||||
origin,
|
||||
direction,
|
||||
};
|
||||
|
||||
let projectile_entity =
|
||||
spawn_projectile(&mut commands, fired_at, fired_at);
|
||||
let message = bincode::serialize(&message).unwrap();
|
||||
|
||||
let message = ServerMessages::SpawnProjectile {
|
||||
entity: projectile_entity,
|
||||
position: fired_at,
|
||||
direction: fired_at,
|
||||
};
|
||||
|
||||
let message = bincode::serialize(&message).unwrap();
|
||||
|
||||
server.broadcast_message(ServerChannel::ServerMessages.id(), message);
|
||||
}
|
||||
}
|
||||
server.broadcast_message(ServerChannel::ServerMessages.id(), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user