De-duplicate some WithTurretAttackAnimation code

This commit is contained in:
reaperrr
2017-11-15 19:14:41 +01:00
committed by abcdefg30
parent 769a49ef0b
commit 5a889c0efd

View File

@@ -55,32 +55,24 @@ namespace OpenRA.Mods.Common.Traits.Render
wst.PlayCustomAnimation(self, Info.Sequence); 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) void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
{ {
if (IsTraitDisabled || a != armament) if (!IsTraitDisabled && a == armament && Info.DelayRelativeTo == AttackDelayType.Attack)
return; NotifyAttack(self);
if (Info.DelayRelativeTo == AttackDelayType.Attack)
{
if (Info.Delay > 0)
tick = Info.Delay;
else
PlayAttackAnimation(self);
}
} }
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel)
{ {
if (IsTraitDisabled || a != armament) if (!IsTraitDisabled && a == armament && Info.DelayRelativeTo == AttackDelayType.Preparation)
return; NotifyAttack(self);
if (Info.DelayRelativeTo == AttackDelayType.Preparation)
{
if (Info.Delay > 0)
tick = Info.Delay;
else
PlayAttackAnimation(self);
}
} }
void ITick.Tick(Actor self) void ITick.Tick(Actor self)