@@ -4,8 +4,9 @@ use crate::{
44 assets:: indexing:: IndexMap ,
55 gameplay:: {
66 FactorySystems ,
7- item:: { inventory :: Slots , stack:: Stack } ,
7+ item:: stack:: Stack ,
88 recipe:: { Input , Output , assets:: RecipeDef , select:: SelectedRecipe } ,
9+ storage:: Storage ,
910 } ,
1011} ;
1112
@@ -41,26 +42,26 @@ impl ProcessState {
4142}
4243
4344fn consume_input (
44- query : Query < ( & mut ProcessState , & Slots , & SelectedRecipe ) > ,
45+ query : Query < ( & mut ProcessState , & Storage , & SelectedRecipe ) > ,
4546 mut input_query : Query < ( & mut Stack , & Input ) > ,
4647 recipes : Res < Assets < RecipeDef > > ,
4748 recipe_index : Res < IndexMap < RecipeDef > > ,
4849) {
49- for ( mut state, slots , selected_recipe) in query {
50+ for ( mut state, storage , selected_recipe) in query {
5051 if !matches ! ( * state, ProcessState :: InsufficientInput ) {
5152 continue ;
5253 }
5354
54- if !slots
55+ if !storage
5556 . iter ( )
56- . filter_map ( |slot | input_query. get ( slot ) . ok ( ) )
57+ . filter_map ( |stored | input_query. get ( stored ) . ok ( ) )
5758 . all ( |( stack, input) | stack. quantity >= input. quantity )
5859 {
5960 continue ;
6061 }
6162
62- for slot in slots . iter ( ) {
63- if let Ok ( ( mut stack, input) ) = input_query. get_mut ( slot ) {
63+ for stored in storage . iter ( ) {
64+ if let Ok ( ( mut stack, input) ) = input_query. get_mut ( stored ) {
6465 stack. quantity = stack. quantity . saturating_sub ( input. quantity ) ;
6566 }
6667 }
@@ -91,16 +92,16 @@ fn progress_work(query: Query<&mut ProcessState>, time: Res<Time>) {
9192}
9293
9394fn produce_output (
94- query : Query < ( & mut ProcessState , & Slots ) > ,
95+ query : Query < ( & mut ProcessState , & Storage ) > ,
9596 mut output_query : Query < ( & mut Stack , & Output ) > ,
9697) {
97- for ( mut state, slots ) in query {
98+ for ( mut state, storage ) in query {
9899 if !matches ! ( * state, ProcessState :: Completed ) {
99100 continue ;
100101 }
101102
102- for output in slots . iter ( ) {
103- let Ok ( ( mut stack, output) ) = output_query. get_mut ( output ) else {
103+ for stored in storage . iter ( ) {
104+ let Ok ( ( mut stack, output) ) = output_query. get_mut ( stored ) else {
104105 continue ;
105106 } ;
106107
0 commit comments