From cea9ceb72e5266c0ef6e0f50159ab2004028a9e6 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Wed, 8 Jun 2022 22:19:18 +0200 Subject: [PATCH] Support multiple With(Turret)AimAnimation traits --- .../Traits/Render/WithAimAnimation.cs | 16 +++++++++++++++- .../Traits/Render/WithTurretAimAnimation.cs | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithAimAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithAimAnimation.cs index b268cf76ca..944d763a8c 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithAimAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithAimAnimation.cs @@ -59,11 +59,25 @@ namespace OpenRA.Mods.Common.Traits.Render void INotifyAiming.StartedAiming(Actor self, AttackBase ab) { + // Ignore any notifications from INotifyAiming while this trait is disabled + // otherwise we replace the current animation without being active + if (IsTraitDisabled) + return; + // We know that at least one AttackBase is aiming UpdateSequence(true); } - void INotifyAiming.StoppedAiming(Actor self, AttackBase ab) { UpdateSequence(attackBases.Any(a => a.IsAiming)); } + void INotifyAiming.StoppedAiming(Actor self, AttackBase ab) + { + // Ignore any notifications from INotifyAiming while this trait is disabled + // otherwise we replace the current animation without being active + if (IsTraitDisabled) + return; + + UpdateSequence(attackBases.Any(a => a.IsAiming)); + } + protected override void TraitEnabled(Actor self) { UpdateSequence(attackBases.Any(a => a.IsAiming)); } protected override void TraitDisabled(Actor self) diff --git a/OpenRA.Mods.Common/Traits/Render/WithTurretAimAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithTurretAimAnimation.cs index 1ba04389c3..2aee3c24d8 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithTurretAimAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithTurretAimAnimation.cs @@ -59,11 +59,25 @@ namespace OpenRA.Mods.Common.Traits.Render void INotifyAiming.StartedAiming(Actor self, AttackBase ab) { + // Ignore any notifications from INotifyAiming while this trait is disabled + // otherwise we replace the current animation without being active + if (IsTraitDisabled) + return; + // We know that at least one AttackBase is aiming UpdateSequence(true); } - void INotifyAiming.StoppedAiming(Actor self, AttackBase ab) { UpdateSequence(attackBases.Any(a => a.IsAiming)); } + void INotifyAiming.StoppedAiming(Actor self, AttackBase ab) + { + // Ignore any notifications from INotifyAiming while this trait is disabled + // otherwise we replace the current animation without being active + if (IsTraitDisabled) + return; + + UpdateSequence(attackBases.Any(a => a.IsAiming)); + } + protected override void TraitEnabled(Actor self) { UpdateSequence(attackBases.Any(a => a.IsAiming)); } protected override void TraitDisabled(Actor self)