Let parachute cargo render themselves.
This allows for tanks and other multi-sprite actors to render correctly while dropping.
This commit is contained in:
@@ -35,10 +35,8 @@ namespace OpenRA.Mods.RA
|
|||||||
if (IsSuitableCell(pilot, self.Location) && r > 100 - info.SuccessRate && aircraft.Altitude > 10
|
if (IsSuitableCell(pilot, self.Location) && r > 100 - info.SuccessRate && aircraft.Altitude > 10
|
||||||
&& self.Owner.WinState != WinState.Lost)
|
&& self.Owner.WinState != WinState.Lost)
|
||||||
{
|
{
|
||||||
self.World.AddFrameEndTask(w => w.Add(
|
self.World.AddFrameEndTask(w => w.Add(new Parachute(pilot,
|
||||||
new Parachute(pilot.Owner,
|
Util.CenterOfCell(self.CenterLocation.ToCPos()), aircraft.Altitude)));
|
||||||
Util.CenterOfCell(self.CenterLocation.ToCPos()),
|
|
||||||
aircraft.Altitude, pilot)));
|
|
||||||
|
|
||||||
Sound.Play(info.ChuteSound, self.CenterLocation);
|
Sound.Play(info.ChuteSound, self.CenterLocation);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Effects;
|
using OpenRA.Effects;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -17,8 +18,6 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
{
|
{
|
||||||
public class Parachute : IEffect
|
public class Parachute : IEffect
|
||||||
{
|
{
|
||||||
readonly Animation anim;
|
|
||||||
readonly PaletteReference palette;
|
|
||||||
readonly Animation paraAnim;
|
readonly Animation paraAnim;
|
||||||
readonly PPos location;
|
readonly PPos location;
|
||||||
|
|
||||||
@@ -28,29 +27,19 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
float altitude;
|
float altitude;
|
||||||
const float fallRate = .3f;
|
const float fallRate = .3f;
|
||||||
|
|
||||||
public Parachute(Player owner, PPos location, int altitude, Actor cargo)
|
public Parachute(Actor cargo, PPos location, int altitude)
|
||||||
{
|
{
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.altitude = altitude;
|
this.altitude = altitude;
|
||||||
this.cargo = cargo;
|
this.cargo = cargo;
|
||||||
|
|
||||||
var rs = cargo.Trait<RenderSimple>();
|
|
||||||
var image = rs.anim.Name;
|
|
||||||
palette = rs.Palette(owner);
|
|
||||||
|
|
||||||
anim = new Animation(image);
|
|
||||||
if (anim.HasSequence("idle"))
|
|
||||||
anim.PlayFetchIndex("idle", () => 0);
|
|
||||||
else
|
|
||||||
anim.PlayFetchIndex("stand", () => 0);
|
|
||||||
anim.Tick();
|
|
||||||
|
|
||||||
var pai = cargo.Info.Traits.GetOrDefault<ParachuteAttachmentInfo>();
|
var pai = cargo.Info.Traits.GetOrDefault<ParachuteAttachmentInfo>();
|
||||||
|
|
||||||
paraAnim = new Animation(pai != null ? pai.ParachuteSprite : "parach");
|
paraAnim = new Animation(pai != null ? pai.ParachuteSprite : "parach");
|
||||||
paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle"));
|
paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle"));
|
||||||
|
|
||||||
if (pai != null) offset = pai.Offset;
|
if (pai != null) offset = pai.Offset;
|
||||||
|
|
||||||
|
cargo.Trait<ITeleportable>().SetPxPosition(cargo, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(World world)
|
public void Tick(World world)
|
||||||
@@ -75,10 +64,16 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
|
|
||||||
public IEnumerable<Renderable> Render(WorldRenderer wr)
|
public IEnumerable<Renderable> Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
|
var rc = cargo.Render(wr).Select(a => a.WithPos(a.Pos - new float2(0, altitude))
|
||||||
|
.WithZOffset(a.ZOffset + (int)altitude));
|
||||||
|
foreach (var c in rc)
|
||||||
|
{
|
||||||
|
yield return c.WithPos(location.ToFloat2() - .5f * c.Sprite.size).WithPalette(wr.Palette("shadow")).WithZOffset(0);
|
||||||
|
yield return c.WithZOffset(2);
|
||||||
|
}
|
||||||
|
|
||||||
var pos = location.ToFloat2() - new float2(0, altitude);
|
var pos = location.ToFloat2() - new float2(0, altitude);
|
||||||
yield return new Renderable(anim.Image, location.ToFloat2() - .5f * anim.Image.size, wr.Palette("shadow"), 0);
|
yield return new Renderable(paraAnim.Image, pos - .5f * paraAnim.Image.size + offset, rc.First().Palette, 3);
|
||||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, palette, 2);
|
|
||||||
yield return new Renderable(paraAnim.Image, pos - .5f * paraAnim.Image.size + offset, palette, 3);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,11 +55,9 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
var aircraft = self.Trait<IMove>();
|
var aircraft = self.Trait<IMove>();
|
||||||
self.World.AddFrameEndTask(w => w.Add(
|
self.World.AddFrameEndTask(w => w.Add(
|
||||||
new Parachute(
|
new Parachute(a,
|
||||||
self.Owner,
|
|
||||||
Util.CenterOfCell(self.CenterLocation.ToCPos()),
|
Util.CenterOfCell(self.CenterLocation.ToCPos()),
|
||||||
aircraft.Altitude, a
|
aircraft.Altitude)
|
||||||
)
|
|
||||||
));
|
));
|
||||||
|
|
||||||
Sound.Play(info.ChuteSound, self.CenterLocation);
|
Sound.Play(info.ChuteSound, self.CenterLocation);
|
||||||
|
|||||||
Reference in New Issue
Block a user