Dungeon fix
This commit is contained in:
@@ -327,43 +327,48 @@ public partial class DungeonSimulation
|
||||
public TickResult Tick(long tick)
|
||||
{
|
||||
CurrentTick = tick;
|
||||
|
||||
if (Phase != DungeonPhase.Active)
|
||||
return new TickResult { Phase = Phase };
|
||||
|
||||
|
||||
_pendingDamageEvents.Clear();
|
||||
_pendingDeathEvents.Clear();
|
||||
_pendingAbilityEvents.Clear();
|
||||
_pendingProjectileHitEvents.Clear();
|
||||
_pendingProjectileExpiredEvents.Clear();
|
||||
|
||||
// If dungeon is not active, still allow basic updates (movement, corpse cleanup)
|
||||
// but skip combat/AI
|
||||
bool skipCombat = Phase != DungeonPhase.Active;
|
||||
|
||||
// Update all mobs (AI)
|
||||
foreach (var mob in Mobs.Values.Where(m => m.IsAlive))
|
||||
// Only do combat/AI if dungeon is active
|
||||
if (!skipCombat)
|
||||
{
|
||||
MobAI.UpdateMob(mob, this, TickDelta);
|
||||
|
||||
// Process mob attacks if in attacking state
|
||||
if (mob.State == MobState.Attacking && mob.TargetId.HasValue)
|
||||
// Update all mobs (AI)
|
||||
foreach (var mob in Mobs.Values.Where(m => m.IsAlive))
|
||||
{
|
||||
float attackInterval = 1f / mob.Stats.AttackSpeed;
|
||||
if (CurrentTick - mob.LastAttackTick >= (long)(attackInterval * TicksPerSecond))
|
||||
MobAI.UpdateMob(mob, this, TickDelta);
|
||||
|
||||
// Process mob attacks if in attacking state
|
||||
if (mob.State == MobState.Attacking && mob.TargetId.HasValue)
|
||||
{
|
||||
if (Players.TryGetValue(mob.TargetId.Value, out var target) && target.IsAlive)
|
||||
float attackInterval = 1f / mob.Stats.AttackSpeed;
|
||||
if (CurrentTick - mob.LastAttackTick >= (long)(attackInterval * TicksPerSecond))
|
||||
{
|
||||
ProcessMobAbility(mob, target);
|
||||
if (Players.TryGetValue(mob.TargetId.Value, out var target) && target.IsAlive)
|
||||
{
|
||||
ProcessMobAbility(mob, target);
|
||||
}
|
||||
mob.LastAttackTick = CurrentTick;
|
||||
}
|
||||
mob.LastAttackTick = CurrentTick;
|
||||
}
|
||||
}
|
||||
|
||||
// Update projectiles
|
||||
UpdateProjectiles();
|
||||
|
||||
// Update hazard zones
|
||||
UpdateHazardZones();
|
||||
}
|
||||
|
||||
// Update projectiles
|
||||
UpdateProjectiles();
|
||||
|
||||
// Update hazard zones
|
||||
UpdateHazardZones();
|
||||
|
||||
// Update players (movement, regeneration, status effects)
|
||||
|
||||
// Always update players (movement, regeneration, status effects) - even when cleared
|
||||
foreach (var player in Players.Values.Where(p => p.IsAlive))
|
||||
{
|
||||
UpdatePlayer(player);
|
||||
@@ -393,8 +398,8 @@ public partial class DungeonSimulation
|
||||
Mobs.Remove(mobId, out _);
|
||||
}
|
||||
|
||||
// Check dungeon completion
|
||||
if (Mobs.Values.All(m => !m.IsAlive))
|
||||
// Check dungeon completion (only once when phase is still Active)
|
||||
if (Phase == DungeonPhase.Active && Mobs.Values.All(m => !m.IsAlive))
|
||||
{
|
||||
Phase = DungeonPhase.Cleared;
|
||||
SpawnExit();
|
||||
|
||||
Reference in New Issue
Block a user