Night shift lights use power according to the brightness (#67667)

* Night shift lights use less power,
The last three APC buttons have tooltips

* suggested grammar fix
This commit is contained in:
Andrew
2022-06-11 21:35:57 -04:00
committed by GitHub
parent e199349b9d
commit fc540a26cc
2 changed files with 22 additions and 11 deletions
+19 -11
View File
@@ -18,8 +18,6 @@
var/base_state = "tube"
///Is the light on?
var/on = FALSE
///compared to the var/on for static calculations
var/on_gs = FALSE
///Amount of power used
var/static_power_used = 0
///Luminosity when on, also used in power calculation
@@ -66,6 +64,8 @@
var/bulb_emergency_pow_mul = 0.75
///The minimum value for the light's power in emergency mode
var/bulb_emergency_pow_min = 0.5
///Power usage - W per unit of luminosity
var/power_consumption_rate = 20
/obj/machinery/light/Move()
if(status != LIGHT_BROKEN)
@@ -202,17 +202,25 @@
use_power = IDLE_POWER_USE
set_light(l_range = 0)
update_appearance()
if(on != on_gs)
on_gs = on
if(on)
static_power_used = brightness * 20 //20W per unit luminosity
addStaticPower(static_power_used, AREA_USAGE_STATIC_LIGHT)
else
removeStaticPower(static_power_used, AREA_USAGE_STATIC_LIGHT)
update_current_power_usage()
broken_sparks(start_only=TRUE)
/obj/machinery/light/update_current_power_usage()
if(!on && static_power_used > 0) //Light is off but still powered
removeStaticPower(static_power_used, AREA_USAGE_STATIC_LIGHT)
static_power_used = 0
else if(on) //Light is on, just recalculate usage
var/static_power_used_new = 0
var/area/local_area = get_area(src)
if (nightshift_enabled && !local_area?.fire)
static_power_used_new = nightshift_brightness * nightshift_light_power * power_consumption_rate
else
static_power_used_new = brightness * bulb_power * power_consumption_rate
if(static_power_used != static_power_used_new) //Consumption changed - update
removeStaticPower(static_power_used, AREA_USAGE_STATIC_LIGHT)
static_power_used = static_power_used_new
addStaticPower(static_power_used, AREA_USAGE_STATIC_LIGHT)
/obj/machinery/light/update_atom_colour()
..()
update()