// Path: src/main/java/org/terasology/cities/BlockType.java
// public interface BlockType {
//     // empty marker
// }
// 
// Path: src/main/java/org/terasology/cities/DefaultBlockType.java
// public enum DefaultBlockType implements BlockType {
// 
//     /**
//      * Air
//      */
//     AIR,
// 
//     /**
//      * Windows
//      */
//     WINDOW_GLASS,
// 
//     /**
//      * A single-block door element
//      */
//     SIMPLE_DOOR,
// 
//     /**
//      * A two-folded wing door
//      */
//     WING_DOOR,
// 
//     /**
//      * Fill material under the surface of a road
//      */
//     ROAD_FILL,
// 
//     /**
//      * Surface of a road (asphalt)
//      */
//     ROAD_SURFACE,
// 
//     /**
//      * Empty space in a lot
//      */
//     LOT_EMPTY,
// 
//     /**
//      * A simple building's floor
//      */
//     BUILDING_FLOOR,
// 
//     /**
//      * A simple building's foundation
//      */
//     BUILDING_FOUNDATION,
// 
//     /**
//      * A simple building wall
//      */
//     BUILDING_WALL,
// 
//     /**
//      * Flat roof
//      */
//     ROOF_FLAT,
// 
//     /**
//      * Hip roof
//      */
//     ROOF_HIP,
// 
//     /**
//      * Dome roof
//      */
//     ROOF_DOME,
// 
//     /**
//      * The roof gable for saddle roofs
//      */
//     ROOF_GABLE,
// 
//     /**
//      * Saddle roof
//      */
//     ROOF_SADDLE,
// 
//     /**
//      * Tower stone
//      */
//     TOWER_WALL,
// 
//     /**
//      * Fence
//      */
//     FENCE,
// 
//     /**
//      * Fence gate
//      */
//     FENCE_GATE,
// 
//     /**
//      * Tower staircase
//      */
//     TOWER_STAIRS,
// 
//     /**
//      * A barrel
//      */
//     BARREL,
// 
//     /**
//      * A torch
//      */
//     TORCH,
// 
//     /**
//      * Pillar material
//      */
//     PILLAR_TOP,
// 
//     /**
//      * Pillar material
//      */
//     PILLAR_MIDDLE,
// 
//     /**
//      * Pillar material
//      */
//     PILLAR_BASE,
// 
//     /**
//      * A ladder element
//      */
//     LADDER
// }


import com.google.common.base.Function;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.cities.BlockType;
import org.terasology.cities.DefaultBlockType;
import org.terasology.engine.math.Side;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac;
import org.terasology.engine.world.block.BlockRegion;
import org.terasology.math.TeraMath;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.util.Set;
/*
 * Copyright 2015 MovingBlocks
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.terasology.cities.raster;



/**
 * Converts model elements into pixels in an image.
 */
public class ImageRasterTarget implements RasterTarget {

    private static final Logger logger = LoggerFactory.getLogger(ImageRasterTarget.class);

    private final Function<BlockType, Color> blockColor;
    private final BlockAreac area;

    private final BufferedImage image;
    private final short[][] heightMap;      // [x][z]
    private final BlockType[][] typeMap;   // [x][z]

    private final int wz;
    private final int wx;

    private BlockRegion region;

    /**
     * @param wx the world block x of the top-left corner
     * @param wz the world block z of the top-left corner
     * @param image the image to draw onto
     * @param blockColor a mapping String type -> block
     */
    public ImageRasterTarget(int wx, int wz, BufferedImage image, Function<BlockType, Color> blockColor) {
        this.blockColor = blockColor;
        this.image = image;
        this.wx = wx;
// Path: src/main/java/org/terasology/cities/BlockType.java
// public interface BlockType {
//     // empty marker
// }
// 
// Path: src/main/java/org/terasology/cities/DefaultBlockType.java
// public enum DefaultBlockType implements BlockType {
// 
//     /**
//      * Air
//      */
//     AIR,
// 
//     /**
//      * Windows
//      */
//     WINDOW_GLASS,
// 
//     /**
//      * A single-block door element
//      */
//     SIMPLE_DOOR,
// 
//     /**
//      * A two-folded wing door
//      */
//     WING_DOOR,
// 
//     /**
//      * Fill material under the surface of a road
//      */
//     ROAD_FILL,
// 
//     /**
//      * Surface of a road (asphalt)
//      */
//     ROAD_SURFACE,
// 
//     /**
//      * Empty space in a lot
//      */
//     LOT_EMPTY,
// 
//     /**
//      * A simple building's floor
//      */
//     BUILDING_FLOOR,
// 
//     /**
//      * A simple building's foundation
//      */
//     BUILDING_FOUNDATION,
// 
//     /**
//      * A simple building wall
//      */
//     BUILDING_WALL,
// 
//     /**
//      * Flat roof
//      */
//     ROOF_FLAT,
// 
//     /**
//      * Hip roof
//      */
//     ROOF_HIP,
// 
//     /**
//      * Dome roof
//      */
//     ROOF_DOME,
// 
//     /**
//      * The roof gable for saddle roofs
//      */
//     ROOF_GABLE,
// 
//     /**
//      * Saddle roof
//      */
//     ROOF_SADDLE,
// 
//     /**
//      * Tower stone
//      */
//     TOWER_WALL,
// 
//     /**
//      * Fence
//      */
//     FENCE,
// 
//     /**
//      * Fence gate
//      */
//     FENCE_GATE,
// 
//     /**
//      * Tower staircase
//      */
//     TOWER_STAIRS,
// 
//     /**
//      * A barrel
//      */
//     BARREL,
// 
//     /**
//      * A torch
//      */
//     TORCH,
// 
//     /**
//      * Pillar material
//      */
//     PILLAR_TOP,
// 
//     /**
//      * Pillar material
//      */
//     PILLAR_MIDDLE,
// 
//     /**
//      * Pillar material
//      */
//     PILLAR_BASE,
// 
//     /**
//      * A ladder element
//      */
//     LADDER
// }


// Path: src/main/java/org/terasology/cities/raster/ImageRasterTarget.java
import com.google.common.base.Function;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.cities.BlockType;
import org.terasology.cities.DefaultBlockType;
import org.terasology.engine.math.Side;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac;
import org.terasology.engine.world.block.BlockRegion;
import org.terasology.math.TeraMath;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.util.Set;

/*
 * Copyright 2015 MovingBlocks
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.terasology.cities.raster;



/**
 * Converts model elements into pixels in an image.
 */
public class ImageRasterTarget implements RasterTarget {

    private static final Logger logger = LoggerFactory.getLogger(ImageRasterTarget.class);

    private final Function<BlockType, Color> blockColor;
    private final BlockAreac area;

    private final BufferedImage image;
    private final short[][] heightMap;      // [x][z]
    private final BlockType[][] typeMap;   // [x][z]

    private final int wz;
    private final int wx;

    private BlockRegion region;

    /**
     * @param wx the world block x of the top-left corner
     * @param wz the world block z of the top-left corner
     * @param image the image to draw onto
     * @param blockColor a mapping String type -> block
     */
    public ImageRasterTarget(int wx, int wz, BufferedImage image, Function<BlockType, Color> blockColor) {
        this.blockColor = blockColor;
        this.image = image;
        this.wx = wx;
        this.wz = wz;