From dfb12f91d67b767bb8563b40f2b69985d45373e8 Mon Sep 17 00:00:00 2001 From: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Date: Fri, 19 Jul 2024 00:24:07 +0100 Subject: [PATCH] HUD traits now apply their corresponding hud automatically. Most clothing/item/etc sources of HUDs now only use traits (#84984) ## About The Pull Request Currently if you want to apply a HUD you usually add both its trait and the HUD itself. Only exceptions are things like simplemobs where you should avoid adding the hud trait since it adds security/med DB access and such, but there is no cases where you'd want to apply the trait and not apply the hud. Requested by Melbert about a week ago. ![image](https://github.com/user-attachments/assets/8af3e9cc-ea22-4cee-86ec-54c397291727) ## Why It's Good For The Game This makes working with HUDs significantly easier, as you no longer have to bother with manually adding/removing them. Also potentially removes an edge case where if your hud could get removed while keeping the trait. ## Changelog :cl: refactor: HUD traits now apply their corresponding hud automatically /:cl: --- code/__DEFINES/atom_hud.dm | 4 +- code/__DEFINES/traits/declarations.dm | 1 + code/_globalvars/traits/_traits.dm | 1 + code/_globalvars/traits/admin_tooling.dm | 1 + code/datums/elements/digitalcamo.dm | 14 +++-- code/datums/hud.dm | 29 ++++++---- code/game/data_huds.dm | 10 ++-- .../game/objects/items/busts_and_figurines.dm | 4 -- code/modules/admin/verbs/admingame.dm | 4 +- .../nukeop/equipment/overwatch_tools.dm | 21 +------- code/modules/clothing/glasses/_glasses.dm | 2 +- code/modules/clothing/glasses/hud.dm | 54 ++++++------------- code/modules/clothing/suits/ablativecoat.dm | 4 -- code/modules/mob/dead/observer/observer.dm | 17 +++--- code/modules/mob/living/basic/bots/_bots.dm | 2 +- code/modules/mob/living/basic/bots/bot_hud.dm | 2 +- .../mob/living/basic/bots/vibebot/vibebot.dm | 2 +- code/modules/mob/living/silicon/ai/ai.dm | 4 +- code/modules/mob/living/silicon/silicon.dm | 22 +++----- .../mob/living/simple_animal/bot/bot.dm | 8 +-- code/modules/mob/mob.dm | 16 ++++++ code/modules/mod/modules/modules_visor.dm | 13 +---- code/modules/pai/software.dm | 4 +- .../organs/internal/cyberimp/augments_eyes.dm | 37 ++++--------- .../vehicles/mecha/medical/odysseus.dm | 8 +-- 25 files changed, 106 insertions(+), 178 deletions(-) diff --git a/code/__DEFINES/atom_hud.dm b/code/__DEFINES/atom_hud.dm index 86de96f07a1..1af3003bb85 100644 --- a/code/__DEFINES/atom_hud.dm +++ b/code/__DEFINES/atom_hud.dm @@ -58,8 +58,8 @@ #define DATA_HUD_SECURITY_ADVANCED 2 #define DATA_HUD_MEDICAL_BASIC 3 #define DATA_HUD_MEDICAL_ADVANCED 4 -#define DATA_HUD_DIAGNOSTIC_BASIC 5 -#define DATA_HUD_DIAGNOSTIC_ADVANCED 6 +#define DATA_HUD_DIAGNOSTIC 5 +#define DATA_HUD_BOT_PATH 6 #define DATA_HUD_ABDUCTOR 7 #define DATA_HUD_SENTIENT_DISEASE 8 #define DATA_HUD_AI_DETECT 9 diff --git a/code/__DEFINES/traits/declarations.dm b/code/__DEFINES/traits/declarations.dm index 6c2fc4be7a0..90e3fc38265 100644 --- a/code/__DEFINES/traits/declarations.dm +++ b/code/__DEFINES/traits/declarations.dm @@ -336,6 +336,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai #define TRAIT_SECURITY_HUD "sec_hud" /// for something granting you a diagnostic hud #define TRAIT_DIAGNOSTIC_HUD "diag_hud" +#define TRAIT_BOT_PATH_HUD "bot_path_hud" /// Is a medbot healing you #define TRAIT_MEDIBOTCOMINGTHROUGH "medbot" #define TRAIT_PASSTABLE "passtable" diff --git a/code/_globalvars/traits/_traits.dm b/code/_globalvars/traits/_traits.dm index df177e56860..a71e425d827 100644 --- a/code/_globalvars/traits/_traits.dm +++ b/code/_globalvars/traits/_traits.dm @@ -188,6 +188,7 @@ GLOBAL_LIST_INIT(traits_by_type, list( "TRAIT_DETECTIVES_TASTE" = TRAIT_DETECTIVES_TASTE, "TRAIT_DETECT_STORM" = TRAIT_DETECT_STORM, "TRAIT_DIAGNOSTIC_HUD" = TRAIT_DIAGNOSTIC_HUD, + "TRAIT_BOT_PATH_HUD" = TRAIT_BOT_PATH_HUD, "TRAIT_DISCOORDINATED_TOOL_USER" = TRAIT_DISCOORDINATED_TOOL_USER, "TRAIT_DISEASELIKE_SEVERITY_MEDIUM" = TRAIT_DISEASELIKE_SEVERITY_MEDIUM, "TRAIT_DISFIGURED" = TRAIT_DISFIGURED, diff --git a/code/_globalvars/traits/admin_tooling.dm b/code/_globalvars/traits/admin_tooling.dm index 4cb03eedba8..55a9d37b701 100644 --- a/code/_globalvars/traits/admin_tooling.dm +++ b/code/_globalvars/traits/admin_tooling.dm @@ -60,6 +60,7 @@ GLOBAL_LIST_INIT(admin_visible_traits, list( "TRAIT_DEFIB_BLACKLISTED" = TRAIT_DEFIB_BLACKLISTED, "TRAIT_DEPRESSION" = TRAIT_DEPRESSION, "TRAIT_DIAGNOSTIC_HUD" = TRAIT_DIAGNOSTIC_HUD, + "TRAIT_BOT_PATH_HUD" = TRAIT_BOT_PATH_HUD, "TRAIT_DISCOORDINATED_TOOL_USER" = TRAIT_DISCOORDINATED_TOOL_USER, "TRAIT_DISFIGURED" = TRAIT_DISFIGURED, "TRAIT_DISK_VERIFIER" = TRAIT_DISK_VERIFIER, diff --git a/code/datums/elements/digitalcamo.dm b/code/datums/elements/digitalcamo.dm index 3f4db60de2d..b8a9fa673e3 100644 --- a/code/datums/elements/digitalcamo.dm +++ b/code/datums/elements/digitalcamo.dm @@ -27,17 +27,15 @@ /datum/element/digitalcamo/proc/HideFromAIHuds(mob/living/target) for(var/mob/living/silicon/ai/AI in GLOB.ai_list) - var/datum/atom_hud/M = GLOB.huds[AI.med_hud] - M.hide_single_atomhud_from(AI,target) - var/datum/atom_hud/S = GLOB.huds[AI.sec_hud] - S.hide_single_atomhud_from(AI,target) + for (var/hud_type in AI.silicon_huds) + var/datum/atom_hud/silicon_hud = GLOB.huds[hud_type] + silicon_hud.hide_single_atomhud_from(AI,target) /datum/element/digitalcamo/proc/UnhideFromAIHuds(mob/living/target) for(var/mob/living/silicon/ai/AI in GLOB.ai_list) - var/datum/atom_hud/M = GLOB.huds[AI.med_hud] - M.unhide_single_atomhud_from(AI,target) - var/datum/atom_hud/S = GLOB.huds[AI.sec_hud] - S.unhide_single_atomhud_from(AI,target) + for (var/hud_type in AI.silicon_huds) + var/datum/atom_hud/silicon_hud = GLOB.huds[hud_type] + silicon_hud.unhide_single_atomhud_from(AI,target) /datum/element/digitalcamo/proc/on_examine(datum/source, mob/M) SIGNAL_HANDLER diff --git a/code/datums/hud.dm b/code/datums/hud.dm index c0e90994af5..f73a06c5b40 100644 --- a/code/datums/hud.dm +++ b/code/datums/hud.dm @@ -8,17 +8,24 @@ GLOBAL_LIST_EMPTY(huds_by_category) //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(), - DATA_HUD_MALF_APC = new/datum/atom_hud/data/malf_apc(), + 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 = new /datum/atom_hud/data/diagnostic(), + DATA_HUD_BOT_PATH = new /datum/atom_hud/data/bot_path(), + 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(), + DATA_HUD_MALF_APC = new /datum/atom_hud/data/malf_apc(), +)) + +GLOBAL_LIST_INIT(trait_to_hud, list( + TRAIT_SECURITY_HUD = DATA_HUD_SECURITY_ADVANCED, + TRAIT_MEDICAL_HUD = DATA_HUD_MEDICAL_ADVANCED, + TRAIT_DIAGNOSTIC_HUD = DATA_HUD_DIAGNOSTIC, + TRAIT_BOT_PATH_HUD = DATA_HUD_BOT_PATH )) /datum/atom_hud diff --git a/code/game/data_huds.dm b/code/game/data_huds.dm index 91c500fd8f1..e39ce9bd92d 100644 --- a/code/game/data_huds.dm +++ b/code/game/data_huds.dm @@ -53,18 +53,14 @@ hud_icons = list(FAN_HUD) /datum/atom_hud/data/diagnostic - -/datum/atom_hud/data/diagnostic/basic hud_icons = list(DIAG_HUD, DIAG_STAT_HUD, DIAG_BATT_HUD, DIAG_MECH_HUD, DIAG_BOT_HUD, DIAG_TRACK_HUD, DIAG_CAMERA_HUD, DIAG_AIRLOCK_HUD, DIAG_LAUNCHPAD_HUD) -/datum/atom_hud/data/diagnostic/advanced - hud_icons = list(DIAG_HUD, DIAG_STAT_HUD, DIAG_BATT_HUD, DIAG_MECH_HUD, DIAG_BOT_HUD, DIAG_TRACK_HUD, DIAG_CAMERA_HUD, DIAG_AIRLOCK_HUD, DIAG_LAUNCHPAD_HUD, DIAG_PATH_HUD) - /datum/atom_hud/data/bot_path - // This hud exists so the bot can see itself, that's all - uses_global_hud_category = FALSE hud_icons = list(DIAG_PATH_HUD) +/datum/atom_hud/data/bot_path/private + uses_global_hud_category = FALSE + /datum/atom_hud/abductor hud_icons = list(GLAND_HUD) diff --git a/code/game/objects/items/busts_and_figurines.dm b/code/game/objects/items/busts_and_figurines.dm index afc4a58334e..53af3228ffd 100644 --- a/code/game/objects/items/busts_and_figurines.dm +++ b/code/game/objects/items/busts_and_figurines.dm @@ -50,16 +50,12 @@ ..() if(!(slot & ITEM_SLOT_HANDS)) return - var/datum/atom_hud/our_hud = GLOB.huds[DATA_HUD_MEDICAL_ADVANCED] - our_hud.show_to(user) ADD_TRAIT(user, TRAIT_MEDICAL_HUD, type) /obj/item/statuebust/hippocratic/dropped(mob/living/carbon/human/user) ..() if(HAS_TRAIT_NOT_FROM(user, TRAIT_MEDICAL_HUD, type)) return - var/datum/atom_hud/our_hud = GLOB.huds[DATA_HUD_MEDICAL_ADVANCED] - our_hud.hide_from(user) REMOVE_TRAIT(user, TRAIT_MEDICAL_HUD, type) /obj/item/statuebust/hippocratic/attack_self(mob/user) diff --git a/code/modules/admin/verbs/admingame.dm b/code/modules/admin/verbs/admingame.dm index 0e1e6809daa..57311446961 100644 --- a/code/modules/admin/verbs/admingame.dm +++ b/code/modules/admin/verbs/admingame.dm @@ -361,7 +361,7 @@ ADMIN_VERB(combo_hud, R_ADMIN, "Toggle Combo HUD", "Toggles the Admin Combo HUD. combo_hud_enabled = TRUE - for (var/hudtype in list(DATA_HUD_SECURITY_ADVANCED, DATA_HUD_MEDICAL_ADVANCED, DATA_HUD_DIAGNOSTIC_ADVANCED)) + for (var/hudtype in list(DATA_HUD_SECURITY_ADVANCED, DATA_HUD_MEDICAL_ADVANCED, DATA_HUD_DIAGNOSTIC, DATA_HUD_BOT_PATH)) var/datum/atom_hud/atom_hud = GLOB.huds[hudtype] atom_hud.show_to(mob) @@ -377,7 +377,7 @@ ADMIN_VERB(combo_hud, R_ADMIN, "Toggle Combo HUD", "Toggles the Admin Combo HUD. combo_hud_enabled = FALSE - for (var/hudtype in list(DATA_HUD_SECURITY_ADVANCED, DATA_HUD_MEDICAL_ADVANCED, DATA_HUD_DIAGNOSTIC_ADVANCED)) + for (var/hudtype in list(DATA_HUD_SECURITY_ADVANCED, DATA_HUD_MEDICAL_ADVANCED, DATA_HUD_DIAGNOSTIC, DATA_HUD_BOT_PATH)) var/datum/atom_hud/atom_hud = GLOB.huds[hudtype] atom_hud.hide_from(mob) diff --git a/code/modules/antagonists/nukeop/equipment/overwatch_tools.dm b/code/modules/antagonists/nukeop/equipment/overwatch_tools.dm index 6c409f06370..94c16d86dbe 100644 --- a/code/modules/antagonists/nukeop/equipment/overwatch_tools.dm +++ b/code/modules/antagonists/nukeop/equipment/overwatch_tools.dm @@ -42,23 +42,4 @@ Happy hunting! icon_state = "sunhudmed" flags_cover = GLASSESCOVERSEYES flash_protect = FLASH_PROTECTION_WELDER - clothing_traits = list(TRAIT_REAGENT_SCANNER) - var/list/hudlist = list(DATA_HUD_MEDICAL_ADVANCED, DATA_HUD_DIAGNOSTIC_ADVANCED, DATA_HUD_SECURITY_ADVANCED) - -/obj/item/clothing/glasses/overwatch/equipped(mob/user, slot) - . = ..() - if(!(slot & ITEM_SLOT_EYES) || !ishuman(user)) - return - for(var/hud in hudlist) - var/datum/atom_hud/our_hud = GLOB.huds[hud] - our_hud.show_to(user) - user.add_traits(list(TRAIT_MEDICAL_HUD, TRAIT_SECURITY_HUD, TRAIT_DIAGNOSTIC_HUD), GLASSES_TRAIT) - -/obj/item/clothing/glasses/overwatch/dropped(mob/user) - . = ..() - user.remove_traits(list(TRAIT_MEDICAL_HUD, TRAIT_SECURITY_HUD, TRAIT_DIAGNOSTIC_HUD), GLASSES_TRAIT) - if(!ishuman(user)) - return - for(var/hud in hudlist) - var/datum/atom_hud/our_hud = GLOB.huds[hud] - our_hud.hide_from(user) + clothing_traits = list(TRAIT_REAGENT_SCANNER, TRAIT_SECURITY_HUD, TRAIT_MEDICAL_HUD, TRAIT_DIAGNOSTIC_HUD) diff --git a/code/modules/clothing/glasses/_glasses.dm b/code/modules/clothing/glasses/_glasses.dm index e2632dd394e..4ed35997680 100644 --- a/code/modules/clothing/glasses/_glasses.dm +++ b/code/modules/clothing/glasses/_glasses.dm @@ -611,7 +611,7 @@ glass_colour_type = FALSE vision_flags = SEE_TURFS clothing_traits = list(TRAIT_REAGENT_SCANNER, TRAIT_MADNESS_IMMUNE) - var/list/hudlist = list(DATA_HUD_MEDICAL_ADVANCED, DATA_HUD_DIAGNOSTIC_ADVANCED, DATA_HUD_SECURITY_ADVANCED) + var/list/hudlist = list(DATA_HUD_MEDICAL_ADVANCED, DATA_HUD_DIAGNOSTIC, DATA_HUD_SECURITY_ADVANCED, DATA_HUD_BOT_PATH) var/xray = FALSE /obj/item/clothing/glasses/debug/equipped(mob/user, slot) diff --git a/code/modules/clothing/glasses/hud.dm b/code/modules/clothing/glasses/hud.dm index f82f56a48fb..dc35ab1dbf4 100644 --- a/code/modules/clothing/glasses/hud.dm +++ b/code/modules/clothing/glasses/hud.dm @@ -2,26 +2,6 @@ name = "HUD" desc = "A heads-up display that provides important info in (almost) real time." flags_1 = null //doesn't protect eyes because it's a monocle, duh - ///A list of atom hud types added to the mob when the glasses are worn on the appropriate slot. - var/list/hud_types - - // NOTE: Just because you have a HUD display doesn't mean you should be able to interact with stuff on examine, that's where the associated trait (TRAIT_MEDICAL_HUD, TRAIT_SECURITY_HUD, etc) is necessary. - -/obj/item/clothing/glasses/hud/equipped(mob/living/carbon/human/user, slot) - ..() - if(!(slot & ITEM_SLOT_EYES)) - return - for(var/hud_type in hud_types) - var/datum/atom_hud/our_hud = GLOB.huds[hud_type] - our_hud.show_to(user) - -/obj/item/clothing/glasses/hud/dropped(mob/living/carbon/human/user) - ..() - if(!istype(user) || user.glasses != src) - return - for(var/hud_type in hud_types) - var/datum/atom_hud/our_hud = GLOB.huds[hud_type] - our_hud.hide_from(user) /obj/item/clothing/glasses/hud/emp_act(severity) . = ..() @@ -56,7 +36,6 @@ name = "health scanner HUD" desc = "A heads-up display that scans the humanoids in view and provides accurate data about their health status." icon_state = "healthhud" - hud_types = list(DATA_HUD_MEDICAL_ADVANCED) clothing_traits = list(TRAIT_MEDICAL_HUD) glass_colour_type = /datum/client_colour/glass_colour/lightblue @@ -64,7 +43,6 @@ name = "health scanner security HUD" desc = "A heads-up display that scans the humanoids in view and provides accurate data about their health status, ID status and security records." icon_state = "medsechud" - hud_types = list(DATA_HUD_MEDICAL_ADVANCED, DATA_HUD_SECURITY_ADVANCED) clothing_traits = list(TRAIT_MEDICAL_HUD, TRAIT_SECURITY_HUD) /obj/item/clothing/glasses/hud/health/night @@ -118,7 +96,6 @@ name = "diagnostic HUD" desc = "A heads-up display capable of analyzing the integrity and status of robotics and exosuits." icon_state = "diagnostichud" - hud_types = list(DATA_HUD_DIAGNOSTIC_BASIC) clothing_traits = list(TRAIT_DIAGNOSTIC_HUD) glass_colour_type = /datum/client_colour/glass_colour/lightorange @@ -161,7 +138,6 @@ name = "security HUD" desc = "A heads-up display that scans the humanoids in view and provides accurate data about their ID status and security records." icon_state = "securityhud" - hud_types = list(DATA_HUD_SECURITY_ADVANCED) clothing_traits = list(TRAIT_SECURITY_HUD) glass_colour_type = /datum/client_colour/glass_colour/red @@ -251,20 +227,18 @@ if (wearer.glasses != src) return - for(var/hud_type in hud_types) - var/datum/atom_hud/our_hud = GLOB.huds[hud_type] - our_hud.hide_from(user) + for(var/trait in clothing_traits) + REMOVE_CLOTHING_TRAIT(user, trait) - if (DATA_HUD_MEDICAL_ADVANCED in hud_types) - hud_types = null - else if (DATA_HUD_SECURITY_ADVANCED in hud_types) - hud_types = list(DATA_HUD_MEDICAL_ADVANCED) + if (TRAIT_MEDICAL_HUD in clothing_traits) + clothing_traits = null + else if (TRAIT_SECURITY_HUD in clothing_traits) + clothing_traits = list(TRAIT_MEDICAL_HUD) else - hud_types = list(DATA_HUD_SECURITY_ADVANCED) + clothing_traits = list(TRAIT_SECURITY_HUD) - for(var/hud_type in hud_types) - var/datum/atom_hud/our_hud = GLOB.huds[hud_type] - our_hud.show_to(user) + for(var/trait in clothing_traits) + ADD_CLOTHING_TRAIT(user, trait) /datum/action/item_action/switch_hud name = "Switch HUD" @@ -273,20 +247,22 @@ name = "thermal HUD scanner" desc = "Thermal imaging HUD in the shape of glasses." icon_state = "thermal" - hud_types = list(DATA_HUD_SECURITY_ADVANCED) vision_flags = SEE_MOBS color_cutoffs = list(25, 8, 5) glass_colour_type = /datum/client_colour/glass_colour/red + clothing_traits = list(TRAIT_SECURITY_HUD) /obj/item/clothing/glasses/hud/toggle/thermal/attack_self(mob/user) ..() - var/hud_type = hud_types[1] + var/hud_type + if (!isnull(clothing_traits) && clothing_traits.len) + hud_type = clothing_traits[1] switch (hud_type) - if (DATA_HUD_MEDICAL_ADVANCED) + if (TRAIT_MEDICAL_HUD) icon_state = "meson" color_cutoffs = list(5, 15, 5) change_glass_color(/datum/client_colour/glass_colour/green) - if (DATA_HUD_SECURITY_ADVANCED) + if (TRAIT_SECURITY_HUD) icon_state = "thermal" color_cutoffs = list(25, 8, 5) change_glass_color(/datum/client_colour/glass_colour/red) diff --git a/code/modules/clothing/suits/ablativecoat.dm b/code/modules/clothing/suits/ablativecoat.dm index 8bc37aaba22..32233f23400 100644 --- a/code/modules/clothing/suits/ablativecoat.dm +++ b/code/modules/clothing/suits/ablativecoat.dm @@ -50,15 +50,11 @@ /obj/item/clothing/suit/hooded/ablative/on_hood_up(obj/item/clothing/head/hooded/hood) . = ..() var/mob/living/carbon/user = loc - var/datum/atom_hud/hud = GLOB.huds[DATA_HUD_SECURITY_ADVANCED] ADD_TRAIT(user, TRAIT_SECURITY_HUD, HELMET_TRAIT) - hud.show_to(user) balloon_alert(user, "hud enabled") /obj/item/clothing/suit/hooded/ablative/on_hood_down(obj/item/clothing/head/hooded/hood) var/mob/living/carbon/user = loc - var/datum/atom_hud/sec_hud = GLOB.huds[DATA_HUD_SECURITY_ADVANCED] REMOVE_TRAIT(user, TRAIT_SECURITY_HUD, HELMET_TRAIT) - sec_hud.hide_from(user) balloon_alert(user, "hud disabled") return ..() diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index 070189a1ff3..a3fa4c47386 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -36,7 +36,6 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER) var/health_scan = FALSE //Are health scans currently enabled? var/chem_scan = FALSE //Are chem scans currently enabled? var/gas_scan = FALSE //Are gas scans currently enabled? - var/list/datahuds = list(DATA_HUD_SECURITY_ADVANCED, DATA_HUD_MEDICAL_ADVANCED, DATA_HUD_DIAGNOSTIC_ADVANCED) //list of data HUDs shown to ghosts. var/ghost_orbit = GHOST_ORBIT_CIRCLE //These variables store hair data if the ghost originates from a species with head and/or facial hair. @@ -63,6 +62,13 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER) /// The POI we're orbiting (orbit menu) var/orbiting_ref + var/static/list/observer_hud_traits = list( + TRAIT_SECURITY_HUD, + TRAIT_MEDICAL_HUD, + TRAIT_DIAGNOSTIC_HUD, + TRAIT_BOT_PATH_HUD + ) + /mob/dead/observer/Initialize(mapload) set_invisibility(GLOB.observer_default_invisibility) @@ -149,7 +155,6 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER) SSpoints_of_interest.make_point_of_interest(src) ADD_TRAIT(src, TRAIT_HEAR_THROUGH_DARKNESS, ref(src)) - ADD_TRAIT(src, TRAIT_SECURITY_HUD, ref(src)) /mob/dead/observer/get_photo_description(obj/item/camera/camera) if(!invisibility || camera.see_ghosts) @@ -760,14 +765,10 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp return /mob/dead/observer/proc/show_data_huds() - for(var/hudtype in datahuds) - var/datum/atom_hud/data_hud = GLOB.huds[hudtype] - data_hud.show_to(src) + add_traits(observer_hud_traits, REF(src)) /mob/dead/observer/proc/remove_data_huds() - for(var/hudtype in datahuds) - var/datum/atom_hud/data_hud = GLOB.huds[hudtype] - data_hud.hide_from(src) + remove_traits(observer_hud_traits, REF(src)) /mob/dead/observer/verb/toggle_data_huds() set name = "Toggle Sec/Med/Diag HUD" diff --git a/code/modules/mob/living/basic/bots/_bots.dm b/code/modules/mob/living/basic/bots/_bots.dm index aad840aa185..9f2b915944b 100644 --- a/code/modules/mob/living/basic/bots/_bots.dm +++ b/code/modules/mob/living/basic/bots/_bots.dm @@ -88,7 +88,7 @@ GLOBAL_LIST_INIT(command_strings, list( var/list/current_pathed_turfs = list() ///The type of data HUD the bot uses. Diagnostic by default. - var/data_hud_type = DATA_HUD_DIAGNOSTIC_BASIC + var/data_hud_type = DATA_HUD_DIAGNOSTIC /// If true we will allow ghosts to control this mob var/can_be_possessed = FALSE /// Message to display upon possession diff --git a/code/modules/mob/living/basic/bots/bot_hud.dm b/code/modules/mob/living/basic/bots/bot_hud.dm index cbadab01360..61aee9f10b1 100644 --- a/code/modules/mob/living/basic/bots/bot_hud.dm +++ b/code/modules/mob/living/basic/bots/bot_hud.dm @@ -52,7 +52,7 @@ var/list/path_images = active_hud_list[DIAG_PATH_HUD] LAZYCLEARLIST(path_images) - var/list/path_huds_watching_me = list(GLOB.huds[DATA_HUD_DIAGNOSTIC_ADVANCED]) + var/list/path_huds_watching_me = list(GLOB.huds[DATA_HUD_DIAGNOSTIC], GLOB.huds[DATA_HUD_BOT_PATH]) var/atom/move_target = ai_controller.current_movement_target if(move_target != ai_controller.blackboard[BB_BEACON_TARGET]) diff --git a/code/modules/mob/living/basic/bots/vibebot/vibebot.dm b/code/modules/mob/living/basic/bots/vibebot/vibebot.dm index c872e1ea595..c8e2d713623 100644 --- a/code/modules/mob/living/basic/bots/vibebot/vibebot.dm +++ b/code/modules/mob/living/basic/bots/vibebot/vibebot.dm @@ -14,7 +14,7 @@ radio_key = /obj/item/encryptionkey/headset_service radio_channel = RADIO_CHANNEL_SERVICE bot_type = VIBE_BOT - data_hud_type = DATA_HUD_DIAGNOSTIC_BASIC + data_hud_type = DATA_HUD_DIAGNOSTIC path_image_color = "#2cac12" possessed_message = "You are a vibebot! Maintain the station's vibes to the best of your ability!" diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index 6c4be898162..7e0cd4e5ef3 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -11,9 +11,7 @@ combat_mode = TRUE //so we always get pushed instead of trying to swap sight = SEE_TURFS | SEE_MOBS | SEE_OBJS hud_type = /datum/hud/ai - med_hud = DATA_HUD_MEDICAL_BASIC - sec_hud = DATA_HUD_SECURITY_BASIC - d_hud = DATA_HUD_DIAGNOSTIC_ADVANCED + silicon_huds = list(DATA_HUD_MEDICAL_BASIC, DATA_HUD_SECURITY_BASIC, DATA_HUD_DIAGNOSTIC, DATA_HUD_BOT_PATH) mob_size = MOB_SIZE_LARGE radio = /obj/item/radio/headset/silicon/ai can_buckle_to = FALSE diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index 6916c01f4d3..e41cd215708 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -38,9 +38,7 @@ ///Are our siliconHUDs on? TRUE for yes, FALSE for no. var/sensors_on = TRUE - var/med_hud = DATA_HUD_MEDICAL_ADVANCED //Determines the med hud to use - var/sec_hud = DATA_HUD_SECURITY_ADVANCED //Determines the sec hud to use - var/d_hud = DATA_HUD_DIAGNOSTIC_BASIC //Determines the diag hud to use + var/list/silicon_huds = list(DATA_HUD_MEDICAL_ADVANCED, DATA_HUD_SECURITY_ADVANCED, DATA_HUD_DIAGNOSTIC) var/law_change_counter = 0 var/obj/machinery/camera/builtInCamera = null @@ -392,20 +390,14 @@ return -10 /mob/living/silicon/proc/remove_sensors() - var/datum/atom_hud/secsensor = GLOB.huds[sec_hud] - var/datum/atom_hud/medsensor = GLOB.huds[med_hud] - var/datum/atom_hud/diagsensor = GLOB.huds[d_hud] - secsensor.hide_from(src) - medsensor.hide_from(src) - diagsensor.hide_from(src) + for (var/hud_type in silicon_huds) + var/datum/atom_hud/silicon_hud = GLOB.huds[hud_type] + silicon_hud.hide_from(src) /mob/living/silicon/proc/add_sensors() - var/datum/atom_hud/secsensor = GLOB.huds[sec_hud] - var/datum/atom_hud/medsensor = GLOB.huds[med_hud] - var/datum/atom_hud/diagsensor = GLOB.huds[d_hud] - secsensor.show_to(src) - medsensor.show_to(src) - diagsensor.show_to(src) + for (var/hud_type in silicon_huds) + var/datum/atom_hud/silicon_hud = GLOB.huds[hud_type] + silicon_hud.show_to(src) /mob/living/silicon/proc/toggle_sensors() if(incapacitated()) diff --git a/code/modules/mob/living/simple_animal/bot/bot.dm b/code/modules/mob/living/simple_animal/bot/bot.dm index 50b30b09aa8..c483d371e1a 100644 --- a/code/modules/mob/living/simple_animal/bot/bot.dm +++ b/code/modules/mob/living/simple_animal/bot/bot.dm @@ -95,8 +95,8 @@ var/turf/nearest_beacon_loc ///The type of data HUD the bot uses. Diagnostic by default. - var/data_hud_type = DATA_HUD_DIAGNOSTIC_BASIC - var/datum/atom_hud/data/bot_path/path_hud + var/data_hud_type = DATA_HUD_DIAGNOSTIC + var/datum/atom_hud/data/bot_path/private/path_hud var/path_image_icon = 'icons/mob/silicon/aibots.dmi' var/path_image_icon_state = "path_indicator" var/path_image_color = COLOR_WHITE @@ -165,7 +165,7 @@ . = ..() GLOB.bots_list += src - path_hud = new /datum/atom_hud/data/bot_path() + path_hud = new /datum/atom_hud/data/bot_path/private() for(var/hud in path_hud.hud_icons) // You get to see your own path set_hud_image_active(hud, exclusive_hud = path_hud) @@ -1148,7 +1148,7 @@ Pass a positive integer as an argument to override a bot's default speed. path = newpath ? newpath : list() if(!path_hud) return - var/list/path_huds_watching_me = list(GLOB.huds[DATA_HUD_DIAGNOSTIC_ADVANCED]) + var/list/path_huds_watching_me = list(GLOB.huds[DATA_HUD_DIAGNOSTIC], GLOB.huds[DATA_HUD_BOT_PATH]) if(path_hud) path_huds_watching_me += path_hud for(var/datum/atom_hud/hud as anything in path_huds_watching_me) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index dd651085d91..c90c81b6ce4 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -92,6 +92,7 @@ AA.onNewMob(src) set_nutrition(rand(NUTRITION_LEVEL_START_MIN, NUTRITION_LEVEL_START_MAX)) . = ..() + setup_hud_traits() update_config_movespeed() initialize_actionspeed() update_movespeed(TRUE) @@ -1598,3 +1599,18 @@ /mob/key_down(key, client/client, full_key) ..() SEND_SIGNAL(src, COMSIG_MOB_KEYDOWN, key, client, full_key) + +/mob/proc/setup_hud_traits() + 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)) + +/mob/proc/hud_trait_enabled(datum/source, new_trait) + SIGNAL_HANDLER + 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) + SIGNAL_HANDLER + var/datum/atom_hud/datahud = GLOB.huds[GLOB.trait_to_hud[new_trait]] + datahud.hide_from(src) diff --git a/code/modules/mod/modules/modules_visor.dm b/code/modules/mod/modules/modules_visor.dm index 4527fa631a6..6a1d61ea7ef 100644 --- a/code/modules/mod/modules/modules_visor.dm +++ b/code/modules/mod/modules/modules_visor.dm @@ -10,23 +10,15 @@ incompatible_modules = list(/obj/item/mod/module/visor) cooldown_time = 0.5 SECONDS required_slots = list(ITEM_SLOT_HEAD|ITEM_SLOT_EYES|ITEM_SLOT_MASK) - /// The HUD type given by the visor. - var/hud_type /// The traits given by the visor. var/list/visor_traits = list() /obj/item/mod/module/visor/on_activation() - if(hud_type) - var/datum/atom_hud/hud = GLOB.huds[hud_type] - hud.show_to(mod.wearer) if(length(visor_traits)) mod.wearer.add_traits(visor_traits, MOD_TRAIT) mod.wearer.update_sight() /obj/item/mod/module/visor/on_deactivation(display_message = TRUE, deleting = FALSE) - if(hud_type) - var/datum/atom_hud/hud = GLOB.huds[hud_type] - hud.hide_from(mod.wearer) if(length(visor_traits)) mod.wearer.remove_traits(visor_traits, MOD_TRAIT) mod.wearer.update_sight() @@ -38,7 +30,6 @@ biological scanning suite, allowing the user to visualize the current health of organic lifeforms, as well as \ access data such as patient files in a convenient readout. They say these also let you see behind you." icon_state = "medhud_visor" - hud_type = DATA_HUD_MEDICAL_ADVANCED visor_traits = list(TRAIT_MEDICAL_HUD) //Diagnostic Visor - Gives you a diagnostic HUD. @@ -48,8 +39,7 @@ from advanced machinery, exosuits, and other devices, allowing the user to visualize current power levels \ and integrity of such. They say these also let you see behind you." icon_state = "diaghud_visor" - hud_type = DATA_HUD_DIAGNOSTIC_ADVANCED - visor_traits = list(TRAIT_DIAGNOSTIC_HUD) + visor_traits = list(TRAIT_DIAGNOSTIC_HUD, TRAIT_BOT_PATH_HUD) //Security Visor - Gives you a security HUD. /obj/item/mod/module/visor/sechud @@ -58,7 +48,6 @@ plugged into various criminal databases to be able to view arrest records, command simple security-oriented robots, \ and generally know who to shoot. They say these also let you see behind you." icon_state = "sechud_visor" - hud_type = DATA_HUD_SECURITY_ADVANCED visor_traits = list(TRAIT_SECURITY_HUD) //Meson Visor - Gives you meson vision. diff --git a/code/modules/pai/software.dm b/code/modules/pai/software.dm index ab69e69388c..59db3716107 100644 --- a/code/modules/pai/software.dm +++ b/code/modules/pai/software.dm @@ -230,11 +230,11 @@ var/datum/atom_hud/hud var/hud_on if(mode == PAI_TOGGLE_MEDICAL_HUD) - hud = GLOB.huds[med_hud] + hud = GLOB.huds[DATA_HUD_MEDICAL_ADVANCED] medHUD = !medHUD hud_on = medHUD if(mode == PAI_TOGGLE_SECURITY_HUD) - hud = GLOB.huds[sec_hud] + hud = GLOB.huds[DATA_HUD_SECURITY_ADVANCED] secHUD = !secHUD hud_on = secHUD if(hud_on) diff --git a/code/modules/surgery/organs/internal/cyberimp/augments_eyes.dm b/code/modules/surgery/organs/internal/cyberimp/augments_eyes.dm index cd9de70c4e2..401e951a853 100644 --- a/code/modules/surgery/organs/internal/cyberimp/augments_eyes.dm +++ b/code/modules/surgery/organs/internal/cyberimp/augments_eyes.dm @@ -13,62 +13,47 @@ desc = "These cybernetic eyes will display a HUD over everything you see. Maybe." slot = ORGAN_SLOT_HUD actions_types = list(/datum/action/item_action/toggle_hud) - var/HUD_type = 0 - var/HUD_trait = null + var/HUD_traits = list() /// Whether the HUD implant is on or off var/toggled_on = TRUE /obj/item/organ/internal/cyberimp/eyes/hud/proc/toggle_hud(mob/living/carbon/eye_owner) if(toggled_on) - if(HUD_type) - var/datum/atom_hud/hud = GLOB.huds[HUD_type] - hud.hide_from(eye_owner) toggled_on = FALSE + eye_owner.add_traits(HUD_traits, ORGAN_TRAIT) balloon_alert(eye_owner, "hud disabled") - else - if(HUD_type) - var/datum/atom_hud/hud = GLOB.huds[HUD_type] - hud.show_to(eye_owner) - toggled_on = TRUE - balloon_alert(eye_owner, "hud enabled") + return + toggled_on = TRUE + eye_owner.remove_traits(HUD_traits, ORGAN_TRAIT) + balloon_alert(eye_owner, "hud enabled") /obj/item/organ/internal/cyberimp/eyes/hud/Insert(mob/living/carbon/eye_owner, special = FALSE, movement_flags) . = ..() if(!.) return - if(HUD_type) - var/datum/atom_hud/hud = GLOB.huds[HUD_type] - hud.show_to(eye_owner) - if(HUD_trait) - ADD_TRAIT(eye_owner, HUD_trait, ORGAN_TRAIT) + eye_owner.add_traits(HUD_traits, ORGAN_TRAIT) toggled_on = TRUE /obj/item/organ/internal/cyberimp/eyes/hud/Remove(mob/living/carbon/eye_owner, special, movement_flags) . = ..() - if(HUD_type) - var/datum/atom_hud/hud = GLOB.huds[HUD_type] - hud.hide_from(eye_owner) - if(HUD_trait) - REMOVE_TRAIT(eye_owner, HUD_trait, ORGAN_TRAIT) + eye_owner.remove_traits(HUD_traits, ORGAN_TRAIT) toggled_on = FALSE /obj/item/organ/internal/cyberimp/eyes/hud/medical name = "Medical HUD implant" desc = "These cybernetic eye implants will display a medical HUD over everything you see." - HUD_type = DATA_HUD_MEDICAL_ADVANCED - HUD_trait = TRAIT_MEDICAL_HUD + HUD_traits = list(TRAIT_MEDICAL_HUD) /obj/item/organ/internal/cyberimp/eyes/hud/security name = "Security HUD implant" desc = "These cybernetic eye implants will display a security HUD over everything you see." - HUD_type = DATA_HUD_SECURITY_ADVANCED - HUD_trait = TRAIT_SECURITY_HUD + HUD_traits = list(TRAIT_SECURITY_HUD) /obj/item/organ/internal/cyberimp/eyes/hud/diagnostic name = "Diagnostic HUD implant" desc = "These cybernetic eye implants will display a diagnostic HUD over everything you see." - HUD_type = DATA_HUD_DIAGNOSTIC_ADVANCED + HUD_traits = list(TRAIT_DIAGNOSTIC_HUD, TRAIT_BOT_PATH_HUD) /obj/item/organ/internal/cyberimp/eyes/hud/security/syndicate name = "Contraband Security HUD Implant" diff --git a/code/modules/vehicles/mecha/medical/odysseus.dm b/code/modules/vehicles/mecha/medical/odysseus.dm index 90a46f54f58..162858bc310 100644 --- a/code/modules/vehicles/mecha/medical/odysseus.dm +++ b/code/modules/vehicles/mecha/medical/odysseus.dm @@ -15,20 +15,14 @@ /obj/vehicle/sealed/mecha/odysseus/moved_inside(mob/living/carbon/human/H) . = ..() if(. && !HAS_TRAIT(H, TRAIT_MEDICAL_HUD)) - var/datum/atom_hud/hud = GLOB.huds[DATA_HUD_MEDICAL_ADVANCED] - hud.show_to(H) ADD_TRAIT(H, TRAIT_MEDICAL_HUD, VEHICLE_TRAIT) /obj/vehicle/sealed/mecha/odysseus/remove_occupant(mob/living/carbon/human/H) if(isliving(H) && HAS_TRAIT_FROM(H, TRAIT_MEDICAL_HUD, VEHICLE_TRAIT)) - var/datum/atom_hud/med_hud = GLOB.huds[DATA_HUD_MEDICAL_ADVANCED] - med_hud.hide_from(H) REMOVE_TRAIT(H, TRAIT_MEDICAL_HUD, VEHICLE_TRAIT) return ..() /obj/vehicle/sealed/mecha/odysseus/mmi_moved_inside(obj/item/mmi/M, mob/user) . = ..() if(. && !HAS_TRAIT(M, TRAIT_MEDICAL_HUD)) - var/datum/atom_hud/hud = GLOB.huds[DATA_HUD_MEDICAL_ADVANCED] - var/mob/living/brain/B = M.brainmob - hud.show_to(B) + ADD_TRAIT(M, TRAIT_MEDICAL_HUD, VEHICLE_TRAIT)