Cache light colors in computers (#30590)

* Remember the lights

* Update computer.dm
This commit is contained in:
Vi3trice
2025-10-04 15:35:08 -04:00
committed by GitHub
parent 118a986373
commit bb369af72f
+9 -6
View File
@@ -17,6 +17,8 @@
var/flickering = FALSE
/// Are we forcing the icon to be represented in a no-power state?
var/force_no_power_icon_state = FALSE
/// Cached list of colors associated with overlays
var/list/cached_emissive_color = list()
/obj/machinery/computer/Initialize(mapload)
. = ..()
@@ -86,12 +88,13 @@
underlays += emissive_appearance(icon, "[icon_keyboard]_lightmask")
if(!(stat & BROKEN))
// Get the average color of the computer screen so it can be used as a tinted glow
// Shamelessly stolen from /tg/'s /datum/component/customizable_reagent_holder.
var/icon/emissive_avg_screen_color = new(icon, overlay_state)
emissive_avg_screen_color.Scale(1, 1)
var/screen_emissive_color = copytext(emissive_avg_screen_color.GetPixel(1, 1), 1, 8) // remove opacity
set_light(light_range_on, light_power_on, screen_emissive_color)
if(!cached_emissive_color[overlay_state])
// Get the average color of the computer screen so it can be used as a tinted glow
// Shamelessly stolen from /tg/'s /datum/component/customizable_reagent_holder.
var/icon/emissive_avg_screen_color = new(icon, overlay_state)
emissive_avg_screen_color.Scale(1, 1)
cached_emissive_color[overlay_state] = copytext(emissive_avg_screen_color.GetPixel(1, 1), 1, 8) // remove opacity
set_light(light_range_on, light_power_on, cached_emissive_color[overlay_state])
/obj/machinery/computer/power_change()
. = ..() //we don't check parent return due to this also being contigent on the BROKEN stat flag