From 5f883c80e7fc63c97910d003c44aea814ab8a5d6 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 18 Jul 2024 15:42:11 +0200 Subject: reimplement customers as entity --- pixel-client/src/game.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'pixel-client/src') diff --git a/pixel-client/src/game.rs b/pixel-client/src/game.rs index 7e43bdc9..57f419e2 100644 --- a/pixel-client/src/game.rs +++ b/pixel-client/src/game.rs @@ -45,6 +45,7 @@ pub struct Game { tilemap: Tilemap, collision_map: HashSet, players: HashMap, + player_ids: HashSet, items_removed: Vec, my_id: PlayerID, @@ -107,6 +108,7 @@ impl Game { items_removed: Vec::new(), interacting: false, score: Score::default(), + player_ids: HashSet::new(), camera_center: Vec2::ZERO, } } @@ -255,9 +257,11 @@ impl Game { }, }, ); + self.player_ids.insert(id); } PacketC::RemovePlayer { id } => { info!("remove player {}", id.0); + self.player_ids.remove(&id); self.players.remove(&id); } PacketC::Position { @@ -355,6 +359,8 @@ impl Game { self.tilemap.draw(ctx); + + if let Some(me) = self.players.get(&self.my_id) { let t = me.movement.get_interact_target(); ctx.draw_world( -- cgit v1.2.3-70-g09d2