Change classes that use FieldLoader to use read-only collections.
This commit is contained in:
committed by
Paul Chote
parent
797c71e500
commit
649e7e8c28
@@ -9,7 +9,8 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -30,17 +31,17 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[Desc("Time (in ticks) between actor spawn. Supports 1 or 2 values.",
|
||||
"If 2 values are provided they are used as a range from which a value is randomly selected.")]
|
||||
public readonly int[] SpawnInterval = [6000];
|
||||
public readonly ImmutableArray<int> SpawnInterval = [6000];
|
||||
|
||||
[FieldLoader.Require]
|
||||
[ActorReference]
|
||||
[Desc("Name of the actor that will be randomly picked to spawn.")]
|
||||
public readonly string[] Actors = [];
|
||||
public readonly ImmutableArray<string> Actors = [];
|
||||
|
||||
public readonly string Owner = "Creeps";
|
||||
|
||||
[Desc("Type of ActorSpawner with which it connects.")]
|
||||
public readonly HashSet<string> Types = [];
|
||||
public readonly FrozenSet<string> Types = FrozenSet<string>.Empty;
|
||||
|
||||
public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Immutable;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -21,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
string Type { get; }
|
||||
DamageState DamageState { get; }
|
||||
CVec[] NeighbourOffsets { get; }
|
||||
ImmutableArray<CVec> NeighbourOffsets { get; }
|
||||
bool Valid { get; }
|
||||
CPos Location { get; }
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Frozen;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class BuildableTerrainOverlayInfo : TraitInfo
|
||||
{
|
||||
[FieldLoader.Require]
|
||||
public readonly HashSet<string> AllowedTerrainTypes = null;
|
||||
public readonly FrozenSet<string> AllowedTerrainTypes = null;
|
||||
|
||||
[PaletteReference]
|
||||
[Desc("Palette to use for rendering the sprite.")]
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.MapGenerator;
|
||||
using OpenRA.Support;
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[FieldLoader.Require]
|
||||
[Desc("Tilesets that are compatible with this map generator.")]
|
||||
public readonly string[] Tilesets = null;
|
||||
public readonly ImmutableArray<string> Tilesets = default;
|
||||
|
||||
[FluentReference]
|
||||
[Desc("The title to use for generated maps.")]
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// This is purely of interest to the linter.
|
||||
[FieldLoader.LoadUsing(nameof(FluentReferencesLoader))]
|
||||
[FluentReference]
|
||||
public readonly List<string> FluentReferences = null;
|
||||
public readonly ImmutableArray<string> FluentReferences = default;
|
||||
|
||||
[FieldLoader.LoadUsing(nameof(SettingsLoader))]
|
||||
public readonly MiniYaml Settings;
|
||||
@@ -58,10 +58,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return my.NodeWithKey("Settings").Value;
|
||||
}
|
||||
|
||||
static List<string> FluentReferencesLoader(MiniYaml my)
|
||||
static object FluentReferencesLoader(MiniYaml my)
|
||||
{
|
||||
return new MapGeneratorSettings(null, my.NodeWithKey("Settings").Value)
|
||||
.Options.SelectMany(o => o.GetFluentReferences()).ToList();
|
||||
.Options.SelectMany(o => o.GetFluentReferences()).ToImmutableArray();
|
||||
}
|
||||
|
||||
public IMapGeneratorSettings GetSettings()
|
||||
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return new ClearMapGenerator(this);
|
||||
}
|
||||
|
||||
string[] IEditorMapGeneratorInfo.Tilesets => Tilesets;
|
||||
ImmutableArray<string> IEditorMapGeneratorInfo.Tilesets => Tilesets;
|
||||
}
|
||||
|
||||
public class ClearMapGenerator : IEditorTool
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Widgets;
|
||||
using OpenRA.Primitives;
|
||||
@@ -34,16 +36,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
const string InvalidPlayerColor = "notification-invalid-player-color";
|
||||
|
||||
[Desc("Minimum and maximum saturation levels that are valid for use.")]
|
||||
public readonly float[] HsvSaturationRange = [0.3f, 0.95f];
|
||||
public readonly ImmutableArray<float> HsvSaturationRange = [0.3f, 0.95f];
|
||||
|
||||
[Desc("Minimum and maximum value levels that are valid for use.")]
|
||||
public readonly float[] HsvValueRange = [0.3f, 0.95f];
|
||||
public readonly ImmutableArray<float> HsvValueRange = [0.3f, 0.95f];
|
||||
|
||||
[Desc("Perceptual color threshold for determining whether two colors are too similar.")]
|
||||
public readonly int SimilarityThreshold = 0x50;
|
||||
|
||||
[Desc("List of colors to be displayed in the palette tab.")]
|
||||
public readonly Color[] PresetColors = [];
|
||||
public readonly ImmutableArray<Color> PresetColors = [];
|
||||
|
||||
[ActorReference]
|
||||
[Desc("Actor type to show in the color picker. This can be overridden for specific factions with FactionPreviewActors.")]
|
||||
@@ -52,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[SequenceReference(dictionaryReference: LintDictionaryReference.Values)]
|
||||
[Desc("Actor type to show in the color picker for specific factions. Overrides PreviewActor.",
|
||||
"A dictionary of [faction name]: [actor name].")]
|
||||
public readonly Dictionary<string, string> FactionPreviewActors = [];
|
||||
public readonly FrozenDictionary<string, string> FactionPreviewActors = FrozenDictionary<string, string>.Empty;
|
||||
|
||||
public bool IsInvalidColor(Color color, IEnumerable<Color> candidateBlockers)
|
||||
{
|
||||
@@ -131,7 +133,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
(float SMin, float SMax) IColorPickerManagerInfo.SaturationRange => (HsvSaturationRange[0], HsvSaturationRange[1]);
|
||||
(float VMin, float VMax) IColorPickerManagerInfo.ValueRange => (HsvValueRange[0], HsvValueRange[1]);
|
||||
|
||||
Color[] IColorPickerManagerInfo.PresetColors => PresetColors;
|
||||
ImmutableArray<Color> IColorPickerManagerInfo.PresetColors => PresetColors;
|
||||
|
||||
Color IColorPickerManagerInfo.RandomPresetColor(
|
||||
MersenneTwister random,
|
||||
|
||||
@@ -18,18 +18,18 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class ControlGroupsInfo : TraitInfo, IControlGroupsInfo
|
||||
{
|
||||
public readonly string[] Groups = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
|
||||
public readonly ImmutableArray<string> Groups = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
|
||||
|
||||
public override object Create(ActorInitializer init) { return new ControlGroups(init.World, this); }
|
||||
|
||||
string[] IControlGroupsInfo.Groups => Groups;
|
||||
ImmutableArray<string> IControlGroupsInfo.Groups => Groups;
|
||||
}
|
||||
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
public class ControlGroups : IControlGroups, ITick, IGameSaveTraitData
|
||||
{
|
||||
readonly World world;
|
||||
public string[] Groups { get; }
|
||||
public ImmutableArray<string> Groups { get; }
|
||||
|
||||
readonly List<Actor>[] controlGroups;
|
||||
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Traits;
|
||||
@@ -53,20 +55,20 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly int InitialSpawnDelay = 0;
|
||||
|
||||
[Desc("Which terrain types can we drop on?")]
|
||||
public readonly HashSet<string> ValidGround = ["Clear", "Rough", "Road", "Ore", "Beach"];
|
||||
public readonly FrozenSet<string> ValidGround = new HashSet<string> { "Clear", "Rough", "Road", "Ore", "Beach" }.ToFrozenSet();
|
||||
|
||||
[Desc("Which terrain types count as water?")]
|
||||
public readonly HashSet<string> ValidWater = ["Water"];
|
||||
public readonly FrozenSet<string> ValidWater = new HashSet<string> { "Water" }.ToFrozenSet();
|
||||
|
||||
[Desc("Chance of generating a water crate instead of a land crate.")]
|
||||
public readonly int WaterChance = 20;
|
||||
|
||||
[ActorReference]
|
||||
[Desc("Crate actors to drop.")]
|
||||
public readonly string[] CrateActors = ["crate"];
|
||||
public readonly ImmutableArray<string> CrateActors = ["crate"];
|
||||
|
||||
[Desc("Chance of each crate actor spawning.")]
|
||||
public readonly int[] CrateActorShares = [10];
|
||||
public readonly ImmutableArray<int> CrateActorShares = [10];
|
||||
|
||||
[ActorReference]
|
||||
[Desc("If a DeliveryAircraft: is specified, then this actor will deliver crates.")]
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Support;
|
||||
@@ -128,7 +129,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
NonCombatant = true,
|
||||
Spectating = true,
|
||||
Faction = "Random",
|
||||
Allies = worldPlayers.Where(p => !p.NonCombatant && p.Playable).Select(p => p.InternalName).ToArray()
|
||||
Allies = worldPlayers.Where(p => !p.NonCombatant && p.Playable).Select(p => p.InternalName).ToImmutableArray()
|
||||
}, playerRandom));
|
||||
|
||||
w.SetPlayers(worldPlayers, localPlayer);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -342,7 +343,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var creeps = Players.Players.Keys.FirstOrDefault(p => p == "Creeps");
|
||||
if (!string.IsNullOrEmpty(creeps))
|
||||
Players.Players[creeps].Enemies = Players.Players.Keys.Where(p => !Players.Players[p].NonCombatant).ToArray();
|
||||
Players.Players[creeps].Enemies = Players.Players.Keys.Where(p => !Players.Players[p].NonCombatant).ToImmutableArray();
|
||||
}
|
||||
|
||||
void UpdateNeighbours(ReadOnlySpan<EditorActorPreview> previews)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -22,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class EditorResourceLayerInfo : TraitInfo, IResourceLayerInfo
|
||||
{
|
||||
[FieldLoader.LoadUsing(nameof(LoadResourceTypes))]
|
||||
public readonly Dictionary<string, ResourceLayerInfo.ResourceTypeInfo> ResourceTypes = null;
|
||||
public readonly FrozenDictionary<string, ResourceLayerInfo.ResourceTypeInfo> ResourceTypes = null;
|
||||
|
||||
// Copied from ResourceLayerInfo
|
||||
protected static object LoadResourceTypes(MiniYaml yaml)
|
||||
@@ -33,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var r in resources.Value.Nodes)
|
||||
ret[r.Key] = new ResourceLayerInfo.ResourceTypeInfo(r.Value);
|
||||
|
||||
return ret;
|
||||
return ret.ToFrozenDictionary();
|
||||
}
|
||||
|
||||
[Desc("Override the density saved in maps with values calculated based on the number of neighbouring resource cells.")]
|
||||
@@ -72,7 +73,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
protected readonly Map Map;
|
||||
protected readonly Dictionary<byte, string> ResourceTypesByIndex;
|
||||
protected readonly CellLayer<ResourceLayerContents> Tiles;
|
||||
protected Dictionary<string, int> resourceValues;
|
||||
protected FrozenDictionary<string, int> resourceValues;
|
||||
|
||||
public int NetWorth { get; protected set; }
|
||||
|
||||
@@ -109,7 +110,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public void WorldLoaded(World w, WorldRenderer wr)
|
||||
{
|
||||
var playerResourcesInfo = w.Map.Rules.Actors[SystemActors.Player].TraitInfoOrDefault<PlayerResourcesInfo>();
|
||||
resourceValues = playerResourcesInfo?.ResourceValues ?? [];
|
||||
resourceValues = playerResourcesInfo?.ResourceValues ?? FrozenDictionary<string, int>.Empty;
|
||||
|
||||
foreach (var cell in Map.AllCells)
|
||||
UpdateCell(cell);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
@@ -33,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[FieldLoader.Require]
|
||||
[Desc("Tilesets that are compatible with this map generator.")]
|
||||
public readonly string[] Tilesets = null;
|
||||
public readonly ImmutableArray<string> Tilesets = default;
|
||||
|
||||
[FluentReference]
|
||||
[Desc("The title to use for generated maps.")]
|
||||
@@ -45,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// This is purely of interest to the linter.
|
||||
[FieldLoader.LoadUsing(nameof(FluentReferencesLoader))]
|
||||
[FluentReference]
|
||||
public readonly List<string> FluentReferences = null;
|
||||
public readonly ImmutableArray<string> FluentReferences = default;
|
||||
|
||||
[FieldLoader.LoadUsing(nameof(SettingsLoader))]
|
||||
public readonly MiniYaml Settings;
|
||||
@@ -53,17 +54,17 @@ namespace OpenRA.Mods.Common.Traits
|
||||
string IMapGeneratorInfo.Type => Type;
|
||||
string IMapGeneratorInfo.Name => Name;
|
||||
string IMapGeneratorInfo.MapTitle => MapTitle;
|
||||
string[] IEditorMapGeneratorInfo.Tilesets => Tilesets;
|
||||
ImmutableArray<string> IEditorMapGeneratorInfo.Tilesets => Tilesets;
|
||||
|
||||
static MiniYaml SettingsLoader(MiniYaml my)
|
||||
{
|
||||
return my.NodeWithKey("Settings").Value;
|
||||
}
|
||||
|
||||
static List<string> FluentReferencesLoader(MiniYaml my)
|
||||
static object FluentReferencesLoader(MiniYaml my)
|
||||
{
|
||||
return new MapGeneratorSettings(null, my.NodeWithKey("Settings").Value)
|
||||
.Options.SelectMany(o => o.GetFluentReferences()).ToList();
|
||||
.Options.SelectMany(o => o.GetFluentReferences()).ToImmutableArray();
|
||||
}
|
||||
|
||||
const int FractionMax = Terraformer.FractionMax;
|
||||
@@ -280,7 +281,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return my.NodeWithKey(key).Value.Value
|
||||
.Split(',', StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(terrainInfo.GetTerrainIndex)
|
||||
.ToImmutableHashSet();
|
||||
.ToFrozenSet();
|
||||
}
|
||||
|
||||
IReadOnlyList<string> ParseSegmentTypes(string key)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -22,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class LegacyBridgeLayerInfo : TraitInfo
|
||||
{
|
||||
[ActorReference]
|
||||
public readonly string[] Bridges = ["bridge1", "bridge2"];
|
||||
public readonly ImmutableArray<string> Bridges = ["bridge1", "bridge2"];
|
||||
|
||||
public override object Create(ActorInitializer init) { return new LegacyBridgeLayer(init.Self, this); }
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -80,7 +81,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[FieldLoader.LoadUsing(nameof(LoadSpeeds), true)]
|
||||
[Desc("Lower the value on rough terrain. Leave out entries for impassable terrain.")]
|
||||
public readonly Dictionary<string, TerrainInfo> TerrainSpeeds;
|
||||
public readonly FrozenDictionary<string, TerrainInfo> TerrainSpeeds;
|
||||
|
||||
protected static object LoadSpeeds(MiniYaml y)
|
||||
{
|
||||
@@ -99,8 +100,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
ret.TrimExcess();
|
||||
return ret;
|
||||
return ret.ToFrozenDictionary();
|
||||
}
|
||||
|
||||
public class TerrainInfo
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Widgets.Logic;
|
||||
@@ -62,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
sealed class AssignSpawnLocationsState
|
||||
{
|
||||
public CPos[] SpawnLocations;
|
||||
public ImmutableArray<CPos> SpawnLocations;
|
||||
public List<int> AvailableSpawnPoints;
|
||||
public readonly Dictionary<int, Session.Client> OccupiedSpawnPoints = [];
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Immutable;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -26,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string ClassName = "Unlabeled";
|
||||
|
||||
[Desc("Only available when selecting one of these factions.", "Leave empty for no restrictions.")]
|
||||
public readonly HashSet<string> Factions = [];
|
||||
public readonly FrozenSet<string> Factions = FrozenSet<string>.Empty;
|
||||
|
||||
[Desc("The actor at the center, usually the mobile construction vehicle.")]
|
||||
[ActorReference]
|
||||
@@ -37,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[Desc("A group of units ready to defend or scout.")]
|
||||
[ActorReference]
|
||||
public readonly string[] SupportActors = [];
|
||||
public readonly ImmutableArray<string> SupportActors = [];
|
||||
|
||||
[Desc("Inner radius for spawning support actors")]
|
||||
public readonly int InnerSupportRadius = 2;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
@@ -33,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[FluentReference(LintDictionaryReference.Keys)]
|
||||
[Desc("A list of colors to be used for drawing.")]
|
||||
public readonly Dictionary<string, Color> Colors = new()
|
||||
public readonly FrozenDictionary<string, Color> Colors = new Dictionary<string, Color>
|
||||
{
|
||||
{ "notification-added-marker-tiles-markers.red", Color.FromArgb(255, 0, 0) },
|
||||
{ "notification-added-marker-tiles-markers.orange", Color.FromArgb(255, 127, 0) },
|
||||
@@ -43,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{ "notification-added-marker-tiles-markers.blue", Color.FromArgb(0, 42, 255) },
|
||||
{ "notification-added-marker-tiles-markers.purple", Color.FromArgb(165, 0, 255) },
|
||||
{ "notification-added-marker-tiles-markers.magenta", Color.FromArgb(255, 0, 220) }
|
||||
};
|
||||
}.ToFrozenDictionary();
|
||||
|
||||
[Desc("Default alpha blend.")]
|
||||
public readonly int Alpha = 85;
|
||||
@@ -174,7 +175,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
NumSides = file.NumSides;
|
||||
AxisAngle = file.AxisAngle;
|
||||
|
||||
SetAll(file.Tiles.ToImmutableDictionary(d => d.Key, d => d.Value.ToImmutableArray()));
|
||||
SetAll(file.Tiles.ToFrozenDictionary(d => d.Key, d => d.Value.ToImmutableArray()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -204,7 +205,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Tiles.Clear();
|
||||
}
|
||||
|
||||
public void SetAll(IImmutableDictionary<int, ImmutableArray<CPos>> newTiles)
|
||||
public void SetAll(FrozenDictionary<int, ImmutableArray<CPos>> newTiles)
|
||||
{
|
||||
ClearAll();
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -40,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[FieldLoader.Require]
|
||||
[Desc("Terrain types that this resource can spawn on.")]
|
||||
public readonly HashSet<string> AllowedTerrainTypes = null;
|
||||
public readonly FrozenSet<string> AllowedTerrainTypes = null;
|
||||
|
||||
[Desc("Maximum number of resource units allowed in a single cell.")]
|
||||
public readonly byte MaxDensity = 10;
|
||||
@@ -52,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
[FieldLoader.LoadUsing(nameof(LoadResourceTypes))]
|
||||
public readonly Dictionary<string, ResourceTypeInfo> ResourceTypes = null;
|
||||
public readonly FrozenDictionary<string, ResourceTypeInfo> ResourceTypes = null;
|
||||
|
||||
[Desc("Override the density saved in maps with values calculated based on the number of neighbouring resource cells.")]
|
||||
public readonly bool RecalculateResourceDensity = false;
|
||||
@@ -66,7 +67,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var r in resources.Value.Nodes)
|
||||
ret[r.Key] = new ResourceTypeInfo(r.Value);
|
||||
|
||||
return ret;
|
||||
return ret.ToFrozenDictionary();
|
||||
}
|
||||
|
||||
bool IResourceLayerInfo.TryGetTerrainType(string resourceType, out string terrainType)
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -31,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[FieldLoader.Require]
|
||||
[SequenceReference(nameof(Image))]
|
||||
[Desc("Randomly chosen image sequences.")]
|
||||
public readonly string[] Sequences = [];
|
||||
public readonly ImmutableArray<string> Sequences = [];
|
||||
|
||||
[PaletteReference]
|
||||
[Desc("Palette used for rendering the resource sprites.")]
|
||||
@@ -50,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[IncludeFluentReferences(LintDictionaryReference.Values)]
|
||||
[FieldLoader.LoadUsing(nameof(LoadResourceTypes))]
|
||||
public readonly Dictionary<string, ResourceTypeInfo> ResourceTypes = null;
|
||||
public readonly FrozenDictionary<string, ResourceTypeInfo> ResourceTypes = null;
|
||||
|
||||
// Copied from ResourceLayerInfo
|
||||
protected static object LoadResourceTypes(MiniYaml yaml)
|
||||
@@ -61,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var r in resources.Value.Nodes)
|
||||
ret[r.Key] = new ResourceTypeInfo(r.Value);
|
||||
|
||||
return ret;
|
||||
return ret.ToFrozenDictionary();
|
||||
}
|
||||
|
||||
void IMapPreviewSignatureInfo.PopulateMapPreviewSignatureCells(Map map, ActorInfo ai, ActorReference s, List<(MPos Uv, Color Color)> destinationBuffer)
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -24,10 +25,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public readonly string Sequence = "shroud";
|
||||
[SequenceReference(nameof(Sequence))]
|
||||
public readonly string[] ShroudVariants = ["shroud"];
|
||||
public readonly ImmutableArray<string> ShroudVariants = ["shroud"];
|
||||
|
||||
[SequenceReference(nameof(Sequence))]
|
||||
public readonly string[] FogVariants = ["fog"];
|
||||
public readonly ImmutableArray<string> FogVariants = ["fog"];
|
||||
|
||||
[PaletteReference]
|
||||
public readonly string ShroudPalette = "shroud";
|
||||
@@ -37,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[Desc("Bitfield of shroud directions for each frame. Lower four bits are",
|
||||
"corners clockwise from TL; upper four are edges clockwise from top")]
|
||||
public readonly int[] Index = [12, 9, 8, 3, 1, 6, 4, 2, 13, 11, 7, 14];
|
||||
public readonly ImmutableArray<int> Index = [12, 9, 8, 3, 1, 6, 4, 2, 13, 11, 7, 14];
|
||||
|
||||
[Desc("Use the upper four bits when calculating frame")]
|
||||
public readonly bool UseExtendedIndex = false;
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -46,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[SequenceReference(nameof(SmokeImage), allowNullImage: true)]
|
||||
[Desc("Smoke sprite sequences randomly chosen from")]
|
||||
public readonly string[] SmokeSequences = [];
|
||||
public readonly ImmutableArray<string> SmokeSequences = [];
|
||||
|
||||
[PaletteReference]
|
||||
public readonly string SmokePalette = "effect";
|
||||
@@ -55,7 +57,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string Palette = TileSet.TerrainPaletteInternalName;
|
||||
|
||||
[FieldLoader.LoadUsing(nameof(LoadInitialSmudges))]
|
||||
public readonly Dictionary<CPos, MapSmudge> InitialSmudges;
|
||||
public readonly FrozenDictionary<CPos, MapSmudge> InitialSmudges;
|
||||
|
||||
public static object LoadInitialSmudges(MiniYaml yaml)
|
||||
{
|
||||
@@ -77,7 +79,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
return smudges;
|
||||
return smudges.ToFrozenDictionary();
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new SmudgeLayer(init.Self, this); }
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Frozen;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly short SubterraneanTransitionCost = 0;
|
||||
|
||||
[Desc("The terrain types that this actor can transition on. Leave empty to allow any.")]
|
||||
public readonly HashSet<string> SubterraneanTransitionTerrainTypes = [];
|
||||
public readonly FrozenSet<string> SubterraneanTransitionTerrainTypes = FrozenSet<string>.Empty;
|
||||
|
||||
[Desc("Can this actor transition on slopes?")]
|
||||
public readonly bool SubterraneanTransitionOnRamps = false;
|
||||
|
||||
@@ -27,11 +27,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public sealed class TilingPathToolInfo : TraitInfo
|
||||
{
|
||||
[Desc("The preferred defaults for the start type.")]
|
||||
public readonly string[] DefaultStart = [];
|
||||
public readonly ImmutableArray<string> DefaultStart = [];
|
||||
[Desc("The preferred defaults for the inner type.")]
|
||||
public readonly string[] DefaultInner = [];
|
||||
public readonly ImmutableArray<string> DefaultInner = [];
|
||||
[Desc("The preferred defaults for the end type.")]
|
||||
public readonly string[] DefaultEnd = [];
|
||||
public readonly ImmutableArray<string> DefaultEnd = [];
|
||||
|
||||
public override object Create(ActorInitializer init)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Widgets;
|
||||
using OpenRA.Primitives;
|
||||
@@ -32,10 +34,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string TimeLimitDescription = "dropdown-time-limit.description";
|
||||
|
||||
[Desc("Time Limit options that will be shown in the lobby dropdown. Values are in minutes.")]
|
||||
public readonly int[] TimeLimitOptions = [0, 10, 20, 30, 40, 60, 90];
|
||||
public readonly ImmutableArray<int> TimeLimitOptions = [0, 10, 20, 30, 40, 60, 90];
|
||||
|
||||
[Desc("List of remaining minutes of game time when a text and optional speech notification should be made to players.")]
|
||||
public readonly Dictionary<int, string> TimeLimitWarnings = new()
|
||||
public readonly FrozenDictionary<int, string> TimeLimitWarnings = new Dictionary<int, string>
|
||||
{
|
||||
{ 1, null },
|
||||
{ 2, null },
|
||||
@@ -43,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{ 4, null },
|
||||
{ 5, null },
|
||||
{ 10, null },
|
||||
};
|
||||
}.ToFrozenDictionary();
|
||||
|
||||
[Desc("Default selection for the time limit option in the lobby. Needs to use one of the TimeLimitOptions.")]
|
||||
public readonly int TimeLimitDefault = 0;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Primitives;
|
||||
@@ -28,10 +29,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class WarheadDebugOverlay : IRenderAnnotations
|
||||
{
|
||||
sealed class WHImpact(WPos pos, WDist[] range, int time, Color color)
|
||||
sealed class WHImpact(WPos pos, ImmutableArray<WDist> range, int time, Color color)
|
||||
{
|
||||
public readonly WPos CenterPosition = pos;
|
||||
public readonly WDist[] Range = range;
|
||||
public readonly ImmutableArray<WDist> Range = range;
|
||||
public readonly Color Color = color;
|
||||
public int Time = time;
|
||||
|
||||
@@ -46,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void AddImpact(WPos pos, WDist[] range, Color color)
|
||||
public void AddImpact(WPos pos, ImmutableArray<WDist> range, Color color)
|
||||
{
|
||||
impacts.Add(new WHImpact(pos, range, info.DisplayDuration, color));
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Support;
|
||||
@@ -28,10 +29,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly bool ChangingWindLevel = true;
|
||||
|
||||
[Desc("The levels of wind intensity (particles x-axis movement in px/tick).")]
|
||||
public readonly int[] WindLevels = [-12, -7, -5, 0, 5, 7, 12];
|
||||
public readonly ImmutableArray<int> WindLevels = [-12, -7, -5, 0, 5, 7, 12];
|
||||
|
||||
[Desc("Works only if ChangingWindLevel is enabled. Min. and max. ticks needed to change the WindLevel.")]
|
||||
public readonly int[] WindTick = [150, 550];
|
||||
public readonly ImmutableArray<int> WindTick = [150, 550];
|
||||
|
||||
[Desc("Hard or soft fading between the WindLevels.")]
|
||||
public readonly bool InstantWindChanges = false;
|
||||
@@ -40,25 +41,25 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly bool UseSquares = true;
|
||||
|
||||
[Desc("Size / width of the particle in px.")]
|
||||
public readonly int[] ParticleSize = [1, 3];
|
||||
public readonly ImmutableArray<int> ParticleSize = [1, 3];
|
||||
|
||||
[Desc("Scatters falling direction on the x-axis. Scatter min. and max. value in px/tick.")]
|
||||
public readonly int[] ScatterDirection = [-1, 1];
|
||||
public readonly ImmutableArray<int> ScatterDirection = [-1, 1];
|
||||
|
||||
[Desc("Min. and max. speed at which particles fall in px/tick.")]
|
||||
public readonly float[] Gravity = [2.5f, 5f];
|
||||
public readonly ImmutableArray<float> Gravity = [2.5f, 5f];
|
||||
|
||||
[Desc("The current offset value for the swing movement. SwingOffset min. and max. value in px/tick.")]
|
||||
public readonly float[] SwingOffset = [2.5f, 3.5f];
|
||||
public readonly ImmutableArray<float> SwingOffset = [2.5f, 3.5f];
|
||||
|
||||
[Desc("The value that particles swing to the side each update. SwingSpeed min. and max. value in px/tick.")]
|
||||
public readonly float[] SwingSpeed = [0.0025f, 0.06f];
|
||||
public readonly ImmutableArray<float> SwingSpeed = [0.0025f, 0.06f];
|
||||
|
||||
[Desc("The value range that can be swung to the left or right. SwingAmplitude min. and max. value in px/tick.")]
|
||||
public readonly float[] SwingAmplitude = [1.0f, 1.5f];
|
||||
public readonly ImmutableArray<float> SwingAmplitude = [1.0f, 1.5f];
|
||||
|
||||
[Desc("The randomly selected rgb(a) hex colors for the particles. Use this order: rrggbb[aa], rrggbb[aa], ...")]
|
||||
public readonly Color[] ParticleColors =
|
||||
public readonly ImmutableArray<Color> ParticleColors =
|
||||
[
|
||||
Color.FromArgb(236, 236, 236),
|
||||
Color.FromArgb(228, 228, 228),
|
||||
|
||||
Reference in New Issue
Block a user