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);
}
}
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;
}
}
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());
}
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();
}
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;
}
Aggregations