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); } } }
public Materials getMaterials(boolean withRight, boolean withTop) { Materials materials = new Materials(); entities .values() .stream() .forEach( (entity) -> { materials.put(entity.getMaterials()); }); if (withRight) { for (int i = 0; i < Constants.FLOORS_LIMIT; i++) { Wall wall = map.getTile(this, 1, 0).getVerticalWall(i); Wall fence = map.getTile(this, 1, 0).getVerticalFence(i); if (wall != null) { materials.put(wall.getMaterials()); } if (fence != null) { materials.put(fence.getMaterials()); } } } if (withTop) { for (int i = 0; i < Constants.FLOORS_LIMIT; i++) { Wall wall = map.getTile(this, 0, 1).getHorizontalWall(i); Wall fence = map.getTile(this, 0, 1).getHorizontalFence(i); if (wall != null) { materials.put(wall.getMaterials()); } if (fence != null) { materials.put(fence.getMaterials()); } } } return materials; }