Fixes newfood reagent transfer and food trash' to_chat (#55150)

Co-authored-by: Jared-Fogle <35135081+Jared-Fogle@users.noreply.github.com>
This commit is contained in:
Qustinnus
2020-12-02 02:04:58 -08:00
committed by GitHub
co-authored by Jared-Fogle
parent 126df37863
commit 9c85aba400
3 changed files with 19 additions and 17 deletions
+2 -16
View File
@@ -192,7 +192,7 @@ Behavior that's still missing from this component that original food items had t
var/atom/this_food = parent
this_food.reagents.clear_reagents()
this_food.reagents.multiply_reagents(CRAFTED_FOOD_BASE_REAGENT_MODIFIER)
for(var/obj/item/crafted_part in this_food.contents)
crafted_part.reagents?.trans_to(this_food.reagents, crafted_part.reagents.maximum_volume, CRAFTED_FOOD_INGREDIENT_REAGENT_MODIFIER)
@@ -208,13 +208,6 @@ Behavior that's still missing from this component that original food items had t
QDEL_LIST(objects_to_delete)
for(var/r_id in initial_reagents)
var/amount = initial_reagents[r_id] * CRAFTED_FOOD_BASE_REAGENT_MODIFIER
if(r_id == /datum/reagent/consumable/nutriment || r_id == /datum/reagent/consumable/nutriment/vitamin || r_id == /datum/reagent/consumable/nutriment/protein)
this_food.reagents.add_reagent(r_id, amount, tastes)
else
this_food.reagents.add_reagent(r_id, amount)
SSblackbox.record_feedback("tally", "food_made", 1, type)
/datum/component/edible/proc/OnMicrowaved(datum/source, obj/machinery/microwave/used_microwave)
@@ -245,17 +238,10 @@ Behavior that's still missing from this component that original food items had t
var/atom/this_food = parent
this_food.reagents.clear_reagents()
this_food.reagents.multiply_reagents(cooking_efficiency * CRAFTED_FOOD_BASE_REAGENT_MODIFIER)
source_item.reagents?.trans_to(this_food, source_item.reagents.total_volume)
for(var/r_id in initial_reagents)
var/amount = initial_reagents[r_id] * cooking_efficiency * CRAFTED_FOOD_BASE_REAGENT_MODIFIER
if(r_id == /datum/reagent/consumable/nutriment || r_id == /datum/reagent/consumable/nutriment/vitamin || r_id == /datum/reagent/consumable/nutriment/protein)
this_food.reagents.add_reagent(r_id, amount, tastes)
else
this_food.reagents.add_reagent(r_id, amount)
///Makes sure the thing hasn't been destroyed or fully eaten to prevent eating phantom edibles
/datum/component/edible/proc/IsFoodGone(atom/owner, mob/living/feeder)
if(QDELETED(owner)|| !(IS_EDIBLE(owner)))
+1 -1
View File
@@ -65,7 +65,7 @@
/datum/element/food_trash/proc/open_trash(datum/source, mob/user)
SIGNAL_HANDLER
to_chat(user, "<span class='notice'>You open the [src]\'s shell, revealing \a [initial(trash.name)].</span>")
to_chat(user, "<span class='notice'>You open the [source], revealing \a [initial(trash.name)].</span>")
INVOKE_ASYNC(src, .proc/async_generate_trash, source)
qdel(source)
+16
View File
@@ -324,6 +324,22 @@
src.handle_reactions()
return amount
///Multiplies the reagents inside this holder by a specific amount
/datum/reagents/proc/multiply_reagents(multiplier=1)
var/list/cached_reagents = reagent_list
if(!total_volume)
return
var/change = (multiplier - 1) //Get the % change
for(var/reagent in cached_reagents)
var/datum/reagent/T = reagent
if(change > 0)
add_reagent(T.type, T.volume * change)
else
remove_reagent(T.type, abs(T.volume * change)) //absolute value to prevent a double negative situation (removing -50% would be adding 50%)
update_total()
handle_reactions()
/// Transfer a specific reagent id to the target object
/datum/reagents/proc/trans_id_to(obj/target, reagent, amount=1, preserve_data=1)//Not sure why this proc didn't exist before. It does now! /N
var/list/cached_reagents = reagent_list