diff options
Diffstat (limited to 'server/src/data.rs')
| -rw-r--r-- | server/src/data.rs | 25 | 
1 files changed, 11 insertions, 14 deletions
| diff --git a/server/src/data.rs b/server/src/data.rs index 2d942de4..a8b712b0 100644 --- a/server/src/data.rs +++ b/server/src/data.rs @@ -28,8 +28,8 @@ use std::{collections::HashMap, sync::RwLock};  pub enum Action {      #[default]      Never, -    Passive(f32), -    Active(f32), +    Passive, +    Active,      Instant,  } @@ -45,6 +45,10 @@ pub struct RecipeDecl {      action: Action,      #[serde(default)]      warn: bool, +    #[serde(default)] +    revert_duration: Option<f32>, +    #[serde(default)] +    duration: Option<f32>,  }  #[derive(Debug, Clone, Deserialize)] @@ -109,15 +113,16 @@ pub fn build_gamedata(          let tile = r.tile.map(|t| TileIndex(register(&tile_names, t)));          match r.action {              Action::Never => {} -            Action::Passive(duration) => recipes.push(Recipe::Passive { -                duration, +            Action::Passive => recipes.push(Recipe::Passive { +                duration: r.duration.expect("duration for passive missing"),                  warn: r.warn,                  tile, +                revert_duration: r.revert_duration,                  input: inputs.next().expect("passive recipe without input"),                  output: outputs.next(),              }), -            Action::Active(duration) => recipes.push(Recipe::Active { -                duration, +            Action::Active => recipes.push(Recipe::Active { +                duration: r.duration.expect("duration for active missing"),                  tile,                  input: inputs.next().expect("active recipe without input"),                  outputs: [outputs.next(), outputs.next()], @@ -236,11 +241,3 @@ impl Gamedata {              .map(|(i, e)| (RecipeIndex(i), e))      }  } -impl Action { -    pub fn duration(&self) -> f32 { -        match self { -            Action::Instant | Action::Never => 0., -            Action::Passive(x) | Action::Active(x) => *x, -        } -    } -} | 
