use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class ShadowMapResolutionDependentFBOs method request.
@Override
public FBO request(FBOConfig fboConfig) {
FBO fbo;
SimpleUri fboName = fboConfig.getName();
if (fboConfigs.containsKey(fboName)) {
if (!fboConfig.equals(fboConfigs.get(fboName))) {
throw new IllegalArgumentException("Requested FBO is already available with different configuration");
}
fbo = fboLookup.get(fboConfig.getName());
} else {
fbo = generateWithDimensions(fboConfig, shadowMapResolution);
}
retain(fboName);
return fbo;
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class WorldSerializerImpl method createPrefab.
private void createPrefab(EntityData.Prefab prefabData) {
SimpleUri uri = new SimpleUri(prefabData.getName());
try (ModuleContext.ContextSpan ignored = ModuleContext.setContext(moduleManager.getEnvironment().get(uri.getModuleName()))) {
PrefabData protoPrefab = prefabSerializer.deserialize(prefabData);
Assets.generateAsset(new ResourceUrn(prefabData.getName()), protoPrefab, Prefab.class);
} catch (Exception e) {
logger.error("Failed to create prefab {}", prefabData.getName());
}
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class LocalPlayerSystem method startAutoMove.
/**
* Append the input for moving forward to the keyboard command queue to simulate pressing of the forward key.
* For an input that repeats, the key must be in Down state before Repeat state can be applied to it.
*/
private void startAutoMove() {
isAutoMove = false;
List<Input> inputs = bindsManager.getBindsConfig().getBinds(new SimpleUri("engine:forwards"));
Input forwardKey = getValidKey(inputs);
if (forwardKey != null) {
isAutoMove = true;
inputSystem.simulateSingleKeyStroke(forwardKey);
inputSystem.simulateRepeatedKeyStroke(forwardKey);
}
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class RenderGraph method addNode.
public SimpleUri addNode(Node node, String suggestedUri) {
Preconditions.checkNotNull(node, "node cannot be null!");
Preconditions.checkNotNull(suggestedUri, "suggestedUri cannot be null!");
SimpleUri nodeUri = new SimpleUri("engine:" + suggestedUri);
if (nodeMap.containsKey(nodeUri)) {
int i = 2;
while (nodeMap.containsKey(new SimpleUri(nodeUri.toString() + i))) {
i++;
}
nodeUri = new SimpleUri(nodeUri.toString() + i);
}
node.setUri(nodeUri);
nodeMap.put(nodeUri, node);
return nodeUri;
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class PropertyProvider method createProperties.
public List<Property<?, ?>> createProperties(Object target) {
List<Property<?, ?>> properties = Lists.newArrayList();
try {
Class<?> type = target.getClass();
ReflectFactory reflectFactory = CoreRegistry.get(ReflectFactory.class);
CopyStrategyLibrary copyStrategies = new CopyStrategyLibrary(reflectFactory);
ClassMetadata<?, ?> classMetadata = new DefaultClassMetadata<>(new SimpleUri(), type, reflectFactory, copyStrategies);
for (Field field : getAllFields(type)) {
Annotation annotation = getFactory(field);
if (annotation != null) {
FieldMetadata<Object, ?> fieldMetadata = (FieldMetadata<Object, ?>) classMetadata.getField(field.getName());
PropertyFactory factory = factories.get(annotation.annotationType());
Property property = factory.create(target, fieldMetadata, field.getName(), annotation);
properties.add(property);
}
}
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
return properties;
}
Aggregations