diff --git a/OpenRA.Mods.Cnc/Traits/Attack/AttackPopupTurreted.cs b/OpenRA.Mods.Cnc/Traits/Attack/AttackPopupTurreted.cs index 1881a90eb8..9e223efb08 100644 --- a/OpenRA.Mods.Cnc/Traits/Attack/AttackPopupTurreted.cs +++ b/OpenRA.Mods.Cnc/Traits/Attack/AttackPopupTurreted.cs @@ -21,21 +21,24 @@ namespace OpenRA.Mods.Cnc.Traits class AttackPopupTurretedInfo : AttackTurretedInfo, Requires, Requires { [Desc("How many game ticks should pass before closing the actor's turret.")] - public int CloseDelay = 125; + public readonly int CloseDelay = 125; - public int DefaultFacing = 0; + public readonly int DefaultFacing = 0; [Desc("The percentage of damage that is received while this actor is closed.")] - public int ClosedDamageMultiplier = 50; + public readonly int ClosedDamageMultiplier = 50; [Desc("Sequence to play when opening.")] - [SequenceReference] public string OpeningSequence = "opening"; + [SequenceReference] public readonly string OpeningSequence = "opening"; [Desc("Sequence to play when closing.")] - [SequenceReference] public string ClosingSequence = "closing"; + [SequenceReference] public readonly string ClosingSequence = "closing"; [Desc("Idle sequence to play when closed.")] - [SequenceReference] public string ClosedIdleSequence = "closed-idle"; + [SequenceReference] public readonly string ClosedIdleSequence = "closed-idle"; + + [Desc("Which sprite body to play the animation on.")] + public readonly string Body = "body"; public override object Create(ActorInitializer init) { return new AttackPopupTurreted(init, this); } } @@ -57,7 +60,7 @@ namespace OpenRA.Mods.Cnc.Traits { this.info = info; turret = turrets.FirstOrDefault(); - wsb = init.Self.Trait(); + wsb = init.Self.TraitsImplementing().Single(w => w.Info.Name == info.Body); skippedMakeAnimation = init.Contains(); } diff --git a/OpenRA.Mods.Cnc/Traits/Render/WithDeliveryAnimation.cs b/OpenRA.Mods.Cnc/Traits/Render/WithDeliveryAnimation.cs index a7e054d8cd..5a11468d14 100644 --- a/OpenRA.Mods.Cnc/Traits/Render/WithDeliveryAnimation.cs +++ b/OpenRA.Mods.Cnc/Traits/Render/WithDeliveryAnimation.cs @@ -9,6 +9,7 @@ */ #endregion +using System.Linq; using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits.Render; using OpenRA.Traits; @@ -22,6 +23,9 @@ namespace OpenRA.Mods.Cnc.Traits.Render [SequenceReference] public readonly string IdleSequence = "idle"; + [Desc("Which sprite body to play the animation on.")] + public readonly string Body = "body"; + public object Create(ActorInitializer init) { return new WithDeliveryAnimation(init.Self, this); } } @@ -32,7 +36,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render public WithDeliveryAnimation(Actor self, WithDeliveryAnimationInfo info) { - wsb = self.Trait(); + wsb = self.TraitsImplementing().Single(w => w.Info.Name == info.Body); this.info = info; } diff --git a/OpenRA.Mods.Cnc/Traits/Render/WithLandingCraftAnimation.cs b/OpenRA.Mods.Cnc/Traits/Render/WithLandingCraftAnimation.cs index 881a4189ad..f4af493cf0 100644 --- a/OpenRA.Mods.Cnc/Traits/Render/WithLandingCraftAnimation.cs +++ b/OpenRA.Mods.Cnc/Traits/Render/WithLandingCraftAnimation.cs @@ -24,6 +24,9 @@ namespace OpenRA.Mods.Cnc.Traits.Render [SequenceReference] public readonly string CloseSequence = "close"; [SequenceReference] public readonly string UnloadSequence = "unload"; + [Desc("Which sprite body to play the animation on.")] + public readonly string Body = "body"; + public object Create(ActorInitializer init) { return new WithLandingCraftAnimation(init, this); } } @@ -42,7 +45,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render self = init.Self; cargo = self.Trait(); move = self.Trait(); - wsb = init.Self.Trait(); + wsb = init.Self.TraitsImplementing().Single(w => w.Info.Name == info.Body); } public bool ShouldBeOpen() diff --git a/OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeAnimation.cs b/OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeAnimation.cs index fa2c8ed28d..818009d9f4 100644 --- a/OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeAnimation.cs +++ b/OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeAnimation.cs @@ -9,6 +9,7 @@ */ #endregion +using System.Linq; using OpenRA.Mods.Common.Traits.Render; using OpenRA.Traits; @@ -20,6 +21,9 @@ namespace OpenRA.Mods.Cnc.Traits.Render [Desc("Sequence to use for charge animation.")] [SequenceReference] public readonly string ChargeSequence = "active"; + [Desc("Which sprite body to play the animation on.")] + public readonly string Body = "body"; + public object Create(ActorInitializer init) { return new WithTeslaChargeAnimation(init, this); } } @@ -31,7 +35,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render public WithTeslaChargeAnimation(ActorInitializer init, WithTeslaChargeAnimationInfo info) { this.info = info; - wsb = init.Self.Trait(); + wsb = init.Self.TraitsImplementing().Single(w => w.Info.Name == info.Body); } void INotifyTeslaCharging.Charging(Actor self, Target target)