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
|
// 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'.
|
// 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,
|
public SpriteEffect(WPos pos, World world, string image, string sequence, string palette,
|
||||||
bool visibleThroughFog = false, int facing = 0, int delay = 0)
|
bool visibleThroughFog = false, int delay = 0)
|
||||||
: this(() => pos, () => facing, world, image, sequence, palette, visibleThroughFog, delay) { }
|
: this(() => pos, () => WAngle.Zero, world, image, sequence, palette, visibleThroughFog, delay) { }
|
||||||
|
|
||||||
public SpriteEffect(Actor actor, World world, string image, string sequence, string palette,
|
public SpriteEffect(Actor actor, World world, string image, string sequence, string palette,
|
||||||
bool visibleThroughFog = false, int facing = 0, int delay = 0)
|
bool visibleThroughFog = false, int delay = 0)
|
||||||
: this(() => actor.CenterPosition, () => facing, world, image, sequence, palette, visibleThroughFog, delay) { }
|
: 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)
|
bool visibleThroughFog = false, int delay = 0)
|
||||||
{
|
{
|
||||||
this.world = world;
|
this.world = world;
|
||||||
@@ -48,7 +52,7 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
this.visibleThroughFog = visibleThroughFog;
|
this.visibleThroughFog = visibleThroughFog;
|
||||||
this.delay = delay;
|
this.delay = delay;
|
||||||
pos = posFunc();
|
pos = posFunc();
|
||||||
anim = new Animation(world, image, () => WAngle.FromFacing(facingFunc()));
|
anim = new Animation(world, image, facingFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(World world)
|
public void Tick(World world)
|
||||||
|
|||||||
@@ -212,8 +212,8 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
if (!string.IsNullOrEmpty(info.TrailImage) && --smokeTicks < 0)
|
if (!string.IsNullOrEmpty(info.TrailImage) && --smokeTicks < 0)
|
||||||
{
|
{
|
||||||
var delayedPos = WPos.LerpQuadratic(source, target, angle, ticks - info.TrailDelay, length);
|
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),
|
world.AddFrameEndTask(w => w.Add(new SpriteEffect(delayedPos, GetEffectiveFacing(), w,
|
||||||
trailPalette, facing: GetEffectiveFacing().Facing)));
|
info.TrailImage, info.TrailSequences.Random(world.SharedRandom), trailPalette)));
|
||||||
|
|
||||||
smokeTicks = info.TrailInterval;
|
smokeTicks = info.TrailInterval;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
@@ -148,8 +149,11 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
source = args.CurrentSource();
|
source = args.CurrentSource();
|
||||||
|
|
||||||
if (hasLaunchEffect && ticks == 0)
|
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)));
|
info.LaunchEffectImage, info.LaunchEffectSequence, info.LaunchEffectPalette)));
|
||||||
|
}
|
||||||
|
|
||||||
// Beam tracks target
|
// Beam tracks target
|
||||||
if (info.TrackTarget && args.GuidedTarget.IsValidFor(args.SourceActor))
|
if (info.TrackTarget && args.GuidedTarget.IsValidFor(args.SourceActor))
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
@@ -857,8 +858,8 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
// Create the sprite trail effect
|
// Create the sprite trail effect
|
||||||
if (!string.IsNullOrEmpty(info.TrailImage) && --ticksToNextSmoke < 0 && (state != States.Freefall || info.TrailWhenDeactivated))
|
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),
|
world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos - 3 * move / 2, renderFacing, w,
|
||||||
trailPalette, facing: renderFacing.Facing)));
|
info.TrailImage, info.TrailSequences.Random(world.SharedRandom), trailPalette)));
|
||||||
|
|
||||||
ticksToNextSmoke = info.TrailInterval;
|
ticksToNextSmoke = info.TrailInterval;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using OpenRA.Mods.Common.Effects;
|
using OpenRA.Mods.Common.Effects;
|
||||||
|
using OpenRA.Mods.Common.Traits.Render;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
@@ -37,19 +39,14 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
readonly SmokeTrailWhenDamagedInfo info;
|
readonly SmokeTrailWhenDamagedInfo info;
|
||||||
readonly BodyOrientation body;
|
readonly BodyOrientation body;
|
||||||
readonly int getFacing;
|
readonly Func<WAngle> getFacing;
|
||||||
int ticks;
|
int ticks;
|
||||||
|
|
||||||
public SmokeTrailWhenDamaged(Actor self, SmokeTrailWhenDamagedInfo info)
|
public SmokeTrailWhenDamaged(Actor self, SmokeTrailWhenDamagedInfo info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
body = self.Trait<BodyOrientation>();
|
body = self.Trait<BodyOrientation>();
|
||||||
var facing = self.TraitOrDefault<IFacing>();
|
getFacing = RenderSprites.MakeFacingFunc(self);
|
||||||
|
|
||||||
if (facing != null)
|
|
||||||
getFacing = facing.Facing;
|
|
||||||
else
|
|
||||||
getFacing = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ITick.Tick(Actor 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 offset = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation));
|
||||||
var pos = position + body.LocalToWorld(offset);
|
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;
|
ticks = info.Interval;
|
||||||
|
|||||||
Reference in New Issue
Block a user