var/datum/planet/sif/planet_sif = null /datum/planet/sif name = "Sif" /datum/planet/sif name = "Sif" desc = "Sif is a terrestrial planet in the Vir system. It is somewhat earth-like, in that it has oceans, a \ breathable atmosphere, a magnetic field, weather, and similar gravity to Earth. It is currently the capital planet of Vir. \ Its center of government is the equatorial city and site of first settlement, New Reykjavik." // Ripped straight from the wiki. current_time = new /datum/time/sif() // 32 hour clocks are nice. expected_z_levels = list(1) // To be changed when real map is finished. /datum/planet/sif/New() ..() weather_holder = new /datum/weather_holder/sif(src) // Cold weather is also nice. // This code is horrible. /datum/planet/sif/update_sun() ..() var/datum/time/time = current_time var/length_of_day = time.seconds_in_day / 10 / 60 / 60 // 32 var/noon = length_of_day / 2 var/distance_from_noon = abs(text2num(time.show_time("hh")) - noon) sun_position = distance_from_noon / noon sun_position = abs(sun_position - 1) var/low_brightness = null var/high_brightness = null var/low_color = null var/high_color = null var/min = 0 switch(sun_position) if(0 to 0.40) // Night low_brightness = 0.2 low_color = "#000066" high_brightness = 0.5 high_color = "#66004D" min = 0 if(0.40 to 0.50) // Twilight low_brightness = 0.6 low_color = "#66004D" high_brightness = 0.8 high_color = "#CC3300" min = 0.40 if(0.50 to 0.70) // Sunrise/set low_brightness = 0.8 low_color = "#CC3300" high_brightness = 0.9 high_color = "#FF9933" min = 0.50 if(0.70 to 1.00) // Noon low_brightness = 0.9 low_color = "#DDDDDD" high_brightness = 1.0 high_color = "#FFFFFF" min = 0.70 var/lerp_weight = (abs(min - sun_position)) * 4 var/weather_light_modifier = 1 if(weather_holder && weather_holder.current_weather) weather_light_modifier = weather_holder.current_weather.light_modifier var/new_brightness = (Interpolate(low_brightness, high_brightness, weight = lerp_weight) ) * weather_light_modifier var/new_color = null if(weather_holder && weather_holder.current_weather && weather_holder.current_weather.light_color) new_color = weather_holder.current_weather.light_color else var/list/low_color_list = hex2rgb(low_color) var/low_r = low_color_list[1] var/low_g = low_color_list[2] var/low_b = low_color_list[3] var/list/high_color_list = hex2rgb(high_color) var/high_r = high_color_list[1] var/high_g = high_color_list[2] var/high_b = high_color_list[3] var/new_r = Interpolate(low_r, high_r, weight = lerp_weight) var/new_g = Interpolate(low_g, high_g, weight = lerp_weight) var/new_b = Interpolate(low_b, high_b, weight = lerp_weight) new_color = rgb(new_r, new_g, new_b) spawn(1) update_sun_deferred(2, new_brightness, new_color) /datum/planet/proc/update_sun_deferred(var/new_range, var/new_brightness, var/new_color) set background = 1 set waitfor = 0 var/i = 0 for(var/turf/simulated/floor/T in outdoor_turfs) T.set_light(new_range, new_brightness, new_color) i++ if(i % 30 == 0) sleep(1)