mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 05:00:55 +01:00
Hud Image Culling By Z Level: Theft edition (#65189)
* makes hud images only apply by z level * makes some of the atom_hud procs have better names * fixes warning with the hud_user list and adds better documentation * better docs for hud_images * removes TODOs * docs for hud_list * adds support for linked z levels so mobs can see lower ones * fixes merge conflict and shittily makes only shocked airlocks get added * adds support for setting images in the hud as active and inactive * gets rid of unatomic spatial grid change * maybe i should actually try COMPILING my changes * fixes merge skew and makes it compile again * fixes huds refusing to remove from users who changed z level * improves z level and registration logic * fixes antag huds not appearing * Fixes antag huds not properly setting. We now use hud_list in init, so it needs to be set before the new call, not after. Not sure why the use of appearance key was split like this, but none else knows either so none can stop me * Ensures that hiding a basic appearance also hides the atom's active list too * Fixes antag huds going poof Ensures that remove_atom_from_hud will return false if the passed atom isn't managed by it This fixes antag huds disappearing randomly, since they assumed that if the parent call of remove_atom_from_hud returned true, we should delete ourselves. This is a safe assumption for them to make, since they should only ever have one atom. Does kinda bork if we call remove_atom_from_hud in a way that is unsure if the passed atom is actually in that list. We were forced into doing this by how atom huds use the qdeleting signal. * makes basic alternate_appearance's only update themselves when setting their hud image to active and makes them not add themselves to the global huds_by_category list * fixes mistake with hud_users list being set non associatively (bad) * as anything in bot path loops * Fixes merge skew problems * Makes bot paths non global This way they can show themselves to only the bot that "owns" them, ya feel me? * Fixes huds not showing up sometimes, cleans up some code Post Kapu's limb refactor, we were calling prepare_huds twice in a human init call chain. What was happening was this: call prepare_huds() // Human I gained a new hud image I set active hud icons to mirror it call prepare_huds() // Living I overwrote the new hud image I attempted to set active hud icons, which failed because it assumes this can never happen *cries* * Renames add_hud_to_atom to show_to My hope is this will make understanding hud code a bit easier, by tying the behavior to a "verb" more closely. Also renamed a few vars * remove_hud_from_mob -> hide_from * Nitpicks a few comments * Whoops/fuck/shit/damn it all/hhhhhhhhhhhh * Moves check down, improves stack trace a bit Co-authored-by: KylerAce <kylerlumpkin1@gmail.com>
This commit is contained in:
co-authored by
KylerAce
parent
d0a083143c
commit
24326bc649
@@ -734,13 +734,13 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
|
||||
|
||||
/mob/dead/observer/proc/show_data_huds()
|
||||
for(var/hudtype in datahuds)
|
||||
var/datum/atom_hud/H = GLOB.huds[hudtype]
|
||||
H.add_hud_to(src)
|
||||
var/datum/atom_hud/data_hud = GLOB.huds[hudtype]
|
||||
data_hud.show_to(src)
|
||||
|
||||
/mob/dead/observer/proc/remove_data_huds()
|
||||
for(var/hudtype in datahuds)
|
||||
var/datum/atom_hud/H = GLOB.huds[hudtype]
|
||||
H.remove_hud_from(src)
|
||||
var/datum/atom_hud/data_hud = GLOB.huds[hudtype]
|
||||
data_hud.hide_from(src)
|
||||
|
||||
/mob/dead/observer/verb/toggle_data_huds()
|
||||
set name = "Toggle Sec/Med/Diag HUD"
|
||||
|
||||
@@ -28,11 +28,11 @@
|
||||
/datum/species/abductor/on_species_gain(mob/living/carbon/C, datum/species/old_species)
|
||||
. = ..()
|
||||
var/datum/atom_hud/abductor_hud = GLOB.huds[DATA_HUD_ABDUCTOR]
|
||||
abductor_hud.add_hud_to(C)
|
||||
abductor_hud.show_to(C)
|
||||
|
||||
C.set_safe_hunger_level()
|
||||
|
||||
/datum/species/abductor/on_species_loss(mob/living/carbon/C)
|
||||
. = ..()
|
||||
var/datum/atom_hud/abductor_hud = GLOB.huds[DATA_HUD_ABDUCTOR]
|
||||
abductor_hud.remove_hud_from(C)
|
||||
abductor_hud.hide_from(C)
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
if(unique_name)
|
||||
set_name()
|
||||
var/datum/atom_hud/data/human/medical/advanced/medhud = GLOB.huds[DATA_HUD_MEDICAL_ADVANCED]
|
||||
medhud.add_to_hud(src)
|
||||
medhud.add_atom_to_hud(src)
|
||||
for(var/datum/atom_hud/data/diagnostic/diag_hud in GLOB.huds)
|
||||
diag_hud.add_to_hud(src)
|
||||
diag_hud.add_atom_to_hud(src)
|
||||
faction += "[REF(src)]"
|
||||
GLOB.mob_living_list += src
|
||||
SSpoints_of_interest.make_point_of_interest(src)
|
||||
|
||||
@@ -35,14 +35,14 @@
|
||||
var/datum/atom_hud/ai_detector/hud = GLOB.huds[DATA_HUD_AI_DETECT]
|
||||
var/list/old_images = hud_list[AI_DETECT_HUD]
|
||||
if(!ai_detector_visible)
|
||||
hud.remove_from_hud(src)
|
||||
hud.remove_atom_from_hud(src)
|
||||
QDEL_LIST(old_images)
|
||||
return
|
||||
|
||||
if(!length(hud.hudusers))
|
||||
if(!length(hud.hud_users))
|
||||
return //no one is watching, do not bother updating anything
|
||||
|
||||
hud.remove_from_hud(src)
|
||||
hud.remove_atom_from_hud(src)
|
||||
|
||||
var/static/list/vis_contents_opaque = list()
|
||||
var/obj/effect/overlay/ai_detect_hud/hud_obj = vis_contents_opaque[ai_detector_color]
|
||||
@@ -61,7 +61,7 @@
|
||||
for(var/i in (new_images.len + 1) to old_images.len)
|
||||
qdel(old_images[i])
|
||||
hud_list[AI_DETECT_HUD] = new_images
|
||||
hud.add_to_hud(src)
|
||||
hud.add_atom_to_hud(src)
|
||||
|
||||
/mob/camera/ai_eye/proc/get_visible_turfs()
|
||||
if(!isturf(loc))
|
||||
@@ -124,7 +124,7 @@
|
||||
GLOB.aiEyes -= src
|
||||
if(ai_detector_visible)
|
||||
var/datum/atom_hud/ai_detector/hud = GLOB.huds[DATA_HUD_AI_DETECT]
|
||||
hud.remove_from_hud(src)
|
||||
hud.remove_atom_from_hud(src)
|
||||
var/list/L = hud_list[AI_DETECT_HUD]
|
||||
QDEL_LIST(L)
|
||||
return ..()
|
||||
|
||||
@@ -119,10 +119,10 @@
|
||||
medHUD = !medHUD
|
||||
if(medHUD)
|
||||
var/datum/atom_hud/med = GLOB.huds[med_hud]
|
||||
med.add_hud_to(src)
|
||||
med.show_to(src)
|
||||
else
|
||||
var/datum/atom_hud/med = GLOB.huds[med_hud]
|
||||
med.remove_hud_from(src)
|
||||
med.hide_from(src)
|
||||
if("newscaster")
|
||||
newscaster.ui_interact(src)
|
||||
if("photography_module")
|
||||
@@ -147,10 +147,10 @@
|
||||
secHUD = !secHUD
|
||||
if(secHUD)
|
||||
var/datum/atom_hud/sec = GLOB.huds[sec_hud]
|
||||
sec.add_hud_to(src)
|
||||
sec.show_to(src)
|
||||
else
|
||||
var/datum/atom_hud/sec = GLOB.huds[sec_hud]
|
||||
sec.remove_hud_from(src)
|
||||
sec.hide_from(src)
|
||||
if("universal_translator")
|
||||
if(!languages_granted)
|
||||
grant_all_languages(TRUE, TRUE, TRUE, LANGUAGE_SOFTWARE)
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
if(ispath(radio))
|
||||
radio = new radio(src)
|
||||
for(var/datum/atom_hud/data/diagnostic/diag_hud in GLOB.huds)
|
||||
diag_hud.add_to_hud(src)
|
||||
diag_hud.add_atom_to_hud(src)
|
||||
diag_hud_set_status()
|
||||
diag_hud_set_health()
|
||||
add_sensors()
|
||||
@@ -377,17 +377,17 @@
|
||||
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.remove_hud_from(src)
|
||||
medsensor.remove_hud_from(src)
|
||||
diagsensor.remove_hud_from(src)
|
||||
secsensor.hide_from(src)
|
||||
medsensor.hide_from(src)
|
||||
diagsensor.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.add_hud_to(src)
|
||||
medsensor.add_hud_to(src)
|
||||
diagsensor.add_hud_to(src)
|
||||
secsensor.show_to(src)
|
||||
medsensor.show_to(src)
|
||||
diagsensor.show_to(src)
|
||||
|
||||
/mob/living/silicon/proc/toggle_sensors()
|
||||
if(incapacitated())
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
var/beacon_freq = FREQ_NAV_BEACON
|
||||
///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 = new /datum/atom_hud/data/bot_path()
|
||||
var/datum/atom_hud/data/bot_path/path_hud
|
||||
var/path_image_icon = 'icons/mob/aibots.dmi'
|
||||
var/path_image_icon_state = "path_indicator"
|
||||
var/path_image_color = "#FFFFFF"
|
||||
@@ -164,6 +164,11 @@
|
||||
/mob/living/simple_animal/bot/Initialize(mapload)
|
||||
. = ..()
|
||||
GLOB.bots_list += src
|
||||
|
||||
path_hud = new /datum/atom_hud/data/bot_path()
|
||||
for(var/hud in path_hud.hud_icons) // You get to see your own path
|
||||
set_hud_image_active(hud, exclusive_hud = path_hud)
|
||||
|
||||
// Give bots a fancy new ID card that can hold any access.
|
||||
access_card = new /obj/item/card/id/advanced/simple_bot(src)
|
||||
// This access is so bots can be immediately set to patrol and leave Robotics, instead of having to be let out first.
|
||||
@@ -178,7 +183,7 @@
|
||||
//Adds bot to the diagnostic HUD system
|
||||
prepare_huds()
|
||||
for(var/datum/atom_hud/data/diagnostic/diag_hud in GLOB.huds)
|
||||
diag_hud.add_to_hud(src)
|
||||
diag_hud.add_atom_to_hud(src)
|
||||
diag_hud_set_bothealth()
|
||||
diag_hud_set_botstat()
|
||||
diag_hud_set_botmode()
|
||||
@@ -186,10 +191,10 @@
|
||||
//If a bot has its own HUD (for player bots), provide it.
|
||||
if(!isnull(data_hud_type))
|
||||
var/datum/atom_hud/datahud = GLOB.huds[data_hud_type]
|
||||
datahud.add_hud_to(src)
|
||||
datahud.show_to(src)
|
||||
if(path_hud)
|
||||
path_hud.add_to_hud(src)
|
||||
path_hud.add_hud_to(src)
|
||||
path_hud.add_atom_to_hud(src)
|
||||
path_hud.show_to(src)
|
||||
|
||||
|
||||
/mob/living/simple_animal/bot/Destroy()
|
||||
@@ -1022,11 +1027,10 @@ Pass a positive integer as an argument to override a bot's default speed.
|
||||
var/list/path_huds_watching_me = list(GLOB.huds[DATA_HUD_DIAGNOSTIC_ADVANCED])
|
||||
if(path_hud)
|
||||
path_huds_watching_me += path_hud
|
||||
for(var/V in path_huds_watching_me)
|
||||
var/datum/atom_hud/H = V
|
||||
H.remove_from_hud(src)
|
||||
for(var/datum/atom_hud/hud as anything in path_huds_watching_me)
|
||||
hud.remove_atom_from_hud(src)
|
||||
|
||||
var/list/path_images = hud_list[DIAG_PATH_HUD]
|
||||
var/list/path_images = active_hud_list[DIAG_PATH_HUD]
|
||||
QDEL_LIST(path_images)
|
||||
if(newpath)
|
||||
for(var/i in 1 to newpath.len)
|
||||
@@ -1065,9 +1069,8 @@ Pass a positive integer as an argument to override a bot's default speed.
|
||||
path[T] = I
|
||||
path_images += I
|
||||
|
||||
for(var/V in path_huds_watching_me)
|
||||
var/datum/atom_hud/H = V
|
||||
H.add_to_hud(src)
|
||||
for(var/datum/atom_hud/hud as anything in path_huds_watching_me)
|
||||
hud.add_atom_to_hud(src)
|
||||
|
||||
/mob/living/simple_animal/bot/proc/increment_path()
|
||||
if(!length(path))
|
||||
|
||||
@@ -306,7 +306,7 @@
|
||||
/mob/living/simple_animal/hostile/construct/artificer/Initialize(mapload)
|
||||
. = ..()
|
||||
var/datum/atom_hud/datahud = GLOB.huds[health_hud]
|
||||
datahud.add_hud_to(src)
|
||||
datahud.show_to(src)
|
||||
|
||||
/mob/living/simple_animal/hostile/construct/artificer/Found(atom/A) //what have we found here?
|
||||
if(isconstruct(A)) //is it a construct?
|
||||
|
||||
@@ -182,7 +182,7 @@
|
||||
alert_drones(DRONE_NET_CONNECT)
|
||||
|
||||
for(var/datum/atom_hud/data/diagnostic/diag_hud in GLOB.huds)
|
||||
diag_hud.add_to_hud(src)
|
||||
diag_hud.add_atom_to_hud(src)
|
||||
|
||||
ADD_TRAIT(src, TRAIT_VENTCRAWLER_ALWAYS, INNATE_TRAIT)
|
||||
ADD_TRAIT(src, TRAIT_NEGATES_GRAVITY, INNATE_TRAIT)
|
||||
|
||||
@@ -57,11 +57,11 @@
|
||||
|
||||
/mob/living/simple_animal/robot_customer/MouseEntered(location, control, params)
|
||||
. = ..()
|
||||
hud_to_show_on_hover?.add_hud_to(usr)
|
||||
hud_to_show_on_hover?.show_to(usr)
|
||||
|
||||
/mob/living/simple_animal/robot_customer/MouseExited(location, control, params)
|
||||
. = ..()
|
||||
hud_to_show_on_hover?.remove_hud_from(usr)
|
||||
hud_to_show_on_hover?.hide_from(usr)
|
||||
|
||||
/mob/living/simple_animal/robot_customer/update_overlays()
|
||||
. = ..()
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
/mob/living/simple_animal/hostile/guardian/healer/Initialize(mapload)
|
||||
. = ..()
|
||||
var/datum/atom_hud/medsensor = GLOB.huds[DATA_HUD_MEDICAL_ADVANCED]
|
||||
medsensor.add_hud_to(src)
|
||||
medsensor.show_to(src)
|
||||
|
||||
/mob/living/simple_animal/hostile/guardian/healer/get_status_tab_items()
|
||||
. = ..()
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
/mob/living/simple_animal/hostile/giant_spider/nurse/Initialize(mapload)
|
||||
. = ..()
|
||||
var/datum/atom_hud/datahud = GLOB.huds[health_hud]
|
||||
datahud.add_hud_to(src)
|
||||
datahud.show_to(src)
|
||||
|
||||
/mob/living/simple_animal/hostile/giant_spider/nurse/AttackingTarget()
|
||||
if(is_busy)
|
||||
|
||||
@@ -506,7 +506,7 @@
|
||||
remove_verb(src, /mob/living/verb/pulled)
|
||||
remove_verb(src, /mob/verb/me_verb)
|
||||
var/datum/atom_hud/medsensor = GLOB.huds[DATA_HUD_MEDICAL_ADVANCED]
|
||||
medsensor.add_hud_to(src)
|
||||
medsensor.show_to(src)
|
||||
|
||||
ADD_TRAIT(src, TRAIT_VENTCRAWLER_ALWAYS, INNATE_TRAIT)
|
||||
|
||||
|
||||
+55
-9
@@ -94,23 +94,69 @@
|
||||
/mob/GenerateTag()
|
||||
tag = "mob_[next_mob_id++]"
|
||||
|
||||
/**
|
||||
* set every hud image in the given category active so other people with the given hud can see it.
|
||||
* Arguments:
|
||||
* * hud_category - the index in our active_hud_list corresponding to an image now being shown.
|
||||
* * update_huds - if FALSE we will just put the hud_category into active_hud_list without actually updating the atom_hud datums subscribed to it
|
||||
* * exclusive_hud - if given a reference to an atom_hud, will just update that hud instead of all global ones attached to that category.
|
||||
* This is because some atom_hud subtypes arent supposed to work via global categories, updating normally would affect all of these which we dont want.
|
||||
*/
|
||||
/atom/proc/set_hud_image_active(hud_category, update_huds = TRUE, datum/atom_hud/exclusive_hud)
|
||||
if(!istext(hud_category) || !hud_list?[hud_category] || active_hud_list?[hud_category])
|
||||
return FALSE
|
||||
|
||||
LAZYSET(active_hud_list, hud_category, hud_list[hud_category])
|
||||
|
||||
if(!update_huds)
|
||||
return TRUE
|
||||
|
||||
if(exclusive_hud)
|
||||
exclusive_hud.add_single_hud_category_on_atom(src, hud_category)
|
||||
else
|
||||
for(var/datum/atom_hud/hud_to_update as anything in GLOB.huds_by_category[hud_category])
|
||||
hud_to_update.add_single_hud_category_on_atom(src, hud_category)
|
||||
|
||||
return TRUE
|
||||
|
||||
///sets every hud image in the given category inactive so no one can see it
|
||||
/atom/proc/set_hud_image_inactive(hud_category, update_huds = TRUE, datum/atom_hud/exclusive_hud)
|
||||
if(!istext(hud_category))
|
||||
return FALSE
|
||||
|
||||
LAZYREMOVE(active_hud_list, hud_category)
|
||||
|
||||
if(!update_huds)
|
||||
return TRUE
|
||||
|
||||
if(exclusive_hud)
|
||||
exclusive_hud.remove_single_hud_category_on_atom(src, hud_category)
|
||||
else
|
||||
for(var/datum/atom_hud/hud_to_update as anything in GLOB.huds_by_category[hud_category])
|
||||
hud_to_update.remove_single_hud_category_on_atom(src, hud_category)
|
||||
|
||||
return TRUE
|
||||
|
||||
/**
|
||||
* Prepare the huds for this atom
|
||||
*
|
||||
* Goes through hud_possible list and adds the images to the hud_list variable (if not already
|
||||
* cached)
|
||||
* Goes through hud_possible list and adds the images to the hud_list variable (if not already cached)
|
||||
*/
|
||||
/atom/proc/prepare_huds()
|
||||
if(hud_list) // I choose to be lienient about people calling this proc more then once
|
||||
return
|
||||
hud_list = list()
|
||||
for(var/hud in hud_possible)
|
||||
var/hint = hud_possible[hud]
|
||||
switch(hint)
|
||||
if(HUD_LIST_LIST)
|
||||
hud_list[hud] = list()
|
||||
else
|
||||
var/image/I = image('icons/mob/huds/hud.dmi', src, "")
|
||||
I.appearance_flags = RESET_COLOR|RESET_TRANSFORM
|
||||
hud_list[hud] = I
|
||||
|
||||
if(hint == HUD_LIST_LIST)
|
||||
hud_list[hud] = list()
|
||||
|
||||
else
|
||||
var/image/I = image('icons/mob/huds/hud.dmi', src, "")
|
||||
I.appearance_flags = RESET_COLOR|RESET_TRANSFORM
|
||||
hud_list[hud] = I
|
||||
set_hud_image_active(hud, update_huds = FALSE) //by default everything is active. but dont add it to huds to keep control.
|
||||
|
||||
/**
|
||||
* Some kind of debug verb that gives atmosphere environment details
|
||||
|
||||
Reference in New Issue
Block a user