Normalize mob visual state on tick and document remaining client loot prompt gating
- Add server-side state sanity checks so alive mobs cannot remain in dead/death animation state - Enforce dead state/death animation for dead mobs every tick - Remove Damaged-state assignment on hit to avoid hurt-loop visual lock-in - Update pending-clientChanges.md: client should gate loot prompt by isAlive=false && hasLoot=true
This commit is contained in:
@@ -344,6 +344,17 @@ public partial class DungeonSimulation
|
|||||||
// Update all mobs (AI)
|
// Update all mobs (AI)
|
||||||
foreach (var mob in Mobs.Values.Where(m => m.IsAlive))
|
foreach (var mob in Mobs.Values.Where(m => m.IsAlive))
|
||||||
{
|
{
|
||||||
|
// Defensive normalization in case persisted/runtime state drifts.
|
||||||
|
if (mob.State == MobState.Dead)
|
||||||
|
{
|
||||||
|
mob.State = MobState.Idle;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(mob.CurrentAnimation) &&
|
||||||
|
mob.CurrentAnimation.StartsWith("death_", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
mob.CurrentAnimation = mob.GetDirectionalAnimation("idle");
|
||||||
|
}
|
||||||
|
|
||||||
MobAI.UpdateMob(mob, this, TickDelta);
|
MobAI.UpdateMob(mob, this, TickDelta);
|
||||||
|
|
||||||
// Process mob attacks if in attacking state
|
// Process mob attacks if in attacking state
|
||||||
@@ -378,6 +389,15 @@ public partial class DungeonSimulation
|
|||||||
// We still stamp when loot becomes empty so UI/inspection logic can reference it.
|
// We still stamp when loot becomes empty so UI/inspection logic can reference it.
|
||||||
foreach (var mob in Mobs.Values.Where(m => !m.IsAlive))
|
foreach (var mob in Mobs.Values.Where(m => !m.IsAlive))
|
||||||
{
|
{
|
||||||
|
if (mob.State != MobState.Dead)
|
||||||
|
{
|
||||||
|
mob.State = MobState.Dead;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrWhiteSpace(mob.CurrentAnimation) ||
|
||||||
|
!mob.CurrentAnimation.StartsWith("death_", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
mob.CurrentAnimation = mob.GetDirectionalAnimation("death");
|
||||||
|
}
|
||||||
if (!mob.HasDeathLoot && !mob.LootEmptiedAtTick.HasValue)
|
if (!mob.HasDeathLoot && !mob.LootEmptiedAtTick.HasValue)
|
||||||
{
|
{
|
||||||
mob.LootEmptiedAtTick = CurrentTick;
|
mob.LootEmptiedAtTick = CurrentTick;
|
||||||
@@ -1282,10 +1302,6 @@ public partial class DungeonSimulation
|
|||||||
};
|
};
|
||||||
Console.WriteLine($"[DamageEvent] Player {player.CharacterId} -> Mob {mob.Id}: {result.FinalDamage} damage ({damageTypeKey})");
|
Console.WriteLine($"[DamageEvent] Player {player.CharacterId} -> Mob {mob.Id}: {result.FinalDamage} damage ({damageTypeKey})");
|
||||||
_pendingDamageEvents.Add(damageEvent);
|
_pendingDamageEvents.Add(damageEvent);
|
||||||
if (mob.Health > 0)
|
|
||||||
{
|
|
||||||
mob.State = MobState.Damaged;
|
|
||||||
}
|
|
||||||
if (mob.Health <= 0)
|
if (mob.Health <= 0)
|
||||||
{
|
{
|
||||||
mob.Health = 0;
|
mob.Health = 0;
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
# Pending Client Changes
|
# Pending Client Changes
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
No mandatory client changes are currently required for the latest server fixes.
|
One client-side update is still required for corpse interaction UX.
|
||||||
|
|
||||||
|
## Required Client Update
|
||||||
|
1. Gate loot prompt (`E`) by `hasLoot`.
|
||||||
|
- Server now sends `hasLoot` for each mob in join/state payloads.
|
||||||
|
- Show corpse loot interaction only when:
|
||||||
|
- `isAlive == false`
|
||||||
|
- `hasLoot == true`
|
||||||
|
- Hide loot interaction if `hasLoot == false` (corpse remains, but not lootable).
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
1. Server now includes `isAlive` consistently in mob payloads and sends `mobCatalog` on dungeon-enter responses and one-time in dungeon state.
|
1. Server now includes `isAlive`/`hasLoot`/`currentAnimation` 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:
|
2. If invisible mobs still occur, keep a fallback render path when `spriteConfig` is null:
|
||||||
- Use `definitionId` -> local/default sprite mapping.
|
- Use `definitionId` -> local/default sprite mapping.
|
||||||
- Apply default tint `#ffffff` and scale `1.0`.
|
- Apply default tint `#ffffff` and scale `1.0`.
|
||||||
|
|||||||
Reference in New Issue
Block a user