Skip to main content

Recipe

Trait Recipe 

Source
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§

Source

const TIME: u64

Amount of ticks one cycle of the recipe takes to complete.

Source

const INPUT_AMOUNTS: Self::InputAmountsType

Amount for each of the input resource types, per recipe cycle.

Source

const OUTPUT_AMOUNTS: Self::OutputAmountsType

Amount for each of the output resource types, per recipe cycle.

Required Associated Types§

Source

type Inputs: Debug

Typically a tuple of multiple RecipeTypes, to define the inputs for one cycle of the recipe.

Source

type Outputs: Debug

Typically a tuple of multiple RecipeTypes, to define the outputs for one cycle of the recipe.

Source

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.

Source

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§

Source

fn new_inputs() -> Self::Inputs

Factory function to create a new Self::Inputs with zero resources.

Source

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.

Implementors§

Source§

impl Recipe for CopperSmelting

Source§

impl Recipe for CopperWireRecipe

Source§

impl Recipe for ElectronicCircuitRecipe

Source§

impl Recipe for IronSmelting

Source§

impl Recipe for PointRecipe

Source§

impl Recipe for RedScienceRecipe

Source§

impl Recipe for SteelSmelting

Source§

impl<T> Recipe for TechRecipe<T>
where T: Technology,

Source§

const TIME: u64 = T::POINT_RECIPE_TIME

Source§

const INPUT_AMOUNTS: <TechRecipe<T> as Recipe>::InputAmountsType = T::INPUT_AMOUNTS

Source§

const OUTPUT_AMOUNTS: (u32,)

Source§

type Inputs = <T as TechnologyEx>::Inputs

Source§

type InputAmountsType = <T as TechnologyEx>::InputAmountsType

Source§

type Outputs = (Resource<ResearchPoint<T>>,)

Source§

type OutputAmountsType = (u32,)