Added more symbols to the game, added gates blocking pathfinding and improved DSL feedback system with enum for better control and UX
This commit is contained in:
@@ -14,6 +14,7 @@ public partial class Layer : Node3D
|
||||
public bool hasContentGenerated = false;
|
||||
public Vector2I gateCoordinate;
|
||||
public List<string> currentResources;
|
||||
public bool isGateOpen = false;
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
@@ -89,7 +90,7 @@ public partial class Layer : Node3D
|
||||
var node = new Node3D
|
||||
{
|
||||
Position = tile.Position,
|
||||
Visible = false
|
||||
Visible = tile.collapsedMesh != null && tile.collapsedMesh == "gate"
|
||||
};
|
||||
decorationRoot.AddChild(node);
|
||||
|
||||
@@ -115,7 +116,7 @@ public partial class Layer : Node3D
|
||||
for (int z = 0; z < layerSize; z++)
|
||||
{
|
||||
//Exclude spawn from border generation
|
||||
if(x == 0 && z == 0) continue;
|
||||
if(x == 0 && z == 0 && level == 0) continue;
|
||||
if (!IsBorder(x, z))
|
||||
continue;
|
||||
|
||||
@@ -155,6 +156,7 @@ public partial class Layer : Node3D
|
||||
if (tiles[posX, posY].tileMeshes.ContainsKey("gate"))
|
||||
{
|
||||
tiles[posX, posY].Collapse("gate");
|
||||
tiles[posX, posY].containsDecoration = true;
|
||||
gateCoordinate = new Vector2I(posX, posY);
|
||||
Propagate(gateCoordinate);
|
||||
break;
|
||||
|
||||
@@ -8,6 +8,7 @@ public class Pathfinding
|
||||
private static Dictionary<Vector3I, long> coordToId = new();
|
||||
private static Dictionary<long, Vector3I> idToCoord = new();
|
||||
private static long nextId = 1;
|
||||
private static long[] layerGateIds = new long[GameData.ruinSize];
|
||||
|
||||
private static long GetOrCreateId(Vector3I coord)
|
||||
{
|
||||
@@ -26,6 +27,7 @@ public class Pathfinding
|
||||
aStar.Clear();
|
||||
coordToId.Clear();
|
||||
idToCoord.Clear();
|
||||
layerGateIds = new long[GameData.ruinSize];
|
||||
nextId = 1;
|
||||
|
||||
for (int y = 0; y < GameData.ruinSize; y++)
|
||||
@@ -43,6 +45,10 @@ public class Pathfinding
|
||||
long id = GetOrCreateId(coord);
|
||||
|
||||
aStar.AddPoint(id, tile.Position);
|
||||
if (tile.collapsedMesh == "gate")
|
||||
{
|
||||
layerGateIds[y] = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,6 +80,16 @@ public class Pathfinding
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = 0; y < GameData.ruinSize; y++)
|
||||
{
|
||||
UpdateGatePoint(y, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateGatePoint(int layer, bool isOpen)
|
||||
{
|
||||
aStar.SetPointDisabled(layerGateIds[layer], !isOpen);
|
||||
}
|
||||
|
||||
public static List<Vector3> GetPath(Vector3I start, Vector3I end)
|
||||
|
||||
@@ -132,7 +132,10 @@ public partial class Tile
|
||||
Position = placeholder.transform.Origin
|
||||
};
|
||||
ContentNode.AddChild(decoration);
|
||||
decoration.LookAt(transform.Origin, Vector3.Up);
|
||||
if (!key.ToLower().Contains("gate"))
|
||||
{
|
||||
decoration.LookAt(transform.Origin, Vector3.Up);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ public class WFC
|
||||
}
|
||||
else
|
||||
{
|
||||
return fromTile.collapsedMesh == "gate";
|
||||
return fromTile.collapsedMesh == "gate" && GameData.map[from.Y].isGateOpen;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user