mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 05:30:05 +01:00
[MIRROR] Made integrated circuits duplicatable through the module printer [MDB IGNORE] (#9198)
* Made integrated circuits duplicatable (#62302) Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com> * Made integrated circuits duplicatable through the module printer Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com>
This commit is contained in:
co-authored by
Watermelon914
Watermelon914
parent
b6dcc86786
commit
6cdf152a84
@@ -285,10 +285,13 @@
|
||||
|
||||
/// Called when this component is about to be added to an integrated_circuit.
|
||||
/obj/item/circuit_component/proc/add_to(obj/item/integrated_circuit/added_to)
|
||||
if(circuit_flags & CIRCUIT_FLAG_ADMIN)
|
||||
ADD_TRAIT(added_to, TRAIT_CIRCUIT_UNDUPABLE, src)
|
||||
return TRUE
|
||||
|
||||
/// Called when this component is removed from an integrated_circuit.
|
||||
/obj/item/circuit_component/proc/removed_from(obj/item/integrated_circuit/removed_from)
|
||||
REMOVE_TRAIT(removed_from, TRAIT_CIRCUIT_UNDUPABLE, src)
|
||||
return
|
||||
|
||||
/**
|
||||
|
||||
@@ -343,46 +343,66 @@
|
||||
addtimer(CALLBACK(src, .proc/finish_module_print, design), 1.6 SECONDS)
|
||||
|
||||
/obj/machinery/module_duplicator/proc/finish_module_print(list/design)
|
||||
var/obj/item/circuit_component/module/module = new(drop_location())
|
||||
module.load_data_from_list(design["dupe_data"])
|
||||
module.pixel_x = module.base_pixel_x + rand(-5, 5)
|
||||
module.pixel_y = module.base_pixel_y + rand(-5, 5)
|
||||
var/atom/movable/created_atom
|
||||
if(design["integrated_circuit"])
|
||||
var/obj/item/integrated_circuit/circuit = new(drop_location())
|
||||
var/list/errors = list()
|
||||
circuit.load_circuit_data(design["dupe_data"], errors)
|
||||
if(length(errors))
|
||||
stack_trace("Error loading user saved circuit [errors.Join(", ")].")
|
||||
created_atom = circuit
|
||||
else
|
||||
var/obj/item/circuit_component/module/module = new(drop_location())
|
||||
module.load_data_from_list(design["dupe_data"])
|
||||
created_atom = module
|
||||
created_atom.pixel_x = created_atom.base_pixel_x + rand(-5, 5)
|
||||
created_atom.pixel_y = created_atom.base_pixel_y + rand(-5, 5)
|
||||
|
||||
/obj/machinery/module_duplicator/attackby(obj/item/weapon, mob/user, params)
|
||||
if(!istype(weapon, /obj/item/circuit_component/module))
|
||||
var/list/data = list()
|
||||
|
||||
if(istype(weapon, /obj/item/circuit_component/module))
|
||||
var/obj/item/circuit_component/module/module = weapon
|
||||
if(HAS_TRAIT(module, TRAIT_CIRCUIT_UNDUPABLE))
|
||||
balloon_alert(user, "integrated circuit cannot be saved!")
|
||||
return ..()
|
||||
|
||||
data["dupe_data"] = list()
|
||||
module.save_data_to_list(data["dupe_data"])
|
||||
|
||||
data["name"] = module.display_name
|
||||
data["desc"] = "A module that has been loaded in by [user]."
|
||||
data["materials"] = list(GET_MATERIAL_REF(/datum/material/glass) = module.circuit_size * cost_per_component)
|
||||
else if(istype(weapon, /obj/item/integrated_circuit))
|
||||
var/obj/item/integrated_circuit/integrated_circuit = weapon
|
||||
if(HAS_TRAIT(integrated_circuit, TRAIT_CIRCUIT_UNDUPABLE))
|
||||
balloon_alert(user, "integrated circuit cannot be saved!")
|
||||
return ..()
|
||||
data["dupe_data"] = integrated_circuit.convert_to_json()
|
||||
|
||||
data["name"] = integrated_circuit.display_name
|
||||
data["desc"] = "An integrated circuit that has been loaded in by [user]."
|
||||
|
||||
var/datum/design/integrated_circuit/circuit_design = SSresearch.techweb_design_by_id("integrated_circuit")
|
||||
var/materials = list(GET_MATERIAL_REF(/datum/material/glass) = integrated_circuit.current_size * cost_per_component)
|
||||
for(var/material_type in circuit_design.materials)
|
||||
materials[material_type] += circuit_design.materials[material_type]
|
||||
|
||||
data["materials"] = materials
|
||||
data["integrated_circuit"] = TRUE
|
||||
|
||||
if(!length(data))
|
||||
return ..()
|
||||
|
||||
var/obj/item/circuit_component/module/module = weapon
|
||||
if(module.circuit_flags & CIRCUIT_FLAG_UNDUPEABLE)
|
||||
balloon_alert(user, "module cannot be saved!")
|
||||
return ..()
|
||||
|
||||
if(module.display_name == initial(module.display_name))
|
||||
balloon_alert(user, "module needs a name!")
|
||||
if(!data["name"])
|
||||
balloon_alert(user, "it needs a name!")
|
||||
return ..()
|
||||
|
||||
for(var/list/component_data as anything in scanned_designs)
|
||||
if(component_data["name"] == module.display_name)
|
||||
balloon_alert(user, "module name already exists!")
|
||||
if(component_data["name"] == data["name"])
|
||||
balloon_alert(user, "name already exists!")
|
||||
return ..()
|
||||
|
||||
var/total_cost = 0
|
||||
for(var/obj/item/circuit_component/component as anything in module.internal_circuit.attached_components)
|
||||
if(component.circuit_flags & CIRCUIT_FLAG_UNDUPEABLE)
|
||||
balloon_alert(user, "module contains prohibited components!")
|
||||
return ..()
|
||||
|
||||
total_cost += cost_per_component
|
||||
|
||||
var/list/data = list()
|
||||
|
||||
data["dupe_data"] = list()
|
||||
module.save_data_to_list(data["dupe_data"])
|
||||
|
||||
data["name"] = module.display_name
|
||||
data["desc"] = "A module that has been loaded in by [user]."
|
||||
data["materials"] = list(/datum/material/glass = total_cost)
|
||||
|
||||
flick("module-fab-scan", src)
|
||||
addtimer(CALLBACK(src, .proc/finish_module_scan, user, data), 1.4 SECONDS)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user