Files
Bubberstation/code/controllers/subsystem/weather.dm
vuonojenmustaturska 39375d5cc2 Replaces a bunch of mob loops with hopefully better ones (#32786)
* Free codebase churn

* fixes dviewmob

* a commit

* Partial revert "Free codebase churn"

This reverts commit 9dd41b3860c331637bbc85e694dd32dc59768ad5.

* better fix to dviewmob

* renames living_mob_list to alive_mob_list, adds mob_living_list and carbon_list

* make some use out of the shiny carbon list

* make some use out of the shiny new living list

* more things, also make the mobs subsystem (Life) use living list

* bonus

* domo arigato mr. roboto

* compile fixes, also made the drone code less dumb

* better?

* make admin message prettier

* honk

* fixes blobs

* rev fixes

* one small thing
2017-11-16 23:08:40 +01:00

46 lines
1.5 KiB
Plaintext

//Used for all kinds of weather, ex. lavaland ash storms.
SUBSYSTEM_DEF(weather)
name = "Weather"
flags = SS_BACKGROUND
wait = 10
runlevels = RUNLEVEL_GAME
var/list/processing = list()
var/list/existing_weather = list()
var/list/eligible_zlevels = list(ZLEVEL_LAVALAND)
/datum/controller/subsystem/weather/fire()
for(var/V in processing)
var/datum/weather/W = V
if(W.aesthetic)
continue
for(var/i in GLOB.mob_living_list)
var/mob/living/L = i
if(W.can_weather_act(L))
W.weather_act(L)
for(var/Z in eligible_zlevels)
var/list/possible_weather_for_this_z = list()
for(var/V in existing_weather)
var/datum/weather/WE = V
if(WE.target_z == Z && WE.probability) //Another check so that it doesn't run extra weather
possible_weather_for_this_z[WE] = WE.probability
var/datum/weather/W = pickweight(possible_weather_for_this_z)
run_weather(W.name, Z)
eligible_zlevels -= Z
addtimer(CALLBACK(src, .proc/make_z_eligible, Z), rand(3000, 6000) + W.weather_duration_upper, TIMER_UNIQUE) //Around 5-10 minutes between weathers
/datum/controller/subsystem/weather/Initialize(start_timeofday)
..()
for(var/V in subtypesof(/datum/weather))
new V //Weather's New() will handle adding stuff to the list
/datum/controller/subsystem/weather/proc/run_weather(weather_name, Z)
if(!weather_name)
return
for(var/V in existing_weather)
var/datum/weather/W = V
if(W.name == weather_name && W.target_z == Z)
W.telegraph()
/datum/controller/subsystem/weather/proc/make_z_eligible(zlevel)
eligible_zlevels |= zlevel