Convert AnimationWithOffset to world coords.

Animations (via Actor.CenterPosition) now
understand Altitude, so there is potential for
mis-positioned animations if any existing altitude
hacks were missed.
This commit is contained in:
Paul Chote
2013-05-14 21:02:46 +12:00
parent fb17654ea0
commit fe716e76a7
16 changed files with 64 additions and 66 deletions

View File

@@ -18,7 +18,9 @@ namespace OpenRA.Mods.Cnc
{
class RenderBuildingRefineryInfo : RenderBuildingInfo
{
public override object Create(ActorInitializer init) { return new RenderBuildingRefinery( init, this ); }
public readonly WVec Offset = new WVec(1365, 896, 0);
public override object Create(ActorInitializer init) { return new RenderBuildingRefinery(init, this); }
}
class RenderBuildingRefinery : RenderBuilding, INotifyBuildComplete, INotifySold, INotifyCapture
@@ -27,7 +29,7 @@ namespace OpenRA.Mods.Cnc
PlayerResources playerResources;
bool buildComplete;
public RenderBuildingRefinery(ActorInitializer init, RenderBuildingInfo info)
public RenderBuildingRefinery(ActorInitializer init, RenderBuildingRefineryInfo info)
: base(init, info)
{
playerResources = init.self.Owner.PlayerActor.Trait<PlayerResources>();
@@ -38,9 +40,7 @@ namespace OpenRA.Mods.Cnc
? (59 * playerResources.Ore) / (10 * playerResources.OreCapacity)
: 0);
var offset = new float2(-32,-21);
anims.Add("lights", new AnimationWithOffset( lights, wr => offset, () => !buildComplete )
{ ZOffset = 24 });
anims.Add("lights", new AnimationWithOffset(lights, () => info.Offset, () => !buildComplete, 24));
}
public void BuildingComplete( Actor self )

View File

@@ -34,8 +34,12 @@ namespace OpenRA.Mods.RA.Render
var wake = new Animation(anim.Name);
wake.Play("left-wake");
Func<WorldRenderer, float2> offset = wr => new float2(((anims["wake"].Animation.CurrentSequence.Name == "left-wake") ? 1 : -1),2);
anims.Add( "wake", new AnimationWithOffset( wake, offset, () => false ) { ZOffset = -2 } );
var leftOffset = new WVec(43, 86, 0);
var rightOffset = new WVec(-43, 86, 0);
anims.Add("wake", new AnimationWithOffset(wake,
() => anims["wake"].Animation.CurrentSequence.Name == "left-wake" ? leftOffset : rightOffset,
() => false, -2));
}
public override void Tick(Actor self)

View File

@@ -15,17 +15,20 @@ namespace OpenRA.Mods.Cnc
{
class WithFireInfo : ITraitInfo, Requires<RenderSimpleInfo>
{
public object Create(ActorInitializer init) { return new WithFire(init.self); }
public readonly WVec Offset = new WVec(299,-640,0);
public object Create(ActorInitializer init) { return new WithFire(init.self, this); }
}
class WithFire
{
public WithFire(Actor self)
public WithFire(Actor self, WithFireInfo info)
{
var rs = self.Trait<RenderSimple>();
var roof = new Animation(rs.GetImage(self));
roof.PlayThen("fire-start", () => roof.PlayRepeating("fire-loop"));
rs.anims.Add( "fire", new AnimationWithOffset( roof, wr => new float2(7,-15), null ) { ZOffset = 24 } );
rs.anims.Add("fire", new AnimationWithOffset(roof, () => info.Offset, null, 24));
}
}
}

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Cnc
var rs = self.Trait<RenderSimple>();
var roof = new Animation(rs.GetImage(self), () => self.Trait<IFacing>().Facing);
roof.Play("roof");
rs.anims.Add( "roof", new AnimationWithOffset( roof ) { ZOffset = 24 } );
rs.anims.Add("roof", new AnimationWithOffset(roof, null, null, 24));
}
}
}