diff --git a/OpenRA.Mods.Cnc/Traits/Render/WithEmbeddedTurretSpriteBody.cs b/OpenRA.Mods.Cnc/Traits/Render/WithEmbeddedTurretSpriteBody.cs index c6e273f1c6..68b5921e53 100644 --- a/OpenRA.Mods.Cnc/Traits/Render/WithEmbeddedTurretSpriteBody.cs +++ b/OpenRA.Mods.Cnc/Traits/Render/WithEmbeddedTurretSpriteBody.cs @@ -23,6 +23,9 @@ namespace OpenRA.Mods.Cnc.Traits.Render [Desc("This actor has turret art with facings baked into the sprite.")] public class WithEmbeddedTurretSpriteBodyInfo : WithSpriteBodyInfo, Requires, Requires { + [Desc("Number of facings for gameplay calculations. -1 indicates auto-detection from the sequence.")] + public readonly int QuantizedFacings = -1; + public override object Create(ActorInitializer init) { return new WithEmbeddedTurretSpriteBody(init, this); } public override IEnumerable RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) @@ -43,6 +46,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render public class WithEmbeddedTurretSpriteBody : WithSpriteBody { + readonly WithEmbeddedTurretSpriteBodyInfo info; readonly Turreted turreted; static Func MakeTurretFacingFunc(Actor self) @@ -52,22 +56,23 @@ namespace OpenRA.Mods.Cnc.Traits.Render return () => turreted.WorldOrientation.Yaw; } - public WithEmbeddedTurretSpriteBody(ActorInitializer init, WithSpriteBodyInfo info) + public WithEmbeddedTurretSpriteBody(ActorInitializer init, WithEmbeddedTurretSpriteBodyInfo info) : base(init, info, MakeTurretFacingFunc(init.Self)) { + this.info = info; turreted = init.Self.TraitsImplementing().FirstOrDefault(); } protected override void TraitEnabled(Actor self) { base.TraitEnabled(self); - turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings; + turreted.QuantizedFacings = info.QuantizedFacings >= 0 ? info.QuantizedFacings : DefaultAnimation.CurrentSequence.Facings; } protected override void DamageStateChanged(Actor self) { base.DamageStateChanged(self); - turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings; + turreted.QuantizedFacings = info.QuantizedFacings >= 0 ? info.QuantizedFacings : DefaultAnimation.CurrentSequence.Facings; } } } diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index 4357ca1249..8c8b923f3f 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -909,6 +909,7 @@ SAM: RealignDelay: -1 -WithSpriteBody: WithEmbeddedTurretSpriteBody: + QuantizedFacings: 32 Armament: Weapon: Dragon MuzzleSequence: muzzle