diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-20 02:16:41 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-23 19:21:49 +0200 |
commit | c78665e4fd83a64a67a6747ec9429c74a3d4a466 (patch) | |
tree | 6d0714808ca3c3fb9a3ca652770668058f5f89cc /server/src/interaction.rs | |
parent | 935dc832d02ba49ad50cbbaee333ab2dacd3226d (diff) | |
download | hurrycurry-c78665e4fd83a64a67a6747ec9429c74a3d4a466.tar hurrycurry-c78665e4fd83a64a67a6747ec9429c74a3d4a466.tar.bz2 hurrycurry-c78665e4fd83a64a67a6747ec9429c74a3d4a466.tar.zst |
generate dot graph from recipes
Diffstat (limited to 'server/src/interaction.rs')
-rw-r--r-- | server/src/interaction.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/server/src/interaction.rs b/server/src/interaction.rs index a4b79bd0..93f54b2d 100644 --- a/server/src/interaction.rs +++ b/server/src/interaction.rs @@ -42,6 +42,26 @@ impl Recipe { _ => None, } } + pub fn inputs(&self) -> Vec<ItemIndex> { + match self { + Recipe::Passive { input, .. } => vec![*input], + Recipe::Active { input, .. } => vec![*input], + Recipe::Instant { inputs, .. } => { + inputs.into_iter().flat_map(|e| e.to_owned()).collect() + } + } + } + pub fn outputs(&self) -> Vec<ItemIndex> { + match self { + Recipe::Passive { output, .. } => output.to_owned().into_iter().collect(), + Recipe::Active { outputs, .. } => { + outputs.into_iter().flat_map(|e| e.to_owned()).collect() + } + Recipe::Instant { outputs, .. } => { + outputs.into_iter().flat_map(|e| e.to_owned()).collect() + } + } + } pub fn supports_tile(&self, tile: TileIndex) -> bool { if let Some(tile_constraint) = self.tile() { if tile != tile_constraint { |