Refine combat settlement exit flow
This commit is contained in:
-1
@@ -15,7 +15,6 @@ namespace GeometryTD.CustomComponent
|
||||
return;
|
||||
}
|
||||
|
||||
Context.SettlementFlowService.CommitSettlementInventory(Context.SettlementContext);
|
||||
Flow.EnsureCombatFinishFormUseCaseBound();
|
||||
Context.SettlementFlowService.OpenCombatFinishForm(
|
||||
Context.SettlementContext,
|
||||
|
||||
+2
-2
@@ -60,9 +60,9 @@ namespace GeometryTD.CustomComponent
|
||||
Context.PhaseLoopRuntime.AdvancePhaseElapsed(elapseSeconds);
|
||||
Context.EnemyManager.OnUpdate(elapseSeconds, realElapseSeconds);
|
||||
|
||||
if (Flow.ShouldEnterSettlementFromActiveState(out string reason, out bool isVictory))
|
||||
if (Flow.ShouldEnterSettlementFromActiveState(out bool isVictory))
|
||||
{
|
||||
Flow.ChangeState(new CombatSettlementState(Context, Flow, reason, isVictory));
|
||||
Flow.ChangeState(new CombatSettlementState(Context, Flow, isVictory));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
-4
@@ -2,16 +2,13 @@ namespace GeometryTD.CustomComponent
|
||||
{
|
||||
internal sealed class CombatSettlementState : CombatStateBase
|
||||
{
|
||||
private readonly string _reason;
|
||||
private readonly bool _isVictory;
|
||||
|
||||
public CombatSettlementState(
|
||||
CombatSchedulerRuntimeContext context,
|
||||
CombatSchedulerFlowCoordinator flow,
|
||||
string reason,
|
||||
bool isVictory) : base(context, flow)
|
||||
{
|
||||
_reason = reason;
|
||||
_isVictory = isVictory;
|
||||
}
|
||||
|
||||
@@ -21,7 +18,6 @@ namespace GeometryTD.CustomComponent
|
||||
Context.EnemyManager.CleanupTrackedEnemies();
|
||||
Context.IsFinishAsVictory = _isVictory;
|
||||
Context.SettlementContext = Context.SettlementFlowService.BuildSettlementContext(
|
||||
_reason,
|
||||
_isVictory,
|
||||
Context.CurrentLevel,
|
||||
Context.EnemyManager.DefeatedEnemyCount,
|
||||
|
||||
+2
-2
@@ -22,9 +22,9 @@ namespace GeometryTD.CustomComponent
|
||||
|
||||
Context.PhaseLoopRuntime.AdvancePhaseElapsed(elapseSeconds);
|
||||
|
||||
if (Flow.ShouldEnterSettlementFromActiveState(out string reason, out bool isVictory))
|
||||
if (Flow.ShouldEnterSettlementFromActiveState(out bool isVictory))
|
||||
{
|
||||
Flow.ChangeState(new CombatSettlementState(Context, Flow, reason, isVictory));
|
||||
Flow.ChangeState(new CombatSettlementState(Context, Flow, isVictory));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -24,6 +24,13 @@ namespace GeometryTD.CustomComponent
|
||||
return;
|
||||
}
|
||||
|
||||
if (Context.SettlementContext == null)
|
||||
{
|
||||
Flow.EnterFailureFallback("Combat return failed. Settlement context is missing.");
|
||||
return;
|
||||
}
|
||||
|
||||
Context.SettlementFlowService.CommitSettlementInventory(Context.SettlementContext);
|
||||
Context.LoadSession.Cleanup();
|
||||
Flow.CloseCombatFinishForm();
|
||||
Flow.CloseRewardSelectForm();
|
||||
|
||||
Reference in New Issue
Block a user