forked from SteamWar/SteamWar
Improve PathRegion.calculateGardenState
This commit is contained in:
+4
-1
@@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"region_identifier": "SpawnRegion",
|
"region_identifier": "SpawnRegion",
|
||||||
"tiles": [
|
"tiles": [
|
||||||
{ "tile_x": 0, "tile_z": 0 }
|
{
|
||||||
|
"tile_x": 0,
|
||||||
|
"tile_z": 0
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
+8
-13
@@ -29,7 +29,9 @@ import lombok.NonNull;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@RegionConstructorData(
|
@RegionConstructorData(
|
||||||
identifier = "path",
|
identifier = "path",
|
||||||
@@ -81,19 +83,12 @@ public class PathRegion extends DynamicRegion {
|
|||||||
|
|
||||||
public void calculateGardenState() {
|
public void calculateGardenState() {
|
||||||
garden = false;
|
garden = false;
|
||||||
for (int x = -1; x <= 1; x++) {
|
Set<Tile> neighbours = tile.neighboursRing().collect(Collectors.toSet());
|
||||||
for (int z = -1; z <= 1; z++) {
|
if (neighbours.size() == 8) return;
|
||||||
if (x == 0 && z == 0) continue;
|
garden = neighbours.stream()
|
||||||
Tile t = tile.add(x, z).orElse(null);
|
.map(DynamicRegionSystem.INSTANCE::get)
|
||||||
if (t == null) {
|
.map(Region::getType)
|
||||||
return;
|
.allMatch(RegionType::isPath);
|
||||||
}
|
|
||||||
if (!DynamicRegionSystem.INSTANCE.get(t).getType().isPath()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
garden = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user