Altering Escape

This commit is contained in:
dingo
2025-12-16 21:12:23 -05:00
parent 086a1e15bb
commit 6438e610ce
3 changed files with 134 additions and 22 deletions
+49
View File
@@ -24,6 +24,7 @@ public class DungeonSimulation
public ConcurrentDictionary<int, MobInstance> Mobs { get; } = new();
public ConcurrentDictionary<int, ChestInstance> Chests { get; } = new();
public ConcurrentDictionary<int, DroppedItem> DroppedItems { get; } = new();
public ConcurrentDictionary<int, PortalInstance> Portals { get; } = new();
// Combat tracking
private readonly List<DamageEvent> _pendingDamageEvents = new();
@@ -40,6 +41,54 @@ public class DungeonSimulation
SpawnMobs();
InitializeChests();
SpawnExitPortal();
}
private void SpawnExitPortal()
{
// Spawn exit portal near the entrance room (but offset so players don't spawn on it)
if (Layout.Rooms.Count == 0) return;
var entranceRoom = Layout.Rooms[0];
// Find a valid floor tile near the entrance that's not at the exact center
// Try positions around the room center
var offsets = new[] { (2, 0), (-2, 0), (0, 2), (0, -2), (2, 2), (-2, -2) };
foreach (var (dx, dy) in offsets)
{
int portalTileX = entranceRoom.CenterX + dx;
int portalTileY = entranceRoom.CenterY + dy;
// Check if this is a valid floor tile
if (portalTileX >= 0 && portalTileX < Layout.Width &&
portalTileY >= 0 && portalTileY < Layout.Height &&
Layout.Tiles[portalTileX, portalTileY] == 1) // 1 = floor
{
var portal = new PortalInstance
{
Id = 1,
X = portalTileX * 32 + 16, // Center of tile in world coords
Y = portalTileY * 32 + 16,
Type = PortalType.Exit,
IsActive = true
};
Portals[portal.Id] = portal;
return;
}
}
// Fallback: spawn at room center if no offset worked
var fallbackPortal = new PortalInstance
{
Id = 1,
X = entranceRoom.CenterX * 32 + 16,
Y = entranceRoom.CenterY * 32 + 16,
Type = PortalType.Exit,
IsActive = true
};
Portals[fallbackPortal.Id] = fallbackPortal;
}
private void SpawnMobs()