/obj/machinery/computer/rust_core_control
name = "RUST Core Control"
icon = 'icons/rust.dmi'
icon_state = "core_control"
var/list/connected_devices = list()
var/id_tag = "allan remember to update this before you leave"
var/scan_range = 25
//currently viewed
var/obj/machinery/power/rust_core/cur_viewed_device
/obj/machinery/computer/rust_core_control/process()
if(stat & (BROKEN|NOPOWER))
return
/obj/machinery/computer/rust_core_control/attack_ai(mob/user)
attack_hand(user)
/obj/machinery/computer/rust_core_control/attack_hand(mob/user)
add_fingerprint(user)
interact(user)
/obj/machinery/computer/rust_core_control/interact(mob/user)
if(stat & BROKEN)
user.unset_machine()
user << browse(null, "window=core_control")
return
if (!istype(user, /mob/living/silicon) && (get_dist(src, user) > 1 ))
user.unset_machine()
user << browse(null, "window=core_control")
return
var/dat = ""
if(stat & NOPOWER)
dat += "The console is dark and nonresponsive."
else
dat += "Reactor Core Primary Monitor
"
if(cur_viewed_device && cur_viewed_device.stat & (BROKEN|NOPOWER))
cur_viewed_device = null
if(cur_viewed_device && !cur_viewed_device.remote_access_enabled)
cur_viewed_device = null
if(cur_viewed_device)
dat += "Device tag: [cur_viewed_device.id_tag ? cur_viewed_device.id_tag : "UNSET"]
"
dat += "Device [cur_viewed_device.owned_field ? "activated" : "deactivated"].
"
dat += "\[Bring field [cur_viewed_device.owned_field ? "offline" : "online"]\]
"
dat += "Device [cur_viewed_device.anchored ? "secured" : "unsecured"].
"
dat += "
"
dat += "Field encumbrance: [cur_viewed_device.owned_field ? 0 : "NA"]
"
dat += "Field strength: [cur_viewed_device.field_strength] Wm^3
"
dat += "\[----\] \
\[--- \] \
\[-- \] \
\[- \] \
\[+ \] \
\[++ \] \
\[+++ \] \
\[++++\]
"
dat += "Field frequency: [cur_viewed_device.field_frequency] MHz
"
dat += "\[----\] \
\[--- \] \
\[-- \] \
\[- \] \
\[+ \] \
\[++ \] \
\[+++ \] \
\[++++\]
"
var/power_stat = "Good"
if(cur_viewed_device.cached_power_avail < cur_viewed_device.active_power_usage)
power_stat = "Insufficient"
else if(cur_viewed_device.cached_power_avail < cur_viewed_device.active_power_usage * 2)
power_stat = "Check"
dat += "Power status: [power_stat]
"
else
dat += "\[Refresh device list\]
"
if(connected_devices.len)
dat += ""
dat += ""
dat += "| Device tag | "
dat += " | "
dat += "
"
for(var/obj/machinery/power/rust_core/C in connected_devices)
if(!check_core_status(C))
connected_devices.Remove(C)
continue
dat += ""
dat += "| [C.id_tag] | "
dat += "\[Manage\] | "
dat += "
"
dat += "
"
else
dat += "No devices connected.
"
dat += "
"
dat += "Refresh "
dat += "Close"
user << browse(dat, "window=core_control;size=500x400")
onclose(user, "core_control")
user.set_machine(src)
/obj/machinery/computer/rust_core_control/Topic(href, href_list)
..()
if( href_list["goto_scanlist"] )
cur_viewed_device = null
if( href_list["manage_individual"] )
cur_viewed_device = locate(href_list["manage_individual"])
if( href_list["scan"] )
connected_devices = list()
for(var/obj/machinery/power/rust_core/C in range(scan_range, src))
if(check_core_status(C))
connected_devices.Add(C)
if( href_list["startup"] )
if(cur_viewed_device)
cur_viewed_device.Startup()
if( href_list["shutdown"] )
if(cur_viewed_device)
cur_viewed_device.Shutdown()
if( href_list["close"] )
usr << browse(null, "window=core_control")
usr.unset_machine()
updateDialog()
/obj/machinery/computer/rust_core_control/proc/check_core_status(var/obj/machinery/power/rust_core/C)
if(!C)
return 0
if(C.stat & (BROKEN|NOPOWER) || !C.remote_access_enabled || !C.id_tag)
if(connected_devices.Find(C))
connected_devices.Remove(C)
return 0
return 1