More things use trait huds over raw hud management (#93084)

This commit is contained in:
MrMelbert
2025-10-02 21:36:40 +02:00
committed by GitHub
parent 3d0cdfeac0
commit 44acefa73f
47 changed files with 249 additions and 236 deletions
+33 -2
View File
@@ -1665,13 +1665,44 @@
for(var/hud_trait in GLOB.trait_to_hud)
RegisterSignal(src, SIGNAL_ADDTRAIT(hud_trait), PROC_REF(hud_trait_enabled))
RegisterSignal(src, SIGNAL_REMOVETRAIT(hud_trait), PROC_REF(hud_trait_disabled))
for(var/hud_trait in GLOB.trait_blockers_to_hud)
RegisterSignal(src, SIGNAL_ADDTRAIT(hud_trait), PROC_REF(hud_trait_blocker_gained))
RegisterSignal(src, SIGNAL_REMOVETRAIT(hud_trait), PROC_REF(hud_trait_blocker_lost))
/mob/proc/hud_trait_enabled(datum/source, new_trait)
SIGNAL_HANDLER
for(var/blocker, blocked_traits in GLOB.trait_blockers_to_hud)
if(HAS_TRAIT(src, blocker) && (new_trait in blocked_traits))
return
var/datum/atom_hud/datahud = GLOB.huds[GLOB.trait_to_hud[new_trait]]
datahud.show_to(src)
/mob/proc/hud_trait_disabled(datum/source, new_trait)
/mob/proc/hud_trait_disabled(datum/source, lost_trait)
SIGNAL_HANDLER
var/datum/atom_hud/datahud = GLOB.huds[GLOB.trait_to_hud[new_trait]]
for(var/blocker, blocked_traits in GLOB.trait_blockers_to_hud)
if(HAS_TRAIT(src, blocker) && (lost_trait in blocked_traits))
return // it may seem counterintuitive to check for blockers on trait removal, the blocker now has total reign over whether the hud should come back
var/datum/atom_hud/datahud = GLOB.huds[GLOB.trait_to_hud[lost_trait]]
datahud.hide_from(src)
/mob/proc/hud_trait_blocker_gained(datum/source, new_trait)
SIGNAL_HANDLER
for(var/trait in GLOB.trait_blockers_to_hud[new_trait])
if(!HAS_TRAIT(src, trait))
continue
var/datum/atom_hud/datahud = GLOB.huds[GLOB.trait_to_hud[trait]]
datahud.hide_from(src)
/mob/proc/hud_trait_blocker_lost(datum/source, new_trait)
SIGNAL_HANDLER
for(var/trait in GLOB.trait_blockers_to_hud[new_trait])
if(!HAS_TRAIT(src, trait))
continue
var/datum/atom_hud/datahud = GLOB.huds[GLOB.trait_to_hud[trait]]
datahud.show_to(src)