Examples of BlockShape


Examples of edu.mit.blocks.codeblocks.BlockShape

        //form basic shape
        if (getBlock().isInfix()) {
            blockShape = new InfixBlockShape(this);
        } else {
            blockShape = new BlockShape(this);
        }

        if (!isLoading) {
            //reformBlockShape so as to update socket points to position labels and setBounds of this rb
            reformBlockShape();
View Full Code Here

Examples of org.terasology.world.block.shapes.BlockShape

        return null;
    }

    public BlockFamily loadWithShape(BlockUri uri) {
        try (ModuleContext.ContextSpan ignored = ModuleContext.setContext(uri.getModuleName())) {
            BlockShape shape = cubeShape;
            if (uri.hasShape()) {
                AssetUri shapeUri = uri.getShapeUri();
                if (!shapeUri.isValid()) {
                    return null;
                }
                shape = (BlockShape) Assets.get(shapeUri);
                if (shape == null) {
                    return null;
                }
            }
            AssetUri blockDefUri = new AssetUri(AssetType.BLOCK_DEFINITION, uri.getModuleName(), uri.getFamilyName());
            BlockDefinition def;
            if (assetManager.getAssetURLs(blockDefUri).isEmpty()) {
                // An auto-block
                def = new BlockDefinition();
            } else {
                def = createBlockDefinition(inheritData(blockDefUri, readJson(blockDefUri).getAsJsonObject()));
            }

            def.shape = (shape.getURI().toSimpleString());
            if (shape.isCollisionYawSymmetric()) {
                Block block = constructSingleBlock(blockDefUri, def);
                if (block.getDisplayName().isEmpty()) {
                    block.setDisplayName(shape.getDisplayName());
                } else if (!shape.getDisplayName().isEmpty()) {
                    block.setDisplayName(block.getDisplayName() + " " + shape.getDisplayName());
                }
                return new SymmetricFamily(uri, block, def.categories);
            } else {
                Map<Side, Block> blockMap = Maps.newEnumMap(Side.class);
                constructHorizontalBlocks(blockDefUri, def, blockMap);
                for (Block block : blockMap.values()) {
                    if (block.getDisplayName().isEmpty()) {
                        block.setDisplayName(shape.getDisplayName());
                    } else if (!shape.getDisplayName().isEmpty()) {
                        block.setDisplayName(block.getDisplayName() + " " + shape.getDisplayName());
                    }
                }
                return new HorizontalBlockFamily(uri, blockMap, def.categories);
            }
        } catch (Exception e) {
View Full Code Here

Examples of org.terasology.world.block.shapes.BlockShape

    }

    private List<BlockFamily> processMultiBlockFamily(AssetUri blockDefUri, BlockDefinition blockDef) {
        List<BlockFamily> result = Lists.newArrayList();
        for (String shapeString : blockDef.shapes) {
            BlockShape shape = (BlockShape) Assets.get(AssetType.SHAPE, shapeString);
            if (shape != null) {
                BlockUri familyUri;
                if (shape.equals(cubeShape)) {
                    familyUri = new BlockUri(blockDefUri.getModuleName(), blockDefUri.getAssetName());
                } else {
                    familyUri = new BlockUri(blockDefUri.getModuleName(), blockDefUri.getAssetName(), shape.getURI().getModuleName(), shape.getURI().getAssetName());
                }
                blockDef.shape = shapeString;
                if (shape.isCollisionYawSymmetric()) {
                    Block block = constructSingleBlock(blockDefUri, blockDef);
                    result.add(new SymmetricFamily(familyUri, block, blockDef.categories));
                } else {
                    Map<Side, Block> blockMap = Maps.newEnumMap(Side.class);
                    constructHorizontalBlocks(blockDefUri, blockDef, blockMap);
View Full Code Here

Examples of org.terasology.world.block.shapes.BlockShape

    private Block constructSingleBlock(AssetUri blockDefUri, BlockDefinition blockDef) {
        Map<BlockPart, AssetUri> tileUris = prepareTiles(blockDef, blockDefUri);
        Map<BlockPart, DefaultColorSource> colorSourceMap = prepareColorSources(blockDef);
        Map<BlockPart, Vector4f> colorOffsetsMap = prepareColorOffsets(blockDef);
        BlockShape shape = getShape(blockDef);

        Block block = createRawBlock(blockDef, blockDefUri.getAssetName());
        block.setPrimaryAppearance(createAppearance(shape, tileUris, Rotation.none()));
        setBlockFullSides(block, shape, Rotation.none());
        block.setCollision(shape.getCollisionOffset(Rotation.none()), shape.getCollisionShape(Rotation.none()));

        for (BlockPart part : BlockPart.values()) {
            block.setColorSource(part, colorSourceMap.get(part));
            block.setColorOffset(part, colorOffsetsMap.get(part));
        }
View Full Code Here

Examples of org.terasology.world.block.shapes.BlockShape

    @Override
    public Block constructTransformedBlock(AssetUri blockDefUri, BlockDefinition blockDef, Rotation rotation) {
        Map<BlockPart, AssetUri> tileUris = prepareTiles(blockDef, blockDefUri);
        Map<BlockPart, DefaultColorSource> colorSourceMap = prepareColorSources(blockDef);
        Map<BlockPart, Vector4f> colorOffsetsMap = prepareColorOffsets(blockDef);
        BlockShape shape = getShape(blockDef);

        Block block = createRawBlock(blockDef, blockDefUri.getAssetName());
        block.setDirection(rotation.rotate(Side.FRONT));
        block.setPrimaryAppearance(createAppearance(shape, tileUris, rotation));
        setBlockFullSides(block, shape, rotation);
        block.setCollision(shape.getCollisionOffset(rotation), shape.getCollisionShape(rotation));

        for (BlockPart part : BlockPart.values()) {
            block.setColorSource(part, colorSourceMap.get(part));
            block.setColorOffset(part, colorOffsetsMap.get(part));
        }
View Full Code Here

Examples of org.terasology.world.block.shapes.BlockShape

        }
        return result;
    }

    private BlockShape getShape(BlockDefinition blockDef) {
        BlockShape shape = null;
        if (!blockDef.shape.isEmpty()) {
            shape = (BlockShape) Assets.get(AssetType.SHAPE, blockDef.shape);
        }
        if (shape == null) {
            return cubeShape;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.