Dungeon improvements

This commit is contained in:
dingo
2025-12-28 14:22:57 -05:00
parent 1b3e47e5c2
commit 965694406d
3 changed files with 60 additions and 24 deletions
+13 -23
View File
@@ -92,10 +92,8 @@ public class DungeonSimulation
foreach (var (tileX, tileY) in cornerPositions)
{
// Check if this is a valid floor tile (non-zero = walkable)
if (tileX >= 0 && tileX < Layout.Width &&
tileY >= 0 && tileY < Layout.Height &&
Layout.Tiles[tileX, tileY] != 0) // non-zero = floor
// Check if this is a valid floor tile
if (Layout.IsWalkable(tileX, tileY))
{
// Check surrounding tiles to avoid placing near hallways
bool nearHallway = false;
@@ -105,18 +103,16 @@ public class DungeonSimulation
{
int checkX = tileX + dx;
int checkY = tileY + dy;
if (checkX >= 0 && checkX < Layout.Width && checkY >= 0 && checkY < Layout.Height)
// Check if this position is outside the room bounds (potential hallway)
bool outsideRoom = checkX < entranceRoom.X ||
checkX >= entranceRoom.X + entranceRoom.Width ||
checkY < entranceRoom.Y ||
checkY >= entranceRoom.Y + entranceRoom.Height;
if (outsideRoom && Layout.IsWalkable(checkX, checkY)) // Floor outside room = hallway
{
// Check if this position is outside the room bounds (potential hallway)
bool outsideRoom = checkX < entranceRoom.X ||
checkX >= entranceRoom.X + entranceRoom.Width ||
checkY < entranceRoom.Y ||
checkY >= entranceRoom.Y + entranceRoom.Height;
if (outsideRoom && Layout.Tiles[checkX, checkY] != 0) // Floor outside room = hallway
{
nearHallway = true;
}
nearHallway = true;
}
}
}
@@ -146,9 +142,7 @@ public class DungeonSimulation
int portalTileX = entranceRoom.CenterX + dx;
int portalTileY = entranceRoom.CenterY + dy;
if (portalTileX >= 0 && portalTileX < Layout.Width &&
portalTileY >= 0 && portalTileY < Layout.Height &&
Layout.Tiles[portalTileX, portalTileY] != 0)
if (Layout.IsWalkable(portalTileX, portalTileY))
{
var portal = new PortalInstance
{
@@ -1012,11 +1006,7 @@ public class DungeonSimulation
int tileX = (int)(x / 32);
int tileY = (int)(y / 32);
if (tileX < 0 || tileX >= Layout.Width || tileY < 0 || tileY >= Layout.Height)
return false;
// Any non-zero tile is walkable (0 = void/wall, >0 = floor tile ID or 1 for basic floor)
return Layout.Tiles[tileX, tileY] != 0;
return Layout.IsWalkable(tileX, tileY);
}
private void MoveToward(MobInstance mob, float targetX, float targetY, float speed)