diff --git a/RotationSolver/Updaters/TargetUpdater.cs b/RotationSolver/Updaters/TargetUpdater.cs index 493740e01..81ccc99c5 100644 --- a/RotationSolver/Updaters/TargetUpdater.cs +++ b/RotationSolver/Updaters/TargetUpdater.cs @@ -404,24 +404,24 @@ private static IEnumerable GetPartyMembers(IEnumerable private static void MaintainDeathPeople(ref IEnumerable deathAll, ref IEnumerable deathParty) { SortedDictionary locs = new(); - foreach (var item in deathAll) + if (!deathAll.Any() && !deathParty.Any()) { - if (item is null) continue; - locs[item.ObjectId] = item.Position; + // Both collections are empty, nothing to maintain + return; } - foreach (var item in deathParty) + void ProcessCollection(IEnumerable collection) { - if (item is null) continue; - locs[item.ObjectId] = item.Position; - } - if (deathAll is not null) - { - deathAll = FilterForDeath(deathAll); - } - if (deathParty is not null) - { - deathParty = FilterForDeath(deathParty); + foreach (var item in collection ?? Enumerable.Empty()) + { + locs[item.ObjectId] = item?.Position ?? Vector3.Zero; + } } + + ProcessCollection(deathAll); + ProcessCollection(deathParty); + + deathAll = FilterForDeath(deathAll); + deathParty = FilterForDeath(deathParty); _locations = locs; }