mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 10:11:09 +00:00
* 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>
27 lines
875 B
Plaintext
27 lines
875 B
Plaintext
// A dummy parent type used for easily making components that target an item's wearer rather than the item itself.
|
|
|
|
/datum/component/wearertargeting
|
|
var/list/valid_slots = list()
|
|
var/list/signals = list()
|
|
var/proctype = GLOBAL_PROC_REF(pass)
|
|
var/mobtype = /mob/living
|
|
|
|
/datum/component/wearertargeting/Initialize()
|
|
if(!isitem(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, PROC_REF(on_equip))
|
|
RegisterSignal(parent, COMSIG_ITEM_DROPPED, PROC_REF(on_drop))
|
|
|
|
/datum/component/wearertargeting/proc/on_equip(datum/source, mob/equipper, slot)
|
|
SIGNAL_HANDLER
|
|
|
|
if((slot in valid_slots) && istype(equipper, mobtype))
|
|
RegisterSignals(equipper, signals, proctype, TRUE)
|
|
else
|
|
UnregisterSignal(equipper, signals)
|
|
|
|
/datum/component/wearertargeting/proc/on_drop(datum/source, mob/user)
|
|
SIGNAL_HANDLER
|
|
|
|
UnregisterSignal(user, signals)
|