Loot fix
This commit is contained in:
@@ -423,7 +423,7 @@ public sealed class DungeonHandler : IClientMessageHandler
|
||||
seed = instance.Seed,
|
||||
width = layout2.Width,
|
||||
height = layout2.Height,
|
||||
tiles = layout2.SerializeTiles(),
|
||||
tilesRLE = layout2.SerializeTilesRLE(),
|
||||
spawn = new { x = player.X, y = player.Y },
|
||||
players = instance.Simulation.Players.Values.Select(p => new
|
||||
{
|
||||
@@ -1393,11 +1393,16 @@ public sealed class DungeonHandler : IClientMessageHandler
|
||||
chest.Items.Remove(chestItem);
|
||||
|
||||
// Check if chest is now empty
|
||||
await CheckAndRemoveEmptyChestAsync(db, dungeon, chest, ct);
|
||||
await CheckAndRemoveEmptyChestAsync(db, dungeon, chest, session, ct);
|
||||
|
||||
// Send updated states
|
||||
await HandleInventoryRequest(connection, session, ct);
|
||||
await HandleLootChestOpen(connection, session, payload, ct); // Resend chest state
|
||||
|
||||
// Only resend chest state if it still exists
|
||||
if (!chest.IsEmpty)
|
||||
{
|
||||
await HandleLootChestOpen(connection, session, payload, ct);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1521,7 +1526,7 @@ public sealed class DungeonHandler : IClientMessageHandler
|
||||
}
|
||||
|
||||
// Check if chest is now empty
|
||||
await CheckAndRemoveEmptyChestAsync(db, dungeon, chest, ct);
|
||||
await CheckAndRemoveEmptyChestAsync(db, dungeon, chest, session, ct);
|
||||
|
||||
// Send updated inventory
|
||||
await HandleInventoryRequest(connection, session, ct);
|
||||
@@ -1560,7 +1565,7 @@ public sealed class DungeonHandler : IClientMessageHandler
|
||||
/// <summary>
|
||||
/// Check if a chest is empty and remove it if so
|
||||
/// </summary>
|
||||
private async Task CheckAndRemoveEmptyChestAsync(GameDbContext db, DungeonInstance dungeon, LootChestInstance chest, CancellationToken ct)
|
||||
private async Task CheckAndRemoveEmptyChestAsync(GameDbContext db, DungeonInstance dungeon, LootChestInstance chest, DungeonPlayerSession owner, CancellationToken ct)
|
||||
{
|
||||
if (chest.IsEmpty)
|
||||
{
|
||||
@@ -1573,6 +1578,12 @@ public sealed class DungeonHandler : IClientMessageHandler
|
||||
await db.SaveChangesAsync(ct);
|
||||
}
|
||||
|
||||
// Notify owner that chest is removed
|
||||
await SendAsync(owner.Connection, DungeonOpCodes.LOOT_CHEST_REMOVED, new
|
||||
{
|
||||
chestId = chest.Id
|
||||
}, ct);
|
||||
|
||||
// Remove from runtime
|
||||
dungeon.Simulation.LootChests.TryRemove(chest.Id, out _);
|
||||
|
||||
@@ -1831,7 +1842,7 @@ public sealed class DungeonHandler : IClientMessageHandler
|
||||
levelBracket = new { min = instance.LevelBracketMin, max = instance.LevelBracketMax },
|
||||
width = layout.Width,
|
||||
height = layout.Height,
|
||||
tiles = layout.SerializeTiles(),
|
||||
tilesRLE = layout.SerializeTilesRLE(),
|
||||
spawn = new { x = player.X, y = player.Y },
|
||||
players = instance.Simulation.Players.Values.Select(p => new
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user