mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-29 16:18:01 +01:00
Introduces particle weather, converts rain and ash storms to it (#96297)
Co-authored-by: Lucy <lucy@absolucy.moe>
This commit is contained in:
@@ -8,13 +8,26 @@ SUBSYSTEM_DEF(weather)
|
||||
wait = 10
|
||||
runlevels = RUNLEVEL_GAME
|
||||
var/list/processing = list()
|
||||
/// Z levels on which weather can occur -> weather that can occur -> probability of said weather occuring
|
||||
var/list/eligible_zlevels = list()
|
||||
var/list/next_hit_by_zlevel = list() //Used by barometers to know when the next storm is coming
|
||||
/// Used by barometers to know when the next storm is coming
|
||||
var/list/next_hit_by_zlevel = list()
|
||||
/// Alist of all particle holders per Z-stack offset for particle weather to be shown to clients
|
||||
var/alist/particle_holders = alist()
|
||||
/// List of all RENDER_PLANE_PARTICLE_WEATHER and RENDER_PLANE_EMISSIVE_PARTICLE_WEATHER planes
|
||||
var/list/particle_planemasters = list()
|
||||
|
||||
/datum/controller/subsystem/weather/fire(resumed = FALSE)
|
||||
// process active weather
|
||||
for(var/datum/weather/weather_event as anything in processing)
|
||||
if(!length(weather_event.subsystem_tasks) || weather_event.stage != MAIN_STAGE)
|
||||
if(!length(weather_event.subsystem_tasks))
|
||||
continue
|
||||
|
||||
if(istype(weather_event, /datum/weather/particle))
|
||||
var/datum/weather/particle/particle_event = weather_event
|
||||
particle_event.process_particles()
|
||||
|
||||
if(weather_event.stage != MAIN_STAGE)
|
||||
continue
|
||||
|
||||
if(weather_event.subsystem_tasks[weather_event.task_index] == SSWEATHER_MOBS)
|
||||
@@ -69,21 +82,42 @@ SUBSYSTEM_DEF(weather)
|
||||
next_hit_by_zlevel["[z]"] = addtimer(CALLBACK(src, PROC_REF(make_eligible), z, possible_weather), randTime + initial(weather_event.weather_duration_upper), TIMER_UNIQUE|TIMER_STOPPABLE)
|
||||
|
||||
/datum/controller/subsystem/weather/Initialize()
|
||||
for(var/V in subtypesof(/datum/weather))
|
||||
var/datum/weather/W = V
|
||||
var/probability = initial(W.probability)
|
||||
var/target_trait = initial(W.target_trait)
|
||||
for(var/datum/weather/weather as anything in valid_subtypesof(/datum/weather))
|
||||
var/probability = initial(weather.probability)
|
||||
var/target_trait = initial(weather.target_trait)
|
||||
|
||||
// any weather with a probability set may occur at random
|
||||
if (probability)
|
||||
for(var/z in SSmapping.levels_by_trait(target_trait))
|
||||
LAZYINITLIST(eligible_zlevels["[z]"])
|
||||
eligible_zlevels["[z]"][W] = probability
|
||||
eligible_zlevels["[z]"][weather] = probability
|
||||
return SS_INIT_SUCCESS
|
||||
|
||||
/datum/controller/subsystem/weather/proc/add_weather_objects(list/new_holders, z_level)
|
||||
for (var/offset in 1 to length(new_holders))
|
||||
var/list/holder_list = new_holders[offset]
|
||||
if (isnull(particle_holders[offset]))
|
||||
particle_holders[offset] = list()
|
||||
particle_holders[offset] += holder_list
|
||||
|
||||
// We add it to vis_contents of planemasters rather than client screen as planemasters already
|
||||
// manage their own visibility based on owner's z level
|
||||
for (var/atom/movable/screen/plane_master/plane_master as anything in particle_planemasters)
|
||||
for (var/obj/effect/abstract/weather_holder/holder as anything in holder_list)
|
||||
if (holder.plane == plane_master.plane)
|
||||
plane_master.vis_contents |= holder
|
||||
|
||||
/datum/controller/subsystem/weather/proc/remove_weather_objects(list/old_holders)
|
||||
for (var/offset in 1 to length(old_holders))
|
||||
var/list/holder_list = old_holders[offset]
|
||||
particle_holders[offset] -= holder_list
|
||||
|
||||
for (var/atom/movable/screen/plane_master/plane_master as anything in particle_planemasters)
|
||||
plane_master.vis_contents -= holder_list
|
||||
|
||||
/datum/controller/subsystem/weather/proc/update_z_level(datum/space_level/level)
|
||||
var/z = level.z_value
|
||||
for(var/datum/weather/weather as anything in subtypesof(/datum/weather))
|
||||
for(var/datum/weather/weather as anything in valid_subtypesof(/datum/weather))
|
||||
var/probability = initial(weather.probability)
|
||||
var/target_trait = initial(weather.target_trait)
|
||||
if(probability && level.traits[target_trait])
|
||||
@@ -92,10 +126,9 @@ SUBSYSTEM_DEF(weather)
|
||||
|
||||
/datum/controller/subsystem/weather/proc/run_weather(datum/weather/weather_datum_type, z_levels, list/weather_data)
|
||||
if (istext(weather_datum_type))
|
||||
for (var/V in subtypesof(/datum/weather))
|
||||
var/datum/weather/W = V
|
||||
if (initial(W.name) == weather_datum_type)
|
||||
weather_datum_type = V
|
||||
for (var/datum/weather/weather as anything in valid_subtypesof(/datum/weather))
|
||||
if (initial(weather.name) == weather_datum_type)
|
||||
weather_datum_type = weather
|
||||
break
|
||||
if (!ispath(weather_datum_type, /datum/weather))
|
||||
CRASH("run_weather called with invalid weather_datum_type: [weather_datum_type || "null"]")
|
||||
@@ -107,10 +140,9 @@ SUBSYSTEM_DEF(weather)
|
||||
else if (!islist(z_levels))
|
||||
CRASH("run_weather called with invalid z_levels: [z_levels || "null"]")
|
||||
|
||||
|
||||
var/datum/weather/W = new weather_datum_type(z_levels, weather_data)
|
||||
W.telegraph(weather_data)
|
||||
return W
|
||||
var/datum/weather/weather = new weather_datum_type(z_levels, weather_data)
|
||||
weather.telegraph(weather_data)
|
||||
return weather
|
||||
|
||||
/datum/controller/subsystem/weather/proc/make_eligible(z, possible_weather)
|
||||
eligible_zlevels[z] = possible_weather
|
||||
|
||||
Reference in New Issue
Block a user