diff --git a/modular_nova/modules/colony_fabricator/code/appliances/wall_cell_charger.dm b/modular_nova/modules/colony_fabricator/code/appliances/wall_cell_charger.dm index 97e341809ac..4dc8057bfa9 100644 --- a/modular_nova/modules/colony_fabricator/code/appliances/wall_cell_charger.dm +++ b/modular_nova/modules/colony_fabricator/code/appliances/wall_cell_charger.dm @@ -7,7 +7,7 @@ circuit = null obj_flags = CAN_BE_HIT | NO_DECONSTRUCTION max_batteries = 3 - charge_rate = 750 + charge_rate = 750 KILO WATTS /// The item we turn into when repacked var/repacked_type = /obj/item/wallframe/cell_charger_multi @@ -33,7 +33,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/cell_charger_multi/wall_mounted, 29) /obj/machinery/cell_charger_multi/wall_mounted/RefreshParts() . = ..() - charge_rate = 750 // Nuh uh! + charge_rate = 750 KILO WATTS // Nuh uh! // Item for creating the arc furnace or carrying it around diff --git a/modular_nova/modules/multicellcharger/code/multi_cell_charger.dm b/modular_nova/modules/multicellcharger/code/multi_cell_charger.dm index 7f19ddf16be..1eaf0ba22e1 100644 --- a/modular_nova/modules/multicellcharger/code/multi_cell_charger.dm +++ b/modular_nova/modules/multicellcharger/code/multi_cell_charger.dm @@ -10,11 +10,12 @@ power_channel = AREA_USAGE_EQUIP circuit = /obj/item/circuitboard/machine/cell_charger_multi pass_flags = PASSTABLE - var/list/charging_batteries = list() //The list of batteries we are gonna charge! + /// The list of batteries we are gonna charge! + var/list/charging_batteries = list() + /// Number of concurrent batteries that can be charged var/max_batteries = 4 - var/charge_rate = 250 - var/charge_rate_base = 250 // Amount of charge we gain from a level one capacitor - var/charge_rate_max = 4000 // The highest we allow the charge rate to go + /// The base charge rate when spawned + var/charge_rate = 250 KILO WATTS /obj/machinery/cell_charger_multi/update_overlays() . = ..() @@ -49,7 +50,7 @@ for(var/obj/item/stock_parts/cell/charging in charging_batteries) . += "There's [charging] cell in the charger, current charge: [round(charging.percent(), 1)]%." if(in_range(user, src) || isobserver(user)) - . += span_notice("The status display reads: Charging power: [charge_rate]W.") + . += span_notice("The status display reads: Charging power: [display_power(charge_rate, convert = FALSE)].") . += span_notice("Right click it to remove all the cells at once!") /obj/machinery/cell_charger_multi/attackby(obj/item/tool, mob/user, params) @@ -93,15 +94,27 @@ if(!charging_batteries.len || !anchored || (machine_stat & (BROKEN|NOPOWER))) return - for(var/obj/item/stock_parts/cell/charging in charging_batteries) - if(charging.percent() >= 100) - continue - var/main_draw = use_power_from_net(charge_rate * seconds_per_tick, take_any = TRUE) //Pulls directly from the Powernet to dump into the cell - if(!main_draw) - return - charging.give(main_draw) - use_energy(charge_rate / 100) //use a small bit for the charger itself, but power usage scales up with the part tier + // create a charging queue, we only want cells that require charging to use the power budget + var/list/charging_queue = list() + for(var/obj/item/stock_parts/cell/battery_slot in charging_batteries) + if(battery_slot.percent() >= 100) + continue + LAZYADD(charging_queue, battery_slot) + + if(!length(charging_queue)) + return + // since this loop is running multiple times per tick, we divide so that the total usage in the tick is the expected charge rate + // 4 batteries can no longer magically each pull 4MW per tick (16MW total per tick) out of thin air like in the old system + var/charge_current = (charge_rate / length(charging_queue)) * seconds_per_tick + if(!charge_current) + return + + for(var/obj/item/stock_parts/cell/charging_cell in charging_queue) + use_energy(charge_current * 0.01) //use a small bit for the charger itself, but power usage scales up with the part tier + charge_cell(charge_current, charging_cell, grid_only = TRUE) + + LAZYNULL(charging_queue) update_appearance() /obj/machinery/cell_charger_multi/attack_tk(mob/user) @@ -115,14 +128,9 @@ /obj/machinery/cell_charger_multi/RefreshParts() . = ..() charge_rate = 0 // No, you cant get free charging speed! + var/charge_rate_base = 250 KILO WATTS for(var/datum/stock_part/capacitor/capacitor in component_parts) - charge_rate += charge_rate_base * capacitor.tier - if(charge_rate >= charge_rate_max) // We've hit the charge speed cap, stop iterating. - charge_rate = charge_rate_max - break - - if(charge_rate < charge_rate_base) // This should never happen; but we need to pretend it can. - charge_rate = charge_rate_base + charge_rate += (charge_rate_base * capacitor.tier) / 4 /obj/machinery/cell_charger_multi/emp_act(severity) . = ..() @@ -165,7 +173,7 @@ if(charging_batteries.len > 1 && user) var/list/buttons = list() for(var/obj/item/stock_parts/cell/battery in charging_batteries) - buttons["[battery] [battery.percent()]%"] = battery + buttons["[battery.name] ([round(battery.percent(), 1)]%)"] = battery var/cell_name = tgui_input_list(user, "Please choose what cell you'd like to remove.", "Remove a cell", buttons) charging = buttons[cell_name] else