/** * Main and only Acedia mutator used for loading Acedia packages * and providing access to mutator events' calls. * Copyright 2020 Anton Tarasenko *------------------------------------------------------------------------------ * This file is part of Acedia. * * Acedia is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License, or * (at your option) any later version. * * Acedia is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Acedia. If not, see . */ class Acedia extends Mutator config(Acedia); // Default value of this variable will be used to store // reference to the active Acedia mutator, // as well as to ensure there's only one copy of it. // We can't use 'Singleton' class for that, // as we have to derive from 'Mutator'. var private Acedia selfReference; // Array of predefined services that must be started along with Acedia mutator. var private config array< class > registeredManifests; // Array of predefined services that must be started along with Acedia mutator. var private array< class > systemServices; static public final function Acedia GetInstance() { return default.selfReference; } event PreBeginPlay() { // Enforce one copy rule and remember a reference to that copy if (default.selfReference != none) { Destroy(); return; } default.selfReference = self; BootUp(); if (class'TestingService'.default.runTestsOnStartUp) { RunStartUpTests(); } } private final function BootUp() { local int i; Spawn(class'Global'); for (i = 0; i < registeredManifests.length; i += 1) { LoadManifest(registeredManifests[i]); } InjectBroadcastHandler(); // TODO: move this to 'SideEffect' mechanic } private final function RunStartUpTests() { local TestingService testService; testService = TestingService(class'TestingService'.static.Require()); testService.PrepareTests(); if (testService.filterTestsByName) { testService.FilterByName(testService.requiredName); } if (testService.filterTestsByGroup) { testService.FilterByName(testService.requiredGroup); } testService.Run(); } private final function LoadManifest(class manifestClass) { local int i; // Load alias sources for (i = 0; i < manifestClass.default.aliasSources.length; i += 1) { if (manifestClass.default.aliasSources[i] == none) continue; Spawn(manifestClass.default.aliasSources[i]); } // Enable features for (i = 0; i < manifestClass.default.features.length; i += 1) { if (manifestClass.default.features[i] == none) continue; if (manifestClass.default.features[i].static.IsAutoEnabled()) { manifestClass.default.features[i].static.EnableMe(); } } // Load tests cases for (i = 0; i < manifestClass.default.testCases.length; i += 1) { class'TestingService'.static .RegisterTestCase(manifestClass.default.testCases[i]); } } private final function InjectBroadcastHandler() { local BroadcastHandler ourBroadcastHandler; if (level == none || level.game == none) return; ourBroadcastHandler = Spawn(class'BroadcastHandler'); // Swap out level's first handler with ours // (needs to be done for both actor reference and it's class) ourBroadcastHandler.nextBroadcastHandler = level.game.broadcastHandler; ourBroadcastHandler.nextBroadcastHandlerClass = level.game.broadcastClass; level.game.broadcastHandler = ourBroadcastHandler; level.game.broadcastClass = class'BroadcastHandler'; } // Acedia is only able to run in a server mode right now, // so this function is just a stub. public final function bool IsServerOnly() { return true; } // Provide a way to handle CheckReplacement event function bool CheckReplacement(Actor other, out byte isSuperRelevant) { return class'MutatorEvents'.static. CallCheckReplacement(other, isSuperRelevant); } function Mutate(string command, PlayerController sendingController) { if (class'MutatorEvents'.static.CallMutate(command, sendingController)) { super.Mutate(command, sendingController); } } defaultproperties { // Add Acedia's own manifest registeredManifests(0) = class'Manifest' // This is a server-only mutator remoteRole = ROLE_None bAlwaysRelevant = true // Mutator description GroupName = "Core mutator" FriendlyName = "Acedia" Description = "Launcher for Acedia modules" }