mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Controller with deferrals and SCHECKs to be specific. Won't lag while updating the sun, weather, or temperature. Also moved some vars around. Namely the planet walls are stored on the planet, not in the weather_holder. Planets now have their own turfs, the controller 'gives' them to the planets each cycle if there are any unallocated turfs in the global lists, to avoid iterating over other planets' turfs if you have more than one, then cuts the lists if you were crazy and some turf added some invalid type. This saves us type-checking in the for() loops later to make them crunch faster. The former operation should only happen once at the start of the game (and maybe very rarely when turfs are added/removed from a map during the game). With regards to the temperature updates, rebuilding the zone entirely is an intensive operation. Instead we can use this new cheaty proc to do it from over here. ZAS code outside ZAS oh noooo. Well, the option is to snowflake this case into ZAS which is maybe worse? Only downside to all this is that if you manually set weather and time it might take between 1-60 seconds for the controller to get around to checking if you wanted to update it. That's not that big a deal. If you really want you can now debug that controller and call doWork on it.
53 lines
1.8 KiB
Plaintext
53 lines
1.8 KiB
Plaintext
// This holds information about a specific 'planetside' area, such as its time, weather, etc. This will most likely be used to model Sif,
|
|
// but away missions may also have use for this.
|
|
|
|
/datum/planet
|
|
var/name = "a rock"
|
|
var/desc = "Someone neglected to write a nice description for this poor rock."
|
|
|
|
var/datum/time/current_time = new() // Holds the current time for sun positioning. Note that we assume day and night is the same length because simplicity.
|
|
var/sun_process_interval = 1 HOUR
|
|
var/sun_last_process = null // world.time
|
|
|
|
var/datum/weather_holder/weather_holder
|
|
|
|
var/sun_position = 0 // 0 means midnight, 1 means noon.
|
|
var/list/sun = list("range","brightness","color")
|
|
var/expected_z_levels = list()
|
|
|
|
var/turf/unsimulated/wall/planetary/planetary_wall_type = /turf/unsimulated/wall/planetary
|
|
|
|
var/turf/simulated/floor/planet_floors = list()
|
|
var/turf/unsimulated/wall/planetary/planet_walls = list()
|
|
|
|
|
|
var/needs_work = 0 // Bitflags to signal to the planet controller these need (properly deferrable) work. Flags defined in controller.
|
|
|
|
/datum/planet/New()
|
|
..()
|
|
weather_holder = new(src)
|
|
current_time = current_time.make_random_time()
|
|
update_sun()
|
|
|
|
/datum/planet/proc/process(amount)
|
|
if(current_time)
|
|
current_time = current_time.add_seconds(amount)
|
|
update_weather() // We update this first, because some weather types decease the brightness of the sun.
|
|
if(sun_last_process <= world.time - sun_process_interval)
|
|
update_sun()
|
|
|
|
// This changes the position of the sun on the planet.
|
|
/datum/planet/proc/update_sun()
|
|
sun_last_process = world.time
|
|
|
|
/datum/planet/proc/update_weather()
|
|
if(weather_holder)
|
|
weather_holder.process()
|
|
|
|
/datum/planet/proc/update_sun_deferred(var/new_range, var/new_brightness, var/new_color)
|
|
sun["range"] = new_range
|
|
sun["brightness"] = new_brightness
|
|
sun["color"] = new_color
|
|
needs_work |= PLANET_PROCESS_SUN
|
|
|