From bee85df93f815ddc0fd5898d0dd89e023e56c769 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sat, 31 Dec 2022 17:27:12 +0100 Subject: [PATCH] [MIRROR] makes status tab use signals, thirds the delay between updates [MDB IGNORE] (#18179) * makes status tab use signals, thirds the delay between updates (#72002) ## About The Pull Request status panel for carbons and humans instead of hardcoding stuff, uses signals (borg material storage too) removes combat mode indicator in status tab from xenomorphs which have a button for it, but adds it to simplemobs, since they dont have a visual indicator adds status tab stuff to basic mobs, i think they were missing everything by accident offsets unique status tab stuff for all mobs by a single line the delay between updates is a third of what it was before, mainly to make shuttle timers more accurate (approved by kyler) ## Why It's Good For The Game much cleaner code, makes future implementations easy ## Changelog :cl: qol: you can see your combat mode status as a simple or basic mob, and you can see your health as a basic mob qol: status panel updates three times as fast /:cl: * makes status tab use signals, thirds the delay between updates Co-authored-by: Fikou <23585223+Fikou@users.noreply.github.com> --- .../signals/signals_mob/signals_mob_main.dm | 2 ++ code/controllers/subsystem/statpanel.dm | 2 +- code/game/objects/items/tanks/tanks.dm | 11 ++++++++-- .../antagonists/changeling/changeling.dm | 8 +++++++- code/modules/assembly/health.dm | 11 ++++++++++ .../clothing/spacesuits/_spacesuits.dm | 17 +++++++++++----- code/modules/mob/dead/dead.dm | 3 --- code/modules/mob/living/basic/basic.dm | 5 +++++ code/modules/mob/living/carbon/alien/alien.dm | 4 ---- .../modules/mob/living/carbon/alien/organs.dm | 8 +++++++- code/modules/mob/living/carbon/carbon.dm | 13 +----------- code/modules/mob/living/carbon/human/human.dm | 20 ------------------- .../carbon/human/species_types/vampire.dm | 12 +++++++++++ .../modules/mob/living/silicon/robot/robot.dm | 4 ---- .../mob/living/silicon/robot/robot_model.dm | 12 +++++++---- .../mob/living/simple_animal/parrot.dm | 2 -- .../mob/living/simple_animal/simple_animal.dm | 2 +- code/modules/mob/mob.dm | 3 ++- 18 files changed, 78 insertions(+), 61 deletions(-) diff --git a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm index fbe2df6bff9..1cac348d152 100644 --- a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm +++ b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm @@ -171,3 +171,5 @@ ///from living/flash_act(), when a mob is successfully flashed. #define COMSIG_MOB_FLASHED "mob_flashed" +/// from mob/get_status_tab_items(): (list/items) +#define COMSIG_MOB_GET_STATUS_TAB_ITEMS "mob_get_status_tab_items" diff --git a/code/controllers/subsystem/statpanel.dm b/code/controllers/subsystem/statpanel.dm index b1c54ae0b26..6417858d133 100644 --- a/code/controllers/subsystem/statpanel.dm +++ b/code/controllers/subsystem/statpanel.dm @@ -13,7 +13,7 @@ SUBSYSTEM_DEF(statpanels) ///how many subsystem fires between most tab updates var/default_wait = 10 ///how many subsystem fires between updates of the status tab - var/status_wait = 6 + var/status_wait = 2 ///how many subsystem fires between updates of the MC tab var/mc_wait = 5 ///how many full runs this subsystem has completed. used for variable rate refreshes. diff --git a/code/game/objects/items/tanks/tanks.dm b/code/game/objects/items/tanks/tanks.dm index 391be310aa6..3f83bbf2905 100644 --- a/code/game/objects/items/tanks/tanks.dm +++ b/code/game/objects/items/tanks/tanks.dm @@ -68,10 +68,18 @@ /// Called by carbons after they connect the tank to their breathing apparatus. /obj/item/tank/proc/after_internals_opened(mob/living/carbon/carbon_target) breathing_mob = carbon_target + RegisterSignal(carbon_target, COMSIG_MOB_GET_STATUS_TAB_ITEMS, PROC_REF(get_status_tab_item)) /// Called by carbons after they disconnect the tank from their breathing apparatus. /obj/item/tank/proc/after_internals_closed(mob/living/carbon/carbon_target) breathing_mob = null + UnregisterSignal(carbon_target, COMSIG_MOB_GET_STATUS_TAB_ITEMS) + +/obj/item/tank/proc/get_status_tab_item(mob/living/source, list/items) + SIGNAL_HANDLER + items += "Internal Atmosphere Info: [name]" + items += "Tank Pressure: [air_contents.return_pressure()] kPa" + items += "Distribution Pressure: [distribute_pressure] kPa" /// Attempts to toggle the mob's internals on or off using this tank. Returns TRUE if successful. /obj/item/tank/proc/toggle_internals(mob/living/carbon/mob_target) @@ -106,7 +114,6 @@ return /obj/item/tank/Destroy() - UnregisterSignal(air_contents, COMSIG_GASMIX_MERGED) air_contents = null STOP_PROCESSING(SSobj, src) return ..() @@ -121,7 +128,7 @@ . += span_notice("If you want any more information you'll need to get closer.") return - . += span_notice("The pressure gauge reads [round(src.air_contents.return_pressure(),0.01)] kPa.") + . += span_notice("The pressure gauge reads [round(air_contents.return_pressure(),0.01)] kPa.") var/celsius_temperature = air_contents.temperature-T0C var/descriptive diff --git a/code/modules/antagonists/changeling/changeling.dm b/code/modules/antagonists/changeling/changeling.dm index f1a5f468499..8e3d61d1cb5 100644 --- a/code/modules/antagonists/changeling/changeling.dm +++ b/code/modules/antagonists/changeling/changeling.dm @@ -164,6 +164,7 @@ RegisterSignal(living_mob, COMSIG_MOB_LOGIN, PROC_REF(on_login)) RegisterSignal(living_mob, COMSIG_LIVING_LIFE, PROC_REF(on_life)) RegisterSignal(living_mob, COMSIG_LIVING_POST_FULLY_HEAL, PROC_REF(on_fullhealed)) + RegisterSignal(living_mob, COMSIG_MOB_GET_STATUS_TAB_ITEMS, PROC_REF(get_status_tab_item)) RegisterSignals(living_mob, list(COMSIG_MOB_MIDDLECLICKON, COMSIG_MOB_ALTCLICKON), PROC_REF(on_click_sting)) if(living_mob.hud_used) @@ -221,7 +222,7 @@ /datum/antagonist/changeling/remove_innate_effects(mob/living/mob_override) var/mob/living/living_mob = mob_override || owner.current handle_clown_mutation(living_mob, removing = FALSE) - UnregisterSignal(living_mob, list(COMSIG_MOB_LOGIN, COMSIG_LIVING_LIFE, COMSIG_LIVING_POST_FULLY_HEAL, COMSIG_MOB_MIDDLECLICKON, COMSIG_MOB_ALTCLICKON)) + UnregisterSignal(living_mob, list(COMSIG_MOB_LOGIN, COMSIG_LIVING_LIFE, COMSIG_LIVING_POST_FULLY_HEAL, COMSIG_MOB_GET_STATUS_TAB_ITEMS, COMSIG_MOB_MIDDLECLICKON, COMSIG_MOB_ALTCLICKON)) if(living_mob.hud_used) var/datum/hud/hud_used = living_mob.hud_used @@ -327,6 +328,11 @@ return COMSIG_MOB_CANCEL_CLICKON +/datum/antagonist/changeling/proc/get_status_tab_item(mob/living/source, list/items) + SIGNAL_HANDLER + items += "Chemical Storage: [chem_charges]/[total_chem_storage]" + items += "Absorbed DNA: [absorbed_count]" + /* * Adjust the chem charges of the ling by [amount] * and clamp it between 0 and override_cap (if supplied) or total_chem_storage (if no override supplied) diff --git a/code/modules/assembly/health.dm b/code/modules/assembly/health.dm index 8a2607fa341..5e3ad6558a0 100644 --- a/code/modules/assembly/health.dm +++ b/code/modules/assembly/health.dm @@ -14,6 +14,13 @@ . += "Use it in hand to turn it off/on and Alt-click to swap between \"detect death\" mode and \"detect critical state\" mode." . += "[src.scanning ? "The sensor is on and you can see [health_scan] displayed on the screen" : "The sensor is off"]." +/obj/item/assembly/health/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change) + . = ..() + if(iscarbon(old_loc)) + UnregisterSignal(old_loc, COMSIG_MOB_GET_STATUS_TAB_ITEMS) + if(iscarbon(loc)) + RegisterSignal(loc, COMSIG_MOB_GET_STATUS_TAB_ITEMS, PROC_REF(get_status_tab_item)) + /obj/item/assembly/health/activate() if(!..()) return FALSE//Cooldown check @@ -76,3 +83,7 @@ else balloon_alert(user, span_warning("secure it first!")) toggle_scan() + +/obj/item/assembly/health/proc/get_status_tab_item(mob/living/carbon/source, list/items) + SIGNAL_HANDLER + items += "Health: [round((source.health / source.maxHealth) * 100)]%" diff --git a/code/modules/clothing/spacesuits/_spacesuits.dm b/code/modules/clothing/spacesuits/_spacesuits.dm index 079d6a1e450..01f4080de62 100644 --- a/code/modules/clothing/spacesuits/_spacesuits.dm +++ b/code/modules/clothing/spacesuits/_spacesuits.dm @@ -64,19 +64,26 @@ cell = new cell(src) /// Start Processing on the space suit when it is worn to heat the wearer -/obj/item/clothing/suit/space/equipped(mob/user, slot) +/obj/item/clothing/suit/space/equipped(mob/living/user, slot) . = ..() if(slot & ITEM_SLOT_OCLOTHING) // Check that the slot is valid START_PROCESSING(SSobj, src) update_hud_icon(user) // update the hud + RegisterSignal(user, COMSIG_MOB_GET_STATUS_TAB_ITEMS, PROC_REF(get_status_tab_item)) // On removal stop processing, save battery -/obj/item/clothing/suit/space/dropped(mob/user) +/obj/item/clothing/suit/space/dropped(mob/living/user) . = ..() STOP_PROCESSING(SSobj, src) - var/mob/living/carbon/human/human = user - if(istype(human)) - human.update_spacesuit_hud_icon("0") + UnregisterSignal(user, COMSIG_MOB_GET_STATUS_TAB_ITEMS) + var/mob/living/carbon/carbon_user = user + if(istype(carbon_user)) + carbon_user.update_spacesuit_hud_icon("0") + +/obj/item/clothing/suit/space/proc/get_status_tab_item(mob/living/source, list/items) + SIGNAL_HANDLER + items += "Thermal Regulator: [thermal_on ? "On" : "Off"]" + items += "Cell Charge: [cell ? "[round(cell.percent(), 0.1)]%" : "No Cell!"]" // Space Suit temperature regulation and power usage /obj/item/clothing/suit/space/process(delta_time) diff --git a/code/modules/mob/dead/dead.dm b/code/modules/mob/dead/dead.dm index d1822221d2b..ca2ba755cce 100644 --- a/code/modules/mob/dead/dead.dm +++ b/code/modules/mob/dead/dead.dm @@ -39,11 +39,8 @@ INITIALIZE_IMMEDIATE(/mob/dead) /mob/dead/get_status_tab_items() . = ..() - . += "" - if(SSticker.HasRoundStarted()) return - var/time_remaining = SSticker.GetTimeLeft() if(time_remaining > 0) . += "Time To Start: [round(time_remaining/10)]s" diff --git a/code/modules/mob/living/basic/basic.dm b/code/modules/mob/living/basic/basic.dm index 1c08976beb0..f20e5cf3b4b 100644 --- a/code/modules/mob/living/basic/basic.dm +++ b/code/modules/mob/living/basic/basic.dm @@ -185,3 +185,8 @@ if(user.incapacitated()) return return relaydrive(user, direction) + +/mob/living/basic/get_status_tab_items() + . = ..() + . += "Health: [round((health / maxHealth) * 100)]%" + . += "Combat Mode: [combat_mode ? "On" : "Off"]" diff --git a/code/modules/mob/living/carbon/alien/alien.dm b/code/modules/mob/living/carbon/alien/alien.dm index f35c2f6bc1b..c3ada1aa5e3 100644 --- a/code/modules/mob/living/carbon/alien/alien.dm +++ b/code/modules/mob/living/carbon/alien/alien.dm @@ -73,10 +73,6 @@ /mob/living/carbon/alien/reagent_check(datum/reagent/R, delta_time, times_fired) //can metabolize all reagents return FALSE -/mob/living/carbon/alien/get_status_tab_items() - . = ..() - . += "Combat mode: [combat_mode ? "On" : "Off"]" - /mob/living/carbon/alien/getTrail() if(getBruteLoss() < 200) return pick (list("xltrails_1", "xltrails2")) diff --git a/code/modules/mob/living/carbon/alien/organs.dm b/code/modules/mob/living/carbon/alien/organs.dm index 5bdddf2e818..65c477925a7 100644 --- a/code/modules/mob/living/carbon/alien/organs.dm +++ b/code/modules/mob/living/carbon/alien/organs.dm @@ -72,12 +72,18 @@ if(isalien(organ_owner)) var/mob/living/carbon/alien/target_alien = organ_owner target_alien.updatePlasmaDisplay() + RegisterSignal(organ_owner, COMSIG_MOB_GET_STATUS_TAB_ITEMS, PROC_REF(get_status_tab_item)) /obj/item/organ/internal/alien/plasmavessel/Remove(mob/living/carbon/organ_owner, special = FALSE) ..() if(isalien(organ_owner)) var/mob/living/carbon/alien/organ_owner_alien = organ_owner organ_owner_alien.updatePlasmaDisplay() + UnregisterSignal(organ_owner, COMSIG_MOB_GET_STATUS_TAB_ITEMS) + +/obj/item/organ/internal/alien/plasmavessel/proc/get_status_tab_item(mob/living/carbon/source, list/items) + SIGNAL_HANDLER + items += "Plasma Stored: [stored_plasma]/[max_plasma]" #define QUEEN_DEATH_DEBUFF_DURATION 2400 @@ -332,7 +338,7 @@ /obj/item/organ/internal/stomach/alien/proc/eject_stomach(list/turf/targets, spit_range, content_speed, particle_delay, particle_count=4) var/atom/spit_as = owner || src - /// Throw out the stuff in our stomach + // Throw out the stuff in our stomach for(var/atom/movable/thing as anything in stomach_contents) thing.forceMove(spit_as.drop_location()) if(length(targets)) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 04d11950faf..e6c7957095b 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -40,7 +40,7 @@ if(!isnum(held_index)) CRASH("You passed [held_index] into swap_hand instead of a number. WTF man") - + var/oindex = active_hand_index active_hand_index = held_index if(hud_used) @@ -412,17 +412,6 @@ var/turf/target = get_turf(loc) I.safe_throw_at(target,I.throw_range,I.throw_speed,src, force = move_force) -/mob/living/carbon/get_status_tab_items() - . = ..() - var/obj/item/organ/internal/alien/plasmavessel/vessel = getorgan(/obj/item/organ/internal/alien/plasmavessel) - if(vessel) - . += "Plasma Stored: [vessel.stored_plasma]/[vessel.max_plasma]" - var/obj/item/organ/internal/heart/vampire/darkheart = getorgan(/obj/item/organ/internal/heart/vampire) - if(darkheart) - . += "Current blood level: [blood_volume]/[BLOOD_VOLUME_MAXIMUM]." - if(locate(/obj/item/assembly/health) in src) - . += "Health: [health]" - /mob/living/carbon/attack_ui(slot, params) if(!has_hand_for_held_index(active_hand_index)) return 0 diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 021f0b34513..98756edd90d 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -82,26 +82,6 @@ //...and display them. add_to_all_human_data_huds() -/mob/living/carbon/human/get_status_tab_items() - . = ..() - var/obj/item/tank/target_tank = internal || external - if(target_tank) - var/datum/gas_mixture/internal_air = target_tank.return_air() - . += "" - . += "Internal Atmosphere Info: [target_tank.name]" - . += "Tank Pressure: [internal_air.return_pressure()]" - . += "Distribution Pressure: [target_tank.distribute_pressure]" - if(istype(wear_suit, /obj/item/clothing/suit/space)) - var/obj/item/clothing/suit/space/S = wear_suit - . += "Thermal Regulator: [S.thermal_on ? "on" : "off"]" - . += "Cell Charge: [S.cell ? "[round(S.cell.percent(), 0.1)]%" : "!invalid!"]" - if(mind) - var/datum/antagonist/changeling/changeling = mind.has_antag_datum(/datum/antagonist/changeling) - if(changeling) - . += "" - . += "Chemical Storage: [changeling.chem_charges]/[changeling.total_chem_storage]" - . += "Absorbed DNA: [changeling.absorbed_count]" - /mob/living/carbon/human/reset_perspective(atom/new_eye, force_reset = FALSE) if(dna?.species?.prevent_perspective_change && !force_reset) // This is in case a species needs to prevent perspective changes in certain cases, like Dullahans preventing perspective changes when they're looking through their head. update_fullscreen() diff --git a/code/modules/mob/living/carbon/human/species_types/vampire.dm b/code/modules/mob/living/carbon/human/species_types/vampire.dm index ad6f5ca04ff..d69bc4c95b1 100644 --- a/code/modules/mob/living/carbon/human/species_types/vampire.dm +++ b/code/modules/mob/living/carbon/human/species_types/vampire.dm @@ -195,5 +195,17 @@ name = "vampire heart" color = "#1C1C1C" +/obj/item/organ/internal/heart/vampire/Insert(mob/living/carbon/receiver, special, drop_if_replaced) + . = ..() + RegisterSignal(receiver, COMSIG_MOB_GET_STATUS_TAB_ITEMS, PROC_REF(get_status_tab_item)) + +/obj/item/organ/internal/heart/vampire/Remove(mob/living/carbon/heartless, special) + . = ..() + UnregisterSignal(heartless, COMSIG_MOB_GET_STATUS_TAB_ITEMS) + +/obj/item/organ/internal/heart/vampire/proc/get_status_tab_item(mob/living/carbon/source, list/items) + SIGNAL_HANDLER + items += "Blood Level: [source.blood_volume]/[BLOOD_VOLUME_MAXIMUM]" + #undef VAMPIRES_PER_HOUSE #undef VAMP_DRAIN_AMOUNT diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 5e55e8d4439..c60f7081050 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -279,15 +279,11 @@ /mob/living/silicon/robot/get_status_tab_items() . = ..() - . += "" if(cell) . += "Charge Left: [cell.charge]/[cell.maxcharge]" else . += "No Cell Inserted!" - if(model) - for(var/datum/robot_energy_storage/st in model.storages) - . += "[st.name]: [st.energy]/[st.max_energy]" if(connected_ai) . += "Master AI: [connected_ai.name]" diff --git a/code/modules/mob/living/silicon/robot/robot_model.dm b/code/modules/mob/living/silicon/robot/robot_model.dm index c6163919054..717c547e95b 100644 --- a/code/modules/mob/living/silicon/robot/robot_model.dm +++ b/code/modules/mob/living/silicon/robot/robot_model.dm @@ -913,11 +913,15 @@ var/recharge_rate = 1000 var/energy -/datum/robot_energy_storage/New(obj/item/robot_model/R = null) +/datum/robot_energy_storage/New(obj/item/robot_model/model) energy = max_energy - if(R) - R.storages |= src - return + if(model) + model.storages |= src + RegisterSignal(model.robot, COMSIG_MOB_GET_STATUS_TAB_ITEMS, PROC_REF(get_status_tab_item)) + +/datum/robot_energy_storage/proc/get_status_tab_item(mob/living/silicon/robot/source, list/items) + SIGNAL_HANDLER + items += "[name]: [energy]/[max_energy]" /datum/robot_energy_storage/proc/use_charge(amount) if (energy >= amount) diff --git a/code/modules/mob/living/simple_animal/parrot.dm b/code/modules/mob/living/simple_animal/parrot.dm index a7339567cc1..a706bafb129 100644 --- a/code/modules/mob/living/simple_animal/parrot.dm +++ b/code/modules/mob/living/simple_animal/parrot.dm @@ -159,9 +159,7 @@ /mob/living/simple_animal/parrot/get_status_tab_items() . = ..() - . += "" . += "Held Item: [held_item]" - . += "Combat mode: [combat_mode ? "On" : "Off"]" // SKYRAT EDIT REMOVAL BEGIN - MOVED TO modular_skyrat/modules/poly_commands /* diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index 57a4354783b..1e574f433a5 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -449,8 +449,8 @@ /mob/living/simple_animal/get_status_tab_items() . = ..() - . += "" . += "Health: [round((health / maxHealth) * 100)]%" + . += "Combat Mode: [combat_mode ? "On" : "Off"]" /mob/living/simple_animal/proc/drop_loot() if(loot.len) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 7e4f4c5d1d8..874412e7a0c 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -854,7 +854,8 @@ /// Adds this list to the output to the stat browser /mob/proc/get_status_tab_items() - . = list() + . = list("") //we want to offset unique stuff from standard stuff + SEND_SIGNAL(src, COMSIG_MOB_GET_STATUS_TAB_ITEMS, .) /** * Convert a list of spells into a displyable list for the statpanel