Skip to content

Commit

Permalink
Turfs cleanup, part 4: undertile component (#12811)
Browse files Browse the repository at this point in the history
* undertile component

* ready

* fixes

* Fixes #12812

* planes

* Update undertile.dm

* catwalk & disposable fixes
  • Loading branch information
volas authored Feb 17, 2024
1 parent 32a7286 commit f388d0f
Show file tree
Hide file tree
Showing 77 changed files with 310 additions and 434 deletions.
9 changes: 8 additions & 1 deletion code/__DEFINES/_planes_layers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ What is the naming convention for planes or layers?
#define ANOMALY_PLANE -21
#define ANOMALY_RENDER_TARGET "*ANOM_RENDER_TARGET"

// underfloor, floor and game planes have common layout order
// in some cases object can be switched between these planes
// FLOOR plane disables ambitn occlusion, UNDERFLOOR exists for undertile component
#define UNDERFLOOR_PLANE -8
#define FLOOR_PLANE -7

#define GAME_PLANE -4
#define BELOW_TURF_LAYER 1.9
//efine TURF_LAYER 2 // For easy recordkeeping; this is a byond define
Expand All @@ -96,13 +99,17 @@ What is the naming convention for planes or layers?
#define GAS_PIPE_HIDDEN_SUPPLY_LAYER 2.33
#define GAS_PIPE_HIDDEN_SCRUBBER_LAYER 2.34
#define GAS_PIPE_HIDDEN_LAYER 2.35
#define POWER_CABLES_HEAVY 2.39
#define TURF_CAP_LAYER 2.4 // cap on grid_floor and possible other future floors who can do UNDERFLOOR_VISIBLE, should be above hidden pipes
#define POWER_CABLES 2.44
#define GAS_SCRUBBER_LAYER 2.46
#define GAS_PIPE_VISIBLE_LAYER 2.47
#define GAS_FILTER_LAYER 2.48
#define GAS_PUMP_LAYER 2.49
#define LOW_OBJ_LAYER 2.491 // Currently used only by unused machinery
#define SAFEDOOR_LAYER 2.5 // firedoors, poddoors, and someone used this for safe for some reason
#define ABOVE_SAFEDOOR_LAYER 2.51 // poddoors default, they should be around SAFEDOOR_LAYER (see SAFEDOOR_CLOSED_MOD_*) but little above firedoors
#define POWER_TERMINAL 2.6
#define BELOW_CONTAINERS_LAYER 2.7 // Below closets, crates...
#define CONTAINER_STRUCTURE_LAYER 2.8 // Layer for closets, crates, bags, racks, tables
#define DOOR_LAYER 2.82
Expand Down
5 changes: 4 additions & 1 deletion code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,14 @@
#define COMSIG_INSTRUMENT_REPEAT "instrument_repeat"
///sent to the instrument when tempo changes, skipped on new: (datum/music_player)
#define COMSIG_INSTRUMENT_TEMPO_CHANGE "instrument_tempo_change"
// /obj

// /obj signals
/// from base of datum/religion_rites/reset_rite_wrapper(): ()
#define COMSIG_OBJ_RESET_RITE "obj_reset_rite"
/// from base of datum/religion_rites/start(): ()
#define COMSIG_OBJ_START_RITE "obj_start_rite"
///from base of /turf/proc/levelupdate(). (underfloor_accessibility)
#define COMSIG_OBJ_LEVELUPDATE "obj_levelupdate"

// /obj/item signals
/// from base of obj/item/attack(): (/mob/living/target, /mob/living/user, def_zone)
Expand Down
7 changes: 7 additions & 0 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
: FALSE)
#define HAS_TRAIT_NOT_FROM(target, trait, source) (target.status_traits ? (target.status_traits[trait] ? (length(target.status_traits[trait] - source) > 0) : FALSE) : FALSE)

/// Trait applied by element
#define ELEMENT_TRAIT(source) "element_trait_[source]"

//mob traits
/// Forces user to be unmovable
Expand Down Expand Up @@ -206,6 +208,9 @@
// item trait
#define TRAIT_NO_SACRIFICE "religion_no_sacrifice"

/// Visible on t-ray scanners if the atom is under tile
#define TRAIT_T_RAY_VISIBLE "t-ray-visible"

// idk why this exists on TG
#define GENERIC_TRAIT "generic"
// common trait sources
Expand All @@ -226,6 +231,8 @@

// atom traits
#define TRAIT_XENO_FUR "xeno_fur"
// Trait from being under the floor in some manner
#define TRAIT_UNDERFLOOR "underfloor"

// trait sources
#define EYE_DAMAGE_TRAIT "eye_damage"
Expand Down
6 changes: 6 additions & 0 deletions code/__DEFINES/turfs.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// The pipes, disposals, and wires are hidden
#define UNDERFLOOR_HIDDEN 0
/// The pipes, disposals, and wires are visible but cannot be interacted with
#define UNDERFLOOR_VISIBLE 1
/// The pipes, disposals, and wires are visible and can be interacted with
#define UNDERFLOOR_INTERACTABLE 2
8 changes: 8 additions & 0 deletions code/_onclick/hud/rendering/plane_master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
/atom/movable/screen/plane_master/proc/apply_effects(mob/mymob)
return

///Level below the floor, for undertile component
/atom/movable/screen/plane_master/underfloor
name = "underfloor plane master"
plane = UNDERFLOOR_PLANE
appearance_flags = PLANE_MASTER
blend_mode = BLEND_OVERLAY
render_relay_plane = RENDER_PLANE_GAME

///Contains just the floor
/atom/movable/screen/plane_master/floor
name = "floor plane master"
Expand Down
1 change: 1 addition & 0 deletions code/_onclick/hud/rendering/plane_master_controller.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/atom/movable/plane_master_controller/game
name = PLANE_MASTERS_GAME
controlled_planes = list(
UNDERFLOOR_PLANE,
FLOOR_PLANE,
GAME_PLANE,
ABOVE_GAME_PLANE,
Expand Down
84 changes: 84 additions & 0 deletions code/datums/elements/undertile.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/// The alpha we give to stuff under tiles, if they want it
#define ALPHA_UNDERTILE 128

///Add to an object if you want to be able to be hidden under tiles
/datum/element/undertile
element_flags = ELEMENT_BESPOKE | COMPONENT_DUPE_HIGHLANDER
id_arg_index = 2

///the invisiblity trait applied, like TRAIT_T_RAY_VISIBLE
var/invisibility_trait
///level of invisibility applied when under a tile. Could be INVISIBILITY_OBSERVER if you still want it to be visible to ghosts
var/invisibility_level
///an overlay for the tile if we wish to apply that
var/tile_overlay
///whether we use alpha or not. TRUE uses ALPHA_UNDERTILE because otherwise we have 200 different instances of this element for different alphas
var/use_alpha
///We will switch between anchored and unanchored. for stuff like satchels that shouldn't be pullable under tiles but are otherwise unanchored
var/use_anchor

/datum/element/undertile/Attach(datum/target, invisibility_trait, invisibility_level = INVISIBILITY_MAXIMUM, tile_overlay, use_alpha = TRUE, use_anchor = FALSE)
. = ..()

if(!ismovable(target))
return ELEMENT_INCOMPATIBLE

RegisterSignal(target, COMSIG_OBJ_LEVELUPDATE, PROC_REF(hide))

src.invisibility_trait = invisibility_trait
src.invisibility_level = invisibility_level
src.tile_overlay = tile_overlay
src.use_alpha = use_alpha
src.use_anchor = use_anchor

///called when a tile has been covered or uncovered
/datum/element/undertile/proc/hide(atom/movable/source, underfloor_accessibility)
SIGNAL_HANDLER

if(underfloor_accessibility < UNDERFLOOR_VISIBLE)
source.invisibility = invisibility_level
else
source.invisibility = initial(invisibility_level)

var/turf/T = get_turf(source)

if(underfloor_accessibility < UNDERFLOOR_INTERACTABLE)
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)
ADD_TRAIT(source, TRAIT_UNDERFLOOR, REF(src))

if(tile_overlay)
T.add_overlay(tile_overlay)

if(use_anchor)
source.anchored = TRUE

if(underfloor_accessibility < UNDERFLOOR_VISIBLE)
if(use_alpha)
source.alpha = ALPHA_UNDERTILE

if(invisibility_trait)
ADD_TRAIT(source, invisibility_trait, ELEMENT_TRAIT(type))

else
source.plane = initial(source.plane)
REMOVE_TRAIT(source, TRAIT_UNDERFLOOR, REF(src))

if(invisibility_trait)
REMOVE_TRAIT(source, invisibility_trait, ELEMENT_TRAIT(type))

if(tile_overlay)
T.overlays -= tile_overlay

if(use_alpha)
source.alpha = initial(source.alpha)

if(use_anchor)
source.anchored = FALSE

/datum/element/undertile/Detach(atom/movable/source, visibility_trait, invisibility_level = INVISIBILITY_MAXIMUM)
. = ..()

hide(source, UNDERFLOOR_INTERACTABLE)
UnregisterSignal(source, COMSIG_OBJ_LEVELUPDATE)

#undef ALPHA_UNDERTILE
1 change: 0 additions & 1 deletion code/game/area/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// ===
/area
level = null
name = "Space"
icon = 'icons/turf/areas.dmi'
icon_state = "unknown"
Expand Down
1 change: 0 additions & 1 deletion code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
layer = TURF_LAYER
plane = GAME_PLANE

var/level = 2
var/flags = 0
var/flags_2 = 0
var/list/fingerprints
Expand Down
10 changes: 2 additions & 8 deletions code/game/gamemodes/factions/blob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,10 @@ Message ends."}
floor += 1

if(iswallturf(T))
if(T.intact)
wall += 2
else
wall += 1
wall += 2

if(istype(T, /turf/simulated/wall/r_wall))
if(T.intact)
r_wall += 2
else
r_wall += 1
r_wall += 2

for(var/obj/O in T.contents)
if(istype(O, /obj/structure/window))
Expand Down
36 changes: 3 additions & 33 deletions code/game/machinery/Beacon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
icon_state = "floor_beaconf"
name = "Bluespace Gigabeacon"
desc = "A device that draws power from bluespace and creates a permanent tracking beacon."
level = 1 // underfloor
layer = 2.5
anchored = TRUE
use_power = IDLE_POWER_USE
Expand All @@ -13,41 +12,12 @@

/obj/machinery/bluespace_beacon/atom_init()
. = ..()
var/turf/T = loc
Beacon = new /obj/item/device/radio/beacon
Beacon.invisibility = INVISIBILITY_MAXIMUM
Beacon.loc = T

hide(T.intact)
Beacon = new /obj/item/device/radio/beacon(src)

AddElement(/datum/element/undertile, TRAIT_T_RAY_VISIBLE, use_alpha = TRUE)

/obj/machinery/bluespace_beacon/Destroy()
if(Beacon)
qdel(Beacon)
return ..()

// update the invisibility and icon
/obj/machinery/bluespace_beacon/hide(intact)
invisibility = intact ? 101 : 0
updateicon()

// update the icon_state
/obj/machinery/bluespace_beacon/proc/updateicon()
var/state="floor_beacon"

if(invisibility)
icon_state = "[state]f"

else
icon_state = "[state]"

/obj/machinery/bluespace_beacon/process()
if(!Beacon)
var/turf/T = loc
Beacon = new /obj/item/device/radio/beacon
Beacon.invisibility = INVISIBILITY_MAXIMUM
Beacon.loc = T
if(Beacon)
if(Beacon.loc != loc)
Beacon.loc = loc

updateicon()
22 changes: 3 additions & 19 deletions code/game/machinery/magnet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
icon_state = "floor_magnet-f"
name = "Electromagnetic Generator"
desc = "A device that uses station power to create points of magnetic energy."
level = 1 // underfloor
layer = 2.5
anchored = TRUE
use_power = IDLE_POWER_USE
Expand All @@ -30,29 +29,14 @@

/obj/machinery/magnetic_module/atom_init()
. = ..()
var/turf/T = loc
hide(T.intact)
center = T
center = loc
radio_controller.add_object(src, freq, RADIO_MAGNETS)
INVOKE_ASYNC(src, PROC_REF(magnetic_process))

// update the invisibility and icon
/obj/machinery/magnetic_module/hide(intact)
invisibility = intact ? 101 : 0
updateicon()
AddElement(/datum/element/undertile, TRAIT_T_RAY_VISIBLE, use_alpha = TRUE)

// update the icon_state
/obj/machinery/magnetic_module/proc/updateicon()
var/state = "floor_magnet"
var/onstate = ""
if(!on)
onstate = "0"

if(invisibility)
icon_state = "[state][onstate]-f" // if invisible, set icon to faded version
// in case of being revealed by T-scanner
else
icon_state = "[state][onstate]"
icon_state = "floor_magnet[on ? "" : "0"]"

/obj/machinery/magnetic_module/receive_signal(datum/signal/signal)
var/command = signal.data["command"]
Expand Down
26 changes: 5 additions & 21 deletions code/game/machinery/navbeacon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
icon_state = "navbeacon0-f"
name = "Navigation Beacon"
desc = "A radio beacon used for bot navigation."
level = 1 // underfloor
layer = 2.5
anchored = TRUE
interact_offline = TRUE
Expand All @@ -25,10 +24,10 @@
/obj/machinery/navbeacon/atom_init()
. = ..()
set_codes()
var/turf/T = loc
hide(T.intact)
radio_controller.add_object(src, freq, RADIO_NAVBEACONS)

AddElement(/datum/element/undertile, TRAIT_T_RAY_VISIBLE, use_alpha = TRUE)

/obj/machinery/navbeacon/Destroy()
if(radio_controller)
radio_controller.remove_object(src, freq)
Expand All @@ -52,23 +51,8 @@
else
codes[e] = "1"


// called when turf state changes
// hide the object if turf is intact
/obj/machinery/navbeacon/hide(intact)
invisibility = intact ? 101 : 0
updateicon()

// update the icon_state
/obj/machinery/navbeacon/proc/updateicon()
var/state="navbeacon[open]"

if(invisibility)
icon_state = "[state]-f" // if invisible, set icon to faded version
// in case revealed by T-scanner
else
icon_state = "[state]"

icon_state = "navbeacon[open]"

// look for a signal of the form "findbeacon=X"
// where X is any
Expand Down Expand Up @@ -102,7 +86,7 @@

/obj/machinery/navbeacon/attackby(obj/item/I, mob/user)
var/turf/T = loc
if(T.intact)
if(T.underfloor_accessibility < UNDERFLOOR_INTERACTABLE)
return // prevent intraction when T-scanner revealed

if(isscrewing(I))
Expand Down Expand Up @@ -135,7 +119,7 @@
var/ai = isAI(user) || isobserver(user)

var/turf/T = loc
if(T.intact)
if(T.underfloor_accessibility < UNDERFLOOR_INTERACTABLE)
return // prevent intraction when T-scanner revealed

if(!open && !ai) // can't alter controls if not open, unless you're an AI
Expand Down
1 change: 0 additions & 1 deletion code/game/machinery/pipe/construction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Buildable meters
icon_state = "simple"
item_state = "buildpipe"
w_class = SIZE_SMALL
level = 2

var/pipe_type = 0
var/pipename
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/syndicatebeacon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
return
else
var/turf/T = loc
if(isturf(T) && !T.intact)
if(isturf(T) && T.underfloor_accessibility >= UNDERFLOOR_INTERACTABLE)
attached = locate() in T
if(!attached)
to_chat(user, "This device must be placed over an exposed cable.")
Expand Down
Loading

0 comments on commit f388d0f

Please sign in to comment.