Reworked border placement

This commit is contained in:
=
2026-04-28 17:41:18 +02:00
parent 5e4e325ec7
commit c8debc316f
3 changed files with 59 additions and 65 deletions
+25 -3
View File
@@ -36,7 +36,7 @@ public class WFC
public static Dictionary<string, HashSet<Direction>> tileConnections = new Dictionary<string, HashSet<Direction>>
{
["t_right"] = new() { Direction.Backward, Direction.Forward, Direction.Right , Direction.Up},
["t_right"] = new() { Direction.Backward, Direction.Forward, Direction.Right, Direction.Up },
["t_left"] = new() { Direction.Backward, Direction.Forward, Direction.Left, Direction.Up },
["t_up"] = new() { Direction.Left, Direction.Right, Direction.Backward, Direction.Up },
["t_down"] = new() { Direction.Left, Direction.Right, Direction.Forward, Direction.Up },
@@ -54,8 +54,8 @@ public class WFC
["corner_down_left"] = new() { Direction.Forward, Direction.Left, Direction.Up },
["corner_down_right"] = new() { Direction.Forward, Direction.Right, Direction.Up },
["junction"] = new() { Direction.Backward, Direction.Forward, Direction.Left, Direction.Right, Direction.Up},
["gate"] = new() { Direction.Backward, Direction.Forward, Direction.Left, Direction.Right, Direction.Up, Direction.Down}
["junction"] = new() { Direction.Backward, Direction.Forward, Direction.Left, Direction.Right, Direction.Up },
["gate"] = new() { Direction.Backward, Direction.Forward, Direction.Left, Direction.Right, Direction.Up, Direction.Down }
};
public static Dictionary<string, float> weights = new()
@@ -196,4 +196,26 @@ public class WFC
pos.X < layerSize &&
pos.Y < layerSize;
}
public static List<string> GetBorderPossibilities(int x, int z)
{
bool left = x == 0;
bool right = x == GameData.layerSize - 1;
bool top = z == 0;
bool bottom = z == GameData.layerSize - 1;
// Corners
if (left && top) return new() { "corner_down_right" };
if (left && bottom) return new() { "corner_up_right" };
if (right && top) return new() { "corner_down_left" };
if (right && bottom) return new() { "corner_up_left" };
// Edges
if (top) return new() { "straight_left_right", "t_down" };
if (bottom) return new() { "straight_left_right", "t_up" };
if (left) return new() { "straight_up_down", "t_right" };
if (right) return new() { "straight_up_down", "t_left" };
return new();
}
}