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:
@@ -49,9 +49,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
: base(init, info)
|
||||
{
|
||||
roof = new Animation(GetImage(init.self));
|
||||
var offset = new AnimationWithOffset( roof ) { ZOffset = 24 };
|
||||
offset.DisableFunc = () => !buildComplete;
|
||||
anims.Add("roof", offset);
|
||||
anims.Add("roof", new AnimationWithOffset(roof, null, () => !buildComplete, 24));
|
||||
}
|
||||
|
||||
public void BuildingComplete( Actor self )
|
||||
|
||||
@@ -45,10 +45,10 @@ namespace OpenRA.Mods.RA.Render
|
||||
var muzzleFlash = new Animation(render.GetImage(self), getFacing);
|
||||
muzzleFlash.Play("muzzle");
|
||||
|
||||
muzzleFlashes.Add("muzzle{0}".F(muzzleFlashes.Count), new AnimationWithOffset(
|
||||
muzzleFlash,
|
||||
wr => wr.ScreenPxOffset(a.MuzzleOffset(self, barrel)),
|
||||
() => !isShowing));
|
||||
muzzleFlashes.Add("muzzle{0}".F(muzzleFlashes.Count),
|
||||
new AnimationWithOffset(muzzleFlash,
|
||||
() => a.MuzzleOffset(self, barrel),
|
||||
() => !isShowing));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,10 +32,9 @@ namespace OpenRA.Mods.RA.Render
|
||||
|
||||
rotorAnim = new Animation(rs.GetImage(self));
|
||||
rotorAnim.PlayRepeating("rotor");
|
||||
rs.anims.Add(info.Id, new AnimationWithOffset(
|
||||
rotorAnim,
|
||||
wr => wr.ScreenPxOffset(rs.LocalToWorld(info.Offset.Rotate(rs.QuantizeOrientation(self, self.Orientation)))),
|
||||
null ) { ZOffset = 1 } );
|
||||
rs.anims.Add(info.Id, new AnimationWithOffset(rotorAnim,
|
||||
() => rs.LocalToWorld(info.Offset.Rotate(rs.QuantizeOrientation(self, self.Orientation))),
|
||||
null, 1));
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
|
||||
@@ -28,11 +28,13 @@ namespace OpenRA.Mods.RA.Render
|
||||
|
||||
/* rude hack */
|
||||
var visualOffset = ((move is Helicopter || move is Mobile) && move.Altitude > 0)
|
||||
? Math.Abs((self.ActorID + Game.LocalTick) / 5 % 4 - 1) - 1 : 0;
|
||||
? (int)Math.Abs((self.ActorID + Game.LocalTick) / 5 % 4 - 1) - 1 : 0;
|
||||
|
||||
var shadowSprites = r.Select(a => a.WithPalette(wr.Palette("shadow")));
|
||||
var flyingSprites = (move.Altitude <= 0) ? r
|
||||
: r.Select(a => a.WithPxOffset(new float2(0, -(move.Altitude + visualOffset))).WithZOffset(move.Altitude + a.ZOffset));
|
||||
var shadowSprites = r.Select(a => a.WithPalette(wr.Palette("shadow"))
|
||||
.WithPos(a.Pos - new WVec(0, 0, a.Pos.Z)).WithZOffset(-24));
|
||||
|
||||
var flyingSprites = (move.Altitude <= 0) ? r :
|
||||
r.Select(a => a.WithPos(a.Pos - new WVec(0,0,43*visualOffset)));
|
||||
|
||||
return shadowSprites.Concat(flyingSprites);
|
||||
}
|
||||
|
||||
@@ -28,8 +28,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
var rs = self.Trait<RenderSimple>();
|
||||
|
||||
anim = new Animation("smoke_m");
|
||||
rs.anims.Add("smoke", new AnimationWithOffset(
|
||||
anim, null, () => !isSmoking));
|
||||
rs.anims.Add("smoke", new AnimationWithOffset(anim, null, () => !isSmoking));
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
|
||||
@@ -32,10 +32,9 @@ namespace OpenRA.Mods.RA.Render
|
||||
var rs = self.Trait<RenderSimple>();
|
||||
var spinner = new Animation(rs.GetImage(self));
|
||||
spinner.PlayRepeating(info.Sequence);
|
||||
rs.anims.Add("spinner_{0}".F(info.Sequence), new AnimationWithOffset(
|
||||
spinner,
|
||||
wr => wr.ScreenPxOffset(rs.LocalToWorld(info.Offset.Rotate(rs.QuantizeOrientation(self, self.Orientation)))),
|
||||
null ) { ZOffset = 1 } );
|
||||
rs.anims.Add("spinner_{0}".F(info.Sequence), new AnimationWithOffset(spinner,
|
||||
() => rs.LocalToWorld(info.Offset.Rotate(rs.QuantizeOrientation(self, self.Orientation))),
|
||||
null, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,20 +53,16 @@ namespace OpenRA.Mods.RA.Render
|
||||
anim = new Animation(rs.GetImage(self), () => t.turretFacing);
|
||||
anim.Play(info.Sequence);
|
||||
rs.anims.Add("turret_{0}".F(info.Turret), new AnimationWithOffset(
|
||||
anim,
|
||||
wr => TurretPosition(self, wr),
|
||||
null) { ZOffset = 1 });
|
||||
anim, () => TurretOffset(self), null, 24));
|
||||
}
|
||||
|
||||
int2 TurretPosition(Actor self, WorldRenderer wr)
|
||||
WVec TurretOffset(Actor self)
|
||||
{
|
||||
var recoil = arms.Aggregate(WRange.Zero, (a,b) => a + b.Recoil);
|
||||
var localOffset = new WVec(-recoil, WRange.Zero, WRange.Zero);
|
||||
var bodyOrientation = rs.QuantizeOrientation(self, self.Orientation);
|
||||
var turretOrientation = rs.QuantizeOrientation(self, t.LocalOrientation(self));
|
||||
var worldPos = t.Position(self) + rs.LocalToWorld(localOffset.Rotate(turretOrientation).Rotate(bodyOrientation));
|
||||
|
||||
return wr.ScreenPxOffset(worldPos);
|
||||
return t.Position(self) + rs.LocalToWorld(localOffset.Rotate(turretOrientation).Rotate(bodyOrientation));
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
|
||||
Reference in New Issue
Block a user