From d3ab8dbd014997687bd8be818d0f91c9a3b1a524 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Tue, 1 Mar 2016 20:50:35 +0100 Subject: [PATCH 1/3] Add facing support to Smoke effect --- OpenRA.Mods.Common/Effects/Smoke.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Effects/Smoke.cs b/OpenRA.Mods.Common/Effects/Smoke.cs index 7c3b11bc00..3a64d4369a 100644 --- a/OpenRA.Mods.Common/Effects/Smoke.cs +++ b/OpenRA.Mods.Common/Effects/Smoke.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using System.Collections.Generic; using OpenRA.Effects; using OpenRA.Graphics; @@ -23,12 +24,15 @@ namespace OpenRA.Mods.Common.Effects readonly string palette; public Smoke(World world, WPos pos, string trail, string palette, string sequence) + : this(world, pos, () => 0, trail, palette, sequence) { } + + public Smoke(World world, WPos pos, Func facingFunc, string trail, string palette, string sequence) { this.world = world; this.pos = pos; this.palette = palette; - anim = new Animation(world, trail); + anim = new Animation(world, trail, facingFunc); anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this))); } From d063087de916fbe64c9eaa596785809055fccda4 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Fri, 2 Oct 2015 21:50:58 +0200 Subject: [PATCH 2/3] Add TrailSequences to Bullet And use that instead of Sequences. --- OpenRA.Mods.Common/Effects/Bullet.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Effects/Bullet.cs b/OpenRA.Mods.Common/Effects/Bullet.cs index e507410f55..1452bd419c 100644 --- a/OpenRA.Mods.Common/Effects/Bullet.cs +++ b/OpenRA.Mods.Common/Effects/Bullet.cs @@ -47,6 +47,9 @@ namespace OpenRA.Mods.Common.Effects [Desc("Trail animation.")] public readonly string Trail = null; + [Desc("Loop these sequences of Trail while this projectile is moving.")] + [SequenceReference("Trail")] public readonly string[] TrailSequences = { "idle" }; + [Desc("Is this blocked by actors with BlocksProjectiles trait.")] public readonly bool Blockable = true; @@ -179,7 +182,7 @@ namespace OpenRA.Mods.Common.Effects if (!string.IsNullOrEmpty(info.Trail) && --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, trailPalette, info.Sequences.Random(world.SharedRandom)))); + world.AddFrameEndTask(w => w.Add(new Smoke(w, delayedPos, info.Trail, trailPalette, info.TrailSequences.Random(world.SharedRandom)))); smokeTicks = info.TrailInterval; } From 717a5063d96ede4fa3bc808a2ae4e04aedc48f2d Mon Sep 17 00:00:00 2001 From: reaperrr Date: Tue, 1 Mar 2016 23:15:11 +0100 Subject: [PATCH 3/3] Add facings support to projectile trails and SmokeTrailWhenDamaged --- OpenRA.Mods.Common/Effects/Bullet.cs | 2 +- OpenRA.Mods.Common/Effects/Missile.cs | 2 +- OpenRA.Mods.Common/Traits/SmokeTrailWhenDamaged.cs | 10 +++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Effects/Bullet.cs b/OpenRA.Mods.Common/Effects/Bullet.cs index 1452bd419c..f7b6e7b269 100644 --- a/OpenRA.Mods.Common/Effects/Bullet.cs +++ b/OpenRA.Mods.Common/Effects/Bullet.cs @@ -182,7 +182,7 @@ namespace OpenRA.Mods.Common.Effects if (!string.IsNullOrEmpty(info.Trail) && --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, trailPalette, info.TrailSequences.Random(world.SharedRandom)))); + world.AddFrameEndTask(w => w.Add(new Smoke(w, delayedPos, () => GetEffectiveFacing(), info.Trail, trailPalette, info.TrailSequences.Random(world.SharedRandom)))); smokeTicks = info.TrailInterval; } diff --git a/OpenRA.Mods.Common/Effects/Missile.cs b/OpenRA.Mods.Common/Effects/Missile.cs index 55341fa541..2fe5fed611 100644 --- a/OpenRA.Mods.Common/Effects/Missile.cs +++ b/OpenRA.Mods.Common/Effects/Missile.cs @@ -805,7 +805,7 @@ namespace OpenRA.Mods.Common.Effects // Create the smoke trail effect if (!string.IsNullOrEmpty(info.TrailImage) && --ticksToNextSmoke < 0 && (state != States.Freefall || info.TrailWhenDeactivated)) { - world.AddFrameEndTask(w => w.Add(new Smoke(w, pos - 3 * move / 2, info.TrailImage, trailPalette, info.TrailSequence))); + world.AddFrameEndTask(w => w.Add(new Smoke(w, pos - 3 * move / 2, () => renderFacing, info.TrailImage, trailPalette, info.TrailSequence))); ticksToNextSmoke = info.TrailInterval; } diff --git a/OpenRA.Mods.Common/Traits/SmokeTrailWhenDamaged.cs b/OpenRA.Mods.Common/Traits/SmokeTrailWhenDamaged.cs index 2733a8cb36..f0ccfd86f2 100644 --- a/OpenRA.Mods.Common/Traits/SmokeTrailWhenDamaged.cs +++ b/OpenRA.Mods.Common/Traits/SmokeTrailWhenDamaged.cs @@ -9,6 +9,7 @@ */ #endregion +using System; using OpenRA.Mods.Common.Effects; using OpenRA.Traits; @@ -31,12 +32,19 @@ namespace OpenRA.Mods.Common.Traits { readonly SmokeTrailWhenDamagedInfo info; readonly BodyOrientation body; + readonly Func getFacing; int ticks; public SmokeTrailWhenDamaged(Actor self, SmokeTrailWhenDamagedInfo info) { this.info = info; body = self.Trait(); + var facing = self.TraitOrDefault(); + + if (facing != null) + getFacing = () => facing.Facing; + else + getFacing = () => 0; } public void Tick(Actor self) @@ -48,7 +56,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, info.Palette, info.Sequence))); + self.World.AddFrameEndTask(w => w.Add(new Smoke(w, pos, getFacing, info.Sprite, info.Palette, info.Sequence))); } ticks = info.Interval;