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

@@ -27,19 +27,17 @@ namespace OpenRA.Mods.Common.Traits
public class WithRepairAnimation : INotifyRepair
{
IEnumerable<IDisable> disabled;
WithRepairAnimationInfo info;
public WithRepairAnimation(Actor self, WithRepairAnimationInfo info)
{
disabled = self.TraitsImplementing<IDisable>();
this.info = info;
}
public void Repairing(Actor self, Actor host)
{
var building = host.TraitOrDefault<RenderBuilding>();
if (building != null && !(info.PauseOnLowPower && disabled.Any(d => d.Disabled)))
if (building != null && !(info.PauseOnLowPower && self.IsDisabled()))
building.PlayCustomAnim(host, info.Sequence);
}
}