forked from SteamWar/SteamWar
Add DynamicRegionVisualizer
This commit is contained in:
+13
@@ -100,6 +100,19 @@ public class DynamicRegionSystem implements RegionSystem {
|
||||
return GlobalRegion.INSTANCE;
|
||||
}
|
||||
|
||||
public Set<Tile> getTilesOfRegion(@NonNull Region region) {
|
||||
Point minPoint = region.getArea().getMinPoint(false);
|
||||
Point maxPoint = region.getArea().getMaxPoint(false);
|
||||
|
||||
Set<Tile> tiles = new HashSet<>();
|
||||
for (int x = minPoint.getX(); x < maxPoint.getX(); x += Tile.tileSize) {
|
||||
for (int z = minPoint.getZ(); z < maxPoint.getZ(); z += Tile.tileSize) {
|
||||
tiles.add(Tile.fromXZ(x, z).orElseThrow());
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableSet(tiles);
|
||||
}
|
||||
|
||||
public @NonNull Region get(@Nullable Tile tile) {
|
||||
if (tile == null) return getGlobalRegion();
|
||||
return get(tile.getCenterLocation().getBlockX(), tile.getCenterLocation().getBlockZ(), true, regionMap.values());
|
||||
|
||||
Reference in New Issue
Block a user