From 3994e1eec948150b3b5d1d3c8fbda554603e91ef Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 7 Jun 2015 19:28:39 +0100 Subject: [PATCH] Use FogObscures(WPos). --- OpenRA.Mods.Common/Effects/Bullet.cs | 3 +-- OpenRA.Mods.Common/Effects/Corpse.cs | 4 +--- OpenRA.Mods.Common/Effects/CrateEffect.cs | 2 +- OpenRA.Mods.Common/Effects/Explosion.cs | 4 +--- OpenRA.Mods.Common/Effects/FloatingText.cs | 2 +- OpenRA.Mods.Common/Effects/GravityBomb.cs | 3 +-- OpenRA.Mods.Common/Effects/LaserZap.cs | 4 ++-- OpenRA.Mods.Common/Effects/Missile.cs | 2 +- OpenRA.Mods.Common/Effects/Smoke.cs | 4 +--- OpenRA.Mods.Common/Graphics/ContrailRenderable.cs | 5 +---- OpenRA.Mods.RA/Graphics/TeslaZapRenderable.cs | 4 ++-- 11 files changed, 13 insertions(+), 24 deletions(-) diff --git a/OpenRA.Mods.Common/Effects/Bullet.cs b/OpenRA.Mods.Common/Effects/Bullet.cs index 4421c23f36..2a80aaca12 100644 --- a/OpenRA.Mods.Common/Effects/Bullet.cs +++ b/OpenRA.Mods.Common/Effects/Bullet.cs @@ -158,8 +158,7 @@ namespace OpenRA.Mods.Common.Effects if (anim == null || ticks >= length) yield break; - var cell = wr.World.Map.CellContaining(pos); - if (!args.SourceActor.World.FogObscures(cell)) + if (!args.SourceActor.World.FogObscures(pos)) { if (info.Shadow) { diff --git a/OpenRA.Mods.Common/Effects/Corpse.cs b/OpenRA.Mods.Common/Effects/Corpse.cs index ef2170ffb1..8e783b1538 100644 --- a/OpenRA.Mods.Common/Effects/Corpse.cs +++ b/OpenRA.Mods.Common/Effects/Corpse.cs @@ -18,7 +18,6 @@ namespace OpenRA.Mods.Common.Effects { readonly World world; readonly WPos pos; - readonly CPos cell; readonly string paletteName; readonly Animation anim; @@ -26,7 +25,6 @@ namespace OpenRA.Mods.Common.Effects { this.world = world; this.pos = pos; - this.cell = world.Map.CellContaining(pos); this.paletteName = paletteName; anim = new Animation(world, image); anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this))); @@ -36,7 +34,7 @@ namespace OpenRA.Mods.Common.Effects public IEnumerable Render(WorldRenderer wr) { - if (world.FogObscures(cell)) + if (world.FogObscures(pos)) return SpriteRenderable.None; return anim.Render(pos, wr.Palette(paletteName)); diff --git a/OpenRA.Mods.Common/Effects/CrateEffect.cs b/OpenRA.Mods.Common/Effects/CrateEffect.cs index 7f5ce2e376..53f1c5043d 100644 --- a/OpenRA.Mods.Common/Effects/CrateEffect.cs +++ b/OpenRA.Mods.Common/Effects/CrateEffect.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Effects public IEnumerable Render(WorldRenderer wr) { - if (!a.IsInWorld || a.World.FogObscures(a.Location)) + if (!a.IsInWorld || a.World.FogObscures(a.CenterPosition)) return SpriteRenderable.None; return anim.Render(a.CenterPosition, wr.Palette(palette)); diff --git a/OpenRA.Mods.Common/Effects/Explosion.cs b/OpenRA.Mods.Common/Effects/Explosion.cs index 4024ec6285..3a56e672e2 100644 --- a/OpenRA.Mods.Common/Effects/Explosion.cs +++ b/OpenRA.Mods.Common/Effects/Explosion.cs @@ -20,13 +20,11 @@ namespace OpenRA.Mods.Common.Effects readonly string palette; readonly Animation anim; WPos pos; - CPos cell; public Explosion(World world, WPos pos, string sequence, string palette) { this.world = world; this.pos = pos; - this.cell = world.Map.CellContaining(pos); this.palette = palette; anim = new Animation(world, "explosion"); anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this))); @@ -36,7 +34,7 @@ namespace OpenRA.Mods.Common.Effects public IEnumerable Render(WorldRenderer wr) { - if (world.FogObscures(cell)) + if (world.FogObscures(pos)) return SpriteRenderable.None; return anim.Render(pos, wr.Palette(palette)); diff --git a/OpenRA.Mods.Common/Effects/FloatingText.cs b/OpenRA.Mods.Common/Effects/FloatingText.cs index a8f9a1bb7c..ed1c97c690 100644 --- a/OpenRA.Mods.Common/Effects/FloatingText.cs +++ b/OpenRA.Mods.Common/Effects/FloatingText.cs @@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Effects public IEnumerable Render(WorldRenderer wr) { - if (wr.World.FogObscures(wr.World.Map.CellContaining(pos))) + if (wr.World.FogObscures(pos)) yield break; yield return new TextRenderable(font, pos, 0, color, text); diff --git a/OpenRA.Mods.Common/Effects/GravityBomb.cs b/OpenRA.Mods.Common/Effects/GravityBomb.cs index 66b7ef5dc9..19dc15f7ba 100644 --- a/OpenRA.Mods.Common/Effects/GravityBomb.cs +++ b/OpenRA.Mods.Common/Effects/GravityBomb.cs @@ -78,8 +78,7 @@ namespace OpenRA.Mods.Common.Effects public IEnumerable Render(WorldRenderer wr) { - var cell = wr.World.Map.CellContaining(pos); - if (!args.SourceActor.World.FogObscures(cell)) + if (!args.SourceActor.World.FogObscures(pos)) { if (info.Shadow) { diff --git a/OpenRA.Mods.Common/Effects/LaserZap.cs b/OpenRA.Mods.Common/Effects/LaserZap.cs index a5208e57b7..c7cab338fb 100644 --- a/OpenRA.Mods.Common/Effects/LaserZap.cs +++ b/OpenRA.Mods.Common/Effects/LaserZap.cs @@ -85,8 +85,8 @@ namespace OpenRA.Mods.Common.Effects public IEnumerable Render(WorldRenderer wr) { - if (wr.World.FogObscures(wr.World.Map.CellContaining(target)) && - wr.World.FogObscures(wr.World.Map.CellContaining(args.Source))) + if (wr.World.FogObscures(target) && + wr.World.FogObscures(args.Source)) yield break; if (ticks < info.BeamDuration) diff --git a/OpenRA.Mods.Common/Effects/Missile.cs b/OpenRA.Mods.Common/Effects/Missile.cs index be726e5cfc..92dece6c26 100644 --- a/OpenRA.Mods.Common/Effects/Missile.cs +++ b/OpenRA.Mods.Common/Effects/Missile.cs @@ -210,7 +210,7 @@ namespace OpenRA.Mods.Common.Effects if (info.ContrailLength > 0) yield return contrail; - if (!args.SourceActor.World.FogObscures(wr.World.Map.CellContaining(pos))) + if (!args.SourceActor.World.FogObscures(pos)) { if (info.Shadow) { diff --git a/OpenRA.Mods.Common/Effects/Smoke.cs b/OpenRA.Mods.Common/Effects/Smoke.cs index 519295416e..65c4cec7ae 100644 --- a/OpenRA.Mods.Common/Effects/Smoke.cs +++ b/OpenRA.Mods.Common/Effects/Smoke.cs @@ -18,7 +18,6 @@ namespace OpenRA.Mods.Common.Effects { readonly World world; readonly WPos pos; - readonly CPos cell; readonly Animation anim; readonly string palette; @@ -26,7 +25,6 @@ namespace OpenRA.Mods.Common.Effects { this.world = world; this.pos = pos; - this.cell = world.Map.CellContaining(pos); this.palette = palette; anim = new Animation(world, trail); @@ -38,7 +36,7 @@ namespace OpenRA.Mods.Common.Effects public IEnumerable Render(WorldRenderer wr) { - if (world.FogObscures(cell)) + if (world.FogObscures(pos)) return SpriteRenderable.None; return anim.Render(pos, wr.Palette(palette)); diff --git a/OpenRA.Mods.Common/Graphics/ContrailRenderable.cs b/OpenRA.Mods.Common/Graphics/ContrailRenderable.cs index d1075be2cb..156792be57 100644 --- a/OpenRA.Mods.Common/Graphics/ContrailRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/ContrailRenderable.cs @@ -65,20 +65,17 @@ namespace OpenRA.Mods.Common.Graphics // Start of the first line segment is the tail of the list - don't smooth it. var curPos = trail[Index(next - skip - 1)]; - var curCell = wr.World.Map.CellContaining(curPos); var curColor = color; for (var i = 0; i < length - skip - 4; i++) { var j = next - skip - i - 2; var nextPos = Average(trail[Index(j)], trail[Index(j - 1)], trail[Index(j - 2)], trail[Index(j - 3)]); - var nextCell = wr.World.Map.CellContaining(nextPos); var nextColor = Exts.ColorLerp(i * 1f / (length - 4), color, Color.Transparent); - if (!world.FogObscures(curCell) && !world.FogObscures(nextCell)) + if (!world.FogObscures(curPos) && !world.FogObscures(nextPos)) wlr.DrawLine(wr.ScreenPosition(curPos), wr.ScreenPosition(nextPos), curColor, nextColor); curPos = nextPos; - curCell = nextCell; curColor = nextColor; } diff --git a/OpenRA.Mods.RA/Graphics/TeslaZapRenderable.cs b/OpenRA.Mods.RA/Graphics/TeslaZapRenderable.cs index ec9d73ffb4..06baa89c90 100644 --- a/OpenRA.Mods.RA/Graphics/TeslaZapRenderable.cs +++ b/OpenRA.Mods.RA/Graphics/TeslaZapRenderable.cs @@ -70,8 +70,8 @@ namespace OpenRA.Mods.RA.Graphics public void RenderDebugGeometry(WorldRenderer wr) { } public void Render(WorldRenderer wr) { - if (wr.World.FogObscures(wr.World.Map.CellContaining(pos)) && - wr.World.FogObscures(wr.World.Map.CellContaining(pos + length))) + if (wr.World.FogObscures(pos) && + wr.World.FogObscures(pos + length)) return; if (!cache.Any() || length != cachedLength || pos != cachedPos)