mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 02:34:00 +00:00
Replaces the emergency shuttle control console
Replaces the old emergency shuttle control console with a nice new NanoUI one. Improves the NanoUI for the docking controllers.
This commit is contained in:
@@ -57,7 +57,7 @@
|
||||
|
||||
if (destination == area_station) location = 0
|
||||
if (destination == area_offsite) location = 1
|
||||
//if this is a long_jump retain the location we were last at until we get to the new one
|
||||
//if this is a long_jump retain the location we were last at until we get to the new one
|
||||
|
||||
/datum/shuttle/ferry/proc/get_location_area(location_id = null)
|
||||
if (isnull(location_id))
|
||||
@@ -73,7 +73,7 @@
|
||||
if (skip_docking_checks() || docking_controller.can_launch())
|
||||
|
||||
if (travel_time && area_transition)
|
||||
long_jump(null, null, area_transition, travel_time)
|
||||
long_jump(interim=area_transition, travel_time=travel_time)
|
||||
else
|
||||
short_jump()
|
||||
|
||||
@@ -115,9 +115,10 @@
|
||||
else
|
||||
short_jump()
|
||||
|
||||
|
||||
process_state = WAIT_ARRIVE
|
||||
|
||||
/datum/shuttle/ferry/proc/cancel_launch(var/obj/machinery/computer/shuttle_control/user)
|
||||
/datum/shuttle/ferry/proc/cancel_launch(var/user)
|
||||
if (!can_cancel()) return
|
||||
|
||||
moving_status = SHUTTLE_IDLE
|
||||
@@ -165,7 +166,6 @@
|
||||
|
||||
var/shuttle_tag // Used to coordinate data in shuttle controller.
|
||||
var/hacked = 0 // Has been emagged, no access restrictions.
|
||||
var/launch_override = 0
|
||||
|
||||
|
||||
/obj/machinery/computer/shuttle_control/attack_hand(user as mob)
|
||||
@@ -238,7 +238,7 @@
|
||||
if(href_list["force"])
|
||||
shuttle.force_launch(src)
|
||||
else if(href_list["cancel"])
|
||||
shuttle.cancel_launch()
|
||||
shuttle.cancel_launch(src)
|
||||
|
||||
/obj/machinery/computer/shuttle_control/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
|
||||
|
||||
@@ -1,22 +1,227 @@
|
||||
|
||||
|
||||
/datum/shuttle/ferry/emergency
|
||||
var/jump_time = null //the time at which the shuttle last jumped. Used for ETAs
|
||||
var/last_move_time = null //the time at which the shuttle last moved. Used for ETAs
|
||||
|
||||
/datum/shuttle/ferry/emergency/arrived()
|
||||
emergency_shuttle.shuttle_arrived()
|
||||
|
||||
/datum/shuttle/ferry/emergency/long_jump(var/area/departing,var/area/destination,var/area/interim,var/travel_time)
|
||||
if (!location)
|
||||
travel_time = SHUTTLE_TRANSIT_DURATION_RETURN
|
||||
else
|
||||
travel_time = SHUTTLE_TRANSIT_DURATION
|
||||
..()
|
||||
|
||||
/*
|
||||
/area/shuttle/escape/centcom/verb/shuttle_long_jump(var/area/A as area, var/area/B as area, var/area/I as area, var/travel_time as num)
|
||||
set category = "Debug"
|
||||
//set src in world
|
||||
var/datum/shuttle/ferry/emergency/E = shuttle_controller.shuttles["Escape"]
|
||||
E.long_jump(A, B, I, travel_time)
|
||||
|
||||
/area/shuttle/escape/centcom/verb/shuttle_move(var/area/A as area, var/area/B as area)
|
||||
set category = "Debug"
|
||||
//set src in world
|
||||
var/datum/shuttle/ferry/emergency/E = shuttle_controller.shuttles["Escape"]
|
||||
E.long_jump(A, B)
|
||||
*/
|
||||
|
||||
/datum/shuttle/ferry/emergency/move(var/area/origin,var/area/destination)
|
||||
if (destination == area_transition)
|
||||
jump_time = world.time
|
||||
last_move_time = world.time
|
||||
else
|
||||
jump_time = null
|
||||
last_move_time = null
|
||||
|
||||
if (!location) //leaving the station
|
||||
emergency_shuttle.departed = 1
|
||||
captain_announce("The Emergency Shuttle has left the station. Estimate [round(emergency_shuttle.estimate_arrival_time()/60,1)] minutes until the shuttle docks at Central Command.")
|
||||
..(origin, destination)
|
||||
|
||||
/datum/shuttle/ferry/emergency/launch(var/user)
|
||||
if (!can_launch()) return
|
||||
|
||||
if (istype(user, /obj/machinery/computer/shuttle_control/emergency)) //if we were given a command by an emergency shuttle console
|
||||
var/obj/machinery/computer/shuttle_control/emergency/C = user
|
||||
if (!C.has_authorization())
|
||||
return
|
||||
|
||||
if (emergency_shuttle.autopilot)
|
||||
emergency_shuttle.autopilot = 0
|
||||
world << "\blue <B>Alert: The shuttle autopilot has been overridden. Launch sequence initiated!</B>"
|
||||
|
||||
..(user)
|
||||
|
||||
/datum/shuttle/ferry/emergency/force_launch(var/user)
|
||||
if (!can_force()) return
|
||||
|
||||
if (istype(user, /obj/machinery/computer/shuttle_control/emergency)) //if we were given a command by an emergency shuttle console
|
||||
var/obj/machinery/computer/shuttle_control/emergency/C = user
|
||||
if (!C.has_authorization())
|
||||
return
|
||||
|
||||
if (emergency_shuttle.autopilot)
|
||||
emergency_shuttle.autopilot = 0
|
||||
world << "\blue <B>Alert: The shuttle autopilot has been overridden. Bluespace drive engaged!</B>"
|
||||
|
||||
..(user)
|
||||
|
||||
/datum/shuttle/ferry/emergency/cancel_launch(var/user)
|
||||
if (!can_cancel()) return
|
||||
|
||||
if (istype(user, /obj/machinery/computer/shuttle_control/emergency)) //if we were given a command by an emergency shuttle console
|
||||
var/obj/machinery/computer/shuttle_control/emergency/C = user
|
||||
if (!C.has_authorization())
|
||||
return
|
||||
|
||||
if (emergency_shuttle.autopilot)
|
||||
emergency_shuttle.autopilot = 0
|
||||
world << "\blue <B>Alert: The shuttle autopilot has been overridden. Launch sequence aborted!</B>"
|
||||
|
||||
..(user)
|
||||
|
||||
/obj/machinery/computer/shuttle_control/emergency
|
||||
shuttle_tag = "Escape"
|
||||
var/debug = 0
|
||||
var/req_authorizations = 3
|
||||
var/list/authorized = list()
|
||||
|
||||
/obj/machinery/computer/shuttle_control/emergency/proc/has_authorization()
|
||||
return (authorized.len >= req_authorizations || emagged)
|
||||
|
||||
//returns 1 if the ID was accepted and a new authorization was added, 0 otherwise
|
||||
/obj/machinery/computer/shuttle_control/emergency/proc/read_authorization(var/ident)
|
||||
if (authorized.len >= req_authorizations)
|
||||
return 0 //don't need any more
|
||||
|
||||
var/list/access
|
||||
var/auth_name
|
||||
var/dna_hash
|
||||
|
||||
if(istype(ident, /obj/item/weapon/card/id))
|
||||
var/obj/item/weapon/card/id/ID = ident
|
||||
access = ID.access
|
||||
auth_name = "[ID.registered_name] ([ID.assignment])"
|
||||
dna_hash = ID.dna_hash
|
||||
|
||||
if(istype(ident, /obj/item/device/pda))
|
||||
var/obj/item/device/pda/PDA = ident
|
||||
access = PDA.id.access
|
||||
auth_name = "[PDA.id.registered_name] ([PDA.id.assignment])"
|
||||
dna_hash = PDA.id.dna_hash
|
||||
|
||||
if (!access || !istype(access))
|
||||
return 0 //not an ID
|
||||
|
||||
if (dna_hash in authorized)
|
||||
src.visible_message("[src] buzzes. That ID has already been scanned.")
|
||||
return 0
|
||||
|
||||
if (!(access_heads in access))
|
||||
src.visible_message("[src] buzzes, rejecting [ident].")
|
||||
return 0
|
||||
|
||||
src.visible_message("[src] beeps as it scans [ident].")
|
||||
authorized[dna_hash] = auth_name
|
||||
if (req_authorizations - authorized.len)
|
||||
world << "\blue <B>Alert: [req_authorizations - authorized.len] authorization\s needed override the shuttle autopilot.</B>"
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
|
||||
/obj/machinery/computer/shuttle_control/emergency/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
if (istype(W, /obj/item/weapon/card/emag) && !emagged)
|
||||
user << "\blue You short out the [src]'s authorization protocols."
|
||||
emagged = 1
|
||||
return
|
||||
|
||||
read_authorization(W)
|
||||
..()
|
||||
|
||||
/obj/machinery/computer/shuttle_control/emergency/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
|
||||
var/data[0]
|
||||
var/datum/shuttle/ferry/emergency/shuttle = shuttle_controller.shuttles[shuttle_tag]
|
||||
if (!istype(shuttle))
|
||||
return
|
||||
|
||||
var/shuttle_state
|
||||
switch(shuttle.moving_status)
|
||||
if(SHUTTLE_IDLE) shuttle_state = "idle"
|
||||
if(SHUTTLE_WARMUP) shuttle_state = "warmup"
|
||||
if(SHUTTLE_INTRANSIT) shuttle_state = "in_transit"
|
||||
|
||||
var/shuttle_status
|
||||
switch (shuttle.process_state)
|
||||
if(IDLE_STATE)
|
||||
if (shuttle.in_use)
|
||||
shuttle_status = "Busy."
|
||||
else if (!shuttle.location)
|
||||
shuttle_status = "Standing-by at [station_name]."
|
||||
else
|
||||
shuttle_status = "Standing-by at Central Command."
|
||||
if(WAIT_LAUNCH)
|
||||
shuttle_status = "Shuttle has recieved command and will depart shortly."
|
||||
if(WAIT_ARRIVE)
|
||||
shuttle_status = "Proceeding to destination."
|
||||
if(WAIT_FINISH)
|
||||
shuttle_status = "Arriving at destination now."
|
||||
|
||||
//build a list of authorizations
|
||||
var/list/auth_list[req_authorizations]
|
||||
|
||||
if (!emagged)
|
||||
var/i = 1
|
||||
for (var/dna_hash in authorized)
|
||||
auth_list[i++] = list("auth_name"=authorized[dna_hash], "auth_hash"=dna_hash)
|
||||
|
||||
while (i <= req_authorizations) //for some reason dream maker gives warnings if you use for(; i <= req_authorizations; i++) here.
|
||||
auth_list[i++] = list("auth_name"="", "auth_hash"=-1)
|
||||
else
|
||||
for (var/i = 1; i <= req_authorizations; i++)
|
||||
auth_list[i] = list("auth_name"="<font color=\"red\">ERROR</font>", "auth_hash"=-1)
|
||||
|
||||
var/has_auth = has_authorization()
|
||||
|
||||
data = list(
|
||||
"shuttle_status" = shuttle_status,
|
||||
"shuttle_state" = shuttle_state,
|
||||
"has_docking" = shuttle.docking_controller? 1 : 0,
|
||||
"docking_status" = shuttle.docking_controller? shuttle.docking_controller.get_docking_status() : null,
|
||||
"docking_override" = shuttle.docking_controller? shuttle.docking_controller.override_enabled : null,
|
||||
"can_launch" = shuttle.can_launch() && has_auth,
|
||||
"can_cancel" = shuttle.can_cancel() && has_auth,
|
||||
"can_force" = shuttle.can_force() && has_auth,
|
||||
"auth_list" = auth_list,
|
||||
"has_auth" = has_auth,
|
||||
"user" = debug? user : null,
|
||||
)
|
||||
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data)
|
||||
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "escape_shuttle_control_console.tmpl", "Shuttle Control", 470, 380)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/obj/machinery/computer/shuttle_control/emergency/Topic(href, href_list)
|
||||
if(..())
|
||||
return
|
||||
|
||||
if(href_list["auth"])
|
||||
if (!emagged && href_list["auth"] == -1)
|
||||
//They selected an empty entry. Try to scan their id.
|
||||
if (ishuman(usr))
|
||||
var/mob/living/carbon/human/H = usr
|
||||
if (!read_authorization(H.get_active_hand())) //try to read what's in their hand first
|
||||
read_authorization(H.wear_id)
|
||||
else
|
||||
//remove the authorization
|
||||
var/dna_hash = href_list["auth"]
|
||||
authorized -= dna_hash
|
||||
|
||||
|
||||
|
||||
|
||||
/datum/shuttle/ferry/escape_pod
|
||||
//pass
|
||||
@@ -42,4 +247,4 @@
|
||||
|
||||
for(var/obj/machinery/door/D in destination)
|
||||
spawn(0)
|
||||
D.open()
|
||||
D.open()
|
||||
|
||||
Reference in New Issue
Block a user