Integrated the component printer into the integrated circuit UI. You can now link integrated circuits to component printers (#62287)

Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com>
This commit is contained in:
Watermelon914
2021-10-28 11:42:57 -07:00
committed by GitHub
co-authored by Watermelon914
parent bfe0fcc601
commit 44a2af780d
86 changed files with 571 additions and 34 deletions
@@ -14,11 +14,24 @@
/// The techweb the printer will get researched designs from
var/datum/techweb/techweb
/// The current unlocked circuit component designs. Used by integrated circuits to print off circuit components remotely.
var/list/current_unlocked_designs = list()
/obj/machinery/component_printer/Initialize(mapload)
. = ..()
techweb = SSresearch.science_tech
for (var/researched_design_id in techweb.researched_designs)
var/datum/design/design = SSresearch.techweb_design_by_id(researched_design_id)
if (!(design.build_type & COMPONENT_PRINTER) || !ispath(design.build_path, /obj/item/circuit_component))
continue
current_unlocked_designs[design.build_path] = design.id
RegisterSignal(techweb, COMSIG_TECHWEB_ADD_DESIGN, .proc/on_research)
RegisterSignal(techweb, COMSIG_TECHWEB_REMOVE_DESIGN, .proc/on_removed)
materials = AddComponent( \
/datum/component/remote_materials, \
"component_printer", \
@@ -26,6 +39,19 @@
mat_container_flags = BREAKDOWN_FLAGS_LATHE, \
)
/obj/machinery/component_printer/proc/on_research(datum/source, datum/design/added_design, custom)
SIGNAL_HANDLER
if (!(added_design.build_type & COMPONENT_PRINTER) || !ispath(added_design.build_path, /obj/item/circuit_component))
return
current_unlocked_designs[added_design.build_path] = added_design.id
/obj/machinery/component_printer/proc/on_removed(datum/source, datum/design/added_design, custom)
SIGNAL_HANDLER
if (!(added_design.build_type & COMPONENT_PRINTER) || !ispath(added_design.build_path, /obj/item/circuit_component))
return
current_unlocked_designs -= added_design.build_path
/obj/machinery/component_printer/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
@@ -37,6 +63,23 @@
get_asset_datum(/datum/asset/spritesheet/sheetmaterials)
)
/obj/machinery/component_printer/proc/print_component(typepath)
var/design_id = current_unlocked_designs[typepath]
var/datum/design/design = SSresearch.techweb_design_by_id(design_id)
if (!(design.build_type & COMPONENT_PRINTER))
return
if (materials.on_hold())
return
if (!materials.mat_container?.has_materials(design.materials))
return
materials.mat_container.use_materials(design.materials)
materials.silo_log(src, "printed", -1, design.name, design.materials)
return new design.build_path(drop_location())
/obj/machinery/component_printer/ui_act(action, list/params)
. = ..()
if (.)
@@ -105,6 +148,14 @@
return data
/obj/machinery/component_printer/attackby(obj/item/weapon, mob/living/user, params)
if(istype(weapon, /obj/item/integrated_circuit) && !user.combat_mode)
var/obj/item/integrated_circuit/circuit = weapon
circuit.linked_component_printer = WEAKREF(src)
balloon_alert(user, "successfully linked to the integrated circuit")
return
return ..()
/obj/machinery/component_printer/crowbar_act(mob/living/user, obj/item/tool)
if(..())
return TRUE