Makes Health Sensor assemblies a bit nicer to use (#83183)

## About The Pull Request
Gives health sensors a UI to change their settings

![sensor-off](https://github.com/tgstation/tgstation/assets/139372157/06eb1756-23ff-4d8a-b305-e847430f6982)

![sensor-on](https://github.com/tgstation/tgstation/assets/139372157/466f21d2-8369-4e04-9197-d606063aa715)

![checking-for-death](https://github.com/tgstation/tgstation/assets/139372157/25d7bc84-246b-4997-9684-e899a6700b5b)


## Why It's Good For The Game

Makes the assemblies less annoying to use

## Changelog
🆑

qol: Gives Health sensor assemblies a UI so its easier to use.

/🆑
This commit is contained in:
starrm4nn
2024-05-13 11:09:05 -07:00
committed by GitHub
parent 6933307eea
commit 5d81ba7bb0
2 changed files with 92 additions and 18 deletions
+37 -18
View File
@@ -7,11 +7,10 @@
var/scanning = FALSE
var/health_scan
var/alarm_health = HEALTH_THRESHOLD_CRIT
var/health_target = HEALTH_THRESHOLD_CRIT
/obj/item/assembly/health/examine(mob/user)
. = ..()
. += "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)
@@ -37,15 +36,6 @@
update_appearance()
return secured
/obj/item/assembly/health/click_alt(mob/living/user)
if(alarm_health == HEALTH_THRESHOLD_CRIT)
alarm_health = HEALTH_THRESHOLD_DEAD
to_chat(user, span_notice("You toggle [src] to \"detect death\" mode."))
else
alarm_health = HEALTH_THRESHOLD_CRIT
to_chat(user, span_notice("You toggle [src] to \"detect critical state\" mode."))
return CLICK_ACTION_SUCCESS
/obj/item/assembly/health/process()
//not ready yet
if(!scanning || !secured)
@@ -63,7 +53,7 @@
//only do the pulse if we are within alarm thresholds
var/mob/living/target_mob = object
health_scan = target_mob.health
if(health_scan > alarm_health)
if(health_scan > health_target)
return
//do the pulse & the scan
@@ -82,14 +72,43 @@
STOP_PROCESSING(SSobj, src)
return
/obj/item/assembly/health/attack_self(mob/user)
. = ..()
if (secured)
balloon_alert(user, "scanning [scanning ? "disabled" : "enabled"]")
/obj/item/assembly/health/proc/toggle_target()
if(health_target == HEALTH_THRESHOLD_CRIT)
health_target = HEALTH_THRESHOLD_DEAD
else
balloon_alert(user, "secure it first!")
toggle_scan()
health_target = HEALTH_THRESHOLD_CRIT
return
/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)]%"
/obj/item/assembly/health/ui_status(mob/user, datum/ui_state/state)
return is_secured(user) ? ..() : UI_CLOSE
/obj/item/assembly/health/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "HealthSensor", name)
ui.open()
/obj/item/assembly/health/ui_data(mob/user)
var/list/data = list()
data["health"] = health_scan
data["scanning"] = scanning
data["target"] = health_target
return data
/obj/item/assembly/health/ui_act(action, params)
. = ..()
if(.)
return .
switch(action)
if("scanning")
toggle_scan()
return TRUE
if("target")
toggle_target()
return TRUE