From 0d60ee5fe04b96288cdd29b2538448e955abc53a Mon Sep 17 00:00:00 2001 From: reaperrr Date: Mon, 14 Dec 2015 15:27:52 +0100 Subject: [PATCH] Disable WithSpriteTurret until build/transform complete --- .../Traits/Render/WithSpriteTurret.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithSpriteTurret.cs b/OpenRA.Mods.Common/Traits/Render/WithSpriteTurret.cs index 6a3d23ad31..fe48517623 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithSpriteTurret.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithSpriteTurret.cs @@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits } } - public class WithSpriteTurret : UpgradableTrait, ITick, INotifyDamageStateChanged + public class WithSpriteTurret : UpgradableTrait, INotifyBuildComplete, INotifySold, INotifyTransform, ITick, INotifyDamageStateChanged { public readonly Animation DefaultAnimation; protected readonly AttackBase Attack; @@ -65,6 +65,9 @@ namespace OpenRA.Mods.Common.Traits readonly Turreted t; readonly Armament[] arms; + // TODO: This should go away once https://github.com/OpenRA/OpenRA/issues/7035 is implemented + bool buildComplete; + public WithSpriteTurret(Actor self, WithSpriteTurretInfo info) : base(info) { @@ -75,11 +78,14 @@ namespace OpenRA.Mods.Common.Traits .First(tt => tt.Name == info.Turret); arms = self.TraitsImplementing() .Where(w => w.Info.Turret == info.Turret).ToArray(); + buildComplete = !self.Info.HasTraitInfo(); // always render instantly for units DefaultAnimation = new Animation(self.World, rs.GetImage(self), () => t.TurretFacing); DefaultAnimation.PlayRepeating(NormalizeSequence(self, info.Sequence)); - rs.Add(new AnimationWithOffset( - DefaultAnimation, () => TurretOffset(self), () => IsTraitDisabled, p => RenderUtils.ZOffsetFromCenter(self, p, 1))); + rs.Add(new AnimationWithOffset(DefaultAnimation, + () => TurretOffset(self), + () => IsTraitDisabled || !buildComplete, + p => RenderUtils.ZOffsetFromCenter(self, p, 1))); // Restrict turret facings to match the sprite t.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings; @@ -116,5 +122,12 @@ namespace OpenRA.Mods.Common.Traits var sequence = Attack.IsAttacking ? Info.AimSequence : Info.Sequence; DefaultAnimation.ReplaceAnim(sequence); } + + void INotifyBuildComplete.BuildingComplete(Actor self) { buildComplete = true; } + void INotifySold.Selling(Actor self) { buildComplete = false; } + void INotifySold.Sold(Actor self) { } + void INotifyTransform.BeforeTransform(Actor self) { buildComplete = false; } + void INotifyTransform.OnTransform(Actor self) { } + void INotifyTransform.AfterTransform(Actor toActor) { } } }