Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer rollover checks while generating selection decorations #19546

Merged
merged 1 commit into from Aug 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions OpenRA.Mods.Common/Traits/World/Selection.cs
Expand Up @@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
{
public class SelectionInfo : TraitInfo
{
public override object Create(ActorInitializer init) { return new Selection(this); }
public override object Create(ActorInitializer init) { return new Selection(); }
}

[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
Expand All @@ -29,13 +29,11 @@ public class Selection : ISelection, INotifyCreated, INotifyOwnerChanged, ITick,
public IEnumerable<Actor> Actors => actors;

readonly HashSet<Actor> actors = new HashSet<Actor>();
readonly List<Actor> rolloverActors = new List<Actor>();
World world;
IEnumerable<Actor> rolloverActors;

INotifySelection[] worldNotifySelection;

public Selection(SelectionInfo info) { }

void INotifyCreated.Created(Actor self)
{
worldNotifySelection = self.TraitsImplementing<INotifySelection>().ToArray();
Expand Down Expand Up @@ -157,12 +155,13 @@ public void Clear()

public void SetRollover(IEnumerable<Actor> rollover)
{
rolloverActors = rollover;
rolloverActors.Clear();
rolloverActors.AddRange(rollover);
}

public bool RolloverContains(Actor a)
{
return rolloverActors != null && rolloverActors.Contains(a);
return rolloverActors.Contains(a);
}

void ITick.Tick(Actor self)
Expand Down