diff --git a/code/datums/components/crafting/crafting.dm b/code/datums/components/crafting/crafting.dm index 39c53be57d9..e16ab582b77 100644 --- a/code/datums/components/crafting/crafting.dm +++ b/code/datums/components/crafting/crafting.dm @@ -210,8 +210,13 @@ if(result.atom_storage && recipe.delete_contents) for(var/obj/item/thing in result) qdel(thing) - if (IsEdible(result)) - result.reagents?.clear_reagents() + result.reagents?.clear_reagents() + var/datum/reagents/holder = locate() in parts + if(holder) //transfer reagents from ingredients to result + if(result.reagents) + holder.trans_to(result.reagents, holder.total_volume, no_react = TRUE) + parts -= holder + qdel(holder) result.CheckParts(parts, recipe) if(send_feedback) SSblackbox.record_feedback("tally", "object_crafted", 1, result.type) @@ -244,9 +249,11 @@ */ /datum/component/personal_crafting/proc/del_reqs(datum/crafting_recipe/R, atom/a) + . = list() + + var/datum/reagents/holder var/list/surroundings var/list/Deletion = list() - . = list() var/data var/amt var/list/requirements = list() @@ -266,17 +273,24 @@ if(ispath(path_key, /datum/reagent)) while(amt > 0) var/obj/item/reagent_containers/RC = locate() in surroundings - if(QDELETED(RC)) //being deleted or null(i.e. not found) + if(isnull(RC)) //not found break - var/datum/reagent/RG = RC.reagents.has_reagent(path_key) - if(RG) - if(RG.volume >= amt) - RC.reagents.remove_reagent(path_key, amt) + if(QDELING(RC)) //deleting so is unusable + surroundings -= RC + continue + + var/reagent_volume = RC.reagents.get_reagent_amount(path_key) + if(reagent_volume) + if(!holder) + holder = new(INFINITY, NO_REACT) //an infinite volume holder than can store reagents without reacting + . += holder + if(reagent_volume >= amt) + RC.reagents.trans_to(holder, amt, target_id = path_key, no_react = TRUE) continue main_loop else + RC.reagents.trans_to(holder, reagent_volume, target_id = path_key, no_react = TRUE) surroundings -= RC - amt -= RG.volume - RC.reagents.remove_reagent(path_key, RG.volume) + amt -= reagent_volume SEND_SIGNAL(RC.reagents, COMSIG_REAGENTS_CRAFTING_PING) // - [] TODO: Make this entire thing less spaghetti else surroundings -= RC diff --git a/code/modules/reagents/chemistry/holder/holder.dm b/code/modules/reagents/chemistry/holder/holder.dm index 4cfad8aae9c..ed7e8349055 100644 --- a/code/modules/reagents/chemistry/holder/holder.dm +++ b/code/modules/reagents/chemistry/holder/holder.dm @@ -423,7 +423,7 @@ * * ignore_stomach - when using methods INGEST will not use the stomach as the target */ /datum/reagents/proc/trans_to( - obj/target, + atom/target, amount = 1, multiplier = 1, datum/reagent/target_id,