From a02c1d31f4d2de92388dcc8c07a602e62f5ddbbe Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 10 Aug 2024 22:55:26 +0200 Subject: fix customers for new proto --- server/protocol/src/movement.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'server/protocol/src/movement.rs') diff --git a/server/protocol/src/movement.rs b/server/protocol/src/movement.rs index 5525c5e6..dad9d300 100644 --- a/server/protocol/src/movement.rs +++ b/server/protocol/src/movement.rs @@ -29,6 +29,7 @@ const BOOST_DURATION: f32 = 0.3; const BOOST_RESTORE: f32 = 0.5; pub struct MovementBase { + pub direction: Vec2, pub position: Vec2, pub facing: Vec2, pub rotation: f32, @@ -41,6 +42,7 @@ impl MovementBase { pub fn new(position: Vec2) -> Self { Self { position, + direction: Vec2::ZERO, facing: Vec2::X, velocity: Vec2::ZERO, boosting: false, @@ -49,7 +51,7 @@ impl MovementBase { } } pub fn update(&mut self, map: &HashSet, direction: Vec2, mut boost: bool, dt: f32) { - let direction = direction.clamp_length_max(1.); + self.direction = direction.clamp_length_max(1.); if direction.length() > 0.1 { self.facing = direction + (self.facing - direction) * (-dt * 10.).exp(); } @@ -69,11 +71,11 @@ impl MovementBase { collide_player_tiles(self, map); } - pub fn movement_packet(&self, direction: Vec2, player: PlayerID) -> PacketS { + pub fn movement_packet(&self, player: PlayerID) -> PacketS { PacketS::Movement { pos: Some(self.position), boosting: self.boosting, - direction, + direction: self.direction, player, } } -- cgit v1.2.3-70-g09d2