namespace GeometryTD.CustomComponent { public partial class CombatScheduler { private sealed class CombatWaitingForPhaseEndState : CombatStateBase { public CombatWaitingForPhaseEndState(CombatScheduler scheduler) : base(scheduler) { } public override void OnUpdate(float elapseSeconds, float realElapseSeconds) { _ = realElapseSeconds; var currentPhase = Scheduler._phaseLoopRuntime.CurrentPhase; if (currentPhase == null) { Scheduler.EnterFailureFallback("CombatScheduler waiting phase failed. Current phase is null."); return; } Scheduler._phaseLoopRuntime.AdvancePhaseElapsed(elapseSeconds); if (Scheduler.ShouldEnterSettlementFromActiveState(out string reason, out bool isVictory)) { Scheduler.ChangeState(new CombatSettlementState(Scheduler, reason, isVictory)); return; } PhaseEndConditionContext context = new( currentPhase, Scheduler._phaseLoopRuntime.CurrentPhaseElapsed, Scheduler._enemyManager.IsPhaseSpawnCompleted, Scheduler._enemyManager.AliveEnemyCount, Scheduler._enemyManager.HasAliveBoss); IPhaseEndCondition endCondition = PhaseEndConditionFactory.Create(currentPhase.EndType); if (!endCondition.ShouldExit(context)) { return; } Scheduler.CompleteCurrentPhase(); } } } }