Light fixtures now use different variants of overlays in order to be non-unique and save up on instantiating a TON of overlay objects. Also, fixed the GC for them
This commit is contained in:
Azarak
2020-12-22 22:51:15 +01:00
committed by GitHub
parent 67b4aa190e
commit 9e23c3e5ee
2 changed files with 8 additions and 9 deletions
+8 -9
View File
@@ -253,8 +253,6 @@
var/bulb_emergency_pow_mul = 0.75 // the multiplier for determining the light's power in emergency mode
var/bulb_emergency_pow_min = 0.5 // the minimum value for the light's power in emergency mode
var/obj/effect/overlay/vis/glowybit // the light overlay
/obj/machinery/light/broken
status = LIGHT_BROKEN
icon_state = "tube-broken"
@@ -350,8 +348,6 @@
/obj/machinery/light/Initialize(mapload)
. = ..()
glowybit = SSvis_overlays.add_vis_overlay(src, overlayicon, base_state, layer, plane, dir, alpha = 0, unique = TRUE)
if(!mapload) //sync up nightshift lighting for player made lights
var/area/A = get_area(src)
var/obj/machinery/power/apc/temp_apc = A.get_apc()
@@ -381,8 +377,6 @@
on = FALSE
// A.update_lights()
QDEL_NULL(cell)
vis_contents.Cut()
QDEL_NULL(glowybit)
return ..()
/obj/machinery/light/update_icon_state()
@@ -402,10 +396,15 @@
/obj/machinery/light/update_overlays()
. = ..()
SSvis_overlays.remove_vis_overlay(src, managed_vis_overlays)
if(on && status == LIGHT_OK)
glowybit.alpha = clamp(light_power*250, 30, 200)
else
glowybit.alpha = 0
var/area/A = get_area(src)
if(emergency_mode || (A?.fire))
SSvis_overlays.add_vis_overlay(src, overlayicon, "[base_state]_emergency", layer, plane, dir)
else if (nightshift_enabled)
SSvis_overlays.add_vis_overlay(src, overlayicon, "[base_state]_nightshift", layer, plane, dir)
else
SSvis_overlays.add_vis_overlay(src, overlayicon, base_state, layer, plane, dir)
// update the icon_state and luminosity of the light depending on its state
/obj/machinery/light/proc/update(trigger = TRUE)