diff --git a/code/__DEFINES/dcs/signals/signals_object.dm b/code/__DEFINES/dcs/signals/signals_object.dm index 45b671141a3..72828cc8916 100644 --- a/code/__DEFINES/dcs/signals/signals_object.dm +++ b/code/__DEFINES/dcs/signals/signals_object.dm @@ -530,6 +530,9 @@ /// from /datum/component/dart_insert/on_reskin() #define COMSIG_DART_INSERT_PARENT_RESKINNED "dart_insert_parent_reskinned" +/// from /datum/element/undertile/hide() +#define COMSIG_UNDERTILE_UPDATED "undertile_updated" + /// Sent from /obj/item/update_weight_class(). (old_w_class, new_w_class) #define COMSIG_ITEM_WEIGHT_CLASS_CHANGED "item_weight_class_changed" /// Sent from /obj/item/update_weight_class(), to its loc. (obj/item/changed_item, old_w_class, new_w_class) diff --git a/code/__DEFINES/is_helpers.dm b/code/__DEFINES/is_helpers.dm index 0d9d28d4d85..be21dcf081a 100644 --- a/code/__DEFINES/is_helpers.dm +++ b/code/__DEFINES/is_helpers.dm @@ -69,6 +69,8 @@ GLOBAL_LIST_INIT(turfs_openspace, typecacheof(list( #define isplatingturf(A) (istype(A, /turf/open/floor/plating)) +#define iscatwalkturf(A) (istype(A, /turf/open/floor/catwalk_floor)) + #define isasteroidturf(A) (istype(A, /turf/open/misc/asteroid)) #define istransparentturf(A) (HAS_TRAIT(A, TURF_Z_TRANSPARENT_TRAIT)) diff --git a/code/__DEFINES/layers.dm b/code/__DEFINES/layers.dm index 0815f118ee9..cf2d8bda3ed 100644 --- a/code/__DEFINES/layers.dm +++ b/code/__DEFINES/layers.dm @@ -169,9 +169,9 @@ #define WIRE_LAYER (9 + TOPDOWN_LAYER) #define GLASS_FLOOR_LAYER (10 + TOPDOWN_LAYER) #define TRAM_RAIL_LAYER (11 + TOPDOWN_LAYER) +#define ABOVE_OPEN_TURF_LAYER (12 + TOPDOWN_LAYER) ///catwalk overlay of /turf/open/floor/plating/catwalk_floor -#define CATWALK_LAYER (12 + TOPDOWN_LAYER) -#define ABOVE_OPEN_TURF_LAYER (13 + TOPDOWN_LAYER) +#define CATWALK_LAYER (13 + TOPDOWN_LAYER) //GAME_PLANE layers #define BELOW_CLOSED_TURF_LAYER 2.053 diff --git a/code/datums/elements/undertile.dm b/code/datums/elements/undertile.dm index ed901b196c1..229b292b31a 100644 --- a/code/datums/elements/undertile.dm +++ b/code/datums/elements/undertile.dm @@ -43,8 +43,13 @@ var/turf/T = get_turf(source) if(underfloor_accessibility < UNDERFLOOR_INTERACTABLE) - SET_PLANE_IMPLICIT(source, FLOOR_PLANE) // We do this so that turfs that allow you to see what's underneath them don't have to be on the game plane (which causes ambient occlusion weirdness) - source.layer = ABOVE_OPEN_TURF_LAYER + // We only want to change the layer/plane for things that aren't already on the floor plane, + // as overriding the settings for those would cause layering issues + if(PLANE_TO_TRUE(source.plane) != FLOOR_PLANE) + // We do this so that turfs that allow you to see what's underneath them don't have to be on the game plane (which causes ambient occlusion weirdness) + SET_PLANE_IMPLICIT(source, FLOOR_PLANE) + source.layer = ABOVE_OPEN_TURF_LAYER + ADD_TRAIT(source, TRAIT_UNDERFLOOR, REF(src)) if(tile_overlay) @@ -77,6 +82,8 @@ if(use_anchor) source.set_anchored(FALSE) + SEND_SIGNAL(source, COMSIG_UNDERTILE_UPDATED) + /datum/element/undertile/Detach(atom/movable/source, visibility_trait, invisibility_level = INVISIBILITY_MAXIMUM) . = ..() diff --git a/code/modules/atmospherics/machinery/atmosmachinery.dm b/code/modules/atmospherics/machinery/atmosmachinery.dm index 8674e6331e4..12e6c684079 100644 --- a/code/modules/atmospherics/machinery/atmosmachinery.dm +++ b/code/modules/atmospherics/machinery/atmosmachinery.dm @@ -112,7 +112,7 @@ turf_loc.add_blueprints_preround(src) if(hide) - RegisterSignal(src, COMSIG_OBJ_HIDE, PROC_REF(on_hide)) + setup_hiding() SSspatial_grid.add_grid_awareness(src, SPATIAL_GRID_CONTENTS_TYPE_ATMOS) SSspatial_grid.add_grid_membership(src, turf_loc, SPATIAL_GRID_CONTENTS_TYPE_ATMOS) @@ -133,9 +133,18 @@ return ..() /** - * Handler for `COMSIG_OBJ_HIDE`, connects only if `hide` is set to `TRUE`. Calls `update_cap_visuals` on pipe and its connected nodes + * Sets up our pipe hiding logic, consolidated in one place so subtypes may override it. + * This lets subtypes implement their own hiding logic without needing to worry about conflicts with the parent hiding logic. */ -/obj/machinery/atmospherics/proc/on_hide(datum/source, underfloor_accessibility) +/obj/machinery/atmospherics/proc/setup_hiding() + // Register pipe cap updating when hidden/unhidden + RegisterSignal(src, COMSIG_OBJ_HIDE, PROC_REF(on_hide)) + +/** + * Signal handler. Updates both our pipe cap visuals and those of adjacent nodes. + * We update adjacent nodes as their pipe caps are based partially on our state, so they need updating as well. + */ +/obj/machinery/atmospherics/proc/on_hide(datum/source) SHOULD_CALL_PARENT(TRUE) SIGNAL_HANDLER @@ -651,7 +660,8 @@ if(HAS_TRAIT(node, TRAIT_UNDERFLOOR)) continue - if(isplatingturf(get_turf(node))) + var/turf/node_turf = get_turf(node) + if(isplatingturf(node_turf) || iscatwalkturf(node_turf)) continue var/connected_dir = get_dir(src, node) diff --git a/code/modules/atmospherics/machinery/pipes/pipes.dm b/code/modules/atmospherics/machinery/pipes/pipes.dm index 230edc9a897..ebc31e847b8 100644 --- a/code/modules/atmospherics/machinery/pipes/pipes.dm +++ b/code/modules/atmospherics/machinery/pipes/pipes.dm @@ -27,12 +27,11 @@ volume = 35 * device_type . = ..() -///I have no idea why there's a new and at this point I'm too afraid to ask -/obj/machinery/atmospherics/pipe/Initialize(mapload) - . = ..() +/obj/machinery/atmospherics/pipe/setup_hiding() + AddElement(/datum/element/undertile, TRAIT_T_RAY_VISIBLE) //if changing this, change the subtypes RemoveElements too, because thats how bespoke works - if(hide) - AddElement(/datum/element/undertile, TRAIT_T_RAY_VISIBLE) //if changing this, change the subtypes RemoveElements too, because thats how bespoke works + // Registering on `COMSIG_OBJ_HIDE` would cause order of operations issues with undertile, so we register to run when undertile updates instead + RegisterSignal(src, COMSIG_UNDERTILE_UPDATED, PROC_REF(on_hide)) /obj/machinery/atmospherics/pipe/on_deconstruction(disassembled) //we delete the parent here so it initializes air_temporary for us. See /datum/pipeline/Destroy() which calls temporarily_store_air()