Files
Yogstation/code/datums/components/wearertargeting.dm
Emmett Gaines 488b6b5517 Adds the signal origin as the first arg to all signals (#39861)
* Adds the signal origin as the first arg to all signals

* Fixes some storage and nanite procs
2018-08-28 16:28:34 +01:00

26 lines
962 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/datum/callback/callback = CALLBACK(GLOBAL_PROC, .proc/pass)
var/mobtype = /mob/living
/datum/component/wearertargeting/Initialize()
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, .proc/on_equip)
RegisterSignal(parent, COMSIG_ITEM_DROPPED, .proc/on_drop)
/datum/component/wearertargeting/proc/on_equip(datum/source, mob/equipper, slot)
if((slot in valid_slots) && istype(equipper, mobtype))
RegisterSignal(equipper, signals, callback, TRUE)
else
UnregisterSignal(equipper, signals)
/datum/component/wearertargeting/proc/on_drop(datum/source, mob/user)
UnregisterSignal(user, signals)
/datum/component/wearertargeting/Destroy()
QDEL_NULL(callback) //is likely to ourselves.
return ..()