generalize MoveFlash as parametrized SpriteEffect
This commit is contained in:
@@ -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
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
@@ -13,15 +13,17 @@ using OpenRA.Graphics;
|
|||||||
|
|
||||||
namespace OpenRA.Effects
|
namespace OpenRA.Effects
|
||||||
{
|
{
|
||||||
public class MoveFlash : IEffect
|
public class SpriteEffect : IEffect
|
||||||
{
|
{
|
||||||
|
string palette;
|
||||||
Animation anim;
|
Animation anim;
|
||||||
WPos pos;
|
WPos pos;
|
||||||
|
|
||||||
public MoveFlash(WPos pos, World world)
|
public SpriteEffect(WPos pos, World world, string sprite, string palette)
|
||||||
{
|
{
|
||||||
this.pos = pos;
|
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)));
|
anim.PlayThen("idle", () => world.AddFrameEndTask(w => w.Remove(this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +34,7 @@ namespace OpenRA.Effects
|
|||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,7 +212,6 @@
|
|||||||
<Compile Include="Traits\World\ScreenMap.cs" />
|
<Compile Include="Traits\World\ScreenMap.cs" />
|
||||||
<Compile Include="Traits\World\ActorMap.cs" />
|
<Compile Include="Traits\World\ActorMap.cs" />
|
||||||
<Compile Include="Widgets\HotkeyEntryWidget.cs" />
|
<Compile Include="Widgets\HotkeyEntryWidget.cs" />
|
||||||
<Compile Include="Effects\MoveFlash.cs" />
|
|
||||||
<Compile Include="Widgets\SpriteWidget.cs" />
|
<Compile Include="Widgets\SpriteWidget.cs" />
|
||||||
<Compile Include="Widgets\SpriteSequenceWidget.cs" />
|
<Compile Include="Widgets\SpriteSequenceWidget.cs" />
|
||||||
<Compile Include="Widgets\RGBASpriteWidget.cs" />
|
<Compile Include="Widgets\RGBASpriteWidget.cs" />
|
||||||
@@ -243,6 +242,7 @@
|
|||||||
<Compile Include="Sound\SoundDevice.cs" />
|
<Compile Include="Sound\SoundDevice.cs" />
|
||||||
<Compile Include="Sound\OpenAlSound.cs" />
|
<Compile Include="Sound\OpenAlSound.cs" />
|
||||||
<Compile Include="Sound\NullSound.cs" />
|
<Compile Include="Sound\NullSound.cs" />
|
||||||
|
<Compile Include="Effects\SpriteEffect.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="FileSystem\D2kSoundResources.cs" />
|
<Compile Include="FileSystem\D2kSoundResources.cs" />
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ namespace OpenRA.Widgets
|
|||||||
}
|
}
|
||||||
else if (o.TargetLocation != CPos.Zero)
|
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;
|
flashed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user