mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-02-07 14:50:21 +00:00
Largely ported from the work done at Baystation in https://github.com/Baystation12/Baystation12/pull/17460 and later commits. - Shuttles no longer require a separate area for each location they jump to. Instead destinations are indicated by landmark objects, which are not necessarily exclusive to that shuttle. This means that more than one shuttle could use the same docking port (not at the same time of course). - Enhanced shuttle control computers to use nanoui if they didn't. - Organizes shuttle datum code a bit better so there is less re-inventing the wheel in subtypes. - Allows the possibility of shuttles (or destinations) that start on late-loaded maps. - Deprecate the "extra" shuttle areas that are no longer needed and update shuttle areas in unit tests This all required a bit of infrastructure improvements. - ChangeArea proc, for changing the area of a turf. - Fixed lighting overlays actually being able to be destroyed. - Added a few utility macros and procs. - Added "turf translation" procs which are like move_contents_to but more flexible.
145 lines
5.1 KiB
Plaintext
145 lines
5.1 KiB
Plaintext
/obj/machinery/computer/shuttle_control
|
|
name = "shuttle control console"
|
|
desc = "Used to control a linked shuttle."
|
|
icon_keyboard = "atmos_key"
|
|
icon_screen = "shuttle"
|
|
circuit = null
|
|
|
|
var/shuttle_tag // Used to coordinate data in shuttle controller.
|
|
var/hacked = 0 // Has been emagged, no access restrictions.
|
|
|
|
var/ui_template = "shuttle_control_console.tmpl"
|
|
|
|
|
|
/obj/machinery/computer/shuttle_control/attack_hand(user as mob)
|
|
if(..(user))
|
|
return
|
|
//src.add_fingerprint(user) //shouldn't need fingerprints just for looking at it.
|
|
if(!allowed(user))
|
|
to_chat(user, "<span class='warning'>Access Denied.</span>")
|
|
return 1
|
|
|
|
ui_interact(user)
|
|
|
|
/obj/machinery/computer/shuttle_control/proc/get_ui_data(var/datum/shuttle/autodock/shuttle)
|
|
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)
|
|
var/cannot_depart = shuttle.current_location.cannot_depart(shuttle)
|
|
if (shuttle.in_use)
|
|
shuttle_status = "Busy."
|
|
else if(cannot_depart)
|
|
shuttle_status = cannot_depart
|
|
else
|
|
shuttle_status = "Standing-by at \the [shuttle.get_location_name()]."
|
|
|
|
if(WAIT_LAUNCH, FORCE_LAUNCH)
|
|
shuttle_status = "Shuttle has received command and will depart shortly."
|
|
if(WAIT_ARRIVE)
|
|
shuttle_status = "Proceeding to \the [shuttle.get_destination_name()]."
|
|
if(WAIT_FINISH)
|
|
shuttle_status = "Arriving at destination now."
|
|
|
|
return list(
|
|
"shuttle_status" = shuttle_status,
|
|
"shuttle_state" = shuttle_state,
|
|
"has_docking" = shuttle.shuttle_docking_controller ? 1 : 0,
|
|
"docking_status" = shuttle.shuttle_docking_controller?.get_docking_status(),
|
|
"docking_override" = shuttle.shuttle_docking_controller?.override_enabled,
|
|
"can_launch" = shuttle.can_launch(),
|
|
"can_cancel" = shuttle.can_cancel(),
|
|
"can_force" = shuttle.can_force(),
|
|
"docking_codes" = shuttle.docking_codes
|
|
)
|
|
|
|
// This is a subset of the actual checks; contains those that give messages to the user.
|
|
// This enables us to give nice error messages as well as not even bother proceeding if we can't.
|
|
/obj/machinery/computer/shuttle_control/proc/can_move(var/datum/shuttle/autodock/shuttle, var/user)
|
|
var/cannot_depart = shuttle.current_location.cannot_depart(shuttle)
|
|
if(cannot_depart)
|
|
to_chat(user, "<span class='warning'>[cannot_depart]</span>")
|
|
log_shuttle("Shuttle [shuttle] cannot depart [shuttle.current_location] because: [cannot_depart].")
|
|
return FALSE
|
|
if(!shuttle.next_location.is_valid(shuttle))
|
|
to_chat(user, "<span class='warning'>Destination zone is invalid or obstructed.</span>")
|
|
log_shuttle("Shuttle [shuttle] destination [shuttle.next_location] is invalid.")
|
|
return FALSE
|
|
return TRUE
|
|
|
|
/obj/machinery/computer/shuttle_control/Topic(href, href_list)
|
|
if((. = ..()))
|
|
return
|
|
|
|
usr.set_machine(src)
|
|
src.add_fingerprint(usr)
|
|
|
|
var/datum/shuttle/autodock/shuttle = SSshuttles.shuttles[shuttle_tag]
|
|
if(!shuttle)
|
|
to_chat(usr, "<span class='warning'>Unable to establish link with the shuttle.</span>")
|
|
return handle_topic_href(shuttle, href_list, usr)
|
|
|
|
/obj/machinery/computer/shuttle_control/proc/handle_topic_href(var/datum/shuttle/autodock/shuttle, var/list/href_list, var/user)
|
|
if(!istype(shuttle))
|
|
return TOPIC_NOACTION
|
|
|
|
if(href_list["move"])
|
|
if(can_move(shuttle, user))
|
|
shuttle.launch(src)
|
|
return TOPIC_REFRESH
|
|
return TOPIC_HANDLED
|
|
|
|
if(href_list["force"])
|
|
if(can_move(shuttle, user))
|
|
shuttle.force_launch(src)
|
|
return TOPIC_REFRESH
|
|
return TOPIC_HANDLED
|
|
|
|
if(href_list["cancel"])
|
|
shuttle.cancel_launch(src)
|
|
return TOPIC_REFRESH
|
|
|
|
if(href_list["set_codes"])
|
|
var/newcode = input("Input new docking codes", "Docking codes", shuttle.docking_codes) as text|null
|
|
if (newcode && CanInteract(usr, global.default_state))
|
|
shuttle.set_docking_codes(uppertext(newcode))
|
|
return TOPIC_REFRESH
|
|
|
|
// We delegate populating data to another proc to make it easier for overriding types to add their data.
|
|
/obj/machinery/computer/shuttle_control/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
|
var/datum/shuttle/autodock/shuttle = SSshuttles.shuttles[shuttle_tag]
|
|
if (!istype(shuttle))
|
|
to_chat(user, "<span class='warning'>Unable to establish link with the shuttle.</span>")
|
|
return
|
|
|
|
var/list/data = get_ui_data(shuttle)
|
|
|
|
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
|
if (!ui)
|
|
ui = new(user, src, ui_key, ui_template, "[shuttle_tag] Shuttle Control", 470, 310)
|
|
ui.set_initial_data(data)
|
|
ui.open()
|
|
ui.set_auto_update(1)
|
|
|
|
/obj/machinery/computer/shuttle_control/emag_act(var/remaining_charges, var/mob/user)
|
|
if (!hacked)
|
|
req_access = list()
|
|
req_one_access = list()
|
|
hacked = 1
|
|
to_chat(user, "You short out the console's ID checking system. It's now available to everyone!")
|
|
return 1
|
|
|
|
/obj/machinery/computer/shuttle_control/bullet_act(var/obj/item/projectile/Proj)
|
|
visible_message("\The [Proj] ricochets off \the [src]!")
|
|
|
|
/obj/machinery/computer/shuttle_control/ex_act()
|
|
return
|
|
|
|
/obj/machinery/computer/shuttle_control/emp_act()
|
|
return
|