Files
Bubberstation/code/datums/components/plumbing/IV_drip.dm
Mothblocks fa7688d043 Save 0.6-0.7s of init time by splitting registering lists of signals into its own proc, and optimizing QDELETED (#71056)
- Makes QDELETED use isnull(x) instead of !x, giving about 0.2 to 0.25s
of speed.
- Make disposal constructs only update icon state rather than go through
expensive overlay code. Unfortunately did not have much effect, but is
something they should've been doing nonetheless.
- Makes RegisterSignal only take signals directly as opposed to
allocating a fresh list of signals. Very few consumers actually used
this and it costs about 0.4s. Also I think this is just a bad API anyway
and that separate procs are important

`\bRegisterSignal\((.*)list\(` replaced with `RegisterSignals($1list(`
2022-11-22 07:40:05 +00: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, COMSIG_IV_ATTACH, PROC_REF(update_attached))
RegisterSignal(parent, COMSIG_IV_DETACH, PROC_REF(clear_attached))
/datum/component/plumbing/iv_drip/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_IV_ATTACH)
UnregisterSignal(parent, 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)