diff --git a/code/game/machinery/rechargestation.dm b/code/game/machinery/rechargestation.dm index f43431b8e79..fbd85064f1b 100644 --- a/code/game/machinery/rechargestation.dm +++ b/code/game/machinery/rechargestation.dm @@ -11,6 +11,8 @@ processing_flags = NONE var/recharge_speed var/repairs + ///Callback for borgs & modsuits to provide their cell to us for charging + var/datum/callback/charge_cell ///Whether we're sending iron and glass to a cyborg. Requires Silo connection. var/sendmats = FALSE var/datum/component/remote_materials/materials @@ -24,6 +26,7 @@ mapload, \ mat_container_flags = MATCONTAINER_NO_INSERT, \ ) + charge_cell = CALLBACK(src, PROC_REF(charge_target_cell)) update_appearance() if(is_operational) @@ -41,16 +44,33 @@ return GLOB.roundstart_station_borgcharger_areas += area_name +/obj/machinery/recharge_station/Destroy() + materials = null + charge_cell = null + return ..() + +/** + * Mobs & borgs invoke this through a callback to recharge their cells + * Arguments + * + * * obj/item/stock_parts/cell/target - the cell to charge, optional if provided else will draw power used directly + * * seconds_per_tick - supplied from process() + */ +/obj/machinery/recharge_station/proc/charge_target_cell(obj/item/stock_parts/cell/target, seconds_per_tick) + PRIVATE_PROC(TRUE) + + return charge_cell(recharge_speed * seconds_per_tick, target, grid_only = TRUE) + /obj/machinery/recharge_station/RefreshParts() . = ..() recharge_speed = 0 repairs = 0 for(var/datum/stock_part/capacitor/capacitor in component_parts) - recharge_speed += capacitor.tier * 100 + recharge_speed += (capacitor.tier * STANDARD_CELL_CHARGE * 0.01) for(var/datum/stock_part/servo/servo in component_parts) repairs += servo.tier - 1 for(var/obj/item/stock_parts/cell/cell in component_parts) - recharge_speed *= cell.maxcharge / 10000 + recharge_speed *= (cell.maxcharge / STANDARD_CELL_CHARGE) /obj/machinery/recharge_station/examine(mob/user) . = ..() @@ -156,7 +176,4 @@ /obj/machinery/recharge_station/proc/process_occupant(seconds_per_tick) if(!occupant) return - var/main_draw = use_energy(recharge_speed * seconds_per_tick) //Pulls directly from the Powernet to dump into the cell - if(!main_draw) - return - SEND_SIGNAL(occupant, COMSIG_PROCESS_BORGCHARGER_OCCUPANT, main_draw, repairs, sendmats) + SEND_SIGNAL(occupant, COMSIG_PROCESS_BORGCHARGER_OCCUPANT, charge_cell, seconds_per_tick, repairs, sendmats) diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 9cc97ed4fd6..cc280ea833d 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -965,14 +965,13 @@ for(var/i in connected_ai.aicamera.stored) aicamera.stored[i] = TRUE -/mob/living/silicon/robot/proc/charge(datum/source, amount, repairs, sendmats) +/mob/living/silicon/robot/proc/charge(datum/source, datum/callback/charge_cell, seconds_per_tick, repairs, sendmats) SIGNAL_HANDLER + charge_cell.Invoke(cell, seconds_per_tick) if(model) - model.respawn_consumable(src, amount * 0.005) + model.respawn_consumable(src, cell.use(cell.chargerate * 0.005)) if(sendmats) model.restock_consumable() - if(cell) - cell.charge = min(cell.charge + amount, cell.maxcharge) if(repairs) heal_bodypart_damage(repairs, repairs) diff --git a/code/modules/mod/mod_core.dm b/code/modules/mod/mod_core.dm index cd564e12cb8..3a765e537eb 100644 --- a/code/modules/mod/mod_core.dm +++ b/code/modules/mod/mod_core.dm @@ -236,10 +236,15 @@ UnregisterSignal(mod.wearer, COMSIG_PROCESS_BORGCHARGER_OCCUPANT) UnregisterSignal(mod, COMSIG_MOD_WEARER_UNSET) -/obj/item/mod/core/standard/proc/on_borg_charge(datum/source, amount) +/obj/item/mod/core/standard/proc/on_borg_charge(datum/source, datum/callback/charge_cell, seconds_per_tick) SIGNAL_HANDLER - add_charge(amount) + var/obj/item/stock_parts/cell/target_cell = charge_source() + if(isnull(target_cell)) + return + + if(charge_cell.Invoke(target_cell, seconds_per_tick)) + mod.update_charge_alert() /obj/item/mod/core/ethereal name = "MOD ethereal core" diff --git a/code/modules/wiremod/shell/brain_computer_interface.dm b/code/modules/wiremod/shell/brain_computer_interface.dm index 308aea87420..3cd9a3d6bc0 100644 --- a/code/modules/wiremod/shell/brain_computer_interface.dm +++ b/code/modules/wiremod/shell/brain_computer_interface.dm @@ -189,13 +189,13 @@ COMSIG_LIVING_ELECTROCUTE_ACT, )) -/obj/item/circuit_component/bci_core/proc/on_borg_charge(datum/source, amount) +/obj/item/circuit_component/bci_core/proc/on_borg_charge(datum/source, datum/callback/charge_cell, seconds_per_tick) SIGNAL_HANDLER if (isnull(parent.cell)) return - parent.cell.give(amount) + charge_cell.Invoke(parent.cell, seconds_per_tick) /obj/item/circuit_component/bci_core/proc/on_electrocute(datum/source, shock_damage, shock_source, siemens_coefficient, flags) SIGNAL_HANDLER diff --git a/code/modules/wiremod/shell/drone.dm b/code/modules/wiremod/shell/drone.dm index 96fe3b2fa0a..7d547645cd1 100644 --- a/code/modules/wiremod/shell/drone.dm +++ b/code/modules/wiremod/shell/drone.dm @@ -74,11 +74,11 @@ UnregisterSignal(shell, COMSIG_PROCESS_BORGCHARGER_OCCUPANT) return ..() -/obj/item/circuit_component/bot_circuit/proc/on_borg_charge(datum/source, amount) +/obj/item/circuit_component/bot_circuit/proc/on_borg_charge(datum/source, datum/callback/charge_cell, seconds_per_tick) SIGNAL_HANDLER if (isnull(parent.cell)) return - parent.cell.give(amount) + charge_cell.Invoke(parent.cell, seconds_per_tick) /obj/item/circuit_component/bot_circuit/populate_ports() north = add_input_port("Move North", PORT_TYPE_SIGNAL)