objc2-sprite-kit 0.3.2

Bindings to the SpriteKit framework
Documentation
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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
//! 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::*;

/// The tile set type is used to describe how the tiles will be arranged in a tile map.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/sktilesettype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SKTileSetType(pub NSUInteger);
impl SKTileSetType {
    #[doc(alias = "SKTileSetTypeGrid")]
    pub const Grid: Self = Self(0);
    #[doc(alias = "SKTileSetTypeIsometric")]
    pub const Isometric: Self = Self(1);
    #[doc(alias = "SKTileSetTypeHexagonalFlat")]
    pub const HexagonalFlat: Self = Self(2);
    #[doc(alias = "SKTileSetTypeHexagonalPointy")]
    pub const HexagonalPointy: Self = Self(3);
}

unsafe impl Encode for SKTileSetType {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for SKTileSetType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// The adjacency mask is used to specify which neighboring tiles need to be filled in for a rule to go into effect.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/sktileadjacencymask?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SKTileAdjacencyMask(pub NSUInteger);
bitflags::bitflags! {
    impl SKTileAdjacencyMask: NSUInteger {
        #[doc(alias = "SKTileAdjacencyUp")]
        const AdjacencyUp = 1<<0;
        #[doc(alias = "SKTileAdjacencyUpperRight")]
        const AdjacencyUpperRight = 1<<1;
        #[doc(alias = "SKTileAdjacencyRight")]
        const AdjacencyRight = 1<<2;
        #[doc(alias = "SKTileAdjacencyLowerRight")]
        const AdjacencyLowerRight = 1<<3;
        #[doc(alias = "SKTileAdjacencyDown")]
        const AdjacencyDown = 1<<4;
        #[doc(alias = "SKTileAdjacencyLowerLeft")]
        const AdjacencyLowerLeft = 1<<5;
        #[doc(alias = "SKTileAdjacencyLeft")]
        const AdjacencyLeft = 1<<6;
        #[doc(alias = "SKTileAdjacencyUpperLeft")]
        const AdjacencyUpperLeft = 1<<7;
        #[doc(alias = "SKTileAdjacencyAll")]
        const AdjacencyAll = SKTileAdjacencyMask::AdjacencyUp.0|SKTileAdjacencyMask::AdjacencyUpperRight.0|SKTileAdjacencyMask::AdjacencyRight.0|SKTileAdjacencyMask::AdjacencyLowerRight.0|SKTileAdjacencyMask::AdjacencyDown.0|SKTileAdjacencyMask::AdjacencyLowerLeft.0|SKTileAdjacencyMask::AdjacencyLeft.0|SKTileAdjacencyMask::AdjacencyUpperLeft.0;
        #[doc(alias = "SKTileHexFlatAdjacencyUp")]
        const HexFlatAdjacencyUp = 1<<0;
        #[doc(alias = "SKTileHexFlatAdjacencyUpperRight")]
        const HexFlatAdjacencyUpperRight = 1<<1;
        #[doc(alias = "SKTileHexFlatAdjacencyLowerRight")]
        const HexFlatAdjacencyLowerRight = 1<<2;
        #[doc(alias = "SKTileHexFlatAdjacencyDown")]
        const HexFlatAdjacencyDown = 1<<3;
        #[doc(alias = "SKTileHexFlatAdjacencyLowerLeft")]
        const HexFlatAdjacencyLowerLeft = 1<<4;
        #[doc(alias = "SKTileHexFlatAdjacencyUpperLeft")]
        const HexFlatAdjacencyUpperLeft = 1<<5;
        #[doc(alias = "SKTileHexFlatAdjacencyAll")]
        const HexFlatAdjacencyAll = SKTileAdjacencyMask::HexFlatAdjacencyUp.0|SKTileAdjacencyMask::HexFlatAdjacencyUpperRight.0|SKTileAdjacencyMask::HexFlatAdjacencyLowerRight.0|SKTileAdjacencyMask::HexFlatAdjacencyDown.0|SKTileAdjacencyMask::HexFlatAdjacencyLowerLeft.0|SKTileAdjacencyMask::HexFlatAdjacencyUpperLeft.0;
        #[doc(alias = "SKTileHexPointyAdjacencyUpperLeft")]
        const HexPointyAdjacencyUpperLeft = 1<<0;
        #[doc(alias = "SKTileHexPointyAdjacencyUpperRight")]
        const HexPointyAdjacencyUpperRight = 1<<1;
        #[doc(alias = "SKTileHexPointyAdjacencyRight")]
        const HexPointyAdjacencyRight = 1<<2;
        #[doc(alias = "SKTileHexPointyAdjacencyLowerRight")]
        const HexPointyAdjacencyLowerRight = 1<<3;
        #[doc(alias = "SKTileHexPointyAdjacencyLowerLeft")]
        const HexPointyAdjacencyLowerLeft = 1<<4;
        #[doc(alias = "SKTileHexPointyAdjacencyLeft")]
        const HexPointyAdjacencyLeft = 1<<5;
        #[doc(alias = "SKTileHexPointyAdjacencyAdd")]
        const HexPointyAdjacencyAdd = SKTileAdjacencyMask::HexPointyAdjacencyUpperLeft.0|SKTileAdjacencyMask::HexPointyAdjacencyUpperRight.0|SKTileAdjacencyMask::HexPointyAdjacencyRight.0|SKTileAdjacencyMask::HexPointyAdjacencyLowerRight.0|SKTileAdjacencyMask::HexPointyAdjacencyLowerLeft.0|SKTileAdjacencyMask::HexPointyAdjacencyLeft.0;
        #[doc(alias = "SKTileAdjacencyUpEdge")]
        const AdjacencyUpEdge = SKTileAdjacencyMask::AdjacencyRight.0|SKTileAdjacencyMask::AdjacencyLowerRight.0|SKTileAdjacencyMask::AdjacencyDown.0|SKTileAdjacencyMask::AdjacencyLowerLeft.0|SKTileAdjacencyMask::AdjacencyLeft.0;
        #[doc(alias = "SKTileAdjacencyUpperRightEdge")]
        const AdjacencyUpperRightEdge = SKTileAdjacencyMask::AdjacencyDown.0|SKTileAdjacencyMask::AdjacencyLowerLeft.0|SKTileAdjacencyMask::AdjacencyLeft.0;
        #[doc(alias = "SKTileAdjacencyRightEdge")]
        const AdjacencyRightEdge = SKTileAdjacencyMask::AdjacencyDown.0|SKTileAdjacencyMask::AdjacencyLowerLeft.0|SKTileAdjacencyMask::AdjacencyLeft.0|SKTileAdjacencyMask::AdjacencyUpperLeft.0|SKTileAdjacencyMask::AdjacencyUp.0;
        #[doc(alias = "SKTileAdjacencyLowerRightEdge")]
        const AdjacencyLowerRightEdge = SKTileAdjacencyMask::AdjacencyLeft.0|SKTileAdjacencyMask::AdjacencyUpperLeft.0|SKTileAdjacencyMask::AdjacencyUp.0;
        #[doc(alias = "SKTileAdjacencyDownEdge")]
        const AdjacencyDownEdge = SKTileAdjacencyMask::AdjacencyUp.0|SKTileAdjacencyMask::AdjacencyUpperRight.0|SKTileAdjacencyMask::AdjacencyRight.0|SKTileAdjacencyMask::AdjacencyLeft.0|SKTileAdjacencyMask::AdjacencyUpperLeft.0;
        #[doc(alias = "SKTileAdjacencyLowerLeftEdge")]
        const AdjacencyLowerLeftEdge = SKTileAdjacencyMask::AdjacencyUp.0|SKTileAdjacencyMask::AdjacencyUpperRight.0|SKTileAdjacencyMask::AdjacencyRight.0;
        #[doc(alias = "SKTileAdjacencyLeftEdge")]
        const AdjacencyLeftEdge = SKTileAdjacencyMask::AdjacencyUp.0|SKTileAdjacencyMask::AdjacencyUpperRight.0|SKTileAdjacencyMask::AdjacencyRight.0|SKTileAdjacencyMask::AdjacencyLowerRight.0|SKTileAdjacencyMask::AdjacencyDown.0;
        #[doc(alias = "SKTileAdjacencyUpperLeftEdge")]
        const AdjacencyUpperLeftEdge = SKTileAdjacencyMask::AdjacencyRight.0|SKTileAdjacencyMask::AdjacencyLowerRight.0|SKTileAdjacencyMask::AdjacencyDown.0;
        #[doc(alias = "SKTileAdjacencyUpperRightCorner")]
        const AdjacencyUpperRightCorner = SKTileAdjacencyMask::AdjacencyUp.0|SKTileAdjacencyMask::AdjacencyUpperRight.0|SKTileAdjacencyMask::AdjacencyRight.0|SKTileAdjacencyMask::AdjacencyLowerRight.0|SKTileAdjacencyMask::AdjacencyDown.0|SKTileAdjacencyMask::AdjacencyLeft.0|SKTileAdjacencyMask::AdjacencyUpperLeft.0;
        #[doc(alias = "SKTileAdjacencyLowerRightCorner")]
        const AdjacencyLowerRightCorner = SKTileAdjacencyMask::AdjacencyUp.0|SKTileAdjacencyMask::AdjacencyUpperRight.0|SKTileAdjacencyMask::AdjacencyRight.0|SKTileAdjacencyMask::AdjacencyLowerRight.0|SKTileAdjacencyMask::AdjacencyDown.0|SKTileAdjacencyMask::AdjacencyLowerLeft.0|SKTileAdjacencyMask::AdjacencyLeft.0;
        #[doc(alias = "SKTileAdjacencyLowerLeftCorner")]
        const AdjacencyLowerLeftCorner = SKTileAdjacencyMask::AdjacencyUp.0|SKTileAdjacencyMask::AdjacencyRight.0|SKTileAdjacencyMask::AdjacencyLowerRight.0|SKTileAdjacencyMask::AdjacencyDown.0|SKTileAdjacencyMask::AdjacencyLowerLeft.0|SKTileAdjacencyMask::AdjacencyLeft.0|SKTileAdjacencyMask::AdjacencyUpperLeft.0;
        #[doc(alias = "SKTileAdjacencyUpperLeftCorner")]
        const AdjacencyUpperLeftCorner = SKTileAdjacencyMask::AdjacencyUp.0|SKTileAdjacencyMask::AdjacencyUpperRight.0|SKTileAdjacencyMask::AdjacencyRight.0|SKTileAdjacencyMask::AdjacencyDown.0|SKTileAdjacencyMask::AdjacencyLowerLeft.0|SKTileAdjacencyMask::AdjacencyLeft.0|SKTileAdjacencyMask::AdjacencyUpperLeft.0;
    }
}

unsafe impl Encode for SKTileAdjacencyMask {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for SKTileAdjacencyMask {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// A tile set contains all of the tile definitions that are available for use in a tile map. In addition, it also contains tile groups, which define collections of related tile definitions and the rules that govern their placement.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/sktileset?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SKTileSet;
);

extern_conformance!(
    unsafe impl NSCoding for SKTileSet {}
);

extern_conformance!(
    unsafe impl NSCopying for SKTileSet {}
);

unsafe impl CopyingHelper for SKTileSet {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for SKTileSet {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for SKTileSet {}
);

impl SKTileSet {
    extern_methods!(
        /// Create a tile set with the specified tile groups.
        ///
        /// Parameter `tileGroups`: the tile groups that will be available for use with this set
        #[unsafe(method(tileSetWithTileGroups:))]
        #[unsafe(method_family = none)]
        pub unsafe fn tileSetWithTileGroups(tile_groups: &NSArray<SKTileGroup>) -> Retained<Self>;

        /// Create a tile set with the specified tile groups and tile set type.
        ///
        /// Parameter `tileGroups`: the tile groups that will be available for use with this set
        ///
        /// Parameter `tileSetType`: the type of tile set this will be
        #[unsafe(method(tileSetWithTileGroups:tileSetType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn tileSetWithTileGroups_tileSetType(
            tile_groups: &NSArray<SKTileGroup>,
            tile_set_type: SKTileSetType,
        ) -> Retained<Self>;

        /// Initilize a tile set with the specified tile groups.
        ///
        /// Parameter `tileGroups`: the tile groups that will be available for use with this set
        #[unsafe(method(initWithTileGroups:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithTileGroups(
            this: Allocated<Self>,
            tile_groups: &NSArray<SKTileGroup>,
        ) -> Retained<Self>;

        /// Initilize a tile set with the specified tile groups and tile set type.
        ///
        /// Parameter `tileGroups`: the tile groups that will be available for use with this set
        ///
        /// Parameter `tileSetType`: the type of tile set this will be
        #[unsafe(method(initWithTileGroups:tileSetType:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithTileGroups_tileSetType(
            this: Allocated<Self>,
            tile_groups: &NSArray<SKTileGroup>,
            tile_set_type: SKTileSetType,
        ) -> Retained<Self>;

        /// Gets the tile set with the specified name from the SpriteKit resource bundle. Returns nil if a tile set with a matching name cannot be found.
        ///
        /// Parameter `name`: the name of the tile set to search for
        #[unsafe(method(tileSetNamed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn tileSetNamed(name: &NSString) -> Option<Retained<Self>>;

        /// Creates a tile set from the specified tile set file. Returns nil if the URL doesn't point to a valid tile set file.
        ///
        /// Parameter `url`: the URL of the tile set file
        #[unsafe(method(tileSetFromURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn tileSetFromURL(url: &NSURL) -> Option<Retained<Self>>;

        /// The tile groups that this set provides for use.
        #[unsafe(method(tileGroups))]
        #[unsafe(method_family = none)]
        pub unsafe fn tileGroups(&self) -> Retained<NSArray<SKTileGroup>>;

        /// Setter for [`tileGroups`][Self::tileGroups].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setTileGroups:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTileGroups(&self, tile_groups: &NSArray<SKTileGroup>);

        /// Client-assignable name for the tile set. 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>);

        /// The tile set type specifies how the tiles in the set will be arranged when placed in a tile map. Defaults to SKTileSetTypeGrid.
        #[unsafe(method(type))]
        #[unsafe(method_family = none)]
        pub unsafe fn r#type(&self) -> SKTileSetType;

        /// Setter for [`type`][Self::type].
        #[unsafe(method(setType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setType(&self, r#type: SKTileSetType);

        #[unsafe(method(defaultTileGroup))]
        #[unsafe(method_family = none)]
        pub unsafe fn defaultTileGroup(&self) -> Option<Retained<SKTileGroup>>;

        /// Setter for [`defaultTileGroup`][Self::defaultTileGroup].
        #[unsafe(method(setDefaultTileGroup:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDefaultTileGroup(&self, default_tile_group: Option<&SKTileGroup>);

        #[cfg(feature = "objc2-core-foundation")]
        /// The default tile size is the value an SKTileMapNode will use for it's tiles when the tile set is assigned to it.
        #[unsafe(method(defaultTileSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn defaultTileSize(&self) -> CGSize;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`defaultTileSize`][Self::defaultTileSize].
        #[unsafe(method(setDefaultTileSize:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDefaultTileSize(&self, default_tile_size: CGSize);
    );
}

/// Methods declared on superclass `NSObject`.
impl SKTileSet {
    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>;
    );
}

extern_class!(
    /// A tile group encapsulates a collection of related tile definitions that are designed to be pieced together within a tile map. How those tiles are pieced together is governed by the set of rules. When a tile group is placed in a tile map, the map evaluates the rules to determine which tiles should be placed to achieve the desired outcome.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/sktilegroup?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SKTileGroup;
);

extern_conformance!(
    unsafe impl NSCoding for SKTileGroup {}
);

extern_conformance!(
    unsafe impl NSCopying for SKTileGroup {}
);

unsafe impl CopyingHelper for SKTileGroup {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for SKTileGroup {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for SKTileGroup {}
);

impl SKTileGroup {
    extern_methods!(
        #[cfg(feature = "SKTileDefinition")]
        /// Create a simple tile group for a single tile definition. This creates and initializes the SKTileGroupRule necessary to place the provided tile definition in a tile map.
        ///
        /// Parameter `tileDefinition`: the tile definition we wish to place in a tile map
        #[unsafe(method(tileGroupWithTileDefinition:))]
        #[unsafe(method_family = none)]
        pub unsafe fn tileGroupWithTileDefinition(
            tile_definition: &SKTileDefinition,
        ) -> Retained<Self>;

        /// Create a tile group with the specified rules.
        ///
        /// Parameter `rules`: the rules the group will use to determine tile placement
        #[unsafe(method(tileGroupWithRules:))]
        #[unsafe(method_family = none)]
        pub unsafe fn tileGroupWithRules(rules: &NSArray<SKTileGroupRule>) -> Retained<Self>;

        /// Create an empty tile group. Placing this in a tile map will erase the existing tile at that location.
        #[unsafe(method(emptyTileGroup))]
        #[unsafe(method_family = none)]
        pub unsafe fn emptyTileGroup() -> Retained<Self>;

        #[cfg(feature = "SKTileDefinition")]
        /// Initilize a simple tile group for a single tile definition. This creates and initializes the SKTileGroupRule necessary to place the provided tile definition in a tile map.
        ///
        /// Parameter `tileDefinition`: tile definition we wish to place in a tile map
        #[unsafe(method(initWithTileDefinition:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithTileDefinition(
            this: Allocated<Self>,
            tile_definition: &SKTileDefinition,
        ) -> Retained<Self>;

        /// Initilize a tile group with the specified rules.
        ///
        /// Parameter `rules`: the rules the group will use to determine tile placement
        #[unsafe(method(initWithRules:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithRules(
            this: Allocated<Self>,
            rules: &NSArray<SKTileGroupRule>,
        ) -> Retained<Self>;

        /// The rules that govern which tiles are placed when this group is used, and where in the map they'll be placed.
        #[unsafe(method(rules))]
        #[unsafe(method_family = none)]
        pub unsafe fn rules(&self) -> Retained<NSArray<SKTileGroupRule>>;

        /// Setter for [`rules`][Self::rules].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setRules:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRules(&self, rules: &NSArray<SKTileGroupRule>);

        /// Client-assignable name for the tile group. 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>);
    );
}

/// Methods declared on superclass `NSObject`.
impl SKTileGroup {
    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>;
    );
}

extern_class!(
    /// A tile group rule defines how a certain type of tile should be placed on the map. These tiles are like puzzle pieces, and the rules define how they should be pieced together. This is accomplished by defining which neighboring spaces need to be filled with tiles that belong to the same group, and which tiles are required to be empty. The required pattern of neighboring tiles is defined using the SKTileAdjacencyMask.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/sktilegrouprule?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SKTileGroupRule;
);

extern_conformance!(
    unsafe impl NSCoding for SKTileGroupRule {}
);

extern_conformance!(
    unsafe impl NSCopying for SKTileGroupRule {}
);

unsafe impl CopyingHelper for SKTileGroupRule {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for SKTileGroupRule {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for SKTileGroupRule {}
);

impl SKTileGroupRule {
    extern_methods!(
        #[cfg(feature = "SKTileDefinition")]
        /// Create a tile group rule with the specified adjacency and tile definitions.
        ///
        /// Parameter `adjacency`: the adjacency requirements for this rule; use the mask that covers the adjacent spaces that must be filled with tiles belonging to the same group; tiles not masked out must be empty
        ///
        /// Parameter `tileDefinitions`: the tile definitions used for this rule
        #[unsafe(method(tileGroupRuleWithAdjacency:tileDefinitions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn tileGroupRuleWithAdjacency_tileDefinitions(
            adjacency: SKTileAdjacencyMask,
            tile_definitions: &NSArray<SKTileDefinition>,
        ) -> Retained<Self>;

        #[cfg(feature = "SKTileDefinition")]
        /// Initilize a tile group rule with the specified adjacency and tile definitions.
        ///
        /// Parameter `adjacency`: the adjacency requirements for this rule; use the mask that covers the adjacent spaces that must be filled with tiles belonging to the same group; tiles not masked out must be empty
        ///
        /// Parameter `tileDefinitions`: the tile definitions used for this rule
        #[unsafe(method(initWithAdjacency:tileDefinitions:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithAdjacency_tileDefinitions(
            this: Allocated<Self>,
            adjacency: SKTileAdjacencyMask,
            tile_definitions: &NSArray<SKTileDefinition>,
        ) -> Retained<Self>;

        /// The adjacency mask used by this rule. Set this to the mask that covers the adjacent spaces that must be filled with tiles belonging to the same group for this rule met.
        #[unsafe(method(adjacency))]
        #[unsafe(method_family = none)]
        pub unsafe fn adjacency(&self) -> SKTileAdjacencyMask;

        /// Setter for [`adjacency`][Self::adjacency].
        #[unsafe(method(setAdjacency:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAdjacency(&self, adjacency: SKTileAdjacencyMask);

        #[cfg(feature = "SKTileDefinition")]
        /// The tile definitions used by this rule. If the rule is evaluated and its conditions are met, one of the tile definitions within this array will be randomly selected for placement within the tile map. Each tile definitions' placement weight is taken into consideration to determine how likely each is to be selected; tile definitions with higher placement weights will be selected more frequently than those with lower placement weights.
        #[unsafe(method(tileDefinitions))]
        #[unsafe(method_family = none)]
        pub unsafe fn tileDefinitions(&self) -> Retained<NSArray<SKTileDefinition>>;

        #[cfg(feature = "SKTileDefinition")]
        /// Setter for [`tileDefinitions`][Self::tileDefinitions].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setTileDefinitions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTileDefinitions(&self, tile_definitions: &NSArray<SKTileDefinition>);

        /// Client-assignable name for the tile group rule. 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>);
    );
}

/// Methods declared on superclass `NSObject`.
impl SKTileGroupRule {
    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>;
    );
}