From be16d05f08c59ebff90ae35064469d8b415fc48a Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sat, 7 Nov 2020 01:32:56 +0100 Subject: [PATCH] [MIRROR] Fixes foods crafted from glowing ingredients having incorrect light_overlay (#1592) * Fixes foods crafted from glowing ingredients having incorrect light_overlay (#54768) Fixes #54699 Grown foods used in crafting recipes are moved into the contents of the item they are used to craft. Any grown food with a lighting component was never properly attached to their parent as part of crafting and thus the grown food itself would glow from the containing item instead of the containing item's loc or turf, including when in the user's hand or backpack as per the above issue report. This PR creates a new signal sent to atoms that are used as part of crafting recipes. It then makes lightning components register this signal with their parents. If their parents are "consumed" (ie moved into the newly crafted item's contents) during crafting, the signal handler proc re-registers the signal with the newly crafted item and sets the newly crafted item as the attached parent for that lighting overlay component. This now means that crafting using objects with lighting components is now fully supported including when you craft with objects that were crafted with objects with lightning components * Fixes foods crafted from glowing ingredients having incorrect light_overlay Co-authored-by: Timberpoes --- code/__DEFINES/dcs/signals.dm | 2 ++ code/datums/components/overlay_lighting.dm | 13 +++++++++++++ code/game/atoms.dm | 1 + 3 files changed, 16 insertions(+) diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index 57ba69c3f7b..19334f1fec0 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -98,6 +98,8 @@ #define COMSIG_ATOM_BULLET_ACT "atom_bullet_act" ///from base of atom/CheckParts(): (list/parts_list, datum/crafting_recipe/R) #define COMSIG_ATOM_CHECKPARTS "atom_checkparts" +///from base of atom/CheckParts(): (atom/movable/new_craft) - The atom has just been used in a crafting recipe and has been moved inside new_craft. +#define COMSIG_ATOM_USED_IN_CRAFT "atom_used_in_craft" ///from base of atom/blob_act(): (/obj/structure/blob) #define COMSIG_ATOM_BLOB_ACT "atom_blob_act" ///from base of atom/acid_act(): (acidpwr, acid_volume) diff --git a/code/datums/components/overlay_lighting.dm b/code/datums/components/overlay_lighting.dm index bdc855a2aa3..ff47d54e1b4 100644 --- a/code/datums/components/overlay_lighting.dm +++ b/code/datums/components/overlay_lighting.dm @@ -112,6 +112,7 @@ RegisterSignal(parent, COMSIG_ATOM_SET_LIGHT_COLOR, .proc/set_color) RegisterSignal(parent, COMSIG_ATOM_SET_LIGHT_ON, .proc/on_toggle) RegisterSignal(parent, COMSIG_ATOM_SET_LIGHT_FLAGS, .proc/on_light_flags_change) + RegisterSignal(parent, COMSIG_ATOM_USED_IN_CRAFT, .proc/on_parent_crafted) var/atom/movable/movable_parent = parent if(movable_parent.light_flags & LIGHT_ATTACHED) overlay_lighting_flags |= LIGHTING_ATTACHED @@ -133,6 +134,7 @@ COMSIG_ATOM_SET_LIGHT_COLOR, COMSIG_ATOM_SET_LIGHT_ON, COMSIG_ATOM_SET_LIGHT_FLAGS, + COMSIG_ATOM_USED_IN_CRAFT, )) if(directional) UnregisterSignal(parent, COMSIG_ATOM_DIR_CHANGE) @@ -203,6 +205,7 @@ /datum/component/overlay_lighting/proc/set_parent_attached_to(atom/movable/new_parent_attached_to) if(new_parent_attached_to == parent_attached_to) return + . = parent_attached_to parent_attached_to = new_parent_attached_to if(.) @@ -442,6 +445,16 @@ if(overlay_lighting_flags & LIGHTING_ON) make_luminosity_update() +/datum/component/overlay_lighting/proc/on_parent_crafted(datum/source, atom/movable/new_craft) + SIGNAL_HANDLER + + if(!istype(new_craft)) + return + + UnregisterSignal(parent, COMSIG_ATOM_USED_IN_CRAFT) + RegisterSignal(new_craft, COMSIG_ATOM_USED_IN_CRAFT, .proc/on_parent_crafted) + set_parent_attached_to(new_craft) + #undef LIGHTING_ON #undef LIGHTING_ATTACHED #undef GET_PARENT diff --git a/code/game/atoms.dm b/code/game/atoms.dm index a8242dd6767..3945a81c61a 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -434,6 +434,7 @@ L.transferItemToLoc(M, src) else M.forceMove(src) + SEND_SIGNAL(M, COMSIG_ATOM_USED_IN_CRAFT, src) parts_list.Cut() ///Take air from the passed in gas mixture datum