use of org.terasology.engine.module.ModuleManager in project Terasology by MovingBlocks.
the class RegisterSystems method step.
@Override
public boolean step() {
componentSystemManager = context.get(ComponentSystemManager.class);
ModuleManager moduleManager = context.get(ModuleManager.class);
TerasologyEngine terasologyEngine = (TerasologyEngine) context.get(GameEngine.class);
for (EngineSubsystem subsystem : terasologyEngine.getSubsystems()) {
subsystem.registerSystems(componentSystemManager);
}
componentSystemManager.loadSystems(moduleManager.getEnvironment(), netMode);
return true;
}
use of org.terasology.engine.module.ModuleManager in project Terasology by MovingBlocks.
the class BindsSubsystem method updateDefaultBinds.
private void updateDefaultBinds(Context passedContext, BindsConfiguration config) {
ModuleManager moduleManager = passedContext.get(ModuleManager.class);
DependencyResolver resolver = new DependencyResolver(moduleManager.getRegistry());
for (Name moduleId : moduleManager.getRegistry().getModuleIds()) {
if (moduleManager.getRegistry().getLatestModuleVersion(moduleId).isCodeModule()) {
ResolutionResult result = resolver.resolve(moduleId);
if (result.isSuccess()) {
try (ModuleEnvironment environment = moduleManager.loadEnvironment(result.getModules(), false)) {
FromModule filter = new FromModule(environment, moduleId);
Iterable<Class<?>> buttons = environment.getTypesAnnotatedWith(RegisterBindButton.class, filter);
Iterable<Class<?>> axes = environment.getTypesAnnotatedWith(RegisterRealBindAxis.class, filter);
addButtonDefaultsFor(moduleId, buttons, config);
addAxisDefaultsFor(moduleId, axes, config);
}
}
}
}
}
use of org.terasology.engine.module.ModuleManager in project Terasology by MovingBlocks.
the class BindsSubsystem method registerBinds.
@Override
public void registerBinds() {
ModuleManager moduleManager = context.get(ModuleManager.class);
ModuleEnvironment environment = moduleManager.getEnvironment();
clearBinds();
registerButtonBinds(environment);
registerAxisBinds(environment);
registerRealAxisBinds(environment);
}
use of org.terasology.engine.module.ModuleManager in project Terasology by MovingBlocks.
the class StateHeadlessSetup method createGameManifest.
public GameManifest createGameManifest() {
GameManifest gameManifest = new GameManifest();
Config config = context.get(Config.class);
ModuleManager moduleManager = context.get(ModuleManager.class);
for (Name moduleName : config.getDefaultModSelection().listModules()) {
Module module = moduleManager.getRegistry().getLatestModuleVersion(moduleName);
if (module != null) {
gameManifest.addModule(module.getId(), module.getVersion());
}
}
WorldGenerationConfig worldGenConfig = config.getWorldGeneration();
// If no valid default world generator set then try to find one - no option to pick one manually in headless
if (!worldGenConfig.getDefaultGenerator().isValid()) {
// find the first gameplay module that is available, it should have a preferred world gen
for (Name moduleName : config.getDefaultModSelection().listModules()) {
Module module = moduleManager.getRegistry().getLatestModuleVersion(moduleName);
if (StandardModuleExtension.isGameplayModule(module)) {
SimpleUri defaultWorldGenerator = StandardModuleExtension.getDefaultWorldGenerator(module);
worldGenConfig.setDefaultGenerator(defaultWorldGenerator);
break;
}
}
}
SimpleUri worldGeneratorUri = worldGenConfig.getDefaultGenerator();
gameManifest.setTitle(worldGenConfig.getWorldTitle());
gameManifest.setSeed(worldGenConfig.getDefaultSeed());
WorldInfo worldInfo = new WorldInfo(TerasologyConstants.MAIN_WORLD, gameManifest.getSeed(), (long) (WorldTime.DAY_LENGTH * 0.025f), worldGeneratorUri);
gameManifest.addWorld(worldInfo);
return gameManifest;
}
use of org.terasology.engine.module.ModuleManager in project Terasology by MovingBlocks.
the class TerasologyEngine method initManagers.
private void initManagers() {
changeStatus(TerasologyEngineStatus.INITIALIZING_MODULE_MANAGER);
ModuleManager moduleManager = new ModuleManagerImpl(rootContext.get(Config.class));
rootContext.put(ModuleManager.class, moduleManager);
changeStatus(TerasologyEngineStatus.INITIALIZING_LOWLEVEL_OBJECT_MANIPULATION);
ReflectFactory reflectFactory = new ReflectionReflectFactory();
rootContext.put(ReflectFactory.class, reflectFactory);
CopyStrategyLibrary copyStrategyLibrary = new CopyStrategyLibrary(reflectFactory);
rootContext.put(CopyStrategyLibrary.class, copyStrategyLibrary);
rootContext.put(TypeSerializationLibrary.class, new TypeSerializationLibrary(reflectFactory, copyStrategyLibrary));
changeStatus(TerasologyEngineStatus.INITIALIZING_ASSET_TYPES);
assetTypeManager = new ModuleAwareAssetTypeManager();
rootContext.put(ModuleAwareAssetTypeManager.class, assetTypeManager);
rootContext.put(AssetManager.class, assetTypeManager.getAssetManager());
}
Aggregations