Fix CurrentAdjacentCells cache not acting as a cache

This commit is contained in:
Gustas
2023-08-07 18:46:24 +03:00
committed by Matthias Mailänder
parent e72d0ed2c6
commit 6040187844

View File

@@ -107,9 +107,9 @@ namespace OpenRA.Mods.Common.Traits
bool takeOffAfterLoad; bool takeOffAfterLoad;
bool initialised; bool initialised;
readonly CachedTransform<CPos, IEnumerable<CPos>> currentAdjacentCells; readonly CachedTransform<CPos, CPos[]> currentAdjacentCells;
public IEnumerable<CPos> CurrentAdjacentCells => currentAdjacentCells.Update(self.Location); public CPos[] CurrentAdjacentCells => currentAdjacentCells.Update(self.Location);
public IEnumerable<Actor> Passengers => cargo; public IEnumerable<Actor> Passengers => cargo;
public int PassengerCount => cargo.Count; public int PassengerCount => cargo.Count;
@@ -123,8 +123,8 @@ namespace OpenRA.Mods.Common.Traits
self = init.Self; self = init.Self;
checkTerrainType = info.UnloadTerrainTypes.Count > 0; checkTerrainType = info.UnloadTerrainTypes.Count > 0;
currentAdjacentCells = new CachedTransform<CPos, IEnumerable<CPos>>(loc => currentAdjacentCells = new CachedTransform<CPos, CPos[]>(loc =>
Util.AdjacentCells(self.World, Target.FromActor(self)).Where(c => loc != c)); Util.AdjacentCells(self.World, Target.FromActor(self)).Where(c => loc != c).ToArray());
var runtimeCargoInit = init.GetOrDefault<RuntimeCargoInit>(info); var runtimeCargoInit = init.GetOrDefault<RuntimeCargoInit>(info);
var cargoInit = init.GetOrDefault<CargoInit>(info); var cargoInit = init.GetOrDefault<CargoInit>(info);