Skip to main content

rustorio/
recipes.rs

1//! A recipe is a way of turning resources into other resources.
2//! Some recipes can be performed by hand, but most can be automated using buildings like the [`Assembler`](crate::buildings::Assembler) or the [`Furnace`](crate::buildings::Furnace).
3//! To figure out where the recipe can be performed, look at the trait impls.
4//! For example, the [`CopperWireRecipe`] implements the [`AssemblerRecipe`] and [`HandRecipe`] traits, meaning it can be performed by hand and in an [`Assembler`](crate::buildings::Assembler).
5//!
6//! The documentation for each recipe struct provides more details about the recipe, including inputs, outputs and time taken.
7
8use std::fmt::Debug;
9
10use rustorio_engine::{
11    Sealed,
12    recipe::{HandRecipe, Recipe, RecipeEx, recipe_doc},
13};
14
15use crate::{
16    research::RedScience,
17    resources::{Copper, CopperOre, CopperWire, ElectronicCircuit, Iron, IronOre, Point, Steel},
18};
19
20/// Any recipe that implements this trait can be used in an [`Assembler`](crate::buildings::Assembler).
21pub trait AssemblerRecipe: Debug + Sealed + RecipeEx {}
22
23#[derive(Debug, Clone, Copy, Recipe, RecipeEx)]
24#[recipe_doc]
25#[recipe_inputs(
26    (1, Copper),
27)]
28#[recipe_outputs(
29    (2, CopperWire),
30)]
31#[recipe_ticks(1)]
32pub struct CopperWireRecipe;
33impl Sealed for CopperWireRecipe {}
34impl AssemblerRecipe for CopperWireRecipe {}
35impl HandRecipe for CopperWireRecipe {}
36
37#[derive(Debug, Clone, Copy, Recipe, RecipeEx)]
38#[recipe_doc]
39#[recipe_inputs(
40    (1, Iron),
41    (2, CopperWire),
42)]
43#[recipe_outputs(
44    (1, ElectronicCircuit),
45)]
46#[recipe_ticks(3)]
47pub struct ElectronicCircuitRecipe;
48impl Sealed for ElectronicCircuitRecipe {}
49impl AssemblerRecipe for ElectronicCircuitRecipe {}
50impl HandRecipe for ElectronicCircuitRecipe {}
51
52/// A recipe for crafting red science packs.
53#[derive(Debug, Clone, Copy, Recipe, RecipeEx)]
54#[recipe_doc]
55#[recipe_inputs(
56    (1, Iron),
57    (1, ElectronicCircuit),
58)]
59#[recipe_outputs(
60    (1, RedScience),
61)]
62#[recipe_ticks(10)]
63pub struct RedScienceRecipe;
64impl Sealed for RedScienceRecipe {}
65impl AssemblerRecipe for RedScienceRecipe {}
66impl HandRecipe for RedScienceRecipe {}
67
68/// The recipe you need to win! An [`Assembler`](crate::buildings::Assembler) recipe that creates points.
69///
70/// You can unlock this recipe by researching [`PointsTechnology`](crate::research::PointsTechnology).
71#[derive(Debug, Clone, Copy, Recipe, RecipeEx)]
72#[recipe_doc]
73#[recipe_inputs(
74    (4, ElectronicCircuit),
75    (1, Steel),
76)]
77#[recipe_outputs(
78    (1, Point),
79)]
80#[recipe_ticks(20)]
81#[non_exhaustive]
82pub struct PointRecipe;
83impl Sealed for PointRecipe {}
84impl AssemblerRecipe for PointRecipe {}
85
86/// Any recipe that implements this trait can be used in a [`Furnace`](crate::buildings::Furnace).
87pub trait FurnaceRecipe: Debug + Sealed + RecipeEx {}
88
89/// A [`Furnace`](crate::buildings::Furnace) recipe that smelts iron ore into iron.
90#[derive(Debug, Clone, Copy, Recipe, RecipeEx)]
91#[recipe_doc]
92#[recipe_inputs(
93    (1, IronOre),
94)]
95#[recipe_outputs(
96    (1, Iron),
97)]
98#[recipe_ticks(6)]
99pub struct IronSmelting;
100impl Sealed for IronSmelting {}
101impl FurnaceRecipe for IronSmelting {}
102
103/// A [`Furnace`](crate::buildings::Furnace) recipe that smelts copper ore into copper.
104#[derive(Debug, Clone, Copy, Recipe, RecipeEx)]
105#[recipe_doc]
106#[recipe_inputs(
107    (1, CopperOre),
108)]
109#[recipe_outputs(
110    (1, Copper),
111)]
112#[recipe_ticks(6)]
113pub struct CopperSmelting;
114impl Sealed for CopperSmelting {}
115impl FurnaceRecipe for CopperSmelting {}
116
117/// A [`Furnace`](crate::buildings::Furnace) recipe that smelts iron into steel.
118#[derive(Debug, Clone, Copy, Recipe, RecipeEx)]
119#[recipe_doc]
120#[recipe_inputs(
121    (5, Iron),
122)]
123#[recipe_outputs(
124    (1, Steel),
125)]
126#[recipe_ticks(30)]
127#[non_exhaustive]
128pub struct SteelSmelting;
129impl Sealed for SteelSmelting {}
130impl FurnaceRecipe for SteelSmelting {}