Remove our own ReadOnlyDictionary and update usages
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
@@ -179,7 +180,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
yield return new FacingInit(PreviewFacing);
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any) { return new ReadOnlyDictionary<CPos, SubCell>(); }
|
||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any) { return new Dictionary<CPos, SubCell>(); }
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell => false;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
@@ -241,7 +242,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var occupied = OccupiedTiles(topLeft)
|
||||
.ToDictionary(c => c, c => SubCell.FullCell);
|
||||
|
||||
return new ReadOnlyDictionary<CPos, SubCell>(occupied);
|
||||
return occupied;
|
||||
}
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell => false;
|
||||
|
||||
@@ -35,7 +35,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 new ReadOnlyDictionary<CPos, SubCell>(occupied);
|
||||
return occupied;
|
||||
}
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell => false;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Primitives;
|
||||
@@ -37,7 +38,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 new ReadOnlyDictionary<CPos, SubCell>(occupied);
|
||||
return occupied;
|
||||
}
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell => false;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -25,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var occupied = OccupiesSpace ? new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } } :
|
||||
new Dictionary<CPos, SubCell>();
|
||||
|
||||
return new ReadOnlyDictionary<CPos, SubCell>(occupied);
|
||||
return occupied;
|
||||
}
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell => false;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
@@ -130,7 +131,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any)
|
||||
{
|
||||
return new ReadOnlyDictionary<CPos, SubCell>(new Dictionary<CPos, SubCell>() { { location, subCell } });
|
||||
return new Dictionary<CPos, SubCell>() { { location, subCell } };
|
||||
}
|
||||
|
||||
bool IOccupySpaceInfo.SharesCell => LocomotorInfo.SharesCell;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (startingCash.Any())
|
||||
yield return new LobbyOption("startingcash", DefaultCashDropdownLabel, DefaultCashDropdownDescription, DefaultCashDropdownVisible, DefaultCashDropdownDisplayOrder,
|
||||
new ReadOnlyDictionary<string, string>(startingCash), DefaultCash.ToString(), DefaultCashDropdownLocked);
|
||||
startingCash, DefaultCash.ToString(), DefaultCashDropdownLocked);
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new PlayerResources(init.Self, this); }
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
});
|
||||
|
||||
yield return new LobbyOption("timelimit", TimeLimitLabel, TimeLimitDescription, TimeLimitDropdownVisible, TimeLimitDisplayOrder,
|
||||
new ReadOnlyDictionary<string, string>(timelimits), TimeLimitDefault.ToString(), TimeLimitLocked);
|
||||
timelimits, TimeLimitDefault.ToString(), TimeLimitLocked);
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new TimeLimitManager(init.Self, this); }
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -80,8 +81,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Footprint = ios.OccupiedCells(Info, location, subCell);
|
||||
else
|
||||
{
|
||||
var footprint = new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } };
|
||||
Footprint = new ReadOnlyDictionary<CPos, SubCell>(footprint);
|
||||
Footprint = new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } };
|
||||
}
|
||||
|
||||
tooltip = Info.TraitInfos<EditorOnlyTooltipInfo>().FirstOrDefault(info => info.EnabledByDefault) as TooltipInfoBase
|
||||
|
||||
@@ -82,14 +82,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (techLevels.Any())
|
||||
yield return new LobbyOption("techlevel", TechLevelDropdownLabel, TechLevelDropdownDescription, TechLevelDropdownVisible, TechLevelDropdownDisplayOrder,
|
||||
new ReadOnlyDictionary<string, string>(techLevels), TechLevel, TechLevelDropdownLocked);
|
||||
techLevels, TechLevel, TechLevelDropdownLocked);
|
||||
|
||||
var gameSpeeds = Game.ModData.Manifest.Get<GameSpeeds>().Speeds
|
||||
.ToDictionary(s => s.Key, s => s.Value.Name);
|
||||
|
||||
// NOTE: The server hardcodes special-case logic for this option id
|
||||
yield return new LobbyOption("gamespeed", GameSpeedDropdownLabel, GameSpeedDropdownDescription, GameSpeedDropdownVisible, GameSpeedDropdownDisplayOrder,
|
||||
new ReadOnlyDictionary<string, string>(gameSpeeds), GameSpeed, GameSpeedDropdownLocked);
|
||||
gameSpeeds, GameSpeed, GameSpeedDropdownLocked);
|
||||
}
|
||||
|
||||
void IRulesetLoaded<ActorInfo>.RulesetLoaded(Ruleset rules, ActorInfo info)
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
|
||||
{
|
||||
yield return new LobbyOption(ID, Label, Description, Visible, DisplayOrder,
|
||||
new ReadOnlyDictionary<string, string>(Values), Default, Locked);
|
||||
Values, Default, Locked);
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new ScriptLobbyDropdown(this); }
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (startingUnits.Any())
|
||||
yield return new LobbyOption("startingunits", DropdownLabel, DropdownDescription, DropdownVisible, DropdownDisplayOrder,
|
||||
new ReadOnlyDictionary<string, string>(startingUnits), StartingUnitsClass, DropdownLocked);
|
||||
startingUnits, StartingUnitsClass, DropdownLocked);
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new SpawnStartingUnits(this); }
|
||||
|
||||
Reference in New Issue
Block a user