mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-11 23:23:28 +01:00
Shuttles now dock on arrival and departure
Squashes 3 commits: Shuttles now dock on arrival and departure Adds docking controller to outpost, tweaks Finishes off shuttle_console Could use some cleanup, though. Commented out the debug stuff. Conflicts: code/controllers/master_controller.dm code/game/machinery/embedded_controller/docking_program.dm code/game/machinery/embedded_controller/simple_docking_controller.dm code/modules/shuttles/shuttle.dm maps/tgstation2.dmm
This commit is contained in:
@@ -33,6 +33,8 @@ datum/controller/game_controller
|
||||
|
||||
var/last_thing_processed
|
||||
|
||||
var/list/shuttle_list //for debugging and VV
|
||||
|
||||
datum/controller/game_controller/New()
|
||||
//There can be only one master_controller. Out with the old and in with the new.
|
||||
if(master_controller != src)
|
||||
@@ -70,6 +72,7 @@ datum/controller/game_controller/proc/setup()
|
||||
garbage = new /datum/controller/garbage_collector()
|
||||
|
||||
if(!shuttles) setup_shuttles()
|
||||
shuttle_list = shuttles
|
||||
|
||||
setup_objects()
|
||||
setupgenetics()
|
||||
|
||||
@@ -23,7 +23,11 @@
|
||||
|
||||
MODE_NONE|STATE_UNDOCKED idle - not docked.
|
||||
MODE_NONE|anything else should never happen.
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
|
||||
>>>>>>> ed4fb8d... Shuttles now dock on arrival and departure
|
||||
*/
|
||||
|
||||
|
||||
@@ -169,6 +173,14 @@
|
||||
tag_target = null
|
||||
response_sent = 0
|
||||
|
||||
/datum/computer/file/embedded_program/docking/proc/force_undock()
|
||||
if (tag_target)
|
||||
send_docking_command(tag_target, "dock_error")
|
||||
reset()
|
||||
|
||||
/datum/computer/file/embedded_program/docking/proc/docked()
|
||||
return (dock_state == STATE_DOCKED)
|
||||
|
||||
/datum/computer/file/embedded_program/docking/proc/undocked()
|
||||
return (dock_state == STATE_UNDOCKED)
|
||||
|
||||
|
||||
@@ -28,17 +28,17 @@
|
||||
/obj/machinery/embedded_controller/radio/simple_docking_controller/Topic(href, href_list)
|
||||
if(..())
|
||||
return
|
||||
|
||||
|
||||
usr.set_machine(src)
|
||||
src.add_fingerprint(usr)
|
||||
|
||||
|
||||
var/clean = 0
|
||||
switch(href_list["command"]) //anti-HTML-hacking checks
|
||||
if("force_door")
|
||||
clean = 1
|
||||
if("toggle_override")
|
||||
clean = 1
|
||||
|
||||
|
||||
if(clean)
|
||||
program.receive_user_command(href_list["command"])
|
||||
|
||||
@@ -56,24 +56,24 @@
|
||||
|
||||
if (istype(M, /obj/machinery/embedded_controller/radio/simple_docking_controller))
|
||||
var/obj/machinery/embedded_controller/radio/simple_docking_controller/controller = M
|
||||
|
||||
|
||||
tag_door = controller.tag_door
|
||||
|
||||
|
||||
spawn(10)
|
||||
signal_door("update") //signals connected doors to update their status
|
||||
|
||||
|
||||
|
||||
|
||||
/datum/computer/file/embedded_program/docking/simple/receive_signal(datum/signal/signal, receive_method, receive_param)
|
||||
var/receive_tag = signal.data["tag"]
|
||||
|
||||
|
||||
if(!receive_tag) return
|
||||
|
||||
|
||||
if(receive_tag==tag_door)
|
||||
memory["door_status"]["state"] = signal.data["door_status"]
|
||||
memory["door_status"]["lock"] = signal.data["lock_status"]
|
||||
|
||||
|
||||
..(signal, receive_method, receive_param)
|
||||
|
||||
|
||||
/datum/computer/file/embedded_program/docking/simple/receive_user_command(command)
|
||||
switch(command)
|
||||
if("force_door")
|
||||
@@ -157,4 +157,4 @@
|
||||
set category = "Debug"
|
||||
set src in view(1)
|
||||
src.program:initiate_undocking()
|
||||
*/
|
||||
*/
|
||||
@@ -11,18 +11,25 @@ var/global/list/shuttles
|
||||
var/location = 0 //0 = at area_station, 1 = at area_offsite
|
||||
var/warmup_time = 0
|
||||
var/moving_status = SHUTTLE_IDLE //prevents people from doing things they shouldn't when the shuttle is in transit
|
||||
var/in_use = 0 //prevents people from controlling the shuttle from different consoles at the same time
|
||||
var/in_use = 0 //this mutex ensures that only one console can be doing things with the shuttle at a time.
|
||||
var/area_station
|
||||
var/area_offsite
|
||||
|
||||
var/docking_controller = null
|
||||
var/list/docking_targets = list()
|
||||
var/docking_controller_tag //tag of the controller used to coordinate docking
|
||||
var/datum/computer/file/embedded_program/docking/docking_controller //the controller itself
|
||||
//TODO: change location to a string and use a mapping for area and dock targets.
|
||||
var/dock_target_station
|
||||
var/dock_target_offsite
|
||||
|
||||
|
||||
/datum/shuttle/proc/short_jump(var/datum/shuttle/shuttle,var/area/origin,var/area/destination)
|
||||
if(moving_status != SHUTTLE_IDLE) return
|
||||
|
||||
moving_status = SHUTTLE_WARMUP
|
||||
spawn(warmup_time*10)
|
||||
if (moving_status == SHUTTLE_IDLE)
|
||||
return //someone cancelled the launch
|
||||
|
||||
move(origin, destination)
|
||||
moving_status = SHUTTLE_IDLE
|
||||
|
||||
@@ -32,6 +39,9 @@ var/global/list/shuttles
|
||||
moving_status = SHUTTLE_WARMUP
|
||||
|
||||
spawn(warmup_time*10)
|
||||
if (moving_status == SHUTTLE_IDLE)
|
||||
return //someone cancelled the launch
|
||||
|
||||
move(locate(departing),locate(interim))
|
||||
|
||||
sleep(travel_time)
|
||||
@@ -40,6 +50,31 @@ var/global/list/shuttles
|
||||
|
||||
moving_status = SHUTTLE_IDLE
|
||||
|
||||
|
||||
/datum/shuttle/proc/dock()
|
||||
if (!docking_controller)
|
||||
return
|
||||
|
||||
var/dock_target = current_dock_target()
|
||||
if (!dock_target)
|
||||
return
|
||||
|
||||
docking_controller.initiate_docking(dock_target)
|
||||
|
||||
/datum/shuttle/proc/undock()
|
||||
if (!docking_controller)
|
||||
return
|
||||
|
||||
docking_controller.initiate_undocking()
|
||||
|
||||
/datum/shuttle/proc/current_dock_target()
|
||||
var/dock_target
|
||||
if (!location) //station
|
||||
dock_target = dock_target_station
|
||||
else
|
||||
dock_target = dock_target_offsite
|
||||
return dock_target
|
||||
|
||||
//just moves the shuttle from A to B, if it can be moved
|
||||
/datum/shuttle/proc/move(var/area/origin,var/area/destination)
|
||||
|
||||
@@ -115,6 +150,8 @@ var/global/list/shuttles
|
||||
|
||||
|
||||
/proc/setup_shuttles()
|
||||
shuttles = list()
|
||||
|
||||
var/datum/shuttle/shuttle
|
||||
|
||||
//Supply and escape shuttles.
|
||||
@@ -122,7 +159,6 @@ var/global/list/shuttles
|
||||
shuttle.location = 1
|
||||
shuttle.area_offsite = locate(/area/supply/dock)
|
||||
shuttle.area_station = locate(/area/supply/station)
|
||||
shuttle.docking_targets = list(null, null)
|
||||
shuttles["Supply"] = shuttle
|
||||
|
||||
// Admin shuttles.
|
||||
@@ -130,20 +166,17 @@ var/global/list/shuttles
|
||||
shuttle.location = 1
|
||||
shuttle.area_offsite = locate(/area/shuttle/transport1/centcom)
|
||||
shuttle.area_station = locate(/area/shuttle/transport1/station)
|
||||
shuttle.docking_targets = list(null, null)
|
||||
shuttles["Centcom"] = shuttle
|
||||
|
||||
shuttle = new/datum/shuttle()
|
||||
shuttle.location = 1
|
||||
shuttle.area_offsite = locate(/area/shuttle/administration/centcom)
|
||||
shuttle.area_station = locate(/area/shuttle/administration/station)
|
||||
shuttle.docking_targets = list(null, null)
|
||||
shuttles["Administration"] = shuttle
|
||||
|
||||
shuttle = new/datum/shuttle()
|
||||
shuttle.area_offsite = locate(/area/shuttle/alien/base)
|
||||
shuttle.area_station = locate(/area/shuttle/alien/mine)
|
||||
shuttle.docking_targets = list(null, null)
|
||||
shuttles["Alien"] = shuttle
|
||||
|
||||
// Public shuttles
|
||||
@@ -152,21 +185,21 @@ var/global/list/shuttles
|
||||
shuttle.warmup_time = 10
|
||||
shuttle.area_offsite = locate(/area/shuttle/constructionsite/site)
|
||||
shuttle.area_station = locate(/area/shuttle/constructionsite/station)
|
||||
shuttle.docking_targets = list(null, null)
|
||||
shuttles["Engineering"] = shuttle
|
||||
|
||||
shuttle = new/datum/shuttle()
|
||||
shuttle.warmup_time = 10
|
||||
shuttle.area_offsite = locate(/area/shuttle/mining/outpost)
|
||||
shuttle.area_station = locate(/area/shuttle/mining/station)
|
||||
shuttle.docking_targets = list(null, null)
|
||||
shuttles["Mining"] = shuttle
|
||||
|
||||
shuttle = new/datum/shuttle()
|
||||
shuttle.warmup_time = 10
|
||||
shuttle.area_offsite = locate(/area/shuttle/research/outpost)
|
||||
shuttle.area_station = locate(/area/shuttle/research/station)
|
||||
shuttle.docking_targets = list(null, null)
|
||||
shuttle.docking_controller_tag = "research_shuttle"
|
||||
shuttle.dock_target_station = "research_dock_airlock"
|
||||
shuttle.dock_target_offsite = "research_outpost_dock"
|
||||
shuttles["Research"] = shuttle
|
||||
|
||||
//Vox Shuttle.
|
||||
@@ -210,3 +243,33 @@ var/global/list/shuttles
|
||||
MS.warmup_time = 10
|
||||
shuttles["Syndicate"] = MS
|
||||
|
||||
|
||||
/proc/setup_shuttle_docks()
|
||||
var/datum/shuttle/shuttle
|
||||
var/list/dock_controller_map = list() //so we only have to iterate once through each list
|
||||
|
||||
for (var/shuttle_tag in shuttles)
|
||||
shuttle = shuttles[shuttle_tag]
|
||||
if (shuttle.docking_controller_tag)
|
||||
dock_controller_map[shuttle.docking_controller_tag] = shuttle
|
||||
|
||||
//search for the controllers, if we have one.
|
||||
if (dock_controller_map.len)
|
||||
for (var/obj/machinery/embedded_controller/radio/C in machines) //only radio controllers are supported at the moment
|
||||
if (istype(C.program, /datum/computer/file/embedded_program/docking) && C.id_tag in dock_controller_map)
|
||||
shuttle = dock_controller_map[C.id_tag]
|
||||
shuttle.docking_controller = C.program
|
||||
dock_controller_map -= C.id_tag
|
||||
|
||||
//sanity check
|
||||
if (dock_controller_map.len)
|
||||
var/dat = ""
|
||||
for (var/dock_tag in dock_controller_map)
|
||||
dat += "\"[dock_tag]\", "
|
||||
world << "/red /b warning: shuttles with docking tags [dat] could not find their controllers!"
|
||||
|
||||
//makes all shuttles docked to something at round start go into the docked state
|
||||
for (var/shuttle_tag in shuttles)
|
||||
shuttle = shuttles[shuttle_tag]
|
||||
shuttle.dock()
|
||||
|
||||
|
||||
@@ -1,42 +1,125 @@
|
||||
#define STATUS_IDLE
|
||||
#define STATUS_LAUNCH
|
||||
#define STATUS_ARRIVE
|
||||
#define IDLE_STATE 0
|
||||
#define WAIT_LAUNCH 1
|
||||
#define WAIT_ARRIVE 2
|
||||
#define WAIT_FINISH 3
|
||||
|
||||
|
||||
/*
|
||||
I dont really like how much this manipulates shuttle it's docking controller, as it makes this code
|
||||
depend a lot on their current implementation, and also having var/datum/shuttle/shuttle = shuttles[shuttle_tag]
|
||||
everywhere is kind of messy. I'm probably going to end up creating a subtype of shuttle called ferry_shuttle
|
||||
and move a lot of this into there when I get the time.
|
||||
*/
|
||||
/obj/machinery/computer/shuttle_control
|
||||
name = "shuttle control console"
|
||||
icon = 'icons/obj/computer.dmi'
|
||||
icon_state = "shuttle"
|
||||
req_access = list(access_engine)
|
||||
circuit = "/obj/item/weapon/circuitboard/engineering_shuttle"
|
||||
|
||||
//for mapping
|
||||
|
||||
var/shuttle_tag // Used to coordinate data in shuttle controller.
|
||||
var/datum/shuttle/shuttle
|
||||
var/docking_controller_tag //tag of the controller used to coordinate docking
|
||||
|
||||
var/datum/computer/file/embedded_program/docking/docking_controller //the controller itself
|
||||
var/hacked = 0 // Has been emagged, no access restrictions.
|
||||
|
||||
/obj/machinery/computer/shuttle_control/initialize()
|
||||
shuttle = shuttles[shuttle_tag]
|
||||
|
||||
//search for our controller, if we have one.
|
||||
if (docking_controller_tag)
|
||||
for (var/obj/machinery/embedded_controller/radio/C in machines) //only radio controllers are supported, for now...
|
||||
if (C.id_tag == docking_controller_tag && istype(C.program, /datum/computer/file/embedded_program/docking))
|
||||
docking_controller = C.program
|
||||
|
||||
var/process_state = IDLE_STATE
|
||||
|
||||
/obj/machinery/computer/shuttle_control/proc/launch_shuttle()
|
||||
if (!can_launch()) return
|
||||
|
||||
var/datum/shuttle/shuttle = shuttles[shuttle_tag]
|
||||
|
||||
shuttle.in_use = 1 //obtain an exclusive lock on the shuttle
|
||||
|
||||
process_state = WAIT_LAUNCH
|
||||
shuttle.undock()
|
||||
|
||||
/obj/machinery/computer/shuttle_control/proc/cancel_launch()
|
||||
if (!can_cancel()) return
|
||||
|
||||
var/datum/shuttle/shuttle = shuttles[shuttle_tag]
|
||||
|
||||
shuttle.moving_status = SHUTTLE_IDLE
|
||||
process_state = WAIT_FINISH
|
||||
|
||||
if (shuttle.docking_controller && !shuttle.docking_controller.undocked())
|
||||
shuttle.docking_controller.force_undock()
|
||||
shuttle.dock()
|
||||
|
||||
shuttle.in_use = 0
|
||||
|
||||
return
|
||||
|
||||
/obj/machinery/computer/shuttle_control/proc/toggle_override()
|
||||
if (!can_override()) return
|
||||
|
||||
var/datum/shuttle/shuttle = shuttles[shuttle_tag]
|
||||
|
||||
if (shuttle.docking_controller.override_enabled)
|
||||
shuttle.docking_controller.disable_override()
|
||||
else
|
||||
shuttle.docking_controller.enable_override()
|
||||
|
||||
/obj/machinery/computer/shuttle_control/proc/can_launch()
|
||||
var/datum/shuttle/shuttle = shuttles[shuttle_tag]
|
||||
|
||||
if (shuttle.moving_status != SHUTTLE_IDLE)
|
||||
return 0
|
||||
|
||||
if (shuttle.in_use && !skip_checks())
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
/obj/machinery/computer/shuttle_control/proc/can_cancel()
|
||||
var/datum/shuttle/shuttle = shuttles[shuttle_tag]
|
||||
|
||||
if (shuttle.moving_status == SHUTTLE_WARMUP || process_state == WAIT_LAUNCH)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/machinery/computer/shuttle_control/proc/can_override()
|
||||
var/datum/shuttle/shuttle = shuttles[shuttle_tag]
|
||||
|
||||
if (shuttle.docking_controller && (!shuttle.docking_controller.override_enabled || !shuttle.in_use))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
//TODO move this stuff into the shuttle datum itself, instead of manipulating the shuttle's members
|
||||
/obj/machinery/computer/shuttle_control/process()
|
||||
/*
|
||||
switch (launch_status)
|
||||
if (!shuttles || !(shuttle_tag in shuttles))
|
||||
return
|
||||
|
||||
if (wait_for_launch)
|
||||
if (docking_controller && docking_controller.can_launch())
|
||||
shuttles.jump_shuttle(shuttle_tag)
|
||||
wait_for_launch = 0
|
||||
*/
|
||||
var/datum/shuttle/shuttle = shuttles[shuttle_tag]
|
||||
|
||||
switch(process_state)
|
||||
if (WAIT_LAUNCH)
|
||||
if (skip_checks() || shuttle.docking_controller.can_launch())
|
||||
shuttle.short_jump()
|
||||
if (shuttle.docking_controller && !shuttle.docking_controller.undocked())
|
||||
shuttle.docking_controller.force_undock()
|
||||
process_state = WAIT_ARRIVE
|
||||
if (WAIT_ARRIVE)
|
||||
if (shuttle.moving_status == SHUTTLE_IDLE)
|
||||
shuttle.dock()
|
||||
process_state = WAIT_FINISH
|
||||
if (WAIT_FINISH)
|
||||
if (skip_checks() || shuttle.docking_controller.docked())
|
||||
process_state = IDLE_STATE
|
||||
shuttle.in_use = 0 //release lock
|
||||
|
||||
/obj/machinery/computer/shuttle_control/proc/skip_checks()
|
||||
var/datum/shuttle/shuttle = shuttles[shuttle_tag]
|
||||
|
||||
if (!shuttle.docking_controller || !shuttle.current_dock_target())
|
||||
return 1 //shuttles without docking controllers or at locations without docking ports act like old-style shuttles
|
||||
|
||||
return shuttle.docking_controller.override_enabled //override pretty much lets you do whatever you want
|
||||
|
||||
|
||||
/obj/machinery/computer/shuttle_control/Del()
|
||||
var/datum/shuttle/shuttle = shuttles[shuttle_tag]
|
||||
|
||||
if (process_state != IDLE_STATE)
|
||||
shuttle.in_use = 0 //shuttle may not dock properly if this gets deleted while in transit, but its not a big deal
|
||||
|
||||
/obj/machinery/computer/shuttle_control/attack_hand(user as mob)
|
||||
if(..(user))
|
||||
@@ -45,9 +128,9 @@
|
||||
|
||||
ui_interact(user)
|
||||
|
||||
|
||||
/obj/machinery/computer/shuttle_control/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
|
||||
var/data[0]
|
||||
var/datum/shuttle/shuttle = shuttles[shuttle_tag]
|
||||
|
||||
var/shuttle_state
|
||||
switch(shuttle.moving_status)
|
||||
@@ -55,44 +138,56 @@
|
||||
if(SHUTTLE_WARMUP) shuttle_state = "warmup"
|
||||
if(SHUTTLE_INTRANSIT) shuttle_state = "in_transit"
|
||||
|
||||
if (docking_controller)
|
||||
data = list(
|
||||
"shuttle_state" = shuttle_state,
|
||||
"shuttle_loc" = shuttle.location,
|
||||
"has_docking" = 1,
|
||||
"docking_status" = docking_controller.get_docking_status(),
|
||||
"override_enabled" = docking_controller.override_enabled,
|
||||
)
|
||||
else
|
||||
data = list(
|
||||
"shuttle_state" = shuttle_state,
|
||||
"shuttle_loc" = shuttle.location,
|
||||
"has_docking" = 0,
|
||||
"docking_status" = null,
|
||||
"override_enabled" = null,
|
||||
)
|
||||
var/shuttle_status
|
||||
switch (process_state)
|
||||
if(IDLE_STATE)
|
||||
if (shuttle.in_use)
|
||||
shuttle_status = "Busy."
|
||||
else if (!shuttle.location)
|
||||
shuttle_status = "Standing-by at station."
|
||||
else
|
||||
shuttle_status = "Standing-by at offsite location."
|
||||
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."
|
||||
|
||||
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,
|
||||
"override_enabled" = shuttle.docking_controller? shuttle.docking_controller.override_enabled : null,
|
||||
"can_launch" = can_launch(),
|
||||
"can_cancel" = can_cancel(),
|
||||
"can_override" = can_override(),
|
||||
)
|
||||
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data)
|
||||
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "shuttle_control_console.tmpl", "[shuttle_tag] Shuttle Control", 470, 290)
|
||||
ui = new(user, src, ui_key, "shuttle_control_console.tmpl", "[shuttle_tag] Shuttle Control", 470, 310)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
//TODO: Canceling launches
|
||||
//TODO: Canceling launches, dock overrides using the console, forcing dock/undock
|
||||
/obj/machinery/computer/shuttle_control/Topic(href, href_list)
|
||||
if(..())
|
||||
return
|
||||
|
||||
usr.set_machine(src)
|
||||
src.add_fingerprint(usr)
|
||||
|
||||
|
||||
if(href_list["move"])
|
||||
if (shuttle.moving_status == SHUTTLE_IDLE)
|
||||
usr << "\blue [shuttle_tag] Shuttle recieved message and will be sent shortly."
|
||||
shuttle.short_jump()
|
||||
else
|
||||
usr << "\blue [shuttle_tag] Shuttle is already moving."
|
||||
launch_shuttle()
|
||||
else if(href_list["cancel"])
|
||||
cancel_launch()
|
||||
else if(href_list["override"])
|
||||
toggle_override()
|
||||
|
||||
|
||||
/obj/machinery/computer/shuttle_control/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
@@ -107,13 +202,8 @@
|
||||
/obj/machinery/computer/shuttle_control/bullet_act(var/obj/item/projectile/Proj)
|
||||
visible_message("[Proj] ricochets off [src]!")
|
||||
|
||||
//makes all shuttles docked to something at round start go into the docked state
|
||||
/proc/setup_shuttle_docks()
|
||||
var/list/setup_complete = list() //so we dont setup the same shuttle repeatedly
|
||||
|
||||
for (var/obj/machinery/computer/shuttle_control/SC in machines)
|
||||
var/dock_target = SC.shuttle.docking_targets[SC.shuttle.location+1] //damned byond is 1-indexed - don't forget
|
||||
|
||||
if (!(SC.shuttle_tag in setup_complete) && SC.docking_controller && dock_target)
|
||||
SC.docking_controller.initiate_docking(dock_target)
|
||||
setup_complete += SC.shuttle_tag
|
||||
#undef IDLE_STATE
|
||||
#undef WAIT_LAUNCH
|
||||
#undef WAIT_ARRIVE
|
||||
#undef WAIT_FINISH
|
||||
|
||||
|
||||
Reference in New Issue
Block a user