Files
Yogstation/code/datums/components/wearertargeting.dm
vuonojenmustaturska c70c6c94e6 Replaces HEALS_EARS_2 with a component, adds a wearertargeting parent component for future use (#37530)
code: HEALS_EARS_2 is removed in favor of the earhealing component

code: wearertargeting component is available to subtype for components that want to target the wearer of an item rather than the item itself
2018-04-29 23:33:45 +01:00

27 lines
894 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/datum/component/mobhook
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(list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED), .proc/checkMobHook)
/datum/component/wearertargeting/Destroy()
QDEL_NULL(mobhook)
return ..()
/datum/component/wearertargeting/proc/checkMobHook(mob/user, slot)
if ((slot in valid_slots) && istype(user, mobtype))
if (mobhook && mobhook.parent != user)
QDEL_NULL(mobhook)
if (!mobhook)
mobhook = user.AddComponent(/datum/component/redirect, signals, callback)
else
QDEL_NULL(mobhook)