Normalize mob visual state before join/state payloads and clarify client animation handling
- Add server-side payload-time normalization to prevent alive mobs from being sent with dead/hurt animations - Enforce dead state/death animation payload consistency for non-alive mobs - Apply normalization in both dungeon enter flows and recurring dungeon state sends - Update pending-clientChanges.md: client must treat currentAnimation as authoritative and gate loot prompt by hasLoot
This commit is contained in:
@@ -333,6 +333,7 @@ public sealed partial class DungeonHandler
|
||||
|
||||
instance.Simulation.Players[session.CharacterId] = player;
|
||||
instance.LastPlayerActivity = DateTime.UtcNow;
|
||||
NormalizeMobVisualStateForPayload(instance.Simulation);
|
||||
|
||||
session.State = PlayerState.InDungeon;
|
||||
session.CurrentDungeonId = instance.Id;
|
||||
|
||||
@@ -120,6 +120,37 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
}
|
||||
}
|
||||
|
||||
private static void NormalizeMobVisualStateForPayload(DungeonSimulation sim)
|
||||
{
|
||||
foreach (var mob in sim.Mobs.Values)
|
||||
{
|
||||
if (mob.IsAlive)
|
||||
{
|
||||
if (mob.State == MobState.Dead)
|
||||
{
|
||||
mob.State = MobState.Idle;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(mob.CurrentAnimation) ||
|
||||
mob.CurrentAnimation.StartsWith("death_", StringComparison.OrdinalIgnoreCase) ||
|
||||
mob.CurrentAnimation.StartsWith("hurt_", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
mob.CurrentAnimation = mob.GetDirectionalAnimation("idle");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mob.Health = 0;
|
||||
mob.State = MobState.Dead;
|
||||
if (string.IsNullOrWhiteSpace(mob.CurrentAnimation) ||
|
||||
!mob.CurrentAnimation.StartsWith("death_", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
mob.CurrentAnimation = mob.GetDirectionalAnimation("death");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IReadOnlyCollection<int> SupportedOpCodes => new[]
|
||||
{
|
||||
DungeonOpCodes.HUB_STATE,
|
||||
@@ -706,6 +737,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
|
||||
// Update last activity
|
||||
instance.LastPlayerActivity = DateTime.UtcNow;
|
||||
NormalizeMobVisualStateForPayload(instance.Simulation);
|
||||
|
||||
var layout2 = instance.Simulation.Layout;
|
||||
|
||||
@@ -2799,6 +2831,7 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
if (dungeon == null) return;
|
||||
|
||||
var sim = dungeon.Simulation;
|
||||
NormalizeMobVisualStateForPayload(sim);
|
||||
var selfPlayer = sim.Players.GetValueOrDefault(session.CharacterId);
|
||||
bool spatialFiltering = _spatialStateFilterEnabled && selfPlayer != null;
|
||||
bool sendSpatialThisTick = !spatialFiltering ||
|
||||
|
||||
Reference in New Issue
Block a user