Browse Source

Change to account for AcediaCore's refactor

feature_improvement
Anton Tarasenko 2 years ago
parent
commit
c1ba704493
  1. 4
      sources/Commands/ACommandFeature.uc
  2. 52
      sources/Futility_Feature.uc

4
sources/Commands/ACommandFeature.uc

@ -224,10 +224,8 @@ protected function class<Feature> LoadFeatureClass(BaseText featureName)
protected function ShowAllFeatures() protected function ShowAllFeatures()
{ {
local int i; local int i;
local CoreService service;
local array< class<Feature> > availableFeatures; local array< class<Feature> > availableFeatures;
service = CoreService(class'CoreService'.static.Require()); availableFeatures = _.environment.GetAvailableFeatures();
availableFeatures = service.GetAvailableFeatures();
for (i = 0; i < availableFeatures.length; i ++) { for (i = 0; i < availableFeatures.length; i ++) {
ShowFeature(availableFeatures[i]); ShowFeature(availableFeatures[i]);
} }

52
sources/Futility_Feature.uc

@ -20,44 +20,62 @@
*/ */
class Futility_Feature extends Feature; class Futility_Feature extends Feature;
var LoggerAPI.Definition errNoCommandsFeature; var private array< class<Command> > allCommandClasses;
var private LoggerAPI.Definition errNoCommandsFeature;
protected function OnEnabled() protected function OnEnabled()
{ {
local int i;
local Commands_Feature commandsFeature; local Commands_Feature commandsFeature;
commandsFeature = commandsFeature =
Commands_Feature(class'Commands_Feature'.static.GetInstance()); Commands_Feature(class'Commands_Feature'.static.GetEnabledInstance());
if (commandsFeature == none) if (commandsFeature == none)
{ {
_.logger.Auto(errNoCommandsFeature); _.logger.Auto(errNoCommandsFeature);
return; return;
} }
commandsFeature.RegisterCommand(class'ACommandDosh'); for (i = 0; i < allCommandClasses.length; i += 1) {
commandsFeature.RegisterCommand(class'ACommandNick'); commandsFeature.RegisterCommand(allCommandClasses[i]);
commandsFeature.RegisterCommand(class'ACommandTrader'); }
commandsFeature.RegisterCommand(class'ACommandDB'); _.environment.OnFeatureEnabled(self).connect = RegisterAllCommandClasses;
commandsFeature.RegisterCommand(class'ACommandInventory');
commandsFeature.RegisterCommand(class'ACommandFeature');
} }
protected function OnDisabled() protected function OnDisabled()
{ {
local int i;
local Commands_Feature commandsFeature; local Commands_Feature commandsFeature;
commandsFeature = commandsFeature =
Commands_Feature(class'Commands_Feature'.static.GetInstance()); Commands_Feature(class'Commands_Feature'.static.GetEnabledInstance());
if (commandsFeature != none) if (commandsFeature == none) {
{ return;
commandsFeature.RemoveCommand(class'ACommandDosh'); }
commandsFeature.RemoveCommand(class'ACommandNick'); for (i = 0; i < allCommandClasses.length; i += 1) {
commandsFeature.RemoveCommand(class'ACommandTrader'); commandsFeature.RegisterCommand(allCommandClasses[i]);
commandsFeature.RemoveCommand(class'ACommandDB'); }
commandsFeature.RemoveCommand(class'ACommandInventory'); }
commandsFeature.RemoveCommand(class'ACommandFeature');
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 defaultproperties
{ {
configClass = class'Futility' 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.") errNoCommandsFeature = (l=LOG_Error,m="`Commands_Feature` is not detected, \"Futility\" will not be able to provide its functionality.")
} }
Loading…
Cancel
Save