Files
Bubberstation/code/game/turfs/open/openspace.dm
T
LemonInTheDark cfc4e960bc Properly unreg's turf changed when space openspace is deleted (#76501)
## About The Pull Request

Openspace tracks the turf below for starlight purposes The trouble is if
a turf is replaced by another, all its signal registers still persist

I forgot about this, so we'd get runtimes when a
/turf/open/space/openspace was replaced, and the turf below it changed

## Why It's Good For The Game

Less random runtimes
2023-07-08 00:02:18 +01:00

202 lines
6.7 KiB
Plaintext

/turf/open/openspace
name = "open space"
desc = "Watch your step!"
// We don't actually draw openspace, but it needs to have color
// In its icon state so we can count it as a "non black" tile
icon_state = MAP_SWITCH("pure_white", "invisible")
baseturfs = /turf/open/openspace
overfloor_placed = FALSE
underfloor_accessibility = UNDERFLOOR_INTERACTABLE
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
pathing_pass_method = TURF_PATHING_PASS_PROC
plane = TRANSPARENT_FLOOR_PLANE
var/can_cover_up = TRUE
var/can_build_on = TRUE
/turf/open/openspace/airless
initial_gas_mix = AIRLESS_ATMOS
/turf/open/openspace/airless/planetary
planetary_atmos = TRUE
// Reminder, any behavior code written here needs to be duped to /turf/open/space/openspace
// I am so sorry
/turf/open/openspace/Initialize(mapload) // handle plane and layer here so that they don't cover other obs/turfs in Dream Maker
. = ..()
if(PERFORM_ALL_TESTS(focus_only/openspace_clear) && !GET_TURF_BELOW(src))
stack_trace("[src] was inited as openspace with nothing below it at ([x], [y], [z])")
RegisterSignal(src, COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON, PROC_REF(on_atom_created))
var/area/our_area = loc
if(istype(our_area, /area/space))
force_no_gravity = TRUE
return INITIALIZE_HINT_LATELOAD
/turf/open/openspace/LateInitialize()
. = ..()
AddElement(/datum/element/turf_z_transparency)
/turf/open/openspace/ChangeTurf(path, list/new_baseturfs, flags)
UnregisterSignal(src, COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON)
return ..()
/**
* Prepares a moving movable to be precipitated if Move() is successful.
* This is done in Enter() and not Entered() because there's no easy way to tell
* if the latter was called by Move() or forceMove() while the former is only called by Move().
*/
/turf/open/openspace/Enter(atom/movable/movable, atom/oldloc)
. = ..()
if(.)
//higher priority than CURRENTLY_Z_FALLING so the movable doesn't fall on Entered()
movable.set_currently_z_moving(CURRENTLY_Z_FALLING_FROM_MOVE)
///Makes movables fall when forceMove()'d to this turf.
/turf/open/openspace/Entered(atom/movable/movable)
. = ..()
if(movable.set_currently_z_moving(CURRENTLY_Z_FALLING))
zFall(movable, falling_from_move = TRUE)
/**
* Drops movables spawned on this turf after they are successfully initialized.
* so that spawned movables that should fall to gravity, will fall.
*/
/turf/open/openspace/proc/on_atom_created(datum/source, atom/created_atom)
SIGNAL_HANDLER
if(ismovable(created_atom))
zfall_if_on_turf(created_atom)
/turf/open/openspace/proc/zfall_if_on_turf(atom/movable/movable)
if(QDELETED(movable) || movable.loc != src)
return
zFall(movable)
/turf/open/openspace/can_have_cabling()
if(locate(/obj/structure/lattice/catwalk, src))
return TRUE
return FALSE
/turf/open/openspace/zAirIn()
return TRUE
/turf/open/openspace/zAirOut()
return TRUE
/turf/open/openspace/zPassIn(atom/movable/A, direction, turf/source)
if(direction == DOWN)
for(var/obj/contained_object in contents)
if(contained_object.obj_flags & BLOCK_Z_IN_DOWN)
return FALSE
return TRUE
if(direction == UP)
for(var/obj/contained_object in contents)
if(contained_object.obj_flags & BLOCK_Z_IN_UP)
return FALSE
return TRUE
return FALSE
/turf/open/openspace/zPassOut(atom/movable/A, direction, turf/destination, allow_anchored_movement)
if(A.anchored && !allow_anchored_movement)
return FALSE
if(direction == DOWN)
for(var/obj/contained_object in contents)
if(contained_object.obj_flags & BLOCK_Z_OUT_DOWN)
return FALSE
return TRUE
if(direction == UP)
for(var/obj/contained_object in contents)
if(contained_object.obj_flags & BLOCK_Z_OUT_UP)
return FALSE
return TRUE
return FALSE
/turf/open/openspace/proc/CanCoverUp()
return can_cover_up
/turf/open/openspace/proc/CanBuildHere()
return can_build_on
/turf/open/openspace/attackby(obj/item/C, mob/user, params)
..()
if(!CanBuildHere())
return
if(istype(C, /obj/item/stack/rods))
build_with_rods(C, user)
else if(istype(C, /obj/item/stack/tile/iron))
build_with_floor_tiles(C, user)
/turf/open/openspace/build_with_floor_tiles(obj/item/stack/tile/iron/used_tiles)
if(!CanCoverUp())
return
return ..()
/turf/open/openspace/rcd_vals(mob/user, obj/item/construction/rcd/the_rcd)
if(!CanBuildHere())
return FALSE
switch(the_rcd.mode)
if(RCD_FLOORWALL)
var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
if(L)
return list("mode" = RCD_FLOORWALL, "delay" = 0, "cost" = 1)
else
return list("mode" = RCD_FLOORWALL, "delay" = 0, "cost" = 3)
return FALSE
/turf/open/openspace/rcd_act(mob/user, obj/item/construction/rcd/the_rcd, passed_mode)
switch(passed_mode)
if(RCD_FLOORWALL)
to_chat(user, span_notice("You build a floor."))
PlaceOnTop(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
return TRUE
return FALSE
/turf/open/openspace/rust_heretic_act()
return FALSE
/turf/open/openspace/CanAStarPass(obj/item/card/id/ID, to_dir, atom/movable/caller, no_id = FALSE)
if(caller && !caller.can_z_move(DOWN, src, null , ZMOVE_FALL_FLAGS)) //If we can't fall here (flying/lattice), it's fine to path through
return TRUE
return FALSE
/turf/open/openspace/replace_floor(turf/open/new_floor_path, flags)
if (!initial(new_floor_path.overfloor_placed))
ChangeTurf(new_floor_path, flags = flags)
return
// Create plating under tiled floor we try to create directly onto the air
PlaceOnTop(/turf/open/floor/plating, flags = flags)
PlaceOnTop(new_floor_path, flags = flags)
/turf/open/openspace/icemoon
name = "ice chasm"
baseturfs = /turf/open/openspace/icemoon
initial_gas_mix = ICEMOON_DEFAULT_ATMOS
planetary_atmos = TRUE
/// Replaces itself with replacement_turf if the turf has the no ruins allowed flag (usually ruins themselves)
var/protect_ruin = TRUE
/// The turf that will replace this one if the turf below has the no ruins allowed flag. we use this one so we don't get any potential double whammies
var/replacement_turf = /turf/open/misc/asteroid/snow/icemoon/do_not_chasm
/// If true mineral turfs below this openspace turf will be mined automatically
var/drill_below = TRUE
/turf/open/openspace/icemoon/Initialize(mapload)
. = ..()
var/turf/T = below()
//I wonder if I should error here
if(!T)
return
if(T.turf_flags & NO_RUINS && protect_ruin)
ChangeTurf(replacement_turf, null, CHANGETURF_IGNORE_AIR)
return
if(!ismineralturf(T) || !drill_below)
return
var/turf/closed/mineral/M = T
M.mineralAmt = 0
M.gets_drilled()
baseturfs = /turf/open/openspace/icemoon //This is to ensure that IF random turf generation produces a openturf, there won't be other turfs assigned other than openspace.
/turf/open/openspace/icemoon/keep_below
drill_below = FALSE
/turf/open/openspace/icemoon/ruins
protect_ruin = FALSE
drill_below = FALSE