Files
CHOMPStation2/code/ATMOSPHERICS/pipes/universal.dm
Leshana 741e02407a Port SSoverlays & Convert turfs to use it (#5004)
* Added "Display Initialize() Log" admin debug command so you can see it mid-round.

* Ported the core of the overlays management subsystem from /tg

- Added SSoverlays subsystem for compiling overlay lists and applying them to atoms in a controlled anti-lag subsystem.
- Added vars and procs to atom which should eventually replace all direct interaction with BYOND's /atom/overlays var outside the subsystem.
- Added OVERLAY_QUEUED flag to var/atom/flags bitfield.
- Added small framework for subsystem performance tracking. So far used only by SSoverlays
- Added admin debug command "Display overlay Log" to see performance stats mid-round.

* Fix runtime on universal pipe adaptor update_icons

* Workaround for appearance_bro not initialized

Unfortuantely BYOND's initialization order is strange, and the appearance_bro var is only half initialized when map starts to load, causing errors.  We temporarily fix by moving it to be a global-scoped global.

* Convert fire alarms to use add_overlay() A good first test.

* Convert turfs to use add_overlays(), eliminating the turf_overlay_holder!

- Converted as much as I could find about turf overlays to use add_overlay().
- This should be enough to stop BYOND from crashing, so we can eliminate the turf_overlay_holder hack.
- This also lets us remove the anti-corruption hacks from walls and open space.
- ZAS gas overlays can use priority overlays, so this also fixes the gas-goes-away-when-crowbarring-plating issue.
- Stuff like that

* Convert turf overlay interactions to use add_overlay.

Note: This is a plain and simple conversion of existing code to use SSoverlays. However I look at the line changed, and note that that line likely never fully worked as intended, as it has no way of re-applying itself.
I would make it use a priority overlay, but there is no code present for *removing* said overlay from neighbors when it is no longer required.  That code should be implemented by original author.
2018-03-05 19:43:23 -06:00

103 lines
3.4 KiB
Plaintext

//
// Universal Pipe Adapter - Designed for connecting scrubbers, normal, and supply pipes together.
//
/obj/machinery/atmospherics/pipe/simple/visible/universal
name="Universal pipe adapter"
desc = "An adapter for regular, supply and scrubbers pipes"
connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_SUPPLY|CONNECT_TYPE_SCRUBBER
icon_state = "map_universal"
/obj/machinery/atmospherics/pipe/simple/visible/universal/update_icon(var/safety = 0)
if(!check_icon_cache())
return
alpha = 255
overlays.Cut()
overlays += icon_manager.get_atmos_icon("pipe", , pipe_color, "universal")
underlays.Cut()
if (node1)
universal_underlays(node1)
if(node2)
universal_underlays(node2)
else
var/node1_dir = get_dir(node1,src)
universal_underlays(,node1_dir)
else if (node2)
universal_underlays(node2)
else
universal_underlays(,dir)
universal_underlays(,turn(dir, -180))
/obj/machinery/atmospherics/pipe/simple/visible/universal/update_underlays()
..()
update_icon()
/obj/machinery/atmospherics/pipe/simple/hidden/universal
name="Universal pipe adapter"
desc = "An adapter for regular, supply and scrubbers pipes"
connect_types = CONNECT_TYPE_REGULAR|CONNECT_TYPE_SUPPLY|CONNECT_TYPE_SCRUBBER
icon_state = "map_universal"
/obj/machinery/atmospherics/pipe/simple/hidden/universal/update_icon(var/safety = 0)
if(!check_icon_cache())
return
alpha = 255
overlays.Cut()
overlays += icon_manager.get_atmos_icon("pipe", , pipe_color, "universal")
underlays.Cut()
if (node1)
universal_underlays(node1)
if(node2)
universal_underlays(node2)
else
var/node2_dir = turn(get_dir(src,node1),-180)
universal_underlays(,node2_dir)
else if (node2)
universal_underlays(node2)
var/node1_dir = turn(get_dir(src,node2),-180)
universal_underlays(,node1_dir)
else
universal_underlays(,dir)
universal_underlays(,turn(dir, -180))
/obj/machinery/atmospherics/pipe/simple/hidden/universal/update_underlays()
..()
update_icon()
/obj/machinery/atmospherics/proc/universal_underlays(var/obj/machinery/atmospherics/node, var/direction)
var/turf/T = loc
if(node)
var/node_dir = get_dir(src,node)
if(node.icon_connect_type == "-supply")
add_underlay_adapter(T, , node_dir, "")
add_underlay_adapter(T, node, node_dir, "-supply")
add_underlay_adapter(T, , node_dir, "-scrubbers")
else if (node.icon_connect_type == "-scrubbers")
add_underlay_adapter(T, , node_dir, "")
add_underlay_adapter(T, , node_dir, "-supply")
add_underlay_adapter(T, node, node_dir, "-scrubbers")
else
add_underlay_adapter(T, node, node_dir, "")
add_underlay_adapter(T, , node_dir, "-supply")
add_underlay_adapter(T, , node_dir, "-scrubbers")
else
add_underlay_adapter(T, , direction, "-supply")
add_underlay_adapter(T, , direction, "-scrubbers")
add_underlay_adapter(T, , direction, "")
/obj/machinery/atmospherics/proc/add_underlay_adapter(var/turf/T, var/obj/machinery/atmospherics/node, var/direction, var/icon_connect_type) //modified from add_underlay, does not make exposed underlays
if(node)
if(!T.is_plating() && node.level == 1 && istype(node, /obj/machinery/atmospherics/pipe))
underlays += icon_manager.get_atmos_icon("underlay", direction, color_cache_name(node), "down" + icon_connect_type)
else
underlays += icon_manager.get_atmos_icon("underlay", direction, color_cache_name(node), "intact" + icon_connect_type)
else
underlays += icon_manager.get_atmos_icon("underlay", direction, color_cache_name(node), "retracted" + icon_connect_type)