Adopted Span for the setTiles wrapper in the library to adapt to Swift 6.4.
This commit is contained in:
@@ -48,14 +48,22 @@ extension Graphics {
|
||||
|
||||
/// Fills the tilemap with `indexes`, `rowWidth` tiles per row. The
|
||||
/// tilemap is resized to fit.
|
||||
public func setTiles(_ indexes: [UInt16], rowWidth: Int) {
|
||||
var indexes = indexes
|
||||
indexes.withUnsafeMutableBufferPointer { buffer in
|
||||
tilemapAPI.pointee.setTiles.unsafelyUnwrapped(pointer, buffer.baseAddress,
|
||||
Int32(buffer.count), Int32(rowWidth))
|
||||
public func setTiles(_ indexes: Span<UInt16>, rowWidth: Int) {
|
||||
indexes.withUnsafeBufferPointer { buffer in
|
||||
// The C API takes a non-const pointer but only reads the
|
||||
// indexes, copying them into the tilemap.
|
||||
tilemapAPI.pointee.setTiles.unsafelyUnwrapped(
|
||||
pointer, UnsafeMutablePointer(mutating: buffer.baseAddress),
|
||||
Int32(buffer.count), Int32(rowWidth))
|
||||
}
|
||||
}
|
||||
|
||||
/// Fills the tilemap with `indexes`, `rowWidth` tiles per row. The
|
||||
/// tilemap is resized to fit.
|
||||
public func setTiles(_ indexes: [UInt16], rowWidth: Int) {
|
||||
indexes.withUnsafeBufferPointer { setTiles($0.span, rowWidth: rowWidth) }
|
||||
}
|
||||
|
||||
/// Sets the tile index at position (x, y).
|
||||
public func setTile(x: Int, y: Int, index: UInt16) {
|
||||
tilemapAPI.pointee.setTileAtPosition.unsafelyUnwrapped(pointer, Int32(x), Int32(y), index)
|
||||
|
||||
Reference in New Issue
Block a user