Added resources to the game and prepared scripts for later usage

This commit is contained in:
=
2026-04-29 18:03:43 +02:00
parent 253c7d9f89
commit c54ff3088e
15 changed files with 102 additions and 56 deletions
+10 -7
View File
@@ -5,7 +5,6 @@ using System.Linq;
using static WFC;
public partial class Layer : Node3D
{
Random rand = new Random();
private Node3D decorationRoot;
public Tile[,] tiles;
int layerSize;
@@ -14,10 +13,12 @@ public partial class Layer : Node3D
bool updateFailed = false;
public bool hasContentGenerated = false;
public Vector2I gateCoordinate;
public List<string> currentResources;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
currentResources = new();
decorationRoot = new Node3D
{
Name = "Decorations"
@@ -28,6 +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()
@@ -62,14 +64,14 @@ public partial class Layer : Node3D
{
Vector3 position;
float offsetX;
float offsetY = level * 4 * -1;
float offsetY = level * GameData.tileHeight * -1;
float offsetZ;
for (int x = 0; x < layerSize; x++)
{
offsetX = x * 6;
offsetX = x * GameData.tileWidth;
for (int y = 0; y < layerSize; y++)
{
offsetZ = y * 6;
offsetZ = y * GameData.tileWidth;
position = new Vector3(offsetX, offsetY, offsetZ);
tile = new Tile();
tile.SetMeshes(tileMeshes);
@@ -120,7 +122,7 @@ public partial class Layer : Node3D
if (possibilities.Count == 0)
continue;
tile.Collapse(possibilities[rand.Next(possibilities.Count)]);
tile.Collapse(possibilities[GameData.rand.Next(possibilities.Count)]);
Propagate(new Vector2I(x, z));
}
}
@@ -136,14 +138,15 @@ public partial class Layer : Node3D
int posX, posY;
while (true)
{
posX = rand.Next(layerSize);
posY = rand.Next(layerSize);
posX = GameData.rand.Next(layerSize);
posY = GameData.rand.Next(layerSize);
if (tiles[posX, posY].collapsedMesh != null) continue;
if (tiles[posX, posY].tileMeshes.ContainsKey("gate"))
{
tiles[posX, posY].Collapse("gate");
gateCoordinate = new Vector2I(posX, posY);
GD.Print(gateCoordinate);
Propagate(gateCoordinate);
break;
}