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

View File

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

View File

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