Search in sources :

Example 6 with SimpleUri

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;
}
Also used : FBO(org.terasology.rendering.opengl.FBO) SimpleUri(org.terasology.engine.SimpleUri)

Example 7 with SimpleUri

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());
    }
}
Also used : PrefabData(org.terasology.entitySystem.prefab.PrefabData) SimpleUri(org.terasology.engine.SimpleUri) ModuleContext(org.terasology.persistence.ModuleContext) ResourceUrn(org.terasology.assets.ResourceUrn)

Example 8 with SimpleUri

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);
    }
}
Also used : Input(org.terasology.input.Input) SimpleUri(org.terasology.engine.SimpleUri)

Example 9 with SimpleUri

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;
}
Also used : SimpleUri(org.terasology.engine.SimpleUri)

Example 10 with SimpleUri

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;
}
Also used : FieldMetadata(org.terasology.reflection.metadata.FieldMetadata) SimpleUri(org.terasology.engine.SimpleUri) CopyStrategyLibrary(org.terasology.reflection.copy.CopyStrategyLibrary) Annotation(java.lang.annotation.Annotation) ReflectFactory(org.terasology.reflection.reflect.ReflectFactory) Field(java.lang.reflect.Field) DefaultClassMetadata(org.terasology.reflection.metadata.DefaultClassMetadata)

Aggregations

SimpleUri (org.terasology.engine.SimpleUri)71 Test (org.junit.Test)18 Map (java.util.Map)10 Name (org.terasology.naming.Name)9 ResourceUrn (org.terasology.assets.ResourceUrn)7 DefaultClassMetadata (org.terasology.reflection.metadata.DefaultClassMetadata)7 Config (org.terasology.config.Config)6 Input (org.terasology.input.Input)6 FBO (org.terasology.rendering.opengl.FBO)6 ModuleManager (org.terasology.engine.module.ModuleManager)5 Command (org.terasology.logic.console.commandSystem.annotations.Command)5 ModuleEnvironment (org.terasology.module.ModuleEnvironment)5 List (java.util.List)4 DependencyResolver (org.terasology.module.DependencyResolver)4 ResolutionResult (org.terasology.module.ResolutionResult)4 UILabel (org.terasology.rendering.nui.widgets.UILabel)4 Lists (com.google.common.collect.Lists)3 IOException (java.io.IOException)3 Type (java.lang.reflect.Type)3 Locale (java.util.Locale)3