Files
Bubberstation/code/datums/elements/delete_on_drop.dm
SkyratBot a70a6a8055 [MIRROR] Save 0.6-0.7s of init time by splitting registering lists of signals into its own proc, and optimizing QDELETED [MDB IGNORE] (#17670)
* Save 0.6-0.7s of init time by splitting registering lists of signals into its own proc, and optimizing QDELETED

* modular RegisterSignals

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
Co-authored-by: tastyfish <crazychris32@gmail.com>
2022-11-28 14:51:08 -05:00

21 lines
601 B
Plaintext

/**
* Attaches to an item, if that item is dropped on the floor delete it
*/
/datum/element/delete_on_drop
var/list/myvar = list()
/datum/element/delete_on_drop/Attach(datum/target)
. = ..()
if(!isitem(target))
return COMPONENT_INCOMPATIBLE
RegisterSignals(target, list(COMSIG_ITEM_DROPPED, COMSIG_CASING_EJECTED), PROC_REF(del_on_drop))
/datum/element/delete_on_drop/Detach(datum/source)
. = ..()
UnregisterSignal(source, list(COMSIG_ITEM_DROPPED, COMSIG_CASING_EJECTED))
/datum/element/delete_on_drop/proc/del_on_drop(atom/source)
SIGNAL_HANDLER
if(isturf(source.loc))
qdel(source)