Files
Aurora.3/code/modules/turbolift/turbolift.dm
T
BatrachophrenoandGitHub 4ecb0bc21c Repath obj/machinery to obj/structure/machinery [MDB Ignore] (#22500)
Repaths obj/machinery to obj/structure/machinery. **Note for
reviewers:** the only meaningful changed code exists within
**code/game/objects/structures.dm** and
**code/game/objects/structures/_machinery.dm**, largely concerning
damage procs. With the exception of moving airlock defines to their own
file, ALL OTHER CHANGES ARE STRICTLY PATH CHANGES.

Objects, _categorically_, are largely divided between those you can hold
in your hand/inventory and those you can't. Machinery objects are
already subtypes of Structures behaviorally, this PR just makes their
pathing reflect that, and allows for future work (tool actions, more
health/destruction functionality) to be developed without unnecessary
code duplication.

I have tested this PR by loading up the Horizon and dismantling various
machines and structures with tools, shooting guns of various types
throughout the ship, and detonating a bunch of explosions throughout the
ship.
2026-05-26 19:35:48 +00:00

152 lines
4.9 KiB
Plaintext

// Lift master datum. One per turbolift.
/datum/turbolift
var/datum/turbolift_floor/target_floor // Where are we going?
var/datum/turbolift_floor/current_floor // Where is the lift currently?
var/list/doors = list() // Doors inside the lift structure.
var/list/queued_floors = list() // Where are we moving to next?
var/list/floors = list() // All floors in this system.
var/move_delay = 15 // Time between floor changes.
var/floor_wait_delay = 95 // Time to wait at floor stops.
var/obj/structure/lift/panel/control_panel_interior // Lift control panel.
var/doors_closing = 0 // Whether doors are in the process of closing
var/tmp/moving_upwards
var/tmp/busy
var/move_timer
/datum/turbolift/proc/emergency_stop()
deltimer(move_timer)
move_timer = null
queued_floors.Cut()
target_floor = null
open_doors()
/datum/turbolift/proc/doors_are_open(datum/turbolift_floor/use_floor = current_floor)
for(var/obj/structure/machinery/door/airlock/door in (use_floor ? (doors + use_floor.doors) : doors))
if(!door.density)
return 1
return 0
/datum/turbolift/proc/open_doors(datum/turbolift_floor/use_floor = current_floor)
for(var/obj/structure/machinery/door/airlock/door in (use_floor ? (doors + use_floor.doors) : doors))
door.command("open")
/datum/turbolift/proc/close_doors(datum/turbolift_floor/use_floor = current_floor)
for(var/obj/structure/machinery/door/airlock/door in (use_floor ? (doors + use_floor.doors) : doors))
door.command("close")
/datum/turbolift/proc/do_work()
var/current_floor_index = floors.Find(current_floor)
if(!target_floor)
if(!queued_floors || !queued_floors.len)
return 0
target_floor = queued_floors[1]
queued_floors -= target_floor
if(current_floor_index < floors.Find(target_floor))
moving_upwards = 1
else
moving_upwards = 0
if(doors_are_open())
if(!doors_closing)
close_doors()
doors_closing = 1
queue_movement(move_delay / 2)
return 1
else // We failed to close the doors - probably, someone is blocking them; stop trying to move
doors_closing = 0
open_doors()
control_panel_interior.audible_message("\The [current_floor.ext_panel] buzzes loudly.")
playsound(control_panel_interior.loc, 'sound/machines/buzz-two.ogg', 50, 1)
return 0
doors_closing = 0 // The doors weren't open, so they are done closing
var/area/turbolift/origin = locate(current_floor.area_ref) in get_sorted_areas()
if(target_floor == current_floor)
playsound(control_panel_interior.loc, origin.arrival_sound, 50, 1)
target_floor.arrived(src)
target_floor = null
sleep(15)
control_panel_interior.visible_message("<b>The elevator</b> announces, \"[origin.lift_announce_str]\"")
queue_movement(floor_wait_delay + move_delay)
return 1
// Work out where we're headed.
var/datum/turbolift_floor/next_floor
if(moving_upwards)
next_floor = floors[current_floor_index + 1]
else
next_floor = floors[current_floor_index - 1]
var/area/turbolift/destination = locate(next_floor.area_ref) in get_sorted_areas()
if(!istype(origin) || !istype(destination) || (origin == destination))
return 0
var/list/move_candidates = list()
if(!moving_upwards)
for(var/turf/T in destination)
for(var/atom/movable/AM in T)
// for most Atom Movables, we'll more or less just delete them. Mobs get special treatment.
if(istype(AM, /mob/living))
var/mob/living/safety_hater = AM
safety_hater.gib()
else
AM.crush_act()
else
for(var/turf/simulated/wall/W in origin)
var/turf/T = GET_TURF_ABOVE(W)
for(var/atom/movable/AM in T)
if(next_floor == floors[floors.len])
if(istype(AM, /mob/living))
var/mob/living/safety_hater = AM
safety_hater.gib()
else
AM.crush_act()
else
move_candidates += AM
origin.move_contents_to(destination)
for(var/thing in move_candidates)
var/atom/movable/AM = thing
var/turf/T = get_turf(AM)
if(istype(T))
AM.forceMove(GET_TURF_ABOVE(T))
current_floor = next_floor
control_panel_interior.visible_message("The elevator [moving_upwards ? "rises" : "descends"] smoothly.")
queue_movement()
return 1
/datum/turbolift/proc/queue_move_to(datum/turbolift_floor/floor)
if(!floor || !(floor in floors) || (floor in queued_floors))
return // STOP PRESSING THE BUTTON.
floor.pending_move(src)
queued_floors |= floor
queue_movement()
// TODO: dummy machine ('lift mechanism') in powered area for functionality/blackout checks.
/datum/turbolift/proc/is_functional()
return 1
/datum/turbolift/proc/handle_movement()
if (!do_work())
if (target_floor)
target_floor.ext_panel.reset()
target_floor = null
/datum/turbolift/proc/queue_movement(delay = move_delay)
if (!delay)
delay = move_delay
move_timer = addtimer(CALLBACK(src, PROC_REF(handle_movement)), delay, TIMER_STOPPABLE | TIMER_UNIQUE)