Remove our own ReadOnlyDictionary and update usages

This commit is contained in:
teinarss
2021-03-16 20:03:38 +01:00
committed by reaperrr
parent afbdb395b2
commit e12ff2c59d
44 changed files with 73 additions and 142 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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); }

View File

@@ -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); }