Big project cleanup with overhaul of file responsibilities (KISS) and code (DRY, YAGNI)

This commit is contained in:
2026-05-14 11:17:02 +02:00
parent bd6cdeb97b
commit 300c8f5a42
54 changed files with 2030 additions and 1745 deletions
-94
View File
@@ -629,98 +629,4 @@ public partial class TestRunner : Node
AssertTrue(hasStartNode, "start node prefab loaded");
}
private Layer CreateTestLayer(int level, string collapsedMesh)
{
Layer layer = new Layer
{
level = level,
currentResources = new List<string> { "stone" },
gateIngredients = new List<Ingredient>(),
tiles = new Tile[1, 1]
};
Tile tile = new Tile
{
GridPosition = new Vector2I(0, 0),
Position = Vector3.Zero,
collapsedMesh = collapsedMesh,
containsResource = true,
resource = new GameResource("stone")
};
layer.tiles[0, 0] = tile;
return layer;
}
private bool IsGeneratedLayerValid(Layer layer)
{
bool hasGate = false;
foreach (Tile tile in layer.tiles)
{
if (tile.collapsedMesh == null)
{
return false;
}
if (tile.collapsedMesh == "gate")
{
hasGate = true;
}
}
if (!hasGate)
{
return false;
}
return WFC.IsMapConnected(layer.tiles, 1f);
}
private Godot.Collections.Dictionary CreateConnection(
string fromNode,
int fromPort,
string toNode,
int toPort
)
{
Godot.Collections.Dictionary connection = new Godot.Collections.Dictionary();
connection["from_node"] = new StringName(fromNode);
connection["from_port"] = fromPort;
connection["to_node"] = new StringName(toNode);
connection["to_port"] = toPort;
return connection;
}
private void AssertTrue(bool value, string message)
{
if (!value)
{
throw new Exception(message);
}
}
private void AssertFalse(bool value, string message)
{
if (value)
{
throw new Exception(message);
}
}
private void AssertEqual<T>(T expected, T actual, string message)
{
if (!EqualityComparer<T>.Default.Equals(expected, actual))
{
throw new Exception($"{message}: expected {expected}, got {actual}");
}
}
private void AssertClose(float expected, float actual, float tolerance, string message)
{
if (Math.Abs(expected - actual) > tolerance)
{
throw new Exception($"{message}: expected {expected}, got {actual}");
}
}
}