use of org.pepsoft.worldpainter.TileFactory in project WorldPainter by Captain-Chaos.
the class Sponge method tick.
@Override
protected void tick(int centreX, int centreY, boolean inverse, boolean first, float dynamicLevel) {
final int waterHeight;
final Dimension dimension = getDimension();
final TileFactory tileFactory = dimension.getTileFactory();
if (tileFactory instanceof HeightMapTileFactory) {
waterHeight = ((HeightMapTileFactory) tileFactory).getWaterHeight();
} else {
// If we can't determine the water height disable the inverse
// functionality, which resets to the default water height
waterHeight = -1;
}
dimension.setEventsInhibited(true);
try {
final int radius = getEffectiveRadius();
for (int dx = -radius; dx <= radius; dx++) {
for (int dy = -radius; dy <= radius; dy++) {
if (getStrength(centreX, centreY, centreX + dx, centreY + dy) != 0f) {
if (inverse) {
if (waterHeight != -1) {
dimension.setWaterLevelAt(centreX + dx, centreY + dy, waterHeight);
dimension.setBitLayerValueAt(FloodWithLava.INSTANCE, centreX + dx, centreY + dy, false);
}
} else {
dimension.setWaterLevelAt(centreX + dx, centreY + dy, 0);
}
}
}
}
} finally {
dimension.setEventsInhibited(false);
}
}
use of org.pepsoft.worldpainter.TileFactory in project WorldPainter by Captain-Chaos.
the class RepairHeightMap method repairDimension.
private static final boolean repairDimension(Dimension dimension) {
TileFactory tileFactory = dimension.getTileFactory();
if (tileFactory instanceof HeightMapTileFactory) {
HeightMap heightMap = ((HeightMapTileFactory) tileFactory).getHeightMap();
if ((heightMap instanceof SumHeightMap) && ((((SumHeightMap) heightMap).getHeightMap1() == null) || (((SumHeightMap) heightMap).getHeightMap2() == null))) {
System.out.println("Broken height map found in dimension " + dimension.getName() + "; replacing with default height map");
heightMap = new ConstantHeightMap(46);
// heightMap = new SumHeightMap(new ConstantHeightMap(58), new NoiseHeightMap(20, 1.0, 1));
((HeightMapTileFactory) tileFactory).setHeightMap(heightMap);
return true;
}
}
return false;
}
Aggregations