working missile trails
This commit is contained in:
@@ -14,6 +14,7 @@ using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
@@ -30,6 +31,9 @@ namespace OpenRA.Mods.RA.Effects
|
||||
public readonly bool Proximity = false;
|
||||
public readonly float Angle = 0;
|
||||
public readonly int TrailInterval = 2;
|
||||
public readonly int ContrailLength = 0;
|
||||
public readonly bool ContrailUsePlayerColor = false;
|
||||
public readonly int ContrailDelay = 1;
|
||||
|
||||
public IEffect Create(ProjectileArgs args) { return new Bullet( this, args ); }
|
||||
}
|
||||
@@ -43,6 +47,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
Animation anim;
|
||||
|
||||
const int BaseBulletSpeed = 100; /* pixels / 40ms frame */
|
||||
ContrailHistory Trail;
|
||||
|
||||
public Bullet(BulletInfo info, ProjectileArgs args)
|
||||
{
|
||||
@@ -60,6 +65,13 @@ namespace OpenRA.Mods.RA.Effects
|
||||
anim = new Animation(Info.Image, GetEffectiveFacing);
|
||||
anim.PlayRepeating("idle");
|
||||
}
|
||||
|
||||
if (Info.ContrailLength > 0)
|
||||
{
|
||||
Trail = new ContrailHistory(Info.ContrailLength,
|
||||
Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Color.White,
|
||||
Info.ContrailDelay);
|
||||
}
|
||||
}
|
||||
|
||||
int TotalTime() { return (Args.dest - Args.src).Length * BaseBulletSpeed / Info.Speed; }
|
||||
@@ -94,7 +106,6 @@ namespace OpenRA.Mods.RA.Effects
|
||||
|
||||
if (t > TotalTime()) Explode( world );
|
||||
|
||||
if (Info.Trail != null)
|
||||
{
|
||||
var at = (float)t / TotalTime();
|
||||
var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at);
|
||||
@@ -104,12 +115,15 @@ namespace OpenRA.Mods.RA.Effects
|
||||
? (pos - new float2(0, GetAltitude()))
|
||||
: pos;
|
||||
|
||||
if (--ticksToNextSmoke < 0)
|
||||
if (Info.Trail != null && --ticksToNextSmoke < 0)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Add(
|
||||
new Smoke(w, highPos.ToInt2(), Info.Trail)));
|
||||
ticksToNextSmoke = Info.TrailInterval;
|
||||
}
|
||||
|
||||
if (Trail != null)
|
||||
Trail.Tick(highPos);
|
||||
}
|
||||
|
||||
if (!Info.High) // check for hitting a wall
|
||||
@@ -129,29 +143,35 @@ namespace OpenRA.Mods.RA.Effects
|
||||
|
||||
const float height = .1f;
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
if (anim != null)
|
||||
{
|
||||
var at = (float)t / TotalTime();
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
if (anim != null)
|
||||
{
|
||||
var at = (float)t / TotalTime();
|
||||
|
||||
var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at);
|
||||
var pos = float2.Lerp(Args.src, Args.dest, at) - new float2(0, altitude);
|
||||
var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at);
|
||||
var pos = float2.Lerp(Args.src, Args.dest, at) - new float2(0, altitude);
|
||||
|
||||
if (Info.High || Info.Angle > 0)
|
||||
{
|
||||
if (Info.Shadow)
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "shadow", (int)pos.Y);
|
||||
if (Args.firedBy.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(pos)))
|
||||
{
|
||||
if (Info.High || Info.Angle > 0)
|
||||
{
|
||||
if (Info.Shadow)
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "shadow", (int)pos.Y);
|
||||
|
||||
var highPos = pos - new float2(0, GetAltitude());
|
||||
var highPos = pos - new float2(0, GetAltitude());
|
||||
|
||||
yield return new Renderable(anim.Image, highPos - .5f * anim.Image.size, Args.firedBy.Owner.Palette, (int)pos.Y);
|
||||
}
|
||||
else
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size,
|
||||
Args.weapon.Underwater ? "shadow" : Args.firedBy.Owner.Palette, (int)pos.Y);
|
||||
}
|
||||
}
|
||||
yield return new Renderable(anim.Image, highPos - .5f * anim.Image.size, Args.firedBy.Owner.Palette, (int)pos.Y);
|
||||
}
|
||||
else
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size,
|
||||
Args.weapon.Underwater ? "shadow" : Args.firedBy.Owner.Palette, (int)pos.Y);
|
||||
}
|
||||
}
|
||||
|
||||
if (Trail != null)
|
||||
Trail.Render(Args.firedBy);
|
||||
}
|
||||
|
||||
void Explode( World world )
|
||||
{
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace OpenRA.Mods.RA
|
||||
List<float2> positions = new List<float2>();
|
||||
readonly int TrailLength;
|
||||
readonly Color Color;
|
||||
readonly int StartSkip;
|
||||
|
||||
public static Color ChooseColor(Actor self)
|
||||
{
|
||||
@@ -66,9 +67,13 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
public ContrailHistory(int trailLength, Color color)
|
||||
: this(trailLength, color, 0) { }
|
||||
|
||||
public ContrailHistory(int trailLength, Color color, int startSkip)
|
||||
{
|
||||
this.TrailLength = trailLength;
|
||||
this.Color = color;
|
||||
this.StartSkip = startSkip;
|
||||
}
|
||||
|
||||
public void Tick(float2 currentPos)
|
||||
@@ -84,7 +89,7 @@ namespace OpenRA.Mods.RA
|
||||
Color trailEnd = Color.FromArgb(trailStart.A - 255 / TrailLength, trailStart.R,
|
||||
trailStart.G, trailStart.B);
|
||||
|
||||
for (int i = positions.Count - 1; i >= 1; --i)
|
||||
for (int i = positions.Count - 1 - StartSkip; i >= 1; --i)
|
||||
{
|
||||
var conPos = positions[i];
|
||||
var nextPos = positions[i - 1];
|
||||
|
||||
@@ -34,7 +34,8 @@ namespace OpenRA.Mods.RA.Effects
|
||||
public readonly bool TurboBoost = false;
|
||||
public readonly int TrailInterval = 2;
|
||||
public readonly int ContrailLength = 0;
|
||||
public readonly bool ContrailUsePlayerColor = true;
|
||||
public readonly bool ContrailUsePlayerColor = false;
|
||||
public readonly int ContrailDelay = 1;
|
||||
|
||||
public IEffect Create(ProjectileArgs args) { return new Missile( this, args ); }
|
||||
}
|
||||
@@ -54,28 +55,31 @@ namespace OpenRA.Mods.RA.Effects
|
||||
int Altitude;
|
||||
ContrailHistory Trail;
|
||||
|
||||
public Missile(MissileInfo info, ProjectileArgs args)
|
||||
{
|
||||
Info = info;
|
||||
Args = args;
|
||||
public Missile(MissileInfo info, ProjectileArgs args)
|
||||
{
|
||||
Info = info;
|
||||
Args = args;
|
||||
|
||||
SubPxPosition = 1024*Args.src;
|
||||
Altitude = Args.srcAltitude;
|
||||
Facing = Args.facing;
|
||||
SubPxPosition = 1024 * Args.src;
|
||||
Altitude = Args.srcAltitude;
|
||||
Facing = Args.facing;
|
||||
|
||||
if (info.Inaccuracy > 0)
|
||||
offset = (info.Inaccuracy * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2();
|
||||
if (info.Inaccuracy > 0)
|
||||
offset = (info.Inaccuracy * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2();
|
||||
|
||||
if (Info.Image != null)
|
||||
{
|
||||
anim = new Animation(Info.Image, () => Facing);
|
||||
anim.PlayRepeating("idle");
|
||||
}
|
||||
if (Info.Image != null)
|
||||
{
|
||||
anim = new Animation(Info.Image, () => Facing);
|
||||
anim.PlayRepeating("idle");
|
||||
}
|
||||
|
||||
if (Info.ContrailLength > 0)
|
||||
Trail = new ContrailHistory(Info.ContrailLength,
|
||||
Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Color.White);
|
||||
}
|
||||
{
|
||||
Trail = new ContrailHistory(Info.ContrailLength,
|
||||
Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Color.White,
|
||||
Info.ContrailDelay);
|
||||
}
|
||||
}
|
||||
|
||||
// In pixels
|
||||
const int MissileCloseEnough = 7;
|
||||
@@ -149,8 +153,9 @@ namespace OpenRA.Mods.RA.Effects
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image,PxPosition.ToFloat2() - 0.5f * anim.Image.size - new float2(0, Altitude),
|
||||
Args.weapon.Underwater ? "shadow" : "effect", PxPosition.Y);
|
||||
if (Args.firedBy.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(PxPosition.ToFloat2())))
|
||||
yield return new Renderable(anim.Image,PxPosition.ToFloat2() - 0.5f * anim.Image.size - new float2(0, Altitude),
|
||||
Args.weapon.Underwater ? "shadow" : "effect", PxPosition.Y);
|
||||
|
||||
if (Trail != null)
|
||||
Trail.Render(Args.firedBy);
|
||||
|
||||
@@ -119,7 +119,8 @@ Maverick:
|
||||
High: true
|
||||
Shadow: false
|
||||
Proximity: true
|
||||
Trail: smokey
|
||||
# Trail: smokey
|
||||
ContrailLength: 10
|
||||
Inaccuracy: 12
|
||||
Image: DRAGON
|
||||
ROT: 5
|
||||
@@ -266,6 +267,7 @@ Dragon:
|
||||
Shadow: false
|
||||
Proximity: true
|
||||
Trail: smokey
|
||||
ContrailLength: 10
|
||||
Inaccuracy: 3
|
||||
Image: DRAGON
|
||||
ROT: 5
|
||||
@@ -295,7 +297,8 @@ Hellfire:
|
||||
High: true
|
||||
Shadow: false
|
||||
Proximity: true
|
||||
Trail: smokey
|
||||
# Trail: smokey
|
||||
ContrailLength: 10
|
||||
Inaccuracy: 3
|
||||
Image: DRAGON
|
||||
ROT: 5
|
||||
@@ -452,7 +455,8 @@ MammothTusk:
|
||||
High: true
|
||||
Shadow: false
|
||||
Proximity: true
|
||||
Trail: smokey
|
||||
# Trail: smokey
|
||||
ContrailLength: 10
|
||||
Inaccuracy: 3
|
||||
Image: DRAGON
|
||||
ROT: 5
|
||||
@@ -481,6 +485,7 @@ MammothTusk:
|
||||
Angle: .1
|
||||
Inaccuracy: 40
|
||||
Image: 120MM
|
||||
ContrailLength: 30
|
||||
Warhead:
|
||||
Spread: 10
|
||||
Versus:
|
||||
@@ -616,7 +621,8 @@ Nike:
|
||||
High: true
|
||||
Shadow: false
|
||||
Proximity: true
|
||||
Trail: smokey
|
||||
# Trail: smokey
|
||||
ContrailLength: 10
|
||||
Image: MISSILE
|
||||
ROT: 25
|
||||
RangeLimit: 50
|
||||
@@ -644,7 +650,8 @@ RedEye:
|
||||
High: true
|
||||
Shadow: false
|
||||
Proximity: true
|
||||
Trail: smokey
|
||||
# Trail: smokey
|
||||
ContrailLength: 10
|
||||
Image: MISSILE
|
||||
ROT: 20
|
||||
RangeLimit: 30
|
||||
@@ -673,6 +680,7 @@ RedEye:
|
||||
Angle: .1
|
||||
Inaccuracy: 120
|
||||
Image: 120MM
|
||||
ContrailLength: 30
|
||||
Warhead:
|
||||
Spread: 3
|
||||
Versus:
|
||||
@@ -701,6 +709,7 @@ SubMissile:
|
||||
Inaccuracy: 70
|
||||
Image: MISSILE
|
||||
Trail: smokey
|
||||
ContrailLength: 30
|
||||
Warhead:
|
||||
Spread: 10
|
||||
Versus:
|
||||
@@ -727,7 +736,8 @@ Stinger:
|
||||
High: true
|
||||
Shadow: false
|
||||
Proximity: true
|
||||
Trail: smokey
|
||||
# Trail: smokey
|
||||
ContrailLength: 10
|
||||
Image: DRAGON
|
||||
ROT: 20
|
||||
RangeLimit: 50
|
||||
@@ -753,11 +763,11 @@ TorpTube:
|
||||
ValidTargets: Water, Underwater
|
||||
Underwater: yes
|
||||
Burst: 2
|
||||
BurstDelay: 1
|
||||
BurstDelay: 20
|
||||
Projectile: Missile
|
||||
Image: MISSILE
|
||||
Arm: 3
|
||||
Speed: 6
|
||||
Speed: 10
|
||||
Trail: bubbles
|
||||
ROT: 1
|
||||
RangeLimit: 160
|
||||
@@ -771,7 +781,7 @@ TorpTube:
|
||||
WaterExplosion: large_splash
|
||||
InfDeath: 3
|
||||
SmudgeType: Crater
|
||||
Damage: 90
|
||||
Damage: 180
|
||||
|
||||
2Inch:
|
||||
ROF: 60
|
||||
|
||||
Reference in New Issue
Block a user