diff --git a/OpenRA.Mods.Cnc/AttackPopupTurreted.cs b/OpenRA.Mods.Cnc/AttackPopupTurreted.cs index cb158cad14..4b6ffd90f9 100644 --- a/OpenRA.Mods.Cnc/AttackPopupTurreted.cs +++ b/OpenRA.Mods.Cnc/AttackPopupTurreted.cs @@ -31,18 +31,21 @@ namespace OpenRA.Mods.Cnc enum PopupState { Open, + Rotating, Transitioning, Closed }; protected Target target; AttackPopupTurretedInfo Info; + Turreted Turret; int IdleTicks = 0; PopupState State = PopupState.Open; public AttackPopupTurreted(Actor self, AttackPopupTurretedInfo info) : base(self) { Info = info; + Turret = self.Trait(); } protected override bool CanAttack( Actor self, Target target ) @@ -69,9 +72,8 @@ namespace OpenRA.Mods.Cnc return false; } - var turreted = self.Trait(); - turreted.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, turreted.turretFacing ); - if( turreted.desiredFacing != turreted.turretFacing ) + Turret.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, Turret.turretFacing ); + if( Turret.desiredFacing != Turret.turretFacing ) return false; return true; @@ -86,6 +88,11 @@ namespace OpenRA.Mods.Cnc public void TickIdle(Actor self) { if (State == PopupState.Open && IdleTicks++ > Info.CloseDelay) + { + Turret.desiredFacing = 0; + State = PopupState.Rotating; + } + else if (State == PopupState.Rotating && Turret.turretFacing == 0) { State = PopupState.Transitioning; var rb = self.Trait(); @@ -93,6 +100,7 @@ namespace OpenRA.Mods.Cnc { State = PopupState.Closed; rb.PlayCustomAnimRepeating(self, "closed-idle"); + Turret.desiredFacing = null; }); } } diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index adb7220bd6..41d994f189 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -657,7 +657,7 @@ SAM: RevealsShroud: Range: 5 Turreted: - ROT: 30 + ROT: 7 InitialFacing: 0 RenderBuildingTurreted: AttackPopupTurreted: