Merge pull request #5851 from RoosterDragon/shroud-perf

Speed up shroud checks
This commit is contained in:
Paul Chote
2014-07-23 11:02:27 +12:00
9 changed files with 325 additions and 207 deletions

View File

@@ -10,7 +10,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Effects;
using OpenRA.FileFormats;
@@ -25,6 +24,7 @@ namespace OpenRA
{
public class World
{
static readonly Func<CPos, bool> FalsePredicate = cell => false;
internal readonly TraitDictionary traitDict = new TraitDictionary();
readonly HashSet<Actor> actors = new HashSet<Actor>();
readonly List<IEffect> effects = new List<IEffect>();
@@ -54,6 +54,24 @@ namespace OpenRA
public bool FogObscures(CPos p) { return RenderPlayer != null && !RenderPlayer.Shroud.IsVisible(p); }
public bool ShroudObscures(Actor a) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(a); }
public bool ShroudObscures(CPos p) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(p); }
public Func<CPos, bool> FogObscuresTest(CellRegion region)
{
var rp = RenderPlayer;
if (rp == null)
return FalsePredicate;
var predicate = rp.Shroud.IsVisibleTest(region);
return cell => !predicate(cell);
}
public Func<CPos, bool> ShroudObscuresTest(CellRegion region)
{
var rp = RenderPlayer;
if (rp == null)
return FalsePredicate;
var predicate = rp.Shroud.IsExploredTest(region);
return cell => !predicate(cell);
}
public bool IsReplay
{