diff --git a/OpenRa.Game/GameRules/UnitInfo.cs b/OpenRa.Game/GameRules/UnitInfo.cs index 39789550ca..58803b0bdf 100755 --- a/OpenRa.Game/GameRules/UnitInfo.cs +++ b/OpenRa.Game/GameRules/UnitInfo.cs @@ -51,6 +51,7 @@ namespace OpenRa.Game.GameRules public readonly int[] SecondaryOffset = null; public readonly int Recoil = 0; public readonly string SecondaryAnim = null; + public readonly bool MuzzleFlash = false; public UnitInfo(string name) { Name = name; } diff --git a/OpenRa.Game/Traits/Activities/Follow.cs b/OpenRa.Game/Traits/Activities/Follow.cs index e3f66af5b3..9b19c7aea4 100644 --- a/OpenRa.Game/Traits/Activities/Follow.cs +++ b/OpenRa.Game/Traits/Activities/Follow.cs @@ -33,6 +33,9 @@ namespace OpenRa.Game.Traits.Activities } } - public void Cancel(Actor self, Mobile mobile) { } + public void Cancel(Actor self, Mobile mobile) + { + mobile.InternalSetActivity(null); + } } } diff --git a/OpenRa.Game/Traits/RenderUnitTurreted.cs b/OpenRa.Game/Traits/RenderUnitTurreted.cs index a505e22da5..130a3a0430 100644 --- a/OpenRa.Game/Traits/RenderUnitTurreted.cs +++ b/OpenRa.Game/Traits/RenderUnitTurreted.cs @@ -10,6 +10,7 @@ namespace OpenRa.Game.Traits class RenderUnitTurreted : RenderUnit { public Animation turretAnim; + public Animation muzzleFlash; public float primaryRecoil = 0.0f, secondaryRecoil = 0.0f; public RenderUnitTurreted(Actor self) @@ -17,8 +18,17 @@ namespace OpenRa.Game.Traits { turretAnim = new Animation(self.unitInfo.Name); if (self.traits.Contains()) - turretAnim.PlayFetchIndex("turret", + { + if (self.unitInfo.MuzzleFlash) + { + muzzleFlash = new Animation(self.unitInfo.Name); + muzzleFlash.PlayFetchIndex("muzzle", + () => (Util.QuantizeFacing(self.traits.Get().turretFacing,8)) * 6 + (int)(primaryRecoil * 6)); + } + + turretAnim.PlayFetchIndex("turret", () => self.traits.Get().turretFacing / 8); + } else turretAnim.PlayRepeating("turret"); /* not really a turret; it's a spinner */ } @@ -33,6 +43,10 @@ namespace OpenRa.Game.Traits if (self.unitInfo.SecondaryOffset != null) yield return Util.Centered(turretAnim.Image, self.CenterLocation + Util.GetTurretPosition(self, self.unitInfo.SecondaryOffset, secondaryRecoil)); + + if (muzzleFlash != null && primaryRecoil > 0) + yield return Util.Centered(muzzleFlash.Image, self.CenterLocation + + Util.GetTurretPosition(self, self.unitInfo.PrimaryOffset, primaryRecoil)); } public override void Tick(Actor self) @@ -41,6 +55,8 @@ namespace OpenRa.Game.Traits turretAnim.Tick(); primaryRecoil = Math.Max(0f, primaryRecoil - .2f); secondaryRecoil = Math.Max(0f, secondaryRecoil - .2f); + if (muzzleFlash != null) + muzzleFlash.Tick(); } } } diff --git a/sequences.xml b/sequences.xml index 78faf4b299..2cd952a2cd 100644 --- a/sequences.xml +++ b/sequences.xml @@ -270,6 +270,7 @@ + diff --git a/units.ini b/units.ini index c6f3a3f368..1a31212213 100755 --- a/units.ini +++ b/units.ini @@ -52,6 +52,7 @@ Traits=Mobile, McvDeploy, RenderUnit Description=Ranger Traits=Mobile, Turreted, AttackTurreted, RenderUnitTurreted PrimaryOffset=0,0,0,-2 +MuzzleFlash=yes [APC] Description=Armored Personnel Carrier Traits=Mobile, RenderUnit @@ -323,14 +324,14 @@ Produces=Infantry RallyPoint=1,3 [TENT] Description=Allied Barracks -Traits=Building, RenderBuilding +Traits=Building, RenderBuilding, RallyPoint Dimensions=2,2 Footprint=xx xx Produces=Infantry RallyPoint=1,3 [KENN] Description=Kennel -Traits=Building, RenderBuilding +Traits=Building, RenderBuilding, RallyPoint Dimensions=1,1 Footprint=x RallyPoint=1,2