mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-24 12:37:50 +01:00
Replaces add_load with draw_power. Issue about silly battery handling remains. Fixes the build-error.
This commit is contained in:
@@ -273,7 +273,6 @@
|
||||
master.used_environ = 0
|
||||
|
||||
/area/proc/use_power(var/amount, var/chan)
|
||||
|
||||
switch(chan)
|
||||
if(EQUIP)
|
||||
master.used_equip += amount
|
||||
|
||||
@@ -1040,9 +1040,10 @@
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/apc/add_load(var/amount)
|
||||
/obj/machinery/power/apc/draw_power(var/amount)
|
||||
if(terminal && terminal.powernet)
|
||||
terminal.powernet.load += amount
|
||||
return terminal.powernet.draw_power(amount)
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/apc/avail()
|
||||
if(terminal)
|
||||
@@ -1057,20 +1058,10 @@
|
||||
if(!area.requires_power)
|
||||
return
|
||||
|
||||
|
||||
/*
|
||||
if (equipment > 1) // off=0, off auto=1, on=2, on auto=3
|
||||
use_power(src.equip_consumption, EQUIP)
|
||||
if (lighting > 1) // off=0, off auto=1, on=2, on auto=3
|
||||
use_power(src.light_consumption, LIGHT)
|
||||
if (environ > 1) // off=0, off auto=1, on=2, on auto=3
|
||||
use_power(src.environ_consumption, ENVIRON)
|
||||
|
||||
area.calc_lighting() */
|
||||
lastused_light = area.usage(LIGHT)
|
||||
lastused_equip = area.usage(EQUIP)
|
||||
lastused_environ = area.usage(ENVIRON)
|
||||
area.clear_usage()
|
||||
// area.clear_usage()
|
||||
|
||||
lastused_total = lastused_light + lastused_equip + lastused_environ
|
||||
|
||||
@@ -1100,17 +1091,14 @@
|
||||
cell.use(cellused)
|
||||
|
||||
if(excess > lastused_total) // if power excess recharge the cell
|
||||
// by the same amount just used
|
||||
cell.give(cellused)
|
||||
add_load(cellused/CELLRATE) // add the load used to recharge the cell
|
||||
|
||||
|
||||
var/actual_gain = draw_power(cellused/CELLRATE) // add the load used to recharge the cell
|
||||
cell.give(actual_gain) // by the same amount just used
|
||||
else // no excess, and not enough per-apc
|
||||
|
||||
if( (cell.charge/CELLRATE + excess) >= lastused_total) // can we draw enough from cell+grid to cover last usage?
|
||||
|
||||
cell.charge = min(cell.maxcharge, cell.charge + CELLRATE * excess) //recharge with what we can
|
||||
add_load(excess) // so draw what we can from the grid
|
||||
draw_power(excess) // so draw what we can from the grid
|
||||
charging = 0
|
||||
|
||||
else // not enough power available to run the last tick!
|
||||
@@ -1159,8 +1147,8 @@
|
||||
if(excess > 0) // check to make sure we have enough to charge
|
||||
// Max charge is capped to % per second constant
|
||||
var/ch = min(excess*CELLRATE, cell.maxcharge*CHARGELEVEL)
|
||||
add_load(ch/CELLRATE) // Removes the power we're taking from the grid
|
||||
cell.give(ch) // actually recharge the cell
|
||||
var/actual_charge = draw_power(ch/CELLRATE) // Removes the power we're taking from the grid
|
||||
cell.give(actual_charge) // actually recharge the cell
|
||||
|
||||
else
|
||||
charging = 0 // stop charging
|
||||
|
||||
@@ -241,7 +241,7 @@
|
||||
if(terminal)
|
||||
if(chargemode)
|
||||
var/target_load = min((capacity-charge)/SMESRATE, chargelevel) // charge at set rate, limited to spare capacity
|
||||
var/actual_load = add_load(target_load) // add the load to the terminal side network
|
||||
var/actual_load = draw_power(target_load) // add the load to the terminal side network
|
||||
charge += actual_load * SMESRATE // increase the charge
|
||||
|
||||
if (actual_load >= target_load) // did the powernet have enough power available for us?
|
||||
@@ -249,10 +249,6 @@
|
||||
else
|
||||
charging = 0
|
||||
|
||||
else
|
||||
if (chargemode && excess > 0 && excess >= chargelevel)
|
||||
charging = 1
|
||||
|
||||
if(online) // if outputting
|
||||
lastout = min( charge/SMESRATE, output) //limit output to that stored
|
||||
charge -= lastout*SMESRATE // reduce the storage (may be recovered in /restore() if excessive)
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
if(powernet)
|
||||
powernet.newavail += amount
|
||||
|
||||
/obj/machinery/power/proc/add_load(var/amount)
|
||||
/obj/machinery/power/proc/draw_power(var/amount)
|
||||
if(powernet)
|
||||
return powernet.draw_power(amount)
|
||||
return 0
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
powernets -= src
|
||||
|
||||
/datum/powernet/proc/draw_power(var/amount)
|
||||
var/draw = min(amount, avail - load, 0)
|
||||
var/draw = between(0, amount, avail - load)
|
||||
load += draw
|
||||
return draw
|
||||
|
||||
|
||||
@@ -105,7 +105,8 @@
|
||||
return
|
||||
if(((src.last_shot + src.fire_delay) <= world.time) && (src.active == 1))
|
||||
|
||||
if(surplus() >= active_power_usage && add_load(active_power_usage) >= active_power_usage) //does the laser have enough power to shoot?
|
||||
var/actual_load = draw_power(active_power_usage)
|
||||
if(actual_load >= active_power_usage) //does the laser have enough power to shoot?
|
||||
if(!powered)
|
||||
powered = 1
|
||||
update_icon()
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
//TODO: Add a meter to tell players how much charge we are actually getting, and only set charging to 0 when we are unable to get any charge at all.
|
||||
if(chargemode)
|
||||
var/target_load = min((capacity-charge)/SMESRATE, chargelevel) // charge at set rate, limited to spare capacity
|
||||
var/actual_load = add_load(target_load) // add the load to the terminal side network
|
||||
var/actual_load = draw_power(target_load) // add the load to the terminal side network
|
||||
charge += actual_load * SMESRATE // increase the charge
|
||||
|
||||
if (actual_load >= target_load) // did the powernet have enough power available for us?
|
||||
@@ -174,7 +174,7 @@
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/power/smes/add_load(var/amount)
|
||||
/obj/machinery/power/smes/draw_power(var/amount)
|
||||
if(terminal && terminal.powernet)
|
||||
return terminal.powernet.draw_power(amount)
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user