Files
Bubberstation/code/datums/elements/delete_on_drop.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

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)