Remove direct access to MapPreview.Rules.

This commit is contained in:
Paul Chote
2021-04-04 16:40:46 +01:00
committed by teinarss
parent 53e6d974f0
commit abee274f88
22 changed files with 57 additions and 54 deletions

View File

@@ -73,14 +73,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
void RebuildOptions()
{
if (mapPreview == null || mapPreview.Rules == null || mapPreview.InvalidCustomRules)
if (mapPreview == null || mapPreview.WorldActorInfo == null || mapPreview.InvalidCustomRules)
return;
optionsContainer.RemoveChildren();
optionsContainer.Bounds.Height = 0;
var allOptions = mapPreview.Rules.Actors[SystemActors.Player].TraitInfos<ILobbyOptions>()
.Concat(mapPreview.Rules.Actors[SystemActors.World].TraitInfos<ILobbyOptions>())
.SelectMany(t => t.LobbyOptions(mapPreview.Rules))
var allOptions = mapPreview.PlayerActorInfo.TraitInfos<ILobbyOptions>()
.Concat(mapPreview.WorldActorInfo.TraitInfos<ILobbyOptions>())
.SelectMany(t => t.LobbyOptions(mapPreview))
.Where(o => o.IsVisible)
.OrderBy(o => o.DisplayOrder)
.ToArray();