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(CombatSchedulerRuntimeContext context, CombatSchedulerFlowCoordinator flow)
|
|
: base(context, flow)
|
|
{
|
|
}
|
|
|
|
public override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
|
{
|
|
_ = realElapseSeconds;
|
|
|
|
DRLevelPhase currentPhase = Context.PhaseLoopRuntime.CurrentPhase;
|
|
if (currentPhase == null)
|
|
{
|
|
Flow.EnterFailureFallback("CombatScheduler waiting phase failed. Current phase is null.");
|
|
return;
|
|
}
|
|
|
|
Context.PhaseLoopRuntime.AdvancePhaseElapsed(elapseSeconds);
|
|
|
|
if (Flow.ShouldEnterSettlementFromActiveState(out string reason, out bool isVictory))
|
|
{
|
|
Flow.ChangeState(new CombatSettlementState(Context, Flow, reason, isVictory));
|
|
return;
|
|
}
|
|
|
|
PhaseEndConditionContext conditionContext = new(
|
|
currentPhase,
|
|
Context.PhaseLoopRuntime.CurrentPhaseElapsed,
|
|
Context.EnemyManager.IsPhaseSpawnCompleted,
|
|
Context.EnemyManager.AliveEnemyCount,
|
|
Context.EnemyManager.HasAliveBoss);
|
|
IPhaseEndCondition endCondition = PhaseEndConditionFactory.Create(currentPhase.EndType);
|
|
if (!endCondition.ShouldExit(conditionContext))
|
|
{
|
|
return;
|
|
}
|
|
|
|
Flow.CompleteCurrentPhase();
|
|
}
|
|
}
|
|
}
|