Search in sources :

Example 16 with ModuleManager

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;
}
Also used : EngineSubsystem(org.terasology.engine.subsystem.EngineSubsystem) GameEngine(org.terasology.engine.GameEngine) ModuleManager(org.terasology.engine.module.ModuleManager) TerasologyEngine(org.terasology.engine.TerasologyEngine) ComponentSystemManager(org.terasology.engine.ComponentSystemManager)

Example 17 with ModuleManager

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);
                }
            }
        }
    }
}
Also used : ModuleEnvironment(org.terasology.module.ModuleEnvironment) ResolutionResult(org.terasology.module.ResolutionResult) ModuleManager(org.terasology.engine.module.ModuleManager) FromModule(org.terasology.module.predicates.FromModule) DependencyResolver(org.terasology.module.DependencyResolver) Name(org.terasology.naming.Name)

Example 18 with ModuleManager

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);
}
Also used : ModuleEnvironment(org.terasology.module.ModuleEnvironment) ModuleManager(org.terasology.engine.module.ModuleManager)

Example 19 with ModuleManager

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;
}
Also used : GameManifest(org.terasology.game.GameManifest) Config(org.terasology.config.Config) WorldGenerationConfig(org.terasology.config.WorldGenerationConfig) SimpleUri(org.terasology.engine.SimpleUri) WorldInfo(org.terasology.world.internal.WorldInfo) ModuleManager(org.terasology.engine.module.ModuleManager) Module(org.terasology.module.Module) WorldGenerationConfig(org.terasology.config.WorldGenerationConfig) Name(org.terasology.naming.Name)

Example 20 with ModuleManager

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());
}
Also used : ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectFactory(org.terasology.reflection.reflect.ReflectFactory) ModuleManagerImpl(org.terasology.engine.module.ModuleManagerImpl) Config(org.terasology.config.Config) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) CopyStrategyLibrary(org.terasology.reflection.copy.CopyStrategyLibrary) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) ModuleManager(org.terasology.engine.module.ModuleManager)

Aggregations

ModuleManager (org.terasology.engine.module.ModuleManager)25 ModuleEnvironment (org.terasology.module.ModuleEnvironment)10 Name (org.terasology.naming.Name)8 ModuleAwareAssetTypeManager (org.terasology.assets.module.ModuleAwareAssetTypeManager)7 Module (org.terasology.module.Module)7 DependencyResolver (org.terasology.module.DependencyResolver)6 ResolutionResult (org.terasology.module.ResolutionResult)6 ContextImpl (org.terasology.context.internal.ContextImpl)5 Prefab (org.terasology.entitySystem.prefab.Prefab)5 PrefabData (org.terasology.entitySystem.prefab.PrefabData)5 PojoPrefab (org.terasology.entitySystem.prefab.internal.PojoPrefab)5 BeforeClass (org.junit.BeforeClass)4 TypeSerializationLibrary (org.terasology.persistence.typeHandling.TypeSerializationLibrary)4 Before (org.junit.Before)3 Config (org.terasology.config.Config)3 GameEngine (org.terasology.engine.GameEngine)3 Map (java.util.Map)2 ComponentSystemManager (org.terasology.engine.ComponentSystemManager)2 SimpleUri (org.terasology.engine.SimpleUri)2 EnvironmentSwitchHandler (org.terasology.engine.bootstrap.EnvironmentSwitchHandler)2