mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-18 02:24:11 +01:00
Revise radiation view to use a cached datum
* Creates a new datum, radiation_cache, to store radiation levels per-tile * Reworks radiation subsystem to initialize, expose radiation cache * Makes radiation view reference tiles in range against rad cache
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
PROCESSING_SUBSYSTEM_DEF(radiation)
|
||||
name = "Radiation"
|
||||
flags = SS_NO_INIT | SS_BACKGROUND
|
||||
flags = SS_BACKGROUND
|
||||
wait = 1 SECONDS
|
||||
offline_implications = "Radiation will no longer function; power generation may not happen. A restart may or may not be required, depending on the situation."
|
||||
var/list/warned_atoms = list()
|
||||
var/datum/radiation_cache/turf_cache
|
||||
|
||||
/datum/controller/subsystem/processing/radiation/Initialize(start_timeofday)
|
||||
. = ..()
|
||||
turf_cache = new()
|
||||
|
||||
/datum/controller/subsystem/processing/radiation/proc/warn(datum/component/radioactive/contamination)
|
||||
if(!contamination || QDELETED(contamination))
|
||||
@@ -16,3 +21,46 @@ PROCESSING_SUBSYSTEM_DEF(radiation)
|
||||
SSblackbox.record_feedback("tally", "contaminated", 1, master.type)
|
||||
var/msg = "has become contaminated with enough radiation to contaminate other objects. || Source: [contamination.source] || Strength: [contamination.strength]"
|
||||
master.investigate_log(msg, "radiation")
|
||||
|
||||
/datum/controller/subsystem/processing/radiation/proc/get_turf_radiation(turf/place)
|
||||
return turf_cache.get_turf_radiation(place)
|
||||
|
||||
/datum/controller/subsystem/processing/radiation/proc/update_rad_cache(datum/component/radioactive/thing)
|
||||
return turf_cache.update_rad_cache(thing)
|
||||
/datum/radiation_cache
|
||||
// Cache radiation levels for each turf so it doesn't need to be done iteratively
|
||||
// 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/has_refreshed_cache = FALSE
|
||||
var/list/turf_rad_cache = list()
|
||||
var/list/prev_rad_cache = list()
|
||||
|
||||
/datum/radiation_cache/New()
|
||||
. = ..()
|
||||
START_PROCESSING(SSradiation, src)
|
||||
|
||||
/datum/radiation_cache/Destroy()
|
||||
STOP_PROCESSING(SSradiation, src)
|
||||
return ..()
|
||||
|
||||
/datum/radiation_cache/proc/refresh_rad_cache()
|
||||
prev_rad_cache = turf_rad_cache.Copy()
|
||||
turf_rad_cache = list()
|
||||
|
||||
/datum/radiation_cache/proc/get_turf_radiation(turf/place)
|
||||
if (prev_rad_cache[place])
|
||||
return prev_rad_cache[place]
|
||||
else
|
||||
return 0
|
||||
|
||||
/datum/radiation_cache/proc/update_rad_cache(datum/component/radioactive/thing)
|
||||
var/atom/owner = thing.parent
|
||||
var/turf/place = get_turf(owner)
|
||||
if (turf_rad_cache[place])
|
||||
turf_rad_cache[place] += thing.strength
|
||||
else
|
||||
turf_rad_cache[place] = thing.strength
|
||||
|
||||
/datum/radiation_cache/process()
|
||||
refresh_rad_cache()
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
if(!hl3_release_date)
|
||||
return
|
||||
strength -= strength / hl3_release_date
|
||||
SSradiation.update_rad_cache(src)
|
||||
if(strength <= RAD_BACKGROUND_RADIATION)
|
||||
qdel(src)
|
||||
return PROCESS_KILL
|
||||
|
||||
+5
-13
@@ -1467,20 +1467,12 @@ GLOBAL_LIST_INIT(slot_equipment_priority, list( \
|
||||
* Show an overlay of radiation levels on radioactive objects.
|
||||
*/
|
||||
/mob/proc/show_rads(range)
|
||||
var/list/rad_places = list()
|
||||
for(var/datum/component/radioactive/thing in SSradiation.processing)
|
||||
var/atom/owner = thing.parent
|
||||
var/turf/place = get_turf(owner)
|
||||
if(rad_places[place])
|
||||
rad_places[place] += thing.strength
|
||||
else
|
||||
rad_places[place] = thing.strength
|
||||
|
||||
for(var/i in rad_places)
|
||||
var/turf/place = i
|
||||
if(get_dist(src, place) >= range)
|
||||
for(var/turf/place in range(range, src))
|
||||
var/rads = SSradiation.get_turf_radiation(place)
|
||||
if (rads < RAD_BACKGROUND_RADIATION)
|
||||
continue
|
||||
var/strength = round(rad_places[i] / 1000, 0.1)
|
||||
|
||||
var/strength = round(rads / 1000, 0.1)
|
||||
var/image/pic = image(loc = place)
|
||||
var/mutable_appearance/MA = new()
|
||||
MA.maptext = MAPTEXT("[strength]k")
|
||||
|
||||
Reference in New Issue
Block a user