Refresh fix, Dungeon Builder v2
This commit is contained in:
@@ -18,6 +18,33 @@ public class DungeonLayoutV2 : DungeonLayout
|
||||
/// </summary>
|
||||
public List<TileMapSheetInfo> TileMapSheets { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Placed objects (decorations, containers, traps)
|
||||
/// </summary>
|
||||
public List<PlacedObject> Objects { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Player spawn position
|
||||
/// </summary>
|
||||
public int PlayerSpawnX { get; set; }
|
||||
public int PlayerSpawnY { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Exit portal position
|
||||
/// </summary>
|
||||
public int ExitX { get; set; }
|
||||
public int ExitY { get; set; }
|
||||
|
||||
public DungeonLayoutV2() : base() { }
|
||||
|
||||
public DungeonLayoutV2(int width, int height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
Tiles = new int[width, height];
|
||||
Walkable = new bool[width, height];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Build tile data optimized for client transmission
|
||||
/// </summary>
|
||||
@@ -31,6 +58,14 @@ public class DungeonLayoutV2 : DungeonLayout
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
// Also add sheets from direct SheetId references
|
||||
var directSheetIds = TileDetails
|
||||
.Where(t => t.SheetId > 0)
|
||||
.Select(t => t.SheetId)
|
||||
.Distinct();
|
||||
sheetIds.AddRange(directSheetIds);
|
||||
sheetIds = sheetIds.Distinct().ToList();
|
||||
|
||||
var sheets = tileDefinitions.Values
|
||||
.Where(t => sheetIds.Contains(t.TileMapSheetId))
|
||||
.Select(t => t.TileMapSheet)
|
||||
@@ -76,7 +111,8 @@ public class DungeonLayoutV2 : DungeonLayout
|
||||
height = Height,
|
||||
tileSize = TileSize,
|
||||
tilesRLE = SerializeTilesRLE(),
|
||||
spawn = new { x = SpawnPoint.X, y = SpawnPoint.Y },
|
||||
spawn = new { x = PlayerSpawnX > 0 ? PlayerSpawnX : SpawnPoint.X, y = PlayerSpawnY > 0 ? PlayerSpawnY : SpawnPoint.Y },
|
||||
exit = new { x = ExitX, y = ExitY },
|
||||
rooms = Rooms.Select(r => new
|
||||
{
|
||||
x = r.X, y = r.Y, w = r.Width, h = r.Height,
|
||||
@@ -96,7 +132,23 @@ public class DungeonLayoutV2 : DungeonLayout
|
||||
type = c.ChestType.ToString(),
|
||||
roomIndex = c.RoomIndex
|
||||
}),
|
||||
// New: Visual tile data
|
||||
// Objects (decorations, containers, traps)
|
||||
objects = Objects.Select(o => new
|
||||
{
|
||||
x = o.X,
|
||||
y = o.Y,
|
||||
id = o.ObjectTemplateId,
|
||||
name = o.Name,
|
||||
type = o.Type,
|
||||
sheetId = o.SpriteSheetId,
|
||||
frame = o.FrameIndex,
|
||||
blocks = o.BlocksMovement,
|
||||
interact = o.IsInteractable,
|
||||
trap = o.IsTrap,
|
||||
damage = o.TrapDamage,
|
||||
loot = o.LootTableId
|
||||
}),
|
||||
// Tile sheets
|
||||
tileSheets = TileMapSheets.Select(s => new
|
||||
{
|
||||
id = s.Id,
|
||||
@@ -108,11 +160,14 @@ public class DungeonLayoutV2 : DungeonLayout
|
||||
cols = s.Columns,
|
||||
rows = s.Rows
|
||||
}),
|
||||
// Visual tile details
|
||||
visualTiles = TileDetails.Select(t => new
|
||||
{
|
||||
x = t.X,
|
||||
y = t.Y,
|
||||
tid = t.TileDefinitionId,
|
||||
sid = t.SheetId,
|
||||
f = t.FrameIndex,
|
||||
l = t.Layer,
|
||||
r = t.Rotation,
|
||||
fx = t.FlipX,
|
||||
@@ -134,10 +189,12 @@ public class DungeonLayoutV2 : DungeonLayout
|
||||
height = Height,
|
||||
tileSize = TileSize,
|
||||
tilesRLE = SerializeTilesRLE(),
|
||||
spawn = new { x = SpawnPoint.X, y = SpawnPoint.Y },
|
||||
spawn = new { x = PlayerSpawnX > 0 ? PlayerSpawnX : SpawnPoint.X, y = PlayerSpawnY > 0 ? PlayerSpawnY : SpawnPoint.Y },
|
||||
exit = new { x = ExitX, y = ExitY },
|
||||
rooms = Rooms.Select(r => new { x = r.X, y = r.Y, w = r.Width, h = r.Height, type = r.Type.ToString() }),
|
||||
mobs = MobSpawns.Select(m => new { id = m.Id, x = m.X, y = m.Y, type = m.MobType.ToString() }),
|
||||
chests = ChestSpawns.Select(c => new { id = c.Id, x = c.X, y = c.Y, type = c.ChestType.ToString() })
|
||||
chests = ChestSpawns.Select(c => new { id = c.Id, x = c.X, y = c.Y, type = c.ChestType.ToString() }),
|
||||
objects = Objects.Select(o => new { x = o.X, y = o.Y, id = o.ObjectTemplateId, type = o.Type, blocks = o.BlocksMovement })
|
||||
});
|
||||
}
|
||||
|
||||
@@ -163,6 +220,8 @@ public class DungeonLayoutV2 : DungeonLayout
|
||||
x = t.X,
|
||||
y = t.Y,
|
||||
tid = t.TileDefinitionId,
|
||||
sid = t.SheetId,
|
||||
f = t.FrameIndex,
|
||||
l = t.Layer,
|
||||
r = t.Rotation,
|
||||
fx = t.FlipX,
|
||||
@@ -170,6 +229,4 @@ public class DungeonLayoutV2 : DungeonLayout
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user