Streamline SpawnOccupant management.

This commit is contained in:
Paul Chote
2020-10-01 23:37:16 +01:00
committed by reaperrr
parent 6f32196f89
commit 60df247416
7 changed files with 38 additions and 46 deletions

View File

@@ -76,15 +76,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
mapPreviewRoot.IsVisible = () => selectedReplay != null;
panel.Get("REPLAY_INFO").IsVisible = () => selectedReplay != null;
var spawnOccupants = new CachedTransform<ReplayMetadata, Dictionary<int, SpawnOccupant>>(r =>
r.GameInfo.Players.ToDictionary(c => c.SpawnPoint, c => new SpawnOccupant(c)));
Ui.LoadWidget("MAP_PREVIEW", mapPreviewRoot, new WidgetArgs
{
{ "orderManager", null },
{ "getMap", (Func<MapPreview>)(() => map) },
{ "onMouseDown", (Action<MapPreviewWidget, MapPreview, MouseInput>)((preview, mapPreview, mi) => { }) },
{
"getSpawnOccupants", (Func<MapPreview, Dictionary<CPos, SpawnOccupant>>)(mapPreview =>
LobbyUtils.GetSpawnOccupants(selectedReplay.GameInfo.Players, mapPreview))
},
{ "getSpawnOccupants", (Func<Dictionary<int, SpawnOccupant>>)(() => spawnOccupants.Update(selectedReplay)) },
{ "showUnoccupiedSpawnpoints", false },
});