/** * Creates a set of regions from a region id. This is useful in the case where the region is * compound (e.g. NY+LON). * * @param regionSource The region source, not null * @param regionId The region id, not null * @return a set of the region(s) */ public static Set<Region> getRegions(RegionSource regionSource, final ExternalId regionId) { Validate.notNull(regionSource, "region source"); Validate.notNull(regionId, "region id"); if (regionId.isScheme(RegionUtils.FINANCIAL) && regionId.getValue().contains("+")) { final String[] regions = regionId.getValue().split("\\+"); final Set<Region> resultRegions = new HashSet<Region>(); for (final String region : regions) { resultRegions.add( regionSource.getHighestLevelRegion(RegionUtils.financialRegionId(region))); } return resultRegions; } return Collections.singleton(regionSource.getHighestLevelRegion(regionId)); }
@Override public Region getRegion(Point point, boolean load) { int x = MathHelper.floor(point.getX()); int y = MathHelper.floor(point.getY()); int z = MathHelper.floor(point.getZ()); return regions.getRegionFromBlock(x, y, z, load); }
// TODO need world that loads from disk // TODO set up number of stages ? public SpoutWorld(String name, Server server, long seed, WorldGenerator generator) { super(1, new ThreadAsyncExecutor(), server); uid = UUID.randomUUID(); this.server = server; this.seed = seed; this.name = name; this.generator = generator; entityManager = new EntityManager(); regions = new RegionSource(this, snapshotManager); // load spawn regions for (int dx = -1; dx < 1; dx++) { for (int dy = -1; dy < 1; dy++) { for (int dz = -1; dz < 1; dz++) { regions.getRegion(dx, dy, dz, true, true); } } } }
@Override public SpoutRegion getRegion(int x, int y, int z, LoadOption loadopt) { return regions.getRegion(x, y, z, loadopt); }
@Override public void updatePhysics(int x, int y, int z) { regions.getRegionFromBlock(x, y, z).queuePhysicsUpdate(x, y, z); }
@Override public Region getRegionFromBlock(int x, int y, int z) { return regions.getRegionFromBlock(x, y, z); }
@Override public Region getRegion(int x, int y, int z, boolean load) { return regions.getRegion(x, y, z, load); }
@Override public Region getRegion(int x, int y, int z) { return regions.getRegion(x, y, z); }