Tweaks for map generator performance.

The map generator is already performant, but we can remove a few rough edges from infrastructure it interacts with.

- Add TypeDictionary constructor to clone from an existing copy. The map editor infrastructure relies heavily on cloning ActorReferences and the underlying dictionaries. A dedicated clone method avoids reflection overhead for CreateTypeContainer on a fresh instance.
- Use ThrowIndexOutOfRangeException helper. This allows the Index method to be inlined.
- Reuse lists in FloodFill. This avoids allocating and resizing new lists on each loop when we can reuse the existing capacity.
- Manage CellEntryChanged at the layer rather than individual previews. We only need to attach/detach from the delegate once at the layer, rather than many times as previews are added and removed.
This commit is contained in:
RoosterDragon
2025-11-24 19:10:39 +00:00
committed by Gustas Kažukauskas
parent 3ea5b08848
commit a546ca2f92
10 changed files with 62 additions and 49 deletions

View File

@@ -54,9 +54,7 @@ namespace OpenRA.Mods.Common.Traits
var exitLocations = new List<CPos>();
// Clone the initializer dictionary for the new actor
var td = new TypeDictionary();
foreach (var init in inits)
td.Add(init);
var td = new TypeDictionary(inits);
if (exitinfo != null && self.OccupiesSpace != null && producee.HasTraitInfo<IOccupySpaceInfo>())
{