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

@@ -207,7 +207,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
slotsButton.OnMouseDown = _ =>
{
var botTypes = map.Rules.Actors[SystemActors.Player].TraitInfos<IBotInfo>().Select(t => t.Type);
var botTypes = map.PlayerActorInfo.TraitInfos<IBotInfo>().Select(t => t.Type);
var options = new Dictionary<string, IEnumerable<DropDownOption>>();
var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin);
@@ -539,7 +539,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (addBotOnMapLoad)
{
var slot = orderManager.LobbyInfo.FirstEmptyBotSlot();
var bot = currentMap.Rules.Actors[SystemActors.Player].TraitInfos<IBotInfo>().Select(t => t.Type).FirstOrDefault();
var bot = currentMap.PlayerActorInfo.TraitInfos<IBotInfo>().Select(t => t.Type).FirstOrDefault();
var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin);
if (slot != null && bot != null)
orderManager.IssueOrder(Order.Command("slot_bot {0} {1} {2}".F(slot, botController.Index, bot)));

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();

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var bots = new List<SlotDropDownOption>();
if (slot.AllowBots)
{
foreach (var b in map.Rules.Actors[SystemActors.Player].TraitInfos<IBotInfo>())
foreach (var b in map.PlayerActorInfo.TraitInfos<IBotInfo>())
{
var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin);
bots.Add(new SlotDropDownOption(b.Name,