void setLabel(Label label, boolean undo) { Tile oldTile = new Tile(this); this.label = label; if (undo) { map.addUndo(this, oldTile); } }
void setCaveLabel(Label caveLabel, boolean undo) { Tile oldTile = new Tile(this); this.caveLabel = caveLabel; if (undo) { map.addUndo(this, oldTile); } }
void setTileContent(TileEntity entity, int level, boolean undo) { if (!isFlat()) { return; } if (entity instanceof Roof) { for (TileEntity e : entities.values()) { if (e instanceof Roof) { return; } } } final EntityData entityData = new EntityData(level, EntityType.FLOORROOF); if (entity != entities.get(entityData)) { Tile oldTile = new Tile(this); if (entity != null) { entities.put(entityData, entity); } else { entities.remove(entityData); } if (undo) { map.addUndo(this, oldTile); } } }
void setVerticalWall(WallData wall, int level, boolean undo) { if (wall != null && wall.houseWall) { if (!(isFlat() || map.getTile(this, -1, 0).isFlat())) { return; } } final EntityData entityData; if (wall != null && wall.houseWall) { entityData = new EntityData(level, EntityType.VWALL); } else if (wall != null) { entityData = new EntityData(level, EntityType.VFENCE); } else { entityData = null; } final EntityData wallEntity = new EntityData(level, EntityType.VWALL); final EntityData fenceEntity = new EntityData(level, EntityType.VFENCE); final Wall currentWall = (Wall) entities.get(wallEntity); final Wall currentFence = (Wall) entities.get(fenceEntity); boolean reversed; if (wall != null && wall.houseWall) { if (Globals.autoReverseWall) { reversed = getTileContent(level) == null && map.getTile(this, -1, 0).getTileContent(level) != null; if (reversed == false) { reversed = Globals.reverseWall; } } else { reversed = Globals.reverseWall; } } else { reversed = false; } if (!(new Wall(wall, reversed).equals(entities.get(entityData)))) { Tile oldTile = new Tile(this); if (wall != null) { entities.put(entityData, new Wall(wall, reversed)); if (wall.houseWall && !(wall.arch && currentFence != null && currentFence.data.archBuildable)) { entities.remove(fenceEntity); } else if (!wall.houseWall && !(wall.archBuildable && currentWall != null && currentWall.data.arch)) { entities.remove(wallEntity); } } else { entities.remove(wallEntity); entities.remove(fenceEntity); } if (undo) { map.addUndo(this, oldTile); } } }
void setCaveEntity(CaveData entity, boolean undo) { if (this.cave != entity) { Tile oldTile = new Tile(this); this.cave = entity; if (undo) { map.addUndo(this, oldTile); } } }
void setCaveHeight(int height, boolean undo) { if (this.caveHeight != height) { Tile oldTile = new Tile(this); this.caveHeight = height; map.recalculateHeight(); if (undo) { map.addUndo(this, oldTile); } } }
void setGameObject(GameObjectData data, ObjectLocation location, int floor, boolean undo) { Tile oldTile = new Tile(this); if (data != null) { entities.put(new ObjectEntityData(floor, location), new GameObject(data)); } else { entities.remove(new ObjectEntityData(floor, location)); } if (undo) { map.addUndo(this, oldTile); } }
void setCaveSize(int size, boolean undo) { if (size < 30 || size > 300) { return; } if (this.caveSize != size) { Tile oldTile = new Tile(this); this.caveSize = size; map.recalculateHeight(); if (undo) { map.addUndo(this, oldTile); } } }
void setGround(GroundData data, RoadDirection dir, boolean undo) { if (!new Ground(data).equals(ground)) { Tile oldTile = new Tile(this); if (!data.diagonal) { dir = RoadDirection.CENTER; } ground = new Ground(data, dir); if (undo) { map.addUndo(this, oldTile); } } }
void setVerticalBorder(BorderData border, boolean undo) { final EntityData entityData = new EntityData(0, EntityType.VBORDER); if (border != entities.get(entityData)) { Tile oldTile = new Tile(this); if (border != null) { entities.put(entityData, border); } else { entities.remove(entityData); } if (undo) { map.addUndo(this, oldTile); } } }