diff options
Diffstat (limited to 'server/src/game.rs')
-rw-r--r-- | server/src/game.rs | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/server/src/game.rs b/server/src/game.rs index c010c8b8..5af9658e 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -61,8 +61,6 @@ pub struct Player { pub communicate_persist: Option<Message>, pub movement: MovementBase, - pub direction: Vec2, - pub boost: bool, pub last_position_update: Instant, } @@ -178,7 +176,8 @@ impl Game { } else { self.data.chef_spawn }, - direction: Vec2::ZERO, + input_direction: Vec2::ZERO, + input_boost: false, facing: Vec2::X, rotation: 0., velocity: Vec2::ZERO, @@ -186,8 +185,6 @@ impl Game { stamina: 0., }, last_position_update: Instant::now(), - boost: false, - direction: Vec2::ZERO, communicate_persist: None, interacting: None, name: name.clone(), @@ -298,7 +295,8 @@ impl Game { } else { self.data.chef_spawn }, - direction: Vec2::ZERO, + input_direction: Vec2::ZERO, + input_boost: false, facing: Vec2::X, rotation: 0., velocity: Vec2::ZERO, @@ -306,8 +304,6 @@ impl Game { stamina: 0., }, last_position_update: Instant::now(), - boost: false, - direction: Vec2::ZERO, communicate_persist: None, interacting: None, name: name.clone(), @@ -358,8 +354,8 @@ impl Game { } PacketS::Movement { pos, - boosting, - direction, + boost, + dir: direction, player, } => { let pd = self @@ -367,8 +363,7 @@ impl Game { .get_mut(&player) .ok_or(anyhow!("player does not exist"))?; - pd.direction = direction; - pd.boost = boosting; + pd.movement.input(direction, boost); if let Some(pos) = pos { let dt = pd.last_position_update.elapsed(); @@ -541,9 +536,7 @@ impl Game { } for (&pid, player) in &mut self.players { - player - .movement - .update(&self.walkable, player.direction, player.boost, dt); + player.movement.update(&self.walkable, dt); self.players_spatial_index .update_entry(pid, player.movement.position); @@ -558,10 +551,11 @@ impl Game { }); for (&pid, player) in &mut self.players { - packet_out.push_back(PacketC::Position { + packet_out.push_back(PacketC::Movement { player: pid, pos: player.movement.position, - boosting: player.movement.boosting, + dir: player.movement.input_direction, + boost: player.movement.boosting, rot: player.movement.rotation, }); |