Remove our own impl of ReadOnlyList and update usages
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -74,7 +75,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
|
||||
|
||||
public DdsSprite(Stream stream)
|
||||
{
|
||||
Frames = new ISpriteFrame[] { new DdsFrame(stream) }.AsReadOnly();
|
||||
Frames = new ISpriteFrame[] { new DdsFrame(stream) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -108,7 +109,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
|
||||
|
||||
public TgaSprite(Stream stream)
|
||||
{
|
||||
Frames = new ISpriteFrame[] { new TgaFrame(stream) }.AsReadOnly();
|
||||
Frames = new ISpriteFrame[] { new TgaFrame(stream) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,10 +239,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos topLeft, SubCell subCell = SubCell.Any)
|
||||
{
|
||||
var occupied = OccupiedTiles(topLeft)
|
||||
return OccupiedTiles(topLeft)
|
||||
.ToDictionary(c => c, c => SubCell.FullCell);
|
||||
|
||||
return occupied;
|
||||
}
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell => false;
|
||||
|
||||
@@ -34,8 +34,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any)
|
||||
{
|
||||
var occupied = new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } };
|
||||
return occupied;
|
||||
return new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } };
|
||||
}
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell => false;
|
||||
|
||||
@@ -37,8 +37,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any)
|
||||
{
|
||||
var occupied = new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } };
|
||||
return occupied;
|
||||
return new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } };
|
||||
}
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell => false;
|
||||
|
||||
@@ -21,10 +21,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any)
|
||||
{
|
||||
var occupied = OccupiesSpace ? new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } } :
|
||||
return OccupiesSpace ? new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } } :
|
||||
new Dictionary<CPos, SubCell>();
|
||||
|
||||
return occupied;
|
||||
}
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell => false;
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly MissionObjectivesInfo Info;
|
||||
readonly List<MissionObjective> objectives = new List<MissionObjective>();
|
||||
readonly Player player;
|
||||
public ReadOnlyList<MissionObjective> Objectives;
|
||||
public IReadOnlyList<MissionObjective> Objectives => objectives;
|
||||
|
||||
Player[] enemies;
|
||||
Player[] allies;
|
||||
@@ -92,7 +92,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
Info = info;
|
||||
this.player = player;
|
||||
Objectives = new ReadOnlyList<MissionObjective>(objectives);
|
||||
}
|
||||
|
||||
void IWorldLoaded.WorldLoaded(World w, WorldRenderer wr)
|
||||
|
||||
@@ -77,12 +77,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var radarColorInfo = Info.TraitInfoOrDefault<RadarColorFromTerrainInfo>();
|
||||
RadarColor = radarColorInfo == null ? owner.Color : radarColorInfo.GetColorFromTerrain(world);
|
||||
|
||||
if (ios != null)
|
||||
Footprint = ios.OccupiedCells(Info, location, subCell);
|
||||
else
|
||||
{
|
||||
Footprint = new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } };
|
||||
}
|
||||
Footprint = ios?.OccupiedCells(Info, location, subCell) ?? new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } };
|
||||
|
||||
tooltip = Info.TraitInfos<EditorOnlyTooltipInfo>().FirstOrDefault(info => info.EnabledByDefault) as TooltipInfoBase
|
||||
?? Info.TraitInfos<TooltipInfo>().FirstOrDefault(info => info.EnabledByDefault);
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (techLevels.Any())
|
||||
yield return new LobbyOption("techlevel", TechLevelDropdownLabel, TechLevelDropdownDescription, TechLevelDropdownVisible, TechLevelDropdownDisplayOrder,
|
||||
techLevels, TechLevel, TechLevelDropdownLocked);
|
||||
techLevels, TechLevel, TechLevelDropdownLocked);
|
||||
|
||||
var gameSpeeds = Game.ModData.Manifest.Get<GameSpeeds>().Speeds
|
||||
.ToDictionary(s => s.Key, s => s.Value.Name);
|
||||
|
||||
Reference in New Issue
Block a user