Files
CHOMPStation2/code/ATMOSPHERICS/pipes/pipe_base.dm
Leshana 7da46a6dcc Switch cables and pipes to use define constants instead of literals for layers.
Also fix a few things to be on the correct plane.  Basically the under-floor stuff is supposed to be on PLATING_PLANE.
Portable atmospherics go on object layer so they are above stationary machinery, given that they move around.
Fixed wires to be on top of pipes like they used to be, otherwise they'd be obscured too often.
2018-04-02 21:50:03 -04:00

143 lines
4.2 KiB
Plaintext

//
// Base type of pipes
//
/obj/machinery/atmospherics/pipe
var/datum/gas_mixture/air_temporary // used when reconstructing a pipeline that broke
var/datum/pipeline/parent
var/volume = 0
layer = PIPES_LAYER
use_power = 0
pipe_flags = 0 // Does not have PIPING_DEFAULT_LAYER_ONLY flag.
var/alert_pressure = 80*ONE_ATMOSPHERE
//minimum pressure before check_pressure(...) should be called
can_buckle = 1
buckle_require_restraints = 1
buckle_lying = -1
/obj/machinery/atmospherics/pipe/drain_power()
return -1
/obj/machinery/atmospherics/pipe/New()
if(istype(get_turf(src), /turf/simulated/wall) || istype(get_turf(src), /turf/simulated/shuttle/wall) || istype(get_turf(src), /turf/unsimulated/wall))
level = 1
..()
/obj/machinery/atmospherics/pipe/hides_under_flooring()
return level != 2
/obj/machinery/atmospherics/pipe/proc/pipeline_expansion()
return null
// For pipes this is the same as pipeline_expansion()
/obj/machinery/atmospherics/pipe/get_neighbor_nodes_for_init()
return pipeline_expansion()
/obj/machinery/atmospherics/pipe/proc/check_pressure(pressure)
//Return 1 if parent should continue checking other pipes
//Return null if parent should stop checking other pipes. Recall: qdel(src) will by default return null
return 1
/obj/machinery/atmospherics/pipe/return_air()
if(!parent)
parent = new /datum/pipeline()
parent.build_pipeline(src)
return parent.air
/obj/machinery/atmospherics/pipe/build_network()
if(!parent)
parent = new /datum/pipeline()
parent.build_pipeline(src)
return parent.return_network()
/obj/machinery/atmospherics/pipe/network_expand(datum/pipe_network/new_network, obj/machinery/atmospherics/pipe/reference)
if(!parent)
parent = new /datum/pipeline()
parent.build_pipeline(src)
return parent.network_expand(new_network, reference)
/obj/machinery/atmospherics/pipe/return_network(obj/machinery/atmospherics/reference)
if(!parent)
parent = new /datum/pipeline()
parent.build_pipeline(src)
return parent.return_network(reference)
/obj/machinery/atmospherics/pipe/Destroy()
qdel_null(parent)
if(air_temporary)
loc.assume_air(air_temporary)
for(var/obj/machinery/meter/meter in loc)
if(meter.target == src)
var/obj/item/pipe_meter/PM = new /obj/item/pipe_meter(loc)
meter.transfer_fingerprints_to(PM)
qdel(meter)
. = ..()
/obj/machinery/atmospherics/pipe/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if (istype(src, /obj/machinery/atmospherics/pipe/tank))
return ..()
if(istype(W,/obj/item/device/pipe_painter))
return 0
if (!istype(W, /obj/item/weapon/wrench))
return ..()
var/turf/T = src.loc
if (level==1 && isturf(T) && !T.is_plating())
to_chat(user, "<span class='warning'>You must remove the plating first.</span>")
return 1
if(!can_unwrench())
to_chat(user, "<span class='warning'>You cannot unwrench \the [src], it is too exerted due to internal pressure.</span>")
add_fingerprint(user)
return 1
playsound(src, W.usesound, 50, 1)
to_chat(user, "<span class='notice'>You begin to unfasten \the [src]...</span>")
if (do_after(user, 40 * W.toolspeed))
user.visible_message( \
"<span class='notice'>\The [user] unfastens \the [src].</span>", \
"<span class='notice'>You have unfastened \the [src].</span>", \
"You hear a ratchet.")
deconstruct()
/obj/machinery/atmospherics/pipe/proc/change_color(var/new_color)
//only pass valid pipe colors please ~otherwise your pipe will turn invisible
if(!pipe_color_check(new_color))
return
pipe_color = new_color
update_icon()
/obj/machinery/atmospherics/pipe/color_cache_name(var/obj/machinery/atmospherics/node)
if(istype(src, /obj/machinery/atmospherics/pipe/tank))
return ..()
if(istype(node, /obj/machinery/atmospherics/pipe/manifold) || istype(node, /obj/machinery/atmospherics/pipe/manifold4w))
if(pipe_color == node.pipe_color)
return node.pipe_color
else
return null
else if(istype(node, /obj/machinery/atmospherics/pipe/simple))
return node.pipe_color
else
return pipe_color
/obj/machinery/atmospherics/pipe/hide(var/i)
if(istype(loc, /turf/simulated))
invisibility = i ? 101 : 0
update_icon()
/obj/machinery/atmospherics/pipe/process()
if(!parent) //This should cut back on the overhead calling build_network thousands of times per cycle
..()
else
. = PROCESS_KILL