Administration tools: commands and non gameplay server configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.9 KiB

3 years ago
/**
* This is the Futility feature, whose main purpose is to register commands
3 years ago
* from its package.
* Copyright 2021 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Futility.
3 years ago
*
* Futility is free software: you can redistribute it and/or modify
3 years ago
* 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.
*
* Futility is distributed in the hope that it will be useful,
3 years ago
* 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 Futility. If not, see <https://www.gnu.org/licenses/>.
3 years ago
*/
class Futility_Feature extends Feature;
3 years ago
var private array< class<Command> > allCommandClasses;
var private LoggerAPI.Definition errNoCommandsFeature;
3 years ago
protected function OnEnabled()
{
local int i;
local Commands_Feature commandsFeature;
3 years ago
commandsFeature =
Commands_Feature(class'Commands_Feature'.static.GetEnabledInstance());
3 years ago
if (commandsFeature == none)
{
_.logger.Auto(errNoCommandsFeature);
return;
}
for (i = 0; i < allCommandClasses.length; i += 1) {
commandsFeature.RegisterCommand(allCommandClasses[i]);
}
_.environment.OnFeatureEnabled(self).connect = RegisterAllCommandClasses;
3 years ago
}
protected function OnDisabled()
{
local int i;
local Commands_Feature commandsFeature;
_.environment.OnFeatureEnabled(self).Disconnect();
3 years ago
commandsFeature =
Commands_Feature(class'Commands_Feature'.static.GetEnabledInstance());
if (commandsFeature == none) {
return;
}
for (i = 0; i < allCommandClasses.length; i += 1) {
commandsFeature.RegisterCommand(allCommandClasses[i]);
}
}
private final function RegisterAllCommandClasses(Feature enabledFeature)
{
local int i;
local Commands_Feature commandsFeature;
commandsFeature = Commands_Feature(enabledFeature);
if (commandsFeature == none) {
return;
}
for (i = 0; i < allCommandClasses.length; i += 1) {
commandsFeature.RegisterCommand(allCommandClasses[i]);
3 years ago
}
}
defaultproperties
{
configClass = class'Futility'
allCommandClasses(0) = class'ACommandDosh'
allCommandClasses(1) = class'ACommandNick'
allCommandClasses(2) = class'ACommandTrader'
allCommandClasses(3) = class'ACommandDB'
allCommandClasses(4) = class'ACommandInventory'
allCommandClasses(5) = class'ACommandFeature'
2 years ago
allCommandClasses(6) = class'ACommandGod'
errNoCommandsFeature = (l=LOG_Error,m="`Commands_Feature` is not detected, \"Futility\" will not be able to provide its functionality.")
3 years ago
}