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

@@ -40,10 +40,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
tooltipContainer.BeforeRender = () =>
{
showTooltip = true;
var occupant = preview.SpawnOccupants().Values.FirstOrDefault(c => c.SpawnPoint == preview.TooltipSpawnIndex);
var teamWidth = 0;
if (occupant == null)
if (preview.SpawnOccupants().TryGetValue(preview.TooltipSpawnIndex, out var occupant))
{
labelText = occupant.PlayerName;
playerFaction = occupant.Faction;
playerTeam = occupant.Team;
widget.Bounds.Height = playerTeam > 0 ? doubleHeight : singleHeight;
teamWidth = teamFont.Measure(team.GetText()).X;
}
else
{
if (!showUnoccupiedSpawnpoints)
{
@@ -56,14 +63,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
playerTeam = 0;
widget.Bounds.Height = singleHeight;
}
else
{
labelText = occupant.PlayerName;
playerFaction = occupant.Faction;
playerTeam = occupant.Team;
widget.Bounds.Height = playerTeam > 0 ? doubleHeight : singleHeight;
teamWidth = teamFont.Measure(team.GetText()).X;
}
label.Bounds.X = playerFaction != null ? flag.Bounds.Right + labelMargin : labelMargin;
label.Bounds.Width = ownerFont.Measure(labelText).X;