@Override public boolean hasTileAt(int x, int y) { return getTile(x, y) != null; }
@Override public Tile removeTile(int x, int y) { Tile tmp = getTile(x,y); setTile(x,y,null); return tmp; }
@Override public Tile getTile(int x, int y) { ShortVec2 groupPos = getKey().set((int)Math.floor(x / (float) TileGroup.CHUNK_STEP), (int)Math.floor(y / (float) TileGroup.CHUNK_STEP)); TileGroup tg = tileGroups.get(groupPos); if (tg == null) { return null; } return tg.getTile(x, y); }
public void addData(DimensionData other){ for (Entry<ShortVec2, TileGroup> e:other.tileGroups.entrySet()){ TileGroup group = e.getValue(); Rect s = group.getScope(); for (int x = s.minX; x <= s.maxX; x++){ for (int y = s.minY; y <= s.maxY; y++){ Tile tile = group.getTile(x, y); if (tile != null) setTile(x, y, tile); } } } }
/** * This function has to create a new map on each call since the packet rework */ public Map<ShortVec2, Tile> getSeenChunks() { Map<ShortVec2, Tile> chunks = new ConcurrentHashMap<ShortVec2, Tile>(2, 0.75f, 2); Tile t = null; for (Map.Entry<ShortVec2, TileGroup> entry: tileGroups.entrySet()){ int basex = entry.getValue().getScope().minX; int basey = entry.getValue().getScope().minY; for (int x = basex; x < basex+TileGroup.CHUNK_STEP; x++){ for (int y = basey; y < basey+TileGroup.CHUNK_STEP; y++){ t = entry.getValue().getTile(x, y); if (t!=null){ chunks.put(new ShortVec2(x, y), t); } } } } return chunks; }