Skip to content

Commit

Permalink
[MIRROR] Crafting now transfers reagents from ingredients to final pr…
Browse files Browse the repository at this point in the history
…oduct [MDB IGNORE] (#25711)

* Crafting now transfers reagents from ingredients to final product (#80391)

## About The Pull Request
- Fixes #80143
- Fixes #80381

Based on the ingredients required reagents of the final product can
differ. It now transfers the olive oil from the bottle to the toasted
seeds & the orange juice and grenadine reagent from the ingredients into
the kasei dango.

Snow cones are now also edible

## Changelog
:cl:
fix: crafting now transfers reagents from ingredients to final product
making previously inedible foods (toasted seeds, kasei dango & snow
cones) edible. Other crafted food products/items now differ in reagents
based on the ingredients required.
/:cl:

* Crafting now transfers reagents from ingredients to final product

---------

Co-authored-by: SyncIt21 <[email protected]>
  • Loading branch information
2 people authored and FFMirrorBot committed Dec 18, 2023
1 parent 14eb980 commit 79db96f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
34 changes: 24 additions & 10 deletions code/datums/components/crafting/crafting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/chemistry/holder/holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 79db96f

Please sign in to comment.