void FireTileChangedEvent() { if (OnTileChanged != null) { OnTileChanged.Invoke(this); } }
/// <summary> /// Raises the OnTileChanged event. /// </summary> /// <param name="gridId">The ID of the grid that was modified.</param> /// <param name="tileRef">A reference to the new tile.</param> /// <param name="oldTile">The old tile that got replaced.</param> public void RaiseOnTileChanged(int gridId, TileRef tileRef, Tile oldTile) { if (SuppressOnTileChanged) { return; } OnTileChanged?.Invoke(gridId, tileRef, oldTile); }
/// <summary> /// Set a tile. /// </summary> /// <param name="x">Cell X.</param> /// <param name="y">Cell Y.</param> /// <param name="value">New Tile value.</param> public void SetTile(int x, int y, T value) { if (!CellIsValid(x, y)) { return; } if (!updateAlways && EqualityComparer <T> .Default.Equals(tiles[x, y], value)) { return; } T previousValue = tiles[x, y]; tiles[x, y] = value; OnTileChanged?.Invoke(this, new TileChangedEventArgs { x = x, y = y, value = value, previousValue = previousValue }); }