/** * Creates a SimpleUri for the given module:object combo * * @param moduleName * @param objectName */ public SimpleUri(Name moduleName, String objectName) { this(moduleName, new Name(objectName)); }
@Override public Name getFromString(String representation) { return new Name(representation); } }
@Override public Name parse(String raw) { return new Name(raw); }
/** * Creates a SimpleUri from a string in the format "module:object". If the string does not match this format, it will be marked invalid * * @param simpleUri */ public SimpleUri(String simpleUri) { String[] split = simpleUri.split(MODULE_SEPARATOR, 2); if (split.length > 1) { moduleName = new Name(split[0]); objectName = new Name(split[1]); } }
@Override public Name getAssetName(String filename) throws InvalidAssetFilenameException { if (filename.endsWith(METADATA_SUFFIX)) { return new Name(filename.substring(0, filename.length() - METADATA_SUFFIX.length())); } else { return new Name(filename.substring(0, filename.length() - FRAGMENT_SUFFIX.length())); } }
/** * Returns a AssetUri which represents a Texture that contains white noise * * @param size the size of the texture (both width and height) * @param seed the seed value for the noise generator * @param min the minimum noise value (can be lower than 0 and will be clamped then) * @param max the minimum noise value (can be larger than 255 and will be clamped then) * @return an asset Uri for the texture */ public static ResourceUrn getTextureUriForWhiteNoise(int size, long seed, int min, int max) { String name = String.format("%s.%d.%d.%d.%d", "white", size, seed, min, max); return new ResourceUrn(TerasologyConstants.ENGINE_MODULE, NOISE_RESOURCE_NAME, new Name(name)); }
private static Name basenameFromFilename(String filename) throws IOException { Matcher m = FILENAME_PATTERN.matcher(filename); if (m.matches()) { return new Name(m.group(1)); } throw new IOException("Could not parse project name: " + filename); }
/** * Returns a AssetUri which represents a Texture of that color. * * @param color including alpha, of the texture to represent. * @return an asset Uri for the texture */ public static ResourceUrn getTextureUriForColor(Color color) { return new ResourceUrn(TerasologyConstants.ENGINE_MODULE, COLOR_RESOURCE_NAME, new Name(getColorName(color))); }
@Override public Name getAssetName(String filename) throws InvalidAssetFilenameException { if (filename.endsWith(LANGDATA_EXT)) { return new Name(filename.substring(0, filename.length() - LANGDATA_EXT.length())); } throw new InvalidAssetFilenameException("File '" + filename + "' does not end with '" + LANGDATA_EXT + "'."); }
/** * Called whenever the user decides to add a new world. * @param worldGeneratorInfo The {@link WorldGeneratorInfo} object for the new world. */ private void addNewWorld(WorldGeneratorInfo worldGeneratorInfo) { selectedWorld = worldGeneratorInfo.getDisplayName() + '-' + worldNumber; worlds.add(new WorldSetupWrapper(new Name(worldGeneratorInfo.getDisplayName() + '-' + worldNumber), worldGeneratorInfo)); worldNumber++; }
@Override public BindsConfig deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { BindsConfig result = new BindsConfig(); JsonObject inputObj = json.getAsJsonObject(); for (Map.Entry<String, JsonElement> entry : inputObj.entrySet()) { SetMultimap<String, Input> map = context.deserialize(entry.getValue(), SetMultimap.class); for (String id : map.keySet()) { SimpleUri uri = new SimpleUri(new Name(entry.getKey()), id); result.uriBoundInputs.putAll(uri, map.get(id)); } } return result; }
public BehaviorTree createTree(String name, BehaviorNode root) { BehaviorTreeData data = new BehaviorTreeData(); data.setRoot(root); BehaviorTree behaviorTree = assetManager.loadAsset(new ResourceUrn(BEHAVIORS, new Name(name.replaceAll("\\W+", ""))), data, BehaviorTree.class); trees.add(behaviorTree); save(behaviorTree); return behaviorTree; }
@BeforeClass public static void setupEnvironment() throws Exception { final JavaArchive homeArchive = ShrinkWrap.create(JavaArchive.class); final FileSystem vfs = ShrinkWrapFileSystems.newFileSystem(homeArchive); PathManager.getInstance().useOverrideHomePath(vfs.getPath("")); /* * Create at least for each class a new headless environemnt as it is fast and prevents side effects * (Reusing a headless environment after other tests have modified the core registry isn't really clean) */ env = new HeadlessEnvironment(new Name("engine")); context = env.getContext(); moduleManager = context.get(ModuleManager.class); }
public HorizontalFamily(BlockFamilyDefinition definition, BlockBuilderHelper blockBuilder) { super(definition, blockBuilder); BlockUri uri = new BlockUri(definition.getUrn()); for (Rotation rot : Rotation.horizontalRotations()) { Side side = rot.rotate(Side.FRONT); Block block = blockBuilder.constructTransformedBlock(definition, side.toString().toLowerCase(Locale.ENGLISH), rot, new BlockUri(uri, new Name(side.name())), this); if (block == null) { throw new IllegalArgumentException("Missing block for side: " + side.toString()); } blocks.put(side, block); } }
private boolean areOptionalRequirementsContained(RegisterSystem registerSystem, ModuleEnvironment environment) { if (registerSystem.requiresOptional().length == 0) { return true; } for (String moduleName : registerSystem.requiresOptional()) { if (environment.get(new Name(moduleName)) == null) { return false; } } return true; }
@Override public boolean execute(String rawCommand, EntityRef callingClient) { String commandName = processCommandName(rawCommand); List<String> processedParameters = processParameters(rawCommand); ClientComponent cc = callingClient.getComponent(ClientComponent.class); if (cc.local) { if (!rawCommand.isEmpty() && (localCommandHistory.isEmpty() || !localCommandHistory.getLast().equals(rawCommand))) { localCommandHistory.add(rawCommand); } } return execute(new Name(commandName), processedParameters, callingClient); }
public static ModuleManager create() throws Exception { ModuleManager moduleManager = new ModuleManagerImpl(""); try (Reader reader = new InputStreamReader(ModuleManagerFactory.class.getResourceAsStream("/module.txt"), TerasologyConstants.CHARSET)) { ModuleMetadata metadata = new ModuleMetadataReader().read(reader); moduleManager.getRegistry().add(ClasspathModule.create(metadata, ModuleManagerFactory.class)); } moduleManager.loadEnvironment(Sets.newHashSet(moduleManager.getRegistry().getLatestModuleVersion(new Name("engine"))), true); return moduleManager; } }
@Override public boolean step() { // Refresh widget library after modules got laoded: NUIManager nuiManager = context.get(NUIManager.class); ((NUIManagerInternal) nuiManager).refreshWidgetsLibrary(); // TODO: This should be elsewhere // Create gelatinousCubeMesh Tessellator tessellator = new Tessellator(); TessellatorHelper.addBlockMesh(tessellator, new Vector4f(1.0f, 1.0f, 1.0f, 1.0f), 0.8f, 0.8f, 0.6f, 0f, 0f, 0f); TessellatorHelper.addBlockMesh(tessellator, new Vector4f(1.0f, 1.0f, 1.0f, 0.6f), 1.0f, 1.0f, 0.8f, 0f, 0f, 0f); tessellator.generateMesh(new ResourceUrn(TerasologyConstants.ENGINE_MODULE, new Name("gelatinousCube"))); return true; }