From 0d60ee5fe04b96288cdd29b2538448e955abc53a Mon Sep 17 00:00:00 2001 From: reaperrr Date: Mon, 14 Dec 2015 15:27:52 +0100 Subject: [PATCH 1/3] 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) { } } } From e5b3291d415c590a6531d166af4f4d5214fd7dd8 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Mon, 14 Dec 2015 15:28:31 +0100 Subject: [PATCH 2/3] Enable crumble overlay for D2k turrets --- mods/d2k/rules/defaults.yaml | 1 - mods/d2k/sequences/structures.yaml | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index 689e59978d..11580521eb 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -293,7 +293,6 @@ AutoTarget: RenderRangeCircle: -GivesBuildableArea: - -WithCrumbleOverlay: -WithMakeAnimation: -WithSpriteBody: WithWallSpriteBody: diff --git a/mods/d2k/sequences/structures.yaml b/mods/d2k/sequences/structures.yaml index 9b05d56556..c5c8fec686 100644 --- a/mods/d2k/sequences/structures.yaml +++ b/mods/d2k/sequences/structures.yaml @@ -30,6 +30,10 @@ medium_gun_turret: Frames: 2621, 2624, 2622, 2632, 2625, 2626, 2636, 2629, 2623, 2633, 2627, 2628, 2634, 2630, 2631, 2635 Length: 16 Offset: -24,16 + crumble-overlay: DATA.R8 + Start: 4321 + Length: 7 + Offset: -16,16 turret: DATA.R8 Start: 2589 Facings: -32 @@ -53,6 +57,10 @@ large_gun_turret: Frames: 2621, 2624, 2622, 2632, 2625, 2626, 2636, 2629, 2623, 2633, 2627, 2628, 2634, 2630, 2631, 2635 Length: 16 Offset: -24,16 + crumble-overlay: DATA.R8 + Start: 4321 + Length: 7 + Offset: -16,16 turret: DATA.R8 Start: 2637 Facings: -32 From 83dc3a36d266e44a4c1cc533c27153dd829a7878 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Mon, 14 Dec 2015 15:33:05 +0100 Subject: [PATCH 3/3] Add d2k turret make sequences Currently unused, as WithMakeAnimation and WithWallSpriteBody don't work well together at this point. --- mods/d2k/sequences/structures.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mods/d2k/sequences/structures.yaml b/mods/d2k/sequences/structures.yaml index c5c8fec686..5f651538b6 100644 --- a/mods/d2k/sequences/structures.yaml +++ b/mods/d2k/sequences/structures.yaml @@ -30,6 +30,10 @@ medium_gun_turret: Frames: 2621, 2624, 2622, 2632, 2625, 2626, 2636, 2629, 2623, 2633, 2627, 2628, 2634, 2630, 2631, 2635 Length: 16 Offset: -24,16 + make: DATA.R8 #TODO: unused, enabling WMA currently breaks turrets (bleed 20151214) + Start: 4313 + Length: 8 + Offset: -16,16 crumble-overlay: DATA.R8 Start: 4321 Length: 7 @@ -57,6 +61,10 @@ large_gun_turret: Frames: 2621, 2624, 2622, 2632, 2625, 2626, 2636, 2629, 2623, 2633, 2627, 2628, 2634, 2630, 2631, 2635 Length: 16 Offset: -24,16 + make: DATA.R8 #TODO: unused, enabling WMA currently breaks turrets (bleed 20151214) + Start: 4313 + Length: 8 + Offset: -16,16 crumble-overlay: DATA.R8 Start: 4321 Length: 7