47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using GeometryTD.DataTable;
|
|
|
|
namespace GeometryTD.CustomComponent
|
|
{
|
|
internal sealed class CombatWaitingForPhaseEndState : CombatStateBase
|
|
{
|
|
public CombatWaitingForPhaseEndState(CombatSchedulerRuntime runtime, CombatSchedulerCoordinator coordinator)
|
|
: base(runtime, coordinator)
|
|
{
|
|
}
|
|
|
|
public override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
|
{
|
|
_ = realElapseSeconds;
|
|
|
|
DRLevelPhase currentPhase = Runtime.PhaseLoopRuntime.CurrentPhase;
|
|
if (currentPhase == null)
|
|
{
|
|
Coordinator.EnterFailureFallback("CombatScheduler waiting phase failed. Current phase is null.");
|
|
return;
|
|
}
|
|
|
|
Runtime.PhaseLoopRuntime.AdvancePhaseElapsed(elapseSeconds);
|
|
|
|
if (Coordinator.ShouldEnterSettlementFromActiveState(out bool didCombatWin))
|
|
{
|
|
Coordinator.ChangeState(new CombatSettlementState(Runtime, Coordinator, didCombatWin));
|
|
return;
|
|
}
|
|
|
|
PhaseEndConditionContext conditionContext = new(
|
|
currentPhase,
|
|
Runtime.PhaseLoopRuntime.CurrentPhaseElapsed,
|
|
Runtime.EnemyManager.IsPhaseSpawnCompleted,
|
|
Runtime.EnemyManager.AliveEnemyCount,
|
|
Runtime.EnemyManager.HasAliveBoss);
|
|
IPhaseEndCondition endCondition = PhaseEndConditionFactory.Create(currentPhase.EndType);
|
|
if (!endCondition.ShouldExit(conditionContext))
|
|
{
|
|
return;
|
|
}
|
|
|
|
Coordinator.CompleteCurrentPhase();
|
|
}
|
|
}
|
|
}
|