From 676efe73e5b5403b8e71dd3d6512cb29cdfeb40e Mon Sep 17 00:00:00 2001 From: Leshana Date: Mon, 5 Feb 2018 13:56:50 -0500 Subject: [PATCH] Move Xenoarcheology globals and initialization into a subsystem * Move the global spawning_turfs lists from master_controller into SSxenoarch. Rename all references. * Move the call to SetupXenoarch from master_controller.setup() to SSxenoarch.Initialize() Put SSxenoarch init order near the end to match current behavior. --- code/__defines/subsystems.dm | 1 + code/controllers/master_controller.dm | 2 +- .../subsystems/xenoarch.dm} | 31 ++++++++++++++++--- code/modules/xenoarcheaology/sampling.dm | 6 ++-- code/modules/xenoarcheaology/tools/tools.dm | 10 +++--- polaris.dme | 2 +- 6 files changed, 37 insertions(+), 15 deletions(-) rename code/{modules/xenoarcheaology/master_controller.dm => controllers/subsystems/xenoarch.dm} (79%) diff --git a/code/__defines/subsystems.dm b/code/__defines/subsystems.dm index f300ba14fd..faddb9d917 100644 --- a/code/__defines/subsystems.dm +++ b/code/__defines/subsystems.dm @@ -29,3 +29,4 @@ var/global/list/runlevel_flags = list(RUNLEVEL_LOBBY, RUNLEVEL_SETUP, RUNLEVEL_G #define INIT_ORDER_SHUTTLES 3 #define INIT_ORDER_LIGHTING 0 #define INIT_ORDER_AIR -1 +#define INIT_ORDER_XENOARCH -20 diff --git a/code/controllers/master_controller.dm b/code/controllers/master_controller.dm index 2a0ae27d6d..98ca642c82 100644 --- a/code/controllers/master_controller.dm +++ b/code/controllers/master_controller.dm @@ -37,7 +37,7 @@ datum/controller/game_controller/proc/setup() setup_objects() // setupgenetics() Moved to SSatoms - SetupXenoarch() + // SetupXenoarch() - Moved to SSxenoarch transfer_controller = new admin_notice("Initializations complete.", R_DEBUG) diff --git a/code/modules/xenoarcheaology/master_controller.dm b/code/controllers/subsystems/xenoarch.dm similarity index 79% rename from code/modules/xenoarcheaology/master_controller.dm rename to code/controllers/subsystems/xenoarch.dm index a6689e36b6..eb6c97ea75 100644 --- a/code/modules/xenoarcheaology/master_controller.dm +++ b/code/controllers/subsystems/xenoarch.dm @@ -1,14 +1,35 @@ -/datum/controller/game_controller - var/list/artifact_spawning_turfs = list() - var/list/digsite_spawning_turfs = list() - #define XENOARCH_SPAWN_CHANCE 0.5 #define DIGSITESIZE_LOWER 4 #define DIGSITESIZE_UPPER 12 #define ARTIFACTSPAWNNUM_LOWER 6 #define ARTIFACTSPAWNNUM_UPPER 12 -/datum/controller/game_controller/proc/SetupXenoarch() +// +// Xenoarch subsystem handles initialization of Xenoarcheaology artifacts and digsites. +// +SUBSYSTEM_DEF(xenoarch) + name = "Xenoarch" + init_order = INIT_ORDER_XENOARCH + flags = SS_NO_FIRE + var/list/artifact_spawning_turfs = list() + var/list/digsite_spawning_turfs = list() + +/datum/controller/subsystem/xenoarch/Initialize(timeofday) + SetupXenoarch() + ..() + +/datum/controller/subsystem/xenoarch/Recover() + if (istype(SSxenoarch.artifact_spawning_turfs)) + artifact_spawning_turfs = SSxenoarch.artifact_spawning_turfs + if (istype(SSxenoarch.digsite_spawning_turfs)) + digsite_spawning_turfs = SSxenoarch.digsite_spawning_turfs + +/datum/controller/subsystem/xenoarch/stat_entry(msg) + if (!Debug2) + return // Only show up in stat panel if debugging is enabled. + . = ..() + +/datum/controller/subsystem/xenoarch/proc/SetupXenoarch() for(var/turf/simulated/mineral/M in world) if(!M.density) continue diff --git a/code/modules/xenoarcheaology/sampling.dm b/code/modules/xenoarcheaology/sampling.dm index e79957ba28..ae7c203fa3 100644 --- a/code/modules/xenoarcheaology/sampling.dm +++ b/code/modules/xenoarcheaology/sampling.dm @@ -70,15 +70,15 @@ artifact_distance = rand() artifact_id = container.artifact_find.artifact_id else - if(master_controller) //Sanity check due to runtimes ~Z - for(var/turf/simulated/mineral/T in master_controller.artifact_spawning_turfs) + if(SSxenoarch) //Sanity check due to runtimes ~Z + for(var/turf/simulated/mineral/T in SSxenoarch.artifact_spawning_turfs) if(T.artifact_find) var/cur_dist = get_dist(container, T) * 2 if( (artifact_distance < 0 || cur_dist < artifact_distance)) artifact_distance = cur_dist + rand() * 2 - 1 artifact_id = T.artifact_find.artifact_id else - master_controller.artifact_spawning_turfs.Remove(T) + SSxenoarch.artifact_spawning_turfs.Remove(T) /obj/item/device/core_sampler name = "core sampler" diff --git a/code/modules/xenoarcheaology/tools/tools.dm b/code/modules/xenoarcheaology/tools/tools.dm index 1d79a89449..17412b4a8b 100644 --- a/code/modules/xenoarcheaology/tools/tools.dm +++ b/code/modules/xenoarcheaology/tools/tools.dm @@ -57,8 +57,8 @@ var/nearestSimpleTargetDist = -1 var/turf/cur_turf = get_turf(src) - if(master_controller) //Sanity check due to runtimes ~Z - for(var/A in master_controller.artifact_spawning_turfs) + if(SSxenoarch) //Sanity check due to runtimes ~Z + for(var/A in SSxenoarch.artifact_spawning_turfs) var/turf/simulated/mineral/T = A if(T.density && T.artifact_find) if(T.z == cur_turf.z) @@ -67,9 +67,9 @@ nearestTargetDist = cur_dist + rand() * 2 - 1 nearestTargetId = T.artifact_find.artifact_id else - master_controller.artifact_spawning_turfs.Remove(T) + SSxenoarch.artifact_spawning_turfs.Remove(T) - for(var/A in master_controller.digsite_spawning_turfs) + for(var/A in SSxenoarch.digsite_spawning_turfs) var/turf/simulated/mineral/T = A if(T.density && T.finds && T.finds.len) if(T.z == cur_turf.z) @@ -77,7 +77,7 @@ if(nearestSimpleTargetDist < 0 || cur_dist < nearestSimpleTargetDist) nearestSimpleTargetDist = cur_dist + rand() * 2 - 1 else - master_controller.digsite_spawning_turfs.Remove(T) + SSxenoarch.digsite_spawning_turfs.Remove(T) if(nearestTargetDist >= 0) user << "Exotic energy detected on wavelength '[nearestTargetId]' in a radius of [nearestTargetDist]m[nearestSimpleTargetDist > 0 ? "; small anomaly detected in a radius of [nearestSimpleTargetDist]m" : ""]" diff --git a/polaris.dme b/polaris.dme index d5f489f8be..81502edfc1 100644 --- a/polaris.dme +++ b/polaris.dme @@ -180,6 +180,7 @@ #include "code\controllers\subsystems\machines.dm" #include "code\controllers\subsystems\orbits.dm" #include "code\controllers\subsystems\shuttles.dm" +#include "code\controllers\subsystems\xenoarch.dm" #include "code\datums\ai_law_sets.dm" #include "code\datums\ai_laws.dm" #include "code\datums\beam.dm" @@ -2316,7 +2317,6 @@ #include "code\modules\xenoarcheaology\boulder.dm" #include "code\modules\xenoarcheaology\effect.dm" #include "code\modules\xenoarcheaology\manuals.dm" -#include "code\modules\xenoarcheaology\master_controller.dm" #include "code\modules\xenoarcheaology\misc.dm" #include "code\modules\xenoarcheaology\sampling.dm" #include "code\modules\xenoarcheaology\artifacts\artifact.dm"