Always call update_use_power() instead of directly setting the use_power var.

- This will let us react to the change appropriately.
- While we're here, lets define some constants so we can stop using bare numbers.
- Always use those constants when calling update_use_power()
This commit is contained in:
Leshana
2020-03-21 16:40:22 -04:00
parent efeaf058ff
commit c2d16acdca
52 changed files with 124 additions and 119 deletions
+1 -1
View File
@@ -539,7 +539,7 @@
Pump.air2.gas["nitrogen"] = 3750 //The contents of 2 canisters.
Pump.air2.temperature = 50
Pump.air2.update_values()
Pump.use_power=1
Pump.update_use_power(USE_POWER_IDLE)
Pump.target_pressure = 4500
Pump.update_icon()
+2 -2
View File
@@ -224,7 +224,7 @@
damaged = 1
loadProgram(powerdown_program, 0)
active = 0
use_power = 1
update_use_power(USE_POWER_IDLE)
for(var/mob/M in range(10,src))
M.show_message("The holodeck overloads!")
@@ -271,7 +271,7 @@
linkedholodeck.gravitychange(1)
active = 0
use_power = 1
update_use_power(USE_POWER_IDLE)
/obj/machinery/computer/HolodeckControl/proc/loadProgram(var/prog, var/check_delay = 1)
+2 -2
View File
@@ -126,7 +126,7 @@
GLOB.moved_event.register(watching_mob, src, /obj/machinery/station_map/proc/checkPosition)
GLOB.dir_set_event.register(watching_mob, src, /obj/machinery/station_map/proc/checkPosition)
GLOB.destroyed_event.register(watching_mob, src, /obj/machinery/station_map/proc/stopWatching)
update_use_power(2)
update_use_power(USE_POWER_ACTIVE)
if(bogus)
to_chat(user, "<span class='warning'>The holomap failed to initialize. This area of space cannot be mapped.</span>")
@@ -156,7 +156,7 @@
GLOB.dir_set_event.unregister(watching_mob, src)
GLOB.destroyed_event.unregister(watching_mob, src)
watching_mob = null
update_use_power(1)
update_use_power(USE_POWER_IDLE)
/obj/machinery/station_map/power_change()
. = ..()
+3 -3
View File
@@ -319,14 +319,14 @@ var/list/ai_verbs_default = list(
qdel(src)
return
if(powered_ai.APU_power)
use_power = 0
update_use_power(USE_POWER_OFF)
return
if(!powered_ai.anchored)
loc = powered_ai.loc
use_power = 0
update_use_power(USE_POWER_OFF)
use_power(50000) // Less optimalised but only called if AI is unwrenched. This prevents usage of wrenching as method to keep AI operational without power. Intellicard is for that.
if(powered_ai.anchored)
use_power = 2
update_use_power(USE_POWER_ACTIVE)
/mob/living/silicon/ai/proc/pick_icon()
set category = "AI Settings"
@@ -38,9 +38,9 @@
/obj/machinery/ntnet_relay/process()
if(operable())
use_power = 2
update_use_power(USE_POWER_ACTIVE)
else
use_power = 1
update_use_power(USE_POWER_IDLE)
if(dos_overload)
dos_overload = max(0, dos_overload - dos_dissipate)
+2 -2
View File
@@ -211,10 +211,10 @@
/obj/machinery/power/am_control_unit/proc/toggle_power()
active = !active
if(active)
use_power = 2
update_use_power(USE_POWER_ACTIVE)
visible_message("The [src.name] starts up.")
else
use_power = 1
update_use_power(USE_POWER_IDLE)
visible_message("The [src.name] shuts down.")
update_icon()
return
+2 -2
View File
@@ -70,7 +70,7 @@ var/list/fusion_cores = list()
owned_field = new(loc, src)
owned_field.ChangeFieldStrength(field_strength)
icon_state = "core1"
use_power = 2
update_use_power(USE_POWER_ACTIVE)
. = 1
/obj/machinery/power/fusion_core/proc/Shutdown(var/force_rupture)
@@ -82,7 +82,7 @@ var/list/fusion_cores = list()
owned_field.RadiateAll()
qdel(owned_field)
owned_field = null
use_power = 1
update_use_power(USE_POWER_IDLE)
/obj/machinery/power/fusion_core/proc/AddParticles(var/name, var/quantity = 1)
if(owned_field)
@@ -103,13 +103,13 @@ var/list/fuel_injectors = list()
if(!injecting && cur_assembly)
icon_state = "injector1"
injecting = 1
use_power = 1
update_use_power(USE_POWER_IDLE)
/obj/machinery/fusion_fuel_injector/proc/StopInjecting()
if(injecting)
injecting = 0
icon_state = "injector0"
use_power = 0
update_use_power(USE_POWER_OFF)
/obj/machinery/fusion_fuel_injector/proc/Inject()
if(!injecting)
+1 -1
View File
@@ -156,7 +156,7 @@
user.visible_message("[user.name] [anchored ? "secures" : "unsecures"] the bolts holding [src.name] to the floor.", \
"You [anchored ? "secure" : "unsecure"] the bolts holding [src] to the floor.", \
"You hear a ratchet.")
use_power = anchored
update_use_power(anchored ? USE_POWER_IDLE : USE_POWER_ACTIVE)
if(anchored) // Powernet connection stuff.
connect_to_network()
else
+2 -2
View File
@@ -320,10 +320,10 @@ var/global/list/light_type_cache = list()
on = 0
set_light(0)
else
use_power = 2
update_use_power(USE_POWER_ACTIVE)
set_light(brightness_range, brightness_power, brightness_color)
else
use_power = 1
update_use_power(USE_POWER_IDLE)
set_light(0)
active_power_usage = ((light_range * light_power) * LIGHTING_POWER_FACTOR)
@@ -383,10 +383,10 @@ So, hopefully this is helpful if any more icons are to be added/changed/wonderin
if(src.construction_state < 3)//Was taken apart, update state
update_state()
if(use_power)
use_power = 0
update_use_power(USE_POWER_OFF)
src.construction_state = temp_state
if(src.construction_state >= 3)
use_power = 1
update_use_power(USE_POWER_IDLE)
update_icon()
return 1
return 0
@@ -42,7 +42,7 @@
/obj/machinery/particle_accelerator/control_box/update_state()
if(construction_state < 3)
update_use_power(0)
update_use_power(USE_POWER_OFF)
assembled = 0
active = 0
for(var/obj/structure/particle_accelerator/part in connected_parts)
@@ -52,7 +52,7 @@
connected_parts = list()
return
if(!part_scan())
update_use_power(1)
update_use_power(USE_POWER_IDLE)
active = 0
connected_parts = list()
@@ -138,9 +138,9 @@
..()
if(stat & NOPOWER)
active = 0
update_use_power(0)
update_use_power(USE_POWER_OFF)
else if(!stat && construction_state == 3)
update_use_power(1)
update_use_power(USE_POWER_IDLE)
/obj/machinery/particle_accelerator/control_box/process()
@@ -212,13 +212,13 @@
message_admins("PA Control Computer turned [active ?"ON":"OFF"] by [key_name(usr, usr.client)](<A HREF='?_src_=holder;adminmoreinfo=\ref[usr]'>?</A>) in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
log_game("PACCEL([x],[y],[z]) [key_name(usr)] turned [active?"ON":"OFF"].")
if(active)
update_use_power(2)
update_use_power(USE_POWER_ACTIVE)
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = src.strength
part.powered = 1
part.update_icon()
else
update_use_power(1)
update_use_power(USE_POWER_IDLE)
for(var/obj/structure/particle_accelerator/part in connected_parts)
part.strength = null
part.powered = 0
@@ -126,7 +126,7 @@ GLOBAL_LIST_BOILERPLATE(all_engine_setup_markers, /obj/effect/engine_setup)
log_and_message_admins("## WARNING: Unable to locate pump at [x] [y] [z]!")
return SETUP_WARNING
P.target_pressure = P.max_pressure_setting
P.use_power = 1
P.update_use_power(USE_POWER_IDLE)
P.update_icon()
return SETUP_OK
@@ -259,7 +259,7 @@ GLOBAL_LIST_BOILERPLATE(all_engine_setup_markers, /obj/effect/engine_setup)
return SETUP_WARNING
F.rebuild_filtering_list()
F.use_power = 1
F.update_use_power(USE_POWER_IDLE)
F.update_icon()
return SETUP_OK
+3 -3
View File
@@ -359,7 +359,7 @@
// charge the gas reservoir and perform flush if ready
/obj/machinery/disposal/process()
if(!air_contents || (stat & BROKEN)) // nothing can happen if broken
update_use_power(0)
update_use_power(USE_POWER_OFF)
return
flush_count++
@@ -377,7 +377,7 @@
flush()
if(mode != 1) //if off or ready, no need to charge
update_use_power(1)
update_use_power(USE_POWER_IDLE)
else if(air_contents.return_pressure() >= SEND_PRESSURE)
mode = 2 //if full enough, switch to ready mode
update()
@@ -386,7 +386,7 @@
/obj/machinery/disposal/proc/pressurize()
if(stat & NOPOWER) // won't charge if no power
update_use_power(0)
update_use_power(USE_POWER_OFF)
return
var/atom/L = loc // recharging from loc turf
+2 -2
View File
@@ -156,7 +156,7 @@
idle_power_usage = 0
for(var/obj/machinery/shield/shield_tile in deployed_shields)
idle_power_usage += shield_tile.shield_idle_power
update_use_power(1)
update_use_power(USE_POWER_IDLE)
/obj/machinery/shieldgen/proc/shields_down()
if(!active) return 0 //If it's already off, how did this get called?
@@ -166,7 +166,7 @@
collapse_shields()
update_use_power(0)
update_use_power(USE_POWER_OFF)
/obj/machinery/shieldgen/proc/create_shields()
for(var/turf/target_tile in range(2, src))
+1 -1
View File
@@ -57,7 +57,7 @@
update_icon()
return
enabled = !enabled
use_power = enabled + 1
update_use_power(enabled ? USE_POWER_ACTIVE : USE_POWER_IDLE)
update_icon()
to_chat(usr, "You turn \the [src] [enabled ? "on" : "off"].")
@@ -54,7 +54,7 @@
//if we've finished growing...
if(time_spent_spawning >= time_per_spawn)
time_spent_spawning = 0
use_power = 1
update_use_power(USE_POWER_IDLE)
src.visible_message("<span class='notice'>\icon[src] [src] pings!</span>")
icon_state = "cellold1"
desc = "It's full of a bubbling viscous liquid, and is lit by a mysterious glow."
@@ -63,11 +63,11 @@
//if we're getting close to finished, kick into overdrive power usage
if(time_spent_spawning / time_per_spawn > 0.75)
use_power = 2
update_use_power(USE_POWER_ACTIVE)
icon_state = "cellold2"
desc = "It's full of a bubbling viscous liquid, and is lit by a mysterious glow. A dark shape appears to be forming inside..."
else
use_power = 1
update_use_power(USE_POWER_IDLE)
icon_state = "cellold1"
desc = "It's full of a bubbling viscous liquid, and is lit by a mysterious glow."
@@ -104,7 +104,7 @@
max_spawn_time = rand(30,100)
if(!spawning_types.len || !stored_materials.len)
use_power = 1
update_use_power(USE_POWER_IDLE)
icon_state = "borgcharger0(old)"
else if(prob(5))
@@ -145,7 +145,7 @@
spawning_types.Add(construction[construction[index]])
spawn_progress_time = 0
use_power = 2
update_use_power(USE_POWER_ACTIVE)
icon_state = "borgcharger1(old)"
else
src.visible_message(fail_message)
@@ -80,7 +80,7 @@
//check if we've finished
if(inserted_battery.stored_charge >= inserted_battery.capacity)
use_power = 1
update_use_power(USE_POWER_IDLE)
harvesting = 0
cur_artifact.anchored = 0
cur_artifact.being_used = 0
@@ -105,7 +105,7 @@
//if there's no charge left, finish
if(inserted_battery.stored_charge <= 0)
use_power = 1
update_use_power(USE_POWER_IDLE)
inserted_battery.stored_charge = 0
harvesting = 0
if(inserted_battery.battery_effect && inserted_battery.battery_effect.activated)
@@ -191,7 +191,7 @@
if(source_effect)
harvesting = 1
use_power = 2
update_use_power(USE_POWER_ACTIVE)
cur_artifact.anchored = 1
cur_artifact.being_used = 1
icon_state = "incubator_on"
@@ -235,7 +235,7 @@
inserted_battery.battery_effect.ToggleActivate(1)
last_process = world.time
harvesting = -1
use_power = 2
update_use_power(USE_POWER_ACTIVE)
icon_state = "incubator_on"
var/message = "<b>[src]</b> states, \"Warning, battery charge dump commencing.\""
src.visible_message(message)