Make IsDisabled a method on Actor.
This allows us to cache the disabled traits, which simplifies life for some callers since we relieve them of having to cache it, as well as improving perf for all IsDisabled calls.
This commit is contained in:
@@ -30,13 +30,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class WithActiveAnimation : ITick, INotifyBuildComplete, INotifySold
|
||||
{
|
||||
readonly IEnumerable<IDisable> disabled;
|
||||
readonly WithActiveAnimationInfo info;
|
||||
readonly RenderBuilding renderBuilding;
|
||||
|
||||
public WithActiveAnimation(Actor self, WithActiveAnimationInfo info)
|
||||
{
|
||||
disabled = self.TraitsImplementing<IDisable>();
|
||||
renderBuilding = self.Trait<RenderBuilding>();
|
||||
this.info = info;
|
||||
}
|
||||
@@ -49,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (--ticks <= 0)
|
||||
{
|
||||
if (!(info.PauseOnLowPower && disabled.Any(d => d.Disabled)))
|
||||
if (!(info.PauseOnLowPower && self.IsDisabled()))
|
||||
renderBuilding.PlayCustomAnim(self, info.Sequence);
|
||||
ticks = info.Interval;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user