Defer rollover checks while generating selection decorations

This commit is contained in:
abcdefg30
2021-07-19 22:47:00 +02:00
committed by Pavel Penev
parent 35e9fade06
commit 453d59ae16

View File

@@ -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)]
@@ -29,13 +29,11 @@ namespace OpenRA.Mods.Common.Traits
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();
@@ -157,12 +155,13 @@ namespace OpenRA.Mods.Common.Traits
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)