From a1f6b4f47e7aca167e71311d55c3e9a18f4cbff7 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 21 Jun 2024 00:12:13 +0200 Subject: show bad passive recipes in red --- server/src/data.rs | 11 +++++++---- server/src/game.rs | 3 ++- server/src/interaction.rs | 15 +++++++++++---- server/src/protocol.rs | 1 + 4 files changed, 21 insertions(+), 9 deletions(-) (limited to 'server/src') diff --git a/server/src/data.rs b/server/src/data.rs index fd6f266d..17b508ec 100644 --- a/server/src/data.rs +++ b/server/src/data.rs @@ -19,13 +19,15 @@ pub enum Action { #[derive(Debug, Clone, Deserialize, Serialize)] pub struct RecipeDecl { #[serde(default)] - pub tile: Option, + tile: Option, #[serde(default)] - pub inputs: Vec, + inputs: Vec, #[serde(default)] - pub outputs: Vec, + outputs: Vec, #[serde(default)] - pub action: Action, + action: Action, + #[serde(default)] + warn: bool, } #[derive(Debug, Clone, Deserialize)] @@ -92,6 +94,7 @@ pub fn build_gamedata( Action::Never => {} Action::Passive(duration) => recipes.push(Recipe::Passive { duration, + warn: r.warn, tile, input: inputs.next().expect("passive recipe without input"), output: outputs.next(), diff --git a/server/src/game.rs b/server/src/game.rs index b478c037..a8ea9991 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -282,7 +282,8 @@ impl Game { for (&pos, tile) in &mut self.tiles { if let Some(effect) = tick_tile(dt, &self.data, tile) { match effect { - TickEffect::Progress => self.packet_out.push_back(PacketC::SetActive { + TickEffect::Progress(warn) => self.packet_out.push_back(PacketC::SetActive { + warn, tile: pos, progress: tile .item diff --git a/server/src/interaction.rs b/server/src/interaction.rs index 7f694ad8..ef6d5bf7 100644 --- a/server/src/interaction.rs +++ b/server/src/interaction.rs @@ -13,6 +13,7 @@ pub enum Recipe { tile: Option, input: ItemIndex, output: Option, + warn: bool, }, Active { duration: f32, @@ -42,6 +43,12 @@ impl Recipe { _ => None, } } + pub fn warn(&self) -> bool { + match self { + Recipe::Passive { warn, .. } => *warn, + _ => false, + } + } pub fn inputs(&self) -> Vec { match self { Recipe::Passive { input, .. } => vec![*input], @@ -189,7 +196,7 @@ pub fn interact( } pub enum TickEffect { - Progress, + Progress(bool), Produce, } pub fn tick_tile(dt: f32, data: &Gamedata, tile: &mut Tile) -> Option { @@ -205,7 +212,7 @@ pub fn tick_tile(dt: f32, data: &Gamedata, tile: &mut Tile) -> Option Option, + warn: bool, }, UpdateMap { pos: IVec2, -- cgit v1.2.3-70-g09d2