Change classes that use FieldLoader to use read-only collections.
This commit is contained in:
committed by
Paul Chote
parent
797c71e500
commit
649e7e8c28
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -69,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[ActorReference(dictionaryReference: LintDictionaryReference.Keys)]
|
||||
[Desc("Conditions to grant when a specified actor is being carried.",
|
||||
"A dictionary of [actor name]: [condition].")]
|
||||
public readonly Dictionary<string, string> CarryableConditions = [];
|
||||
public readonly FrozenDictionary<string, string> CarryableConditions = FrozenDictionary<string, string>.Empty;
|
||||
|
||||
[VoiceReference]
|
||||
public readonly string Voice = "Action";
|
||||
@@ -107,7 +108,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
WAngle cachedFacing;
|
||||
IActorPreview[] carryablePreview;
|
||||
HashSet<string> landableTerrainTypes;
|
||||
FrozenSet<string> landableTerrainTypes;
|
||||
int carryConditionToken = Actor.InvalidConditionToken;
|
||||
int carryableConditionToken = Actor.InvalidConditionToken;
|
||||
|
||||
@@ -197,7 +198,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
HashSet<string> IOverrideAircraftLanding.LandableTerrainTypes => landableTerrainTypes ?? aircraft.Info.LandableTerrainTypes;
|
||||
FrozenSet<string> IOverrideAircraftLanding.LandableTerrainTypes => landableTerrainTypes ?? aircraft.Info.LandableTerrainTypes;
|
||||
|
||||
public virtual bool AttachCarryable(Actor self, Actor carryable)
|
||||
{
|
||||
@@ -214,7 +215,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
carryableConditionToken = self.GrantCondition(carryableCondition);
|
||||
|
||||
CarryableOffset = OffsetForCarryable(self, carryable);
|
||||
landableTerrainTypes = Carryable.Trait<Mobile>().Info.LocomotorInfo.TerrainSpeeds.Keys.ToHashSet();
|
||||
landableTerrainTypes = Carryable.Trait<Mobile>().Info.LocomotorInfo.TerrainSpeeds.Keys.ToFrozenSet();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user