Search in sources :

Example 6 with World2

use of org.pepsoft.worldpainter.World2 in project WorldPainter by Captain-Chaos.

the class SetSpawnPoint method tick.

@Override
protected void tick(int centreX, int centreY, boolean inverse, boolean first, float dynamicLevel) {
    if (first) {
        Dimension dimension = getDimension();
        if ((dimension.getDim() != Constants.DIM_NORMAL) && (dimension.getDim() != Constants.DIM_NORMAL_CEILING)) {
            throw new IllegalArgumentException("Cannot set spawn point on dimensions other than 0");
        }
        World2 world = dimension.getWorld();
        int spawnHeight = dimension.getIntHeightAt(centreX, centreY);
        if (spawnHeight == -1) {
            // No tile
            if (JOptionPane.showConfirmDialog(getView(), "<html>Are you sure you want to set the spawn <em>outside</em> the boundary of the world?</html>") != JOptionPane.OK_OPTION) {
                return;
            }
        }
        world.setSpawnPoint(new Point(centreX, centreY));
    }
}
Also used : World2(org.pepsoft.worldpainter.World2) Dimension(org.pepsoft.worldpainter.Dimension) Point(java.awt.Point) Point(java.awt.Point)

Aggregations

World2 (org.pepsoft.worldpainter.World2)6 FileInputStream (java.io.FileInputStream)5 ObjectInputStream (java.io.ObjectInputStream)5 GZIPInputStream (java.util.zip.GZIPInputStream)5 Dimension (org.pepsoft.worldpainter.Dimension)5 File (java.io.File)3 FileOutputStream (java.io.FileOutputStream)3 ObjectOutputStream (java.io.ObjectOutputStream)3 GZIPOutputStream (java.util.zip.GZIPOutputStream)3 Tile (org.pepsoft.worldpainter.Tile)3 Point (java.awt.Point)1 SecureRandom (java.security.SecureRandom)1 Random (java.util.Random)1 JavaWorldExporter (org.pepsoft.worldpainter.exporting.JavaWorldExporter)1