diff --git a/code/ATMOSPHERICS/components/binary_devices/binary_atmos_base.dm b/code/ATMOSPHERICS/components/binary_devices/binary_atmos_base.dm index e36e7989db4..c964de9a2c3 100644 --- a/code/ATMOSPHERICS/components/binary_devices/binary_atmos_base.dm +++ b/code/ATMOSPHERICS/components/binary_devices/binary_atmos_base.dm @@ -1,4 +1,4 @@ -/obj/machinery/atmospherics/binary +/obj/machinery/atmospherics/components/binary icon = 'icons/obj/atmospherics/binary_devices.dmi' dir = SOUTH initialize_directions = SOUTH|NORTH @@ -13,9 +13,7 @@ var/datum/pipeline/parent1 var/datum/pipeline/parent2 - var/showpipe = 0 - -/obj/machinery/atmospherics/binary/New() +/obj/machinery/atmospherics/components/binary/New() ..() air1 = new @@ -24,7 +22,7 @@ air1.volume = 200 air2.volume = 200 -/obj/machinery/atmospherics/binary/SetInitDirections() +/obj/machinery/atmospherics/components/binary/SetInitDirections() switch(dir) if(NORTH) initialize_directions = NORTH|SOUTH @@ -35,35 +33,35 @@ if(WEST) initialize_directions = EAST|WEST -//Separate this because we don't need to update pipe icons if we just are going to change the state -/obj/machinery/atmospherics/binary/proc/update_icon_nopipes() - return - -/obj/machinery/atmospherics/binary/update_icon() +/obj/machinery/atmospherics/components/binary/update_icon() + nodes = list(node1, node2) + ..() +/* /obj/machinery/atmospherics/components/binary/update_icon() update_icon_nopipes() underlays.Cut() - if(showpipe) - var/connected = 0 + if(!showpipe) + return + var/connected = 0 - //Add intact pieces - if(node1) - connected = icon_addintact(node1, connected) + //Add intact pieces + if(node1) + connected = icon_addintact(node1, connected) - if(node2) - connected = icon_addintact(node2, connected) + if(node2) + connected = icon_addintact(node2, connected) - //Add broken pieces - icon_addbroken(connected) + //Add broken pieces + icon_addbroken(connected) */ -/obj/machinery/atmospherics/binary/hide(var/intact) +/obj/machinery/atmospherics/components/binary/hide(var/intact) showpipe = !intact update_icon() ..(intact) // Housekeeping and pipe network stuff below -/obj/machinery/atmospherics/binary/Destroy() +/obj/machinery/atmospherics/components/binary/Destroy() if(node1) node1.disconnect(src) node1 = null @@ -74,7 +72,7 @@ nullifyPipenet(parent2) ..() -/obj/machinery/atmospherics/binary/atmosinit() +/obj/machinery/atmospherics/components/binary/atmosinit() var/node2_connect = dir var/node1_connect = turn(dir, 180) @@ -95,12 +93,12 @@ update_icon() ..() -/obj/machinery/atmospherics/binary/construction() +/obj/machinery/atmospherics/components/binary/construction() ..() parent1.update = 1 parent2.update = 1 -/obj/machinery/atmospherics/binary/build_network() +/obj/machinery/atmospherics/components/binary/build_network() if(!parent1) parent1 = new /datum/pipeline() parent1.build_pipeline(src) @@ -109,7 +107,7 @@ parent2 = new /datum/pipeline() parent2.build_pipeline(src) -/obj/machinery/atmospherics/binary/disconnect(obj/machinery/atmospherics/reference) +/obj/machinery/atmospherics/components/binary/disconnect(obj/machinery/atmospherics/reference) if(reference == node1) if(istype(node1, /obj/machinery/atmospherics/pipe)) qdel(parent1) @@ -120,7 +118,7 @@ node2 = null update_icon() -/obj/machinery/atmospherics/binary/nullifyPipenet(datum/pipeline/P) +/obj/machinery/atmospherics/components/binary/nullifyPipenet(datum/pipeline/P) ..() if(P == parent1) parent1.other_airs -= air1 @@ -129,13 +127,13 @@ parent2.other_airs -= air2 parent2 = null -/obj/machinery/atmospherics/binary/returnPipenetAir(datum/pipeline/P) +/obj/machinery/atmospherics/components/binary/returnPipenetAir(datum/pipeline/P) if(P == parent1) return air1 else if(P == parent2) return air2 -/obj/machinery/atmospherics/binary/pipeline_expansion(datum/pipeline/P) +/obj/machinery/atmospherics/components/binary/pipeline_expansion(datum/pipeline/P) if(P) if(parent1 == P) return list(node1) @@ -144,26 +142,26 @@ else return list(node1, node2) -/obj/machinery/atmospherics/binary/setPipenet(datum/pipeline/P, obj/machinery/atmospherics/A) +/obj/machinery/atmospherics/components/binary/setPipenet(datum/pipeline/P, obj/machinery/atmospherics/A) if(A == node1) parent1 = P else if(A == node2) parent2 = P -/obj/machinery/atmospherics/binary/returnPipenet(obj/machinery/atmospherics/A) +/obj/machinery/atmospherics/components/binary/returnPipenet(obj/machinery/atmospherics/A) if(A == node1) return parent1 else if(A == node2) return parent2 -/obj/machinery/atmospherics/binary/replacePipenet(datum/pipeline/Old, datum/pipeline/New) +/obj/machinery/atmospherics/components/binary/replacePipenet(datum/pipeline/Old, datum/pipeline/New) if(Old == parent1) parent1 = New else if(Old == parent2) parent2 = New -/obj/machinery/atmospherics/binary/unsafe_pressure_release(var/mob/user,var/pressures) +/obj/machinery/atmospherics/components/binary/unsafe_pressure_release(var/mob/user,var/pressures) ..() var/turf/T = get_turf(src) diff --git a/code/ATMOSPHERICS/components/components_base.dm b/code/ATMOSPHERICS/components/components_base.dm new file mode 100644 index 00000000000..abe14cb61d2 --- /dev/null +++ b/code/ATMOSPHERICS/components/components_base.dm @@ -0,0 +1,53 @@ +/* +So much of atmospherics.dm was used solely by components, so separating this makes things all a lot cleaner. +On top of that, now people can add component-speciic procs/vars if they want! +*/ + +var/welded = 0 //Used on pumps and scrubbers +var/showpipe = 0 +var/nodes = list() + +/* +Iconnery +*/ + +/obj/machinery/atmospherics/components/proc/icon_addintact(var/obj/machinery/atmospherics/node, var/connected = 0) + var/image/img = getpipeimage('icons/obj/atmospherics/binary_devices.dmi', "pipe_intact", get_dir(src,node), node.pipe_color) + underlays += img + + return connected | img.dir + +/obj/machinery/atmospherics/components/proc/icon_addbroken(var/connected = 0) + var/unconnected = (~connected) & initialize_directions + for(var/direction in cardinal) + if(unconnected & direction) + underlays += getpipeimage('icons/obj/atmospherics/binary_devices.dmi', "pipe_exposed", direction) + +/obj/machinery/atmospherics/components/proc/update_icon_nopipes() + return + +/obj/machinery/atmospherics/components/update_icon(var/update_nodes[] = nodes) + update_icon_nopipes() + + underlays.Cut() + if(!showpipe) + return //no need to update the pipes if they aren't showing + + var/connected = 0 + + for(var/N in nodes) //adds intact pieces + var/obj/machinery/atmospherics/node = N + if(node) + connected = icon_addintact(node, connected) + + icon_addbroken(connected) //adds broken pieces + +/* +I think this is NanoUI? +*/ + +/obj/machinery/atmospherics/components/proc/safe_input(var/title, var/text, var/default_set) + var/new_value = input(usr,text,title,default_set) as num + if(usr.canUseTopic(src)) + return new_value + return default_set \ No newline at end of file diff --git a/code/ATMOSPHERICS/components/trinary_devices/trinary_base.dm b/code/ATMOSPHERICS/components/trinary_devices/trinary_base.dm index d756a14e444..3961aaf50ba 100644 --- a/code/ATMOSPHERICS/components/trinary_devices/trinary_base.dm +++ b/code/ATMOSPHERICS/components/trinary_devices/trinary_base.dm @@ -1,4 +1,4 @@ -/obj/machinery/atmospherics/trinary +/obj/machinery/atmospherics/components/trinary icon = 'icons/obj/atmospherics/trinary_devices.dmi' dir = SOUTH initialize_directions = SOUTH|NORTH|WEST @@ -18,7 +18,7 @@ var/flipped = 0 -/obj/machinery/atmospherics/trinary/New() +/obj/machinery/atmospherics/components/trinary/New() ..() air1 = new @@ -29,7 +29,7 @@ air2.volume = 200 air3.volume = 200 -/obj/machinery/atmospherics/trinary/SetInitDirections() +/obj/machinery/atmospherics/components/trinary/SetInitDirections() switch(dir) if(NORTH) initialize_directions = EAST|NORTH|SOUTH @@ -42,10 +42,11 @@ /* Iconnery */ -/obj/machinery/atmospherics/trinary/proc/update_icon_nopipes() - return +/obj/machinery/atmospherics/components/trinary/update_icon() + nodes = list(node1, node2, node3) + ..() -/obj/machinery/atmospherics/trinary/update_icon() +/* /obj/machinery/atmospherics/components/trinary/update_icon() update_icon_nopipes() var/connected = 0 @@ -62,12 +63,12 @@ Iconnery connected = icon_addintact(node3, connected) //Add broken pieces - icon_addbroken(connected) + icon_addbroken(connected) */ /* Housekeeping and pipe network stuff below */ -/obj/machinery/atmospherics/trinary/Destroy() +/obj/machinery/atmospherics/components/trinary/Destroy() if(node1) node1.disconnect(src) node1 = null @@ -82,7 +83,7 @@ Housekeeping and pipe network stuff below nullifyPipenet(parent3) ..() -/obj/machinery/atmospherics/trinary/atmosinit() +/obj/machinery/atmospherics/components/trinary/atmosinit() //Mixer: //1 and 2 is input @@ -118,16 +119,19 @@ Housekeeping and pipe network stuff below node3 = target break + if(level == 2) + showpipe = 1 + update_icon() ..() -/obj/machinery/atmospherics/trinary/construction() +/obj/machinery/atmospherics/components/trinary/construction() ..() parent1.update = 1 parent2.update = 1 parent3.update = 1 -/obj/machinery/atmospherics/trinary/build_network() +/obj/machinery/atmospherics/components/trinary/build_network() if(!parent1) parent1 = new /datum/pipeline() parent1.build_pipeline(src) @@ -140,7 +144,7 @@ Housekeeping and pipe network stuff below parent3 = new /datum/pipeline() parent3.build_pipeline(src) -/obj/machinery/atmospherics/trinary/disconnect(obj/machinery/atmospherics/reference) +/obj/machinery/atmospherics/components/trinary/disconnect(obj/machinery/atmospherics/reference) if(reference == node1) if(istype(node1, /obj/machinery/atmospherics/pipe)) qdel(parent1) @@ -155,7 +159,7 @@ Housekeeping and pipe network stuff below node3 = null update_icon() -/obj/machinery/atmospherics/trinary/nullifyPipenet(datum/pipeline/P) +/obj/machinery/atmospherics/components/trinary/nullifyPipenet(datum/pipeline/P) ..() if(P == parent1) parent1.other_airs -= air1 @@ -167,7 +171,7 @@ Housekeeping and pipe network stuff below parent3.other_airs -= air3 parent3 = null -/obj/machinery/atmospherics/trinary/returnPipenetAir(datum/pipeline/P) +/obj/machinery/atmospherics/components/trinary/returnPipenetAir(datum/pipeline/P) if(P == parent1) return air1 else if(P == parent2) @@ -175,7 +179,7 @@ Housekeeping and pipe network stuff below else if(P == parent3) return air3 -/obj/machinery/atmospherics/trinary/pipeline_expansion(datum/pipeline/P) +/obj/machinery/atmospherics/components/trinary/pipeline_expansion(datum/pipeline/P) if(P) if(parent1 == P) return list(node1) @@ -185,7 +189,7 @@ Housekeeping and pipe network stuff below return list(node3) return list(node1, node2, node3) -/obj/machinery/atmospherics/trinary/setPipenet(datum/pipeline/P, obj/machinery/atmospherics/A) +/obj/machinery/atmospherics/components/trinary/setPipenet(datum/pipeline/P, obj/machinery/atmospherics/A) if(A == node1) parent1 = P else if(A == node2) @@ -193,7 +197,7 @@ Housekeeping and pipe network stuff below else if(A == node3) parent3 = P -/obj/machinery/atmospherics/trinary/returnPipenet(obj/machinery/atmospherics/A) +/obj/machinery/atmospherics/components/trinary/returnPipenet(obj/machinery/atmospherics/A) if(A == node1) return parent1 else if(A == node2) @@ -201,7 +205,7 @@ Housekeeping and pipe network stuff below else if(A == node3) return parent3 -/obj/machinery/atmospherics/trinary/replacePipenet(datum/pipeline/Old, datum/pipeline/New) +/obj/machinery/atmospherics/components/trinary/replacePipenet(datum/pipeline/Old, datum/pipeline/New) if(Old == parent1) parent1 = New else if(Old == parent2) @@ -210,7 +214,7 @@ Housekeeping and pipe network stuff below parent3 = New -/obj/machinery/atmospherics/trinary/unsafe_pressure_release(var/mob/user,var/pressures) +/obj/machinery/atmospherics/components/trinary/unsafe_pressure_release(var/mob/user,var/pressures) ..() var/turf/T = get_turf(src) diff --git a/code/ATMOSPHERICS/components/unary_devices/unary_base.dm b/code/ATMOSPHERICS/components/unary_devices/unary_base.dm index 7c2ab9b622c..fe21b9109ba 100644 --- a/code/ATMOSPHERICS/components/unary_devices/unary_base.dm +++ b/code/ATMOSPHERICS/components/unary_devices/unary_base.dm @@ -1,47 +1,39 @@ -/obj/machinery/atmospherics/unary +/obj/machinery/atmospherics/components/unary icon = 'icons/obj/atmospherics/unary_devices.dmi' dir = SOUTH initialize_directions = SOUTH layer = TURF_LAYER+0.1 var/datum/gas_mixture/air_contents var/obj/machinery/atmospherics/node - var/showpipe = 0 -/obj/machinery/atmospherics/unary/New() +/obj/machinery/atmospherics/components/unary/New() ..() air_contents = new air_contents.volume = 200 -/obj/machinery/atmospherics/unary/SetInitDirections() +/obj/machinery/atmospherics/components/unary/SetInitDirections() initialize_directions = dir /* Iconnery */ -//Separate this because we don't need to update pipe icons if we just are going to change the state -/obj/machinery/atmospherics/unary/proc/update_icon_nopipes() - return - -/obj/machinery/atmospherics/unary/update_icon() +/obj/machinery/atmospherics/components/unary/update_icon() + nodes = list(node) + ..() +/* /obj/machinery/atmospherics/components/unary/update_icon() update_icon_nopipes() - //This code might be a bit specific to scrubber, vents and injectors, but honestly they are basically the only ones used in the unary branch. - underlays.Cut() - if(showpipe) - var/state - var/col - if(node) - state = "pipe_intact" - col = node.pipe_color - else - state = "pipe_exposed" + if(!showpipe) + return //no need to continue if we're not showing pipes + if(node) + icon_addintact(node) + return + icon_addbroken() */ - underlays += getpipeimage('icons/obj/atmospherics/binary_devices.dmi', state, initialize_directions, col) - -/obj/machinery/atmospherics/unary/hide(var/intact) +/obj/machinery/atmospherics/components/unary/hide(var/intact) showpipe = !intact update_icon() @@ -51,7 +43,7 @@ Iconnery Housekeeping and pipe network stuff below */ -/obj/machinery/atmospherics/unary/Destroy() +/obj/machinery/atmospherics/components/unary/Destroy() if(node) node.disconnect(src) node = null @@ -59,7 +51,7 @@ Housekeeping and pipe network stuff below ..() -/obj/machinery/atmospherics/unary/atmosinit() +/obj/machinery/atmospherics/components/unary/atmosinit() for(var/obj/machinery/atmospherics/target in get_step(src, dir)) if(target.initialize_directions & get_dir(target,src)) node = target @@ -69,11 +61,11 @@ Housekeeping and pipe network stuff below update_icon() ..() -/obj/machinery/atmospherics/unary/construction() +/obj/machinery/atmospherics/components/unary/construction() ..() parent.update = 1 -/obj/machinery/atmospherics/unary/default_change_direction_wrench(mob/user, obj/item/weapon/wrench/W) +/obj/machinery/atmospherics/components/unary/default_change_direction_wrench(mob/user, obj/item/weapon/wrench/W) if(..()) initialize_directions = dir if(node) @@ -89,38 +81,38 @@ Housekeeping and pipe network stuff below build_network() . = 1 -/obj/machinery/atmospherics/unary/build_network() +/obj/machinery/atmospherics/components/unary/build_network() if(!parent) parent = new /datum/pipeline() parent.build_pipeline(src) -/obj/machinery/atmospherics/unary/disconnect(obj/machinery/atmospherics/reference) +/obj/machinery/atmospherics/components/unary/disconnect(obj/machinery/atmospherics/reference) if(reference == node) if(istype(node, /obj/machinery/atmospherics/pipe)) qdel(parent) node = null update_icon() -/obj/machinery/atmospherics/unary/nullifyPipenet() +/obj/machinery/atmospherics/components/unary/nullifyPipenet() ..() parent.other_airs -= air_contents parent = null -/obj/machinery/atmospherics/unary/returnPipenetAir() +/obj/machinery/atmospherics/components/unary/returnPipenetAir() return air_contents -/obj/machinery/atmospherics/unary/pipeline_expansion() +/obj/machinery/atmospherics/components/unary/pipeline_expansion() return list(node) -/obj/machinery/atmospherics/unary/setPipenet(datum/pipeline/P) +/obj/machinery/atmospherics/components/unary/setPipenet(datum/pipeline/P) parent = P -/obj/machinery/atmospherics/unary/replacePipenet(datum/pipeline/Old, datum/pipeline/New) +/obj/machinery/atmospherics/components/unary/replacePipenet(datum/pipeline/Old, datum/pipeline/New) if(Old == parent) parent = New -/obj/machinery/atmospherics/unary/unsafe_pressure_release(var/mob/user,var/pressures) +/obj/machinery/atmospherics/components/unary/unsafe_pressure_release(var/mob/user,var/pressures) ..() var/turf/T = get_turf(src) diff --git a/icons/obj/atmospherics/trinary_devices.dmi b/icons/obj/atmospherics/trinary_devices.dmi index 7eabbd65d01..6c96035c4a7 100644 Binary files a/icons/obj/atmospherics/trinary_devices.dmi and b/icons/obj/atmospherics/trinary_devices.dmi differ