Files
Aurora.3/code/modules/shuttles/shuttle_autodock.dm
T
DreamySkrellGitHubDreamySkrell <>
a253fcba9c Airlock markers - docking and shuttle airlocks (#17717)
* rearrange files

* Squashed commit of the following:

commit ec32b5b6e9
Author: DreamySkrell <>
Date:   Sat Oct 28 22:32:05 2023 +0200

    ccc

commit be750e672d
Author: DreamySkrell <>
Date:   Sat Oct 28 22:01:02 2023 +0200

    cc

commit 1ecd9afb6c
Author: DreamySkrell <>
Date:   Sat Oct 28 21:57:38 2023 +0200

    c

commit 159d1000d9
Author: DreamySkrell <>
Date:   Sat Oct 28 21:40:40 2023 +0200

    nav_ert_dock kill

commit b767a2574a
Author: DreamySkrell <>
Date:   Sat Oct 28 21:24:34 2023 +0200

    a

commit aa01eec1fc
Author: DreamySkrell <>
Date:   Sat Oct 28 21:09:48 2023 +0200

    NAV_HORIZON_DOCK_ALL

commit 4564bfd29f
Author: DreamySkrell <>
Date:   Sat Oct 28 20:55:45 2023 +0200

    burglar and raider to use NAV_HORIZON_EXTERIOR_ALL_DECKS and SNEAKY

commit ec7564fcb1
Author: DreamySkrell <>
Date:   Sat Oct 28 20:43:17 2023 +0200

    merc shuttle to use NAV_HORIZON_EXTERIOR_ALL_DECKS

commit d306934a73
Author: DreamySkrell <>
Date:   Fri Oct 27 00:00:41 2023 +0200

    fix merc and skipjack area/template_noop

commit 0600a348cd
Author: DreamySkrell <>
Date:   Thu Oct 26 22:28:45 2023 +0200

    merc ship generic dock landmark huh

commit c9850622f9
Author: DreamySkrell <>
Date:   Thu Oct 26 20:37:55 2023 +0200

    sane landmark tags

commit 56d9052270
Author: DreamySkrell <>
Date:   Thu Oct 26 20:11:55 2023 +0200

    /horizon/dock/deck_3/port_3

commit 846d737c94
Author: DreamySkrell <>
Date:   Thu Oct 26 20:03:17 2023 +0200

    landmark/horizon/deck -> landmark/horizon/exterior/deck

commit ef5c3d1b09
Author: DreamySkrell <>
Date:   Thu Oct 26 20:02:17 2023 +0200

    landmark/horizon/dock -> landmark/horizon/dock/deck_3/...

commit 1716ef26a8
Author: DreamySkrell <>
Date:   Thu Oct 26 19:54:21 2023 +0200

    docks ruler helpers

commit 18c66a3124
Author: DreamySkrell <>
Date:   Thu Oct 26 19:47:27 2023 +0200

    a

commit 0f2fc4524c
Author: DreamySkrell <>
Date:   Thu Oct 26 19:43:19 2023 +0200

    horizon/nav -> horizon/hangar

commit e13a5233d1
Author: DreamySkrell <>
Date:   Thu Oct 26 19:41:08 2023 +0200

    sccv_horizon_shuttle_landmarks.dm

* Squashed commit of the following:

commit 4d7052be3b
Author: DreamySkrell <>
Date:   Sun Oct 29 14:18:40 2023 +0100

    tests rerun please

commit ae04980347
Author: DreamySkrell <>
Date:   Sun Oct 29 13:25:26 2023 +0100

    oops

commit 176ea80155
Author: DreamySkrell <>
Date:   Sun Oct 29 12:54:25 2023 +0100

    tests rerun please

commit 5cf7db9162
Author: DreamySkrell <>
Date:   Sun Oct 29 12:45:07 2023 +0100

    c

commit f93887a1ef
Author: DreamySkrell <>
Date:   Sun Oct 29 12:43:47 2023 +0100

    jjjjjjjjjjjj

commit 697542a270
Author: DreamySkrell <>
Date:   Sun Oct 29 12:25:32 2023 +0100

    a

commit a83373a62a
Author: DreamySkrell <>
Date:   Sun Oct 29 12:17:47 2023 +0100

    ay

commit baf447a694
Author: 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 <>
2023-11-07 11:04:01 +00:00

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