mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
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:
committed by
yogstation13-bot
parent
94bc4e49a1
commit
c70c6c94e6
26
code/datums/components/wearertargeting.dm
Normal file
26
code/datums/components/wearertargeting.dm
Normal 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)
|
||||
Reference in New Issue
Block a user