Search in sources :

Example 1 with Config

use of org.terasology.engine.config.Config in project Terasology by MovingBlocks.

the class MenuAnimationSystems method createDefaultSwipeAnimation.

public static MenuAnimationSystem createDefaultSwipeAnimation() {
    RenderingConfig config = CoreRegistry.get(Config.class).getRendering();
    MenuAnimationSystem swipe = new SwipeMenuAnimationSystem(0.25f, SwipeMenuAnimationSystem.Direction.LEFT_TO_RIGHT);
    MenuAnimationSystem instant = new MenuAnimationSystemStub();
    Supplier<MenuAnimationSystem> provider = () -> config.isAnimatedMenu() ? swipe : instant;
    return new DeferredMenuAnimationSystem(provider);
}
Also used : Config(org.terasology.engine.config.Config) RenderingConfig(org.terasology.engine.config.RenderingConfig) RenderingConfig(org.terasology.engine.config.RenderingConfig)

Example 2 with Config

use of org.terasology.engine.config.Config in project Terasology by MovingBlocks.

the class GameConfigurationMetric method fetchConfig.

private void fetchConfig() {
    Config config = context.get(Config.class);
    SystemConfig systemConfig = context.get(SystemConfig.class);
    language = systemConfig.locale.get().toString();
    PlayerConfig playerConfig = context.get(PlayerConfig.class);
    playerHeight = playerConfig.height.get();
    playerEyeHeight = playerConfig.eyeHeight.get();
}
Also used : SystemConfig(org.terasology.engine.config.SystemConfig) Config(org.terasology.engine.config.Config) SystemConfig(org.terasology.engine.config.SystemConfig) PlayerConfig(org.terasology.engine.config.PlayerConfig) PlayerConfig(org.terasology.engine.config.PlayerConfig)

Example 3 with Config

use of org.terasology.engine.config.Config in project Terasology by MovingBlocks.

the class StartServer method step.

@Override
public boolean step() {
    try {
        Config config = context.get(Config.class);
        int port = config.getNetwork().getServerPort();
        context.get(NetworkSystem.class).host(port, dedicated);
    } catch (HostingFailedException e) {
        NUIManager nui = context.get(NUIManager.class);
        if (nui != null) {
            nui.pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Failed to Host", e.getMessage() + " - Reverting to single player");
        } else {
            logger.error("Failed to Host. NUI was also unavailable for warning popup (headless?)", e);
            throw new RuntimeException("Cannot host game successfully from likely headless start, terminating");
        }
    }
    return true;
}
Also used : Config(org.terasology.engine.config.Config) HostingFailedException(org.terasology.engine.network.exceptions.HostingFailedException) NetworkSystem(org.terasology.engine.network.NetworkSystem) NUIManager(org.terasology.engine.rendering.nui.NUIManager)

Example 4 with Config

use of org.terasology.engine.config.Config in project Terasology by MovingBlocks.

the class ConfigurationSubsystem method preInitialise.

@Override
public void preInitialise(Context rootContext) {
    config = new Config(rootContext);
    config.load();
    String serverPortProperty = System.getProperty(SERVER_PORT_PROPERTY);
    if (serverPortProperty != null) {
        try {
            config.getNetwork().setServerPort(Integer.parseInt(serverPortProperty));
        } catch (NumberFormatException e) {
            logger.error("Failed to set server port to invalid value: {}", serverPortProperty);
        }
    }
    if (Iterables.isEmpty(config.getDefaultModSelection().listModules())) {
        config.getDefaultModSelection().addModule(TerasologyConstants.CORE_GAMEPLAY_MODULE);
    }
    checkServerIdentity();
    // TODO: Move to display subsystem
    logger.info("Video Settings: {}", config.renderConfigAsJson(config.getRendering()));
    rootContext.put(Config.class, config);
    // add facades
    rootContext.put(InputDeviceConfiguration.class, new InputDeviceConfigurationImpl(config));
    rootContext.put(BindsConfiguration.class, new BindsConfigurationImpl(config));
}
Also used : BindsConfigurationImpl(org.terasology.engine.config.facade.BindsConfigurationImpl) Config(org.terasology.engine.config.Config) InputDeviceConfigurationImpl(org.terasology.engine.config.facade.InputDeviceConfigurationImpl)

Example 5 with Config

use of org.terasology.engine.config.Config in project Terasology by MovingBlocks.

the class CreateWorldEntity method step.

@Override
public boolean step() {
    this.entityManager = context.get(EntityManager.class);
    this.worldGenerator = context.get(WorldGenerator.class);
    this.config = context.get(Config.class);
    this.chunkProvider = context.get(ChunkProvider.class);
    this.worldConfigurator = worldGenerator.getConfigurator();
    Iterator<EntityRef> worldEntityIterator = entityManager.getEntitiesWith(WorldComponent.class).iterator();
    if (worldEntityIterator.hasNext()) {
        EntityRef worldEntity = worldEntityIterator.next();
        worldEntityIterator.forEachRemaining(w -> logger.warn("Ignored extra world {}", w));
        chunkProvider.setWorldEntity(worldEntity);
        // replace the world generator values from the components in the world entity
        worldConfigurator.getProperties().forEach((key, currentComponent) -> {
            Component component = worldEntity.getComponent(currentComponent.getClass());
            if (component != null) {
                worldConfigurator.setProperty(key, component);
            }
        });
    } else {
        // create world entity if one does not exist.
        EntityRef worldEntity = createWorldPoolsAndEntity();
        chunkProvider.setWorldEntity(worldEntity);
        // transfer all world generation parameters from Config to WorldEntity
        SimpleUri generatorUri = worldGenerator.getUri();
        worldConfigurator.getProperties().forEach((key, currentComponent) -> {
            Class<? extends Component> clazz = currentComponent.getClass();
            Component moduleComponent = gameManifest.getModuleConfig(generatorUri, key, clazz);
            if (moduleComponent != null) {
                // configure entity from component
                worldEntity.addComponent(moduleComponent);
                worldConfigurator.setProperty(key, moduleComponent);
            } else {
                worldEntity.addComponent(currentComponent);
            }
        });
    }
    return true;
}
Also used : EntityManager(org.terasology.engine.entitySystem.entity.EntityManager) WorldGenerator(org.terasology.engine.world.generator.WorldGenerator) Config(org.terasology.engine.config.Config) SimpleUri(org.terasology.engine.core.SimpleUri) ChunkProvider(org.terasology.engine.world.chunks.ChunkProvider) WorldComponent(org.terasology.engine.world.WorldComponent) Component(org.terasology.gestalt.entitysystem.component.Component) NetworkComponent(org.terasology.engine.network.NetworkComponent) WorldComponent(org.terasology.engine.world.WorldComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef)

Aggregations

Config (org.terasology.engine.config.Config)19 TelemetryConfig (org.terasology.engine.config.TelemetryConfig)4 SimpleUri (org.terasology.engine.core.SimpleUri)4 ModuleManager (org.terasology.engine.core.module.ModuleManager)3 GameManifest (org.terasology.engine.game.GameManifest)3 Lists (com.google.common.collect.Lists)2 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Collectors (java.util.stream.Collectors)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 ControllerConfig (org.terasology.engine.config.ControllerConfig)2 PlayerConfig (org.terasology.engine.config.PlayerConfig)2 WorldGenerationConfig (org.terasology.engine.config.WorldGenerationConfig)2 ContextImpl (org.terasology.engine.context.internal.ContextImpl)2 StateLoading (org.terasology.engine.core.modes.StateLoading)2 InputSystem (org.terasology.engine.input.InputSystem)2 LwjglControllerDevice (org.terasology.engine.input.lwjgl.LwjglControllerDevice)2 In (org.terasology.engine.registry.In)2