Standardize mob payloads and refresh pending client requirements
- Include isAlive in dungeon state and join mob payloads for consistent render lifecycle - Add mobCatalog to dungeon enter responses so clients can bootstrap mob art deterministically - Filter DUNGEON_STATE visible mobs to alive mobs to avoid stale/dead entity feed - Rewrite pending-clientChanges.md to reflect no mandatory remaining client work
This commit is contained in:
@@ -422,11 +422,21 @@ public sealed partial class DungeonHandler
|
||||
rotation = m.Rotation,
|
||||
health = m.Health,
|
||||
maxHealth = m.MaxHealth,
|
||||
isAlive = m.IsAlive,
|
||||
state = m.State.ToString().ToLower(),
|
||||
spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson),
|
||||
tintColor = m.TintColor,
|
||||
scale = m.Scale
|
||||
}),
|
||||
mobCatalog = instance.Simulation.Mobs.Values.Select(m => new
|
||||
{
|
||||
id = m.Id,
|
||||
definitionId = m.DefinitionId,
|
||||
name = m.Name,
|
||||
spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson),
|
||||
tintColor = m.TintColor,
|
||||
scale = m.Scale
|
||||
}),
|
||||
chests = instance.Simulation.Chests.Values.Select(c => new
|
||||
{
|
||||
id = c.Id,
|
||||
|
||||
@@ -852,6 +852,15 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
tintColor = m.TintColor,
|
||||
scale = m.Scale
|
||||
}),
|
||||
mobCatalog = instance.Simulation.Mobs.Values.Select(m => new
|
||||
{
|
||||
id = m.Id,
|
||||
definitionId = m.DefinitionId,
|
||||
name = m.Name,
|
||||
spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson),
|
||||
tintColor = m.TintColor,
|
||||
scale = m.Scale
|
||||
}),
|
||||
chests = instance.Simulation.Chests.Values.Select(c => new
|
||||
{
|
||||
id = c.Id,
|
||||
@@ -2810,7 +2819,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
var visiblePlayerIds = visiblePlayers.Select(p => p.CharacterId).ToHashSet();
|
||||
|
||||
var nearbyOrRelevantMobs = sim.Mobs.Values
|
||||
.Where(m => !spatialFiltering || IsNearby(m.X, m.Y) || m.TargetId == session.CharacterId)
|
||||
.Where(m => m.IsAlive && (!spatialFiltering || IsNearby(m.X, m.Y) || m.TargetId == session.CharacterId))
|
||||
.ToList();
|
||||
var visibleMobs = sendSpatialThisTick
|
||||
? nearbyOrRelevantMobs
|
||||
@@ -2868,6 +2877,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
rotation = m.Rotation,
|
||||
health = m.Health,
|
||||
maxHealth = m.MaxHealth,
|
||||
isAlive = m.IsAlive,
|
||||
state = m.State.ToString().ToLower(),
|
||||
spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson),
|
||||
tintColor = m.TintColor,
|
||||
|
||||
@@ -1,38 +1,10 @@
|
||||
# Pending Client Changes
|
||||
|
||||
## Context
|
||||
Server-side dungeon state payloads now support spatial filtering and one-time mob metadata delivery per dungeon session.
|
||||
## Status
|
||||
No mandatory client changes are currently required for the latest server fixes.
|
||||
|
||||
## Required Client Updates
|
||||
1. Support `mobCatalog` on `DUNGEON_STATE` packets.
|
||||
- `mobCatalog` is sent once per dungeon join and contains static mob render metadata:
|
||||
- `id`
|
||||
- `definitionId`
|
||||
- `name`
|
||||
- `spriteConfig`
|
||||
- `tintColor`
|
||||
- `scale`
|
||||
- Client should cache this per-runtime mob `id` and use it to preload/resolve art.
|
||||
|
||||
2. Do not assume all mobs are present every tick.
|
||||
- With spatial filtering enabled, `mobs` in `DUNGEON_STATE` only includes nearby/relevant mobs.
|
||||
- Client entity lifecycle should be "visibility-scoped", not "full authoritative list each tick".
|
||||
- Recommended behavior:
|
||||
- Keep existing mob entities when omitted for a tick (out of range), do not hard-delete immediately.
|
||||
- Remove only when confirmed dead/despawned via explicit state/event signal or timeout policy.
|
||||
|
||||
3. Use `definitionId` when available.
|
||||
- `definitionId` is now included in enter/state mob payloads.
|
||||
- Client can use this for fallback art resolution or future dictionary-based rendering.
|
||||
|
||||
4. Portal rendering should treat payload as authoritative for active portals.
|
||||
- Server now sends active portals each state packet regardless of spatial throttling.
|
||||
- If client currently clears portals aggressively between packets, keep the most recent active set.
|
||||
|
||||
## Optional Hardening
|
||||
1. Handle missing/invalid `spriteConfig` gracefully.
|
||||
- Server now nulls bad JSON instead of throwing.
|
||||
- Client should apply safe defaults (placeholder sprite, default tint/scale) when `spriteConfig` is null.
|
||||
|
||||
2. Add debug overlay for spatial tuning validation.
|
||||
- Show current nearby mob count vs total known on minimap for live tuning checks.
|
||||
## Notes
|
||||
1. Server now includes `isAlive` consistently in mob payloads and sends `mobCatalog` on dungeon-enter responses and one-time in dungeon state.
|
||||
2. If invisible mobs still occur, keep a fallback render path when `spriteConfig` is null:
|
||||
- Use `definitionId` -> local/default sprite mapping.
|
||||
- Apply default tint `#ffffff` and scale `1.0`.
|
||||
|
||||
Reference in New Issue
Block a user