mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 13:10:02 +01:00
[MIRROR] Cleans up suit/nanite sensor code a bit (#1547)
* Cleans up suit/nanite sensor code a bit (#54670) * Cleans up suit/nanite sensor code * linted * Cleans up suit/nanite sensor code a bit Co-authored-by: XDTM <heliumt@yahoo.it>
This commit is contained in:
@@ -204,6 +204,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
|
||||
#define TRAIT_TUMOR_SUPPRESSED "brain_tumor_suppressed" //prevents the damage done by a brain tumor
|
||||
#define TRAIT_PERMANENTLY_ONFIRE "permanently_onfire" //overrides the update_fire proc to always add fire (for lava)
|
||||
#define TRAIT_SIGN_LANG "sign_language" //Galactic Common Sign Language
|
||||
#define TRAIT_NANITE_MONITORING "nanite_monitoring" //The mob's nanites are sending a monitoring signal visible on diag HUD
|
||||
|
||||
//SKILLS
|
||||
#define TRAIT_UNDERWATER_BASKETWEAVING_KNOWLEDGE "underwater_basketweaving"
|
||||
|
||||
@@ -300,7 +300,7 @@
|
||||
var/icon/I = icon(icon, icon_state, dir)
|
||||
holder.pixel_y = I.Height() - world.icon_size
|
||||
holder.icon_state = null
|
||||
if(src in SSnanites.nanite_monitored_mobs)
|
||||
if(HAS_TRAIT(src, TRAIT_NANITE_MONITORING))
|
||||
holder.icon_state = "nanite_ping"
|
||||
|
||||
//For Diag health and cell bars!
|
||||
|
||||
@@ -22,60 +22,62 @@ GLOBAL_DATUM_INIT(crewmonitor, /datum/crewmonitor, new)
|
||||
|
||||
/datum/crewmonitor
|
||||
var/list/ui_sources = list() //List of user -> ui source
|
||||
var/list/jobs
|
||||
var/list/data_by_z = list()
|
||||
var/list/last_update = list()
|
||||
var/list/jobs = list(
|
||||
//Note that jobs divisible by 10 are considered heads of staff, and bolded
|
||||
//00: Captain
|
||||
"Captain" = 00,
|
||||
//10-19: Security
|
||||
"Head of Security" = 10,
|
||||
"Warden" = 11,
|
||||
"Security Officer" = 12,
|
||||
"Detective" = 13,
|
||||
//20-29: Medbay
|
||||
"Chief Medical Officer" = 20,
|
||||
"Chemist" = 21,
|
||||
"Virologist" = 22,
|
||||
"Medical Doctor" = 23,
|
||||
"Paramedic" = 24,
|
||||
//30-39: Science
|
||||
"Research Director" = 30,
|
||||
"Scientist" = 31,
|
||||
"Roboticist" = 32,
|
||||
"Geneticist" = 33,
|
||||
//40-49: Engineering
|
||||
"Chief Engineer" = 40,
|
||||
"Station Engineer" = 41,
|
||||
"Atmospheric Technician" = 42,
|
||||
//50-59: Cargo
|
||||
"Head of Personnel" = 50,
|
||||
"Quartermaster" = 51,
|
||||
"Shaft Miner" = 52,
|
||||
"Cargo Technician" = 53,
|
||||
//60+: Civilian/other
|
||||
"Bartender" = 61,
|
||||
"Cook" = 62,
|
||||
"Botanist" = 63,
|
||||
"Curator" = 64,
|
||||
"Chaplain" = 65,
|
||||
"Clown" = 66,
|
||||
"Mime" = 67,
|
||||
"Janitor" = 68,
|
||||
"Lawyer" = 69,
|
||||
"Psychologist" = 71,
|
||||
//ANYTHING ELSE = 81 //Unknowns/custom jobs will appear after civilians, and before assistants
|
||||
"Assistant" = 999,
|
||||
|
||||
/datum/crewmonitor/New()
|
||||
. = ..()
|
||||
|
||||
var/list/jobs = new/list()
|
||||
jobs["Captain"] = 00
|
||||
jobs["Head of Personnel"] = 50
|
||||
jobs["Head of Security"] = 10
|
||||
jobs["Warden"] = 11
|
||||
jobs["Security Officer"] = 12
|
||||
jobs["Detective"] = 13
|
||||
jobs["Chief Medical Officer"] = 20
|
||||
jobs["Chemist"] = 21
|
||||
jobs["Virologist"] = 22
|
||||
jobs["Medical Doctor"] = 23
|
||||
jobs["Paramedic"] = 24
|
||||
jobs["Research Director"] = 30
|
||||
jobs["Scientist"] = 31
|
||||
jobs["Roboticist"] = 32
|
||||
jobs["Geneticist"] = 33
|
||||
jobs["Chief Engineer"] = 40
|
||||
jobs["Station Engineer"] = 41
|
||||
jobs["Atmospheric Technician"] = 42
|
||||
jobs["Quartermaster"] = 51
|
||||
jobs["Shaft Miner"] = 52
|
||||
jobs["Cargo Technician"] = 53
|
||||
jobs["Bartender"] = 61
|
||||
jobs["Cook"] = 62
|
||||
jobs["Botanist"] = 63
|
||||
jobs["Curator"] = 64
|
||||
jobs["Chaplain"] = 65
|
||||
jobs["Clown"] = 66
|
||||
jobs["Mime"] = 67
|
||||
jobs["Janitor"] = 68
|
||||
jobs["Lawyer"] = 69
|
||||
jobs["Psychologist"] = 70
|
||||
jobs["Admiral"] = 200
|
||||
jobs["CentCom Commander"] = 210
|
||||
jobs["Custodian"] = 211
|
||||
jobs["Medical Officer"] = 212
|
||||
jobs["Research Officer"] = 213
|
||||
jobs["Emergency Response Team Commander"] = 220
|
||||
jobs["Security Response Officer"] = 221
|
||||
jobs["Engineer Response Officer"] = 222
|
||||
jobs["Medical Response Officer"] = 223
|
||||
jobs["Assistant"] = 999 //Unknowns/custom jobs should appear after civilians, and before assistants
|
||||
|
||||
src.jobs = jobs
|
||||
|
||||
/datum/crewmonitor/Destroy()
|
||||
return ..()
|
||||
//200-229: Centcom
|
||||
"Admiral" = 200,
|
||||
"CentCom Commander" = 210,
|
||||
"Custodian" = 211,
|
||||
"Medical Officer" = 212,
|
||||
"Research Officer" = 213,
|
||||
"Emergency Response Team Commander" = 220,
|
||||
"Security Response Officer" = 221,
|
||||
"Engineer Response Officer" = 222,
|
||||
"Medical Response Officer" = 223
|
||||
)
|
||||
|
||||
/datum/crewmonitor/ui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
@@ -105,8 +107,8 @@ GLOBAL_DATUM_INIT(crewmonitor, /datum/crewmonitor, new)
|
||||
return data_by_z["[z]"]
|
||||
|
||||
var/list/results = list()
|
||||
var/obj/item/clothing/under/U
|
||||
var/obj/item/card/id/I
|
||||
var/obj/item/clothing/under/uniform
|
||||
var/obj/item/card/id/id_card
|
||||
var/turf/pos
|
||||
var/ijob
|
||||
var/name
|
||||
@@ -122,29 +124,25 @@ GLOBAL_DATUM_INIT(crewmonitor, /datum/crewmonitor, new)
|
||||
|
||||
for(var/i in GLOB.nanite_sensors_list)
|
||||
var/mob/living/carbon/human/H = i
|
||||
var/nanite_sensors = FALSE
|
||||
if(H in SSnanites.nanite_monitored_mobs)
|
||||
nanite_sensors = TRUE
|
||||
// Check if their z-level is correct and if they are wearing a uniform.
|
||||
// Check if their z-level is correct
|
||||
// Accept H.z==0 as well in case the mob is inside an object.
|
||||
if(((H.z == 0 || H.z == z) && (nanite_sensors)))
|
||||
|
||||
pos = H.z == 0 || (nanite_sensors) ? get_turf(H) : null
|
||||
if(H.z == 0 || H.z == z)
|
||||
pos = get_turf(H)
|
||||
|
||||
// Special case: If the mob is inside an object confirm the z-level on turf level.
|
||||
if (H.z == 0 && (!pos || pos.z != z))
|
||||
continue
|
||||
|
||||
I = H.wear_id ? H.wear_id.GetID() : null
|
||||
id_card = H.wear_id ? H.wear_id.GetID() : null
|
||||
|
||||
if (I)
|
||||
name = I.registered_name
|
||||
assignment = I.assignment
|
||||
ijob = jobs[I.assignment]
|
||||
if (id_card)
|
||||
name = id_card.registered_name
|
||||
assignment = id_card.assignment
|
||||
ijob = jobs[id_card.assignment]
|
||||
else
|
||||
name = "Unknown"
|
||||
assignment = ""
|
||||
ijob = 80
|
||||
ijob = 81
|
||||
|
||||
life_status = (!H.stat ? TRUE : FALSE)
|
||||
|
||||
@@ -153,8 +151,6 @@ GLOBAL_DATUM_INIT(crewmonitor, /datum/crewmonitor, new)
|
||||
burndam = round(H.getFireLoss(),1)
|
||||
brutedam = round(H.getBruteLoss(),1)
|
||||
|
||||
if (!pos)
|
||||
pos = get_turf(H)
|
||||
area = get_area_name(H, TRUE)
|
||||
pos_x = pos.x
|
||||
pos_y = pos.y
|
||||
@@ -164,35 +160,36 @@ GLOBAL_DATUM_INIT(crewmonitor, /datum/crewmonitor, new)
|
||||
for(var/i in GLOB.suit_sensors_list)
|
||||
var/mob/living/carbon/human/H = i
|
||||
// Check if their z-level is correct and if they are wearing a uniform.
|
||||
// Accept H.z==0 as well in case the mob is inside an object. Nanite sensors come before normal sensors.
|
||||
// Accept H.z==0 as well in case the mob is inside an object.
|
||||
// Also exclude people already listed due to nanite sensors (which will always be at maximum detail)
|
||||
if((H.z == 0 || H.z == z) && (istype(H.w_uniform, /obj/item/clothing/under)) && !(H in GLOB.nanite_sensors_list))
|
||||
U = H.w_uniform
|
||||
uniform = H.w_uniform
|
||||
|
||||
// Are the suit sensors on?
|
||||
if (((U.has_sensor > 0) && U.sensor_mode))
|
||||
pos = H.z == 0 || (U.sensor_mode == SENSOR_COORDS) ? get_turf(H) : null
|
||||
if (((uniform.has_sensor > 0) && uniform.sensor_mode))
|
||||
pos = get_turf(H)
|
||||
|
||||
// Special case: If the mob is inside an object confirm the z-level on turf level.
|
||||
if (H.z == 0 && (!pos || pos.z != z))
|
||||
continue
|
||||
|
||||
I = H.wear_id ? H.wear_id.GetID() : null
|
||||
id_card = H.wear_id ? H.wear_id.GetID() : null
|
||||
|
||||
if (I)
|
||||
name = I.registered_name
|
||||
assignment = I.assignment
|
||||
ijob = jobs[I.assignment]
|
||||
if (id_card)
|
||||
name = id_card.registered_name
|
||||
assignment = id_card.assignment
|
||||
ijob = jobs[id_card.assignment]
|
||||
else
|
||||
name = "Unknown"
|
||||
assignment = ""
|
||||
ijob = 80
|
||||
ijob = 81
|
||||
|
||||
if (U.sensor_mode >= SENSOR_LIVING)
|
||||
if (uniform.sensor_mode >= SENSOR_LIVING)
|
||||
life_status = (!H.stat ? TRUE : FALSE)
|
||||
else
|
||||
life_status = null
|
||||
|
||||
if (U.sensor_mode >= SENSOR_VITALS)
|
||||
if (uniform.sensor_mode >= SENSOR_VITALS)
|
||||
oxydam = round(H.getOxyLoss(),1)
|
||||
toxdam = round(H.getToxLoss(),1)
|
||||
burndam = round(H.getFireLoss(),1)
|
||||
@@ -203,9 +200,7 @@ GLOBAL_DATUM_INIT(crewmonitor, /datum/crewmonitor, new)
|
||||
burndam = null
|
||||
brutedam = null
|
||||
|
||||
if (U.sensor_mode >= SENSOR_COORDS)
|
||||
if (!pos)
|
||||
pos = get_turf(H)
|
||||
if (pos && uniform.sensor_mode >= SENSOR_COORDS)
|
||||
area = get_area_name(H, TRUE)
|
||||
pos_x = pos.x
|
||||
pos_y = pos.y
|
||||
|
||||
@@ -33,19 +33,16 @@
|
||||
|
||||
/datum/nanite_program/monitoring/enable_passive_effect()
|
||||
. = ..()
|
||||
SSnanites.nanite_monitored_mobs |= host_mob
|
||||
ADD_TRAIT(host_mob, TRAIT_NANITE_MONITORING, "nanites") //Shows up in diagnostic and medical HUDs as a small blinking icon
|
||||
if(ishuman(host_mob))
|
||||
var/mob/living/carbon/human/H = host_mob
|
||||
if(!(H in GLOB.nanite_sensors_list))
|
||||
GLOB.nanite_sensors_list |= H
|
||||
GLOB.nanite_sensors_list |= host_mob
|
||||
host_mob.hud_set_nanite_indicator()
|
||||
|
||||
/datum/nanite_program/monitoring/disable_passive_effect()
|
||||
. = ..()
|
||||
SSnanites.nanite_monitored_mobs -= host_mob
|
||||
REMOVE_TRAIT(host_mob, TRAIT_NANITE_MONITORING, "nanites")
|
||||
if(ishuman(host_mob))
|
||||
var/mob/living/carbon/human/H = host_mob
|
||||
GLOB.nanite_sensors_list -= H
|
||||
GLOB.nanite_sensors_list -= host_mob
|
||||
|
||||
host_mob.hud_set_nanite_indicator()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user