Files
Paradise/code/datums/elements/earhealing.dm
Chap d90a70ecda [REFACTOR] Consolidates SLOT_FLAG and SLOT_HUD into one ITEM_SLOT flag (#26743)
* IT WORKS UP UNTIL THIS POINT

* Consolidates SLOT_FLAG and SLOT_HUD into one

* Remove cover_both_ears

* SLOT_HUD to ITEM_SLOT

* Remove clothing_trait changes for the time being

* Remove accidental copy-paste

* Re-add no-slip var

* More failure to copy-paste correctly

* Leftover flag

* Combine left and right slot flags where possible

* UNGOOF MY DEFINES, PHAND IS NOT A THING

* Minor spacing changes

* Some more fixes from merge

* Seperates ITEM SLOT AMOUNT into two defines

* ON SECOND THOUGHT LETS NOT DO THAT.

* Addresses Contra's review

* Thank you GREP

* Rename ITEM_SLOT_FEET to ITEM_SLOT_SHOES

* Added a comment to the bitmasks in clothing defines

* Rename ITEM_SLOT_TIE to ITEM_SLOT_ACCESSORY

* These are for a seperate PR.

* Magboot fixes

* Requested changes

* Re-add accidental removal

* Wrong flags

* Update code/__DEFINES/clothing_defines.dm

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
Signed-off-by: Chap <erwin@lombok.demon.nl>

* Requested changes

* Merge fixes

* Fix double headset

* Fixes multiple accessories

---------

Signed-off-by: Chap <erwin@lombok.demon.nl>
Co-authored-by: Adrer <adrermail@gmail.com>
Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
2024-11-13 13:02:29 +00:00

37 lines
1.1 KiB
Plaintext

/datum/element/earhealing
element_flags = ELEMENT_DETACH_ON_HOST_DESTROY
var/list/user_by_item = list()
/datum/element/earhealing/New()
START_PROCESSING(SSdcs, src)
/datum/element/earhealing/Attach(datum/target)
. = ..()
if(!isitem(target))
return ELEMENT_INCOMPATIBLE
RegisterSignal(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED), PROC_REF(equippedChanged))
/datum/element/earhealing/Detach(datum/target)
. = ..()
UnregisterSignal(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED))
user_by_item -= target
/datum/element/earhealing/proc/equippedChanged(datum/source, mob/living/carbon/user, slot)
SIGNAL_HANDLER
if((slot & ITEM_SLOT_BOTH_EARS) && istype(user))
user_by_item[source] = user
else
user_by_item -= source
/datum/element/earhealing/process()
for(var/i in user_by_item)
var/mob/living/carbon/user = user_by_item[i]
var/obj/item/organ/internal/ears/ears = user.get_int_organ(/obj/item/organ/internal/ears)
if(!ears || HAS_TRAIT_NOT_FROM(user, TRAIT_DEAF, EAR_DAMAGE))
continue
user.AdjustDeaf(-1 SECONDS)
ears.heal_internal_damage(0.025)
CHECK_TICK