internal machinery for contrails on missiles
This commit is contained in:
@@ -34,17 +34,11 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
ContrailHistory history;
|
ContrailHistory history;
|
||||||
|
|
||||||
static Color ChooseColor(Actor self)
|
|
||||||
{
|
|
||||||
var ownerColor = Color.FromArgb(255, self.Owner.ColorRamp.GetColor(0));
|
|
||||||
return PlayerColorRemap.ColorLerp(0.5f, ownerColor, Color.White);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Contrail(Actor self, ContrailInfo info)
|
public Contrail(Actor self, ContrailInfo info)
|
||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
ContrailTurret = new Turret(Info.ContrailOffset);
|
ContrailTurret = new Turret(Info.ContrailOffset);
|
||||||
history = new ContrailHistory(Info.TrailLength, Info.UsePlayerColor ? ChooseColor(self) : Color.White);
|
history = new ContrailHistory(Info.TrailLength, Info.UsePlayerColor ? ContrailHistory.ChooseColor(self) : Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
@@ -65,6 +59,12 @@ namespace OpenRA.Mods.RA
|
|||||||
readonly int TrailLength;
|
readonly int TrailLength;
|
||||||
readonly Color Color;
|
readonly Color Color;
|
||||||
|
|
||||||
|
public static Color ChooseColor(Actor self)
|
||||||
|
{
|
||||||
|
var ownerColor = Color.FromArgb(255, self.Owner.ColorRamp.GetColor(0));
|
||||||
|
return PlayerColorRemap.ColorLerp(0.5f, ownerColor, Color.White);
|
||||||
|
}
|
||||||
|
|
||||||
public ContrailHistory(int trailLength, Color color)
|
public ContrailHistory(int trailLength, Color color)
|
||||||
{
|
{
|
||||||
this.TrailLength = trailLength;
|
this.TrailLength = trailLength;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using OpenRA.Effects;
|
|||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Effects
|
namespace OpenRA.Mods.RA.Effects
|
||||||
{
|
{
|
||||||
@@ -32,6 +33,8 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
public readonly int RangeLimit = 0;
|
public readonly int RangeLimit = 0;
|
||||||
public readonly bool TurboBoost = false;
|
public readonly bool TurboBoost = false;
|
||||||
public readonly int TrailInterval = 2;
|
public readonly int TrailInterval = 2;
|
||||||
|
public readonly int ContrailLength = 0;
|
||||||
|
public readonly bool ContrailUsePlayerColor = true;
|
||||||
|
|
||||||
public IEffect Create(ProjectileArgs args) { return new Missile( this, args ); }
|
public IEffect Create(ProjectileArgs args) { return new Missile( this, args ); }
|
||||||
}
|
}
|
||||||
@@ -49,6 +52,7 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
int Facing;
|
int Facing;
|
||||||
int t;
|
int t;
|
||||||
int Altitude;
|
int Altitude;
|
||||||
|
ContrailHistory Trail;
|
||||||
|
|
||||||
public Missile(MissileInfo info, ProjectileArgs args)
|
public Missile(MissileInfo info, ProjectileArgs args)
|
||||||
{
|
{
|
||||||
@@ -67,6 +71,10 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
anim = new Animation(Info.Image, () => Facing);
|
anim = new Animation(Info.Image, () => Facing);
|
||||||
anim.PlayRepeating("idle");
|
anim.PlayRepeating("idle");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Info.ContrailLength > 0)
|
||||||
|
Trail = new ContrailHistory(Info.ContrailLength,
|
||||||
|
Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In pixels
|
// In pixels
|
||||||
@@ -126,6 +134,9 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
a => a.HasTrait<IBlocksBullets>()))
|
a => a.HasTrait<IBlocksBullets>()))
|
||||||
Explode(world);
|
Explode(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Trail != null)
|
||||||
|
Trail.Tick(PxPosition - new float2(0,Altitude));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Explode(World world)
|
void Explode(World world)
|
||||||
@@ -140,6 +151,9 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
{
|
{
|
||||||
yield return new Renderable(anim.Image,PxPosition.ToFloat2() - 0.5f * anim.Image.size - new float2(0, Altitude),
|
yield return new Renderable(anim.Image,PxPosition.ToFloat2() - 0.5f * anim.Image.size - new float2(0, Altitude),
|
||||||
Args.weapon.Underwater ? "shadow" : "effect", PxPosition.Y);
|
Args.weapon.Underwater ? "shadow" : "effect", PxPosition.Y);
|
||||||
|
|
||||||
|
if (Trail != null)
|
||||||
|
Trail.Render(Args.firedBy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user