mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-18 10:31:41 +01:00
a253fcba9c
* rearrange files * Squashed commit of the following: commitec32b5b6e9Author: DreamySkrell <> Date: Sat Oct 28 22:32:05 2023 +0200 ccc commitbe750e672dAuthor: DreamySkrell <> Date: Sat Oct 28 22:01:02 2023 +0200 cc commit1ecd9afb6cAuthor: DreamySkrell <> Date: Sat Oct 28 21:57:38 2023 +0200 c commit159d1000d9Author: DreamySkrell <> Date: Sat Oct 28 21:40:40 2023 +0200 nav_ert_dock kill commitb767a2574aAuthor: DreamySkrell <> Date: Sat Oct 28 21:24:34 2023 +0200 a commitaa01eec1fcAuthor: DreamySkrell <> Date: Sat Oct 28 21:09:48 2023 +0200 NAV_HORIZON_DOCK_ALL commit4564bfd29fAuthor: DreamySkrell <> Date: Sat Oct 28 20:55:45 2023 +0200 burglar and raider to use NAV_HORIZON_EXTERIOR_ALL_DECKS and SNEAKY commitec7564fcb1Author: DreamySkrell <> Date: Sat Oct 28 20:43:17 2023 +0200 merc shuttle to use NAV_HORIZON_EXTERIOR_ALL_DECKS commitd306934a73Author: DreamySkrell <> Date: Fri Oct 27 00:00:41 2023 +0200 fix merc and skipjack area/template_noop commit0600a348cdAuthor: DreamySkrell <> Date: Thu Oct 26 22:28:45 2023 +0200 merc ship generic dock landmark huh commitc9850622f9Author: DreamySkrell <> Date: Thu Oct 26 20:37:55 2023 +0200 sane landmark tags commit56d9052270Author: DreamySkrell <> Date: Thu Oct 26 20:11:55 2023 +0200 /horizon/dock/deck_3/port_3 commit846d737c94Author: DreamySkrell <> Date: Thu Oct 26 20:03:17 2023 +0200 landmark/horizon/deck -> landmark/horizon/exterior/deck commitef5c3d1b09Author: DreamySkrell <> Date: Thu Oct 26 20:02:17 2023 +0200 landmark/horizon/dock -> landmark/horizon/dock/deck_3/... commit1716ef26a8Author: DreamySkrell <> Date: Thu Oct 26 19:54:21 2023 +0200 docks ruler helpers commit18c66a3124Author: DreamySkrell <> Date: Thu Oct 26 19:47:27 2023 +0200 a commit0f2fc4524cAuthor: DreamySkrell <> Date: Thu Oct 26 19:43:19 2023 +0200 horizon/nav -> horizon/hangar commite13a5233d1Author: DreamySkrell <> Date: Thu Oct 26 19:41:08 2023 +0200 sccv_horizon_shuttle_landmarks.dm * Squashed commit of the following: commit4d7052be3bAuthor: DreamySkrell <> Date: Sun Oct 29 14:18:40 2023 +0100 tests rerun please commitae04980347Author: DreamySkrell <> Date: Sun Oct 29 13:25:26 2023 +0100 oops commit176ea80155Author: DreamySkrell <> Date: Sun Oct 29 12:54:25 2023 +0100 tests rerun please commit5cf7db9162Author: DreamySkrell <> Date: Sun Oct 29 12:45:07 2023 +0100 c commitf93887a1efAuthor: DreamySkrell <> Date: Sun Oct 29 12:43:47 2023 +0100 jjjjjjjjjjjj commit697542a270Author: DreamySkrell <> Date: Sun Oct 29 12:25:32 2023 +0100 a commita83373a62aAuthor: DreamySkrell <> Date: Sun Oct 29 12:17:47 2023 +0100 ay commitbaf447a694Author: DreamySkrell <> Date: Sun Oct 29 11:05:38 2023 +0100 a * sprites * code and mapping wip... * huhhhh * agony * docs idk * intrepid idk * almost working... * i fucking love docks * 568 * m * kkkkkkkkkkkkkkk * helper in own file * a * tags * huh * a * 1 pixel * intrepid mf * spark mf * access * guidelines * g * gd * hnyfgjdtjtsdyjdtyj * m * c * a * fix canary and ert shuttle docking controller tags * huhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh * remove old changelogs * sprite * bad docs removal --------- Co-authored-by: DreamySkrell <>
196 lines
6.0 KiB
Plaintext
196 lines
6.0 KiB
Plaintext
#define DOCK_ATTEMPT_TIMEOUT 200 //how long in ticks we wait before assuming the docking controller is broken or blown up.
|
|
|
|
/datum/shuttle/autodock
|
|
var/in_use = null //tells the controller whether this shuttle needs processing, also attempts to prevent double-use
|
|
var/last_dock_attempt_time = 0
|
|
var/current_dock_target
|
|
|
|
/// `id_tag`/`master_tag` of the docking controller of this shuttle.
|
|
var/dock_target = null
|
|
|
|
var/obj/effect/shuttle_landmark/next_location
|
|
var/datum/computer/file/embedded_program/docking/active_docking_controller
|
|
|
|
var/obj/effect/shuttle_landmark/landmark_transition
|
|
var/move_time = 240 //the time spent in the transition area
|
|
var/minimum_move_time = 15 //the time spent in the transition area when both of the locations are located on station z-levels
|
|
|
|
category = /datum/shuttle/autodock
|
|
flags = SHUTTLE_FLAGS_PROCESS | SHUTTLE_FLAGS_ZERO_G
|
|
|
|
/datum/shuttle/autodock/New(var/_name, var/obj/effect/shuttle_landmark/start_waypoint)
|
|
..(_name, start_waypoint)
|
|
|
|
//Initial dock
|
|
update_docking_target(current_location)
|
|
active_docking_controller = current_location.docking_controller
|
|
current_dock_target = get_docking_target(current_location)
|
|
dock()
|
|
|
|
//Optional transition area
|
|
if(landmark_transition)
|
|
landmark_transition = SSshuttle.get_landmark(landmark_transition)
|
|
|
|
/datum/shuttle/autodock/Destroy()
|
|
next_location = null
|
|
active_docking_controller = null
|
|
landmark_transition = null
|
|
|
|
return ..()
|
|
|
|
/datum/shuttle/autodock/shuttle_moved()
|
|
force_undock() //bye!
|
|
..()
|
|
|
|
/datum/shuttle/autodock/proc/update_docking_target(var/obj/effect/shuttle_landmark/location)
|
|
if(location && location.special_dock_targets && location.special_dock_targets[name])
|
|
current_dock_target = location.special_dock_targets[name]
|
|
else
|
|
current_dock_target = dock_target
|
|
active_docking_controller = SSshuttle.docking_registry[current_dock_target]
|
|
|
|
/datum/shuttle/autodock/proc/get_docking_target(var/obj/effect/shuttle_landmark/location)
|
|
if(location && location.special_dock_targets)
|
|
if(location.special_dock_targets[name])
|
|
return location.special_dock_targets[name]
|
|
return dock_target
|
|
/*
|
|
Docking stuff
|
|
*/
|
|
/datum/shuttle/autodock/proc/dock()
|
|
if(active_docking_controller)
|
|
active_docking_controller.initiate_docking(current_dock_target)
|
|
last_dock_attempt_time = world.time
|
|
|
|
/datum/shuttle/autodock/proc/undock()
|
|
if(active_docking_controller)
|
|
active_docking_controller.initiate_undocking()
|
|
|
|
/datum/shuttle/autodock/proc/force_undock()
|
|
if(active_docking_controller)
|
|
active_docking_controller.force_undock()
|
|
|
|
/datum/shuttle/autodock/proc/check_docked()
|
|
if(active_docking_controller)
|
|
return active_docking_controller.docked()
|
|
return TRUE
|
|
|
|
/datum/shuttle/autodock/proc/check_undocked()
|
|
if(active_docking_controller)
|
|
return active_docking_controller.can_launch()
|
|
return TRUE
|
|
|
|
/*
|
|
Please ensure that long_jump() and short_jump() are only called from here. This applies to subtypes as well.
|
|
Doing so will ensure that multiple jumps cannot be initiated in parallel.
|
|
*/
|
|
/datum/shuttle/autodock/process()
|
|
switch(process_state)
|
|
if (WAIT_LAUNCH)
|
|
if(check_undocked())
|
|
//*** ready to go
|
|
if(next_location.is_valid(src))
|
|
process_launch()
|
|
set_process_state(WAIT_ARRIVE)
|
|
else
|
|
set_process_state(IDLE_STATE)
|
|
in_use = null
|
|
|
|
if (FORCE_LAUNCH)
|
|
process_launch()
|
|
|
|
if (WAIT_ARRIVE)
|
|
if (moving_status == SHUTTLE_IDLE)
|
|
//*** we made it to the destination, update stuff
|
|
process_arrived()
|
|
set_process_state(WAIT_FINISH)
|
|
|
|
if (WAIT_FINISH)
|
|
if (world.time > last_dock_attempt_time + DOCK_ATTEMPT_TIMEOUT || check_docked())
|
|
//*** all done here
|
|
set_process_state(IDLE_STATE)
|
|
arrived()
|
|
|
|
//not to be confused with the arrived() proc
|
|
/datum/shuttle/autodock/proc/process_arrived()
|
|
update_docking_target(next_location)
|
|
active_docking_controller = next_location.docking_controller
|
|
current_dock_target = get_docking_target(next_location)
|
|
dock()
|
|
|
|
next_location = null
|
|
in_use = null //release lock
|
|
|
|
/datum/shuttle/autodock/proc/get_travel_time()
|
|
if(isStationLevel(current_location.loc.z) && isStationLevel(next_location.loc.z) && move_time > minimum_move_time)
|
|
return minimum_move_time
|
|
else
|
|
return move_time
|
|
|
|
/datum/shuttle/autodock/proc/process_launch()
|
|
if(!next_location.is_valid(src) || current_location.cannot_depart(src))
|
|
set_process_state(IDLE_STATE)
|
|
in_use = null
|
|
return
|
|
if (get_travel_time() && landmark_transition)
|
|
long_jump(next_location, landmark_transition, get_travel_time())
|
|
else
|
|
short_jump(next_location)
|
|
set_process_state(WAIT_ARRIVE)
|
|
|
|
/*
|
|
Guards
|
|
*/
|
|
/datum/shuttle/autodock/proc/can_launch()
|
|
return (next_location && moving_status == SHUTTLE_IDLE && !in_use)
|
|
|
|
/datum/shuttle/autodock/proc/can_force()
|
|
return (next_location && moving_status == SHUTTLE_IDLE && process_state == WAIT_LAUNCH)
|
|
|
|
/datum/shuttle/autodock/proc/can_cancel()
|
|
return (moving_status == SHUTTLE_WARMUP || process_state == WAIT_LAUNCH || process_state == FORCE_LAUNCH)
|
|
|
|
/*
|
|
"Public" procs
|
|
*/
|
|
/datum/shuttle/autodock/proc/launch(var/user)
|
|
if(!can_launch())
|
|
return
|
|
|
|
in_use = user //obtain an exclusive lock on the shuttle
|
|
|
|
set_process_state(WAIT_LAUNCH)
|
|
undock()
|
|
|
|
/datum/shuttle/autodock/proc/force_launch(var/user)
|
|
if(!can_force())
|
|
return
|
|
|
|
in_use = user //obtain an exclusive lock on the shuttle
|
|
|
|
set_process_state(FORCE_LAUNCH)
|
|
|
|
/datum/shuttle/autodock/proc/cancel_launch(var/user)
|
|
if (!can_cancel()) return
|
|
|
|
moving_status = SHUTTLE_IDLE
|
|
set_process_state(WAIT_FINISH)
|
|
in_use = null
|
|
|
|
//whatever we were doing with docking: stop it, then redock
|
|
force_undock()
|
|
spawn(1 SECOND)
|
|
dock()
|
|
|
|
//returns 1 if the shuttle is getting ready to move, but is not in transit yet
|
|
/datum/shuttle/autodock/proc/is_launching()
|
|
return (moving_status == SHUTTLE_WARMUP || process_state == WAIT_LAUNCH || process_state == FORCE_LAUNCH)
|
|
|
|
//This gets called when the shuttle finishes arriving at it's destination
|
|
//This can be used by subtypes to do things when the shuttle arrives.
|
|
//Note that this is called when the shuttle leaves the WAIT_FINISHED state, the proc name is a little misleading
|
|
/datum/shuttle/autodock/proc/arrived()
|
|
return //do nothing for now
|
|
|
|
#undef DOCK_ATTEMPT_TIMEOUT
|