public void SetCellValue <T>(Int2 gridCoord, LayerId layerId, T value) { Int2 chunkCoord = GetChunkCoord(gridCoord, chunkWidth, chunkHeight); ChunkData chunk; if (TryGetChunkData(chunkCoord, out chunk)) { int index = GetCellIndex(gridCoord, chunkWidth, chunkHeight); IDataBuffer buffer = chunk.GetBuffer(layerId); // set the new cell value buffer.SetValue(index, value); // mark the chunk and buffer as modified, so that other systems will be aware of the change. chunk.MarkModified(layerId.id, Time.frameCount); } else { // The chunk did not exist, don't set cell value. } }
/// <inheritdoc /> public void SetValue <TOther>(TOther value, params long[] indices) { Data.SetValue((T)Convert.ChangeType(value, Data.Type.UnderlyingType), NDArrayUtils.GetFlatIndex(Shape, Strides, indices)); }