mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
# Conflicts: # code/_onclick/hud/screen_objects.dm # code/game/objects/items/weapons/storage/storage.dm # code/game/objects/structures/crates_lockers/closets/secure/medical.dm # code/modules/admin/admin_verbs.dm # code/modules/clothing/clothing.dm # code/modules/clothing/gloves/color.dm # code/modules/lore_codex/codex.dm # code/modules/mob/living/simple_animal/aliens/alien.dm # code/modules/mob/living/simple_animal/animals/cat.dm # code/modules/mob/living/simple_animal/animals/goose.dm # code/modules/mob/living/simple_animal/simple_animal.dm # code/modules/mob/mob_defines.dm # code/modules/projectiles/projectile/special.dm # html/changelogs/.all_changelog.yml # maps/southern_cross/southern_cross-1.dmm # maps/southern_cross/southern_cross-7.dmm # vorestation.dme
68 lines
2.5 KiB
Plaintext
68 lines
2.5 KiB
Plaintext
/datum/weather_holder
|
|
var/datum/planet/our_planet = null
|
|
var/datum/weather/current_weather = null
|
|
var/temperature = T20C
|
|
var/wind_dir = 0
|
|
var/wind_speed = 0
|
|
var/list/allowed_weather_types = list()
|
|
var/list/roundstart_weather_chances = list()
|
|
var/next_weather_shift = null
|
|
|
|
/datum/weather_holder/New(var/source)
|
|
..()
|
|
our_planet = source
|
|
for(var/A in allowed_weather_types)
|
|
var/datum/weather/W = allowed_weather_types[A]
|
|
if(istype(W))
|
|
W.holder = src
|
|
|
|
/datum/weather_holder/proc/change_weather(var/new_weather)
|
|
var/old_light_modifier = null
|
|
if(current_weather)
|
|
old_light_modifier = current_weather.light_modifier // We store the old one, so we can determine if recalculating the sun is needed.
|
|
current_weather = allowed_weather_types[new_weather]
|
|
next_weather_shift = world.time + rand(20, 30) MINUTES
|
|
|
|
update_icon_effects()
|
|
update_temperature()
|
|
if(old_light_modifier && current_weather.light_modifier != old_light_modifier) // Updating the sun should be done sparingly.
|
|
our_planet.update_sun()
|
|
//message_admins("[our_planet.name]'s weather is now [new_weather], with a temperature of [temperature]°K ([temperature - T0C]°C | [temperature * 1.8 - 459.67]°F).") //VOREStation Removal - I like weather, I just don't like hearing about it.
|
|
|
|
/datum/weather_holder/proc/process()
|
|
if(world.time >= next_weather_shift)
|
|
var/new_weather
|
|
if(!current_weather)
|
|
new_weather = pickweight(roundstart_weather_chances)
|
|
else
|
|
new_weather = pickweight(current_weather.transition_chances)
|
|
change_weather(new_weather)
|
|
else
|
|
current_weather.process_effects()
|
|
|
|
/datum/weather_holder/proc/update_icon_effects()
|
|
our_planet.needs_work |= PLANET_PROCESS_WEATHER
|
|
|
|
/datum/weather_holder/proc/update_temperature()
|
|
temperature = Interpolate(current_weather.temp_low, current_weather.temp_high, weight = our_planet.sun_position)
|
|
our_planet.needs_work |= PLANET_PROCESS_TEMP
|
|
|
|
/datum/weather_holder/proc/get_weather_datum(desired_type)
|
|
return allowed_weather_types[desired_type]
|
|
|
|
|
|
/datum/weather
|
|
var/name = "weather base"
|
|
var/icon = 'icons/effects/weather.dmi'
|
|
var/icon_state = null // Icon to apply to turf undergoing weather.
|
|
var/temp_high = T20C
|
|
var/temp_low = T0C
|
|
var/light_modifier = 1.0 // Lower numbers means more darkness.
|
|
var/light_color = null // If set, changes how the day/night light looks.
|
|
var/flight_failure_modifier = 0 // Some types of weather make flying harder, and therefore make crashes more likely.
|
|
var/transition_chances = list() // Assoc list
|
|
var/datum/weather_holder/holder = null
|
|
|
|
/datum/weather/proc/process_effects()
|
|
return
|