Files
fulpstation/code/controllers/subsystem/sun.dm
MrPerson e8ba7a1f68 Solar improvements (#48110)
Improves the code for the solar panels a lot. It's still pretty bad but to make it better I'd have to dive into powernets.

Solar panels visually rotate a full 360 degrees instead of being locked to ordinal directions only. In 513 this uses vis_contents, in 512 it uses a regular overlay that needs to be reset constantly.
Adds a signal from the sun SS when the sun moves.
Timed tracking is now measured in degrees per minute instead of degrees per hour.
2019-12-09 13:47:57 -05:00

33 lines
937 B
Plaintext

SUBSYSTEM_DEF(sun)
name = "Sun"
wait = 1 MINUTES
flags = SS_NO_TICK_CHECK
var/azimuth = 0 ///clockwise, top-down rotation from 0 (north) to 359
var/azimuth_mod = 1 ///multiplier against base_rotation
var/base_rotation = 6 ///base rotation in degrees per fire
/datum/controller/subsystem/sun/Initialize(start_timeofday)
azimuth = rand(0, 359)
azimuth_mod = round(rand(50, 200)/100, 0.01) // 50% - 200% of standard rotation
if(prob(50))
azimuth_mod *= -1
return ..()
/datum/controller/subsystem/sun/fire(resumed = FALSE)
azimuth += azimuth_mod * base_rotation
azimuth = round(azimuth, 0.01)
if(azimuth >= 360)
azimuth -= 360
if(azimuth < 0)
azimuth += 360
complete_movement()
/datum/controller/subsystem/sun/proc/complete_movement()
SEND_SIGNAL(src, COMSIG_SUN_MOVED, azimuth)
/datum/controller/subsystem/sun/vv_edit_var(var_name, var_value)
. = ..()
if(var_name == NAMEOF(src, azimuth))
complete_movement()