Merge pull request #8590 from Spookerton/spkrtn/fix/lingering-overlay-odds

fix overlay odds
This commit is contained in:
Atermonera
2022-04-30 15:30:46 -08:00
committed by GitHub
3 changed files with 381 additions and 385 deletions

View File

@@ -8,9 +8,6 @@ SUBSYSTEM_DEF(overlays)
/// The queue of atoms that need overlay updates.
var/static/tmp/list/queue = list()
/// An image used to create appearances to be cached.
var/static/tmp/image/renderer = new
/// A list([icon] = list([state] = [appearance], ...), ...) cache of appearances.
var/static/tmp/list/state_cache = list()
@@ -23,10 +20,12 @@ SUBSYSTEM_DEF(overlays)
/datum/controller/subsystem/overlays/Recover()
queue.Cut()
renderer = new
state_cache.Cut()
icon_cache.Cut()
cache_size = 0
for (var/atom/atom)
atom.flags &= ~OVERLAY_QUEUED
CHECK_TICK
/datum/controller/subsystem/overlays/Initialize(timeofday)
@@ -56,17 +55,16 @@ SUBSYSTEM_DEF(overlays)
subcache = list()
state_cache[icon] = subcache
if (!subcache[state])
renderer.icon = icon
renderer.icon_state = state
subcache[state] = renderer.appearance
var/image/image = new (icon, null, state)
subcache[state] = image.appearance
++cache_size
return subcache[state]
/datum/controller/subsystem/overlays/proc/GetIconAppearance(icon)
if (!icon_cache[icon])
renderer.icon = icon
icon_cache[icon] = renderer.appearance
var/image/image = new (icon)
icon_cache[icon] = image.appearance
++cache_size
return icon_cache[icon]
@@ -76,7 +74,6 @@ SUBSYSTEM_DEF(overlays)
return list()
if (!islist(sources))
sources = list(sources)
var/image/image
var/list/result = list()
var/icon/icon = subject.icon
for (var/atom/entry as anything in sources)
@@ -90,11 +87,11 @@ SUBSYSTEM_DEF(overlays)
if (isloc(entry))
if (entry.flags & OVERLAY_QUEUED)
entry.ImmediateOverlayUpdate()
renderer.appearance = entry
if (!ispath(entry))
image = entry
renderer.dir = image.dir
result += renderer.appearance
result += entry.appearance
else
var/image/image = entry
result += image.appearance
return result

View File

@@ -15,37 +15,36 @@
/obj/structure/closet/secure_closet/guncabinet/update_icon()
cut_overlays()
if(opened)
add_overlay("door_open")
else
var/lazors = 0
var/shottas = 0
for (var/obj/item/gun/G in contents)
if (istype(G, /obj/item/gun/energy))
lazors++
if (istype(G, /obj/item/gun/projectile))
shottas++
var/list/add = list()
if (!opened)
var/energy_count = 0
var/projectile_count = 0
for (var/obj/item/gun/gun in contents)
if (istype(gun, /obj/item/gun/energy))
++energy_count
else if(istype(gun, /obj/item/gun/projectile))
++projectile_count
for (var/i = 0 to 2)
if(lazors || shottas) // only make icons if we have one of the two types.
var/image/gun = image(icon(src.icon))
if (lazors > shottas)
lazors--
gun.icon_state = "laser"
else if (shottas)
shottas--
gun.icon_state = "projectile"
gun.pixel_x = i*4
add_overlay(gun)
add_overlay("door")
if(sealed)
add_overlay("sealed")
if(broken)
add_overlay("broken")
if (!energy_count && !projectile_count)
break
var/image/image = new (icon)
image.pixel_x = i * 4
if (energy_count > projectile_count)
image.icon_state = "laser"
--energy_count
else if (projectile_count)
image.icon_state = "projectile"
--projectile_count
add += image
add += "door"
if (sealed)
add += "sealed"
if (broken)
add += "broken"
else if (locked)
add_overlay("locked")
add += "locked"
else
add_overlay("open")
add += "open"
else
add += "door_open"
add_overlay(add)

View File

@@ -12,7 +12,7 @@
if(labelled)
name += " ([labelled])"
overlays.Cut()
cut_overlays()
// Updates the plant overlay.
if(!isnull(seed))