Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Fixes recharge stations charge rates #2602

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions code/game/machinery/rechargestation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
. = ..()
Expand Down Expand Up @@ -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)
7 changes: 3 additions & 4 deletions code/modules/mob/living/silicon/robot/robot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 7 additions & 2 deletions code/modules/mod/mod_core.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions code/modules/wiremod/shell/brain_computer_interface.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions code/modules/wiremod/shell/drone.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading