objc2_sprite_kit/generated/SKTileMapNode.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9#[cfg(feature = "objc2-core-foundation")]
10use objc2_core_foundation::*;
11use objc2_foundation::*;
12
13use crate::*;
14
15extern_class!(
16 /// A SpriteKit node used to render a 2D array of textured sprites. Uses SKTileSet to determine what textures it can use to render. Separate tile map nodes can be layered on top of one another to achieve various effects, such as parallax scrolling.
17 ///
18 /// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/sktilemapnode?language=objc)
19 #[unsafe(super(SKNode, NSResponder, NSObject))]
20 #[derive(Debug, PartialEq, Eq, Hash)]
21 #[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
22 #[cfg(target_os = "macos")]
23 pub struct SKTileMapNode;
24);
25
26#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
27#[cfg(target_os = "macos")]
28unsafe impl NSCoding for SKTileMapNode {}
29
30#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
31#[cfg(target_os = "macos")]
32unsafe impl NSCopying for SKTileMapNode {}
33
34#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
35#[cfg(target_os = "macos")]
36unsafe impl CopyingHelper for SKTileMapNode {
37 type Result = Self;
38}
39
40#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
41#[cfg(target_os = "macos")]
42unsafe impl NSObjectProtocol for SKTileMapNode {}
43
44#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
45#[cfg(target_os = "macos")]
46unsafe impl NSSecureCoding for SKTileMapNode {}
47
48#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
49#[cfg(target_os = "macos")]
50impl SKTileMapNode {
51 extern_methods!(
52 #[cfg(all(feature = "SKTileSet", feature = "objc2-core-foundation"))]
53 /// Create a tile map node with the specified tile set and dimensions. The tiles of the map will be empty, equivalent to the nil tile definition/group.
54 ///
55 /// Parameter `tileSet`: the tile set that is used to render the tiles
56 ///
57 /// Parameter `columns`: the number of columns in the map that can hold tiles
58 ///
59 /// Parameter `rows`: the number of rows in the map that can hold tiles
60 ///
61 /// Parameter `tileSize`: the size of each tile in points
62 #[unsafe(method(tileMapNodeWithTileSet:columns:rows:tileSize:))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn tileMapNodeWithTileSet_columns_rows_tileSize(
65 tile_set: &SKTileSet,
66 columns: NSUInteger,
67 rows: NSUInteger,
68 tile_size: CGSize,
69 mtm: MainThreadMarker,
70 ) -> Retained<Self>;
71
72 #[cfg(all(feature = "SKTileSet", feature = "objc2-core-foundation"))]
73 /// Create a tile map node with the specified tile set and dimensions, and fill it with the specified tile group.
74 ///
75 /// Parameter `tileSet`: the tile set that is used to render the tiles
76 ///
77 /// Parameter `columns`: the number of columns in the map that can hold tiles
78 ///
79 /// Parameter `rows`: the number of rows in the map that can hold tiles
80 ///
81 /// Parameter `tileSize`: the size of each tile in points
82 ///
83 /// Parameter `tileGroup`: the tile group we wish to fill the tile map with
84 #[unsafe(method(tileMapNodeWithTileSet:columns:rows:tileSize:fillWithTileGroup:))]
85 #[unsafe(method_family = none)]
86 pub unsafe fn tileMapNodeWithTileSet_columns_rows_tileSize_fillWithTileGroup(
87 tile_set: &SKTileSet,
88 columns: NSUInteger,
89 rows: NSUInteger,
90 tile_size: CGSize,
91 tile_group: &SKTileGroup,
92 mtm: MainThreadMarker,
93 ) -> Retained<Self>;
94
95 #[cfg(all(feature = "SKTileSet", feature = "objc2-core-foundation"))]
96 /// Create a tile map node with the specified tile set and dimensions, and fill it with a specific layout of tile groups that belong to the provided tile set. The tileGroupLayout array should match the dimensions of the tile map (i.e., the number of elements should be equal to columns * rows). Index 0 of the array maps to column 0, row 0 of the tile map. Index 1 is column 1, row 0, and so on, wrapping around to the next row once the index passes the number of columns in the tile map. If the array has fewer elements than the number of tiles in the map, the remaining tiles are initialized with the nil tile group. If the array has more elements than the number of tiles in the map, the extra tile groups are ignored.
97 ///
98 /// Parameter `tileSet`: the tile set that is used to render the tiles
99 ///
100 /// Parameter `columns`: the number of columns in the map that can hold tiles
101 ///
102 /// Parameter `rows`: the number of rows in the map that can hold tiles
103 ///
104 /// Parameter `tileSize`: the size of each tile in points
105 ///
106 /// Parameter `tileGroupLayout`: an array of tile groups that we want to use to fill the tile map
107 #[unsafe(method(tileMapNodeWithTileSet:columns:rows:tileSize:tileGroupLayout:))]
108 #[unsafe(method_family = none)]
109 pub unsafe fn tileMapNodeWithTileSet_columns_rows_tileSize_tileGroupLayout(
110 tile_set: &SKTileSet,
111 columns: NSUInteger,
112 rows: NSUInteger,
113 tile_size: CGSize,
114 tile_group_layout: &NSArray<SKTileGroup>,
115 mtm: MainThreadMarker,
116 ) -> Retained<Self>;
117
118 #[cfg(all(feature = "SKTileSet", feature = "objc2-core-foundation"))]
119 /// Initialize a tile map node with the specified tile set and dimensions. The tiles of the map will be empty, equivalent to the nil tile definition/group.
120 ///
121 /// Parameter `tileSet`: the tile set that is used to render the tiles
122 ///
123 /// Parameter `columns`: the number of columns in the map that can hold tiles
124 ///
125 /// Parameter `rows`: the number of rows in the map that can hold tiles
126 ///
127 /// Parameter `tileSize`: the size of each tile in points
128 #[unsafe(method(initWithTileSet:columns:rows:tileSize:))]
129 #[unsafe(method_family = init)]
130 pub unsafe fn initWithTileSet_columns_rows_tileSize(
131 this: Allocated<Self>,
132 tile_set: &SKTileSet,
133 columns: NSUInteger,
134 rows: NSUInteger,
135 tile_size: CGSize,
136 ) -> Retained<Self>;
137
138 #[cfg(all(feature = "SKTileSet", feature = "objc2-core-foundation"))]
139 /// Initialize a tile map node with the specified tile set and dimensions, and fill it with the specified tile group.
140 ///
141 /// Parameter `tileSet`: the tile set that is used to render the tiles
142 ///
143 /// Parameter `columns`: the number of columns in the map that can hold tiles
144 ///
145 /// Parameter `rows`: the number of rows in the map that can hold tiles
146 ///
147 /// Parameter `tileSize`: the size of each tile in points
148 ///
149 /// Parameter `tileGroup`: the tile group we wish to fill the tile map with
150 #[unsafe(method(initWithTileSet:columns:rows:tileSize:fillWithTileGroup:))]
151 #[unsafe(method_family = init)]
152 pub unsafe fn initWithTileSet_columns_rows_tileSize_fillWithTileGroup(
153 this: Allocated<Self>,
154 tile_set: &SKTileSet,
155 columns: NSUInteger,
156 rows: NSUInteger,
157 tile_size: CGSize,
158 tile_group: &SKTileGroup,
159 ) -> Retained<Self>;
160
161 #[cfg(all(feature = "SKTileSet", feature = "objc2-core-foundation"))]
162 /// Initialize a tile map node with the specified tile set and dimensions, and fill it with a specific layout of tile groups that belong to the provided tile set. The tileGroupLayout array should match the dimensions of the tile map (i.e., the number of elements should be equal to columns * rows). Index 0 of the array maps to column 0, row 0 of the tile map. Index 1 is column 1, row 0, and so on, wrapping around to the next row once the index passes the number of columns in the tile map. If the array has fewer elements than the number of tiles in the map, the remaining tiles are initialized with the nil tile group. If the array has more elements than the number of tiles in the map, the extra tile groups are ignored.
163 ///
164 /// Parameter `tileSet`: the tile set that is used to render the tiles
165 ///
166 /// Parameter `columns`: the number of columns in the map that can hold tiles
167 ///
168 /// Parameter `rows`: the number of rows in the map that can hold tiles
169 ///
170 /// Parameter `tileSize`: the size of each tile in points
171 ///
172 /// Parameter `tileGroupLayout`: an array of tile groups that we want to use to fill the tile map
173 #[unsafe(method(initWithTileSet:columns:rows:tileSize:tileGroupLayout:))]
174 #[unsafe(method_family = init)]
175 pub unsafe fn initWithTileSet_columns_rows_tileSize_tileGroupLayout(
176 this: Allocated<Self>,
177 tile_set: &SKTileSet,
178 columns: NSUInteger,
179 rows: NSUInteger,
180 tile_size: CGSize,
181 tile_group_layout: &NSArray<SKTileGroup>,
182 ) -> Retained<Self>;
183
184 /// The number of columns in the tile map.
185 #[unsafe(method(numberOfColumns))]
186 #[unsafe(method_family = none)]
187 pub unsafe fn numberOfColumns(&self) -> NSUInteger;
188
189 /// Setter for [`numberOfColumns`][Self::numberOfColumns].
190 #[unsafe(method(setNumberOfColumns:))]
191 #[unsafe(method_family = none)]
192 pub unsafe fn setNumberOfColumns(&self, number_of_columns: NSUInteger);
193
194 /// The number of rows in the tile map.
195 #[unsafe(method(numberOfRows))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn numberOfRows(&self) -> NSUInteger;
198
199 /// Setter for [`numberOfRows`][Self::numberOfRows].
200 #[unsafe(method(setNumberOfRows:))]
201 #[unsafe(method_family = none)]
202 pub unsafe fn setNumberOfRows(&self, number_of_rows: NSUInteger);
203
204 #[cfg(feature = "objc2-core-foundation")]
205 /// The size of each tile in the map.
206 #[unsafe(method(tileSize))]
207 #[unsafe(method_family = none)]
208 pub unsafe fn tileSize(&self) -> CGSize;
209
210 #[cfg(feature = "objc2-core-foundation")]
211 /// Setter for [`tileSize`][Self::tileSize].
212 #[unsafe(method(setTileSize:))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn setTileSize(&self, tile_size: CGSize);
215
216 #[cfg(feature = "objc2-core-foundation")]
217 /// The size of the tile map. This is dependent on the tileSize, the number of columns and rows in the map, and the tile set type.
218 #[unsafe(method(mapSize))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn mapSize(&self) -> CGSize;
221
222 #[cfg(feature = "SKTileSet")]
223 /// The tile set being used by this tile map.
224 #[unsafe(method(tileSet))]
225 #[unsafe(method_family = none)]
226 pub unsafe fn tileSet(&self) -> Retained<SKTileSet>;
227
228 #[cfg(feature = "SKTileSet")]
229 /// Setter for [`tileSet`][Self::tileSet].
230 #[unsafe(method(setTileSet:))]
231 #[unsafe(method_family = none)]
232 pub unsafe fn setTileSet(&self, tile_set: &SKTileSet);
233
234 #[cfg(feature = "objc2-core-foundation")]
235 /// Controls the blending between the texture and the tile map color. The valid interval of values is from 0.0 up to and including 1.0. A value above or below that interval is clamped to the minimum (0.0) if below or the maximum (1.0) if above.
236 #[unsafe(method(colorBlendFactor))]
237 #[unsafe(method_family = none)]
238 pub unsafe fn colorBlendFactor(&self) -> CGFloat;
239
240 #[cfg(feature = "objc2-core-foundation")]
241 /// Setter for [`colorBlendFactor`][Self::colorBlendFactor].
242 #[unsafe(method(setColorBlendFactor:))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn setColorBlendFactor(&self, color_blend_factor: CGFloat);
245
246 /// Base color for the tile map (If no texture is present, the color still is drawn).
247 #[unsafe(method(color))]
248 #[unsafe(method_family = none)]
249 pub unsafe fn color(&self) -> Retained<NSColor>;
250
251 /// Setter for [`color`][Self::color].
252 #[unsafe(method(setColor:))]
253 #[unsafe(method_family = none)]
254 pub unsafe fn setColor(&self, color: &NSColor);
255
256 /// Sets the blend mode to use when composing the tile map with the final framebuffer.
257 ///
258 /// See: SKNode.SKBlendMode
259 #[unsafe(method(blendMode))]
260 #[unsafe(method_family = none)]
261 pub unsafe fn blendMode(&self) -> SKBlendMode;
262
263 /// Setter for [`blendMode`][Self::blendMode].
264 #[unsafe(method(setBlendMode:))]
265 #[unsafe(method_family = none)]
266 pub unsafe fn setBlendMode(&self, blend_mode: SKBlendMode);
267
268 #[cfg(feature = "objc2-core-foundation")]
269 /// Used to choose the location in the tile map that maps to its 'position' in the parent's coordinate space. The valid interval for each input is from 0.0 up to and including 1.0.
270 #[unsafe(method(anchorPoint))]
271 #[unsafe(method_family = none)]
272 pub unsafe fn anchorPoint(&self) -> CGPoint;
273
274 #[cfg(feature = "objc2-core-foundation")]
275 /// Setter for [`anchorPoint`][Self::anchorPoint].
276 #[unsafe(method(setAnchorPoint:))]
277 #[unsafe(method_family = none)]
278 pub unsafe fn setAnchorPoint(&self, anchor_point: CGPoint);
279
280 #[cfg(feature = "SKShader")]
281 /// A property that determines whether the tile map is rendered using a custom shader.
282 #[unsafe(method(shader))]
283 #[unsafe(method_family = none)]
284 pub unsafe fn shader(&self) -> Option<Retained<SKShader>>;
285
286 #[cfg(feature = "SKShader")]
287 /// Setter for [`shader`][Self::shader].
288 #[unsafe(method(setShader:))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn setShader(&self, shader: Option<&SKShader>);
291
292 #[cfg(feature = "SKAttribute")]
293 /// Optional dictionary of SKAttributeValues
294 /// Attributes can be used with custom SKShaders.
295 #[unsafe(method(attributeValues))]
296 #[unsafe(method_family = none)]
297 pub unsafe fn attributeValues(&self) -> Retained<NSDictionary<NSString, SKAttributeValue>>;
298
299 #[cfg(feature = "SKAttribute")]
300 /// Setter for [`attributeValues`][Self::attributeValues].
301 #[unsafe(method(setAttributeValues:))]
302 #[unsafe(method_family = none)]
303 pub unsafe fn setAttributeValues(
304 &self,
305 attribute_values: &NSDictionary<NSString, SKAttributeValue>,
306 );
307
308 #[cfg(feature = "SKAttribute")]
309 #[unsafe(method(valueForAttributeNamed:))]
310 #[unsafe(method_family = none)]
311 pub unsafe fn valueForAttributeNamed(
312 &self,
313 key: &NSString,
314 ) -> Option<Retained<SKAttributeValue>>;
315
316 #[cfg(feature = "SKAttribute")]
317 #[unsafe(method(setValue:forAttributeNamed:))]
318 #[unsafe(method_family = none)]
319 pub unsafe fn setValue_forAttributeNamed(&self, value: &SKAttributeValue, key: &NSString);
320
321 /// Bitmask to indicate being lit by a set of lights using overlapping lighting categories.
322 ///
323 /// A light whose category is set to a value that masks to non-zero using this mask will
324 /// apply light to this sprite.
325 ///
326 /// When used together with a normal texture, complex lighting effects can be used.
327 #[unsafe(method(lightingBitMask))]
328 #[unsafe(method_family = none)]
329 pub unsafe fn lightingBitMask(&self) -> u32;
330
331 /// Setter for [`lightingBitMask`][Self::lightingBitMask].
332 #[unsafe(method(setLightingBitMask:))]
333 #[unsafe(method_family = none)]
334 pub unsafe fn setLightingBitMask(&self, lighting_bit_mask: u32);
335
336 #[unsafe(method(enableAutomapping))]
337 #[unsafe(method_family = none)]
338 pub unsafe fn enableAutomapping(&self) -> bool;
339
340 /// Setter for [`enableAutomapping`][Self::enableAutomapping].
341 #[unsafe(method(setEnableAutomapping:))]
342 #[unsafe(method_family = none)]
343 pub unsafe fn setEnableAutomapping(&self, enable_automapping: bool);
344
345 #[cfg(feature = "SKTileSet")]
346 /// Fill the entire tile map with the provided tile group.
347 ///
348 /// Parameter `tileGroup`: the tile group that will be used to fill the map
349 #[unsafe(method(fillWithTileGroup:))]
350 #[unsafe(method_family = none)]
351 pub unsafe fn fillWithTileGroup(&self, tile_group: Option<&SKTileGroup>);
352
353 #[cfg(feature = "SKTileDefinition")]
354 /// Look up the tile definition at the specified tile index.
355 ///
356 /// Parameter `column`: the column index of the tile
357 ///
358 /// Parameter `row`: the row index of the tile
359 #[unsafe(method(tileDefinitionAtColumn:row:))]
360 #[unsafe(method_family = none)]
361 pub unsafe fn tileDefinitionAtColumn_row(
362 &self,
363 column: NSUInteger,
364 row: NSUInteger,
365 ) -> Option<Retained<SKTileDefinition>>;
366
367 #[cfg(feature = "SKTileSet")]
368 /// Look up the tile group at the specified tile index.
369 ///
370 /// Parameter `column`: the column index of the tile
371 ///
372 /// Parameter `row`: the row index of the tile
373 #[unsafe(method(tileGroupAtColumn:row:))]
374 #[unsafe(method_family = none)]
375 pub unsafe fn tileGroupAtColumn_row(
376 &self,
377 column: NSUInteger,
378 row: NSUInteger,
379 ) -> Option<Retained<SKTileGroup>>;
380
381 #[cfg(feature = "SKTileSet")]
382 /// Set the tile group at the specified tile index. When automapping is enabled, the appropriate tile definitions will automatically be selected and placed, possibly modifying neighboring tiles. When automapping is disabled, it will simply place the default center tile definition for the group, and will not modify any of the neihboring tiles.
383 ///
384 /// Parameter `tileGroup`: the tile group we want to place in the map
385 ///
386 /// Parameter `column`: the column index of the tile
387 ///
388 /// Parameter `row`: the row index of the tile
389 #[unsafe(method(setTileGroup:forColumn:row:))]
390 #[unsafe(method_family = none)]
391 pub unsafe fn setTileGroup_forColumn_row(
392 &self,
393 tile_group: Option<&SKTileGroup>,
394 column: NSUInteger,
395 row: NSUInteger,
396 );
397
398 #[cfg(all(feature = "SKTileDefinition", feature = "SKTileSet"))]
399 /// Set the tile group and tile defintion at the specified tile index. When automapping is enabled, it will attempt to resolve the surrounding tiles to allow the specified tile definition to be placed. When automapping is disabled, it will simply place the tile definition and not modify any of the neighboring tiles.
400 ///
401 /// Parameter `tileGroup`: the tile group we want to place in the map
402 ///
403 /// Parameter `tileDefinition`: the tile definition we want to place in the map
404 ///
405 /// Parameter `column`: the column index of the tile
406 ///
407 /// Parameter `row`: the row index of the tile
408 #[unsafe(method(setTileGroup:andTileDefinition:forColumn:row:))]
409 #[unsafe(method_family = none)]
410 pub unsafe fn setTileGroup_andTileDefinition_forColumn_row(
411 &self,
412 tile_group: &SKTileGroup,
413 tile_definition: &SKTileDefinition,
414 column: NSUInteger,
415 row: NSUInteger,
416 );
417
418 #[cfg(feature = "objc2-core-foundation")]
419 /// Returns the column index of the tile that lies under the specified position. Returns NSUIntegerMax if the position does not fall within the tile map.
420 ///
421 /// Parameter `position`: the position we want to check against the tile map
422 #[unsafe(method(tileColumnIndexFromPosition:))]
423 #[unsafe(method_family = none)]
424 pub unsafe fn tileColumnIndexFromPosition(&self, position: CGPoint) -> NSUInteger;
425
426 #[cfg(feature = "objc2-core-foundation")]
427 /// Returns the row index of the tile that lies under the specified position. Returns NSUIntegerMax if the position does not fall within the tile map.
428 ///
429 /// Parameter `position`: the position we want to check against the tile map
430 #[unsafe(method(tileRowIndexFromPosition:))]
431 #[unsafe(method_family = none)]
432 pub unsafe fn tileRowIndexFromPosition(&self, position: CGPoint) -> NSUInteger;
433
434 #[cfg(feature = "objc2-core-foundation")]
435 /// Returns the position of the center of the tile at the specified column and row.
436 ///
437 /// Parameter `column`: the column index of the tile
438 ///
439 /// Parameter `row`: the row index of the tile
440 #[unsafe(method(centerOfTileAtColumn:row:))]
441 #[unsafe(method_family = none)]
442 pub unsafe fn centerOfTileAtColumn_row(
443 &self,
444 column: NSUInteger,
445 row: NSUInteger,
446 ) -> CGPoint;
447 );
448}
449
450/// Methods declared on superclass `SKNode`.
451#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
452#[cfg(target_os = "macos")]
453impl SKTileMapNode {
454 extern_methods!(
455 #[unsafe(method(init))]
456 #[unsafe(method_family = init)]
457 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
458
459 /// Support coding and decoding via NSKeyedArchiver.
460 #[unsafe(method(initWithCoder:))]
461 #[unsafe(method_family = init)]
462 pub unsafe fn initWithCoder(
463 this: Allocated<Self>,
464 a_decoder: &NSCoder,
465 ) -> Option<Retained<Self>>;
466
467 #[unsafe(method(node))]
468 #[unsafe(method_family = none)]
469 pub unsafe fn node(mtm: MainThreadMarker) -> Retained<Self>;
470
471 #[unsafe(method(nodeWithFileNamed:))]
472 #[unsafe(method_family = none)]
473 pub unsafe fn nodeWithFileNamed(
474 filename: &NSString,
475 mtm: MainThreadMarker,
476 ) -> Option<Retained<Self>>;
477
478 #[unsafe(method(nodeWithFileNamed:securelyWithClasses:andError:_))]
479 #[unsafe(method_family = none)]
480 pub unsafe fn nodeWithFileNamed_securelyWithClasses_andError(
481 filename: &NSString,
482 classes: &NSSet<AnyClass>,
483 mtm: MainThreadMarker,
484 ) -> Result<Retained<Self>, Retained<NSError>>;
485 );
486}
487
488/// Methods declared on superclass `NSObject`.
489#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
490#[cfg(target_os = "macos")]
491impl SKTileMapNode {
492 extern_methods!(
493 #[unsafe(method(new))]
494 #[unsafe(method_family = new)]
495 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
496 );
497}