diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/customer/mod.rs | 12 | ||||
-rw-r--r-- | server/src/customer/pathfinding.rs | 4 | ||||
-rw-r--r-- | server/src/game.rs | 25 |
3 files changed, 24 insertions, 17 deletions
diff --git a/server/src/customer/mod.rs b/server/src/customer/mod.rs index ba57542c..e60c50c7 100644 --- a/server/src/customer/mod.rs +++ b/server/src/customer/mod.rs @@ -22,7 +22,7 @@ use crate::{data::Gamedata, game::Tile}; use anyhow::{anyhow, Result}; use fake::{faker, Fake}; use hurrycurry_protocol::{glam::IVec2, DemandIndex, Message, PacketS, PlayerID}; -use log::debug; +use log::info; use movement::MovementBase; use pathfinding::{find_path, Path}; use rand::{random, thread_rng}; @@ -121,6 +121,7 @@ impl DemandState { let from = data.customer_spawn.as_ivec2(); let path = find_path(&self.walkable, from, chair) .ok_or(anyhow!("no path from {from} to {chair}"))?; + info!("{id:?} -> entering"); self.customers.insert( id, Customer { @@ -133,7 +134,6 @@ impl DemandState { for (&id, p) in &mut self.customers { match &mut p.state { CustomerState::Entering { path, chair } => { - debug!("{id:?} entering"); packets_out.push((id, path.execute_tick(&mut p.movement, &self.walkable, dt))); if path.is_done() { let demand = DemandIndex(random::<usize>() % self.data.demands.len()); @@ -144,6 +144,7 @@ impl DemandState { persist: true, }, )); + info!("{id:?} -> waiting"); p.state = CustomerState::Waiting { chair: *chair, timeout: 60. + random::<f32>() * 30., @@ -156,7 +157,6 @@ impl DemandState { demand, timeout, } => { - debug!("{id:?} waiting"); *timeout -= dt; if *timeout <= 0. { packets_out.push(( @@ -183,6 +183,7 @@ impl DemandState { self.failed += 1; *points -= 1; self.score_changed = true; + info!("{id:?} -> exiting"); p.state = CustomerState::Exiting { path } } else { let demand_data = &data.demand(*demand); @@ -222,6 +223,7 @@ impl DemandState { )); packets_out.push((id, PacketS::Interact { pos: Some(pos) })); packets_out.push((id, PacketS::Interact { pos: None })); + info!("{id:?} -> eating"); p.state = CustomerState::Eating { demand: *demand, target: pos, @@ -237,7 +239,6 @@ impl DemandState { progress, chair, } => { - debug!("{id:?} eating"); let demand = data.demand(*demand); *progress += dt / demand.duration; if *progress >= 1. { @@ -256,13 +257,14 @@ impl DemandState { self.completed += 1; *points += demand.points; self.score_changed = true; + info!("{id:?} -> exiting"); p.state = CustomerState::Exiting { path } } } CustomerState::Exiting { path } => { - debug!("{id:?} exiting"); packets_out.push((id, path.execute_tick(&mut p.movement, &self.walkable, dt))); if path.is_done() { + info!("{id:?} -> leave"); packets_out.push((id, PacketS::Leave)); customers_to_remove.push(id); } diff --git a/server/src/customer/pathfinding.rs b/server/src/customer/pathfinding.rs index 29ee4e00..2fe938a9 100644 --- a/server/src/customer/pathfinding.rs +++ b/server/src/customer/pathfinding.rs @@ -20,7 +20,7 @@ use hurrycurry_protocol::{ glam::{IVec2, Vec2}, PacketS, }; -use log::debug; +use log::trace; use std::{ cmp::Ordering, collections::{BinaryHeap, HashMap, HashSet}, @@ -36,7 +36,7 @@ impl Path { dt: f32, ) -> PacketS { if let Some(next) = self.0.last().copied() { - debug!("next {next}"); + trace!("next {next}"); if next.distance(player.position) < if self.0.len() == 1 { 0.1 } else { 0.6 } { self.0.pop(); } diff --git a/server/src/game.rs b/server/src/game.rs index 908c0b4e..5cdf8cd4 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -326,8 +326,6 @@ impl Game { .push_back(PacketC::Collide { player, force }); } PacketS::Interact { pos } => { - info!("interact {pos:?}"); - let pid = player; let player = self .players @@ -571,15 +569,22 @@ pub fn interact_effect( if let Some(effect) = interact(&data, edge, this_tile_kind, this, other, points, automated) { match effect { - InteractEffect::Put => packet_out.push_back(PacketC::MoveItem { - from: other_loc, - to: this_loc, - }), - InteractEffect::Take => packet_out.push_back(PacketC::MoveItem { - from: this_loc, - to: other_loc, - }), + InteractEffect::Put => { + info!("put {this_loc} <- {other_loc}"); + packet_out.push_back(PacketC::MoveItem { + from: other_loc, + to: this_loc, + }) + } + InteractEffect::Take => { + info!("take {this_loc} -> {other_loc}"); + packet_out.push_back(PacketC::MoveItem { + from: this_loc, + to: other_loc, + }) + } InteractEffect::Produce => { + info!("produce {this_loc} <~ {other_loc}"); if this_had_item { packet_out.push_back(PacketC::SetProgress { item: this_loc, |