Convert Parachute to world coords.
This commit is contained in:
@@ -35,9 +35,7 @@ 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(new Parachute(pilot,
|
self.World.AddFrameEndTask(w => w.Add(new Parachute(pilot, self.CenterPosition)));
|
||||||
Util.CenterOfCell(self.CenterLocation.ToCPos()), aircraft.Altitude)));
|
|
||||||
|
|
||||||
Sound.Play(info.ChuteSound, self.CenterLocation);
|
Sound.Play(info.ChuteSound, self.CenterLocation);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -19,48 +19,46 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
public class Parachute : IEffect
|
public class Parachute : IEffect
|
||||||
{
|
{
|
||||||
readonly Animation paraAnim;
|
readonly Animation paraAnim;
|
||||||
readonly PPos location;
|
readonly WVec parachuteOffset;
|
||||||
|
|
||||||
readonly Actor cargo;
|
readonly Actor cargo;
|
||||||
|
WPos pos;
|
||||||
|
WVec fallRate = new WVec(0, 0, 13);
|
||||||
|
|
||||||
int2 offset;
|
public Parachute(Actor cargo, WPos dropPosition)
|
||||||
float altitude;
|
|
||||||
const float fallRate = .3f;
|
|
||||||
|
|
||||||
public Parachute(Actor cargo, PPos location, int altitude)
|
|
||||||
{
|
{
|
||||||
this.location = location;
|
|
||||||
this.altitude = altitude;
|
|
||||||
this.cargo = cargo;
|
this.cargo = cargo;
|
||||||
|
|
||||||
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)
|
||||||
|
parachuteOffset = pai.Offset;
|
||||||
|
|
||||||
cargo.Trait<ITeleportable>().SetPxPosition(cargo, location);
|
// Adjust x,y to match the target subcell
|
||||||
|
cargo.Trait<ITeleportable>().SetPosition(cargo, new CPos(dropPosition));
|
||||||
|
var cp = cargo.CenterPosition;
|
||||||
|
pos = new WPos(cp.X, cp.Y, dropPosition.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(World world)
|
public void Tick(World world)
|
||||||
{
|
{
|
||||||
paraAnim.Tick();
|
paraAnim.Tick();
|
||||||
|
|
||||||
altitude -= fallRate;
|
pos -= fallRate;
|
||||||
|
|
||||||
if (altitude <= 0)
|
if (pos.Z <= 0)
|
||||||
|
{
|
||||||
world.AddFrameEndTask(w =>
|
world.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
w.Remove(cargo);
|
w.Remove(this);
|
||||||
w.Remove(this);
|
cargo.CancelActivity();
|
||||||
var loc = location.ToCPos();
|
w.Add(cargo);
|
||||||
cargo.CancelActivity();
|
|
||||||
cargo.Trait<ITeleportable>().SetPosition(cargo, loc);
|
|
||||||
w.Add(cargo);
|
|
||||||
|
|
||||||
foreach( var npl in cargo.TraitsImplementing<INotifyParachuteLanded>() )
|
foreach (var npl in cargo.TraitsImplementing<INotifyParachuteLanded>())
|
||||||
npl.OnLanded();
|
npl.OnLanded();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Renderable> Render(WorldRenderer wr)
|
public IEnumerable<Renderable> Render(WorldRenderer wr)
|
||||||
@@ -74,12 +72,11 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
var shadow = wr.Palette("shadow");
|
var shadow = wr.Palette("shadow");
|
||||||
foreach (var c in rc)
|
foreach (var c in rc)
|
||||||
{
|
{
|
||||||
yield return c.WithPalette(shadow);
|
yield return c.WithPalette(shadow).WithZOffset(-1);
|
||||||
yield return c.WithPxOffset(new float2(0, -altitude)).WithZOffset(c.ZOffset + (int)altitude + 2);
|
yield return c.WithPos(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
var pos = location.ToFloat2() - new float2(0, altitude);
|
yield return new Renderable(paraAnim.Image, pos + parachuteOffset, 1, rc.First().Palette, 1f);
|
||||||
yield return new Renderable(paraAnim.Image, pos + offset, rc.First().Palette, 3);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,14 +52,7 @@ namespace OpenRA.Mods.RA
|
|||||||
droppedAt.Add(self.Location);
|
droppedAt.Add(self.Location);
|
||||||
|
|
||||||
var a = cargo.Unload(self);
|
var a = cargo.Unload(self);
|
||||||
|
self.World.AddFrameEndTask(w => w.Add(new Parachute(a, self.CenterPosition)));
|
||||||
var aircraft = self.Trait<IMove>();
|
|
||||||
self.World.AddFrameEndTask(w => w.Add(
|
|
||||||
new Parachute(a,
|
|
||||||
Util.CenterOfCell(self.CenterLocation.ToCPos()),
|
|
||||||
aircraft.Altitude)
|
|
||||||
));
|
|
||||||
|
|
||||||
Sound.Play(info.ChuteSound, self.CenterLocation);
|
Sound.Play(info.ChuteSound, self.CenterLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace OpenRA.Mods.RA
|
|||||||
class ParachuteAttachmentInfo : TraitInfo<ParachuteAttachment>
|
class ParachuteAttachmentInfo : TraitInfo<ParachuteAttachment>
|
||||||
{
|
{
|
||||||
public readonly string ParachuteSprite = "parach";
|
public readonly string ParachuteSprite = "parach";
|
||||||
public readonly int2 Offset = new int2(0,0);
|
public readonly WVec Offset = WVec.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ParachuteAttachment {}
|
class ParachuteAttachment {}
|
||||||
|
|||||||
@@ -116,7 +116,7 @@
|
|||||||
GpsDot:
|
GpsDot:
|
||||||
String:Infantry
|
String:Infantry
|
||||||
ParachuteAttachment:
|
ParachuteAttachment:
|
||||||
Offset: 0,-10
|
Offset: 0,0,427
|
||||||
CrushableInfantry:
|
CrushableInfantry:
|
||||||
CrushSound: squishy2.aud
|
CrushSound: squishy2.aud
|
||||||
RepairableNear:
|
RepairableNear:
|
||||||
|
|||||||
Reference in New Issue
Block a user