diff --git a/OpenRA.Mods.Cnc/WithRoof.cs b/OpenRA.Mods.Cnc/WithRoof.cs index abe7d3bbb5..5e9b6e8e1c 100644 --- a/OpenRA.Mods.Cnc/WithRoof.cs +++ b/OpenRA.Mods.Cnc/WithRoof.cs @@ -15,12 +15,12 @@ using OpenRA.Graphics; namespace OpenRA.Mods.Cnc { - class WithRoofInfo : ITraitInfo + public class WithRoofInfo : ITraitInfo, ITraitPrerequisite { public object Create(ActorInitializer init) { return new WithRoof(init.self); } } - class WithRoof + public class WithRoof { public WithRoof(Actor self) { diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 3629dd4a30..17f00e1283 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -1,4 +1,4 @@ - + Debug @@ -221,7 +221,6 @@ - @@ -267,8 +266,6 @@ - - @@ -333,6 +330,9 @@ + + + diff --git a/OpenRA.Mods.RA/Render/RenderUnitRotor.cs b/OpenRA.Mods.RA/Render/RenderUnitRotor.cs deleted file mode 100755 index 67babdd36d..0000000000 --- a/OpenRA.Mods.RA/Render/RenderUnitRotor.cs +++ /dev/null @@ -1,64 +0,0 @@ -#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 -{ - class RenderUnitRotorInfo : RenderUnitInfo - { - public readonly int[] PrimaryOffset = { 0, 0 }; - public readonly int[] SecondaryOffset = null; - - public override object Create(ActorInitializer init) { return new RenderUnitRotor(init.self); } - } - - class RenderUnitRotor : RenderUnit - { - public Animation rotorAnim, secondRotorAnim; - - public RenderUnitRotor( Actor self ) - : base(self) - { - var facing = self.Trait(); - var info = self.Info.Traits.Get(); - - rotorAnim = new Animation(GetImage(self)); - rotorAnim.PlayRepeating("rotor"); - anims.Add("rotor_1", new AnimationWithOffset( - rotorAnim, - () => Combat.GetTurretPosition( self, facing, new Turret(info.PrimaryOffset)), - null ) { ZOffset = 1 } ); - - if (info.SecondaryOffset == null) return; - - secondRotorAnim = new Animation(GetImage(self)); - secondRotorAnim.PlayRepeating("rotor2"); - anims.Add("rotor_2", new AnimationWithOffset( - secondRotorAnim, - () => Combat.GetTurretPosition(self, facing, new Turret(info.SecondaryOffset)), - null) { ZOffset = 1 }); - } - - public override void Tick(Actor self) - { - base.Tick(self); - - var isFlying = self.Trait().Altitude > 0 && !self.IsDead(); - if (isFlying ^ (rotorAnim.CurrentSequence.Name != "rotor")) - return; - - rotorAnim.ReplaceAnim(isFlying ? "rotor" : "slow-rotor"); - if (secondRotorAnim != null) - secondRotorAnim.ReplaceAnim(isFlying ? "rotor2" : "slow-rotor2"); - } - } -} diff --git a/OpenRA.Mods.RA/WithMuzzleFlash.cs b/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs similarity index 97% rename from OpenRA.Mods.RA/WithMuzzleFlash.cs rename to OpenRA.Mods.RA/Render/WithMuzzleFlash.cs index 3247538b0b..cfb2c87870 100644 --- a/OpenRA.Mods.RA/WithMuzzleFlash.cs +++ b/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs @@ -12,7 +12,7 @@ using System.Collections.Generic; using OpenRA.Graphics; using OpenRA.Traits; -namespace OpenRA.Mods.RA +namespace OpenRA.Mods.RA.Render { class WithMuzzleFlashInfo : ITraitInfo, ITraitPrerequisite { diff --git a/OpenRA.Mods.RA/Render/WithRotor.cs b/OpenRA.Mods.RA/Render/WithRotor.cs new file mode 100755 index 0000000000..e22e59947a --- /dev/null +++ b/OpenRA.Mods.RA/Render/WithRotor.cs @@ -0,0 +1,48 @@ +#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 WithRotorInfo : ITraitInfo + { + public readonly string Id = "rotor"; + public readonly int[] Offset = { 0, 0 }; + public object Create(ActorInitializer init) { return new WithRotor(init.self, this); } + } + + public class WithRotor : ITick + { + public Animation rotorAnim; + public WithRotor(Actor self, WithRotorInfo info) + { + var rs = self.Trait(); + var facing = self.Trait(); + + rotorAnim = new Animation(rs.GetImage(self)); + rotorAnim.PlayRepeating("rotor"); + rs.anims.Add(info.Id, new RenderSimple.AnimationWithOffset( + rotorAnim, + () => Combat.GetTurretPosition( self, facing, new Turret(info.Offset)), + null ) { ZOffset = 1 } ); + } + + public void Tick(Actor self) + { + var isFlying = self.Trait().Altitude > 0 && !self.IsDead(); + if (isFlying ^ (rotorAnim.CurrentSequence.Name != "rotor")) + return; + + rotorAnim.ReplaceAnim(isFlying ? "rotor" : "slow-rotor"); + } + } +} diff --git a/OpenRA.Mods.RA/WithShadow.cs b/OpenRA.Mods.RA/Render/WithShadow.cs similarity index 96% rename from OpenRA.Mods.RA/WithShadow.cs rename to OpenRA.Mods.RA/Render/WithShadow.cs index 6a37e80865..2c43b9e27a 100644 --- a/OpenRA.Mods.RA/WithShadow.cs +++ b/OpenRA.Mods.RA/Render/WithShadow.cs @@ -12,7 +12,7 @@ using System.Collections.Generic; using System.Linq; using OpenRA.Traits; -namespace OpenRA.Mods.RA +namespace OpenRA.Mods.RA.Render { class WithShadowInfo : TraitInfo {} diff --git a/mods/cnc/rules/vehicles.yaml b/mods/cnc/rules/vehicles.yaml index e83fa6d344..37d1a80f16 100644 --- a/mods/cnc/rules/vehicles.yaml +++ b/mods/cnc/rules/vehicles.yaml @@ -473,9 +473,12 @@ TRAN: Type: Light RevealsShroud: Range: 8 - RenderUnitRotor: - PrimaryOffset: 0,14,0,-4 - SecondaryOffset: 0,-14,0,-2 + RenderUnit: + WithRotor@PRIMARY: + Offset: 0,14,0,-4 + WithRotor@SECONDARY: + Id: rotor_2 + Offset: 0,-14,0,-2 WithShadow: Cargo: Types: Infantry @@ -508,9 +511,10 @@ HELI: PrimaryWeapon: HighV.Heli PrimaryOffset: 0,-10,0,3 FacingTolerance: 20 + RenderUnit: + WithRotor: + Offset: 0,0,0,-2 WithMuzzleFlash: - RenderUnitRotor: - PrimaryOffset: 0,0,0,-2 WithShadow: FallsToEarth: AutoTarget: diff --git a/mods/ra/rules/vehicles.yaml b/mods/ra/rules/vehicles.yaml index a713e9a252..8416ad7afc 100644 --- a/mods/ra/rules/vehicles.yaml +++ b/mods/ra/rules/vehicles.yaml @@ -830,9 +830,12 @@ TRAN: ROT: 5 Speed: 12 LandableTerrainTypes: Clear,Rough,Road,Ore,Beach - RenderUnitRotor: - PrimaryOffset: 0,14,0,-8 - SecondaryOffset: 0,-14,0,-5 + RenderUnit: + WithRotor@PRIMARY: + Offset: 0,14,0,-8 + WithRotor@SECONDARY: + Id: rotor_2 + Offset: 0,-14,0,-5 WithShadow: Cargo: Types: Infantry @@ -872,9 +875,10 @@ HELI: InitialFacing: 20 ROT: 4 Speed: 16 - RenderUnitRotor: - PrimaryOffset: 0,0,0,-2 + RenderUnit: Smokes: no + WithRotor: + Offset: 0,0,0,-2 WithShadow: LimitedAmmo: Ammo: 8 @@ -915,8 +919,9 @@ HIND: InitialFacing: 20 ROT: 4 Speed: 12 - RenderUnitRotor: + RenderUnit: Smokes: no + WithRotor: WithShadow: LimitedAmmo: Ammo: 24