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:
RoosterDragon
2015-04-20 22:12:30 +01:00
parent 500a33b590
commit 2937a31463
9 changed files with 18 additions and 25 deletions

View File

@@ -61,7 +61,6 @@ namespace OpenRA.Mods.Common.Traits
{
var rs = self.Trait<RenderSprites>();
var body = self.Trait<IBodyOrientation>();
var disabled = self.TraitsImplementing<IDisable>();
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
overlay = new Animation(self.World, rs.GetImage(self));
@@ -70,7 +69,7 @@ namespace OpenRA.Mods.Common.Traits
new AnimationWithOffset(overlay,
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
() => IsTraitDisabled || !buildComplete,
() => info.PauseOnLowPower && disabled.Any(d => d.Disabled),
() => info.PauseOnLowPower && self.IsDisabled(),
p => WithTurret.ZOffsetFromCenter(self, p, 1)),
info.Palette, info.IsPlayerPalette);
}