Continual updates until merged
This commit is contained in:
@@ -1104,7 +1104,7 @@
|
||||
|
||||
/obj/machinery/power/apc/add_load(amount)
|
||||
if(terminal && terminal.powernet)
|
||||
terminal.powernet.load += amount
|
||||
terminal.add_load(amount)
|
||||
|
||||
/obj/machinery/power/apc/avail()
|
||||
if(terminal)
|
||||
|
||||
@@ -199,6 +199,10 @@ By design, d1 is the smallest direction and d2 is the highest
|
||||
// Power related
|
||||
///////////////////////////////////////////
|
||||
|
||||
// All power generation handled in add_avail()
|
||||
// Machines should use add_load(), surplus(), avail()
|
||||
// Non-machines should use add_delayedload(), delayed_surplus(), newavail()
|
||||
|
||||
/obj/structure/cable/proc/add_avail(amount)
|
||||
if(powernet)
|
||||
powernet.newavail += amount
|
||||
@@ -209,7 +213,7 @@ By design, d1 is the smallest direction and d2 is the highest
|
||||
|
||||
/obj/structure/cable/proc/surplus()
|
||||
if(powernet)
|
||||
return powernet.avail-powernet.load
|
||||
return CLAMP(powernet.avail-powernet.load, 0, powernet.avail)
|
||||
else
|
||||
return 0
|
||||
|
||||
@@ -219,6 +223,22 @@ By design, d1 is the smallest direction and d2 is the highest
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/structure/cable/proc/add_delayedload(amount)
|
||||
if(powernet)
|
||||
powernet.delayedload += amount
|
||||
|
||||
/obj/structure/cable/proc/delayed_surplus()
|
||||
if(powernet)
|
||||
return CLAMP(powernet.newavail - powernet.delayedload, 0, powernet.newavail)
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/structure/cable/proc/newavail()
|
||||
if(powernet)
|
||||
return powernet.newavail
|
||||
else
|
||||
return 0
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// Cable laying helpers
|
||||
////////////////////////////////////////////////
|
||||
@@ -828,4 +848,4 @@ GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe("cable restrai
|
||||
|
||||
/obj/item/stack/cable_coil/cut/random
|
||||
item_color = null
|
||||
color = "#ffffff"
|
||||
color = "#ffffff"
|
||||
@@ -25,6 +25,10 @@
|
||||
//////////////////////////////
|
||||
|
||||
// common helper procs for all power machines
|
||||
// All power generation handled in add_avail()
|
||||
// Machines should use add_load(), surplus(), avail()
|
||||
// Non-machines should use add_delayedload(), delayed_surplus(), newavail()
|
||||
|
||||
/obj/machinery/power/proc/add_avail(amount)
|
||||
if(powernet)
|
||||
powernet.newavail += amount
|
||||
@@ -38,7 +42,7 @@
|
||||
|
||||
/obj/machinery/power/proc/surplus()
|
||||
if(powernet)
|
||||
return powernet.avail - powernet.load
|
||||
return CLAMP(powernet.avail-powernet.load, 0, powernet.avail)
|
||||
else
|
||||
return 0
|
||||
|
||||
@@ -48,6 +52,22 @@
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/proc/add_delayedload(amount)
|
||||
if(powernet)
|
||||
powernet.delayedload += amount
|
||||
|
||||
/obj/machinery/power/proc/delayed_surplus()
|
||||
if(powernet)
|
||||
return CLAMP(powernet.newavail - powernet.delayedload, 0, powernet.newavail)
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/proc/newavail()
|
||||
if(powernet)
|
||||
return powernet.newavail
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/machinery/power/proc/disconnect_terminal() // machines without a terminal will just return, no harm no fowl.
|
||||
return
|
||||
|
||||
@@ -341,7 +361,7 @@
|
||||
source_area.use_power(drained_energy/GLOB.CELLRATE)
|
||||
else if (istype(power_source, /datum/powernet))
|
||||
var/drained_power = drained_energy/GLOB.CELLRATE //convert from "joules" to "watts"
|
||||
PN.load+=drained_power
|
||||
PN.delayedload += (min(drained_power, max(PN.newavail - PN.delayedload, 0)))
|
||||
else if (istype(power_source, /obj/item/stock_parts/cell))
|
||||
cell.use(drained_energy)
|
||||
return drained_energy
|
||||
@@ -364,4 +384,4 @@
|
||||
/area/proc/get_apc()
|
||||
for(var/obj/machinery/power/apc/APC in GLOB.apcs_list)
|
||||
if(APC.area == src)
|
||||
return APC
|
||||
return APC
|
||||
@@ -13,6 +13,7 @@
|
||||
var/viewavail = 0 // the available power as it appears on the power console (gradually updated)
|
||||
var/viewload = 0 // the load as it appears on the power console (gradually updated)
|
||||
var/netexcess = 0 // excess power on the powernet (typically avail-load)///////
|
||||
var/delayedload = 0 // load applied to powernet between power ticks.
|
||||
|
||||
/datum/powernet/New()
|
||||
SSmachines.powernets += src
|
||||
@@ -88,7 +89,8 @@
|
||||
viewload = round(0.8 * viewload + 0.2 * load)
|
||||
|
||||
// reset the powernet
|
||||
load = 0
|
||||
load = delayedload
|
||||
delayedload = 0
|
||||
avail = newavail
|
||||
newavail = 0
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@
|
||||
update_icon()
|
||||
return
|
||||
if(active == TRUE)
|
||||
if(!active_power_usage || avail(active_power_usage))
|
||||
if(!active_power_usage || surplus() >= active_power_usage)
|
||||
add_load(active_power_usage)
|
||||
if(!powered)
|
||||
powered = TRUE
|
||||
@@ -189,7 +189,7 @@
|
||||
return FALSE
|
||||
if(state != EMITTER_WELDED)
|
||||
return FALSE
|
||||
if(avail(active_power_usage))
|
||||
if(surplus() >= active_power_usage)
|
||||
add_load(active_power_usage)
|
||||
fire_beam()
|
||||
|
||||
@@ -495,4 +495,4 @@
|
||||
|
||||
#undef EMITTER_UNWRENCHED
|
||||
#undef EMITTER_WRENCHED
|
||||
#undef EMITTER_WELDED
|
||||
#undef EMITTER_WELDED
|
||||
Reference in New Issue
Block a user