use of org.terasology.engine.subsystem.DisplayDevice in project Terasology by MovingBlocks.
the class ComponentSystemManager method loadSystems.
public void loadSystems(ModuleEnvironment environment, NetworkMode netMode) {
DisplayDevice display = context.get(DisplayDevice.class);
boolean isHeadless = display.isHeadless();
ListMultimap<Name, Class<?>> systemsByModule = ArrayListMultimap.create();
for (Class<?> type : environment.getTypesAnnotatedWith(RegisterSystem.class)) {
if (!ComponentSystem.class.isAssignableFrom(type)) {
logger.error("Cannot load {}, must be a subclass of ComponentSystem", type.getSimpleName());
continue;
}
Name moduleId = environment.getModuleProviding(type);
RegisterSystem registerInfo = type.getAnnotation(RegisterSystem.class);
if (registerInfo.value().isValidFor(netMode, isHeadless) && areOptionalRequirementsContained(registerInfo, environment)) {
systemsByModule.put(moduleId, type);
}
}
for (Module module : environment.getModulesOrderedByDependencies()) {
for (Class<?> system : systemsByModule.get(module.getId())) {
String id = module.getId() + ":" + system.getSimpleName();
logger.debug("Registering system {}", id);
try {
ComponentSystem newSystem = (ComponentSystem) system.newInstance();
InjectionHelper.share(newSystem);
register(newSystem, id);
logger.debug("Loaded system {}", id);
} catch (RuntimeException | IllegalAccessException | InstantiationException | NoClassDefFoundError e) {
logger.error("Failed to load system {}", id, e);
}
}
}
}
use of org.terasology.engine.subsystem.DisplayDevice in project Terasology by MovingBlocks.
the class Metric method filterMetricMap.
/**
* Filter the metric map by the binding map.
* If the user doesn't want the field to be sent, its value will be covered by "Disabled Field".
* @param bindingMap the binding map.
* @return a new metric map that covers the field that the user doesn't want to send by "Disabled Field".
*/
protected Map<String, Object> filterMetricMap(Map<String, Boolean> bindingMap) {
TelemetryCategory telemetryCategory = this.getClass().getAnnotation(TelemetryCategory.class);
Context context = CoreRegistry.get(Context.class);
DisplayDevice display = context.get(DisplayDevice.class);
if (display.isHeadless() || telemetryCategory.isOneMapMetric()) {
return telemetryFieldToValue;
}
Map<String, Object> metricMapAfterPermission = new HashMap<>();
for (String fieldName : telemetryFieldToValue.keySet()) {
String fieldNameWithID = telemetryCategory.id() + ":" + fieldName;
if (bindingMap.containsKey(fieldNameWithID)) {
if (bindingMap.get(fieldNameWithID)) {
metricMapAfterPermission.put(fieldName, telemetryFieldToValue.get(fieldName));
} else {
metricMapAfterPermission.put(fieldName, "Disabled Field");
}
}
}
return metricMapAfterPermission;
}
use of org.terasology.engine.subsystem.DisplayDevice in project Terasology by MovingBlocks.
the class Metric method filterMetricMap.
/**
* Filter the metric map by the binding map.
* If the user doesn't want the field to be sent, its value will be covered by "Disabled Field".
* This method could be used in module since {@link org.terasology.config.facade.TelemetryConfiguration} is exposed to modules
* @param telemetryConfiguration the telemetry configuration exposed modules
* @return a new metric map that covers the field that the user doesn't want to send by "Disabled Field".
*/
protected Map<String, Object> filterMetricMap(TelemetryConfiguration telemetryConfiguration) {
TelemetryCategory telemetryCategory = this.getClass().getAnnotation(TelemetryCategory.class);
Context context = CoreRegistry.get(Context.class);
DisplayDevice display = context.get(DisplayDevice.class);
if (display.isHeadless() || telemetryCategory.isOneMapMetric()) {
return telemetryFieldToValue;
}
Map<String, Object> metricMapAfterPermission = new HashMap<>();
for (String fieldName : telemetryFieldToValue.keySet()) {
String fieldNameWithID = telemetryCategory.id() + ":" + fieldName;
if (telemetryConfiguration.containsField(fieldNameWithID)) {
if (telemetryConfiguration.get(fieldNameWithID)) {
metricMapAfterPermission.put(fieldName, telemetryFieldToValue.get(fieldName));
} else {
metricMapAfterPermission.put(fieldName, "Disabled Field");
}
}
}
return metricMapAfterPermission;
}
use of org.terasology.engine.subsystem.DisplayDevice in project Terasology by MovingBlocks.
the class StateIngame method render.
@Override
public void render() {
DisplayDevice display = context.get(DisplayDevice.class);
display.prepareToRender();
if (worldRenderer != null) {
if (!context.get(Config.class).getRendering().isVrSupport()) {
worldRenderer.render(RenderingStage.MONO);
} else {
worldRenderer.render(RenderingStage.LEFT_EYE);
worldRenderer.render(RenderingStage.RIGHT_EYE);
}
}
/* UI */
PerformanceMonitor.startActivity("Render and Update UI");
renderUserInterface();
PerformanceMonitor.endActivity();
}
Aggregations