From 5a889c0efd84bb426f22d0afda0953c61200c35b Mon Sep 17 00:00:00 2001 From: reaperrr Date: Wed, 15 Nov 2017 19:14:41 +0100 Subject: [PATCH] De-duplicate some WithTurretAttackAnimation code --- .../Render/WithTurretAttackAnimation.cs | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithTurretAttackAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithTurretAttackAnimation.cs index e1fd4c0b79..d512f2f8e9 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithTurretAttackAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithTurretAttackAnimation.cs @@ -55,32 +55,24 @@ namespace OpenRA.Mods.Common.Traits.Render wst.PlayCustomAnimation(self, Info.Sequence); } + void NotifyAttack(Actor self) + { + if (Info.Delay > 0) + tick = Info.Delay; + else + PlayAttackAnimation(self); + } + void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel) { - if (IsTraitDisabled || a != armament) - return; - - if (Info.DelayRelativeTo == AttackDelayType.Attack) - { - if (Info.Delay > 0) - tick = Info.Delay; - else - PlayAttackAnimation(self); - } + if (!IsTraitDisabled && a == armament && Info.DelayRelativeTo == AttackDelayType.Attack) + NotifyAttack(self); } void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { - if (IsTraitDisabled || a != armament) - return; - - if (Info.DelayRelativeTo == AttackDelayType.Preparation) - { - if (Info.Delay > 0) - tick = Info.Delay; - else - PlayAttackAnimation(self); - } + if (!IsTraitDisabled && a == armament && Info.DelayRelativeTo == AttackDelayType.Preparation) + NotifyAttack(self); } void ITick.Tick(Actor self)