mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
Call update procs instead of directly setting idle_power_usage or active_power_usage.
- Adds the update_idle_power_usage() and update_active_power_usage() procs for the respective vars. - Switches all places modifying those vars directly to call the procs instead. - This will let us react to the change appropriately, paving the way towards static area power. - Adds update_power_channel proc for the sake of completeness, but no machines actually modify it so far.
This commit is contained in:
@@ -64,4 +64,4 @@
|
|||||||
T.maxhealth = round(initial(T.maxhealth) * 1.4)
|
T.maxhealth = round(initial(T.maxhealth) * 1.4)
|
||||||
T.shot_delay = round(initial(T.shot_delay) / 2)
|
T.shot_delay = round(initial(T.shot_delay) / 2)
|
||||||
T.auto_repair = 1
|
T.auto_repair = 1
|
||||||
T.active_power_usage = round(initial(T.active_power_usage) * 5)
|
T.update_active_power_usage(round(initial(T.active_power_usage) * 5))
|
||||||
@@ -207,8 +207,6 @@
|
|||||||
|
|
||||||
available_chemicals.Cut()
|
available_chemicals.Cut()
|
||||||
available_chemicals = base_chemicals.Copy()
|
available_chemicals = base_chemicals.Copy()
|
||||||
idle_power_usage = initial(idle_power_usage)
|
|
||||||
active_power_usage = initial(active_power_usage)
|
|
||||||
|
|
||||||
for(var/obj/item/weapon/stock_parts/P in component_parts)
|
for(var/obj/item/weapon/stock_parts/P in component_parts)
|
||||||
if(istype(P, /obj/item/weapon/stock_parts/capacitor))
|
if(istype(P, /obj/item/weapon/stock_parts/capacitor))
|
||||||
@@ -216,8 +214,8 @@
|
|||||||
|
|
||||||
cap_rating = max(1, round(cap_rating / 2))
|
cap_rating = max(1, round(cap_rating / 2))
|
||||||
|
|
||||||
idle_power_usage /= cap_rating
|
update_idle_power_usage(initial(idle_power_usage) / cap_rating)
|
||||||
active_power_usage /= cap_rating
|
update_active_power_usage(initial(active_power_usage) / cap_rating)
|
||||||
|
|
||||||
if(!limited)
|
if(!limited)
|
||||||
for(var/obj/item/weapon/stock_parts/P in component_parts)
|
for(var/obj/item/weapon/stock_parts/P in component_parts)
|
||||||
|
|||||||
@@ -223,4 +223,4 @@ var/global/list/engineering_networks = list(
|
|||||||
mult++
|
mult++
|
||||||
if (isMotion())
|
if (isMotion())
|
||||||
mult++
|
mult++
|
||||||
active_power_usage = mult*initial(active_power_usage)
|
update_active_power_usage(mult * initial(active_power_usage))
|
||||||
|
|||||||
@@ -60,13 +60,13 @@
|
|||||||
if(toggle)
|
if(toggle)
|
||||||
if(stat & (BROKEN|NOPOWER|EMPED))
|
if(stat & (BROKEN|NOPOWER|EMPED))
|
||||||
on = 0
|
on = 0
|
||||||
idle_power_usage = 0
|
update_idle_power_usage(0)
|
||||||
else
|
else
|
||||||
on = 1
|
on = 1
|
||||||
idle_power_usage = 2500
|
update_idle_power_usage(2500)
|
||||||
else
|
else
|
||||||
on = 0
|
on = 0
|
||||||
idle_power_usage = 0
|
update_idle_power_usage(0)
|
||||||
update_icon()
|
update_icon()
|
||||||
|
|
||||||
// Proc: emp_act()
|
// Proc: emp_act()
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ var/list/floor_light_cache = list()
|
|||||||
if(light_range || light_power)
|
if(light_range || light_power)
|
||||||
set_light(0)
|
set_light(0)
|
||||||
|
|
||||||
active_power_usage = ((light_range + light_power) * 10)
|
update_active_power_usage((light_range + light_power) * 10)
|
||||||
update_icon()
|
update_icon()
|
||||||
|
|
||||||
/obj/machinery/floor_light/update_icon()
|
/obj/machinery/floor_light/update_icon()
|
||||||
|
|||||||
@@ -196,6 +196,18 @@ Class Procs:
|
|||||||
/obj/machinery/proc/update_use_power(var/new_use_power)
|
/obj/machinery/proc/update_use_power(var/new_use_power)
|
||||||
use_power = new_use_power
|
use_power = new_use_power
|
||||||
|
|
||||||
|
// Sets the power_channel var
|
||||||
|
/obj/machinery/proc/update_power_channel(var/new_channel)
|
||||||
|
power_channel = new_channel
|
||||||
|
|
||||||
|
// Sets the idle_power_usage var
|
||||||
|
/obj/machinery/proc/update_idle_power_usage(var/new_power_usage)
|
||||||
|
idle_power_usage = new_power_usage
|
||||||
|
|
||||||
|
// Sets the active_power_usage var
|
||||||
|
/obj/machinery/proc/update_active_power_usage(var/new_power_usage)
|
||||||
|
active_power_usage = new_power_usage
|
||||||
|
|
||||||
/obj/machinery/proc/auto_use_power()
|
/obj/machinery/proc/auto_use_power()
|
||||||
if(!powered(power_channel))
|
if(!powered(power_channel))
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -143,7 +143,7 @@
|
|||||||
// Update power usage:
|
// Update power usage:
|
||||||
if(on)
|
if(on)
|
||||||
update_use_power(USE_POWER_ACTIVE)
|
update_use_power(USE_POWER_ACTIVE)
|
||||||
active_power_usage = electricity_level*15
|
update_active_power_usage(electricity_level * 15)
|
||||||
else
|
else
|
||||||
update_use_power(USE_POWER_OFF)
|
update_use_power(USE_POWER_OFF)
|
||||||
|
|
||||||
|
|||||||
@@ -77,15 +77,15 @@
|
|||||||
if(stat & (BROKEN|NOPOWER|EMPED))
|
if(stat & (BROKEN|NOPOWER|EMPED))
|
||||||
on = 0
|
on = 0
|
||||||
update_PDAs(1) // 1 being to turn off.
|
update_PDAs(1) // 1 being to turn off.
|
||||||
idle_power_usage = 0
|
update_idle_power_usage(0)
|
||||||
else
|
else
|
||||||
on = 1
|
on = 1
|
||||||
update_PDAs(0)
|
update_PDAs(0)
|
||||||
idle_power_usage = 750
|
update_idle_power_usage(750)
|
||||||
else
|
else
|
||||||
on = 0
|
on = 0
|
||||||
update_PDAs(1)
|
update_PDAs(1)
|
||||||
idle_power_usage = 0
|
update_idle_power_usage(0)
|
||||||
update_icon()
|
update_icon()
|
||||||
|
|
||||||
/obj/machinery/pda_multicaster/process()
|
/obj/machinery/pda_multicaster/process()
|
||||||
|
|||||||
@@ -20,9 +20,9 @@
|
|||||||
/obj/machinery/proc/change_power_consumption(new_power_consumption, use_power_mode = USE_POWER_IDLE)
|
/obj/machinery/proc/change_power_consumption(new_power_consumption, use_power_mode = USE_POWER_IDLE)
|
||||||
switch(use_power_mode)
|
switch(use_power_mode)
|
||||||
if(USE_POWER_IDLE)
|
if(USE_POWER_IDLE)
|
||||||
idle_power_usage = new_power_consumption
|
update_idle_power_usage(new_power_consumption)
|
||||||
if(USE_POWER_ACTIVE)
|
if(USE_POWER_ACTIVE)
|
||||||
active_power_usage = new_power_consumption
|
update_active_power_usage(new_power_consumption)
|
||||||
// No need to do anything else in our power scheme.
|
// No need to do anything else in our power scheme.
|
||||||
|
|
||||||
// Defining directly here to avoid conflicts with existing set_broken procs in our codebase that behave differently.
|
// Defining directly here to avoid conflicts with existing set_broken procs in our codebase that behave differently.
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ var/list/fusion_cores = list()
|
|||||||
if(href_list["str"])
|
if(href_list["str"])
|
||||||
var/dif = text2num(href_list["str"])
|
var/dif = text2num(href_list["str"])
|
||||||
field_strength = min(max(field_strength + dif, MIN_FIELD_STR), MAX_FIELD_STR)
|
field_strength = min(max(field_strength + dif, MIN_FIELD_STR), MAX_FIELD_STR)
|
||||||
active_power_usage = 500 * field_strength
|
update_active_power_usage(500 * field_strength)
|
||||||
if(owned_field)
|
if(owned_field)
|
||||||
owned_field.ChangeFieldStrength(field_strength)
|
owned_field.ChangeFieldStrength(field_strength)
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ var/list/fusion_cores = list()
|
|||||||
/obj/machinery/power/fusion_core/proc/set_strength(var/value)
|
/obj/machinery/power/fusion_core/proc/set_strength(var/value)
|
||||||
value = CLAMP(value, MIN_FIELD_STR, MAX_FIELD_STR)
|
value = CLAMP(value, MIN_FIELD_STR, MAX_FIELD_STR)
|
||||||
field_strength = value
|
field_strength = value
|
||||||
active_power_usage = 5 * value
|
update_active_power_usage(5 * value)
|
||||||
if(owned_field)
|
if(owned_field)
|
||||||
owned_field.ChangeFieldStrength(value)
|
owned_field.ChangeFieldStrength(value)
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ var/list/gyrotrons = list()
|
|||||||
|
|
||||||
/obj/machinery/power/emitter/gyrotron/Initialize()
|
/obj/machinery/power/emitter/gyrotron/Initialize()
|
||||||
gyrotrons += src
|
gyrotrons += src
|
||||||
active_power_usage = mega_energy * 50000
|
update_active_power_usage(mega_energy * 50000)
|
||||||
default_apply_parts()
|
default_apply_parts()
|
||||||
. = ..()
|
. = ..()
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ var/list/gyrotrons = list()
|
|||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
/obj/machinery/power/emitter/gyrotron/process()
|
/obj/machinery/power/emitter/gyrotron/process()
|
||||||
active_power_usage = mega_energy * 50000
|
update_active_power_usage(mega_energy * 50000)
|
||||||
. = ..()
|
. = ..()
|
||||||
|
|
||||||
/obj/machinery/power/emitter/gyrotron/get_rand_burst_delay()
|
/obj/machinery/power/emitter/gyrotron/get_rand_burst_delay()
|
||||||
|
|||||||
@@ -75,7 +75,7 @@
|
|||||||
to_chat(usr, "<span class='warning'>That's not a valid number.</span>")
|
to_chat(usr, "<span class='warning'>That's not a valid number.</span>")
|
||||||
return 1
|
return 1
|
||||||
G.mega_energy = CLAMP(new_val, 1, 50)
|
G.mega_energy = CLAMP(new_val, 1, 50)
|
||||||
G.active_power_usage = G.mega_energy * 1500
|
G.update_active_power_usage(G.mega_energy * 1500)
|
||||||
updateUsrDialog()
|
updateUsrDialog()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|||||||
@@ -445,7 +445,7 @@ var/global/list/light_type_cache = list()
|
|||||||
update_use_power(USE_POWER_IDLE)
|
update_use_power(USE_POWER_IDLE)
|
||||||
set_light(0)
|
set_light(0)
|
||||||
|
|
||||||
active_power_usage = ((light_range * light_power) * LIGHTING_POWER_FACTOR)
|
update_active_power_usage((light_range * light_power) * LIGHTING_POWER_FACTOR)
|
||||||
|
|
||||||
|
|
||||||
/obj/machinery/light/attack_generic(var/mob/user, var/damage)
|
/obj/machinery/light/attack_generic(var/mob/user, var/damage)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
/obj/machinery/particle_accelerator/control_box/New()
|
/obj/machinery/particle_accelerator/control_box/New()
|
||||||
wires = new(src)
|
wires = new(src)
|
||||||
connected_parts = list()
|
connected_parts = list()
|
||||||
active_power_usage = initial(active_power_usage) * (strength + 1)
|
update_active_power_usage(initial(active_power_usage) * (strength + 1))
|
||||||
..()
|
..()
|
||||||
|
|
||||||
/obj/machinery/particle_accelerator/control_box/Destroy()
|
/obj/machinery/particle_accelerator/control_box/Destroy()
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
var/tot_rating = 0
|
var/tot_rating = 0
|
||||||
for(var/obj/item/weapon/stock_parts/SP in src)
|
for(var/obj/item/weapon/stock_parts/SP in src)
|
||||||
tot_rating += SP.rating
|
tot_rating += SP.rating
|
||||||
idle_power_usage /= max(1, tot_rating)
|
update_idle_power_usage(initial(idle_power_usage) / max(1, tot_rating))
|
||||||
|
|
||||||
/obj/machinery/r_n_d/server/Initialize()
|
/obj/machinery/r_n_d/server/Initialize()
|
||||||
. = ..()
|
. = ..()
|
||||||
|
|||||||
@@ -153,9 +153,10 @@
|
|||||||
|
|
||||||
create_shields()
|
create_shields()
|
||||||
|
|
||||||
idle_power_usage = 0
|
var/new_power_usage = 0
|
||||||
for(var/obj/machinery/shield/shield_tile in deployed_shields)
|
for(var/obj/machinery/shield/shield_tile in deployed_shields)
|
||||||
idle_power_usage += shield_tile.shield_idle_power
|
new_power_usage += shield_tile.shield_idle_power
|
||||||
|
update_idle_power_usage(new_power_usage)
|
||||||
update_use_power(USE_POWER_IDLE)
|
update_use_power(USE_POWER_IDLE)
|
||||||
|
|
||||||
/obj/machinery/shieldgen/proc/shields_down()
|
/obj/machinery/shieldgen/proc/shields_down()
|
||||||
@@ -205,7 +206,7 @@
|
|||||||
new_power_usage += shield_tile.shield_idle_power
|
new_power_usage += shield_tile.shield_idle_power
|
||||||
|
|
||||||
if (new_power_usage != idle_power_usage)
|
if (new_power_usage != idle_power_usage)
|
||||||
idle_power_usage = new_power_usage
|
update_idle_power_usage(new_power_usage)
|
||||||
use_power(0)
|
use_power(0)
|
||||||
|
|
||||||
check_delay = 60
|
check_delay = 60
|
||||||
|
|||||||
Reference in New Issue
Block a user