use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class BindCommands method bindKey.
@Command(shortDescription = "Maps a key to a function", requiredPermission = PermissionManager.NO_PERMISSION)
public String bindKey(@CommandParam("key") String key, @CommandParam("function") String bind) {
Input keyInput = Keyboard.Key.find(key);
if (keyInput != null) {
bindsManager.linkBindButtonToKey(keyInput.getId(), new SimpleUri(bind));
StringBuilder builder = new StringBuilder();
builder.append("Mapped ").append(keyInput.getDisplayName()).append(" to action ");
builder.append(bind);
return builder.toString();
}
throw new IllegalArgumentException("Unknown key: " + key);
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class BehaviorNodeFactory method determineAnimationPoolUris.
private List<ComponentFieldUri> determineAnimationPoolUris() {
final List<ComponentFieldUri> animationSetUris = Lists.newArrayList();
for (ComponentMetadata<?> componentMetadata : componentLibrary.iterateComponentMetadata()) {
SimpleUri uri = componentMetadata.getUri();
for (FieldMetadata<?, ?> fieldMetadata : componentMetadata.getFields()) {
if (fieldMetadata.getType().isAssignableFrom(List.class)) {
Type fieldType = fieldMetadata.getField().getGenericType();
if (fieldType instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) fieldType;
Type[] typeArguments = parameterizedType.getActualTypeArguments();
if (typeArguments.length == 1) {
Class<?> typeClass = ReflectionUtil.getClassOfType(typeArguments[0]);
if (typeClass.isAssignableFrom(MeshAnimation.class)) {
animationSetUris.add(new ComponentFieldUri(uri, fieldMetadata.getName()));
}
}
}
}
}
}
return animationSetUris;
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class FlexibleConfigImpl method add.
/**
* {@inheritDoc}
*/
@Override
public boolean add(Setting setting) {
SimpleUri id = setting.getId();
if (id == null) {
LOGGER.warn("The id of a setting cannot be null.");
return false;
} else if (contains(id)) {
LOGGER.warn("A Setting with the id \"{}\" already exists.", id);
return false;
}
if (temporarilyParkedSettings.containsKey(id)) {
setting.setValueFromJson(temporarilyParkedSettings.remove(id));
}
settings.put(id, setting);
return true;
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class FlexibleConfigManagerImpl method saveAllConfigs.
@Override
public void saveAllConfigs() {
for (Entry<SimpleUri, FlexibleConfig> entry : flexibleConfigs.entrySet()) {
SimpleUri flexibleConfigId = entry.getKey();
FlexibleConfig flexibleConfig = entry.getValue();
try (BufferedWriter writer = Files.newBufferedWriter(getPathForFlexibleConfig(flexibleConfigId), TerasologyConstants.CHARSET)) {
flexibleConfig.save(writer);
} catch (IOException e) {
logger.error("Failed to save config", e);
}
}
}
use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.
the class RenderTaskListGeneratorTest method testReducePersistingStateChanges.
@Test
public void testReducePersistingStateChanges() {
RenderTaskListGenerator renderTaskListGenerator = new RenderTaskListGenerator();
List<Node> orderedNodes = Lists.newArrayList();
Node alphaNode = new AlphaNode();
alphaNode.setUri(new SimpleUri("engine:alphaNode"));
orderedNodes.add(alphaNode);
Node bravoNode = new BravoNode();
bravoNode.setUri(new SimpleUri("engine:bravoNode"));
orderedNodes.add(bravoNode);
Node charlieNode = new CharlieNode();
charlieNode.setUri(new SimpleUri("engine:charlieNode"));
orderedNodes.add(charlieNode);
Node deltaNode = new DeltaNode();
deltaNode.setUri(new SimpleUri("engine:deltaNode"));
orderedNodes.add(deltaNode);
List<RenderPipelineTask> taskList = renderTaskListGenerator.generateFrom(orderedNodes);
assertEquals("----- engine:alphaNode (AlphaNode)", taskList.get(0).toString().trim());
assertEquals("SetName: foo", taskList.get(1).toString().trim());
assertEquals("engine:alphaNode (AlphaNode)", taskList.get(2).toString().trim());
assertEquals("----- engine:bravoNode (BravoNode)", taskList.get(3).toString().trim());
assertEquals("engine:bravoNode (BravoNode)", taskList.get(4).toString().trim());
assertEquals("----- engine:charlieNode (CharlieNode)", taskList.get(5).toString().trim());
assertEquals("engine:charlieNode (CharlieNode)", taskList.get(6).toString().trim());
assertEquals("----- engine:deltaNode (DeltaNode)", taskList.get(7).toString().trim());
assertEquals("SetName: delta", taskList.get(8).toString().trim());
assertEquals("engine:deltaNode (DeltaNode)", taskList.get(9).toString().trim());
assertEquals("SetName: bar", taskList.get(10).toString().trim());
}
Aggregations