mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-21 20:20:33 +01:00
[MIRROR] ModuleDuplicator & ComponentPrinter now benefit from upgraded parts [MDB IGNORE] (#18105)
* ModuleDuplicator & ComponentPrinter now benefit from upgraded parts (#71183) **About the pull request** Module Duplicator & Component Printer now provide more local storage and cheaper production costs when upgraded with better matter bins & manipulators respectively. Previously this wasn't the case **Why its good for the game** Better parts mean lower costs and more storage. Thats always a good thing **Change Log** 🆑 add: Module Duplicator & Component Printer now get extra storage & reduced costs from more efficient parts /🆑 Co-authored-by: Time-Green <timkoster1@ hotmail.com> * ModuleDuplicator & ComponentPrinter now benefit from upgraded parts Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: Time-Green <timkoster1@ hotmail.com>
This commit is contained in:
co-authored by
Time-Green
SyncIt21
parent
81f51b9b79
commit
bbeeebe83d
@@ -74,6 +74,28 @@
|
||||
get_asset_datum(/datum/asset/spritesheet/sheetmaterials)
|
||||
)
|
||||
|
||||
/obj/machinery/component_printer/proc/calculate_efficiency()
|
||||
var/rating = 0
|
||||
|
||||
for(var/obj/item/stock_parts/manipulator/manipulator in component_parts)
|
||||
///we do -1 because normal manipulators rating of 1 gives us 1-1=0 i.e no decrement in cost
|
||||
rating += manipulator.rating-1
|
||||
|
||||
///linear interpolation between full cost i.e 1 & 1/8th the cost i.e 0.125
|
||||
///we do it in 6 steps because maximum rating of 2 manipulators is 8 but -1 gives us 6
|
||||
var/coff = 1.0+((0.125-1.0)*(rating/6))
|
||||
|
||||
///copied from production.dm calculate_efficiency() proc
|
||||
if(materials)
|
||||
var/total_storage = 0
|
||||
|
||||
for(var/obj/item/stock_parts/matter_bin/bin in component_parts)
|
||||
total_storage += bin.rating * 75000
|
||||
|
||||
materials.set_local_size(total_storage)
|
||||
|
||||
return coff
|
||||
|
||||
/obj/machinery/component_printer/proc/print_component(typepath)
|
||||
var/design_id = current_unlocked_designs[typepath]
|
||||
|
||||
@@ -84,10 +106,11 @@
|
||||
if (materials.on_hold())
|
||||
return
|
||||
|
||||
if (!materials.mat_container?.has_materials(design.materials))
|
||||
var/efficiency_coeff = calculate_efficiency()
|
||||
if (!materials.mat_container?.has_materials(design.materials, efficiency_coeff))
|
||||
return
|
||||
|
||||
materials.mat_container.use_materials(design.materials)
|
||||
materials.mat_container.use_materials(design.materials, efficiency_coeff)
|
||||
materials.silo_log(src, "printed", -1, design.name, design.materials)
|
||||
return new design.build_path(drop_location())
|
||||
|
||||
@@ -110,12 +133,14 @@
|
||||
say("Mineral access is on hold, please contact the quartermaster.")
|
||||
return TRUE
|
||||
|
||||
if (!materials.mat_container?.has_materials(design.materials))
|
||||
var/efficiency_coeff = calculate_efficiency()
|
||||
|
||||
if (!materials.mat_container?.has_materials(design.materials, efficiency_coeff))
|
||||
say("Not enough materials.")
|
||||
return TRUE
|
||||
|
||||
balloon_alert_to_viewers("printed [design.name]")
|
||||
materials.mat_container?.use_materials(design.materials)
|
||||
materials.mat_container?.use_materials(design.materials, efficiency_coeff)
|
||||
materials.silo_log(src, "printed", -1, design.name, design.materials)
|
||||
var/atom/printed_design = new design.build_path(drop_location())
|
||||
printed_design.pixel_x = printed_design.base_pixel_x + rand(-5, 5)
|
||||
@@ -143,6 +168,7 @@
|
||||
|
||||
var/datum/asset/spritesheet/research_designs/spritesheet = get_asset_datum(/datum/asset/spritesheet/research_designs)
|
||||
var/size32x32 = "[spritesheet.name]32x32"
|
||||
var/efficiency_coeff = calculate_efficiency()
|
||||
|
||||
// for (var/datum/design/component/component_design_type as anything in subtypesof(/datum/design/component))
|
||||
for (var/researched_design_id in techweb.researched_designs)
|
||||
@@ -155,7 +181,7 @@
|
||||
designs[researched_design_id] = list(
|
||||
"name" = design.name,
|
||||
"desc" = design.desc,
|
||||
"cost" = get_material_cost_data(design.materials),
|
||||
"cost" = get_material_cost_data(design.materials, efficiency_coeff),
|
||||
"id" = researched_design_id,
|
||||
"categories" = design.category,
|
||||
"icon" = "[icon_size == size32x32 ? "" : "[icon_size] "][design.id]",
|
||||
@@ -184,11 +210,11 @@
|
||||
return TRUE
|
||||
return default_deconstruction_screwdriver(user, "fab-o", "fab-idle", tool)
|
||||
|
||||
/obj/machinery/component_printer/proc/get_material_cost_data(list/materials)
|
||||
/obj/machinery/component_printer/proc/get_material_cost_data(list/materials, efficiency_coeff)
|
||||
var/list/data = list()
|
||||
|
||||
for (var/datum/material/material_type as anything in materials)
|
||||
data[initial(material_type.name)] = materials[material_type]
|
||||
data[initial(material_type.name)] = materials[material_type] * efficiency_coeff
|
||||
|
||||
return data
|
||||
|
||||
@@ -319,6 +345,28 @@
|
||||
get_asset_datum(/datum/asset/spritesheet/research_designs)
|
||||
)
|
||||
|
||||
/obj/machinery/module_duplicator/proc/calculate_efficiency()
|
||||
///copied from production.dm calculate_efficiency() proc
|
||||
if(materials)
|
||||
var/total_storage = 0
|
||||
|
||||
for(var/obj/item/stock_parts/matter_bin/bin in component_parts)
|
||||
total_storage += bin.rating * 75000
|
||||
|
||||
materials.set_local_size(total_storage)
|
||||
|
||||
var/rating = 0
|
||||
|
||||
for(var/obj/item/stock_parts/manipulator/manipulator in component_parts)
|
||||
///we do -1 because normal manipulators rating of 1 gives us 1-1=0 i.e no decrement in cost
|
||||
rating += manipulator.rating-1
|
||||
|
||||
///linear interpolation between full cost i.e 1 & 1/8th the cost i.e 0.125
|
||||
///we do it in 6 steps because maximum rating of 2 manipulators is 8 but -1 gives us 6
|
||||
var/coff=1.0+((0.125-1.0)*(rating/6))
|
||||
|
||||
return coff
|
||||
|
||||
/obj/machinery/module_duplicator/ui_act(action, list/params)
|
||||
. = ..()
|
||||
if (.)
|
||||
@@ -337,12 +385,14 @@
|
||||
say("Mineral access is on hold, please contact the quartermaster.")
|
||||
return TRUE
|
||||
|
||||
if (!materials.mat_container?.has_materials(design["materials"]))
|
||||
var/efficiency_coeff = calculate_efficiency()
|
||||
|
||||
if (!materials.mat_container?.has_materials(design["materials"], efficiency_coeff))
|
||||
say("Not enough materials.")
|
||||
return TRUE
|
||||
|
||||
balloon_alert_to_viewers("printed [design["name"]]")
|
||||
materials.mat_container?.use_materials(design["materials"])
|
||||
materials.mat_container?.use_materials(design["materials"], efficiency_coeff)
|
||||
materials.silo_log(src, "printed", -1, design["name"], design["materials"])
|
||||
print_module(design)
|
||||
if ("remove_mat")
|
||||
@@ -445,11 +495,13 @@
|
||||
|
||||
var/index = 1
|
||||
|
||||
var/efficiency_coeff = calculate_efficiency()
|
||||
|
||||
for (var/list/design as anything in scanned_designs)
|
||||
designs["[index]"] = list(
|
||||
"name" = design["name"],
|
||||
"desc" = design["desc"],
|
||||
"cost" = get_material_cost_data(design["materials"]),
|
||||
"cost" = get_material_cost_data(design["materials"], efficiency_coeff),
|
||||
"id" = "[index]",
|
||||
"icon" = "integrated_circuit",
|
||||
"categories" = list("/Saved Circuits"),
|
||||
@@ -470,11 +522,11 @@
|
||||
return TRUE
|
||||
return default_deconstruction_screwdriver(user, "module-fab-o", "module-fab-idle", tool)
|
||||
|
||||
/obj/machinery/module_duplicator/proc/get_material_cost_data(list/materials)
|
||||
/obj/machinery/module_duplicator/proc/get_material_cost_data(list/materials, efficiency_coeff)
|
||||
var/list/data = list()
|
||||
|
||||
for (var/datum/material/material_type as anything in materials)
|
||||
data[initial(material_type.name)] = materials[material_type]
|
||||
data[initial(material_type.name)] = materials[material_type] * efficiency_coeff
|
||||
|
||||
return data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user