Fixes radiation hud (#18703)

This commit is contained in:
Luc
2022-08-04 10:50:17 +01:00
committed by GitHub
parent 7b6659bf6a
commit b565e29cc6
+8 -3
View File
@@ -8,6 +8,8 @@ PROCESSING_SUBSYSTEM_DEF(radiation)
// turf_rad_cache is the state in the current loop, and may not be 100% representative
// until processing is complete.
// prev_rad_cache is the fully evaluated radiation state cache from the previous tick.
var/last_rad_cache_update = 0
var/rad_cache_update_interval = 5 SECONDS
var/list/turf_rad_cache = list()
var/list/prev_rad_cache = list()
@@ -25,7 +27,9 @@ PROCESSING_SUBSYSTEM_DEF(radiation)
master.investigate_log(msg, "radiation")
/datum/controller/subsystem/processing/radiation/fire(resumed)
refresh_rad_cache()
if(world.time > last_rad_cache_update + rad_cache_update_interval)
refresh_rad_cache()
last_rad_cache_update = world.time
. = ..()
/datum/controller/subsystem/processing/radiation/proc/get_turf_radiation(turf/place)
@@ -37,12 +41,13 @@ PROCESSING_SUBSYSTEM_DEF(radiation)
/datum/controller/subsystem/processing/radiation/proc/update_rad_cache(datum/component/radioactive/thing)
var/atom/owner = thing.parent
var/turf/place = get_turf(owner)
if (turf_rad_cache[place])
if(turf_rad_cache[place])
turf_rad_cache[place] += thing.strength
else
turf_rad_cache[place] = thing.strength
/datum/controller/subsystem/processing/radiation/proc/refresh_rad_cache()
prev_rad_cache = turf_rad_cache.Copy()
prev_rad_cache.Cut()
prev_rad_cache = turf_rad_cache
turf_rad_cache = list()