Skip to content

Commit

Permalink
[MIRROR] Fixes high power consumption for lathes (#884)
Browse files Browse the repository at this point in the history
* Fixes high power consumption for lathes

* Fix Conflict

---------

Co-authored-by: SyncIt21 <[email protected]>
Co-authored-by: SomeRandomOwl <[email protected]>
  • Loading branch information
3 people authored and FFMirrorBot committed Feb 10, 2024
1 parent 9950695 commit 49c23f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 3 additions & 2 deletions code/game/machinery/autolathe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@

flick("autolathe_[item_inserted.has_material_type(/datum/material/glass) ? "r" : "o"]", src)

directly_use_power(round((amount_inserted / SHEET_MATERIAL_AMOUNT) * active_power_usage * 0.0025))
//we use initial(active_power_usage) because higher tier parts will have higher active usage but we have no benifit from it
directly_use_power(ROUND_UP((amount_inserted / (MAX_STACK_SIZE * SHEET_MATERIAL_AMOUNT)) * 0.01 * initial(active_power_usage)))

/obj/machinery/autolathe/ui_interact(mob/user, datum/tgui/ui)
if(!is_operational)
Expand Down Expand Up @@ -273,7 +274,7 @@
var/charge_per_item = 0
for(var/material in design.materials)
charge_per_item += design.materials[material]
charge_per_item = min(active_power_usage, round(charge_per_item * material_cost_coefficient))
charge_per_item = ROUND_UP((charge_per_item / (MAX_STACK_SIZE * SHEET_MATERIAL_AMOUNT)) * material_cost_coefficient * 0.05 * active_power_usage)
var/build_time_per_item = (design.construction_time * design.lathe_time_factor) ** 0.8

//do the printing sequentially
Expand Down
13 changes: 10 additions & 3 deletions code/modules/research/machinery/_production.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
. = ..()

cached_designs = list()

materials = AddComponent(
/datum/component/remote_materials, \
mapload, \
Expand Down Expand Up @@ -65,7 +66,6 @@
stripe.color = stripe_color
. += stripe


/obj/machinery/rnd/production/examine(mob/user)
. = ..()
if(!in_range(user, src) && !isobserver(user))
Expand Down Expand Up @@ -144,7 +144,8 @@
/obj/machinery/rnd/proc/process_item(obj/item/item_inserted, list/mats_consumed, amount_inserted)
PRIVATE_PROC(TRUE)

if(directly_use_power(round((amount_inserted / SHEET_MATERIAL_AMOUNT) * active_power_usage * 0.00025)))
//we use initial(active_power_usage) because higher tier parts will have higher active usage but we have no benifit from it
if(directly_use_power(ROUND_UP((amount_inserted / (MAX_STACK_SIZE * SHEET_MATERIAL_AMOUNT)) * 0.01 * initial(active_power_usage))))
var/mat_name = "iron"

var/highest_mat = 0
Expand Down Expand Up @@ -206,6 +207,7 @@
*/
/obj/machinery/rnd/production/proc/build_efficiency(path)
PROTECTED_PROC(TRUE) // NOVA EDIT CHANGE - ORIGINAL: PRIVATE_PROC(TRUE)
SHOULD_BE_PURE(TRUE)

if(ispath(path, /obj/item/stack/sheet) || ispath(path, /obj/item/stack/ore/bluespace_crystal))
return 1
Expand Down Expand Up @@ -285,6 +287,11 @@
if(isnull(amount))
return

//we use initial(active_power_usage) because higher tier parts will have higher active usage but we have no benifit from it
if(!directly_use_power(ROUND_UP((amount / MAX_STACK_SIZE) * 0.01 * initial(active_power_usage))))
say("No power to dispense sheets")
return

materials.eject_sheets(material, amount)
return TRUE

Expand Down Expand Up @@ -330,7 +337,7 @@
var/charge_per_item = 0
for(var/material in design.materials)
charge_per_item += design.materials[material]
charge_per_item = min(active_power_usage, round(charge_per_item * coefficient))
charge_per_item = ROUND_UP((charge_per_item / (MAX_STACK_SIZE * SHEET_MATERIAL_AMOUNT)) * coefficient * 0.05 * active_power_usage)
var/build_time_per_item = (design.construction_time * design.lathe_time_factor) ** 0.8

//start production
Expand Down

0 comments on commit 49c23f9

Please sign in to comment.