aboutsummaryrefslogtreecommitdiff
path: root/server/src/game.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/game.rs')
-rw-r--r--server/src/game.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/server/src/game.rs b/server/src/game.rs
index 3b16cc05..f207e8f6 100644
--- a/server/src/game.rs
+++ b/server/src/game.rs
@@ -22,6 +22,7 @@ pub struct Tile {
kind: TileIndex,
items: Vec<ItemID>,
active: Option<ActiveRecipe>,
+ last_active: bool,
}
struct Player {
@@ -77,8 +78,8 @@ impl Game {
g.tiles.extend(
[
- ([-5, 1], "pan"),
- ([-5, 2], "pan"),
+ ([2, 4], "pan"),
+ ([3, 4], "pan"),
([4, 3], "meat-spawn"),
([4, 1], "trash"),
]
@@ -210,6 +211,19 @@ impl Game {
}
Ok(())
}
+
+ pub fn tick(&mut self, dt: f32) {
+ for (&pos, tile) in &mut self.tiles {
+ if let Some(active) = &mut tile.active {
+ active.progress += dt / self.data.recipes[active.recipe].action.duration();
+ self.packet_out.push_back(PacketC::SetActive {
+ tile: pos,
+ progress: Some(active.progress),
+ });
+ }
+ tile.last_active = tile.active.is_some()
+ }
+ }
}
impl From<TileIndex> for Tile {
@@ -217,6 +231,7 @@ impl From<TileIndex> for Tile {
Self {
kind,
items: vec![],
+ last_active: false,
active: None,
}
}