mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-29 11:32:13 +00:00
[MIRROR] Chemical Refinery Splitter Machine (#12048)
Co-authored-by: Will <7099514+Willburd@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
dfee7007cc
commit
a7bac7c918
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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!
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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!
|
||||
|
||||
71
code/modules/refinery/core/industrial_reagent_splitter.dm
Normal file
71
code/modules/refinery/core/industrial_reagent_splitter.dm
Normal file
@@ -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, .)
|
||||
@@ -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)
|
||||
. = ..()
|
||||
|
||||
@@ -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)
|
||||
. = ..()
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -340,6 +340,7 @@
|
||||
"industrial_reagent_reactor",
|
||||
"industrial_reagent_vat",
|
||||
"industrial_reagent_mixer",
|
||||
"industrial_reagent_splitter",
|
||||
"industrial_reagent_waste_processor",
|
||||
"pump_relay",
|
||||
"fluid_pump"
|
||||
|
||||
Reference in New Issue
Block a user