[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 <silent_insomnia_pp@hotmail.co.uk>
This commit is contained in:
SkyratBot
2020-11-07 00:32:56 +00:00
committed by GitHub
co-authored by Timberpoes
parent 7a28968feb
commit be16d05f08
3 changed files with 16 additions and 0 deletions
@@ -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