diff --git a/OpenRA.Mods.Cnc/RenderGunboat.cs b/OpenRA.Mods.Cnc/RenderGunboat.cs index b98aba86ed..eb17ed0621 100644 --- a/OpenRA.Mods.Cnc/RenderGunboat.cs +++ b/OpenRA.Mods.Cnc/RenderGunboat.cs @@ -19,10 +19,9 @@ namespace OpenRA.Mods.RA.Render public override object Create(ActorInitializer init) { return new RenderGunboat(init.self); } } - class RenderGunboat : RenderSimple, INotifyDamage, INotifyDamageStateChanged + class RenderGunboat : RenderSimple, INotifyDamageStateChanged { IFacing facing; - bool isSmoking = false; public RenderGunboat(Actor self) : base(self, () => self.HasTrait() ? self.Trait().turretFacing : 0) @@ -34,7 +33,6 @@ namespace OpenRA.Mods.RA.Render wake.Play("left-wake"); Func offset = () => new float2(((anims["wake"].Animation.CurrentSequence.Name == "left-wake") ? 1 : -1),2); anims.Add( "wake", new AnimationWithOffset( wake, offset, () => false ) { ZOffset = -2 } ); - anims.Add( "smoke", new AnimationWithOffset( new Animation( "smoke_m" ), null, () => !isSmoking ) ); } string lastDir = "left"; @@ -61,19 +59,5 @@ namespace OpenRA.Mods.RA.Render lastDamage = ""; anim.ReplaceAnim(lastDir+lastDamage); } - - public void Damaged(Actor self, AttackInfo e) - { - // Smoking - if (e.DamageState < DamageState.Heavy) return; - if (isSmoking) return; - - isSmoking = true; - var smoke = anims[ "smoke" ].Animation; - smoke.PlayThen( "idle", - () => smoke.PlayThen( "loop", - () => smoke.PlayBackwardsThen( "end", - () => isSmoking = false ) ) ); - } } } diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 644c2850c1..625085e99d 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -353,6 +353,7 @@ + diff --git a/OpenRA.Mods.RA/Render/RenderUnit.cs b/OpenRA.Mods.RA/Render/RenderUnit.cs index 907eb78768..6f371c4d3a 100644 --- a/OpenRA.Mods.RA/Render/RenderUnit.cs +++ b/OpenRA.Mods.RA/Render/RenderUnit.cs @@ -16,21 +16,15 @@ namespace OpenRA.Mods.RA.Render { public class RenderUnitInfo : RenderSimpleInfo { - public readonly bool Smokes = true; public override object Create(ActorInitializer init) { return new RenderUnit(init.self); } } - public class RenderUnit : RenderSimple, INotifyDamage + public class RenderUnit : RenderSimple { public RenderUnit(Actor self) : base(self, () => self.HasTrait() ? self.Trait().Facing : 0) { - canSmoke = self.Info.Traits.Get().Smokes; - anim.PlayRepeating("idle"); - - if (canSmoke) - anims.Add( "smoke", new AnimationWithOffset( new Animation( "smoke_m" ), null, () => !isSmoking ) ); } public void PlayCustomAnimation(Actor self, string newAnim, Action after) @@ -49,21 +43,5 @@ namespace OpenRA.Mods.RA.Render anim.PlayBackwardsThen(name, () => { anim.PlayRepeating("idle"); a(); }); } - - bool isSmoking; - bool canSmoke; - - public void Damaged(Actor self, AttackInfo e) - { - if (e.DamageState < DamageState.Heavy) return; - if (isSmoking || !canSmoke) return; - - isSmoking = true; - var smoke = anims[ "smoke" ].Animation; - smoke.PlayThen( "idle", - () => smoke.PlayThen( "loop", - () => smoke.PlayBackwardsThen( "end", - () => isSmoking = false ) ) ); - } } } diff --git a/OpenRA.Mods.RA/Render/WithSmoke.cs b/OpenRA.Mods.RA/Render/WithSmoke.cs new file mode 100644 index 0000000000..c48de88cd1 --- /dev/null +++ b/OpenRA.Mods.RA/Render/WithSmoke.cs @@ -0,0 +1,47 @@ +#region Copyright & License Information +/* + * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using OpenRA.Graphics; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA.Render +{ + public class WithSmokeInfo : ITraitInfo, Requires + { + public object Create(ActorInitializer init) { return new WithSmoke(init.self); } + } + + public class WithSmoke : INotifyDamage + { + bool isSmoking; + Animation anim; + + public WithSmoke(Actor self) + { + var rs = self.Trait(); + + anim = new Animation("smoke_m"); + rs.anims.Add("smoke", new RenderSimple.AnimationWithOffset( + anim, null, () => !isSmoking)); + } + + public void Damaged(Actor self, AttackInfo e) + { + if (isSmoking) return; + if (e.DamageState < DamageState.Heavy) return; + + isSmoking = true; + anim.PlayThen( "idle", + () => anim.PlayThen( "loop", + () => anim.PlayBackwardsThen( "end", + () => isSmoking = false ) ) ); + } + } +} diff --git a/mods/cnc/rules/civilian.yaml b/mods/cnc/rules/civilian.yaml index 141d9d287f..e99996aafc 100644 --- a/mods/cnc/rules/civilian.yaml +++ b/mods/cnc/rules/civilian.yaml @@ -283,5 +283,4 @@ VICE: PrimaryWeapon: Chemspray AttackWander: RenderUnit: - Smokes: False WithMuzzleFlash: diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 3257fff91b..3f4c0ad6c6 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -29,6 +29,7 @@ Notification: unitlost.aud AttackMove: AcceptsCloakCrate: + WithSmoke: ^Tank: AppearsOnRadar: @@ -61,6 +62,7 @@ Notification: unitlost.aud AttackMove: AcceptsCloakCrate: + WithSmoke: ^Helicopter: AppearsOnRadar: diff --git a/mods/cnc/rules/ships.yaml b/mods/cnc/rules/ships.yaml index 055eb84156..2d06993486 100644 --- a/mods/cnc/rules/ships.yaml +++ b/mods/cnc/rules/ships.yaml @@ -25,6 +25,7 @@ BOAT: RenderGunboat: AutoTarget: AllowMovement: false + WithSmoke: LST: Inherits: ^Ship diff --git a/mods/ra/rules/aircraft.yaml b/mods/ra/rules/aircraft.yaml index c5428de120..ca8687201c 100644 --- a/mods/ra/rules/aircraft.yaml +++ b/mods/ra/rules/aircraft.yaml @@ -10,7 +10,6 @@ BADR: ROT: 5 Speed: 16 RenderUnit: - Smokes: no WithShadow: IronCurtainable: Cargo: @@ -53,7 +52,6 @@ BADR.bomber: Ammo: 7 RenderUnit: Image: badr - Smokes: no WithShadow: IronCurtainable: -Selectable: @@ -108,7 +106,6 @@ MIG: Speed: 20 RearmBuildings: afld RenderUnit: - Smokes: no WithShadow: LimitedAmmo: Ammo: 8 @@ -159,7 +156,6 @@ YAK: ROT: 5 Speed: 16 RenderUnit: - Smokes: no WithShadow: LimitedAmmo: Ammo: 18 @@ -251,7 +247,6 @@ HELI: ROT: 4 Speed: 16 RenderUnit: - Smokes: no WithRotor: Offset: 0,0,0,-2 WithShadow: @@ -295,7 +290,6 @@ HIND: ROT: 4 Speed: 12 RenderUnit: - Smokes: no WithRotor: WithShadow: LimitedAmmo: @@ -321,7 +315,6 @@ U2: ROT: 7 Speed: 40 RenderUnit: - Smokes: no WithShadow: IronCurtainable: -Selectable: diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 80d36bcca2..e5d237e64e 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -30,6 +30,7 @@ GivesBounty: GpsDot: String:Vehicle + WithSmoke: ^Tank: AppearsOnRadar: @@ -63,6 +64,7 @@ GivesBounty: GpsDot: String:Vehicle + WithSmoke: ^Infantry: AppearsOnRadar: @@ -129,6 +131,7 @@ GivesBounty: GpsDot: String:Ship + WithSmoke: ^Plane: AppearsOnRadar: