From aa4f9a13db6ba135d3f176379bdcaf4d365de044 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 10 Nov 2021 19:56:39 +0000 Subject: [PATCH] [MIRROR] Reagents scanner circuit component [MDB IGNORE] (#9377) * Reagents scanner circuit component (#62704) It allows people to make circuits objects that interface with reagents. * Reagents scanner circuit component Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> --- .../research/designs/wiremod_designs.dm | 5 +++ code/modules/research/techweb/all_nodes.dm | 1 + .../wiremod/components/atom/reagentscanner.dm | 37 +++++++++++++++++++ tgstation.dme | 1 + 4 files changed, 44 insertions(+) create mode 100644 code/modules/wiremod/components/atom/reagentscanner.dm diff --git a/code/modules/research/designs/wiremod_designs.dm b/code/modules/research/designs/wiremod_designs.dm index aa141f03249..6a5eadfdc01 100644 --- a/code/modules/research/designs/wiremod_designs.dm +++ b/code/modules/research/designs/wiremod_designs.dm @@ -183,6 +183,11 @@ id = "comp_direction" build_path = /obj/item/circuit_component/direction +/datum/design/component/reagentscanner + name = "Reagents Scanner" + id = "comp_reagents" + build_path = /obj/item/circuit_component/reagentscanner + /datum/design/component/health name = "Health Component" id = "comp_health" diff --git a/code/modules/research/techweb/all_nodes.dm b/code/modules/research/techweb/all_nodes.dm index 4f9b2047215..1a061e4a7ce 100644 --- a/code/modules/research/techweb/all_nodes.dm +++ b/code/modules/research/techweb/all_nodes.dm @@ -248,6 +248,7 @@ "comp_printer", "comp_radio", "comp_random", + "comp_reagents", "comp_router", "comp_select_query", "comp_self", diff --git a/code/modules/wiremod/components/atom/reagentscanner.dm b/code/modules/wiremod/components/atom/reagentscanner.dm new file mode 100644 index 00000000000..4c79cd4eafc --- /dev/null +++ b/code/modules/wiremod/components/atom/reagentscanner.dm @@ -0,0 +1,37 @@ +/** + * # Reagents Scanner + * + * Returns the reagentss of an atom + */ +/obj/item/circuit_component/reagentscanner + display_name = "Reagents Scanner" + desc = "Outputs the reagents found inside the inputted entity." + category = "Entity" + + circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL + + // The entity to scan + var/datum/port/input/input_port + /// The result from the output + var/datum/port/output/result + + var/max_range = 5 + +/obj/item/circuit_component/reagentscanner/get_ui_notices() + . = ..() + . += create_ui_notice("Maximum Range: [max_range] tiles", "orange", "info") + +/obj/item/circuit_component/reagentscanner/populate_ports() + input_port = add_input_port("Entity", PORT_TYPE_ATOM) + result = add_output_port("Reagents", PORT_TYPE_ASSOC_LIST(PORT_TYPE_STRING, PORT_TYPE_NUMBER)) + +/obj/item/circuit_component/reagentscanner/input_received(datum/port/input/port) + var/atom/entity = input_port.value + var/turf/location = get_location() + if(!istype(entity) || !IN_GIVEN_RANGE(location, entity, max_range)) + result.set_output(null) + return + var/list/output_list = list() + for(var/datum/reagent/reagent as anything in entity.reagents?.reagent_list) + output_list[reagent.name] += reagent.volume + result.set_output(output_list) diff --git a/tgstation.dme b/tgstation.dme index 1cf03cdd2dd..71a9b9db669 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -3947,6 +3947,7 @@ #include "code\modules\wiremod\components\atom\hear.dm" #include "code\modules\wiremod\components\atom\matscanner.dm" #include "code\modules\wiremod\components\atom\pinpointer.dm" +#include "code\modules\wiremod\components\atom\reagentscanner.dm" #include "code\modules\wiremod\components\atom\self.dm" #include "code\modules\wiremod\components\atom\species.dm" #include "code\modules\wiremod\components\bci\hud\bar_overlay.dm"