From e064593961cede36fe72a6df7f6697750adc85d3 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Tue, 2 Dec 2014 18:14:52 +1300 Subject: [PATCH] Add a CellEntryChanged event to CellLayer. --- OpenRA.Game/Map/CellLayer.cs | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Map/CellLayer.cs b/OpenRA.Game/Map/CellLayer.cs index 9b18333442..a78d803455 100644 --- a/OpenRA.Game/Map/CellLayer.cs +++ b/OpenRA.Game/Map/CellLayer.cs @@ -20,6 +20,8 @@ namespace OpenRA { public readonly Size Size; public readonly TileShape Shape; + public event Action CellEntryChanged = null; + readonly T[] entries; public CellLayer(Map map) @@ -48,15 +50,35 @@ namespace OpenRA /// Gets or sets the using cell coordinates 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); + } } /// Gets or sets the layer contents using raw map coordinates (not CPos!) 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))); + } } /// Clears the layer contents with a known value