From 42da9918d757669b7eb5d7ea8609d7990c5ab4ba Mon Sep 17 00:00:00 2001 From: AffectedArc07 Date: Sat, 11 Apr 2020 22:46:09 +0100 Subject: [PATCH] Makes solars auto-track again (#13278) * Makes solars auto-track again * Forgot this --- code/__DEFINES/subsystems.dm | 1 + code/controllers/subsystem/sun.dm | 13 +++++++++++-- code/modules/power/solar.dm | 10 ++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm index 300d3a41fc0..b1773ba10d5 100644 --- a/code/__DEFINES/subsystems.dm +++ b/code/__DEFINES/subsystems.dm @@ -66,6 +66,7 @@ #define INIT_ORDER_TIMER 1 #define INIT_ORDER_DEFAULT 0 #define INIT_ORDER_AIR -1 +#define INIT_ORDER_SUN -2 #define INIT_ORDER_MINIMAP -3 #define INIT_ORDER_ASSETS -4 #define INIT_ORDER_ICON_SMOOTHING -5 diff --git a/code/controllers/subsystem/sun.dm b/code/controllers/subsystem/sun.dm index 6cfb52f2d25..b9843c57b68 100644 --- a/code/controllers/subsystem/sun.dm +++ b/code/controllers/subsystem/sun.dm @@ -1,19 +1,28 @@ SUBSYSTEM_DEF(sun) name = "Sun" wait = 600 - flags = SS_NO_TICK_CHECK|SS_NO_INIT + flags = SS_NO_TICK_CHECK + init_order = INIT_ORDER_SUN var/angle var/dx var/dy var/rate var/list/solars = list() -/datum/controller/subsystem/sun/PreInit() +/datum/controller/subsystem/sun/Initialize(start_timeofday) + // Lets work out an angle for the "sun" to rotate around the station angle = rand (0,360) // the station position to the sun is randomised at round start rate = rand(50,200)/100 // 50% - 200% of standard rotation if(prob(50)) // same chance to rotate clockwise than counter-clockwise rate = -rate + // Solar consoles need to load after machines init, so this handles that + for(var/obj/machinery/power/solar_control/SC in solars) + SC.setup() + + return ..() + + /datum/controller/subsystem/sun/stat_entry(msg) ..("P:[solars.len]") diff --git a/code/modules/power/solar.dm b/code/modules/power/solar.dm index 945cc286b31..d99df1de7bb 100644 --- a/code/modules/power/solar.dm +++ b/code/modules/power/solar.dm @@ -285,13 +285,15 @@ autostart = 1 // Automatically start /obj/machinery/power/solar_control/Initialize() - ..() - if(!powernet) - return + SSsun.solars |= src + setup() + . = ..() + +/obj/machinery/power/solar_control/proc/setup() connect_to_network() set_panels(cdir) if(autostart) - src.search_for_connected() + search_for_connected() if(connected_tracker && track == 2) connected_tracker.set_angle(SSsun.angle) set_panels(cdir)