diff --git a/code/__DEFINES/atmospherics.dm b/code/__DEFINES/atmospherics.dm index 383e4c8bcc..1273b5e3de 100644 --- a/code/__DEFINES/atmospherics.dm +++ b/code/__DEFINES/atmospherics.dm @@ -177,6 +177,19 @@ #define LAVALAND_EQUIPMENT_EFFECT_PRESSURE 50 //what pressure you have to be under to increase the effect of equipment meant for lavaland #define LAVALAND_DEFAULT_ATMOS "o2=14;n2=23;TEMP=300" +//IF YOU EVER CHANGE THESE CHANGE SPRITES TO MATCH. +#define PIPING_LAYER_MIN 1 +#define PIPING_LAYER_MAX 3 +#define PIPING_LAYER_DEFAULT 2 +#define PIPING_LAYER_P_X 5 +#define PIPING_LAYER_P_Y 5 +#define PIPING_LAYER_LCHANGE 0.05 + +#define PIPING_ALL_LAYER 1 //intended to connect with all layers, check for all instead of just one. +#define PIPING_ONE_PER_TURF 2 //can only be built if nothing else with this flag is on the tile already. +#define PIPING_DEFAULT_LAYER_ONLY 4 //can only exist at PIPING_LAYER_DEFAULT +#define PIPING_CARDINAL_AUTONORMALIZE 8 //north/south east/west doesn't matter, auto normalize on build. + #define THERMAL_ENERGY(gas) (gas.temperature * gas.heat_capacity()) #define ADD_GAS(gas_id, out_list)\ diff --git a/code/__DEFINES/pipe_construction.dm b/code/__DEFINES/pipe_construction.dm index 2d15b8aed3..403c9a061f 100644 --- a/code/__DEFINES/pipe_construction.dm +++ b/code/__DEFINES/pipe_construction.dm @@ -7,24 +7,25 @@ Construction breaks otherwise //Pipes #define PIPE_SIMPLE /obj/machinery/atmospherics/pipe/simple #define PIPE_MANIFOLD /obj/machinery/atmospherics/pipe/manifold -#define PIPE_4WAYMANIFOLD /obj/machinery/atmospherics/pipe/manifold4w +#define PIPE_4WAYMANIFOLD /obj/machinery/atmospherics/pipe/manifold4w #define PIPE_HE /obj/machinery/atmospherics/pipe/heat_exchanging/simple #define PIPE_HE_MANIFOLD /obj/machinery/atmospherics/pipe/heat_exchanging/manifold #define PIPE_HE_4WAYMANIFOLD /obj/machinery/atmospherics/pipe/heat_exchanging/manifold4w #define PIPE_JUNCTION /obj/machinery/atmospherics/pipe/heat_exchanging/junction -#define PIPE_BLUESPACE /obj/machinery/atmospherics/pipe/bluespace +#define PIPE_LAYER_MANIFOLD /obj/machinery/atmospherics/pipe/layer_manifold +#define PIPE_BLUESPACE /obj/machinery/atmospherics/pipe/bluespace //Unary #define PIPE_CONNECTOR /obj/machinery/atmospherics/components/unary/portables_connector #define PIPE_UVENT /obj/machinery/atmospherics/components/unary/vent_pump #define PIPE_SCRUBBER /obj/machinery/atmospherics/components/unary/vent_scrubber #define PIPE_INJECTOR /obj/machinery/atmospherics/components/unary/outlet_injector -#define PIPE_HEAT_EXCHANGE /obj/machinery/atmospherics/components/unary/heat_exchanger +#define PIPE_HEAT_EXCHANGE /obj/machinery/atmospherics/components/unary/heat_exchanger //Binary #define PIPE_PUMP /obj/machinery/atmospherics/components/binary/pump -#define PIPE_PASSIVE_GATE /obj/machinery/atmospherics/components/binary/passive_gate -#define PIPE_VOLUME_PUMP /obj/machinery/atmospherics/components/binary/volume_pump +#define PIPE_PASSIVE_GATE /obj/machinery/atmospherics/components/binary/passive_gate +#define PIPE_VOLUME_PUMP /obj/machinery/atmospherics/components/binary/volume_pump #define PIPE_MVALVE /obj/machinery/atmospherics/components/binary/valve -#define PIPE_DVALVE /obj/machinery/atmospherics/components/binary/valve/digital +#define PIPE_DVALVE /obj/machinery/atmospherics/components/binary/valve/digital //Trinary #define PIPE_GAS_FILTER /obj/machinery/atmospherics/components/trinary/filter #define PIPE_GAS_MIXER /obj/machinery/atmospherics/components/trinary/mixer diff --git a/code/game/machinery/pipe/construction.dm b/code/game/machinery/pipe/construction.dm index 7a8f1f1779..66b451725e 100644 --- a/code/game/machinery/pipe/construction.dm +++ b/code/game/machinery/pipe/construction.dm @@ -19,11 +19,13 @@ Buildable meters item_state = "buildpipe" w_class = WEIGHT_CLASS_NORMAL level = 2 - var/flipped = 0 - var/is_bent = 0 + var/flipped = FALSE + var/is_bent = FALSE + var/piping_layer = PIPING_LAYER_DEFAULT var/static/list/pipe_types = list( PIPE_SIMPLE, \ + PIPE_LAYER_MANIFOLD, \ PIPE_MANIFOLD, \ PIPE_4WAYMANIFOLD, \ PIPE_HE, \ @@ -52,40 +54,58 @@ Buildable meters ..() to_chat(user, "Alt-click to rotate it clockwise.") -/obj/item/pipe/New(loc, pipe_type, dir, obj/machinery/atmospherics/make_from) - ..() +/obj/item/pipe/Initialize(mapload, _pipe_type, _dir, obj/machinery/atmospherics/make_from) if(make_from) - src.setDir(make_from.dir) - src.pipename = make_from.name + setDir(make_from.dir) + pipename = make_from.name add_atom_colour(make_from.color, FIXED_COLOUR_PRIORITY) if(make_from.type in pipe_types) - src.pipe_type = make_from.type + pipe_type = make_from.type + setPipingLayer(make_from.piping_layer) else //make pipe_type a value we can work with for(var/P in pipe_types) if(istype(make_from, P)) - src.pipe_type = P + pipe_type = P break var/obj/machinery/atmospherics/components/trinary/triP = make_from if(istype(triP) && triP.flipped) - src.flipped = 1 - src.setDir(turn(src.dir, -45)) + flipped = TRUE + setDir(turn(dir, -45)) else - src.pipe_type = pipe_type - src.setDir(dir) + pipe_type = _pipe_type + setDir(_dir) - if(src.dir in GLOB.diagonals) - is_bent = 1 + if(_dir in GLOB.diagonals) + is_bent = TRUE update() - src.pixel_x = rand(-5, 5) - src.pixel_y = rand(-5, 5) + pixel_x = rand(-5, 5) + pixel_y = rand(-5, 5) + return ..() + +/obj/item/pipe/dropped() + if(loc) + setPipingLayer(piping_layer) + return ..() + +/obj/item/pipe/proc/setPipingLayer(new_layer = PIPING_LAYER_DEFAULT) + var/obj/machinery/atmospherics/fakeA = get_pipe_cache(pipe_type) + var/nolayer = (fakeA.pipe_flags & PIPING_ALL_LAYER) + if(nolayer) + new_layer = PIPING_LAYER_DEFAULT + piping_layer = new_layer + if(pipe_type != PIPE_LAYER_MANIFOLD) + pixel_x = (piping_layer - PIPING_LAYER_DEFAULT) * PIPING_LAYER_P_X + pixel_y = (piping_layer - PIPING_LAYER_DEFAULT) * PIPING_LAYER_P_Y + layer = initial(layer) + ((piping_layer - PIPING_LAYER_DEFAULT) * PIPING_LAYER_LCHANGE) //update the name and icon of the pipe item depending on the type GLOBAL_LIST_INIT(pipeID2State, list( "[PIPE_SIMPLE]" = "simple", \ "[PIPE_MANIFOLD]" = "manifold", \ + "[PIPE_LAYER_MANIFOLD]" = "layer_manifold", \ "[PIPE_4WAYMANIFOLD]" = "manifold4w", \ "[PIPE_HE]" = "he", \ "[PIPE_HE_MANIFOLD]" = "he_manifold", \ @@ -114,6 +134,7 @@ GLOBAL_LIST_INIT(pipeID2State, list( "[PIPE_SIMPLE]" = "pipe", \ "[PIPE_SIMPLE]_b" = "bent pipe", \ "[PIPE_MANIFOLD]" = "manifold", \ + "[PIPE_LAYER_MANIFOLD]" = "layer manifold", \ "[PIPE_4WAYMANIFOLD]" = "4-way manifold", \ "[PIPE_HE]" = "h/e pipe", \ "[PIPE_HE]_b" = "bent h/e pipe", \ @@ -151,7 +172,7 @@ GLOBAL_LIST_INIT(pipeID2State, list( if ( usr.stat || usr.restrained() || !usr.canmove ) return - src.setDir(turn(src.dir, -90)) + setDir(turn(dir, -90)) fixdir() @@ -166,11 +187,11 @@ GLOBAL_LIST_INIT(pipeID2State, list( return if (pipe_type in list(PIPE_GAS_FILTER, PIPE_GAS_MIXER)) - src.setDir(turn(src.dir, flipped )? 45 : -45) + setDir(turn(dir, flipped )? 45 : -45) flipped = !flipped return - src.setDir(turn(src.dir, -180)) + setDir(turn(dir, -180)) fixdir() @@ -199,7 +220,7 @@ GLOBAL_LIST_INIT(pipeID2State, list( //Helper to clean up dir /obj/item/pipe/proc/fixdir() - if((pipe_type in list (PIPE_SIMPLE, PIPE_HE, PIPE_MVALVE, PIPE_DVALVE)) && !is_bent) + if((pipe_type in list (PIPE_SIMPLE, PIPE_HE, PIPE_MVALVE, PIPE_DVALVE, PIPE_LAYER_MANIFOLD)) && !is_bent) if(dir==SOUTH) setDir(NORTH) else if(dir==WEST) @@ -208,40 +229,54 @@ GLOBAL_LIST_INIT(pipeID2State, list( /obj/item/pipe/attack_self(mob/user) return rotate() +/obj/item/pipe/proc/get_pipe_cache(type, direction) + var/static/list/obj/machinery/atmospherics/check_cache + if(!islist(check_cache)) + check_cache = list() + if(!check_cache[type]) + check_cache[type] = list() + if(!check_cache[type]["[direction]"]) + check_cache[type]["[direction]"] = new type(null, null, direction) + + return check_cache[type]["[direction]"] + /obj/item/pipe/attackby(obj/item/W, mob/user, params) if (!istype(W, /obj/item/wrench)) return ..() - if (!isturf(src.loc)) - return 1 - + if (!isturf(loc)) + return TRUE add_fingerprint(user) fixdir() if(pipe_type in list(PIPE_GAS_MIXER, PIPE_GAS_FILTER)) setDir(unflip(dir)) - var/obj/machinery/atmospherics/A = new pipe_type(src.loc) - A.setDir(src.dir) - A.SetInitDirections() + var/obj/machinery/atmospherics/fakeA = get_pipe_cache(pipe_type, dir) - for(var/obj/machinery/atmospherics/M in src.loc) - if(M == A) //we don't want to check to see if it interferes with itself + for(var/obj/machinery/atmospherics/M in loc) + if((M.pipe_flags & PIPING_ONE_PER_TURF) && (fakeA.pipe_flags & PIPING_ONE_PER_TURF)) //Only one dense/requires density object per tile, eg connectors/cryo/heater/coolers. + to_chat(user, "Something is hogging the tile!") + return TRUE + if((M.piping_layer != piping_layer) && !((M.pipe_flags & PIPING_ALL_LAYER) || (pipe_type == PIPE_LAYER_MANIFOLD))) continue - if(M.GetInitDirections() & A.GetInitDirections()) // matches at least one direction on either type of pipe + if(M.GetInitDirections() & fakeA.GetInitDirections()) // matches at least one direction on either type of pipe to_chat(user, "There is already a pipe at that location!") - qdel(A) - return 1 + return TRUE // no conflicts found + var/obj/machinery/atmospherics/A = new pipe_type(loc) + A.setDir(dir) + A.SetInitDirections() + if(pipename) A.name = pipename var/obj/machinery/atmospherics/components/trinary/T = A if(istype(T)) T.flipped = flipped - A.on_construction(pipe_type, color) + A.on_construction(pipe_type, color, piping_layer) - playsound(src.loc, W.usesound, 50, 1) + playsound(src, W.usesound, 50, 1) user.visible_message( \ "[user] fastens \the [src].", \ "You fasten \the [src].", \ @@ -271,16 +306,33 @@ GLOBAL_LIST_INIT(pipeID2State, list( icon_state = "meter" item_state = "buildpipe" w_class = WEIGHT_CLASS_BULKY + var/piping_layer = PIPING_LAYER_DEFAULT -/obj/item/pipe_meter/attackby(obj/item/W, mob/user, params) +/obj/item/pipe_meter/attackby(obj/item/I, mob/user, params) ..() - if (!istype(W, /obj/item/wrench)) + if (!istype(I, /obj/item/wrench)) return ..() - if(!locate(/obj/machinery/atmospherics/pipe, src.loc)) + var/obj/machinery/atmospherics/pipe/pipe + for(var/obj/machinery/atmospherics/pipe/P in loc) + if(P.piping_layer == piping_layer) + pipe = P + break + if(!pipe) to_chat(user, "You need to fasten it to a pipe!") - return 1 - new/obj/machinery/meter( src.loc ) - playsound(src.loc, W.usesound, 50, 1) + return TRUE + new /obj/machinery/meter(loc, piping_layer) + playsound(src, I.usesound, 50, 1) to_chat(user, "You fasten the meter to the pipe.") qdel(src) + +/obj/item/pipe_meter/dropped() + . = ..() + if(loc) + setAttachLayer(piping_layer) + +/obj/item/pipe_meter/proc/setAttachLayer(new_layer = PIPING_LAYER_DEFAULT) + piping_layer = new_layer + pixel_x = (new_layer - PIPING_LAYER_DEFAULT) * PIPING_LAYER_P_X + pixel_y = (new_layer - PIPING_LAYER_DEFAULT) * PIPING_LAYER_P_Y + diff --git a/code/game/machinery/pipe/pipe_dispenser.dm b/code/game/machinery/pipe/pipe_dispenser.dm index 26559c5ef9..911a81c2fc 100644 --- a/code/game/machinery/pipe/pipe_dispenser.dm +++ b/code/game/machinery/pipe/pipe_dispenser.dm @@ -6,18 +6,21 @@ density = TRUE anchored = TRUE var/wait = 0 + var/piping_layer = PIPING_LAYER_DEFAULT /obj/machinery/pipedispenser/attack_paw(mob/user) - return src.attack_hand(user) + return attack_hand(user) /obj/machinery/pipedispenser/attack_hand(mob/user) if(..()) return 1 var/dat = {" +PIPING LAYER: --[piping_layer]++
Pipes:
Pipe
Bent Pipe
Manifold
+Layer Manifold
4-Way Manifold
Manual Valve
Digital Valve
@@ -53,18 +56,23 @@ usr << browse(null, "window=pipedispenser") return 1 usr.set_machine(src) - src.add_fingerprint(usr) + add_fingerprint(usr) if(href_list["make"]) if(wait < world.time) var/p_type = text2path(href_list["make"]) var/p_dir = text2num(href_list["dir"]) - var/obj/item/pipe/P = new (src.loc, pipe_type=p_type, dir=p_dir) + var/obj/item/pipe/P = new (loc, p_type, p_dir) + P.setPipingLayer(piping_layer) P.add_fingerprint(usr) wait = world.time + 10 if(href_list["makemeter"]) if(wait < world.time ) - new /obj/item/pipe_meter(src.loc) + new /obj/item/pipe_meter(loc) wait = world.time + 15 + if(href_list["layer_up"]) + piping_layer = Clamp(++piping_layer, PIPING_LAYER_MIN, PIPING_LAYER_MAX) + if(href_list["layer_down"]) + piping_layer = Clamp(--piping_layer, PIPING_LAYER_MIN, PIPING_LAYER_MAX) return /obj/machinery/pipedispenser/attackby(obj/item/W, mob/user, params) @@ -75,7 +83,7 @@ return else if (istype(W, /obj/item/wrench)) if (!anchored && !isinspace()) - playsound(src.loc, W.usesound, 50, 1) + playsound(src, W.usesound, 50, 1) to_chat(user, "You begin to fasten \the [src] to the floor...") if (do_after(user, 40*W.toolspeed, target = src)) add_fingerprint(user) @@ -88,7 +96,7 @@ if (usr.machine==src) usr << browse(null, "window=pipedispenser") else if(anchored) - playsound(src.loc, W.usesound, 50, 1) + playsound(src, W.usesound, 50, 1) to_chat(user, "You begin to unfasten \the [src] from the floor...") if (do_after(user, 20*W.toolspeed, target = src)) add_fingerprint(user) @@ -160,11 +168,11 @@ Nah if(..()) return 1 usr.set_machine(src) - src.add_fingerprint(usr) + add_fingerprint(usr) if(href_list["dmake"]) if(wait < world.time) var/p_type = text2num(href_list["dmake"]) - var/obj/structure/disposalconstruct/C = new (src.loc,p_type) + var/obj/structure/disposalconstruct/C = new (loc,p_type) if(!C.can_place()) to_chat(usr, "There's not enough room to build that here!") @@ -211,7 +219,7 @@ Nah if(..()) return 1 usr.set_machine(src) - src.add_fingerprint(usr) + add_fingerprint(usr) if(wait < world.time) if(href_list["tube"]) var/tube_type = text2num(href_list["tube"]) diff --git a/code/game/objects/items/RPD.dm b/code/game/objects/items/RPD.dm index 15abe72a52..0151b0e9e1 100644 --- a/code/game/objects/items/RPD.dm +++ b/code/game/objects/items/RPD.dm @@ -30,10 +30,10 @@ RPD var/selected=0 /datum/pipe_info/New(pid,direction,dt) - src.id=pid - src.icon_state=GLOB.pipeID2State["[pid]"] - src.dir = direction - src.dirtype=dt + id=pid + icon_state=GLOB.pipeID2State["[pid]"] + dir = direction + dirtype=dt /datum/pipe_info/proc/Render(dispenser,label) return "
  • [label]
  • " @@ -67,10 +67,10 @@ GLOBAL_LIST_INIT(disposalpipeID2State, list( icon_state = "meterX" /datum/pipe_info/disposal/New(var/pid,var/dt) - src.id=pid - src.icon_state=GLOB.disposalpipeID2State[pid+1] - src.dir = SOUTH - src.dirtype=dt + id=pid + icon_state=GLOB.disposalpipeID2State[pid+1] + dir = SOUTH + dirtype=dt if(pidDISP_END_CHUTE) icon_state = "con[icon_state]" @@ -80,13 +80,14 @@ GLOBAL_LIST_INIT(disposalpipeID2State, list( //find these defines in code\game\machinery\pipe\consruction.dm GLOBAL_LIST_INIT(RPD_recipes, list( "Pipes" = list( - "Pipe" = new /datum/pipe_info(PIPE_SIMPLE, 1, PIPE_BENDABLE), - //"Bent Pipe" = new /datum/pipe_info(PIPE_SIMPLE, 5, PIPE_BENT), - "Manifold" = new /datum/pipe_info(PIPE_MANIFOLD, 1, PIPE_TRINARY), - "Manual Valve" = new /datum/pipe_info(PIPE_MVALVE, 1, PIPE_BINARY), - "Digital Valve" = new /datum/pipe_info(PIPE_DVALVE, 1, PIPE_BINARY), - "4-Way Manifold" = new /datum/pipe_info(PIPE_4WAYMANIFOLD, 1, PIPE_QUAD), - "Bluespace Pipe" = new /datum/pipe_info(PIPE_BLUESPACE, 1, PIPE_UNARY), + "Pipe" = new /datum/pipe_info(PIPE_SIMPLE, 1, PIPE_BENDABLE), + //"Bent Pipe" = new /datum/pipe_info(PIPE_SIMPLE, 5, PIPE_BENT), + "Manifold" = new /datum/pipe_info(PIPE_MANIFOLD, 1, PIPE_TRINARY), + "Manual Valve" = new /datum/pipe_info(PIPE_MVALVE, 1, PIPE_BINARY), + "Digital Valve" = new /datum/pipe_info(PIPE_DVALVE, 1, PIPE_BINARY), + "4-Way Manifold" = new /datum/pipe_info(PIPE_4WAYMANIFOLD, 1, PIPE_QUAD), + "Layer Manifold" = new /datum/pipe_info(PIPE_LAYER_MANIFOLD, 1, PIPE_BINARY), + "Bluespace Pipe" = new /datum/pipe_info(PIPE_BLUESPACE, 1, PIPE_UNARY), ), "Devices"=list( "Connector" = new /datum/pipe_info(PIPE_CONNECTOR, 1, PIPE_UNARY), @@ -153,6 +154,7 @@ GLOBAL_LIST_INIT(RPD_recipes, list( ) var/paint_color="grey" var/screen = CATEGORY_ATMOS //Starts on the atmos tab. + var/piping_layer = PIPING_LAYER_DEFAULT /obj/item/pipe_dispenser/New() . = ..() @@ -201,6 +203,14 @@ GLOBAL_LIST_INIT(RPD_recipes, list( dat += "Atmospherics Disposals
    " else if(screen == CATEGORY_DISPOSALS) dat += "Atmospherics Disposals
    " + var/generated_layer_list = "" + var/layers_total = PIPING_LAYER_MAX - PIPING_LAYER_MIN + 1 + for(var/iter = PIPING_LAYER_MIN, iter <= layers_total, iter++) + if(iter == piping_layer) + generated_layer_list += "[iter]" + else + generated_layer_list += "[iter]" + dat += "Atmospherics Piping Layer: [generated_layer_list]
    " dat += "" var/icon/preview=null @@ -459,7 +469,7 @@ GLOBAL_LIST_INIT(RPD_recipes, list( usr << browse(null, "window=pipedispenser") return usr.set_machine(src) - src.add_fingerprint(usr) + add_fingerprint(usr) if(href_list["screen"]) screen = text2num(href_list["screen"]) show_menu(usr) @@ -469,11 +479,18 @@ GLOBAL_LIST_INIT(RPD_recipes, list( p_flipped = text2num(href_list["flipped"]) show_menu(usr) + if(href_list["setlayer"]) + if(!isnum(href_list["setlayer"])) + piping_layer = text2num(href_list["setlayer"]) + else + piping_layer = href_list["setlayer"] + show_menu(usr) + if(href_list["eatpipes"]) p_class = EATING_MODE p_conntype=-1 p_dir=1 - src.spark_system.start() + spark_system.start() playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0) show_menu(usr) @@ -481,13 +498,13 @@ GLOBAL_LIST_INIT(RPD_recipes, list( p_class = PAINT_MODE p_conntype = -1 p_dir = 1 - src.spark_system.start() + spark_system.start() playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0) show_menu(usr) if(href_list["set_color"]) paint_color = href_list["set_color"] - src.spark_system.start() + spark_system.start() playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0) show_menu(usr) @@ -496,7 +513,7 @@ GLOBAL_LIST_INIT(RPD_recipes, list( p_dir = text2num(href_list["dir"]) p_conntype = text2num(href_list["type"]) p_class = ATMOS_MODE - src.spark_system.start() + spark_system.start() playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0) show_menu(usr) @@ -504,7 +521,7 @@ GLOBAL_LIST_INIT(RPD_recipes, list( p_class = METER_MODE p_conntype = -1 p_dir = 1 - src.spark_system.start() + spark_system.start() playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0) show_menu(usr) @@ -513,7 +530,7 @@ GLOBAL_LIST_INIT(RPD_recipes, list( p_conntype = text2num(href_list["type"]) p_dir = 1 p_class = DISPOSALS_MODE - src.spark_system.start() + spark_system.start() playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0) show_menu(usr) @@ -522,10 +539,18 @@ GLOBAL_LIST_INIT(RPD_recipes, list( if(!user.IsAdvancedToolUser() || istype(A, /turf/open/space/transit)) return ..() + var/atmos_piping_mode = p_class == ATMOS_MODE || p_class == METER_MODE + var/temp_piping_layer + if(atmos_piping_mode) + if(istype(A, /obj/machinery/atmospherics)) + var/obj/machinery/atmospherics/AM = A + temp_piping_layer = AM.piping_layer + A = get_turf(user) + //make sure what we're clicking is valid for the current mode var/is_paintable = (p_class == PAINT_MODE && istype(A, /obj/machinery/atmospherics/pipe)) var/is_consumable = (p_class == EATING_MODE && (istype(A, /obj/item/pipe) || istype(A, /obj/item/pipe_meter) || istype(A, /obj/structure/disposalconstruct))) - var/can_make_pipe = ((p_class == ATMOS_MODE || p_class == METER_MODE || p_class == DISPOSALS_MODE) && isturf(A)) + var/can_make_pipe = ((atmos_piping_mode || p_class == DISPOSALS_MODE) && isturf(A)) if(!is_paintable && !is_consumable && !can_make_pipe) return ..() @@ -540,10 +565,8 @@ GLOBAL_LIST_INIT(RPD_recipes, list( if(PAINT_MODE) //Paint pipes var/obj/machinery/atmospherics/pipe/P = A playsound(get_turf(src), 'sound/machines/click.ogg', 50, 1) - P.add_atom_colour(paint_colors[paint_color], FIXED_COLOUR_PRIORITY) - P.pipe_color = paint_colors[paint_color] + P.paint(paint_colors[paint_color]) user.visible_message("[user] paints \the [P] [paint_color].","You paint \the [P] [paint_color].") - P.update_node_icon() return if(EATING_MODE) //Eating pipes @@ -558,21 +581,29 @@ GLOBAL_LIST_INIT(RPD_recipes, list( playsound(get_turf(src), 'sound/machines/click.ogg', 50, 1) if(do_after(user, 2, target = A)) activate() - var/obj/item/pipe/P = new (A, pipe_type=queued_p_type, dir=queued_p_dir) + var/obj/item/pipe/P = new(A, queued_p_type, queued_p_dir) P.flipped = queued_p_flipped P.update() P.add_fingerprint(usr) + if(!isnull(temp_piping_layer)) + P.setPipingLayer(temp_piping_layer) + else + P.setPipingLayer(piping_layer) if(METER_MODE) //Making pipe meters to_chat(user, "You start building a meter...") playsound(get_turf(src), 'sound/machines/click.ogg', 50, 1) if(do_after(user, 2, target = A)) activate() - new /obj/item/pipe_meter(A) + var/obj/item/pipe_meter/PM = new /obj/item/pipe_meter(A) + if(!isnull(temp_piping_layer)) + PM.setAttachLayer(temp_piping_layer) + else + PM.setAttachLayer(piping_layer) if(DISPOSALS_MODE) //Making disposals pipes if(isclosedturf(A)) - to_chat(user, "[src]'s error light flickers; there's something in the way!") + to_chat(user, "\the [src]'s error light flickers; there's something in the way!") return to_chat(user, "You start building a disposals pipe...") playsound(get_turf(src), 'sound/machines/click.ogg', 50, 1) diff --git a/code/modules/atmospherics/machinery/atmosmachinery.dm b/code/modules/atmospherics/machinery/atmosmachinery.dm index ce68eecdc9..75e15780f6 100644 --- a/code/modules/atmospherics/machinery/atmosmachinery.dm +++ b/code/modules/atmospherics/machinery/atmosmachinery.dm @@ -25,6 +25,8 @@ Pipelines + Other Objects -> Pipe network var/can_unwrench = 0 var/initialize_directions = 0 var/pipe_color + var/piping_layer = PIPING_LAYER_DEFAULT + var/pipe_flags = NONE var/global/list/iconsetids = list() var/global/list/pipeimages = list() @@ -39,7 +41,11 @@ Pipelines + Other Objects -> Pipe network if(is_type_in_list(src, GLOB.ventcrawl_machinery) && user.ventcrawler) to_chat(user, "Alt-click to crawl through it.") -/obj/machinery/atmospherics/New(loc, process = TRUE) +/obj/machinery/atmospherics/New(loc, process = TRUE, setdir) + if(!isnull(setdir)) + setDir(setdir) + if(pipe_flags & PIPING_CARDINAL_AUTONORMALIZE) + normalize_cardinal_directions() nodes = new(device_type) if (!armor) armor = list(melee = 25, bullet = 10, laser = 10, energy = 100, bomb = 0, bio = 100, rad = 100, fire = 100, acid = 70) @@ -61,6 +67,13 @@ Pipelines + Other Objects -> Pipe network return ..() //return QDEL_HINT_FINDREFERENCE +/obj/machinery/atmospherics/proc/destroy_network() + return + +/obj/machinery/atmospherics/proc/build_network() + // Called to build a network from this node + return + /obj/machinery/atmospherics/proc/nullifyNode(I) if(NODE_I) var/obj/machinery/atmospherics/N = NODE_I @@ -80,6 +93,11 @@ Pipelines + Other Objects -> Pipe network break return node_connects +/obj/machinery/atmospherics/proc/normalize_cardinal_directions() + if(dir==SOUTH) + setDir(NORTH) + else if(dir==WEST) + setDir(EAST) //this is called just after the air controller sets up turfs /obj/machinery/atmospherics/proc/atmosinit(var/list/node_connects) @@ -91,12 +109,37 @@ Pipelines + Other Objects -> Pipe network if(can_be_node(target, I)) NODE_I = target break - update_icon() +/obj/machinery/atmospherics/proc/setPipingLayer(new_layer) + if(pipe_flags & PIPING_DEFAULT_LAYER_ONLY) + new_layer = PIPING_LAYER_DEFAULT + piping_layer = new_layer + pixel_x = (piping_layer - PIPING_LAYER_DEFAULT) * PIPING_LAYER_P_X + pixel_y = (piping_layer - PIPING_LAYER_DEFAULT) * PIPING_LAYER_P_Y + layer = initial(layer) + ((piping_layer - PIPING_LAYER_DEFAULT) * PIPING_LAYER_LCHANGE) + /obj/machinery/atmospherics/proc/can_be_node(obj/machinery/atmospherics/target) - if(target.initialize_directions & get_dir(target,src)) + return connection_check(target, piping_layer) + +//Find a connecting /obj/machinery/atmospherics in specified direction +/obj/machinery/atmospherics/proc/findConnecting(direction, prompted_layer) + for(var/obj/machinery/atmospherics/target in get_step(src, direction)) + if(target.initialize_directions & get_dir(target,src)) + if(connection_check(target, prompted_layer)) + return target + +/obj/machinery/atmospherics/proc/connection_check(obj/machinery/atmospherics/target, given_layer) + if(isConnectable(target, given_layer) && target.isConnectable(src, given_layer) && (target.initialize_directions & get_dir(target,src))) return TRUE + return FALSE + +/obj/machinery/atmospherics/proc/isConnectable(obj/machinery/atmospherics/target, given_layer) + if(isnull(given_layer)) + given_layer = piping_layer + if((target.piping_layer == given_layer) || (target.pipe_flags & PIPING_ALL_LAYER)) + return TRUE + return FALSE /obj/machinery/atmospherics/proc/pipeline_expansion() return nodes @@ -119,14 +162,10 @@ Pipelines + Other Objects -> Pipe network /obj/machinery/atmospherics/proc/replacePipenet() return -/obj/machinery/atmospherics/proc/build_network() - // Called to build a network from this node - return - /obj/machinery/atmospherics/proc/disconnect(obj/machinery/atmospherics/reference) if(istype(reference, /obj/machinery/atmospherics/pipe)) var/obj/machinery/atmospherics/pipe/P = reference - qdel(P.parent) + P.destroy_network() var/I = nodes.Find(reference) NODE_I = null update_icon() @@ -135,12 +174,17 @@ Pipelines + Other Objects -> Pipe network return /obj/machinery/atmospherics/attackby(obj/item/W, mob/user, params) + if(istype(W, /obj/item/pipe)) //lets you autodrop + var/obj/item/pipe/pipe = W + if(user.dropItemToGround(pipe)) + pipe.setPipingLayer(piping_layer) //align it with us + return TRUE if(istype(W, /obj/item/wrench)) if(can_unwrench(user)) var/turf/T = get_turf(src) if (level==1 && isturf(T) && T.intact) to_chat(user, "You must remove the plating first!") - return 1 + return TRUE var/datum/gas_mixture/int_air = return_air() var/datum/gas_mixture/env_air = loc.return_air() add_fingerprint(user) @@ -148,7 +192,7 @@ Pipelines + Other Objects -> Pipe network var/unsafe_wrenching = FALSE var/internal_pressure = int_air.return_pressure()-env_air.return_pressure() - playsound(src.loc, W.usesound, 50, 1) + playsound(src, W.usesound, 50, 1) to_chat(user, "You begin to unfasten \the [src]...") if (internal_pressure > 2*ONE_ATMOSPHERE) to_chat(user, "As you begin unwrenching \the [src] a gush of air blows in your face... maybe you should reconsider?") @@ -193,7 +237,8 @@ Pipelines + Other Objects -> Pipe network /obj/machinery/atmospherics/deconstruct(disassembled = TRUE) if(!(flags_1 & NODECONSTRUCT_1)) if(can_unwrench) - var/obj/item/pipe/stored = new(loc, make_from=src) + var/obj/item/pipe/stored = new(loc, piping_layer, dir, src) + stored.setPipingLayer(piping_layer) if(!disassembled) stored.obj_integrity = stored.max_integrity * 0.5 transfer_fingerprints_to(stored) @@ -224,10 +269,11 @@ Pipelines + Other Objects -> Pipe network if(unconnected & direction) underlays += getpipeimage('icons/obj/atmospherics/components/binary_devices.dmi', "pipe_exposed", direction) -/obj/machinery/atmospherics/on_construction(pipe_type, obj_color) +/obj/machinery/atmospherics/on_construction(pipe_type, obj_color, set_layer) if(can_unwrench) add_atom_colour(obj_color, FIXED_COLOUR_PRIORITY) pipe_color = obj_color + setPipingLayer(set_layer) var/turf/T = get_turf(src) level = T.intact ? 2 : 1 atmosinit() @@ -237,18 +283,16 @@ Pipelines + Other Objects -> Pipe network A.addMember(src) build_network() +/obj/machinery/atmospherics/Entered(atom/movable/AM) + if(istype(AM, /mob/living)) + var/mob/living/L = AM + L.ventcrawl_layer = piping_layer + return ..() + /obj/machinery/atmospherics/singularity_pull(S, current_size) - ..() if(current_size >= STAGE_FIVE) deconstruct(FALSE) - - -//Find a connecting /obj/machinery/atmospherics in specified direction -/obj/machinery/atmospherics/proc/findConnecting(direction) - for(var/obj/machinery/atmospherics/target in get_step(src, direction)) - if(target.initialize_directions & get_dir(target,src)) - return target - + return ..() #define VENT_SOUND_DELAY 30 @@ -259,7 +303,7 @@ Pipelines + Other Objects -> Pipe network if(user in buckled_mobs)// fixes buckle ventcrawl edgecase fuck bug return - var/obj/machinery/atmospherics/target_move = findConnecting(direction) + var/obj/machinery/atmospherics/target_move = findConnecting(direction, user.ventcrawl_layer) if(target_move) if(target_move.can_crawl_through()) if(is_type_in_typecache(target_move, GLOB.ventcrawl_machinery)) @@ -269,14 +313,14 @@ Pipelines + Other Objects -> Pipe network var/list/pipenetdiff = returnPipenets() ^ target_move.returnPipenets() if(pipenetdiff.len) user.update_pipe_vision(target_move) - user.loc = target_move + user.forceMove(target_move) user.client.eye = target_move //Byond only updates the eye every tick, This smooths out the movement if(world.time - user.last_played_vent > VENT_SOUND_DELAY) user.last_played_vent = world.time playsound(src, 'sound/machines/ventcrawl.ogg', 50, 1, -3) else if((direction & initialize_directions) || is_type_in_typecache(src, GLOB.ventcrawl_machinery) && can_crawl_through()) //if we move in a way the pipe can connect, but doesn't - or we're in a vent - user.forceMove(src.loc) + user.forceMove(loc) user.visible_message("You hear something squeezing through the ducts...","You climb out the ventilation system.") user.canmove = 0 spawn(1) diff --git a/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm b/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm index 786aff1038..ef6dd85afa 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/circulator.dm @@ -11,6 +11,7 @@ var/status = 0 var/last_pressure_delta = 0 + pipe_flags = PIPING_ONE_PER_TURF anchored = TRUE density = TRUE diff --git a/code/modules/atmospherics/machinery/components/trinary_devices/trinary_devices.dm b/code/modules/atmospherics/machinery/components/trinary_devices/trinary_devices.dm index 14495cd237..8ba105fdb1 100644 --- a/code/modules/atmospherics/machinery/components/trinary_devices/trinary_devices.dm +++ b/code/modules/atmospherics/machinery/components/trinary_devices/trinary_devices.dm @@ -5,6 +5,7 @@ use_power = IDLE_POWER_USE device_type = TRINARY layer = GAS_FILTER_LAYER + pipe_flags = PIPING_ONE_PER_TURF var/flipped = FALSE diff --git a/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm b/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm index 277608d845..423f3a64a0 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm @@ -11,6 +11,7 @@ layer = ABOVE_WINDOW_LAYER state_open = FALSE circuit = /obj/item/circuitboard/machine/cryo_tube + pipe_flags = PIPING_ONE_PER_TURF | PIPING_DEFAULT_LAYER_ONLY var/on = FALSE var/autoeject = FALSE diff --git a/code/modules/atmospherics/machinery/components/unary_devices/portables_connector.dm b/code/modules/atmospherics/machinery/components/unary_devices/portables_connector.dm index e17a2f796c..ee48889041 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/portables_connector.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/portables_connector.dm @@ -8,6 +8,7 @@ use_power = NO_POWER_USE level = 0 layer = GAS_FILTER_LAYER + pipe_flags = PIPING_ONE_PER_TURF /obj/machinery/atmospherics/components/unary/portables_connector/New() ..() diff --git a/code/modules/atmospherics/machinery/components/unary_devices/tank.dm b/code/modules/atmospherics/machinery/components/unary_devices/tank.dm index ca60c9bf85..04f1068a00 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/tank.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/tank.dm @@ -9,6 +9,7 @@ density = TRUE var/gas_type = 0 layer = ABOVE_WINDOW_LAYER + pipe_flags = PIPING_ONE_PER_TURF /obj/machinery/atmospherics/components/unary/tank/New() ..() diff --git a/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm b/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm index dc482eda02..d7bfe1ecb8 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm @@ -11,6 +11,7 @@ armor = list(melee = 0, bullet = 0, laser = 0, energy = 100, bomb = 0, bio = 100, rad = 100, fire = 80, acid = 30) layer = OBJ_LAYER circuit = /obj/item/circuitboard/machine/thermomachine + pipe_flags = PIPING_ONE_PER_TURF | PIPING_DEFAULT_LAYER_ONLY var/on = FALSE var/min_temperature = 0 diff --git a/code/modules/atmospherics/machinery/components/unary_devices/unary_devices.dm b/code/modules/atmospherics/machinery/components/unary_devices/unary_devices.dm index a6ac9760e8..f629020d74 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/unary_devices.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/unary_devices.dm @@ -3,6 +3,7 @@ dir = SOUTH initialize_directions = SOUTH device_type = UNARY + pipe_flags = PIPING_ONE_PER_TURF /obj/machinery/atmospherics/components/unary/SetInitDirections() initialize_directions = dir diff --git a/code/modules/atmospherics/machinery/other/meter.dm b/code/modules/atmospherics/machinery/other/meter.dm index 124caa23be..7294638162 100644 --- a/code/modules/atmospherics/machinery/other/meter.dm +++ b/code/modules/atmospherics/machinery/other/meter.dm @@ -13,19 +13,33 @@ active_power_usage = 4 max_integrity = 150 armor = list(melee = 0, bullet = 0, laser = 0, energy = 100, bomb = 0, bio = 100, rad = 100, fire = 40, acid = 0) - - -/obj/machinery/meter/Initialize(mapload) - . = ..() - SSair.atmos_machinery += src - if (!target) - target = locate(/obj/machinery/atmospherics/pipe) in loc + var/target_layer = PIPING_LAYER_DEFAULT /obj/machinery/meter/Destroy() SSair.atmos_machinery -= src - src.target = null + target = null return ..() +/obj/machinery/meter/Initialize(mapload, new_piping_layer) + if(!isnull(new_piping_layer)) + target_layer = new_piping_layer + SSair.atmos_machinery += src + if(mapload && !target) + reattach_to_layer() + return ..() + +/obj/machinery/meter/proc/reattach_to_layer() + for(var/obj/machinery/atmospherics/pipe/pipe in loc) + if(pipe.piping_layer == target_layer) + target = pipe + setAttachLayer(pipe.piping_layer) + break + +/obj/machinery/meter/proc/setAttachLayer(var/new_layer) + target_layer = new_layer + pixel_x = (new_layer - PIPING_LAYER_DEFAULT) * PIPING_LAYER_P_X + pixel_y = (new_layer - PIPING_LAYER_DEFAULT) * PIPING_LAYER_P_Y + /obj/machinery/meter/process_atmos() if(!target) icon_state = "meterX" @@ -75,7 +89,7 @@ radio_connection.post_signal(src, signal) /obj/machinery/meter/proc/status() - if (src.target) + if (target) var/datum/gas_mixture/environment = target.return_air() if(environment) . = "The pressure gauge reads [round(environment.return_pressure(), 0.01)] kPa; [round(environment.temperature,0.01)] K ([round(environment.temperature-T0C,0.01)]°C)." @@ -91,23 +105,23 @@ /obj/machinery/meter/attackby(obj/item/W, mob/user, params) if (istype(W, /obj/item/wrench)) - playsound(src.loc, W.usesound, 50, 1) + playsound(src, W.usesound, 50, 1) to_chat(user, "You begin to unfasten \the [src]...") if (do_after(user, 40*W.toolspeed, target = src)) user.visible_message( \ "[user] unfastens \the [src].", \ "You unfasten \the [src].", \ "You hear ratchet.") - new /obj/item/pipe_meter(src.loc) + new /obj/item/pipe_meter(loc) qdel(src) else return ..() /obj/machinery/meter/attack_ai(mob/user) - return src.attack_hand(user) + return attack_hand(user) /obj/machinery/meter/attack_paw(mob/user) - return src.attack_hand(user) + return attack_hand(user) /obj/machinery/meter/attack_hand(mob/user) @@ -129,4 +143,4 @@ /obj/machinery/meter/turf/Initialize() . = ..() - src.target = loc + target = loc diff --git a/code/modules/atmospherics/machinery/pipes/bluespace_pipe.dm b/code/modules/atmospherics/machinery/pipes/bluespace_pipe.dm index 476235d3d9..51e89950c1 100644 --- a/code/modules/atmospherics/machinery/pipes/bluespace_pipe.dm +++ b/code/modules/atmospherics/machinery/pipes/bluespace_pipe.dm @@ -29,7 +29,7 @@ GLOBAL_LIST_EMPTY(bluespace_pipes) /obj/machinery/atmospherics/pipe/bluespace/pipeline_expansion() return ..() + GLOB.bluespace_pipes - src -/obj/machinery/atmospherics/components/pipe/bluespace/hide() +/obj/machinery/atmospherics/pipe/bluespace/hide() update_icon() /obj/machinery/atmospherics/pipe/bluespace/update_icon(showpipe) diff --git a/code/modules/atmospherics/machinery/pipes/layermanifold.dm b/code/modules/atmospherics/machinery/pipes/layermanifold.dm new file mode 100644 index 0000000000..cc9ef36678 --- /dev/null +++ b/code/modules/atmospherics/machinery/pipes/layermanifold.dm @@ -0,0 +1,135 @@ +/obj/machinery/atmospherics/pipe/layer_manifold + name = "pipe-layer manifold" + icon = 'icons/obj/atmospherics/pipes/manifold.dmi' + icon_state = "manifoldlayer" + desc = "A special pipe to bridge pipe layers with." + dir = SOUTH + initialize_directions = NORTH|SOUTH + pipe_flags = PIPING_ALL_LAYER | PIPING_DEFAULT_LAYER_ONLY | PIPING_CARDINAL_AUTONORMALIZE + piping_layer = PIPING_LAYER_DEFAULT + device_type = 0 + volume = 260 + var/list/front_nodes + var/list/back_nodes + +/obj/machinery/atmospherics/pipe/layer_manifold/Initialize() + front_nodes = list() + back_nodes = list() + return ..() + +/obj/machinery/atmospherics/pipe/layer_manifold/Destroy() + nullifyAllNodes() + return ..() + +/obj/machinery/atmospherics/pipe/layer_manifold/proc/nullifyAllNodes() + var/list/obj/machinery/atmospherics/needs_nullifying = get_all_connected_nodes() + front_nodes = null + back_nodes = null + nodes = list() + for(var/obj/machinery/atmospherics/A in needs_nullifying) + A.disconnect(src) + A.build_network() + +/obj/machinery/atmospherics/pipe/layer_manifold/proc/get_all_connected_nodes() + var/list/obj/machinery/atmospherics/all_connected = list() + for(var/obj/machinery/atmospherics/I in front_nodes) + all_connected[I] = I + for(var/obj/machinery/atmospherics/I in back_nodes) + all_connected[I] = I + for(var/obj/machinery/atmospherics/I in nodes) + all_connected[I] = I + var/list/obj/machinery/atmospherics/returnlist = list() + for(var/obj/machinery/atmospherics/A in all_connected) + returnlist += all_connected[A] + return returnlist + +/obj/machinery/atmospherics/pipe/layer_manifold/update_icon() //HEAVILY WIP FOR UPDATE ICONS!! + layer = (initial(layer) + (PIPING_LAYER_MAX * PIPING_LAYER_LCHANGE)) //This is above everything else. + var/invis = invisibility ? "-f" : "" + icon_state = "[initial(icon_state)][invis]" + cut_overlays() + for(var/obj/machinery/atmospherics/A in front_nodes) + add_attached_image(A) + for(var/obj/machinery/atmospherics/A in back_nodes) + add_attached_image(A) + +/obj/machinery/atmospherics/pipe/layer_manifold/proc/add_attached_image(obj/machinery/atmospherics/A) + var/invis = A.invisibility ? "-f" : "" + if(istype(A, /obj/machinery/atmospherics/pipe/layer_manifold)) + for(var/i = PIPING_LAYER_MIN, i <= PIPING_LAYER_MAX, i++) + var/image/I = getpipeimage('icons/obj/atmospherics/pipes/manifold.dmi', "manifold_full_layer_long[invis]", get_dir(src, A), A.pipe_color) + I.pixel_x = (i - PIPING_LAYER_DEFAULT) * PIPING_LAYER_P_X + I.pixel_y = (i - PIPING_LAYER_DEFAULT) * PIPING_LAYER_P_Y + I.layer = layer - 0.01 + add_overlay(I) + else + var/image/I = getpipeimage('icons/obj/atmospherics/pipes/manifold.dmi', "manifold_full_layer_long[invis]", get_dir(src, A), A.pipe_color) + I.pixel_x = A.pixel_x + I.pixel_y = A.pixel_y + I.layer = layer - 0.01 + add_overlay(I) + +/obj/machinery/atmospherics/pipe/layer_manifold/SetInitDirections() + switch(dir) + if(NORTH || SOUTH) + initialize_directions = NORTH|SOUTH + if(EAST || WEST) + initialize_directions = EAST|WEST + +/obj/machinery/atmospherics/pipe/layer_manifold/isConnectable(obj/machinery/atmospherics/target, given_layer) + if(!given_layer) + return TRUE + . = ..() + +/obj/machinery/atmospherics/pipe/layer_manifold/proc/findAllConnections() + front_nodes = list() + back_nodes = list() + var/list/new_nodes = list() + for(var/iter in PIPING_LAYER_MIN to PIPING_LAYER_MAX) + var/obj/machinery/atmospherics/foundfront = findConnecting(dir, iter) + var/obj/machinery/atmospherics/foundback = findConnecting(turn(dir, 180), iter) + front_nodes += foundfront + back_nodes += foundback + if(foundfront && !QDELETED(foundfront)) + new_nodes += foundfront + if(foundback && !QDELETED(foundback)) + new_nodes += foundback + update_icon() + return new_nodes + +/obj/machinery/atmospherics/pipe/layer_manifold/atmosinit() + normalize_cardinal_directions() + findAllConnections() + var/turf/T = loc // hide if turf is not intact + hide(T.intact) + +/obj/machinery/atmospherics/pipe/layer_manifold/setPipingLayer() + piping_layer = PIPING_LAYER_DEFAULT + +/obj/machinery/atmospherics/pipe/layer_manifold/pipeline_expansion() + return get_all_connected_nodes() + +/obj/machinery/atmospherics/pipe/layer_manifold/disconnect(obj/machinery/atmospherics/reference) + if(istype(reference, /obj/machinery/atmospherics/pipe)) + var/obj/machinery/atmospherics/pipe/P = reference + P.destroy_network() + while(reference in get_all_connected_nodes()) + if(reference in nodes) + var/I = nodes.Find(reference) + NODE_I = null + if(reference in front_nodes) + var/I = front_nodes.Find(reference) + front_nodes[I] = null + if(reference in back_nodes) + var/I = back_nodes.Find(reference) + back_nodes[I] = null + update_icon() + +/obj/machinery/atmospherics/pipe/layer_manifold/relaymove(mob/living/user, dir) + if(initialize_directions & dir) + return ..() + if((NORTH|EAST) & dir) + user.ventcrawl_layer = Clamp(user.ventcrawl_layer + 1, PIPING_LAYER_MIN, PIPING_LAYER_MAX) + if((SOUTH|WEST) & dir) + user.ventcrawl_layer = Clamp(user.ventcrawl_layer - 1, PIPING_LAYER_MIN, PIPING_LAYER_MAX) + to_chat(user, "You align yourself with the [user.ventcrawl_layer]\th output.") diff --git a/code/modules/atmospherics/machinery/pipes/manifold.dm b/code/modules/atmospherics/machinery/pipes/manifold.dm index 66b831c477..89aea64a81 100644 --- a/code/modules/atmospherics/machinery/pipes/manifold.dm +++ b/code/modules/atmospherics/machinery/pipes/manifold.dm @@ -125,7 +125,7 @@ /obj/machinery/atmospherics/pipe/manifold/orange/hidden level = PIPE_HIDDEN_LEVEL - + /obj/machinery/atmospherics/pipe/manifold/purple pipe_color=rgb(128,0,182) color=rgb(128,0,182) diff --git a/code/modules/atmospherics/machinery/pipes/pipes.dm b/code/modules/atmospherics/machinery/pipes/pipes.dm index 49383a74cb..cc01e6c4bd 100644 --- a/code/modules/atmospherics/machinery/pipes/pipes.dm +++ b/code/modules/atmospherics/machinery/pipes/pipes.dm @@ -24,6 +24,14 @@ if(oldN) oldN.build_network() +/obj/machinery/atmospherics/pipe/destroy_network() + QDEL_NULL(parent) + +/obj/machinery/atmospherics/pipe/build_network() + if(QDELETED(parent)) + parent = new + parent.build_pipeline(src) + /obj/machinery/atmospherics/pipe/update_icon() //overridden by manifolds if(NODE1&&NODE2) icon_state = "intact[invisibility ? "-f" : "" ]" @@ -51,14 +59,13 @@ /obj/machinery/atmospherics/pipe/return_air() return parent.air -/obj/machinery/atmospherics/pipe/build_network() - if(!parent) - parent = new /datum/pipeline() - parent.build_pipeline(src) - /obj/machinery/atmospherics/pipe/attackby(obj/item/W, mob/user, params) if(istype(W, /obj/item/device/analyzer)) atmosanalyzer_scan(parent.air, user) + if(istype(W, /obj/item/pipe_meter)) + var/obj/item/pipe_meter/meter = W + user.dropItemToGround(meter) + meter.setAttachLayer(piping_layer) else return ..() @@ -81,9 +88,7 @@ qdel(meter) . = ..() - if(parent && !QDELETED(parent)) - qdel(parent) - parent = null + QDEL_NULL(parent) /obj/machinery/atmospherics/pipe/proc/update_node_icon() for(DEVICE_TYPE_LOOP) diff --git a/code/modules/atmospherics/machinery/pipes/simple.dm b/code/modules/atmospherics/machinery/pipes/simple.dm index 5ac9ac31e6..e8d82c611c 100644 --- a/code/modules/atmospherics/machinery/pipes/simple.dm +++ b/code/modules/atmospherics/machinery/pipes/simple.dm @@ -12,10 +12,12 @@ The regular pipe you see everywhere, including bent ones. dir = SOUTH initialize_directions = SOUTH|NORTH + pipe_flags = PIPING_CARDINAL_AUTONORMALIZE device_type = BINARY /obj/machinery/atmospherics/pipe/simple/SetInitDirections() + normalize_cardinal_directions() if(dir in GLOB.diagonals) initialize_directions = dir switch(dir) @@ -24,20 +26,6 @@ The regular pipe you see everywhere, including bent ones. if(EAST,WEST) initialize_directions = EAST|WEST -/obj/machinery/atmospherics/pipe/simple/atmosinit() - normalize_dir() - ..() - -/obj/machinery/atmospherics/pipe/simple/proc/normalize_dir() - if(dir==SOUTH) - setDir(NORTH) - else if(dir==WEST) - setDir(EAST) - -/obj/machinery/atmospherics/pipe/simple/update_icon() - normalize_dir() - ..() - //Colored pipes, use these for mapping /obj/machinery/atmospherics/pipe/simple/general diff --git a/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm b/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm index 96a5b8e489..cad1584991 100644 --- a/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm +++ b/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm @@ -45,11 +45,11 @@ /obj/machinery/portable_atmospherics/proc/connect(obj/machinery/atmospherics/components/unary/portables_connector/new_port) //Make sure not already connected to something else if(connected_port || !new_port || new_port.connected_device) - return 0 + return FALSE //Make sure are close enough for a valid connection if(new_port.loc != get_turf(src)) - return 0 + return TRUE //Perform the connection connected_port = new_port @@ -58,7 +58,9 @@ connected_port_parent.reconcile_air() anchored = TRUE //Prevent movement - return 1 + pixel_x = new_port.pixel_x + pixel_y = new_port.pixel_y + return TRUE /obj/machinery/portable_atmospherics/Move() . = ..() @@ -67,11 +69,11 @@ /obj/machinery/portable_atmospherics/proc/disconnect() if(!connected_port) - return 0 + return FALSE anchored = FALSE connected_port.connected_device = null connected_port = null - return 1 + return TRUE /obj/machinery/portable_atmospherics/portableConnectorReturnAir() return air_contents diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index cf0a786cae..6becdb3ddd 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -143,3 +143,5 @@ var/list/can_ride_typecache = list() var/list/mousemove_intercept_objects + + var/ventcrawl_layer = PIPING_LAYER_DEFAULT diff --git a/icons/obj/atmospherics/pipes/manifold.dmi b/icons/obj/atmospherics/pipes/manifold.dmi index 6fe285c74b..3e4d218ca6 100644 Binary files a/icons/obj/atmospherics/pipes/manifold.dmi and b/icons/obj/atmospherics/pipes/manifold.dmi differ diff --git a/icons/obj/atmospherics/pipes/pipe_item.dmi b/icons/obj/atmospherics/pipes/pipe_item.dmi index 7b9185aba0..d953fc4c89 100644 Binary files a/icons/obj/atmospherics/pipes/pipe_item.dmi and b/icons/obj/atmospherics/pipes/pipe_item.dmi differ diff --git a/tgstation.dme b/tgstation.dme index 913cd5d7a8..f024eb5f68 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -1188,6 +1188,7 @@ #include "code\modules\atmospherics\machinery\other\miner.dm" #include "code\modules\atmospherics\machinery\other\zvent.dm" #include "code\modules\atmospherics\machinery\pipes\bluespace_pipe.dm" +#include "code\modules\atmospherics\machinery\pipes\layermanifold.dm" #include "code\modules\atmospherics\machinery\pipes\manifold.dm" #include "code\modules\atmospherics\machinery\pipes\manifold4w.dm" #include "code\modules\atmospherics\machinery\pipes\pipes.dm"