objc2_sprite_kit/generated/
SKTileDefinition.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-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// Adjust the rotation of the tile definition image, in 90 degree increments.
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/sktiledefinitionrotation?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct SKTileDefinitionRotation(pub NSUInteger);
19impl SKTileDefinitionRotation {
20    #[doc(alias = "SKTileDefinitionRotation0")]
21    pub const Rotation0: Self = Self(0);
22    #[doc(alias = "SKTileDefinitionRotation90")]
23    pub const Rotation90: Self = Self(1);
24    #[doc(alias = "SKTileDefinitionRotation180")]
25    pub const Rotation180: Self = Self(2);
26    #[doc(alias = "SKTileDefinitionRotation270")]
27    pub const Rotation270: Self = Self(3);
28}
29
30unsafe impl Encode for SKTileDefinitionRotation {
31    const ENCODING: Encoding = NSUInteger::ENCODING;
32}
33
34unsafe impl RefEncode for SKTileDefinitionRotation {
35    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
36}
37
38extern_class!(
39    /// A tile definition contains the information needed to represent a single type of tile within a tile map.
40    ///
41    /// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/sktiledefinition?language=objc)
42    #[unsafe(super(NSObject))]
43    #[derive(Debug, PartialEq, Eq, Hash)]
44    pub struct SKTileDefinition;
45);
46
47extern_conformance!(
48    unsafe impl NSCoding for SKTileDefinition {}
49);
50
51extern_conformance!(
52    unsafe impl NSCopying for SKTileDefinition {}
53);
54
55unsafe impl CopyingHelper for SKTileDefinition {
56    type Result = Self;
57}
58
59extern_conformance!(
60    unsafe impl NSObjectProtocol for SKTileDefinition {}
61);
62
63extern_conformance!(
64    unsafe impl NSSecureCoding for SKTileDefinition {}
65);
66
67impl SKTileDefinition {
68    extern_methods!(
69        #[cfg(feature = "SKTexture")]
70        /// Create a tile definition with an SKTexture, and set its size to the SKTexture's width/height.
71        ///
72        /// Parameter `texture`: the texture to reference for size and content
73        #[unsafe(method(tileDefinitionWithTexture:))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn tileDefinitionWithTexture(texture: &SKTexture) -> Retained<Self>;
76
77        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
78        /// Create a tile definition with an SKTexture and the specified size.
79        ///
80        /// Parameter `texture`: the texture to reference for content
81        ///
82        /// Parameter `size`: the size of the tile in points
83        #[unsafe(method(tileDefinitionWithTexture:size:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn tileDefinitionWithTexture_size(
86            texture: &SKTexture,
87            size: CGSize,
88        ) -> Retained<Self>;
89
90        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
91        /// Create a tile definition with an SKTexture and the specified size.
92        ///
93        /// Parameter `texture`: the texture to reference for content
94        ///
95        /// Parameter `normalTexture`: the normal texture to use for generating normals for lighting
96        ///
97        /// Parameter `size`: the size of the tile in points
98        #[unsafe(method(tileDefinitionWithTexture:normalTexture:size:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn tileDefinitionWithTexture_normalTexture_size(
101            texture: &SKTexture,
102            normal_texture: &SKTexture,
103            size: CGSize,
104        ) -> Retained<Self>;
105
106        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
107        /// Create an animated tile definition with an array of SKTextures, the specified size, and the length of time each texture should be displayed for in the animation.
108        ///
109        /// Parameter `textures`: the textures to reference for animated content
110        ///
111        /// Parameter `size`: the size of the tile in points
112        ///
113        /// Parameter `timePerFrame`: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
114        #[unsafe(method(tileDefinitionWithTextures:size:timePerFrame:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn tileDefinitionWithTextures_size_timePerFrame(
117            textures: &NSArray<SKTexture>,
118            size: CGSize,
119            time_per_frame: CGFloat,
120        ) -> Retained<Self>;
121
122        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
123        /// Create an animated tile definition with an array of SKTextures, the specified size, and the length of time each texture should be displayed for in the animation.
124        ///
125        /// Parameter `textures`: the textures to reference for animated content
126        ///
127        /// Parameter `normalTextures`: the normal textures to use for generating normals for lighting
128        ///
129        /// Parameter `size`: the size of the tile in points
130        ///
131        /// Parameter `timePerFrame`: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
132        #[unsafe(method(tileDefinitionWithTextures:normalTextures:size:timePerFrame:))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn tileDefinitionWithTextures_normalTextures_size_timePerFrame(
135            textures: &NSArray<SKTexture>,
136            normal_textures: &NSArray<SKTexture>,
137            size: CGSize,
138            time_per_frame: CGFloat,
139        ) -> Retained<Self>;
140
141        #[cfg(feature = "SKTexture")]
142        /// Initilize a tile definition with an SKTexture, and set its size to the SKTexture's width/height.
143        ///
144        /// Parameter `texture`: the texture to reference for size and content
145        #[unsafe(method(initWithTexture:))]
146        #[unsafe(method_family = init)]
147        pub unsafe fn initWithTexture(this: Allocated<Self>, texture: &SKTexture)
148            -> Retained<Self>;
149
150        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
151        /// Initilize a tile definition with an SKTexture and the specified size.
152        ///
153        /// Parameter `texture`: the texture to reference for content
154        ///
155        /// Parameter `size`: the size of the tile in points
156        #[unsafe(method(initWithTexture:size:))]
157        #[unsafe(method_family = init)]
158        pub unsafe fn initWithTexture_size(
159            this: Allocated<Self>,
160            texture: &SKTexture,
161            size: CGSize,
162        ) -> Retained<Self>;
163
164        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
165        /// Initilize a tile definition with an SKTexture and the specified size.
166        ///
167        /// Parameter `texture`: the texture to reference for content
168        ///
169        /// Parameter `normalTexture`: the normal texture to use for generating normals for lighting
170        ///
171        /// Parameter `size`: the size of the tile in points
172        #[unsafe(method(initWithTexture:normalTexture:size:))]
173        #[unsafe(method_family = init)]
174        pub unsafe fn initWithTexture_normalTexture_size(
175            this: Allocated<Self>,
176            texture: &SKTexture,
177            normal_texture: &SKTexture,
178            size: CGSize,
179        ) -> Retained<Self>;
180
181        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
182        /// Initilize an animated tile definition with an array of SKTextures, the specified size, and the length of time each texture should be displayed for in the animation.
183        ///
184        /// Parameter `textures`: the textures to reference for animated content
185        ///
186        /// Parameter `size`: the size of the tile in points
187        ///
188        /// Parameter `timePerFrame`: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
189        #[unsafe(method(initWithTextures:size:timePerFrame:))]
190        #[unsafe(method_family = init)]
191        pub unsafe fn initWithTextures_size_timePerFrame(
192            this: Allocated<Self>,
193            textures: &NSArray<SKTexture>,
194            size: CGSize,
195            time_per_frame: CGFloat,
196        ) -> Retained<Self>;
197
198        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
199        /// Initilize an animated tile definition with an array of SKTextures, the specified size, and the length of time each texture should be displayed for in the animation.
200        ///
201        /// Parameter `textures`: the textures to reference for animated content
202        ///
203        /// Parameter `normalTextures`: the normal textures to use for generating normals for lighting
204        ///
205        /// Parameter `size`: the size of the tile in points
206        ///
207        /// Parameter `timePerFrame`: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
208        #[unsafe(method(initWithTextures:normalTextures:size:timePerFrame:))]
209        #[unsafe(method_family = init)]
210        pub unsafe fn initWithTextures_normalTextures_size_timePerFrame(
211            this: Allocated<Self>,
212            textures: &NSArray<SKTexture>,
213            normal_textures: &NSArray<SKTexture>,
214            size: CGSize,
215            time_per_frame: CGFloat,
216        ) -> Retained<Self>;
217
218        #[cfg(feature = "SKTexture")]
219        /// The textures used to draw the tile. Non-animated tiles use only one texture. When more than one texture is present, the tile will swap through them in sequence, showing each for the duration specified in the timePerFrame property. After displaying the last texture in the array, the sequence is repeated from the first texture.
220        #[unsafe(method(textures))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn textures(&self) -> Retained<NSArray<SKTexture>>;
223
224        #[cfg(feature = "SKTexture")]
225        /// Setter for [`textures`][Self::textures].
226        ///
227        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
228        #[unsafe(method(setTextures:))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn setTextures(&self, textures: &NSArray<SKTexture>);
231
232        #[cfg(feature = "SKTexture")]
233        /// The textures to use for generating normals that lights use to light this tile. These will only be used if the tile is lit by at least one light. Each normal texture corresponds to a texture in the textures property.
234        #[unsafe(method(normalTextures))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn normalTextures(&self) -> Retained<NSArray<SKTexture>>;
237
238        #[cfg(feature = "SKTexture")]
239        /// Setter for [`normalTextures`][Self::normalTextures].
240        ///
241        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
242        #[unsafe(method(setNormalTextures:))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn setNormalTextures(&self, normal_textures: &NSArray<SKTexture>);
245
246        /// An optional dictionary that can be used to store your own data for each tile definition. Defaults to nil.
247        ///
248        /// # Safety
249        ///
250        /// The returned generic should be of the correct type.
251        #[unsafe(method(userData))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn userData(&self) -> Option<Retained<NSMutableDictionary>>;
254
255        /// Setter for [`userData`][Self::userData].
256        ///
257        /// # Safety
258        ///
259        /// `user_data` generic should be of the correct type.
260        #[unsafe(method(setUserData:))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn setUserData(&self, user_data: Option<&NSMutableDictionary>);
263
264        /// Client-assignable name for the tile definition. Defaults to nil.
265        #[unsafe(method(name))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn name(&self) -> Option<Retained<NSString>>;
268
269        /// Setter for [`name`][Self::name].
270        ///
271        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
272        #[unsafe(method(setName:))]
273        #[unsafe(method_family = none)]
274        pub unsafe fn setName(&self, name: Option<&NSString>);
275
276        #[cfg(feature = "objc2-core-foundation")]
277        /// The size of the tile in points.
278        #[unsafe(method(size))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn size(&self) -> CGSize;
281
282        #[cfg(feature = "objc2-core-foundation")]
283        /// Setter for [`size`][Self::size].
284        #[unsafe(method(setSize:))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn setSize(&self, size: CGSize);
287
288        #[cfg(feature = "objc2-core-foundation")]
289        /// The duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence. Only used when there is more than one texture available.
290        #[unsafe(method(timePerFrame))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn timePerFrame(&self) -> CGFloat;
293
294        #[cfg(feature = "objc2-core-foundation")]
295        /// Setter for [`timePerFrame`][Self::timePerFrame].
296        #[unsafe(method(setTimePerFrame:))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn setTimePerFrame(&self, time_per_frame: CGFloat);
299
300        /// This value is used to determine how likely this tile definition is to be chosen for placement when a SKTileGroupRule has mulitple tile definitions assigned to it. A higher value relative to the other definitions assigned to the rule make it more likely for this definition to be selected; lower values make it less likely. Defaults to 1. When set to 0, the definition will never be chosen as long as there is at least one other definition with a placementWeight above 0.
301        #[unsafe(method(placementWeight))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn placementWeight(&self) -> NSUInteger;
304
305        /// Setter for [`placementWeight`][Self::placementWeight].
306        #[unsafe(method(setPlacementWeight:))]
307        #[unsafe(method_family = none)]
308        pub unsafe fn setPlacementWeight(&self, placement_weight: NSUInteger);
309
310        /// The rotation of the tile definition's images can be set in 90 degree increments. Defaults to SKTileDefinitionRotation0.
311        #[unsafe(method(rotation))]
312        #[unsafe(method_family = none)]
313        pub unsafe fn rotation(&self) -> SKTileDefinitionRotation;
314
315        /// Setter for [`rotation`][Self::rotation].
316        #[unsafe(method(setRotation:))]
317        #[unsafe(method_family = none)]
318        pub unsafe fn setRotation(&self, rotation: SKTileDefinitionRotation);
319
320        /// When set to YES, the tile definition's images will be flipped vertically (i.e., the top of the image becomes the bottom). Defaults to NO.
321        #[unsafe(method(flipVertically))]
322        #[unsafe(method_family = none)]
323        pub unsafe fn flipVertically(&self) -> bool;
324
325        /// Setter for [`flipVertically`][Self::flipVertically].
326        #[unsafe(method(setFlipVertically:))]
327        #[unsafe(method_family = none)]
328        pub unsafe fn setFlipVertically(&self, flip_vertically: bool);
329
330        /// When set to YES, the tile definition's images will be flipped horizontally (i.e., the left of the image becomes the right). Defaults to NO.
331        #[unsafe(method(flipHorizontally))]
332        #[unsafe(method_family = none)]
333        pub unsafe fn flipHorizontally(&self) -> bool;
334
335        /// Setter for [`flipHorizontally`][Self::flipHorizontally].
336        #[unsafe(method(setFlipHorizontally:))]
337        #[unsafe(method_family = none)]
338        pub unsafe fn setFlipHorizontally(&self, flip_horizontally: bool);
339    );
340}
341
342/// Methods declared on superclass `NSObject`.
343impl SKTileDefinition {
344    extern_methods!(
345        #[unsafe(method(init))]
346        #[unsafe(method_family = init)]
347        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
348
349        #[unsafe(method(new))]
350        #[unsafe(method_family = new)]
351        pub unsafe fn new() -> Retained<Self>;
352    );
353}