Added exploration node to DSL and worked on vertical pathfinding (Closed gates blocked horizontal movement as well)
This commit is contained in:
@@ -13,13 +13,15 @@ public partial class Map : PanelContainer
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
|
||||
ShowMap(true);
|
||||
}
|
||||
|
||||
public void ShowMap()
|
||||
public void ShowMap(bool isUpdate)
|
||||
{
|
||||
|
||||
Visible = !Visible;
|
||||
if (!isUpdate)
|
||||
{
|
||||
Visible = !Visible;
|
||||
}
|
||||
if (!Visible) return;
|
||||
foreach (Node node in grid.GetChildren())
|
||||
{
|
||||
|
||||
@@ -8,7 +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 Dictionary<int, (long fromId, long toId)> verticalConnections = new();
|
||||
|
||||
private static long GetOrCreateId(Vector3I coord)
|
||||
{
|
||||
@@ -27,7 +27,7 @@ public class Pathfinding
|
||||
aStar.Clear();
|
||||
coordToId.Clear();
|
||||
idToCoord.Clear();
|
||||
layerGateIds = new long[GameData.ruinSize];
|
||||
verticalConnections.Clear();
|
||||
nextId = 1;
|
||||
|
||||
for (int y = 0; y < GameData.ruinSize; y++)
|
||||
@@ -45,10 +45,6 @@ public class Pathfinding
|
||||
long id = GetOrCreateId(coord);
|
||||
|
||||
aStar.AddPoint(id, tile.Position);
|
||||
if (tile.collapsedMesh == "gate")
|
||||
{
|
||||
layerGateIds[y] = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,6 +70,19 @@ public class Pathfinding
|
||||
|
||||
long toId = coordToId[to];
|
||||
|
||||
if (from.Y != to.Y && GameData.map[from.Y].tiles[from.X, from.Z].collapsedMesh == "gate")
|
||||
{
|
||||
verticalConnections[from.Y] = (fromId, toId);
|
||||
if (GameData.map[from.Y].isGateOpen)
|
||||
{
|
||||
if (!aStar.ArePointsConnected(fromId, toId))
|
||||
{
|
||||
aStar.ConnectPoints(fromId, toId, true);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!aStar.ArePointsConnected(fromId, toId))
|
||||
{
|
||||
aStar.ConnectPoints(fromId, toId);
|
||||
@@ -89,7 +98,21 @@ public class Pathfinding
|
||||
|
||||
public static void UpdateGatePoint(int layer, bool isOpen)
|
||||
{
|
||||
aStar.SetPointDisabled(layerGateIds[layer], !isOpen);
|
||||
if (!verticalConnections.ContainsKey(layer))
|
||||
return;
|
||||
|
||||
var (fromId, toId) = verticalConnections[layer];
|
||||
|
||||
if (isOpen)
|
||||
{
|
||||
if (!aStar.ArePointsConnected(fromId, toId))
|
||||
aStar.ConnectPoints(fromId, toId, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aStar.ArePointsConnected(fromId, toId))
|
||||
aStar.DisconnectPoints(fromId, toId);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Vector3> GetPath(Vector3I start, Vector3I end)
|
||||
|
||||
@@ -134,7 +134,7 @@ public partial class Tile
|
||||
ContentNode.AddChild(decoration);
|
||||
if (!key.ToLower().Contains("gate"))
|
||||
{
|
||||
decoration.LookAt(transform.Origin, Vector3.Up);
|
||||
//decoration.LookAt(transform.Origin, Vector3.Up);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ public class WFC
|
||||
}
|
||||
else
|
||||
{
|
||||
return fromTile.collapsedMesh == "gate" && GameData.map[from.Y].isGateOpen;
|
||||
return fromTile.collapsedMesh == "gate";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user