forked from SteamWar/SteamWar
Update DynamicRegionSystem
This commit is contained in:
+32
-3
@@ -23,17 +23,16 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.region.WireframeCommand;
|
||||
import de.steamwar.bausystem.region.dynamic.*;
|
||||
import de.steamwar.bausystem.region.dynamic.global.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.path.PathRegion;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
@@ -162,6 +161,36 @@ public class DynamicRegionSystem implements RegionSystem {
|
||||
return regionTypeMap.getOrDefault(type, Collections.emptySet()).stream();
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public static class Neighbour<T extends Region> {
|
||||
public final T region;
|
||||
public final Tile tile;
|
||||
public final NeighbourDirection direction;
|
||||
|
||||
public <O extends Region> Neighbour<O> as(Class<O> clazz) {
|
||||
if (!clazz.isInstance(region)) {
|
||||
return null;
|
||||
} else {
|
||||
return (Neighbour<O>) this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Neighbour<?> neighbour)) return false;
|
||||
return Objects.equals(tile, neighbour.tile) && direction == neighbour.direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(tile, direction);
|
||||
}
|
||||
}
|
||||
|
||||
private Stream<Neighbour<Region>> getNeighbours2(Region region, boolean noCorners, boolean fastCache, Collection<Region> regions) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private Stream<Pair<Region, NeighbourDirection>> getNeighbours(Region region, boolean noCorners, boolean fastCache, Collection<Region> regions) {
|
||||
Point minPoint = region.getArea().getMinPoint(false).subtract(TILE_SIZE_ADJUSTED, 0, TILE_SIZE_ADJUSTED);
|
||||
Point maxPoint = region.getArea().getMaxPoint(false).add(Tile.tileSize, 0, Tile.tileSize);
|
||||
|
||||
Reference in New Issue
Block a user