Refresh fix, Dungeon Builder v2
This commit is contained in:
@@ -670,16 +670,16 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<GameDbContext>();
|
||||
|
||||
var generator = new DungeonGeneratorV2(db, seed, tier);
|
||||
var generator = new DungeonGeneratorV3(db, seed, tier);
|
||||
layoutV2 = await generator.GenerateAsync();
|
||||
layout = layoutV2; // V2 extends V1, use directly
|
||||
|
||||
_log.LogInformation("Generated dungeon with V2 generator - {RoomCount} rooms, {TileCount} visual tiles",
|
||||
_log.LogInformation("Generated dungeon with V3 generator - {RoomCount} rooms, {TileCount} visual tiles",
|
||||
layoutV2.Rooms.Count, layoutV2.TileDetails?.Count ?? 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.LogWarning(ex, "V2 dungeon generator failed, falling back to V1");
|
||||
_log.LogWarning(ex, "V3 dungeon generator failed, falling back to V1");
|
||||
layout = DungeonGenerator.Generate(seed, tier);
|
||||
}
|
||||
|
||||
@@ -744,6 +744,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
// Build visual tile data if V2 layout available
|
||||
object? tileSheets = null;
|
||||
object? visualTiles = null;
|
||||
object? placedObjects = null;
|
||||
|
||||
_log.LogInformation("LayoutV2 is null: {IsNull}, TileDetails count: {Count}",
|
||||
instance.LayoutV2 == null, instance.LayoutV2?.TileDetails?.Count ?? 0);
|
||||
@@ -775,8 +776,28 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
fy = t.FlipY
|
||||
}).ToArray();
|
||||
|
||||
_log.LogInformation("Sending {SheetCount} sheets, {TileCount} visual tiles to client",
|
||||
instance.LayoutV2.TileMapSheets.Count, instance.LayoutV2.TileDetails.Count);
|
||||
// V3: Include placed objects (decorations, containers, traps)
|
||||
if (instance.LayoutV2.Objects?.Count > 0)
|
||||
{
|
||||
placedObjects = instance.LayoutV2.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
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
_log.LogInformation("Sending {SheetCount} sheets, {TileCount} visual tiles, {ObjectCount} objects to client",
|
||||
instance.LayoutV2.TileMapSheets.Count, instance.LayoutV2.TileDetails.Count, instance.LayoutV2.Objects?.Count ?? 0);
|
||||
}
|
||||
|
||||
await SendAsync(connection, DungeonOpCodes.DUNGEON_ENTER_RESULT, new
|
||||
@@ -820,9 +841,10 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
y = p.Y,
|
||||
type = p.Type.ToString().ToLower()
|
||||
}),
|
||||
// V2 visual tile data
|
||||
// V3 visual tile data
|
||||
tileSheets,
|
||||
visualTiles
|
||||
visualTiles,
|
||||
placedObjects
|
||||
}, ct);
|
||||
}
|
||||
|
||||
@@ -2152,16 +2174,16 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<GameDbContext>();
|
||||
|
||||
var generator = new DungeonGeneratorV2(db, seed, tier);
|
||||
var generator = new DungeonGeneratorV3(db, seed, tier);
|
||||
layoutV2 = await generator.GenerateAsync();
|
||||
layout = layoutV2; // V2 extends V1, use directly
|
||||
|
||||
_log.LogInformation("Generated dungeon with V2 generator - {RoomCount} rooms, {TileCount} visual tiles",
|
||||
_log.LogInformation("Generated dungeon with V3 generator - {RoomCount} rooms, {TileCount} visual tiles",
|
||||
layoutV2.Rooms.Count, layoutV2.TileDetails?.Count ?? 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.LogWarning(ex, "V2 dungeon generator failed, falling back to V1");
|
||||
_log.LogWarning(ex, "V3 dungeon generator failed, falling back to V1");
|
||||
layout = DungeonGenerator.Generate(seed, tier);
|
||||
}
|
||||
|
||||
@@ -2323,6 +2345,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
// Build visual tile data if V2 layout available
|
||||
object? tileSheets = null;
|
||||
object? visualTiles = null;
|
||||
object? placedObjects = null;
|
||||
|
||||
if (instance.LayoutV2 != null && instance.LayoutV2.TileDetails.Count > 0)
|
||||
{
|
||||
@@ -2350,8 +2373,28 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
fy = t.FlipY
|
||||
}).ToArray();
|
||||
|
||||
_log.LogInformation("Sending {SheetCount} sheets, {TileCount} visual tiles to client",
|
||||
instance.LayoutV2.TileMapSheets.Count, instance.LayoutV2.TileDetails.Count);
|
||||
// V3: Include placed objects (decorations, containers, traps)
|
||||
if (instance.LayoutV2.Objects?.Count > 0)
|
||||
{
|
||||
placedObjects = instance.LayoutV2.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
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
_log.LogInformation("Sending {SheetCount} sheets, {TileCount} visual tiles, {ObjectCount} objects to client",
|
||||
instance.LayoutV2.TileMapSheets.Count, instance.LayoutV2.TileDetails.Count, instance.LayoutV2.Objects?.Count ?? 0);
|
||||
}
|
||||
|
||||
await SendAsync(connection, DungeonOpCodes.DUNGEON_ENTER_RESULT, new
|
||||
@@ -2402,9 +2445,10 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
y = p.Y,
|
||||
type = p.Type.ToString().ToLower()
|
||||
}),
|
||||
// V2 visual tile data
|
||||
// V3 visual tile data
|
||||
tileSheets,
|
||||
visualTiles
|
||||
visualTiles,
|
||||
placedObjects
|
||||
}, ct);
|
||||
|
||||
_log.LogInformation("Player {Name} (Level {Level}) joined dungeon {Id}",
|
||||
|
||||
Reference in New Issue
Block a user