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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user