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")]
28extern_conformance!(
29    unsafe impl NSCoding for SKTileMapNode {}
30);
31
32#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
33#[cfg(target_os = "macos")]
34extern_conformance!(
35    unsafe impl NSCopying for SKTileMapNode {}
36);
37
38#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
39#[cfg(target_os = "macos")]
40unsafe impl CopyingHelper for SKTileMapNode {
41    type Result = Self;
42}
43
44#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
45#[cfg(target_os = "macos")]
46extern_conformance!(
47    unsafe impl NSObjectProtocol for SKTileMapNode {}
48);
49
50#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
51#[cfg(target_os = "macos")]
52extern_conformance!(
53    unsafe impl NSSecureCoding for SKTileMapNode {}
54);
55
56#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
57#[cfg(target_os = "macos")]
58impl SKTileMapNode {
59    extern_methods!(
60        #[cfg(all(feature = "SKTileSet", feature = "objc2-core-foundation"))]
61        /// 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.
62        ///
63        /// Parameter `tileSet`: the tile set that is used to render the tiles
64        ///
65        /// Parameter `columns`: the number of columns in the map that can hold tiles
66        ///
67        /// Parameter `rows`: the number of rows in the map that can hold tiles
68        ///
69        /// Parameter `tileSize`: the size of each tile in points
70        #[unsafe(method(tileMapNodeWithTileSet:columns:rows:tileSize:))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn tileMapNodeWithTileSet_columns_rows_tileSize(
73            tile_set: &SKTileSet,
74            columns: NSUInteger,
75            rows: NSUInteger,
76            tile_size: CGSize,
77            mtm: MainThreadMarker,
78        ) -> Retained<Self>;
79
80        #[cfg(all(feature = "SKTileSet", feature = "objc2-core-foundation"))]
81        /// Create a tile map node with the specified tile set and dimensions, and fill it with the specified tile group.
82        ///
83        /// Parameter `tileSet`: the tile set that is used to render the tiles
84        ///
85        /// Parameter `columns`: the number of columns in the map that can hold tiles
86        ///
87        /// Parameter `rows`: the number of rows in the map that can hold tiles
88        ///
89        /// Parameter `tileSize`: the size of each tile in points
90        ///
91        /// Parameter `tileGroup`: the tile group we wish to fill the tile map with
92        #[unsafe(method(tileMapNodeWithTileSet:columns:rows:tileSize:fillWithTileGroup:))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn tileMapNodeWithTileSet_columns_rows_tileSize_fillWithTileGroup(
95            tile_set: &SKTileSet,
96            columns: NSUInteger,
97            rows: NSUInteger,
98            tile_size: CGSize,
99            tile_group: &SKTileGroup,
100            mtm: MainThreadMarker,
101        ) -> Retained<Self>;
102
103        #[cfg(all(feature = "SKTileSet", feature = "objc2-core-foundation"))]
104        /// 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.
105        ///
106        /// Parameter `tileSet`: the tile set that is used to render the tiles
107        ///
108        /// Parameter `columns`: the number of columns in the map that can hold tiles
109        ///
110        /// Parameter `rows`: the number of rows in the map that can hold tiles
111        ///
112        /// Parameter `tileSize`: the size of each tile in points
113        ///
114        /// Parameter `tileGroupLayout`: an array of tile groups that we want to use to fill the tile map
115        #[unsafe(method(tileMapNodeWithTileSet:columns:rows:tileSize:tileGroupLayout:))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn tileMapNodeWithTileSet_columns_rows_tileSize_tileGroupLayout(
118            tile_set: &SKTileSet,
119            columns: NSUInteger,
120            rows: NSUInteger,
121            tile_size: CGSize,
122            tile_group_layout: &NSArray<SKTileGroup>,
123            mtm: MainThreadMarker,
124        ) -> Retained<Self>;
125
126        #[cfg(all(feature = "SKTileSet", feature = "objc2-core-foundation"))]
127        /// 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.
128        ///
129        /// Parameter `tileSet`: the tile set that is used to render the tiles
130        ///
131        /// Parameter `columns`: the number of columns in the map that can hold tiles
132        ///
133        /// Parameter `rows`: the number of rows in the map that can hold tiles
134        ///
135        /// Parameter `tileSize`: the size of each tile in points
136        #[unsafe(method(initWithTileSet:columns:rows:tileSize:))]
137        #[unsafe(method_family = init)]
138        pub unsafe fn initWithTileSet_columns_rows_tileSize(
139            this: Allocated<Self>,
140            tile_set: &SKTileSet,
141            columns: NSUInteger,
142            rows: NSUInteger,
143            tile_size: CGSize,
144        ) -> Retained<Self>;
145
146        #[cfg(all(feature = "SKTileSet", feature = "objc2-core-foundation"))]
147        /// Initialize a tile map node with the specified tile set and dimensions, and fill it with the specified tile group.
148        ///
149        /// Parameter `tileSet`: the tile set that is used to render the tiles
150        ///
151        /// Parameter `columns`: the number of columns in the map that can hold tiles
152        ///
153        /// Parameter `rows`: the number of rows in the map that can hold tiles
154        ///
155        /// Parameter `tileSize`: the size of each tile in points
156        ///
157        /// Parameter `tileGroup`: the tile group we wish to fill the tile map with
158        #[unsafe(method(initWithTileSet:columns:rows:tileSize:fillWithTileGroup:))]
159        #[unsafe(method_family = init)]
160        pub unsafe fn initWithTileSet_columns_rows_tileSize_fillWithTileGroup(
161            this: Allocated<Self>,
162            tile_set: &SKTileSet,
163            columns: NSUInteger,
164            rows: NSUInteger,
165            tile_size: CGSize,
166            tile_group: &SKTileGroup,
167        ) -> Retained<Self>;
168
169        #[cfg(all(feature = "SKTileSet", feature = "objc2-core-foundation"))]
170        /// 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.
171        ///
172        /// Parameter `tileSet`: the tile set that is used to render the tiles
173        ///
174        /// Parameter `columns`: the number of columns in the map that can hold tiles
175        ///
176        /// Parameter `rows`: the number of rows in the map that can hold tiles
177        ///
178        /// Parameter `tileSize`: the size of each tile in points
179        ///
180        /// Parameter `tileGroupLayout`: an array of tile groups that we want to use to fill the tile map
181        #[unsafe(method(initWithTileSet:columns:rows:tileSize:tileGroupLayout:))]
182        #[unsafe(method_family = init)]
183        pub unsafe fn initWithTileSet_columns_rows_tileSize_tileGroupLayout(
184            this: Allocated<Self>,
185            tile_set: &SKTileSet,
186            columns: NSUInteger,
187            rows: NSUInteger,
188            tile_size: CGSize,
189            tile_group_layout: &NSArray<SKTileGroup>,
190        ) -> Retained<Self>;
191
192        /// The number of columns in the tile map.
193        #[unsafe(method(numberOfColumns))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn numberOfColumns(&self) -> NSUInteger;
196
197        /// Setter for [`numberOfColumns`][Self::numberOfColumns].
198        #[unsafe(method(setNumberOfColumns:))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn setNumberOfColumns(&self, number_of_columns: NSUInteger);
201
202        /// The number of rows in the tile map.
203        #[unsafe(method(numberOfRows))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn numberOfRows(&self) -> NSUInteger;
206
207        /// Setter for [`numberOfRows`][Self::numberOfRows].
208        #[unsafe(method(setNumberOfRows:))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn setNumberOfRows(&self, number_of_rows: NSUInteger);
211
212        #[cfg(feature = "objc2-core-foundation")]
213        /// The size of each tile in the map.
214        #[unsafe(method(tileSize))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn tileSize(&self) -> CGSize;
217
218        #[cfg(feature = "objc2-core-foundation")]
219        /// Setter for [`tileSize`][Self::tileSize].
220        #[unsafe(method(setTileSize:))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn setTileSize(&self, tile_size: CGSize);
223
224        #[cfg(feature = "objc2-core-foundation")]
225        /// 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.
226        #[unsafe(method(mapSize))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn mapSize(&self) -> CGSize;
229
230        #[cfg(feature = "SKTileSet")]
231        /// The tile set being used by this tile map.
232        #[unsafe(method(tileSet))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn tileSet(&self) -> Retained<SKTileSet>;
235
236        #[cfg(feature = "SKTileSet")]
237        /// Setter for [`tileSet`][Self::tileSet].
238        #[unsafe(method(setTileSet:))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn setTileSet(&self, tile_set: &SKTileSet);
241
242        #[cfg(feature = "objc2-core-foundation")]
243        /// 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.
244        #[unsafe(method(colorBlendFactor))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn colorBlendFactor(&self) -> CGFloat;
247
248        #[cfg(feature = "objc2-core-foundation")]
249        /// Setter for [`colorBlendFactor`][Self::colorBlendFactor].
250        #[unsafe(method(setColorBlendFactor:))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn setColorBlendFactor(&self, color_blend_factor: CGFloat);
253
254        /// Base color for the tile map (If no texture is present, the color still is drawn).
255        #[unsafe(method(color))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn color(&self) -> Retained<NSColor>;
258
259        /// Setter for [`color`][Self::color].
260        #[unsafe(method(setColor:))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn setColor(&self, color: &NSColor);
263
264        /// Sets the blend mode to use when composing the tile map with the final framebuffer.
265        ///
266        /// See: SKNode.SKBlendMode
267        #[unsafe(method(blendMode))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn blendMode(&self) -> SKBlendMode;
270
271        /// Setter for [`blendMode`][Self::blendMode].
272        #[unsafe(method(setBlendMode:))]
273        #[unsafe(method_family = none)]
274        pub unsafe fn setBlendMode(&self, blend_mode: SKBlendMode);
275
276        #[cfg(feature = "objc2-core-foundation")]
277        /// 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.
278        #[unsafe(method(anchorPoint))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn anchorPoint(&self) -> CGPoint;
281
282        #[cfg(feature = "objc2-core-foundation")]
283        /// Setter for [`anchorPoint`][Self::anchorPoint].
284        #[unsafe(method(setAnchorPoint:))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn setAnchorPoint(&self, anchor_point: CGPoint);
287
288        #[cfg(feature = "SKShader")]
289        /// A property that determines whether the tile map is rendered using a custom shader.
290        #[unsafe(method(shader))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn shader(&self) -> Option<Retained<SKShader>>;
293
294        #[cfg(feature = "SKShader")]
295        /// Setter for [`shader`][Self::shader].
296        #[unsafe(method(setShader:))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn setShader(&self, shader: Option<&SKShader>);
299
300        #[cfg(feature = "SKAttribute")]
301        /// Optional dictionary of SKAttributeValues
302        /// Attributes can be used with custom SKShaders.
303        #[unsafe(method(attributeValues))]
304        #[unsafe(method_family = none)]
305        pub unsafe fn attributeValues(&self) -> Retained<NSDictionary<NSString, SKAttributeValue>>;
306
307        #[cfg(feature = "SKAttribute")]
308        /// Setter for [`attributeValues`][Self::attributeValues].
309        ///
310        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
311        #[unsafe(method(setAttributeValues:))]
312        #[unsafe(method_family = none)]
313        pub unsafe fn setAttributeValues(
314            &self,
315            attribute_values: &NSDictionary<NSString, SKAttributeValue>,
316        );
317
318        #[cfg(feature = "SKAttribute")]
319        #[unsafe(method(valueForAttributeNamed:))]
320        #[unsafe(method_family = none)]
321        pub unsafe fn valueForAttributeNamed(
322            &self,
323            key: &NSString,
324        ) -> Option<Retained<SKAttributeValue>>;
325
326        #[cfg(feature = "SKAttribute")]
327        #[unsafe(method(setValue:forAttributeNamed:))]
328        #[unsafe(method_family = none)]
329        pub unsafe fn setValue_forAttributeNamed(&self, value: &SKAttributeValue, key: &NSString);
330
331        /// Bitmask to indicate being lit by a set of lights using overlapping lighting categories.
332        ///
333        /// A light whose category is set to a value that masks to non-zero using this mask will
334        /// apply light to this sprite.
335        ///
336        /// When used together with a normal texture, complex lighting effects can be used.
337        #[unsafe(method(lightingBitMask))]
338        #[unsafe(method_family = none)]
339        pub unsafe fn lightingBitMask(&self) -> u32;
340
341        /// Setter for [`lightingBitMask`][Self::lightingBitMask].
342        #[unsafe(method(setLightingBitMask:))]
343        #[unsafe(method_family = none)]
344        pub unsafe fn setLightingBitMask(&self, lighting_bit_mask: u32);
345
346        #[unsafe(method(enableAutomapping))]
347        #[unsafe(method_family = none)]
348        pub unsafe fn enableAutomapping(&self) -> bool;
349
350        /// Setter for [`enableAutomapping`][Self::enableAutomapping].
351        #[unsafe(method(setEnableAutomapping:))]
352        #[unsafe(method_family = none)]
353        pub unsafe fn setEnableAutomapping(&self, enable_automapping: bool);
354
355        #[cfg(feature = "SKTileSet")]
356        /// Fill the entire tile map with the provided tile group.
357        ///
358        /// Parameter `tileGroup`: the tile group that will be used to fill the map
359        #[unsafe(method(fillWithTileGroup:))]
360        #[unsafe(method_family = none)]
361        pub unsafe fn fillWithTileGroup(&self, tile_group: Option<&SKTileGroup>);
362
363        #[cfg(feature = "SKTileDefinition")]
364        /// Look up the tile definition at the specified tile index.
365        ///
366        /// Parameter `column`: the column index of the tile
367        ///
368        /// Parameter `row`: the row index of the tile
369        #[unsafe(method(tileDefinitionAtColumn:row:))]
370        #[unsafe(method_family = none)]
371        pub unsafe fn tileDefinitionAtColumn_row(
372            &self,
373            column: NSUInteger,
374            row: NSUInteger,
375        ) -> Option<Retained<SKTileDefinition>>;
376
377        #[cfg(feature = "SKTileSet")]
378        /// Look up the tile group at the specified tile index.
379        ///
380        /// Parameter `column`: the column index of the tile
381        ///
382        /// Parameter `row`: the row index of the tile
383        #[unsafe(method(tileGroupAtColumn:row:))]
384        #[unsafe(method_family = none)]
385        pub unsafe fn tileGroupAtColumn_row(
386            &self,
387            column: NSUInteger,
388            row: NSUInteger,
389        ) -> Option<Retained<SKTileGroup>>;
390
391        #[cfg(feature = "SKTileSet")]
392        /// 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.
393        ///
394        /// Parameter `tileGroup`: the tile group we want to place in the map
395        ///
396        /// Parameter `column`: the column index of the tile
397        ///
398        /// Parameter `row`: the row index of the tile
399        #[unsafe(method(setTileGroup:forColumn:row:))]
400        #[unsafe(method_family = none)]
401        pub unsafe fn setTileGroup_forColumn_row(
402            &self,
403            tile_group: Option<&SKTileGroup>,
404            column: NSUInteger,
405            row: NSUInteger,
406        );
407
408        #[cfg(all(feature = "SKTileDefinition", feature = "SKTileSet"))]
409        /// 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.
410        ///
411        /// Parameter `tileGroup`: the tile group we want to place in the map
412        ///
413        /// Parameter `tileDefinition`: the tile definition we want to place in the map
414        ///
415        /// Parameter `column`: the column index of the tile
416        ///
417        /// Parameter `row`: the row index of the tile
418        #[unsafe(method(setTileGroup:andTileDefinition:forColumn:row:))]
419        #[unsafe(method_family = none)]
420        pub unsafe fn setTileGroup_andTileDefinition_forColumn_row(
421            &self,
422            tile_group: &SKTileGroup,
423            tile_definition: &SKTileDefinition,
424            column: NSUInteger,
425            row: NSUInteger,
426        );
427
428        #[cfg(feature = "objc2-core-foundation")]
429        /// 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.
430        ///
431        /// Parameter `position`: the position we want to check against the tile map
432        #[unsafe(method(tileColumnIndexFromPosition:))]
433        #[unsafe(method_family = none)]
434        pub unsafe fn tileColumnIndexFromPosition(&self, position: CGPoint) -> NSUInteger;
435
436        #[cfg(feature = "objc2-core-foundation")]
437        /// 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.
438        ///
439        /// Parameter `position`: the position we want to check against the tile map
440        #[unsafe(method(tileRowIndexFromPosition:))]
441        #[unsafe(method_family = none)]
442        pub unsafe fn tileRowIndexFromPosition(&self, position: CGPoint) -> NSUInteger;
443
444        #[cfg(feature = "objc2-core-foundation")]
445        /// Returns the position of the center of the tile at the specified column and row.
446        ///
447        /// Parameter `column`: the column index of the tile
448        ///
449        /// Parameter `row`: the row index of the tile
450        #[unsafe(method(centerOfTileAtColumn:row:))]
451        #[unsafe(method_family = none)]
452        pub unsafe fn centerOfTileAtColumn_row(
453            &self,
454            column: NSUInteger,
455            row: NSUInteger,
456        ) -> CGPoint;
457    );
458}
459
460/// Methods declared on superclass `SKNode`.
461#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
462#[cfg(target_os = "macos")]
463impl SKTileMapNode {
464    extern_methods!(
465        #[unsafe(method(init))]
466        #[unsafe(method_family = init)]
467        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
468
469        /// Support coding and decoding via NSKeyedArchiver.
470        ///
471        /// # Safety
472        ///
473        /// `a_decoder` possibly has further requirements.
474        #[unsafe(method(initWithCoder:))]
475        #[unsafe(method_family = init)]
476        pub unsafe fn initWithCoder(
477            this: Allocated<Self>,
478            a_decoder: &NSCoder,
479        ) -> Option<Retained<Self>>;
480
481        #[unsafe(method(node))]
482        #[unsafe(method_family = none)]
483        pub unsafe fn node(mtm: MainThreadMarker) -> Retained<Self>;
484
485        #[unsafe(method(nodeWithFileNamed:))]
486        #[unsafe(method_family = none)]
487        pub unsafe fn nodeWithFileNamed(
488            filename: &NSString,
489            mtm: MainThreadMarker,
490        ) -> Option<Retained<Self>>;
491
492        /// # Safety
493        ///
494        /// `classes` generic probably has further requirements.
495        #[unsafe(method(nodeWithFileNamed:securelyWithClasses:andError:_))]
496        #[unsafe(method_family = none)]
497        pub unsafe fn nodeWithFileNamed_securelyWithClasses_andError(
498            filename: &NSString,
499            classes: &NSSet<AnyClass>,
500            mtm: MainThreadMarker,
501        ) -> Result<Retained<Self>, Retained<NSError>>;
502    );
503}
504
505/// Methods declared on superclass `NSObject`.
506#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
507#[cfg(target_os = "macos")]
508impl SKTileMapNode {
509    extern_methods!(
510        #[unsafe(method(new))]
511        #[unsafe(method_family = new)]
512        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
513    );
514}