MapData + Event 解耦已完成一轮收口

- `MapData` 已收口为纯初始化快照,不再承载 coin 写接口委托
- 已新增 `MapEntityLoadContext`
  - 用于把 `MapData` 快照与 coin 命令通道拆开传给地图加载
- `CombatLoadingState` 现在会组装:
  - `MapData`
  - `MapEntityLoadContext`
- `CombatLoadSession` / `EntityExtension.ShowMap(...)` 已切到 `MapEntityLoadContext`
- `MapEntity` 当前通过:
  - `MapEntityLoadContext` 获取初始快照与 coin 命令通道
  - `CombatCoinChangedEventArgs` 同步后续 coin 变化
- 已新增 `MapCombatRuntimeBridge`
  - 收口地图侧 coin 当前值、命令调用与事件订阅
- `MapEntity` 不再自己维护 `_currentCoin` 和 coin 事件订阅样板
This commit is contained in:
2026-03-07 20:00:39 +08:00
parent b38088c3ea
commit 3ad7d04b47
15 changed files with 224 additions and 121 deletions
@@ -20,7 +20,7 @@ namespace GeometryTD.CustomComponent
Context.SettlementFlowService.OpenCombatFinishForm(
Context.SettlementContext,
Context.CombatFinishFormUseCase);
Flow.Scheduler.ChangeState(new CombatWaitingForReturnState(Context, Flow));
Flow.ChangeState(new CombatWaitingForReturnState(Context, Flow));
}
}
}
@@ -22,7 +22,7 @@ namespace GeometryTD.CustomComponent
}
MapEntityLoadContext mapLoadContext = BuildMapLoadContext();
if (!Context.LoadSession.StartLoading(Context.CurrentLevel, mapLoadContext, Flow.Scheduler, out string errorMessage))
if (!Context.LoadSession.StartLoading(Context.CurrentLevel, mapLoadContext, Flow.Host, out string errorMessage))
{
Flow.EnterFailureFallback($"Combat loading failed. {errorMessage}");
}
@@ -66,7 +66,7 @@ namespace GeometryTD.CustomComponent
participantTowerSnapshot: GameEntry.PlayerInventory != null
? GameEntry.PlayerInventory.GetParticipantTowerSnapshot()
: null);
return new MapEntityLoadContext(mapData, Flow.Scheduler.TryConsumeCoin, Flow.Scheduler.AddCoin);
return new MapEntityLoadContext(mapData, Flow.TryConsumeCoin, Flow.AddCoin);
}
}
}
@@ -25,7 +25,7 @@ namespace GeometryTD.CustomComponent
Flow.OnFullBaseHpRewardSelected,
Flow.OnFullBaseHpRewardGiveUp))
{
Flow.Scheduler.ChangeState(new CombatFinishFormState(Context, Flow));
Flow.ChangeState(new CombatFinishFormState(Context, Flow));
}
}
@@ -62,7 +62,7 @@ namespace GeometryTD.CustomComponent
if (Flow.ShouldEnterSettlementFromActiveState(out string reason, out bool isVictory))
{
Flow.Scheduler.ChangeState(new CombatSettlementState(Context, Flow, reason, isVictory));
Flow.ChangeState(new CombatSettlementState(Context, Flow, reason, isVictory));
return;
}
@@ -26,13 +26,13 @@ namespace GeometryTD.CustomComponent
Context.CurrentLevel,
Context.EnemyManager.DefeatedEnemyCount,
Context.CombatInRunResourceManager);
if (Context.SettlementContext.ShouldOpenRewardSelection)
if (Context.SettlementContext.Flow.ShouldOpenRewardSelection)
{
Flow.Scheduler.ChangeState(new CombatRewardSelectionState(Context, Flow));
Flow.ChangeState(new CombatRewardSelectionState(Context, Flow));
return;
}
Flow.Scheduler.ChangeState(new CombatFinishFormState(Context, Flow));
Flow.ChangeState(new CombatFinishFormState(Context, Flow));
}
}
}
@@ -24,7 +24,7 @@ namespace GeometryTD.CustomComponent
if (Flow.ShouldEnterSettlementFromActiveState(out string reason, out bool isVictory))
{
Flow.Scheduler.ChangeState(new CombatSettlementState(Context, Flow, reason, isVictory));
Flow.ChangeState(new CombatSettlementState(Context, Flow, reason, isVictory));
return;
}
@@ -43,4 +43,4 @@ namespace GeometryTD.CustomComponent
Flow.CompleteCurrentPhase();
}
}
}
}