Files
Will 4dd9a19c01 Cryogenic planet controller and station boiler upport (#19452)
* boiler basics

* more stuff

* tgui ported

* more cleanup

* more framework

* lets get this settled

* oops

* disabled regularly

* subsystem tweaks

* clean up spans

* name oopsie

* optimize

* you too

* actually optimize that

* linting

* much better optimization

* clean that too

* optimizing

* runtime on stack insertion

* more cleanup

* material handling fix

* pluralized

* oops

* clean that up

* tgui cleanup

* these should just be structures, tgui rework

* some tweaks

* small runtime caught

* polishing

* cleanup

* last tweak

* fixed burn calculation

* Keeeeeeeeeellllllllllll

* scroll fix

* move to proc

* requested changes

* optimization

* buh

* Well that didn't work

* clear those refs

* back to flags

---------

Co-authored-by: Cameron Lennox <killer65311@gmail.com>
Co-authored-by: Selis <12716288+ItsSelis@users.noreply.github.com>
2026-05-18 01:08:54 +02:00

75 lines
2.9 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/datum/sun_holder/sun_holder
var/sun_position = 0 // 0 means midnight, 1 means noon.
var/list/sun = list("brightness","color")
var/list/expected_z_levels = list()
var/turf/unsimulated/wall/planetary/planetary_wall_type = /turf/unsimulated/wall/planetary
var/list/turf/simulated/floor/planet_floors = list()
var/list/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.
var/sun_name = "the sun" // For flavor.
var/moon_name = null // Purely for flavor. Null means no moon exists.
var/moon_phase = null // Set if above is defined.
var/cryogenic_temp_shift = FALSE // If true, ALL areas that are not AREA_CRYOPLANET_SHIELDED will be brought toward the current weather's temperature. Causing indoor station areas to slowly match the planet's environment.
/datum/planet/New()
..()
weather_holder = new(src)
sun_holder = new(src)
current_time = current_time.make_random_time()
if(moon_name)
moon_phase = pick(list(
MOON_PHASE_NEW_MOON,
MOON_PHASE_WAXING_CRESCENT,
MOON_PHASE_FIRST_QUARTER,
MOON_PHASE_WAXING_GIBBOUS,
MOON_PHASE_FULL_MOON,
MOON_PHASE_WANING_GIBBOUS,
MOON_PHASE_LAST_QUARTER,
MOON_PHASE_WANING_CRESCENT
))
update_sun()
/datum/planet/process(last_fire)
if(current_time)
var/difference = world.time - last_fire
current_time = current_time.add_seconds((difference / 10) * PLANET_TIME_MODIFIER)
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(new_brightness, new_color)
sun["brightness"] = CLAMP01(new_brightness)
sun["color"] = new_color
needs_work |= PLANET_PROCESS_SUN
/// Override for unique sun angle handling for stuff like northern/southern hemisphere sun angles during the day cycle
/datum/planet/proc/get_sun_solar_position()
return 220 - (sun_position * 80) // this base version doesn't know how long a planet's day is, so just goes back and forth facing south-eastish based on midnight to noon intensity