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