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
🆑
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
/🆑
This commit is contained in:
Fikou
2022-12-16 09:56:49 -05:00
committed by GitHub
parent 819b760120
commit febdb61e01
18 changed files with 78 additions and 61 deletions
@@ -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"
+1 -1
View File
@@ -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.
+9 -2
View File
@@ -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
@@ -142,6 +142,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)
@@ -199,7 +200,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
@@ -305,6 +306,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)
+11
View File
@@ -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)]%"
@@ -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)
-3
View File
@@ -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"
+5
View File
@@ -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"]"
@@ -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"))
@@ -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))
+1 -12
View File
@@ -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)
@@ -406,17 +406,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
@@ -78,26 +78,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()
@@ -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
@@ -266,15 +266,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]"
@@ -889,11 +889,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)
@@ -159,9 +159,7 @@
/mob/living/simple_animal/parrot/get_status_tab_items()
. = ..()
. += ""
. += "Held Item: [held_item]"
. += "Combat mode: [combat_mode ? "On" : "Off"]"
/mob/living/simple_animal/parrot/Hear(message, atom/movable/speaker, message_langs, raw_message, radio_freq, list/spans, list/message_mods = list(), message_range)
. = ..()
@@ -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)
+2 -1
View File
@@ -831,7 +831,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