Change classes that use FieldLoader to use read-only collections.

This commit is contained in:
RoosterDragon
2025-11-08 12:40:56 +00:00
committed by Paul Chote
parent 797c71e500
commit 649e7e8c28
308 changed files with 1233 additions and 901 deletions

View File

@@ -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.Mods.Common.Orders;
@@ -26,10 +28,10 @@ namespace OpenRA.Mods.Common.Traits
public readonly int MaxWeight = 0;
[Desc("`Passenger.CargoType`s that can be loaded into this actor.")]
public readonly HashSet<string> Types = [];
public readonly FrozenSet<string> Types = FrozenSet<string>.Empty;
[Desc("A list of actor types that are initially spawned into this actor.")]
public readonly string[] InitialUnits = [];
public readonly ImmutableArray<string> InitialUnits = [];
[Desc("When this actor is sold should all of its passengers be unloaded?")]
public readonly bool EjectOnSell = true;
@@ -38,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly bool EjectOnDeath = false;
[Desc("Terrain types that this actor is allowed to eject actors onto. Leave empty for all terrain types.")]
public readonly HashSet<string> UnloadTerrainTypes = [];
public readonly FrozenSet<string> UnloadTerrainTypes = FrozenSet<string>.Empty;
[VoiceReference]
[Desc("Voice to play when ordered to unload the passengers.")]
@@ -82,7 +84,7 @@ namespace OpenRA.Mods.Common.Traits
[ActorReference(dictionaryReference: LintDictionaryReference.Keys)]
[Desc("Conditions to grant when specified actors are loaded inside the transport.",
"A dictionary of [actor name]: [condition].")]
public readonly Dictionary<string, string> PassengerConditions = [];
public readonly FrozenDictionary<string, string> PassengerConditions = FrozenDictionary<string, string>.Empty;
[GrantedConditionReference]
public IEnumerable<string> LinterPassengerConditions => PassengerConditions.Values;