Skip to content

Commit

Permalink
Defer rollover checks while generating selection decorations
Browse files Browse the repository at this point in the history
  • Loading branch information
abcdefg30 committed Aug 4, 2021
1 parent 35e9fad commit 1ec1320
Showing 1 changed file with 5 additions and 6 deletions.
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

0 comments on commit 1ec1320

Please sign in to comment.