Removed popup from the game, added simple options and menu. Added spawn to tiles and reworked content spawning

This commit is contained in:
=
2026-05-01 18:34:48 +02:00
parent 95455597da
commit dd81c2ff2e
13 changed files with 181 additions and 113 deletions
+12 -2
View File
@@ -29,7 +29,7 @@ public partial class Layer : Node3D
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
public void ClearDecorations()
@@ -113,6 +113,8 @@ public partial class Layer : Node3D
{
for (int z = 0; z < layerSize; z++)
{
//Exclude spawn from border generation
if(x == 0 && z == 0) continue;
if (!IsBorder(x, z))
continue;
@@ -135,6 +137,13 @@ public partial class Layer : Node3D
private void GenerateNecessaryTiles()
{
//Generate spawn only in the first layer
if (level == 0)
{
tiles[0,0].Collapse("spawn");
Propagate(new Vector2I());
}
//Randomly position the gate to the next layer
int posX, posY;
while (true)
{
@@ -146,11 +155,12 @@ public partial class Layer : Node3D
{
tiles[posX, posY].Collapse("gate");
gateCoordinate = new Vector2I(posX, posY);
GD.Print(gateCoordinate);
Propagate(gateCoordinate);
break;
}
}
}
public bool GenerateLayer(Vector2I collapseOrigin)
+1
View File
@@ -78,6 +78,7 @@ public partial class Tile
public void SpawnContent(Dictionary<string, MeshInstance3D> contentMeshes, Transform3D transform, List<Placeholder> placeholders)
{
if(!wasVisited) return;
foreach (Placeholder placeholder in placeholders)
{
if (containsLight && placeholder.name == "light") SpawnLight(contentMeshes["light"], placeholder, transform);
+5 -2
View File
@@ -66,7 +66,9 @@ public class WFC
["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 }
["gate"] = new() { Direction.Backward, Direction.Forward, Direction.Left, Direction.Right, Direction.Up, Direction.Down },
["spawn"] = new() { Direction.Forward, Direction.Left },
};
public static Dictionary<string, float> weights = new()
@@ -90,7 +92,8 @@ public class WFC
["end_left"] = 0.2f,
["end_right"] = 0.3f,
["gate"] = 0.0f
["gate"] = 0.0f,
["spawn"] = 0.0f
};
public static Direction Opposite(Direction dir)
+10 -1
View File
@@ -90,7 +90,7 @@ public partial class World : Node3D
{
Robot robot = ResourceLoader.LoadRobotPrefab().Instantiate<Robot>();
robot.Name = $"Robot #{robots.Count + 1}";
robot.Position = map[0].tiles[rand.Next(layerSize), rand.Next(layerSize)].Position;
robot.Position = map[0].tiles[0,0].Position;
AddChild(robot);
robots.Add(robot);
}
@@ -113,6 +113,15 @@ public partial class World : Node3D
map[layer] = layerNode;
}
map[0].tiles[0,0].wasVisited = true;
map[0].tiles[0,0].containsDecoration = true;
map[0].tiles[0,0].containsLight = true;
map[0].tiles[0,0].containsResource = false;
}
private void HandleTileVisit(int level)
{
HandleRenderData(BuildRenderData(level));
}
private List<TileRenderData> BuildRenderData(int layerIndex)