mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-29 07:59:01 +01:00
Ports the weather system from Nebula. (#18706)
* part 1 * compiles? * IT WORKS * vis contents * fixes * umbrelloid * umbrella 2 * dsasdd * stuff * lmao --------- Co-authored-by: Matt Atlas <liermattia@gmail.com>
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
SUBSYSTEM_DEF(vis_contents_update)
|
||||
name = "Vis Contents"
|
||||
flags = SS_BACKGROUND
|
||||
wait = 1
|
||||
init_order = INIT_ORDER_VISCONTENTS
|
||||
runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT
|
||||
var/list/queue_refs = list()
|
||||
|
||||
/datum/controller/subsystem/vis_contents_update/stat_entry()
|
||||
..("Queue: [queue_refs.len]")
|
||||
|
||||
/datum/controller/subsystem/vis_contents_update/Initialize()
|
||||
fire(FALSE, TRUE)
|
||||
return SS_INIT_SUCCESS
|
||||
|
||||
/datum/controller/subsystem/vis_contents_update/StartLoadingMap()
|
||||
can_fire = FALSE
|
||||
|
||||
/datum/controller/subsystem/vis_contents_update/StopLoadingMap()
|
||||
can_fire = TRUE
|
||||
|
||||
// Largely copied from SSicon_update.
|
||||
/datum/controller/subsystem/vis_contents_update/fire(resumed = FALSE, no_mc_tick = FALSE)
|
||||
if(!queue_refs.len)
|
||||
can_fire = FALSE
|
||||
return
|
||||
var/i = 0
|
||||
while (i < queue_refs.len)
|
||||
i++
|
||||
var/atom/A = queue_refs[i]
|
||||
if(QDELETED(A))
|
||||
continue
|
||||
if(Master.map_loading)
|
||||
queue_refs.Cut(1, i+1)
|
||||
return
|
||||
A.vis_update_queued = FALSE
|
||||
A.update_vis_contents(force_no_queue = TRUE)
|
||||
if (no_mc_tick)
|
||||
CHECK_TICK
|
||||
else if (MC_TICK_CHECK)
|
||||
queue_refs.Cut(1, i+1)
|
||||
return
|
||||
queue_refs.Cut()
|
||||
|
||||
/atom
|
||||
var/vis_update_queued = FALSE
|
||||
|
||||
/atom/proc/queue_vis_contents_update()
|
||||
if(vis_update_queued)
|
||||
return
|
||||
vis_update_queued = TRUE
|
||||
SSvis_contents_update.queue_refs.Add(src)
|
||||
SSvis_contents_update.can_fire = TRUE
|
||||
|
||||
// Horrible colon syntax below is because vis_contents
|
||||
// exists in /atom.vars, but will not compile. No idea why.
|
||||
/atom/proc/add_vis_contents(adding)
|
||||
src:vis_contents |= adding
|
||||
|
||||
/atom/proc/remove_vis_contents(removing)
|
||||
src:vis_contents -= removing
|
||||
|
||||
/atom/proc/clear_vis_contents()
|
||||
src:vis_contents = null
|
||||
|
||||
/atom/proc/set_vis_contents(list/adding)
|
||||
src:vis_contents = adding
|
||||
|
||||
/atom/proc/get_vis_contents_to_add()
|
||||
return
|
||||
|
||||
/atom/proc/update_vis_contents(force_no_queue = FALSE)
|
||||
if(!force_no_queue && (!SSvis_contents_update.initialized || TICK_CHECK))
|
||||
queue_vis_contents_update()
|
||||
return
|
||||
vis_update_queued = FALSE
|
||||
var/new_vis_contents = get_vis_contents_to_add()
|
||||
if(length(new_vis_contents))
|
||||
set_vis_contents(new_vis_contents)
|
||||
else if(length(src:vis_contents))
|
||||
clear_vis_contents()
|
||||
|
||||
/image/proc/add_vis_contents(adding)
|
||||
vis_contents |= adding
|
||||
|
||||
/image/proc/remove_vis_contents(removing)
|
||||
vis_contents -= removing
|
||||
|
||||
/image/proc/clear_vis_contents()
|
||||
vis_contents.Cut()
|
||||
|
||||
/image/proc/set_vis_contents(list/adding)
|
||||
vis_contents = adding
|
||||
@@ -0,0 +1,63 @@
|
||||
SUBSYSTEM_DEF(weather)
|
||||
name = "Weather"
|
||||
wait = 15 SECONDS
|
||||
init_order = INIT_ORDER_WEATHER
|
||||
priority = SS_PRIORITY_WEATHER
|
||||
flags = SS_BACKGROUND
|
||||
|
||||
var/list/weather_systems = list()
|
||||
var/list/weather_by_z = list()
|
||||
var/list/processing_systems
|
||||
|
||||
/datum/controller/subsystem/weather/stat_entry()
|
||||
..("all systems: [length(weather_systems)], processing systems: [length(processing_systems)]")
|
||||
|
||||
/datum/controller/subsystem/weather/Initialize(start_timeofday)
|
||||
. = ..()
|
||||
for(var/obj/abstract/weather_system/weather as anything in weather_systems)
|
||||
weather.init_weather()
|
||||
return SS_INIT_SUCCESS
|
||||
|
||||
/datum/controller/subsystem/weather/fire(resumed)
|
||||
|
||||
if(!resumed)
|
||||
processing_systems = weather_systems.Copy()
|
||||
|
||||
var/obj/abstract/weather_system/weather
|
||||
while(processing_systems.len)
|
||||
weather = processing_systems[processing_systems.len]
|
||||
processing_systems.len--
|
||||
weather.tick()
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
|
||||
///Sets a weather state to use for a given z level/z level stack.
|
||||
/datum/controller/subsystem/weather/proc/setup_weather_system(var/topmost_level, var/singleton/state/weather/initial_state)
|
||||
//First check and clear any existing weather system on the level
|
||||
var/obj/abstract/weather_system/WS = weather_by_z["[topmost_level]"]
|
||||
if(WS)
|
||||
unregister_weather_system(WS)
|
||||
qdel(WS)
|
||||
//Create the new weather system and let it register itself
|
||||
new /obj/abstract/weather_system(locate(1, 1, text2num(topmost_level)), topmost_level, initial_state)
|
||||
|
||||
///Registers a given weather system obj for getting updates by SSweather.
|
||||
/datum/controller/subsystem/weather/proc/register_weather_system(var/obj/abstract/weather_system/WS)
|
||||
if(weather_by_z["[WS.z]"])
|
||||
CRASH("Trying to register another weather system on the same z-level([WS.z]) as an existing one!")
|
||||
weather_systems |= WS
|
||||
|
||||
//Mark all affected z-levels
|
||||
var/list/affected = GetConnectedZlevels(WS.z)
|
||||
for(var/Z in affected)
|
||||
if(weather_by_z["[Z]"])
|
||||
CRASH("Trying to register another weather system on the same z-level([Z]) as an existing one!")
|
||||
weather_by_z["[Z]"] = WS
|
||||
|
||||
///Remove a weather systeam from the processing lists.
|
||||
/datum/controller/subsystem/weather/proc/unregister_weather_system(var/obj/abstract/weather_system/WS)
|
||||
//Clear any and all references to our weather object
|
||||
for(var/Z = 1 to length(weather_by_z))
|
||||
if(weather_by_z["[Z]"] == WS)
|
||||
weather_by_z["[Z]"] = null
|
||||
weather_systems -= WS
|
||||
Reference in New Issue
Block a user