pub use rustorio_derive::{Recipe, RecipeEx, recipe_doc};
use crate::{Sealed, tick::Tick};
pub trait Recipe {
const TIME: u64;
type Inputs: std::fmt::Debug;
type Outputs: std::fmt::Debug;
fn new_inputs() -> Self::Inputs;
fn new_outputs() -> Self::Outputs;
type InputAmountsType: std::fmt::Debug;
const INPUT_AMOUNTS: Self::InputAmountsType;
type OutputAmountsType: std::fmt::Debug;
const OUTPUT_AMOUNTS: Self::OutputAmountsType;
}
#[doc(hidden)]
pub trait RecipeEx: Recipe {
type InputBundle: std::fmt::Debug;
type OutputBundle: std::fmt::Debug;
fn new_output_bundle() -> Self::OutputBundle;
fn iter_inputs(items: &mut Self::Inputs)
-> impl Iterator<Item = (&'static str, u32, &mut u32)>;
fn iter_outputs(
items: &mut Self::Outputs,
) -> impl Iterator<Item = (&'static str, u32, &mut u32)>;
}
pub trait HandRecipe: std::fmt::Debug + Sealed + RecipeEx {
fn craft(tick: &mut Tick, inputs: Self::InputBundle) -> Self::OutputBundle {
let _ = inputs;
tick.advance_by(Self::TIME);
Self::new_output_bundle()
}
}