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
This commit is contained in:
vuonojenmustaturska
2018-04-30 01:32:59 +03:00
committed by yogstation13-bot
parent 94bc4e49a1
commit c70c6c94e6
8 changed files with 67 additions and 14 deletions

View File

@@ -0,0 +1,26 @@
// 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)