Merge pull request #7057 from pchote/celllayerupdates

Improve radar rendering performance
This commit is contained in:
Chris Forbes
2014-12-08 14:09:09 +13:00
3 changed files with 161 additions and 39 deletions

View File

@@ -20,6 +20,8 @@ namespace OpenRA
{
public readonly Size Size;
public readonly TileShape Shape;
public event Action<CPos> CellEntryChanged = null;
readonly T[] entries;
public CellLayer(Map map)
@@ -48,15 +50,35 @@ namespace OpenRA
/// <summary>Gets or sets the <see cref="OpenRA.CellLayer"/> using cell coordinates</summary>
public T this[CPos cell]
{
get { return entries[Index(cell)]; }
set { entries[Index(cell)] = value; }
get
{
return entries[Index(cell)];
}
set
{
entries[Index(cell)] = value;
if (CellEntryChanged != null)
CellEntryChanged(cell);
}
}
/// <summary>Gets or sets the layer contents using raw map coordinates (not CPos!)</summary>
public T this[int u, int v]
{
get { return entries[Index(u, v)]; }
set { entries[Index(u, v)] = value; }
get
{
return entries[Index(u, v)];
}
set
{
entries[Index(u, v)] = value;
if (CellEntryChanged != null)
CellEntryChanged(Map.MapToCell(Shape, new CPos(u, v)));
}
}
/// <summary>Clears the layer contents with a known value</summary>

View File

@@ -31,6 +31,23 @@ namespace OpenRA.Traits
readonly CellLayer<short> generatedShroudCount;
readonly CellLayer<bool> explored;
public event Action<CPos> CellEntryChanged
{
add
{
visibleCount.CellEntryChanged += value;
generatedShroudCount.CellEntryChanged += value;
explored.CellEntryChanged += value;
}
remove
{
visibleCount.CellEntryChanged -= value;
generatedShroudCount.CellEntryChanged -= value;
explored.CellEntryChanged -= value;
}
}
readonly Lazy<IFogVisibilityModifier[]> fogVisibilities;
// Cache of visibility that was added, so no matter what crazy trait code does, it