Add sprite trail support to NukeLaunch/NukePower
This commit is contained in:
@@ -35,14 +35,20 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
readonly WPos descendTarget;
|
readonly WPos descendTarget;
|
||||||
readonly int impactDelay;
|
readonly int impactDelay;
|
||||||
readonly int turn;
|
readonly int turn;
|
||||||
|
readonly string trailImage;
|
||||||
|
readonly string[] trailSequences;
|
||||||
|
readonly string trailPalette;
|
||||||
|
readonly int trailInterval;
|
||||||
|
readonly int trailDelay;
|
||||||
|
|
||||||
WPos pos;
|
WPos pos;
|
||||||
int ticks;
|
int ticks, trailTicks;
|
||||||
int launchDelay;
|
int launchDelay;
|
||||||
bool isLaunched;
|
bool isLaunched;
|
||||||
|
|
||||||
public NukeLaunch(Player firedBy, string name, WeaponInfo weapon, string weaponPalette, string upSequence, string downSequence,
|
public NukeLaunch(Player firedBy, string name, WeaponInfo weapon, string weaponPalette, string upSequence, string downSequence,
|
||||||
WPos launchPos, WPos targetPos, WDist velocity, int launchDelay, int impactDelay, bool skipAscent, string flashType)
|
WPos launchPos, WPos targetPos, WDist velocity, int launchDelay, int impactDelay, bool skipAscent, string flashType,
|
||||||
|
string trailImage, string[] trailSequences, string trailPalette, bool trailUsePlayerPalette, int trailDelay, int trailInterval)
|
||||||
{
|
{
|
||||||
this.firedBy = firedBy;
|
this.firedBy = firedBy;
|
||||||
this.weapon = weapon;
|
this.weapon = weapon;
|
||||||
@@ -53,6 +59,15 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
this.impactDelay = impactDelay;
|
this.impactDelay = impactDelay;
|
||||||
turn = skipAscent ? 0 : impactDelay / 2;
|
turn = skipAscent ? 0 : impactDelay / 2;
|
||||||
this.flashType = flashType;
|
this.flashType = flashType;
|
||||||
|
this.trailImage = trailImage;
|
||||||
|
this.trailSequences = trailSequences;
|
||||||
|
this.trailPalette = trailPalette;
|
||||||
|
if (trailUsePlayerPalette)
|
||||||
|
trailPalette += firedBy.InternalName;
|
||||||
|
|
||||||
|
this.trailInterval = trailInterval;
|
||||||
|
this.trailDelay = trailDelay;
|
||||||
|
trailTicks = trailDelay;
|
||||||
|
|
||||||
var offset = new WVec(WDist.Zero, WDist.Zero, velocity * (impactDelay - turn));
|
var offset = new WVec(WDist.Zero, WDist.Zero, velocity * (impactDelay - turn));
|
||||||
ascendSource = launchPos;
|
ascendSource = launchPos;
|
||||||
@@ -90,6 +105,17 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
else
|
else
|
||||||
pos = WPos.LerpQuadratic(descendSource, descendTarget, WAngle.Zero, ticks - turn, impactDelay - turn);
|
pos = WPos.LerpQuadratic(descendSource, descendTarget, WAngle.Zero, ticks - turn, impactDelay - turn);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(trailImage) && --trailTicks < 0)
|
||||||
|
{
|
||||||
|
var trailPos = ticks < turn ? WPos.LerpQuadratic(ascendSource, ascendTarget, WAngle.Zero, ticks - trailDelay, turn)
|
||||||
|
: WPos.LerpQuadratic(descendSource, descendTarget, WAngle.Zero, ticks - turn - trailDelay, impactDelay - turn);
|
||||||
|
|
||||||
|
world.AddFrameEndTask(w => w.Add(new SpriteEffect(trailPos, w, trailImage, trailSequences.Random(world.SharedRandom),
|
||||||
|
trailPalette, false, false, 0)));
|
||||||
|
|
||||||
|
trailTicks = trailInterval;
|
||||||
|
}
|
||||||
|
|
||||||
if (ticks == impactDelay)
|
if (ticks == impactDelay)
|
||||||
Explode(world);
|
Explode(world);
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,24 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Custom palette is a player palette BaseName.")]
|
[Desc("Custom palette is a player palette BaseName.")]
|
||||||
public readonly bool IsPlayerPalette = false;
|
public readonly bool IsPlayerPalette = false;
|
||||||
|
|
||||||
|
[Desc("Trail animation.")]
|
||||||
|
public readonly string TrailImage = null;
|
||||||
|
|
||||||
|
[Desc("Loop a randomly chosen sequence of TrailImage from this list while this projectile is moving.")]
|
||||||
|
[SequenceReference("TrailImage")] public readonly string[] TrailSequences = { "idle" };
|
||||||
|
|
||||||
|
[Desc("Interval in ticks between each spawned Trail animation.")]
|
||||||
|
public readonly int TrailInterval = 1;
|
||||||
|
|
||||||
|
[Desc("Delay in ticks until trail animation is spawned.")]
|
||||||
|
public readonly int TrailDelay = 1;
|
||||||
|
|
||||||
|
[Desc("Palette used to render the trail sequence.")]
|
||||||
|
[PaletteReference("TrailUsePlayerPalette")] public readonly string TrailPalette = "effect";
|
||||||
|
|
||||||
|
[Desc("Use the Player Palette to render the trail sequence.")]
|
||||||
|
public readonly bool TrailUsePlayerPalette = false;
|
||||||
|
|
||||||
[Desc("Travel time - split equally between ascent and descent.")]
|
[Desc("Travel time - split equally between ascent and descent.")]
|
||||||
public readonly int FlightDelay = 400;
|
public readonly int FlightDelay = 400;
|
||||||
|
|
||||||
@@ -117,7 +135,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.CenterPosition + body.LocalToWorld(info.SpawnOffset),
|
self.CenterPosition + body.LocalToWorld(info.SpawnOffset),
|
||||||
targetPosition,
|
targetPosition,
|
||||||
info.FlightVelocity, info.MissileDelay, info.FlightDelay, info.SkipAscent,
|
info.FlightVelocity, info.MissileDelay, info.FlightDelay, info.SkipAscent,
|
||||||
info.FlashType);
|
info.FlashType,
|
||||||
|
info.TrailImage, info.TrailSequences, info.TrailPalette, info.TrailUsePlayerPalette, info.TrailDelay, info.TrailInterval);
|
||||||
|
|
||||||
self.World.AddFrameEndTask(w => w.Add(missile));
|
self.World.AddFrameEndTask(w => w.Add(missile));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user