From bb369af72fe68dffc93ff823c30d014ceeab2221 Mon Sep 17 00:00:00 2001 From: Vi3trice <80771500+Vi3trice@users.noreply.github.com> Date: Sat, 4 Oct 2025 15:35:08 -0400 Subject: [PATCH] Cache light colors in computers (#30590) * Remember the lights * Update computer.dm --- code/game/machinery/computer/computer.dm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/code/game/machinery/computer/computer.dm b/code/game/machinery/computer/computer.dm index fac6352d1b9..27800ac71e4 100644 --- a/code/game/machinery/computer/computer.dm +++ b/code/game/machinery/computer/computer.dm @@ -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