pub trait Recipe {
type Inputs: Debug;
type Outputs: Debug;
type InputAmountsType: Debug;
type OutputAmountsType: Debug;
const TIME: u64;
const INPUT_AMOUNTS: Self::InputAmountsType;
const OUTPUT_AMOUNTS: Self::OutputAmountsType;
// Required methods
fn new_inputs() -> Self::Inputs;
fn new_outputs() -> Self::Outputs;
}Expand description
Basic recipe trait. A building’s specific recipe trait can then be defined like
trait AssemblerRecipe: rustorio_engine::recipe::Recipe + rustorio_engine::Sealed {}For example, one could define a recipe that takes three inputs and gives two outputs like:
use rustorio_engine::{recipe::Recipe, resource_type};
resource_type!(Resource1);
resource_type!(Resource2);
resource_type!(Resource3);
resource_type!(Resource4);
resource_type!(Resource5);
#[derive(Recipe)]
#[recipe_inputs(
(10, Resource1),
(5, Resource2),
(1, Resource3),
)]
#[recipe_outputs(
(1, Resource4),
(100, Resource5),
)]
#[recipe_ticks(10)]
pub struct ThreeToTwoRecipe;The recipe will then take 10 ticks per cycle, consuming 10 Resource1, 5 Resource2,
and 1 Resource3, and produce 1 Resource4 and 100 Resource5.
Required Associated Constants§
Sourceconst INPUT_AMOUNTS: Self::InputAmountsType
const INPUT_AMOUNTS: Self::InputAmountsType
Amount for each of the input resource types, per recipe cycle.
Sourceconst OUTPUT_AMOUNTS: Self::OutputAmountsType
const OUTPUT_AMOUNTS: Self::OutputAmountsType
Amount for each of the output resource types, per recipe cycle.
Required Associated Types§
Sourcetype Inputs: Debug
type Inputs: Debug
Typically a tuple of multiple RecipeTypes, to define the inputs
for one cycle of the recipe.
Sourcetype Outputs: Debug
type Outputs: Debug
Typically a tuple of multiple RecipeTypes, to define the outputs
for one cycle of the recipe.
Sourcetype InputAmountsType: Debug
type InputAmountsType: Debug
The type for Self::InputAmountsType, which is used to allow users to
access the input amount for each of the input resource types, per recipe cycle.
Sourcetype OutputAmountsType: Debug
type OutputAmountsType: Debug
The type for Self::OuptutAmountsType, which is used to allow users to
access the output amount for each of the output resource types, per recipe cycle.
Required Methods§
Sourcefn new_inputs() -> Self::Inputs
fn new_inputs() -> Self::Inputs
Factory function to create a new Self::Inputs with zero resources.
Sourcefn new_outputs() -> Self::Outputs
fn new_outputs() -> Self::Outputs
Factory function to create a new Self::Outputs with zero resources.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.