Files
Bubberstation/code/datums/hud.dm
SkyratBot 2e0e84a6dd [MIRROR] Antag HUDs will now animate if you have multiple antagonists, and will no longer clear on deconversion [MDB IGNORE] (#9397)
* Antag HUDs will now animate if you have multiple antagonists, and will no longer clear on deconversion (#62718)

About The Pull Request

This is for the admin combo HUD. Players shouldn't notice any difference (except at roundend).
2021-11-09T16-27-26.mp4

Removes the ability to set custom antag HUDs for custom admin teams for complexity, though if there's a large enough demand I can try to bring it back in another PR.

Fixes #59767

TM candidate only so that I can make sure antags aren't getting leaked to people who shouldn't see them.
Changelog

cl
fix: Antag HUDs will no longer clear on deconversion if the player was another antag.
qol: Antag HUDs (as seen by admins and at the round end) will now animate between all antagonists, rather than just choosing the most latest.
/cl

* Antag HUDs will now animate if you have multiple antagonists, and will no longer clear on deconversion

* Update sol_fed.dm

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
Co-authored-by: Gandalf <jzo123@hotmail.com>
2021-11-14 23:27:01 +00:00

139 lines
4.2 KiB
Plaintext

/* HUD DATUMS */
GLOBAL_LIST_EMPTY(all_huds)
//GLOBAL HUD LIST
GLOBAL_LIST_INIT(huds, list(
DATA_HUD_SECURITY_BASIC = new/datum/atom_hud/data/human/security/basic(),
DATA_HUD_SECURITY_ADVANCED = new/datum/atom_hud/data/human/security/advanced(),
DATA_HUD_MEDICAL_BASIC = new/datum/atom_hud/data/human/medical/basic(),
DATA_HUD_MEDICAL_ADVANCED = new/datum/atom_hud/data/human/medical/advanced(),
DATA_HUD_DIAGNOSTIC_BASIC = new/datum/atom_hud/data/diagnostic/basic(),
DATA_HUD_DIAGNOSTIC_ADVANCED = new/datum/atom_hud/data/diagnostic/advanced(),
DATA_HUD_ABDUCTOR = new/datum/atom_hud/abductor(),
DATA_HUD_SENTIENT_DISEASE = new/datum/atom_hud/sentient_disease(),
DATA_HUD_AI_DETECT = new/datum/atom_hud/ai_detector(),
DATA_HUD_FAN = new/datum/atom_hud/data/human/fan_hud(),
))
/datum/atom_hud
var/list/atom/hudatoms = list() //list of all atoms which display this hud
var/list/hudusers = list() //list with all mobs who can see the hud
var/list/hud_icons = list() //these will be the indexes for the atom's hud_list
var/list/next_time_allowed = list() //mobs associated with the next time this hud can be added to them
var/list/queued_to_see = list() //mobs that have triggered the cooldown and are queued to see the hud, but do not yet
var/hud_exceptions = list() // huduser = list(ofatomswiththeirhudhidden) - aka everyone hates targeted invisiblity
/datum/atom_hud/New()
GLOB.all_huds += src
/datum/atom_hud/Destroy()
for(var/v in hudusers)
remove_hud_from(v)
for(var/v in hudatoms)
remove_from_hud(v)
GLOB.all_huds -= src
return ..()
/datum/atom_hud/proc/remove_hud_from(mob/M, absolute = FALSE)
if(!M || !hudusers[M])
return
if (absolute || !--hudusers[M])
UnregisterSignal(M, COMSIG_PARENT_QDELETING)
hudusers -= M
if(next_time_allowed[M])
next_time_allowed -= M
if(queued_to_see[M])
queued_to_see -= M
else
for(var/atom/A in hudatoms)
remove_from_single_hud(M, A)
/datum/atom_hud/proc/remove_from_hud(atom/A)
if(!A)
return FALSE
for(var/mob/M in hudusers)
remove_from_single_hud(M, A)
hudatoms -= A
return TRUE
/datum/atom_hud/proc/remove_from_single_hud(mob/M, atom/A) //unsafe, no sanity apart from client
if(!M || !M.client || !A)
return
for(var/i in hud_icons)
M.client.images -= A.hud_list[i]
/datum/atom_hud/proc/add_hud_to(mob/M)
if(!M)
return
if(!hudusers[M])
hudusers[M] = 1
RegisterSignal(M, COMSIG_PARENT_QDELETING, .proc/unregister_mob)
if(next_time_allowed[M] > world.time)
if(!queued_to_see[M])
addtimer(CALLBACK(src, .proc/show_hud_images_after_cooldown, M), next_time_allowed[M] - world.time)
queued_to_see[M] = TRUE
else
next_time_allowed[M] = world.time + ADD_HUD_TO_COOLDOWN
for(var/atom/A in hudatoms)
add_to_single_hud(M, A)
else
hudusers[M]++
/datum/atom_hud/proc/unregister_mob(datum/source, force)
SIGNAL_HANDLER
remove_hud_from(source, TRUE)
/datum/atom_hud/proc/hide_single_atomhud_from(hud_user,hidden_atom)
if(hudusers[hud_user])
remove_from_single_hud(hud_user,hidden_atom)
if(!hud_exceptions[hud_user])
hud_exceptions[hud_user] = list(hidden_atom)
else
hud_exceptions[hud_user] += hidden_atom
/datum/atom_hud/proc/unhide_single_atomhud_from(hud_user,hidden_atom)
hud_exceptions[hud_user] -= hidden_atom
if(hudusers[hud_user])
add_to_single_hud(hud_user,hidden_atom)
/datum/atom_hud/proc/show_hud_images_after_cooldown(M)
if(queued_to_see[M])
queued_to_see -= M
next_time_allowed[M] = world.time + ADD_HUD_TO_COOLDOWN
for(var/atom/A in hudatoms)
add_to_single_hud(M, A)
/datum/atom_hud/proc/add_to_hud(atom/A)
if(!A)
return FALSE
hudatoms |= A
for(var/mob/M in hudusers)
if(!queued_to_see[M])
add_to_single_hud(M, A)
return TRUE
/datum/atom_hud/proc/add_to_single_hud(mob/M, atom/A) //unsafe, no sanity apart from client
if(!M || !M.client || !A)
return
for(var/i in hud_icons)
if(A.hud_list[i] && (!hud_exceptions[M] || !(A in hud_exceptions[M])))
M.client.images |= A.hud_list[i]
//MOB PROCS
/mob/proc/reload_huds()
for(var/datum/atom_hud/hud in GLOB.all_huds)
if(hud?.hudusers[src])
for(var/atom/A in hud.hudatoms)
hud.add_to_single_hud(src, A)
/mob/dead/new_player/reload_huds()
return
/mob/proc/add_click_catcher()
client.screen += client.void
/mob/dead/new_player/add_click_catcher()
return