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.
This commit is contained in:
RoosterDragon
2024-03-14 19:07:38 +00:00
committed by Gustas
parent 4fca85f63d
commit c18d10c846

View File

@@ -116,7 +116,7 @@ namespace OpenRA.Mods.Common
protected override bool ShouldIndexActor(Actor actor)
{
return names.Contains(actor.Info.Name) && actor.TraitOrDefault<T>() != null;
return names.Contains(actor.Info.Name) && actor.TraitsImplementing<T>().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<T>() != null;
return actor.Owner == owner && names.Contains(actor.Info.Name) && actor.TraitsImplementing<T>().Any();
}
}
}