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