aboutsummaryrefslogtreecommitdiff
path: root/server/client-lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/client-lib')
-rw-r--r--server/client-lib/src/lib.rs38
1 files changed, 28 insertions, 10 deletions
diff --git a/server/client-lib/src/lib.rs b/server/client-lib/src/lib.rs
index 38f1070e..38b328b9 100644
--- a/server/client-lib/src/lib.rs
+++ b/server/client-lib/src/lib.rs
@@ -32,9 +32,9 @@ use std::{
#[derive(Debug, PartialEq)]
pub struct Involvement {
- pub progress: f32,
+ pub position: f32,
+ pub speed: f32,
pub recipe: RecipeIndex,
- pub working: usize,
pub warn: bool,
}
@@ -135,18 +135,21 @@ impl Game {
PacketC::SetItem { location, item } => {
*self.get_item(location) = item.map(|kind| Item { kind, active: None });
}
+ PacketC::ClearProgress { item } => {
+ self.get_item(item).as_mut().unwrap().active = None;
+ }
PacketC::SetProgress {
item,
- progress,
+ position,
+ speed,
warn,
} => {
- self.get_item(item).as_mut().unwrap().active =
- progress.map(|progress| Involvement {
- working: 1,
- warn,
- progress,
- recipe: RecipeIndex(0),
- });
+ self.get_item(item).as_mut().unwrap().active = Some(Involvement {
+ speed,
+ warn,
+ position,
+ recipe: RecipeIndex(0),
+ });
}
PacketC::UpdateMap {
tile,
@@ -205,6 +208,21 @@ impl Game {
.update_entry(pid, player.movement.position);
}
+ for (_, player) in &mut self.players {
+ if let Some(item) = &mut player.item {
+ if let Some(active) = &mut item.active {
+ active.position += active.speed;
+ }
+ }
+ }
+ for (_, tile) in &mut self.tiles {
+ if let Some(item) = &mut tile.item {
+ if let Some(active) = &mut item.active {
+ active.position += active.speed;
+ }
+ }
+ }
+
self.players_spatial_index.all(|p1, pos1| {
self.players_spatial_index.query(pos1, 2., |p2, _pos2| {
if let Some([a, b]) = self.players.get_many_mut([&p1, &p2]) {