generalize MoveFlash as parametrized SpriteEffect

This commit is contained in:
Matthias Mailänder
2014-06-22 18:02:23 +02:00
parent 4fb38c955b
commit 5cdf0e6a67
3 changed files with 10 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
#region Copyright & License Information
/*
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
@@ -13,15 +13,17 @@ using OpenRA.Graphics;
namespace OpenRA.Effects
{
public class MoveFlash : IEffect
public class SpriteEffect : IEffect
{
string palette;
Animation anim;
WPos pos;
public MoveFlash(WPos pos, World world)
public SpriteEffect(WPos pos, World world, string sprite, string palette)
{
this.pos = pos;
anim = new Animation(world, "moveflsh");
this.palette = palette;
anim = new Animation(world, sprite);
anim.PlayThen("idle", () => world.AddFrameEndTask(w => w.Remove(this)));
}
@@ -32,7 +34,7 @@ namespace OpenRA.Effects
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
return anim.Render(pos, WVec.Zero, 0, wr.Palette("moveflash"), 1f / wr.Viewport.Zoom);
return anim.Render(pos, WVec.Zero, 0, wr.Palette(palette), 1f / wr.Viewport.Zoom);
}
}
}

View File

@@ -212,7 +212,6 @@
<Compile Include="Traits\World\ScreenMap.cs" />
<Compile Include="Traits\World\ActorMap.cs" />
<Compile Include="Widgets\HotkeyEntryWidget.cs" />
<Compile Include="Effects\MoveFlash.cs" />
<Compile Include="Widgets\SpriteWidget.cs" />
<Compile Include="Widgets\SpriteSequenceWidget.cs" />
<Compile Include="Widgets\RGBASpriteWidget.cs" />
@@ -243,6 +242,7 @@
<Compile Include="Sound\SoundDevice.cs" />
<Compile Include="Sound\OpenAlSound.cs" />
<Compile Include="Sound\NullSound.cs" />
<Compile Include="Effects\SpriteEffect.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="FileSystem\D2kSoundResources.cs" />

View File

@@ -160,7 +160,7 @@ namespace OpenRA.Widgets
}
else if (o.TargetLocation != CPos.Zero)
{
world.AddFrameEndTask(w => w.Add(new MoveFlash(worldRenderer.Position(worldRenderer.Viewport.ViewToWorldPx(mi.Location)), world)));
world.AddFrameEndTask(w => w.Add(new SpriteEffect(worldRenderer.Position(worldRenderer.Viewport.ViewToWorldPx(mi.Location)), world, "moveflsh", "moveflash")));
flashed = true;
}
}