public final void setHeightAt(short x, short y, byte height) { this.heightGrid[x + y * width] = height; backgroundListener.backgroundShapeChangedAt(x, y); }
public void flattenAndChangeHeightTowards(int x, int y, byte targetHeight) { final int index = x + y * width; this.heightGrid[index] += Math.signum(targetHeight - this.heightGrid[index]); this.landscapeGrid[index] = ELandscapeType.FLATTENED.ordinal; this.temporaryFlatened[index] = Byte.MAX_VALUE; // cancel the flattening backgroundListener.backgroundShapeChangedAt(x, y); }
public final void setLandscapeTypeAt(int x, int y, ELandscapeType landscapeType) { if (landscapeType == ELandscapeType.FLATTENED && this.landscapeGrid[x + y * width] != ELandscapeType.FLATTENED.ordinal) { flattenedResetter.addPosition(x, y); } this.landscapeGrid[x + y * width] = landscapeType.ordinal; backgroundListener.backgroundShapeChangedAt(x, y); }
public void setHeight(int x, int y, int height) { byte safeHeight; if (height >= Byte.MAX_VALUE) { safeHeight = Byte.MAX_VALUE; } else if (height <= 0) { safeHeight = 0; } else { safeHeight = (byte) height; } undoDelta.addHeightChange(x, y, heights[x][y]); heights[x][y] = safeHeight; if (backgroundListener != null) { backgroundListener.backgroundShapeChangedAt((short) x, (short) y); } }
private boolean setLandscape(int x, int y, ELandscapeType type) { if (objects[x][y] != null) { if (!landscapeAllowsObjects(type)) { return false; } if (objects[x][y] instanceof LandscapeConstraint) { LandscapeConstraint constraint = (LandscapeConstraint) objects[x][y]; if (!constraint.getAllowedLandscapes().contains(type)) { return false; } } } undoDelta.addLandscapeChange(x, y, landscapes[x][y]); landscapes[x][y] = type; if (backgroundListener != null) { backgroundListener.backgroundShapeChangedAt((short) x, (short) y); } return true; }
inverse.addHeightChange(c.x, c.y, heights[c.x][c.y]); heights[c.x][c.y] = c.height; backgroundListener.backgroundShapeChangedAt(c.x, c.y); c = c.next; inverse.addLandscapeChange(cl.x, cl.y, landscapes[cl.x][cl.y]); landscapes[cl.x][cl.y] = cl.landscape; backgroundListener.backgroundShapeChangedAt(cl.x, cl.y); cl = cl.next;