From 632d8cd898eca5f475a3992d0f989a317fc6dd27 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 5 Jul 2015 00:09:15 +0200 Subject: [PATCH 1/3] Allow setting separate close sequence for landing crafts --- OpenRA.Mods.RA/Traits/Render/WithLandingCraftAnimation.cs | 7 ++++--- mods/ra/sequences/ships.yaml | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.RA/Traits/Render/WithLandingCraftAnimation.cs b/OpenRA.Mods.RA/Traits/Render/WithLandingCraftAnimation.cs index 740434f0f0..90733370ea 100644 --- a/OpenRA.Mods.RA/Traits/Render/WithLandingCraftAnimation.cs +++ b/OpenRA.Mods.RA/Traits/Render/WithLandingCraftAnimation.cs @@ -18,6 +18,7 @@ namespace OpenRA.Mods.RA.Traits { public readonly string[] OpenTerrainTypes = { "Clear" }; [SequenceReference] public readonly string OpenSequence = "open"; + [SequenceReference] public readonly string CloseSequence = "close"; [SequenceReference] public readonly string UnloadSequence = "unload"; public object Create(ActorInitializer init) { return new WithLandingCraftAnimation(init, this); } @@ -43,7 +44,7 @@ namespace OpenRA.Mods.RA.Traits public bool ShouldBeOpen() { - if (self.CenterPosition.Z > 0 || move.IsMoving) + if (move.IsMoving || self.CenterPosition.Z > 0) return false; return cargo.CurrentAdjacentCells.Any(c => self.World.Map.Contains(c) @@ -65,11 +66,11 @@ namespace OpenRA.Mods.RA.Traits void Close() { - if (!open || !wsb.DefaultAnimation.HasSequence(info.OpenSequence)) + if (!open || !wsb.DefaultAnimation.HasSequence(info.CloseSequence)) return; open = false; - wsb.PlayCustomAnimationBackwards(self, info.OpenSequence, null); + wsb.PlayCustomAnimation(self, info.CloseSequence); } public void Tick(Actor self) diff --git a/mods/ra/sequences/ships.yaml b/mods/ra/sequences/ships.yaml index 55f044559a..cf33f1393a 100644 --- a/mods/ra/sequences/ships.yaml +++ b/mods/ra/sequences/ships.yaml @@ -34,6 +34,10 @@ lst: Start: 1 Length: 4 Tick: 150 + close: + Frames: 4, 3, 2, 1 + Length: 4 + Tick: 150 unload: Start: 4 ZOffset: -511 From 8ae541339b2d3b3a44aab251ed873c28ed349f35 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 5 Jul 2015 00:09:46 +0200 Subject: [PATCH 2/3] Make WithMoveAnimation work with WithSpriteBody as well --- OpenRA.Mods.Common/Traits/Render/WithMoveAnimation.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithMoveAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithMoveAnimation.cs index 70f3fdc396..50517f9532 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithMoveAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithMoveAnimation.cs @@ -13,7 +13,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - public class WithMoveAnimationInfo : ITraitInfo, Requires, Requires + public class WithMoveAnimationInfo : ITraitInfo, Requires, Requires { [Desc("Displayed while moving.")] [SequenceReference] public readonly string MoveSequence = "move"; @@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits { readonly WithMoveAnimationInfo info; readonly IMove movement; - readonly WithFacingSpriteBody wfsb; + readonly WithSpriteBody wsb; WPos cachedPosition; @@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits { this.info = info; movement = init.Self.Trait(); - wfsb = init.Self.Trait(); + wsb = init.Self.Trait(); cachedPosition = init.Self.CenterPosition; } @@ -45,10 +45,10 @@ namespace OpenRA.Mods.Common.Traits // Flying units set IsMoving whenever they are airborne, which isn't enough for our purposes var isMoving = movement.IsMoving && !self.IsDead && (oldCachedPosition - cachedPosition).HorizontalLengthSquared != 0; - if (isMoving ^ (wfsb.DefaultAnimation.CurrentSequence.Name != info.MoveSequence)) + if (isMoving ^ (wsb.DefaultAnimation.CurrentSequence.Name != info.MoveSequence)) return; - wfsb.DefaultAnimation.ReplaceAnim(isMoving ? info.MoveSequence : wfsb.Info.Sequence); + wsb.DefaultAnimation.ReplaceAnim(isMoving ? info.MoveSequence : wsb.Info.Sequence); } } } From 26a202600d7f19a69421d338e24e743be2957abc Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 5 Jul 2015 00:17:01 +0200 Subject: [PATCH 3/3] Make WithAttackAnimation work with WithSpriteBody as well --- .../Traits/Render/WithAttackAnimation.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithAttackAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithAttackAnimation.cs index bb9628acdb..12c2dc0e15 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithAttackAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithAttackAnimation.cs @@ -13,7 +13,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - public class WithAttackAnimationInfo : ITraitInfo, Requires, Requires, Requires + public class WithAttackAnimationInfo : ITraitInfo, Requires, Requires, Requires { [Desc("Armament name")] public readonly string Armament = "primary"; @@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits readonly WithAttackAnimationInfo info; readonly AttackBase attack; readonly Armament armament; - readonly WithFacingSpriteBody wfsb; + readonly WithSpriteBody wsb; public WithAttackAnimation(ActorInitializer init, WithAttackAnimationInfo info) { @@ -43,13 +43,13 @@ namespace OpenRA.Mods.Common.Traits attack = init.Self.Trait(); armament = init.Self.TraitsImplementing() .Single(a => a.Info.Name == info.Armament); - wfsb = init.Self.Trait(); + wsb = init.Self.Trait(); } public void Attacking(Actor self, Target target, Armament a, Barrel barrel) { if (!string.IsNullOrEmpty(info.AttackSequence)) - wfsb.PlayCustomAnimation(self, info.AttackSequence); + wsb.PlayCustomAnimation(self, info.AttackSequence); } public void Tick(Actor self) @@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Traits if (string.IsNullOrEmpty(info.AimSequence) && string.IsNullOrEmpty(info.ReloadPrefix)) return; - var sequence = wfsb.Info.Sequence; + var sequence = wsb.Info.Sequence; if (!string.IsNullOrEmpty(info.AimSequence) && attack.IsAttacking) sequence = info.AimSequence; @@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits if (!string.IsNullOrEmpty(prefix) && sequence != (prefix + sequence)) sequence = prefix + sequence; - wfsb.DefaultAnimation.ReplaceAnim(sequence); + wsb.DefaultAnimation.ReplaceAnim(sequence); } } }