Make smoke trail palette customisable, add player color trail support to bullets & missiles
This commit is contained in:
@@ -39,6 +39,8 @@ namespace OpenRA.Mods.Common.Effects
|
||||
public readonly int TrailInterval = 2;
|
||||
[Desc("Delay in ticks until trail animaion is spawned.")]
|
||||
public readonly int TrailDelay = 1;
|
||||
public readonly string TrailPalette = "effect";
|
||||
public readonly bool TrailUsePlayerPalette = false;
|
||||
public readonly int ContrailLength = 0;
|
||||
public readonly Color ContrailColor = Color.White;
|
||||
public readonly bool ContrailUsePlayerColor = false;
|
||||
@@ -56,6 +58,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
[Sync] readonly WRange speed;
|
||||
|
||||
ContrailRenderable contrail;
|
||||
string trailPalette;
|
||||
|
||||
[Sync] WPos pos, target;
|
||||
[Sync] int length;
|
||||
@@ -105,6 +108,10 @@ namespace OpenRA.Mods.Common.Effects
|
||||
contrail = new ContrailRenderable(world, color, info.ContrailLength, info.ContrailDelay, 0);
|
||||
}
|
||||
|
||||
trailPalette = info.TrailPalette;
|
||||
if (info.TrailUsePlayerPalette)
|
||||
trailPalette += args.SourceActor.Owner.InternalName;
|
||||
|
||||
smokeTicks = info.TrailDelay;
|
||||
}
|
||||
|
||||
@@ -131,7 +138,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
if (info.Trail != null && --smokeTicks < 0)
|
||||
{
|
||||
var delayedPos = WPos.LerpQuadratic(args.Source, target, angle, ticks - info.TrailDelay, length);
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, delayedPos, info.Trail)));
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, delayedPos, info.Trail, trailPalette)));
|
||||
smokeTicks = info.TrailInterval;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,8 @@ namespace OpenRA.Mods.Common.Effects
|
||||
public readonly string Trail = null;
|
||||
[Desc("Interval in ticks between each spawned Trail animation.")]
|
||||
public readonly int TrailInterval = 2;
|
||||
public readonly string TrailPalette = "effect";
|
||||
public readonly bool TrailUsePlayerPalette = false;
|
||||
public readonly int ContrailLength = 0;
|
||||
public readonly Color ContrailColor = Color.White;
|
||||
public readonly bool ContrailUsePlayerColor = false;
|
||||
@@ -69,6 +71,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
|
||||
int ticksToNextSmoke;
|
||||
ContrailRenderable contrail;
|
||||
string trailPalette;
|
||||
|
||||
[Sync] WPos pos;
|
||||
[Sync] int facing;
|
||||
@@ -114,6 +117,10 @@ namespace OpenRA.Mods.Common.Effects
|
||||
var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor;
|
||||
contrail = new ContrailRenderable(world, color, info.ContrailLength, info.ContrailDelay, 0);
|
||||
}
|
||||
|
||||
trailPalette = info.TrailPalette;
|
||||
if (info.TrailUsePlayerPalette)
|
||||
trailPalette += args.SourceActor.Owner.InternalName;
|
||||
}
|
||||
|
||||
bool JammedBy(TraitPair<JamsMissiles> tp)
|
||||
@@ -164,7 +171,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
|
||||
if (info.Trail != null && --ticksToNextSmoke < 0)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, pos - 3 * move / 2, info.Trail)));
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, pos - 3 * move / 2, info.Trail, trailPalette)));
|
||||
ticksToNextSmoke = info.TrailInterval;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,14 @@ namespace OpenRA.Mods.Common.Effects
|
||||
readonly WPos pos;
|
||||
readonly CPos cell;
|
||||
readonly Animation anim;
|
||||
readonly string palette;
|
||||
|
||||
public Smoke(World world, WPos pos, string trail)
|
||||
public Smoke(World world, WPos pos, string trail, string palette)
|
||||
{
|
||||
this.world = world;
|
||||
this.pos = pos;
|
||||
this.cell = world.Map.CellContaining(pos);
|
||||
this.palette = palette;
|
||||
|
||||
anim = new Animation(world, trail);
|
||||
anim.PlayThen("idle",
|
||||
@@ -39,7 +41,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
if (world.FogObscures(cell))
|
||||
return SpriteRenderable.None;
|
||||
|
||||
return anim.Render(pos, wr.Palette("effect"));
|
||||
return anim.Render(pos, wr.Palette(palette));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
public readonly int Interval = 3;
|
||||
public readonly string Sprite = "smokey";
|
||||
public readonly string Palette = "effect";
|
||||
public readonly DamageState MinDamage = DamageState.Heavy;
|
||||
|
||||
public object Create(ActorInitializer init) { return new SmokeTrailWhenDamaged(init.Self, this); }
|
||||
@@ -45,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var offset = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation));
|
||||
var pos = position + body.LocalToWorld(offset);
|
||||
self.World.AddFrameEndTask(w => w.Add(new Smoke(w, pos, info.Sprite)));
|
||||
self.World.AddFrameEndTask(w => w.Add(new Smoke(w, pos, info.Sprite, info.Palette)));
|
||||
}
|
||||
|
||||
ticks = info.Interval;
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Sprite sequence name")]
|
||||
public readonly string SmokeType = "smoke_m";
|
||||
|
||||
public readonly string SmokePalette = "effect";
|
||||
|
||||
public readonly string Palette = "terrain";
|
||||
|
||||
public object Create(ActorInitializer init) { return new SmudgeLayer(this); }
|
||||
@@ -86,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public void AddSmudge(CPos loc)
|
||||
{
|
||||
if (Game.CosmeticRandom.Next(0, 100) <= Info.SmokePercentage)
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, world.Map.CenterOfCell(loc), Info.SmokeType)));
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, world.Map.CenterOfCell(loc), Info.SmokeType, Info.SmokePalette)));
|
||||
|
||||
if (!dirty.ContainsKey(loc) && !tiles.ContainsKey(loc))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user