Files
Bubberstation/code/datums/components/wearertargeting.dm
SSensum13 99d95aae62 Some ITEM_SLOT bitflags fixes. (#92441)
## About The Pull Request

This PR fixes wrong usage of bitflags in a few places, where instead of
bitfields lists were used.

## Why It's Good For The Game

It will help prevent problems that can be a thing in the future,
improving consistency of the codebase.
2025-08-19 22:30:33 -04:00

29 lines
969 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
/// Bitflag value of valid slots.
/// You can find all slot bitflags in code/__DEFINES/inventory.dm
var/valid_slots = NONE
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((valid_slots & slot) && 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)