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);
}
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();
}
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;
}
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));
}
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;
}
Aggregations