From c18d10c846fa083b7ca13c1f845b570c9eda6509 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Thu, 14 Mar 2024 19:07:38 +0000 Subject: [PATCH] Fix ActorIndex when dealing with multiple trait instances. The intended check was "has any trait", but TraitOrDefault throws if there is more than one. Adjust this check so it doesn't throw in the face of multiple trait instances. Resolves a regression introduced in 63de527d9e0a90e2f055dc302dacca855092ebfa. --- OpenRA.Mods.Common/ActorIndex.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/ActorIndex.cs b/OpenRA.Mods.Common/ActorIndex.cs index f438e0ceb1..4075bbd4de 100644 --- a/OpenRA.Mods.Common/ActorIndex.cs +++ b/OpenRA.Mods.Common/ActorIndex.cs @@ -116,7 +116,7 @@ namespace OpenRA.Mods.Common protected override bool ShouldIndexActor(Actor actor) { - return names.Contains(actor.Info.Name) && actor.TraitOrDefault() != null; + return names.Contains(actor.Info.Name) && actor.TraitsImplementing().Any(); } } @@ -145,7 +145,7 @@ namespace OpenRA.Mods.Common protected override bool ShouldIndexActor(Actor actor) { - return actor.Owner == owner && names.Contains(actor.Info.Name) && actor.TraitOrDefault() != null; + return actor.Owner == owner && names.Contains(actor.Info.Name) && actor.TraitsImplementing().Any(); } } }