SpriteEffect facing -> WAngle.
This commit is contained in:
@@ -31,14 +31,18 @@ namespace OpenRA.Mods.Common.Effects
|
||||
// Facing is last on these overloads partially for backwards compatibility with previous main ctor revision
|
||||
// and partially because most effects don't need it. The latter is also the reason for placement of 'delay'.
|
||||
public SpriteEffect(WPos pos, World world, string image, string sequence, string palette,
|
||||
bool visibleThroughFog = false, int facing = 0, int delay = 0)
|
||||
: this(() => pos, () => facing, world, image, sequence, palette, visibleThroughFog, delay) { }
|
||||
bool visibleThroughFog = false, int delay = 0)
|
||||
: this(() => pos, () => WAngle.Zero, world, image, sequence, palette, visibleThroughFog, delay) { }
|
||||
|
||||
public SpriteEffect(Actor actor, World world, string image, string sequence, string palette,
|
||||
bool visibleThroughFog = false, int facing = 0, int delay = 0)
|
||||
: this(() => actor.CenterPosition, () => facing, world, image, sequence, palette, visibleThroughFog, delay) { }
|
||||
bool visibleThroughFog = false, int delay = 0)
|
||||
: this(() => actor.CenterPosition, () => WAngle.Zero, world, image, sequence, palette, visibleThroughFog, delay) { }
|
||||
|
||||
public SpriteEffect(Func<WPos> posFunc, Func<int> facingFunc, World world, string image, string sequence, string palette,
|
||||
public SpriteEffect(WPos pos, WAngle facing, World world, string image, string sequence, string palette,
|
||||
bool visibleThroughFog = false, int delay = 0)
|
||||
: this(() => pos, () => facing, world, image, sequence, palette, visibleThroughFog, delay) { }
|
||||
|
||||
public SpriteEffect(Func<WPos> posFunc, Func<WAngle> facingFunc, World world, string image, string sequence, string palette,
|
||||
bool visibleThroughFog = false, int delay = 0)
|
||||
{
|
||||
this.world = world;
|
||||
@@ -48,7 +52,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
this.visibleThroughFog = visibleThroughFog;
|
||||
this.delay = delay;
|
||||
pos = posFunc();
|
||||
anim = new Animation(world, image, () => WAngle.FromFacing(facingFunc()));
|
||||
anim = new Animation(world, image, facingFunc);
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
|
||||
@@ -212,8 +212,8 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
if (!string.IsNullOrEmpty(info.TrailImage) && --smokeTicks < 0)
|
||||
{
|
||||
var delayedPos = WPos.LerpQuadratic(source, target, angle, ticks - info.TrailDelay, length);
|
||||
world.AddFrameEndTask(w => w.Add(new SpriteEffect(delayedPos, w, info.TrailImage, info.TrailSequences.Random(world.SharedRandom),
|
||||
trailPalette, facing: GetEffectiveFacing().Facing)));
|
||||
world.AddFrameEndTask(w => w.Add(new SpriteEffect(delayedPos, GetEffectiveFacing(), w,
|
||||
info.TrailImage, info.TrailSequences.Random(world.SharedRandom), trailPalette)));
|
||||
|
||||
smokeTicks = info.TrailInterval;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
@@ -148,8 +149,11 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
source = args.CurrentSource();
|
||||
|
||||
if (hasLaunchEffect && ticks == 0)
|
||||
world.AddFrameEndTask(w => w.Add(new SpriteEffect(args.CurrentSource, args.CurrentMuzzleFacing, world,
|
||||
{
|
||||
Func<WAngle> getMuzzleFacing = () => WAngle.FromFacing(args.CurrentMuzzleFacing());
|
||||
world.AddFrameEndTask(w => w.Add(new SpriteEffect(args.CurrentSource, getMuzzleFacing, world,
|
||||
info.LaunchEffectImage, info.LaunchEffectSequence, info.LaunchEffectPalette)));
|
||||
}
|
||||
|
||||
// Beam tracks target
|
||||
if (info.TrackTarget && args.GuidedTarget.IsValidFor(args.SourceActor))
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
@@ -857,8 +858,8 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
// Create the sprite trail effect
|
||||
if (!string.IsNullOrEmpty(info.TrailImage) && --ticksToNextSmoke < 0 && (state != States.Freefall || info.TrailWhenDeactivated))
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos - 3 * move / 2, w, info.TrailImage, info.TrailSequences.Random(world.SharedRandom),
|
||||
trailPalette, facing: renderFacing.Facing)));
|
||||
world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos - 3 * move / 2, renderFacing, w,
|
||||
info.TrailImage, info.TrailSequences.Random(world.SharedRandom), trailPalette)));
|
||||
|
||||
ticksToNextSmoke = info.TrailInterval;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Mods.Common.Effects;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -37,19 +39,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
readonly SmokeTrailWhenDamagedInfo info;
|
||||
readonly BodyOrientation body;
|
||||
readonly int getFacing;
|
||||
readonly Func<WAngle> getFacing;
|
||||
int ticks;
|
||||
|
||||
public SmokeTrailWhenDamaged(Actor self, SmokeTrailWhenDamagedInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
body = self.Trait<BodyOrientation>();
|
||||
var facing = self.TraitOrDefault<IFacing>();
|
||||
|
||||
if (facing != null)
|
||||
getFacing = facing.Facing;
|
||||
else
|
||||
getFacing = 0;
|
||||
getFacing = RenderSprites.MakeFacingFunc(self);
|
||||
}
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
@@ -61,7 +58,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 SpriteEffect(pos, w, info.Sprite, info.Sequence, info.Palette, facing: getFacing)));
|
||||
self.World.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, getFacing(), w, info.Sprite, info.Sequence, info.Palette)));
|
||||
}
|
||||
|
||||
ticks = info.Interval;
|
||||
|
||||
Reference in New Issue
Block a user