@@ -6,16 +6,11 @@ use serde::Deserialize;
66use crate :: {
77 assets:: {
88 LoadResource ,
9- indexing:: IndexMap ,
109 manifest:: { Id , Manifest , ManifestPlugin } ,
1110 } ,
1211 screens:: Screen ,
13- simulation:: {
14- item:: { ItemDef , PlayerInventory , Stack } ,
15- recipe:: RecipeDef ,
16- world:: { MAP_SIZE , Terrain , WorldSpawnSystems } ,
17- } ,
18- ui:: { Interact , Interactable , YSort } ,
12+ simulation:: world:: { MAP_SIZE , Terrain , WorldSpawnSystems } ,
13+ ui:: { Interactable , YSort } ,
1914} ;
2015
2116pub fn plugin ( app : & mut App ) {
@@ -27,8 +22,6 @@ pub fn plugin(app: &mut App) {
2722 OnEnter ( Screen :: Gameplay ) ,
2823 spawn_deposits. in_set ( WorldSpawnSystems :: SpawnDeposits ) ,
2924 ) ;
30-
31- app. add_observer ( on_mine_deposit) ;
3225}
3326
3427#[ derive( Debug , Deserialize , TypePath ) ]
@@ -103,37 +96,3 @@ fn spawn_deposits(
10396 }
10497 }
10598}
106-
107- fn on_mine_deposit (
108- trigger : Trigger < Interact > ,
109- deposits : Query < & DepositRecipe > ,
110- mut inventory : Single < & mut PlayerInventory > ,
111- recipes : Res < Assets < RecipeDef > > ,
112- recipe_index : Res < IndexMap < RecipeDef > > ,
113- items : Res < Assets < ItemDef > > ,
114- item_index : Res < IndexMap < ItemDef > > ,
115- ) {
116- let Ok ( deposit_recipe) = deposits. get ( trigger. target ( ) ) else {
117- return ;
118- } ;
119-
120- let recipe_def = recipe_index
121- . get ( & deposit_recipe. 0 )
122- . and_then ( |asset_id| recipes. get ( * asset_id) )
123- . expect ( "Deposit refers to non-existent recipe" ) ;
124-
125- for ( item_id, quantity) in recipe_def. output . iter ( ) {
126- let item_def = item_index
127- . get ( item_id)
128- . and_then ( |asset_id| items. get ( * asset_id) )
129- . expect ( "Recipe refers to invalid item id" ) ;
130-
131- let mut stack = Stack {
132- item_id : item_def. id . to_owned ( ) ,
133- quantity : * quantity,
134- max_quantity : item_def. stack_size ,
135- } ;
136-
137- let _ = inventory. add_stack ( & mut stack) ;
138- }
139- }
0 commit comments