Fix CA1851, assume_method_enumerates_parameters = true

This commit is contained in:
RoosterDragon
2023-07-14 20:30:08 +01:00
committed by abcdefg30
parent 3275875ae5
commit 93a97d5d6f
37 changed files with 108 additions and 96 deletions

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
public class Selection : ISelection, INotifyCreated, INotifyOwnerChanged, ITick, IGameSaveTraitData
{
public int Hash { get; private set; }
public IEnumerable<Actor> Actors => actors;
public IReadOnlyCollection<Actor> Actors => actors;
readonly HashSet<Actor> actors = new();
readonly List<Actor> rolloverActors = new();
@@ -91,10 +91,13 @@ namespace OpenRA.Mods.Common.Traits
public virtual void Combine(World world, IEnumerable<Actor> newSelection, bool isCombine, bool isClick)
{
var newSelectionCollection = newSelection as IReadOnlyCollection<Actor>;
newSelectionCollection ??= newSelection.ToList();
if (isClick)
{
// TODO: select BEST, not FIRST
var adjNewSelection = newSelection.Take(1);
var adjNewSelection = newSelectionCollection.Take(1);
if (isCombine)
actors.SymmetricExceptWith(adjNewSelection);
else
@@ -106,17 +109,17 @@ namespace OpenRA.Mods.Common.Traits
else
{
if (isCombine)
actors.UnionWith(newSelection);
actors.UnionWith(newSelectionCollection);
else
{
actors.Clear();
actors.UnionWith(newSelection);
actors.UnionWith(newSelectionCollection);
}
}
UpdateHash();
foreach (var a in newSelection)
foreach (var a in newSelectionCollection)
foreach (var sel in a.TraitsImplementing<INotifySelected>())
sel.Selected(a);