diff --git a/sources/Commands/ACommandFeature.uc b/sources/Commands/ACommandFeature.uc index fcd240e..15cd55f 100644 --- a/sources/Commands/ACommandFeature.uc +++ b/sources/Commands/ACommandFeature.uc @@ -224,10 +224,8 @@ protected function class LoadFeatureClass(BaseText featureName) protected function ShowAllFeatures() { local int i; - local CoreService service; local array< class > availableFeatures; - service = CoreService(class'CoreService'.static.Require()); - availableFeatures = service.GetAvailableFeatures(); + availableFeatures = _.environment.GetAvailableFeatures(); for (i = 0; i < availableFeatures.length; i ++) { ShowFeature(availableFeatures[i]); } diff --git a/sources/Futility_Feature.uc b/sources/Futility_Feature.uc index 547539b..235063f 100644 --- a/sources/Futility_Feature.uc +++ b/sources/Futility_Feature.uc @@ -20,44 +20,62 @@ */ class Futility_Feature extends Feature; -var LoggerAPI.Definition errNoCommandsFeature; +var private array< class > allCommandClasses; + +var private LoggerAPI.Definition errNoCommandsFeature; protected function OnEnabled() { - local Commands_Feature commandsFeature; + local int i; + local Commands_Feature commandsFeature; commandsFeature = - Commands_Feature(class'Commands_Feature'.static.GetInstance()); + Commands_Feature(class'Commands_Feature'.static.GetEnabledInstance()); if (commandsFeature == none) { _.logger.Auto(errNoCommandsFeature); return; } - commandsFeature.RegisterCommand(class'ACommandDosh'); - commandsFeature.RegisterCommand(class'ACommandNick'); - commandsFeature.RegisterCommand(class'ACommandTrader'); - commandsFeature.RegisterCommand(class'ACommandDB'); - commandsFeature.RegisterCommand(class'ACommandInventory'); - commandsFeature.RegisterCommand(class'ACommandFeature'); + for (i = 0; i < allCommandClasses.length; i += 1) { + commandsFeature.RegisterCommand(allCommandClasses[i]); + } + _.environment.OnFeatureEnabled(self).connect = RegisterAllCommandClasses; } protected function OnDisabled() { - local Commands_Feature commandsFeature; + local int i; + local Commands_Feature commandsFeature; commandsFeature = - Commands_Feature(class'Commands_Feature'.static.GetInstance()); - if (commandsFeature != none) - { - commandsFeature.RemoveCommand(class'ACommandDosh'); - commandsFeature.RemoveCommand(class'ACommandNick'); - commandsFeature.RemoveCommand(class'ACommandTrader'); - commandsFeature.RemoveCommand(class'ACommandDB'); - commandsFeature.RemoveCommand(class'ACommandInventory'); - commandsFeature.RemoveCommand(class'ACommandFeature'); + 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]); } } 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' errNoCommandsFeature = (l=LOG_Error,m="`Commands_Feature` is not detected, \"Futility\" will not be able to provide its functionality.") } \ No newline at end of file