Do not render trails under fog by default.

Exposed a boolean for rendering a SpriteEffect under fog. Exposed a setting in LeavesTrails for this boolean, defaulting to false.
This commit is contained in:
Zimmermann Gyula
2016-02-14 15:18:53 +01:00
parent 2debda926a
commit f37e59e116
3 changed files with 14 additions and 4 deletions

View File

@@ -15,16 +15,20 @@ namespace OpenRA.Effects
{
public class SpriteEffect : IEffect
{
readonly World world;
readonly string palette;
readonly Animation anim;
readonly WPos pos;
readonly bool visibleThroughFog;
readonly bool scaleSizeWithZoom;
public SpriteEffect(WPos pos, World world, string image, string sequence, string palette, bool scaleSizeWithZoom = false)
public SpriteEffect(WPos pos, World world, string image, string sequence, string palette, bool visibleThroughFog = false, bool scaleSizeWithZoom = false)
{
this.world = world;
this.pos = pos;
this.palette = palette;
this.scaleSizeWithZoom = scaleSizeWithZoom;
this.visibleThroughFog = visibleThroughFog;
anim = new Animation(world, image);
anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this)));
}
@@ -36,8 +40,11 @@ namespace OpenRA.Effects
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
if (world.FogObscures(pos) && !visibleThroughFog)
return SpriteRenderable.None;
var zoom = scaleSizeWithZoom ? 1f / wr.Viewport.Zoom : 1f;
return anim.Render(pos, WVec.Zero, 0, wr.Palette(palette), zoom);
}
}
}
}