mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-20 11:40:07 +01:00
- Makes QDELETED use isnull(x) instead of !x, giving about 0.2 to 0.25s of speed. - Make disposal constructs only update icon state rather than go through expensive overlay code. Unfortunately did not have much effect, but is something they should've been doing nonetheless. - Makes RegisterSignal only take signals directly as opposed to allocating a fresh list of signals. Very few consumers actually used this and it costs about 0.4s. Also I think this is just a bad API anyway and that separate procs are important `\bRegisterSignal\((.*)list\(` replaced with `RegisterSignals($1list(`
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(delta_time)
|
|
for(var/i in user_by_item)
|
|
var/mob/living/carbon/user = user_by_item[i]
|
|
var/obj/item/organ/internal/ears/ears = user.getorganslot(ORGAN_SLOT_EARS)
|
|
if(!ears || !ears.damage || ears.organ_flags & ORGAN_FAILING)
|
|
continue
|
|
ears.deaf = max(ears.deaf - 0.25 * delta_time, (ears.damage < ears.maxHealth ? 0 : 1)) // Do not clear deafness if our ears are too damaged
|
|
ears.applyOrganDamage(-0.025 * delta_time)
|
|
CHECK_TICK
|