Files
Bubberstation/code/datums/components/plumbing/IV_drip.dm
SkyratBot d7da41789b [MIRROR] Deletes recipient_reagents_holder on del (#4759)
* Deletes recipient_reagents_holder on del (#57767)

* Deletes recipient_reagents_holder on del

* Cleans up recipient refs when recipient dels

* no one saw that

* Makes plumbing listen to component signal for finishing

* Unregisters enable call

* Deletes recipient_reagents_holder on del

Co-authored-by: Time-Green <timkoster1@hotmail.com>
2021-04-08 22:05:15 +01:00

35 lines
1.2 KiB
Plaintext

///Component for IVs that tracks the current person being IV'd. Input received through plumbing is instead routed to the whoever is attached
/datum/component/plumbing/iv_drip
demand_connects = SOUTH
supply_connects = NORTH
methods = INJECT
/datum/component/plumbing/iv_drip/Initialize(start=TRUE, _ducting_layer, _turn_connects=TRUE, datum/reagents/custom_receiver)
. = ..()
set_recipient_reagents_holder(null)
/datum/component/plumbing/iv_drip/RegisterWithParent()
. = ..()
RegisterSignal(parent, list(COMSIG_IV_ATTACH), .proc/update_attached)
RegisterSignal(parent, list(COMSIG_IV_DETACH), .proc/clear_attached)
/datum/component/plumbing/iv_drip/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_IV_ATTACH))
UnregisterSignal(parent, list(COMSIG_IV_DETACH))
///When an IV is attached, we will use whoever is attached as our receiving container
/datum/component/plumbing/iv_drip/proc/update_attached(datum/source, mob/living/attachee)
SIGNAL_HANDLER
if(attachee?.reagents)
set_recipient_reagents_holder(attachee.reagents)
///IV has been detached, so clear the holder
/datum/component/plumbing/iv_drip/proc/clear_attached(datum/source)
SIGNAL_HANDLER
set_recipient_reagents_holder(null)