Search in sources :

Example 31 with SimpleUri

use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.

the class AutoConfigManager method loadConfigsIn.

public void loadConfigsIn(Context context) {
    ModuleEnvironment environment = context.get(ModuleManager.class).getEnvironment();
    for (Class<? extends AutoConfig> configClass : environment.getSubtypesOf(AutoConfig.class)) {
        if (context.get(configClass) != null) {
            // We've already initialized this config before
            continue;
        }
        SimpleUri configId = verifyNotNull(ReflectionUtil.getFullyQualifiedSimpleUriFor(configClass, environment), "Could not find ID for %s", configClass.getSimpleName());
        loadConfig(configClass, configId, context);
    }
}
Also used : ModuleEnvironment(org.terasology.gestalt.module.ModuleEnvironment) SimpleUri(org.terasology.engine.core.SimpleUri) ModuleManager(org.terasology.engine.core.module.ModuleManager)

Example 32 with SimpleUri

use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.

the class LocalPlayerSystem method stopAutoMove.

/**
 * Auto move is disabled when the associated key is pressed again. This cancels the simulated repeated key stroke
 * for the forward input button.
 */
private void stopAutoMove() {
    List<Input> inputs = bindsManager.getBindsConfig().getBinds(new SimpleUri("engine:forwards"));
    Input forwardKey = getValidKey(inputs);
    if (forwardKey != null) {
        inputSystem.cancelSimulatedKeyStroke(forwardKey);
        isAutoMove = false;
    }
}
Also used : Input(org.terasology.input.Input) SimpleUri(org.terasology.engine.core.SimpleUri)

Example 33 with SimpleUri

use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.

the class ModuleEnvironmentSandbox method doesSubclassMatch.

private boolean doesSubclassMatch(Class<?> subclass, String subTypeIdentifier) {
    if (subclass == null) {
        return false;
    }
    SimpleUri subTypeUri = new SimpleUri(subTypeIdentifier);
    Name subTypeName = subTypeUri.isValid() ? subTypeUri.getObjectName() : new Name(subTypeIdentifier);
    // First check full name
    boolean fullNameEquals = subTypeName.toString().equals((subclass.getName()));
    if (fullNameEquals) {
        return true;
    }
    // Now check through module and simple name
    Name providingModule = getModuleProviding(subclass);
    Name givenModuleName;
    if (subTypeUri.isValid()) {
        givenModuleName = subTypeUri.getModuleName();
    } else {
        // Assume that the requested subtype is in the context module
        givenModuleName = ModuleContext.getContext() != null ? ModuleContext.getContext().getId() : null;
    }
    return Objects.equals(givenModuleName, providingModule) && subTypeName.toString().equals(subclass.getSimpleName());
}
Also used : SimpleUri(org.terasology.engine.core.SimpleUri) Name(org.terasology.gestalt.naming.Name)

Example 34 with SimpleUri

use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.

the class AbstractNode method dispose.

/**
 * Inheriting classes must call this method to ensure that any FBO requested and acquired by a node
 * is automatically released upon the node's disposal. This way FBOs that aren't used by any node
 * are also disposed.
 */
@Override
public void dispose() {
    for (Map.Entry<SimpleUri, BaseFboManager> entry : fboUsages.entrySet()) {
        SimpleUri fboName = entry.getKey();
        BaseFboManager baseFboManager = entry.getValue();
        baseFboManager.release(fboName);
    }
    fboUsages.clear();
}
Also used : SimpleUri(org.terasology.engine.core.SimpleUri) Map(java.util.Map) BaseFboManager(org.terasology.engine.rendering.opengl.BaseFboManager)

Example 35 with SimpleUri

use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.

the class AbstractNode method requiresFbo.

/**
 * Used by inheriting classes to declare the need for a specific Frame Buffer Object and obtain it.
 *
 * The characteristics of the required FBO are described in the fboConfig provided in input.
 * Within the context of the given fboManager an fboConfig uniquely identifies the FBO:
 * if the FBO exists already it is returned, if it doesn't, the FBO is first created and then returned.
 *
 * If the fboManager already contains an FBO with the same fboUri but different characteristics from
 * those described in the fboConfig object, an IllegalArgumentException is thrown.
 *
 * @param fboConfig an FboConfig object describing the required FBO.
 * @param fboManager a BaseFboManager object from which to obtain the FBO.
 * @return the requested FBO object, either newly created or a pre-existing one.
 * @throws IllegalArgumentException if the fboUri in fboConfig already in use by FBO with different characteristics.
 */
protected FBO requiresFbo(FboConfig fboConfig, BaseFboManager fboManager) {
    SimpleUri fboName = fboConfig.getName();
    FBO fbo;
    if (!fboUsages.containsKey(fboName)) {
        fboUsages.put(fboName, fboManager);
    } else {
        logger.warn("FBO " + fboName + " is already requested.");
        fbo = fboManager.get(fboName);
        this.addInputFboConnection(inputConnections.size() + 1, fbo);
        return fbo;
    }
    fbo = fboManager.request(fboConfig);
    return fbo;
}
Also used : FBO(org.terasology.engine.rendering.opengl.FBO) SimpleUri(org.terasology.engine.core.SimpleUri)

Aggregations

SimpleUri (org.terasology.engine.core.SimpleUri)51 Name (org.terasology.gestalt.naming.Name)13 Map (java.util.Map)6 ModuleManager (org.terasology.engine.core.module.ModuleManager)6 FBO (org.terasology.engine.rendering.opengl.FBO)6 ModuleEnvironment (org.terasology.gestalt.module.ModuleEnvironment)6 DependencyResolver (org.terasology.gestalt.module.dependencyresolution.DependencyResolver)6 ResolutionResult (org.terasology.gestalt.module.dependencyresolution.ResolutionResult)6 Config (org.terasology.engine.config.Config)5 BindableButton (org.terasology.engine.input.BindableButton)5 Module (org.terasology.gestalt.module.Module)5 Input (org.terasology.input.Input)5 Test (org.junit.jupiter.api.Test)4 RegisterBindButton (org.terasology.engine.input.RegisterBindButton)4 Lists (com.google.common.collect.Lists)3 List (java.util.List)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 GameManifest (org.terasology.engine.game.GameManifest)3 FboConfig (org.terasology.engine.rendering.opengl.FboConfig)3