void SetBatchRenderedTileGID(int column, int row, CCTileGidAndFlags gidAndFlags) { int flattenedIndex = FlattenedTileIndex(column, row); CCTileGidAndFlags prevGid = TileGIDAndFlagsArray[flattenedIndex]; if (gidAndFlags != prevGid) { TileGIDAndFlagsArray[flattenedIndex] = gidAndFlags; if (prevGid.Gid == 0) { var drawBufferManager = GetDrawBufferManagerByGid(gidAndFlags.Gid); CCTileMapVertAndIndexBuffer drawBuffer = drawBufferManager.GetDrawBufferAtIndex(flattenedIndex); drawBuffer.UpdateQuad(flattenedIndex, ref gidAndFlags, true); } else if (gidAndFlags.Gid == 0) { var oldDrawBufferManager = GetDrawBufferManagerByGid(prevGid.Gid); CCTileMapVertAndIndexBuffer drawBuffer = oldDrawBufferManager.GetDrawBufferAtIndex(flattenedIndex); drawBuffer.UpdateQuad(flattenedIndex, ref gidAndFlags, true); } else { var emptyTile = CCTileGidAndFlags.EmptyTile; var oldDrawBufferManager = GetDrawBufferManagerByGid(prevGid.Gid); CCTileMapVertAndIndexBuffer oldDrawBuffer = oldDrawBufferManager.GetDrawBufferAtIndex(flattenedIndex); oldDrawBuffer.UpdateQuad(flattenedIndex, ref emptyTile, true); var drawBufferManager = GetDrawBufferManagerByGid(gidAndFlags.Gid); CCTileMapVertAndIndexBuffer drawBuffer = drawBufferManager.GetDrawBufferAtIndex(flattenedIndex); drawBuffer.UpdateQuad(flattenedIndex, ref gidAndFlags, true); } } }
void UpdateQuadAt(CCTileMapDrawBufferManager drawBufferManager, int tileCoordX, int tileCoordY, bool updateBuffer = true) { int flattenedTileIndex = FlattenedTileIndex(tileCoordX, tileCoordY); CCTileGidAndFlags tileGID = TileGIDAndFlagsArray[flattenedTileIndex]; if (drawBufferManager.TileSetInfo.FirstGid <= tileGID.Gid && drawBufferManager.TileSetInfo.LastGid >= tileGID.Gid || tileGID.Gid == 0) { CCTileMapVertAndIndexBuffer drawBuffer = drawBufferManager.GetDrawBufferAtIndex(flattenedTileIndex); drawBuffer.UpdateQuad(flattenedTileIndex, ref tileGID, updateBuffer); } }