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
🆑
refactor: HUD traits now apply their corresponding hud automatically
/🆑
This commit is contained in:
SmArtKar
2024-07-19 01:24:07 +02:00
committed by GitHub
parent 1feedc68ab
commit dfb12f91d6
25 changed files with 106 additions and 178 deletions
+1 -12
View File
@@ -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.