mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-31 20:11:56 +00:00
This tracks the seconds per tick of a subsystem, however note that it is not completely accurate, as subsystems can be delayed, however it's useful to have this number as a multiplier or ratio, so that if in future someone changes the subsystem wait time code correctly adjusts how fast it applies effects regexes used git grep --files-with-matches --name-only 'DT_PROB' | xargs -l sed -i 's/DT_PROB/SPT_PROB/g' git grep --files-with-matches --name-only 'delta_time' | xargs -l sed -i 's/delta_time/seconds_per_tick/g'
35 lines
1.2 KiB
Plaintext
35 lines
1.2 KiB
Plaintext
/datum/element/earhealing
|
|
element_flags = ELEMENT_DETACH_ON_HOST_DESTROY
|
|
var/list/user_by_item = list()
|
|
|
|
/datum/element/earhealing/Attach(datum/target)
|
|
. = ..()
|
|
if(!isitem(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
|
|
RegisterSignals(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED), PROC_REF(on_equip))
|
|
|
|
/datum/element/earhealing/Detach(datum/target)
|
|
. = ..()
|
|
UnregisterSignal(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED))
|
|
user_by_item -= target
|
|
|
|
/datum/element/earhealing/proc/on_equip(datum/source, mob/living/carbon/user, slot)
|
|
SIGNAL_HANDLER
|
|
|
|
if((slot & ITEM_SLOT_EARS) && istype(user))
|
|
START_PROCESSING(SSdcs, src)
|
|
user_by_item[source] = user
|
|
else
|
|
user_by_item -= source
|
|
|
|
/datum/element/earhealing/process(seconds_per_tick)
|
|
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_organ_slot(ORGAN_SLOT_EARS)
|
|
if(!ears || !ears.damage || ears.organ_flags & ORGAN_FAILING)
|
|
continue
|
|
ears.deaf = max(ears.deaf - 0.25 * seconds_per_tick, (ears.damage < ears.maxHealth ? 0 : 1)) // Do not clear deafness if our ears are too damaged
|
|
ears.apply_organ_damage(-0.025 * seconds_per_tick)
|
|
CHECK_TICK
|