From 12f7f159c61de64f6af2c761ca031d03a66f58d6 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 7 Sep 2026 09:09:08 +0200 Subject: [PATCH] Remove ConnectionType.Void --- .../steamwar/bausystem/region/RegionType.java | 9 ++-- .../region/dynamic/path/PathArea.java | 46 +++++-------------- .../region/dynamic/path/PathRegion.java | 24 ++++++++-- 3 files changed, 36 insertions(+), 43 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionType.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionType.java index 3afd55b3..4a177fad 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionType.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/RegionType.java @@ -26,17 +26,17 @@ import lombok.RequiredArgsConstructor; @Getter public enum RegionType { - GLOBAL(ConnectionType.Void), + GLOBAL(ConnectionType.Water), /** * This should not be used by the DynamicRegionSystem */ NORMAL(ConnectionType.Plot), - SPAWN(ConnectionType.Void), - SPAWN_EXTENSION(ConnectionType.Void), + SPAWN(ConnectionType.Water), + SPAWN_EXTENSION(ConnectionType.Water), PATH(ConnectionType.Path), - DRY(ConnectionType.Void), + DRY(ConnectionType.Water), DRY_SPECIAL(ConnectionType.Plot), WET(ConnectionType.Water), WET_SPECIAL(ConnectionType.Water), @@ -64,7 +64,6 @@ public enum RegionType { Plot, Path, Water, - Void, Garden, } } diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/path/PathArea.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/path/PathArea.java index ec3e6139..c96486f9 100644 --- a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/path/PathArea.java +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/path/PathArea.java @@ -49,10 +49,6 @@ public class PathArea extends Region.Area { private static final VariantSelector CENTER = VariantSelector.Folder("Path", "Center"); - private static final VariantSelector SIDE_VOID = VariantSelector.Folder("Path", "Edge", "Void"); - private static final VariantSelector CORNER_INNER_VOID = VariantSelector.Folder("Path", "Corner", "Inner", "Void"); - private static final VariantSelector CORNER_OUTER_VOID = VariantSelector.Folder("Path", "Corner", "Outer", "Void"); - private static final VariantSelector SIDE_WATER = VariantSelector.Folder("Path", "Edge", "Water"); private static final VariantSelector CORNER_INNER_WATER = VariantSelector.Folder("Path", "Corner", "Inner", "Water"); private static final VariantSelector CORNER_OUTER_WATER = VariantSelector.Folder("Path", "Corner", "Outer", "Water"); @@ -68,12 +64,10 @@ public class PathArea extends Region.Area { private static final VariantSelector CORNER_OUTER_GARDEN = VariantSelector.Get(new File(PATH_DIR, "couter/garden")); private static final VariantSelector TORII_CENTER = VariantSelector.Schematic("Path", "Torii", "Center"); - private static final VariantSelector TORII_SIDE_VOID = VariantSelector.Schematic("Path", "Torii", "Edge_Void"); private static final VariantSelector TORII_SIDE_WATER = VariantSelector.Schematic("Path", "Torii", "Edge_Water"); private static final SelectorSide SELECTOR_SIDE = new SelectorSide() .Case(Path, CENTER) - .Case(Void, SIDE_VOID) .Case(Water, SIDE_WATER) .Case(Plot, SIDE_CLOSED) .Case(Garden, SIDE_GARDEN_CONNECTED); @@ -81,15 +75,7 @@ public class PathArea extends Region.Area { private static final SelectorCorner SELECTOR_CORNER = new SelectorCorner() // Path to Path .Case(Path, Path, Path, CENTER, RotationCorrection.UsingOrdinal) - // Path to Global - .Case(Path, Void, Void, SIDE_VOID, RotationCorrection.WithCorrection) - .Case(Void, Path, Path, SIDE_VOID) - .Case(Void, Path, Void, SIDE_VOID) - .Case(Path, Void, Path, SIDE_VOID, RotationCorrection.WithCorrection) - .Case(Void, Void, Void, CORNER_OUTER_VOID, RotationCorrection.UsingOrdinal) - .Case(Void, Void, Path, CORNER_OUTER_VOID, RotationCorrection.UsingOrdinal) - .Case(Path, Path, Void, CORNER_INNER_VOID, RotationCorrection.UsingOrdinal) - // Path to Water + // Path to Water, Spawn, Global .Case(Path, Water, Water, SIDE_WATER, RotationCorrection.WithCorrection) .Case(Water, Path, Path, SIDE_WATER) .Case(Water, Path, Water, SIDE_WATER) @@ -97,7 +83,7 @@ public class PathArea extends Region.Area { .Case(Water, Water, Water, CORNER_OUTER_WATER, RotationCorrection.UsingOrdinal) .Case(Water, Water, Path, CORNER_OUTER_WATER, RotationCorrection.UsingOrdinal) .Case(Path, Path, Water, CORNER_INNER_WATER, RotationCorrection.UsingOrdinal) - // Path to Closed + // Path to Plot .Case(Path, Plot, Plot, SIDE_CLOSED, RotationCorrection.WithCorrection) .Case(Plot, Path, Path, SIDE_CLOSED) .Case(Plot, Path, Plot, SIDE_CLOSED) @@ -166,12 +152,8 @@ public class PathArea extends Region.Area { public void reset(PathSide side, boolean torii) { SchematicNode reset = null; VariantSelector selector = SELECTOR_SIDE.Select(tile, side); - if (torii) { - if (selector == SIDE_VOID) { - selector = TORII_SIDE_VOID; - } else if (selector == SIDE_WATER) { - selector = TORII_SIDE_WATER; - } + if (torii && selector == SIDE_WATER) { + selector = TORII_SIDE_WATER; } if (selector != null) reset = selector.select().orElse(null); if (selector == null || reset == null) { @@ -237,27 +219,27 @@ public class PathArea extends Region.Area { VariantSelector north = SELECTOR_SIDE.Select(tile, PathSide.North); VariantSelector south = SELECTOR_SIDE.Select(tile, PathSide.South); boolean zAxis = false; - if (isValidTorriVariantSelector(north) && isValidTorriVariantSelector(south)) { + if (north == SIDE_WATER && south == SIDE_WATER) { zAxis = true; } VariantSelector east = SELECTOR_SIDE.Select(tile, PathSide.East); VariantSelector west = SELECTOR_SIDE.Select(tile, PathSide.West); boolean xAxis = false; - if (isValidTorriVariantSelector(east) && isValidTorriVariantSelector(west)) { + if (east == SIDE_WATER && west == SIDE_WATER) { xAxis = true; } if (xAxis && zAxis) return null; VariantSelector northEast = SELECTOR_CORNER.Select(tile, PathCorner.NorthEast).getKey(); - if (!isValidTorriVariantSelector(northEast)) return null; + if (northEast != SIDE_WATER) return null; VariantSelector northWest = SELECTOR_CORNER.Select(tile, PathCorner.NorthWest).getKey(); - if (!isValidTorriVariantSelector(northWest)) return null; + if (northWest != SIDE_WATER) return null; VariantSelector southEast = SELECTOR_CORNER.Select(tile, PathCorner.SouthEast).getKey(); - if (!isValidTorriVariantSelector(southEast)) return null; + if (southEast != SIDE_WATER) return null; VariantSelector southWest = SELECTOR_CORNER.Select(tile, PathCorner.SouthWest).getKey(); - if (!isValidTorriVariantSelector(southWest)) return null; + if (southWest != SIDE_WATER) return null; if (zAxis) { return PathSide.North; @@ -268,17 +250,13 @@ public class PathArea extends Region.Area { } } - private boolean isValidTorriVariantSelector(VariantSelector selector) { - return selector == SIDE_VOID || selector == SIDE_WATER; - } - protected static RegionType.ConnectionType getConnectionType(Tile source, PathSide side, PathSide optionalSide) { Optional optionalTile = source.add(side.tileOffsetX, side.tileOffsetZ); if (optionalSide != null) { optionalTile = optionalTile.flatMap(t -> t.add(optionalSide.tileOffsetX, optionalSide.tileOffsetZ)); } if (optionalTile.isEmpty()) { - return Void; + return Water; } Tile tile = optionalTile.get(); Region region = DynamicRegionSystem.INSTANCE.get(tile); @@ -291,7 +269,7 @@ public class PathArea extends Region.Area { DynamicRegion.PathConnectResult result = dynamicRegion.shouldPathConnect(source, side.opposite(), optionalSide != null); return switch (result) { case ALWAYS -> Path; - case NEVER -> Void; + case NEVER -> Water; default -> region.getType().getConnectionType(); }; } diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/path/PathRegion.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/path/PathRegion.java index e858b9a5..31b5a21f 100644 --- a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/path/PathRegion.java +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/path/PathRegion.java @@ -21,10 +21,7 @@ package de.steamwar.bausystem.region.dynamic.path; import com.google.gson.JsonArray; import com.google.gson.stream.JsonWriter; -import de.steamwar.bausystem.region.DynamicRegionSystem; -import de.steamwar.bausystem.region.RegionBackups; -import de.steamwar.bausystem.region.RegionHistory; -import de.steamwar.bausystem.region.RegionType; +import de.steamwar.bausystem.region.*; import de.steamwar.bausystem.region.dynamic.*; import de.steamwar.sql.GameModeConfig; import lombok.Getter; @@ -123,6 +120,25 @@ public class PathRegion extends DynamicRegion { return; } toriiSide = area.getToriiSide(); + + if (true) return; + // Push Torii State to adjacent Path if valid Torii region! + if (toriiSide != null) return; + for (Tile adjacent : tile.neighboursPlus().toList()) { + Region region = DynamicRegionSystem.INSTANCE.get(adjacent); + if (region instanceof PathRegion pathRegion) { + if (pathRegion.hasAdjacentToriiState()) continue; + pathRegion.toriiSide = pathRegion.area.getToriiSide(); + } + } + } + + private boolean hasAdjacentToriiState() { + for (Tile adjacent : tile.neighboursPlus().toList()) { + Region region = DynamicRegionSystem.INSTANCE.get(adjacent); + if (region instanceof PathRegion pathRegion && pathRegion.toriiSide != null) return true; + } + return false; } @Override