diff --git a/code/__defines/refinery.dm b/code/__defines/refinery.dm index 221c6b44b7..587385ddff 100644 --- a/code/__defines/refinery.dm +++ b/code/__defines/refinery.dm @@ -15,6 +15,7 @@ #define REFINERY_TUTORIAL_NOOUTPUT (1 << 5) #define REFINERY_TUTORIAL_ALLIN (1 << 6) #define REFINERY_TUTORIAL_SINGLEOUTPUT (1 << 7) +#define REFINERY_TUTORIAL_SPLITTEROUTPUT (1 << 8) #define REAGENT_VAT_VOLUME 500 #define CARGOTANKER_VOLUME 3000 diff --git a/code/game/machinery/frame.dm b/code/game/machinery/frame.dm index 0fe59a73cd..30758cb1a9 100644 --- a/code/game/machinery/frame.dm +++ b/code/game/machinery/frame.dm @@ -247,6 +247,11 @@ GLOBAL_LIST(construction_frame_floor) icon_override = 'icons/obj/stock_parts_refinery.dmi' frame_class = FRAME_CLASS_MACHINE +/datum/frame/frame_types/industrial_reagent_splitter + name = "Industrial Chemical Splitter" + icon_override = 'icons/obj/stock_parts_refinery.dmi' + frame_class = FRAME_CLASS_MACHINE + /datum/frame/frame_types/industrial_reagent_waste_processor name = "Industrial Chemical Waste Processor" icon_override = 'icons/obj/stock_parts_refinery.dmi' diff --git a/code/game/objects/items/weapons/circuitboards/frame.dm b/code/game/objects/items/weapons/circuitboards/frame.dm index cf9672aa80..c6d60df6ca 100644 --- a/code/game/objects/items/weapons/circuitboards/frame.dm +++ b/code/game/objects/items/weapons/circuitboards/frame.dm @@ -352,6 +352,14 @@ board_type = new /datum/frame/frame_types/industrial_reagent_pipe req_components = list( /obj/item/stack/material/glass/reinforced = 1) +/obj/item/circuitboard/industrial_reagent_splitter + name = T_BOARD("industrial chemical splitter") + build_path = /obj/machinery/reagent_refinery/splitter + board_type = new /datum/frame/frame_types/industrial_reagent_splitter + req_components = list( + /obj/item/stack/material/glass/reinforced = 1, + /obj/item/stock_parts/motor = 1) + /obj/item/circuitboard/industrial_reagent_waste_processor name = T_BOARD("industrial chemical waste processor") build_path = /obj/machinery/reagent_refinery/waste_processor diff --git a/code/modules/refinery/core/industrial_reagent_filter.dm b/code/modules/refinery/core/industrial_reagent_filter.dm index 27b54e1826..17d5c0f977 100644 --- a/code/modules/refinery/core/industrial_reagent_filter.dm +++ b/code/modules/refinery/core/industrial_reagent_filter.dm @@ -114,7 +114,7 @@ update_icon() /obj/machinery/reagent_refinery/filter/handle_transfer(var/atom/origin_machine, var/datum/reagents/RT, var/source_forward_dir, var/transfer_rate, var/filter_id = "") - // pumps, furnaces and filters can only be FED in a straight line + // pumps, furnaces, splitters and filters can only be FED in a straight line if(source_forward_dir != dir) return 0 . = ..(origin_machine, RT, source_forward_dir, transfer_rate, filter_id) diff --git a/code/modules/refinery/core/industrial_reagent_furnace.dm b/code/modules/refinery/core/industrial_reagent_furnace.dm index 7b61adf1e9..3a1e910d13 100644 --- a/code/modules/refinery/core/industrial_reagent_furnace.dm +++ b/code/modules/refinery/core/industrial_reagent_furnace.dm @@ -193,7 +193,7 @@ update_icon() /obj/machinery/reagent_refinery/furnace/handle_transfer(var/atom/origin_machine, var/datum/reagents/RT, var/source_forward_dir, var/transfer_rate, var/filter_id = "") - // pumps, furnaces and filters can only be FED in a straight line + // pumps, furnaces, splitters and filters can only be FED in a straight line if(source_forward_dir != dir) return 0 . = ..(origin_machine, RT, source_forward_dir, transfer_rate, filter_id) diff --git a/code/modules/refinery/core/industrial_reagent_hub.dm b/code/modules/refinery/core/industrial_reagent_hub.dm index a7bfe3c1de..ec4bcd5b5d 100644 --- a/code/modules/refinery/core/industrial_reagent_hub.dm +++ b/code/modules/refinery/core/industrial_reagent_hub.dm @@ -41,7 +41,10 @@ var/obj/machinery/other = locate(/obj/machinery/reagent_refinery) in T var/intake = FALSE if(other && other.anchored)// Waste processors do not connect to anything as outgoing - if(!istype(other,/obj/machinery/reagent_refinery/waste_processor)) + if(istype(other,/obj/machinery/reagent_refinery/splitter)) + if(GLOB.reverse_dir[dir] in list(turn(other.dir,90),turn(other.dir,-90))) + intake = TRUE + else if(!istype(other,/obj/machinery/reagent_refinery/waste_processor)) // weird handling for side connections... Otherwise, anything pointing into use gets connected back! if(istype(other,/obj/machinery/reagent_refinery/filter)) var/obj/machinery/reagent_refinery/filter/filt = other diff --git a/code/modules/refinery/core/industrial_reagent_machines.dm b/code/modules/refinery/core/industrial_reagent_machines.dm index 0cecd74eef..ad67330982 100644 --- a/code/modules/refinery/core/industrial_reagent_machines.dm +++ b/code/modules/refinery/core/industrial_reagent_machines.dm @@ -99,7 +99,7 @@ return 0 if(active_power_usage > 0 && !can_use_power_oneoff(active_power_usage)) return 0 - if(!istype(target,/obj/machinery/reagent_refinery)) // cannot transfer into grinders anyway, so it's fine to do it this way. + if(!istype(target,/obj/machinery/reagent_refinery) || istype(target,/obj/machinery/reagent_refinery/grinder)) // Grinders don't allow input return 0 var/transfered = target.handle_transfer(src,RT,source_forward_dir, amount_per_transfer_from_this, filter_id) if(transfered > 0 && active_power_usage > 0) @@ -153,3 +153,40 @@ // No power needed if(flags & REFINERY_TUTORIAL_NOPOWER) examine_list += "Does not require power. " + +/// Checks neighbouring machines for if we should connect visually to them +/obj/machinery/reagent_refinery/proc/update_input_connection_overlays(overlay_state) + for(var/direction in GLOB.cardinal) + var/turf/T = get_step(get_turf(src),direction) + var/obj/machinery/reagent_refinery/other = locate() in T + if(!other?.anchored) + continue + + // Waste processors do not connect to anything as outgoing + if(istype(other,/obj/machinery/reagent_refinery/waste_processor)) + continue + + // Filter allows side connection + if(istype(other,/obj/machinery/reagent_refinery/filter)) + var/obj/machinery/reagent_refinery/filter/filt = other + var/check_dir = 0 + if(filt.get_filter_side() == 1) + check_dir = turn(filt.dir, 270) + else + check_dir = turn(filt.dir, 90) + if(check_dir == GLOB.reverse_dir[direction]) + var/image/intake = image(icon, icon_state = overlay_state, dir = direction) + add_overlay(intake) + continue + + // Splitter only allows side connections + if(istype(other,/obj/machinery/reagent_refinery/splitter)) + if(GLOB.reverse_dir[direction] in list(turn(other.dir,90),turn(other.dir,-90))) + var/image/intake = image(icon, icon_state = overlay_state, dir = direction) + add_overlay(intake) + continue + + // Standard connection + if(other.dir == GLOB.reverse_dir[direction] && (dir != direction || istype(src,/obj/machinery/reagent_refinery/waste_processor))) + var/image/intake = image(icon, icon_state = overlay_state, dir = direction) + add_overlay(intake) diff --git a/code/modules/refinery/core/industrial_reagent_mixer.dm b/code/modules/refinery/core/industrial_reagent_mixer.dm index 6de92a1822..de30d00667 100644 --- a/code/modules/refinery/core/industrial_reagent_mixer.dm +++ b/code/modules/refinery/core/industrial_reagent_mixer.dm @@ -72,28 +72,7 @@ if(!(stat & (NOPOWER|BROKEN))) var/image/dot = image(icon, icon_state = "mixer_dot_[ got_input ? "on" : "off" ]") add_overlay(dot) - for(var/direction in GLOB.cardinal) - var/turf/T = get_step(get_turf(src),direction) - var/obj/machinery/other = locate(/obj/machinery/reagent_refinery) in T - if(other && other.anchored) - // Waste processors do not connect to anything as outgoing - if(istype(other,/obj/machinery/reagent_refinery/waste_processor)) - continue - // weird handling for side connections... Otherwise, anything pointing into use gets connected back! - if(istype(other,/obj/machinery/reagent_refinery/filter)) - var/obj/machinery/reagent_refinery/filter/filt = other - var/check_dir = 0 - if(filt.get_filter_side() == 1) - check_dir = turn(filt.dir, 270) - else - check_dir = turn(filt.dir, 90) - if(check_dir == GLOB.reverse_dir[direction] && dir != direction) - var/image/intake = image(icon, icon_state = "mixer_intakes", dir = direction) - add_overlay(intake) - continue - if(other.dir == GLOB.reverse_dir[direction] && dir != direction) - var/image/intake = image(icon, icon_state = "mixer_intakes", dir = direction) - add_overlay(intake) + update_input_connection_overlays("mixer_intakes") // Get mixer overlay var/image/arm = image(icon, icon_state = "mixer_arm", dir = angle2dir(mixer_angle)) add_overlay(arm) diff --git a/code/modules/refinery/core/industrial_reagent_pipe.dm b/code/modules/refinery/core/industrial_reagent_pipe.dm index 87cca1027c..0d9ce57069 100644 --- a/code/modules/refinery/core/industrial_reagent_pipe.dm +++ b/code/modules/refinery/core/industrial_reagent_pipe.dm @@ -1,6 +1,6 @@ /obj/machinery/reagent_refinery/pipe name = "Industrial Chemical Pipe" - desc = "A large pipe made for transporting industrial chemicals. It has a low-power passive pump. The red marks show where the flow is coming from. Does not require power." + desc = "A large pipe made for transporting industrial chemicals." icon_state = "pipe" density = TRUE anchored = TRUE @@ -32,28 +32,7 @@ /obj/machinery/reagent_refinery/pipe/update_icon() cut_overlays() if(anchored) - for(var/direction in GLOB.cardinal) - var/turf/T = get_step(get_turf(src),direction) - var/obj/machinery/other = locate(/obj/machinery/reagent_refinery) in T - if(other && other.anchored) - // Waste processors do not connect to anything as outgoing - if(istype(other,/obj/machinery/reagent_refinery/waste_processor)) - continue - // weird handling for side connections... Otherwise, anything pointing into use gets connected back! - if(istype(other,/obj/machinery/reagent_refinery/filter)) - var/obj/machinery/reagent_refinery/filter/filt = other - var/check_dir = 0 - if(filt.get_filter_side() == 1) - check_dir = turn(filt.dir, 270) - else - check_dir = turn(filt.dir, 90) - if(check_dir == GLOB.reverse_dir[direction] && dir != direction) - var/image/intake = image(icon, icon_state = "pipe_intakes", dir = direction) - add_overlay(intake) - continue - if(other.dir == GLOB.reverse_dir[direction] && dir != direction) - var/image/intake = image(icon, icon_state = "pipe_intakes", dir = direction) - add_overlay(intake) + update_input_connection_overlays("pipe_intakes") /obj/machinery/reagent_refinery/pipe/handle_transfer(var/atom/origin_machine, var/datum/reagents/RT, var/source_forward_dir, var/transfer_rate, var/filter_id = "") // no back/forth, filters don't use just their forward, they send the side too! diff --git a/code/modules/refinery/core/industrial_reagent_pump.dm b/code/modules/refinery/core/industrial_reagent_pump.dm index 5c833b25a7..5c33f8543f 100644 --- a/code/modules/refinery/core/industrial_reagent_pump.dm +++ b/code/modules/refinery/core/industrial_reagent_pump.dm @@ -52,7 +52,7 @@ set_APTFT() /obj/machinery/reagent_refinery/pump/handle_transfer(var/atom/origin_machine, var/datum/reagents/RT, var/source_forward_dir, var/transfer_rate, var/filter_id = "") - // pumps, furnaces and filters can only be FED in a straight line + // pumps, furnaces, splitters and filters can only be FED in a straight line if(source_forward_dir != dir) return 0 . = ..(origin_machine, RT, source_forward_dir, transfer_rate, filter_id) diff --git a/code/modules/refinery/core/industrial_reagent_reactor.dm b/code/modules/refinery/core/industrial_reagent_reactor.dm index 72928a75c7..65a9fd047c 100644 --- a/code/modules/refinery/core/industrial_reagent_reactor.dm +++ b/code/modules/refinery/core/industrial_reagent_reactor.dm @@ -75,28 +75,7 @@ if(!(stat & (NOPOWER|BROKEN))) var/image/dot = image(icon, icon_state = "vat_dot_[ toggle_mode > REACTOR_MODE_INTAKE ? "on" : "off" ]") // Show refinery output mode add_overlay(dot) - for(var/direction in GLOB.cardinal) - var/turf/T = get_step(get_turf(src),direction) - var/obj/machinery/other = locate(/obj/machinery/reagent_refinery) in T - if(other && other.anchored) - // Waste processors do not connect to anything as outgoing - if(istype(other,/obj/machinery/reagent_refinery/waste_processor)) - continue - // weird handling for side connections... Otherwise, anything pointing into use gets connected back! - if(istype(other,/obj/machinery/reagent_refinery/filter)) - var/obj/machinery/reagent_refinery/filter/filt = other - var/check_dir = 0 - if(filt.get_filter_side() == 1) - check_dir = turn(filt.dir, 270) - else - check_dir = turn(filt.dir, 90) - if(check_dir == GLOB.reverse_dir[direction] && dir != direction) - var/image/intake = image(icon, icon_state = "reactor_intakes", dir = direction) - add_overlay(intake) - continue - if(other.dir == GLOB.reverse_dir[direction] && dir != direction) - var/image/intake = image(icon, icon_state = "reactor_intakes", dir = direction) - add_overlay(intake) + update_input_connection_overlays("reactor_intakes") /obj/machinery/reagent_refinery/reactor/handle_transfer(var/atom/origin_machine, var/datum/reagents/RT, var/source_forward_dir, var/transfer_rate, var/filter_id = "") // no back/forth, filters don't use just their forward, they send the side too! diff --git a/code/modules/refinery/core/industrial_reagent_splitter.dm b/code/modules/refinery/core/industrial_reagent_splitter.dm new file mode 100644 index 0000000000..b08b28b9f2 --- /dev/null +++ b/code/modules/refinery/core/industrial_reagent_splitter.dm @@ -0,0 +1,71 @@ +/obj/machinery/reagent_refinery/splitter + name = "Industrial Chemical Splitter" + desc = "A large machine made for transfering industrial chemicals to multiple machines equally." + icon_state = "splitter" + density = TRUE + anchored = TRUE + idle_power_usage = 0 + active_power_usage = 0 + circuit = /obj/item/circuitboard/industrial_reagent_splitter + default_max_vol = 60 // smoll + +/obj/machinery/reagent_refinery/splitter/Initialize(mapload) + . = ..() + default_apply_parts() + // Can't be set on these + src.verbs -= /obj/machinery/reagent_refinery/verb/set_APTFT + // Update neighbours and self for state + update_neighbours() + update_icon() + AddElement(/datum/element/climbable) + +/obj/machinery/reagent_refinery/splitter/process() + if(!anchored) + return + + if(stat & (BROKEN)) + return + + splitter_transfer() + +/obj/machinery/reagent_refinery/proc/splitter_transfer() + if(amount_per_transfer_from_this <= 0 || reagents.total_volume <= 0) + return 0 + + var/list/target_list = list() + var/list/dir_list = list() + var/list/possible_dirs = list(turn(dir, 90), turn(dir, -90)) + if(prob(50)) // So neither side has priority + possible_dirs = list(turn(dir, -90), turn(dir, 90)) + for(var/dir_check in possible_dirs) + var/obj/machinery/reagent_refinery/target = locate() in get_step(get_turf(src),dir_check) + if(!target) + continue + target_list += list(target) + dir_list += list(dir_check) + if(!target_list.len) + return 0 + + // Dynamically set by reagent amount, we always want half + amount_per_transfer_from_this = reagents.total_volume / target_list.len + if(amount_per_transfer_from_this < 0.5) + return 0 + + var/total_transfered = 0 + for(var/i = 1 to target_list.len) + var/scan_dir = dir_list[i] + var/scan_targ = target_list[i] + if(reagents.total_volume >= minimum_reagents_for_transfer(scan_targ)) + total_transfered += transfer_tank(reagents, scan_targ, scan_dir) + return total_transfered + +/obj/machinery/reagent_refinery/splitter/handle_transfer(var/atom/origin_machine, var/datum/reagents/RT, var/source_forward_dir, var/transfer_rate, var/filter_id = "") + // pumps, furnaces, splitters and filters can only be FED in a straight line + if(source_forward_dir != dir) + return 0 + . = ..(origin_machine, RT, source_forward_dir, transfer_rate, filter_id) + +/obj/machinery/reagent_refinery/splitter/examine(mob/user, infix, suffix) + . = ..() + . += "The meter shows [reagents.total_volume]u / [reagents.maximum_volume]u." + tutorial(REFINERY_TUTORIAL_SPLITTEROUTPUT|REFINERY_TUTORIAL_INPUT, .) diff --git a/code/modules/refinery/core/industrial_reagent_vat.dm b/code/modules/refinery/core/industrial_reagent_vat.dm index 41effa3c39..92b364c7af 100644 --- a/code/modules/refinery/core/industrial_reagent_vat.dm +++ b/code/modules/refinery/core/industrial_reagent_vat.dm @@ -54,28 +54,7 @@ if(!(stat & (NOPOWER|BROKEN))) var/image/dot = image(icon, icon_state = "vat_dot_[ amount_per_transfer_from_this > 0 ? "on" : "off" ]") add_overlay(dot) - for(var/direction in GLOB.cardinal) - var/turf/T = get_step(get_turf(src),direction) - var/obj/machinery/other = locate(/obj/machinery/reagent_refinery) in T - if(other && other.anchored) - // Waste processors do not connect to anything as outgoing - if(istype(other,/obj/machinery/reagent_refinery/waste_processor)) - continue - // weird handling for side connections... Otherwise, anything pointing into use gets connected back! - if(istype(other,/obj/machinery/reagent_refinery/filter)) - var/obj/machinery/reagent_refinery/filter/filt = other - var/check_dir = 0 - if(filt.get_filter_side() == 1) - check_dir = turn(filt.dir, 270) - else - check_dir = turn(filt.dir, 90) - if(check_dir == GLOB.reverse_dir[direction] && dir != direction) - var/image/intake = image(icon, icon_state = "vat_intakes", dir = direction) - add_overlay(intake) - continue - if(other.dir == GLOB.reverse_dir[direction] && dir != direction) - var/image/intake = image(icon, icon_state = "vat_intakes", dir = direction) - add_overlay(intake) + update_input_connection_overlays("vat_intakes") /obj/machinery/reagent_refinery/vat/examine(mob/user, infix, suffix) . = ..() diff --git a/code/modules/refinery/core/industrial_reagent_waste.dm b/code/modules/refinery/core/industrial_reagent_waste.dm index 3d3b66e0e5..042d9bf31a 100644 --- a/code/modules/refinery/core/industrial_reagent_waste.dm +++ b/code/modules/refinery/core/industrial_reagent_waste.dm @@ -36,28 +36,7 @@ /obj/machinery/reagent_refinery/waste_processor/update_icon() cut_overlays() if(anchored) - for(var/direction in GLOB.cardinal) - var/turf/T = get_step(get_turf(src),direction) - var/obj/machinery/other = locate(/obj/machinery/reagent_refinery) in T - if(other && other.anchored) - // Waste processors do not connect to anything as outgoing - if(istype(other,/obj/machinery/reagent_refinery/waste_processor)) - continue - // weird handling for side connections... Otherwise, anything pointing into use gets connected back! - if(istype(other,/obj/machinery/reagent_refinery/filter)) - var/obj/machinery/reagent_refinery/filter/filt = other - var/check_dir = 0 - if(filt.get_filter_side() == 1) - check_dir = turn(filt.dir, 270) - else - check_dir = turn(filt.dir, 90) - if(check_dir == GLOB.reverse_dir[direction]) - var/image/intake = image(icon, icon_state = "waste_intakes", dir = direction) - add_overlay(intake) - continue - if(other.dir == GLOB.reverse_dir[direction]) - var/image/intake = image(icon, icon_state = "waste_intakes", dir = direction) - add_overlay(intake) + update_input_connection_overlays("waste_intakes") /obj/machinery/reagent_refinery/waste_processor/examine(mob/user, infix, suffix) . = ..() diff --git a/code/modules/research/tg/designs/boards/refinery.dm b/code/modules/research/tg/designs/boards/refinery.dm index 2d83a258e3..5f1c11a31b 100644 --- a/code/modules/research/tg/designs/boards/refinery.dm +++ b/code/modules/research/tg/designs/boards/refinery.dm @@ -98,6 +98,16 @@ ) departmental_flags = DEPARTMENT_BITFLAG_ENGINEERING | DEPARTMENT_BITFLAG_SCIENCE +/datum/design_techweb/board/industrial_reagent_splitter + name = "Industrial Reagent Splitter" + id = "industrial_reagent_splitter" + // req_tech = list(TECH_DATA = 1) + build_path = /obj/item/circuitboard/industrial_reagent_splitter + category = list( + RND_CATEGORY_MACHINE + RND_SUBCATEGORY_MACHINE_ENGINEERING + ) + departmental_flags = DEPARTMENT_BITFLAG_ENGINEERING | DEPARTMENT_BITFLAG_SCIENCE + /datum/design_techweb/board/pump_relay name = "Pump Relay" id = "pump_relay" diff --git a/code/modules/research/tg/techwebs/nodes/engi_nodes.dm b/code/modules/research/tg/techwebs/nodes/engi_nodes.dm index 001dc4b423..41ef001392 100644 --- a/code/modules/research/tg/techwebs/nodes/engi_nodes.dm +++ b/code/modules/research/tg/techwebs/nodes/engi_nodes.dm @@ -340,6 +340,7 @@ "industrial_reagent_reactor", "industrial_reagent_vat", "industrial_reagent_mixer", + "industrial_reagent_splitter", "industrial_reagent_waste_processor", "pump_relay", "fluid_pump" diff --git a/icons/obj/machines/refinery_machines.dmi b/icons/obj/machines/refinery_machines.dmi index 259e412ac4..3da5c71f98 100644 Binary files a/icons/obj/machines/refinery_machines.dmi and b/icons/obj/machines/refinery_machines.dmi differ diff --git a/icons/obj/stock_parts_refinery.dmi b/icons/obj/stock_parts_refinery.dmi index 75ed01f2ad..ff8359b1f2 100644 Binary files a/icons/obj/stock_parts_refinery.dmi and b/icons/obj/stock_parts_refinery.dmi differ diff --git a/vorestation.dme b/vorestation.dme index e563f748de..6954af287f 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -4507,6 +4507,7 @@ #include "code\modules\refinery\core\industrial_reagent_pipe.dm" #include "code\modules\refinery\core\industrial_reagent_pump.dm" #include "code\modules\refinery\core\industrial_reagent_reactor.dm" +#include "code\modules\refinery\core\industrial_reagent_splitter.dm" #include "code\modules\refinery\core\industrial_reagent_vat.dm" #include "code\modules\refinery\core\industrial_reagent_waste.dm" #include "code\modules\refinery\equipment\chemcontainer.dm"