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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user