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