From 20fbe40187f394d3cda1282b36dc3655fcb87aa6 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Mon, 26 Jul 2021 16:48:38 +0200 Subject: [PATCH] [MIRROR] Makes only mapload foods require players to pick them up to decompose (#7131) * Makes only mapload foods require players to pick them up to decompose (#60392) Co-authored-by: Changelogs * Makes only mapload foods require players to pick them up to decompose Co-authored-by: Wallemations <66052067+Wallemations@users.noreply.github.com> Co-authored-by: Changelogs --- code/datums/components/food/decomposition.dm | 14 ++++++++++---- code/game/objects/items/food/_food.dm | 8 ++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/code/datums/components/food/decomposition.dm b/code/datums/components/food/decomposition.dm index be923786fd3..5877530ba8d 100644 --- a/code/datums/components/food/decomposition.dm +++ b/code/datums/components/food/decomposition.dm @@ -10,8 +10,8 @@ /datum/component/decomposition dupe_mode = COMPONENT_DUPE_UNIQUE - /// Makes sure food only starts decomposing if a player's EVER picked it up before - var/handled = FALSE + /// Makes sure maploaded food only starts decomposing if a player's EVER picked it up before + var/handled = TRUE /// Used to stop food in someone's hand & in storage slots from decomposing. var/protected = FALSE /// Used to stop the timer & check for the examine proc @@ -23,11 +23,13 @@ /// Used for examining var/examine_type = DECOMP_EXAM_NORMAL -/datum/component/decomposition/Initialize(decomp_flags = NONE) +/datum/component/decomposition/Initialize(mapload, decomp_flags = NONE) if(!isobj(parent)) return COMPONENT_INCOMPATIBLE src.decomp_flags = decomp_flags + if(mapload) + handled = FALSE RegisterSignal(parent, COMSIG_MOVABLE_MOVED, .proc/handle_movement) RegisterSignal(parent, list( @@ -47,6 +49,9 @@ time_remaining = DECOMPOSITION_TIME_GROSS examine_type = DECOMP_EXAM_GROSS + handle_movement() + + /datum/component/decomposition/UnregisterFromParent() UnregisterSignal(parent, list( COMSIG_ITEM_PICKUP, @@ -57,7 +62,8 @@ COMSIG_PARENT_EXAMINE)) /datum/component/decomposition/proc/handle_movement() - if(!handled) // Has someone touched this previously? + SIGNAL_HANDLER + if(!handled) // If maploaded, has someone touched this previously? return var/obj/food = parent // Doesn't HAVE to be food, that's just what it's intended for diff --git a/code/game/objects/items/food/_food.dm b/code/game/objects/items/food/_food.dm index 6e167cc380e..dd48a5ce232 100644 --- a/code/game/objects/items/food/_food.dm +++ b/code/game/objects/items/food/_food.dm @@ -39,7 +39,7 @@ ///Food that's immune to decomposition. var/preserved_food = FALSE -/obj/item/food/Initialize() +/obj/item/food/Initialize(mapload) . = ..() if(food_reagents) food_reagents = string_assoc_list(food_reagents) @@ -53,7 +53,7 @@ MakeProcessable() MakeLeaveTrash() MakeGrillable() - MakeDecompose() + MakeDecompose(mapload) ///This proc adds the edible component, overwrite this if you for some reason want to change some specific args like callbacks. /obj/item/food/proc/MakeEdible() @@ -87,6 +87,6 @@ return ///This proc makes things decompose. Set preserved_food to TRUE to make it never decompose. -/obj/item/food/proc/MakeDecompose() +/obj/item/food/proc/MakeDecompose(mapload) if(!preserved_food) - AddComponent(/datum/component/decomposition, decomp_flags = foodtypes) + AddComponent(/datum/component/decomposition, mapload, decomp_flags = foodtypes)