mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 22:19:30 +01:00
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:
@@ -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()
|
||||
|
||||
@@ -187,6 +187,7 @@ const ApcContent = (props, context) => {
|
||||
label="Cover Lock"
|
||||
buttons={(
|
||||
<Button
|
||||
tooltip="APC cover can be pried open with a crowbar."
|
||||
icon={data.coverLocked ? 'lock' : 'unlock'}
|
||||
content={data.coverLocked ? 'Engaged' : 'Disengaged'}
|
||||
disabled={locked}
|
||||
@@ -196,6 +197,7 @@ const ApcContent = (props, context) => {
|
||||
label="Emergency Lighting"
|
||||
buttons={(
|
||||
<Button
|
||||
tooltip="Lights use internal power cell when there is no power available."
|
||||
icon="lightbulb-o"
|
||||
content={data.emergencyLights ? 'Enabled' : 'Disabled'}
|
||||
disabled={locked}
|
||||
@@ -205,6 +207,7 @@ const ApcContent = (props, context) => {
|
||||
label="Night Shift Lighting"
|
||||
buttons={(
|
||||
<Button
|
||||
tooltip="Dim lights to reduce power consumption."
|
||||
icon="lightbulb-o"
|
||||
content={data.nightshiftLights ? 'Enabled' : 'Disabled'}
|
||||
onClick={() => act('toggle_nightshift')} />
|
||||
|
||||
Reference in New Issue
Block a user