diff options
| author | metamuffin <metamuffin@disroot.org> | 2024-06-18 09:57:39 +0200 | 
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2024-06-23 19:20:50 +0200 | 
| commit | 9bdb81bb34bd6a7e33c47d6fcb3dced1c5bda991 (patch) | |
| tree | f99e521bf3b199162ed3e4e45536e944fe634489 /server/src/game.rs | |
| parent | a99aa006599827ea999a5684e40635175c8d790a (diff) | |
| download | hurrycurry-9bdb81bb34bd6a7e33c47d6fcb3dced1c5bda991.tar hurrycurry-9bdb81bb34bd6a7e33c47d6fcb3dced1c5bda991.tar.bz2 hurrycurry-9bdb81bb34bd6a7e33c47d6fcb3dced1c5bda991.tar.zst | |
can start passive recipes
Diffstat (limited to 'server/src/game.rs')
| -rw-r--r-- | server/src/game.rs | 19 | 
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,          }      } | 
