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,
|
rotation = m.Rotation,
|
||||||
health = m.Health,
|
health = m.Health,
|
||||||
maxHealth = m.MaxHealth,
|
maxHealth = m.MaxHealth,
|
||||||
|
isAlive = m.IsAlive,
|
||||||
state = m.State.ToString().ToLower(),
|
state = m.State.ToString().ToLower(),
|
||||||
spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson),
|
spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson),
|
||||||
tintColor = m.TintColor,
|
tintColor = m.TintColor,
|
||||||
scale = m.Scale
|
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
|
chests = instance.Simulation.Chests.Values.Select(c => new
|
||||||
{
|
{
|
||||||
id = c.Id,
|
id = c.Id,
|
||||||
|
|||||||
@@ -852,6 +852,15 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
|||||||
tintColor = m.TintColor,
|
tintColor = m.TintColor,
|
||||||
scale = m.Scale
|
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
|
chests = instance.Simulation.Chests.Values.Select(c => new
|
||||||
{
|
{
|
||||||
id = c.Id,
|
id = c.Id,
|
||||||
@@ -2810,7 +2819,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
|||||||
var visiblePlayerIds = visiblePlayers.Select(p => p.CharacterId).ToHashSet();
|
var visiblePlayerIds = visiblePlayers.Select(p => p.CharacterId).ToHashSet();
|
||||||
|
|
||||||
var nearbyOrRelevantMobs = sim.Mobs.Values
|
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();
|
.ToList();
|
||||||
var visibleMobs = sendSpatialThisTick
|
var visibleMobs = sendSpatialThisTick
|
||||||
? nearbyOrRelevantMobs
|
? nearbyOrRelevantMobs
|
||||||
@@ -2868,6 +2877,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
|||||||
rotation = m.Rotation,
|
rotation = m.Rotation,
|
||||||
health = m.Health,
|
health = m.Health,
|
||||||
maxHealth = m.MaxHealth,
|
maxHealth = m.MaxHealth,
|
||||||
|
isAlive = m.IsAlive,
|
||||||
state = m.State.ToString().ToLower(),
|
state = m.State.ToString().ToLower(),
|
||||||
spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson),
|
spriteConfig = DeserializeSpriteConfigSafe(m.SpriteConfigJson),
|
||||||
tintColor = m.TintColor,
|
tintColor = m.TintColor,
|
||||||
|
|||||||
@@ -1,38 +1,10 @@
|
|||||||
# Pending Client Changes
|
# Pending Client Changes
|
||||||
|
|
||||||
## Context
|
## Status
|
||||||
Server-side dungeon state payloads now support spatial filtering and one-time mob metadata delivery per dungeon session.
|
No mandatory client changes are currently required for the latest server fixes.
|
||||||
|
|
||||||
## Required Client Updates
|
## Notes
|
||||||
1. Support `mobCatalog` on `DUNGEON_STATE` packets.
|
1. Server now includes `isAlive` consistently in mob payloads and sends `mobCatalog` on dungeon-enter responses and one-time in dungeon state.
|
||||||
- `mobCatalog` is sent once per dungeon join and contains static mob render metadata:
|
2. If invisible mobs still occur, keep a fallback render path when `spriteConfig` is null:
|
||||||
- `id`
|
- Use `definitionId` -> local/default sprite mapping.
|
||||||
- `definitionId`
|
- Apply default tint `#ffffff` and scale `1.0`.
|
||||||
- `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.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user