Files
4ab234f10c maploader / overmaps update - struct system, overmaps location bindings, misc backend improvements (#6403)
tl;dr level collections that can easily be logically restructured/moved
as necessary

will eventually be used for radio and overmaps location resolution.

this is the last part of
https://github.com/Citadel-Station-13/Citadel-Station-13-RP/pull/4841
that has not yet been integrated.
this will be a draft for a while.

---------

Co-authored-by: LetterN <24603524+LetterN@users.noreply.github.com>
2025-11-06 17:49:23 -08:00

256 lines
7.3 KiB
Plaintext

// Map object.
/obj/turbolift_map_holder
name = "turbolift map placeholder"
icon = 'icons/obj/turbolift_preview_3x3.dmi'
dir = SOUTH // Direction of the holder determines the placement of the lift control panel and doors.
var/depth = 1 // Number of floors to generate, including the initial floor.
var/lift_size_x = 2 // Number of turfs on each axis to generate in addition to the first
var/lift_size_y = 2 // ie. a 3x3 lift would have a value of 2 in each of these variables.
// Various turf and door types used when generating the turbolift floors.
var/wall_type = /turf/simulated/wall/elevator
var/floor_type = /turf/simulated/floor/tiled/dark
var/door_type = /obj/machinery/door/airlock/lift
var/light_type = /obj/machinery/light/no_nightshift
var/list/areas_to_use = list()
// rotated
var/got_rotated_by_maploader
/obj/turbolift_map_holder/preloading_from_mapload_rotation(datum/dmm_context/context)
. = ..()
got_rotated_by_maploader = context.loaded_orientation
/obj/turbolift_map_holder/Initialize(mapload)
. = ..()
return INITIALIZE_HINT_LATELOAD
// since this WILL cause qdels (on other atoms) to be invoked
/obj/turbolift_map_holder/LateInitialize()
// Create our system controller.
var/datum/turbolift/lift = new()
// Holder values since we're moving this object to null ASAP.
var/ux = x
var/uy = y
var/uz = z
// handle orientations
switch(got_rotated_by_maploader)
if(SOUTH)
if(NORTH)
ux -= lift_size_x
uy -= lift_size_y
if(EAST)
var/swap = lift_size_x
lift_size_x = lift_size_y
lift_size_y = swap
ux -= lift_size_x
if(WEST)
var/swap = lift_size_x
lift_size_x = lift_size_y
lift_size_y = swap
uy -= lift_size_y
var/udir = dir
moveToNullspace()
// These modifiers are used in relation to the origin
// to place the system control panels and doors.
var/make_walls = isnull(wall_type) ? FALSE : TRUE // Wall-less elevator
var/int_panel_x
var/int_panel_y
var/ext_panel_x
var/ext_panel_y
var/door_x1
var/door_y1
var/door_x2
var/door_y2
var/light_x1
var/light_x2
var/light_y1
var/light_y2
var/az = 1
var/ex = (ux+lift_size_x)
var/ey = (uy+lift_size_y)
var/ez = (uz+(depth-1))
switch(dir)
if(NORTH)
int_panel_x = ux + FLOOR(lift_size_x/2, 1)
int_panel_y = uy + (make_walls ? 1 : 0)
ext_panel_x = ux
ext_panel_y = ey + 2
door_x1 = ux + 1
door_y1 = ey + (make_walls ? 0 : 1)
door_x2 = ex - 1
door_y2 = ey + 1
light_x1 = ux + (make_walls ? 1 : 0)
light_y1 = uy + (make_walls ? 1 : 0)
light_x2 = ux + lift_size_x - (make_walls ? 1 : 0)
light_y2 = uy + (make_walls ? 1 : 0)
if(SOUTH)
int_panel_x = ux + FLOOR(lift_size_x/2, 1)
int_panel_y = ey - (make_walls ? 1 : 0)
ext_panel_x = ex
ext_panel_y = uy - 2
door_x1 = ux + 1
door_y1 = uy - 1
door_x2 = ex - 1
door_y2 = uy - (make_walls ? 0 : 1)
light_x1 = ux + (make_walls ? 1 : 0)
light_y1 = uy + lift_size_y - (make_walls ? 1 : 0)
light_x2 = ux + lift_size_x - (make_walls ? 1 : 0)
light_y2 = uy + lift_size_y - (make_walls ? 1 : 0)
if(EAST)
int_panel_x = ux+(make_walls ? 1 : 0)
int_panel_y = uy + FLOOR(lift_size_y/2, 1)
ext_panel_x = ex+2
ext_panel_y = ey
door_x1 = ex + (make_walls ? 0 : 1)
door_y1 = uy + 1
door_x2 = ex + 1
door_y2 = ey - 1
light_x1 = ux + (make_walls ? 1 : 0)
light_y1 = uy + (make_walls ? 1 : 0)
light_x2 = ux + (make_walls ? 1 : 0)
light_y2 = uy + lift_size_x - (make_walls ? 1 : 0)
if(WEST)
int_panel_x = ex-(make_walls ? 1 : 0)
int_panel_y = uy + FLOOR(lift_size_y/2, 1)
ext_panel_x = ux-2
ext_panel_y = uy
door_x1 = ux - 1
door_y1 = uy + 1
door_x2 = ux - (make_walls ? 0 : 1)
door_y2 = ey - 1
light_x1 = ux + lift_size_x - (make_walls ? 1 : 0)
light_y1 = uy + (make_walls ? 1 : 0)
light_x2 = ux + lift_size_x - (make_walls ? 1 : 0)
light_y2 = uy + lift_size_y - (make_walls ? 1 : 0)
// Generate each floor and store it in the controller datum.
for(var/cz = uz;cz<=ez;cz++)
var/datum/turbolift_floor/cfloor = new()
lift.floors += cfloor
var/list/floor_turfs = list()
// Update the appropriate turfs.
for(var/tx = ux to ex)
for(var/ty = uy to ey)
var/turf/checking = locate(tx,ty,cz)
if(!istype(checking))
log_debug(SPAN_DEBUGERROR("[name] cannot find a component turf at [tx],[ty] on floor [cz]. Aborting."))
qdel(src)
return
// Update path appropriately if needed.
var/swap_to = /turf/baseturf_bottom
if(cz == uz) // Elevator.
if(wall_type && (tx == ux || ty == uy || tx == ex || ty == ey) && !(tx >= door_x1 && tx <= door_x2 && ty >= door_y1 && ty <= door_y2))
swap_to = wall_type
else
swap_to = floor_type
if(checking.type != swap_to)
checking.ChangeTurf(swap_to)
// /tg/ baseturfs - IMPORTANT - inject plating beneath
checking.PlaceBelowLogicalTop(/turf/simulated/floor/plating)
// Let's make absolutely sure that we have the right turf.
checking = locate(tx,ty,cz)
// Clear out contents.
for(var/atom/movable/thing in checking.contents)
if(!(thing.atom_flags & ATOM_ABSTRACT))
qdel(thing)
if(tx >= ux && tx <= ex && ty >= uy && ty <= ey)
floor_turfs += checking
// Place exterior doors.
for(var/tx = door_x1 to door_x2)
for(var/ty = door_y1 to door_y2)
var/turf/checking = locate(tx,ty,cz)
var/internal = 1
if(!(checking in floor_turfs))
internal = 0
if(checking.type != floor_type)
checking.ChangeTurf(floor_type)
checking = locate(tx,ty,cz)
for(var/atom/movable/thing in checking.contents)
if(!(thing.atom_flags & ATOM_ABSTRACT))
qdel(thing)
if(checking.type == floor_type) // Don't build over empty space on lower levels.
var/obj/machinery/door/airlock/lift/newdoor = new door_type(checking)
newdoor.setDir(got_rotated_by_maploader ? got_rotated_by_maploader : dir)
if(internal)
lift.doors += newdoor
newdoor.lift = cfloor
else
cfloor.doors += newdoor
newdoor.floor = cfloor
// Place exterior control panel.
var/turf/placing = locate(ext_panel_x, ext_panel_y, cz)
var/obj/structure/lift/button/panel_ext = new(placing, lift)
panel_ext.floor = cfloor
panel_ext.setDir(udir)
cfloor.ext_panel = panel_ext
// Update area.
if(az > areas_to_use.len)
log_debug(SPAN_DEBUGWARNING("Insufficient defined areas in turbolift datum, aborting."))
qdel(src)
return
var/area_path = areas_to_use[az]
var/area/areaInstance = new area_path(null)
areaInstance.addSorted()
for(var/thing in floor_turfs)
areaInstance.contents.Add(thing)
cfloor.set_area_ref("[REF(areaInstance)]")
az++
// Place lift panel.
var/turf/T = locate(int_panel_x, int_panel_y, uz)
lift.control_panel_interior = new(T, lift)
lift.control_panel_interior.setDir(udir)
lift.current_floor = lift.floors[1]
// Place interior lights
if(light_type)
var/turf/placing1 = locate(light_x1, light_y1, uz)
var/turf/placing2 = locate(light_x2, light_y2, uz)
var/obj/machinery/light/light1 = new light_type(placing1, light)
var/obj/machinery/light/light2 = new light_type(placing2, light)
if(udir == NORTH || udir == SOUTH)
light1.setDir(WEST)
light2.setDir(EAST)
else
light1.setDir(SOUTH)
light2.setDir(NORTH)
lift.open_doors()