Convert WithRotor to world coords.

This commit is contained in:
Paul Chote
2013-03-31 21:12:50 +13:00
parent 34a9675744
commit 41dcb11030
4 changed files with 14 additions and 13 deletions

View File

@@ -8,6 +8,7 @@
*/
#endregion
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Traits;
@@ -15,8 +16,10 @@ namespace OpenRA.Mods.RA.Render
{
public class WithRotorInfo : ITraitInfo, Requires<RenderSimpleInfo>
{
[Desc("Position relative to body")]
public readonly WVec Offset = WVec.Zero;
public readonly string Id = "rotor";
public readonly int[] Offset = { 0, 0 };
public object Create(ActorInitializer init) { return new WithRotor(init.self, this); }
}
@@ -26,14 +29,12 @@ namespace OpenRA.Mods.RA.Render
public WithRotor(Actor self, WithRotorInfo info)
{
var rs = self.Trait<RenderSimple>();
var facing = self.Trait<IFacing>();
rotorAnim = new Animation(rs.GetImage(self));
rotorAnim.PlayRepeating("rotor");
var turret = new Turret(info.Offset);
rs.anims.Add(info.Id, new AnimationWithOffset(
rotorAnim,
wr => turret.PxPosition(self, facing).ToFloat2(),
wr => wr.ScreenPxOffset(rs.LocalToWorld(info.Offset.Rotate(rs.QuantizeOrientation(self, self.Orientation)))),
null ) { ZOffset = 1 } );
}

View File

@@ -28,10 +28,10 @@ TRAN:
Range: 8
RenderUnit:
WithRotor@PRIMARY:
Offset: 0,14,0,-4
Offset: -597,0,171
WithRotor@SECONDARY:
Id: rotor_2
Offset: 0,-14,0,-2
Offset: 597,0,85
WithShadow:
Cargo:
Types: Infantry
@@ -84,7 +84,7 @@ HELI:
Period: 200
RenderUnit:
WithRotor:
Offset: 0,0,0,-2
Offset: 0,0,85
WithMuzzleFlash:
WithShadow:
FallsToEarth:

View File

@@ -187,10 +187,10 @@ TRAN:
LandableTerrainTypes: Clear,Rough,Road,Ore,Beach
RenderUnit:
WithRotor@PRIMARY:
Offset: 0,14,0,-8
Offset: -597,0,341
WithRotor@SECONDARY:
Id: rotor_2
Offset: 0,-14,0,-5
Offset: 597,0,213
WithShadow:
Cargo:
Types: Infantry
@@ -232,7 +232,7 @@ HELI:
Speed: 16
RenderUnit:
WithRotor:
Offset: 0,0,0,-2
Offset: 0,0,85
WithShadow:
LimitedAmmo:
Ammo: 6

View File

@@ -209,10 +209,10 @@ TRAN:
LandableTerrainTypes: Clear,Rough,Road,Ore,Beach
RenderUnit:
WithRotor@PRIMARY:
Offset: 0,14,0,-8
Offset: -597,0,341
WithRotor@SECONDARY:
Id: rotor_2
Offset: 0,-14,0,-5
Offset: 597,0,213
WithShadow:
Cargo:
Types: Infantry
@@ -272,7 +272,7 @@ HELI:
Speed: 16
RenderUnit:
WithRotor:
Offset: 0,0,0,-2
Offset: 0,0,85
WithShadow:
LimitedAmmo:
Ammo: 8