Keep mob corpses persistent and enforce death animation state
- Stop automatic corpse removal after loot is emptied; corpses now remain in world - On all mob death paths, set dead state plus death animation (death_[dir]) and clear combat/cast targeting - Include dead mobs in spatial state feed so corpses do not disappear from clients - Add mob currentAnimation/hasLoot in payload and reject loot interaction when corpse has no loot
This commit is contained in:
@@ -374,33 +374,16 @@ public partial class DungeonSimulation
|
||||
UpdatePlayer(player);
|
||||
}
|
||||
|
||||
// Handle corpse cleanup (remove corpses 30 seconds after loot is empty AND dungeon is cleared)
|
||||
var corpsesToRemove = new List<int>();
|
||||
if (Phase == DungeonPhase.Cleared)
|
||||
// Keep corpses in the world after death (even after loot is emptied).
|
||||
// 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.HasDeathLoot && !mob.LootEmptiedAtTick.HasValue)
|
||||
{
|
||||
// Check if loot just became empty
|
||||
if (!mob.HasDeathLoot && !mob.LootEmptiedAtTick.HasValue)
|
||||
{
|
||||
mob.LootEmptiedAtTick = CurrentTick;
|
||||
}
|
||||
|
||||
// Remove corpse 30 seconds after loot emptied (10 ticks per second)
|
||||
if (mob.LootEmptiedAtTick.HasValue &&
|
||||
CurrentTick - mob.LootEmptiedAtTick.Value >= 30 * TicksPerSecond)
|
||||
{
|
||||
corpsesToRemove.Add(mob.Id);
|
||||
}
|
||||
mob.LootEmptiedAtTick = CurrentTick;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove corpses
|
||||
foreach (var mobId in corpsesToRemove)
|
||||
{
|
||||
Mobs.Remove(mobId, out _);
|
||||
}
|
||||
|
||||
// Check dungeon completion (only once when phase is still Active)
|
||||
if (Phase == DungeonPhase.Active && Mobs.Values.All(m => !m.IsAlive))
|
||||
{
|
||||
@@ -786,7 +769,13 @@ public partial class DungeonSimulation
|
||||
// Check if mob died
|
||||
if (mob.Health <= 0 && mob.IsAlive)
|
||||
{
|
||||
mob.Health = 0;
|
||||
mob.IsAlive = false;
|
||||
mob.State = MobState.Dead;
|
||||
mob.TargetId = null;
|
||||
mob.CastingAbility = null;
|
||||
mob.CastTimeRemaining = 0;
|
||||
mob.CurrentAnimation = mob.GetDirectionalAnimation("death");
|
||||
_pendingDeathEvents.Add(new DeathEvent
|
||||
{
|
||||
EntityType = EntityType.Mob,
|
||||
@@ -1302,6 +1291,10 @@ public partial class DungeonSimulation
|
||||
mob.Health = 0;
|
||||
mob.IsAlive = false;
|
||||
mob.State = MobState.Dead;
|
||||
mob.TargetId = null;
|
||||
mob.CastingAbility = null;
|
||||
mob.CastTimeRemaining = 0;
|
||||
mob.CurrentAnimation = mob.GetDirectionalAnimation("death");
|
||||
|
||||
player.XpGained += mob.Stats.XpReward;
|
||||
player.MobsKilled++;
|
||||
|
||||
Reference in New Issue
Block a user