objc2_sprite_kit/generated/
SKFieldNode.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    /// [Apple's documentation](https://developer.apple.com/documentation/spritekit/skfieldnode?language=objc)
17    #[unsafe(super(SKNode, NSResponder, NSObject))]
18    #[derive(Debug, PartialEq, Eq, Hash)]
19    #[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
20    #[cfg(target_os = "macos")]
21    pub struct SKFieldNode;
22);
23
24#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
25#[cfg(target_os = "macos")]
26extern_conformance!(
27    unsafe impl NSCoding for SKFieldNode {}
28);
29
30#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
31#[cfg(target_os = "macos")]
32extern_conformance!(
33    unsafe impl NSCopying for SKFieldNode {}
34);
35
36#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
37#[cfg(target_os = "macos")]
38unsafe impl CopyingHelper for SKFieldNode {
39    type Result = Self;
40}
41
42#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
43#[cfg(target_os = "macos")]
44extern_conformance!(
45    unsafe impl NSObjectProtocol for SKFieldNode {}
46);
47
48#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
49#[cfg(target_os = "macos")]
50extern_conformance!(
51    unsafe impl NSSecureCoding for SKFieldNode {}
52);
53
54#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
55#[cfg(target_os = "macos")]
56impl SKFieldNode {
57    extern_methods!(
58        #[cfg(feature = "SKRegion")]
59        /// The region property is the domain of the field's effect. No force is applied to objects outside the region.
60        #[unsafe(method(region))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn region(&self) -> Option<Retained<SKRegion>>;
63
64        #[cfg(feature = "SKRegion")]
65        /// Setter for [`region`][Self::region].
66        #[unsafe(method(setRegion:))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn setRegion(&self, region: Option<&SKRegion>);
69
70        /// strength scaling value. default 1.0
71        #[unsafe(method(strength))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn strength(&self) -> c_float;
74
75        /// Setter for [`strength`][Self::strength].
76        #[unsafe(method(setStrength:))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn setStrength(&self, strength: c_float);
79
80        /// The falloff exponent used to calculate field strength at a distance.
81        /// Falloff starts at the minimum radius.
82        ///
83        /// The default exponent is zero, which results in a uniform field with no falloff.
84        ///
85        ///
86        /// See: minimumRadius
87        #[unsafe(method(falloff))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn falloff(&self) -> c_float;
90
91        /// Setter for [`falloff`][Self::falloff].
92        #[unsafe(method(setFalloff:))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn setFalloff(&self, falloff: c_float);
95
96        /// minimum radius of effect. Default is very small.
97        #[unsafe(method(minimumRadius))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn minimumRadius(&self) -> c_float;
100
101        /// Setter for [`minimumRadius`][Self::minimumRadius].
102        #[unsafe(method(setMinimumRadius:))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn setMinimumRadius(&self, minimum_radius: c_float);
105
106        /// If enabled, a field has an effect.
107        ///
108        /// default YES
109        #[unsafe(method(isEnabled))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn isEnabled(&self) -> bool;
112
113        /// Setter for [`isEnabled`][Self::isEnabled].
114        #[unsafe(method(setEnabled:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn setEnabled(&self, enabled: bool);
117
118        /// If a field is exclusive, it suppresses any other field in its region of effect.
119        /// If two or more exclusive fields overlap, it is undefined which one of them will take effect
120        ///
121        ///
122        /// See: region
123        #[unsafe(method(isExclusive))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn isExclusive(&self) -> bool;
126
127        /// Setter for [`isExclusive`][Self::isExclusive].
128        #[unsafe(method(setExclusive:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setExclusive(&self, exclusive: bool);
131
132        /// Logical categories the field belongs to. Default is all categories.
133        /// These categories correspond to fieldBitMasks, and can be used to enforce that a particular field applies
134        /// to a particular category of objects.
135        ///
136        ///
137        /// See: SKPhysicsBody.fieldBitMask
138        ///
139        /// See: SKEmitterNode.fieldBitMask
140        #[unsafe(method(categoryBitMask))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn categoryBitMask(&self) -> u32;
143
144        /// Setter for [`categoryBitMask`][Self::categoryBitMask].
145        #[unsafe(method(setCategoryBitMask:))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn setCategoryBitMask(&self, category_bit_mask: u32);
148
149        /// fields without a smoothness component will return 0
150        ///
151        ///
152        /// See: noiseFieldWithSmoothness:smoothness:animationSpeed
153        ///
154        /// See: turbulenceFieldWithSmoothness:smoothness:animationSpeed
155        #[unsafe(method(smoothness))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn smoothness(&self) -> c_float;
158
159        /// Setter for [`smoothness`][Self::smoothness].
160        #[unsafe(method(setSmoothness:))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn setSmoothness(&self, smoothness: c_float);
163
164        /// fields that can be animated can have non zero values.
165        ///
166        /// A value of 2 will animated twice as fast as a value of 1.
167        ///
168        ///
169        /// See: noiseFieldWithSmoothness:smoothness:animationSpeed
170        ///
171        /// See: turbulenceFieldWithSmoothness:smoothness:animationSpeed
172        #[unsafe(method(animationSpeed))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn animationSpeed(&self) -> c_float;
175
176        /// Setter for [`animationSpeed`][Self::animationSpeed].
177        #[unsafe(method(setAnimationSpeed:))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn setAnimationSpeed(&self, animation_speed: c_float);
180
181        #[cfg(feature = "SKTexture")]
182        /// fields constructed with a texture can be uppdated by assigning a new texture
183        ///
184        ///
185        /// See: velocityFieldWithTexture:velocityTexture
186        #[unsafe(method(texture))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn texture(&self) -> Option<Retained<SKTexture>>;
189
190        #[cfg(feature = "SKTexture")]
191        /// Setter for [`texture`][Self::texture].
192        #[unsafe(method(setTexture:))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn setTexture(&self, texture: Option<&SKTexture>);
195
196        /// Slows an object proportionally to the object’s velocity.
197        /// Use this to simulate effects such as friction from motion through the air.
198        #[unsafe(method(dragField))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn dragField(mtm: MainThreadMarker) -> Retained<SKFieldNode>;
201
202        /// Applies a force tangential to the direction from the sample point to the field's position.
203        /// The force will be CCW to the direction. Make the strength negative to apply force in the CW direction.
204        /// Amount is proportional to distance from center and the object's mass.
205        /// Use this to create effects such as tornadoes.
206        #[unsafe(method(vortexField))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn vortexField(mtm: MainThreadMarker) -> Retained<SKFieldNode>;
209
210        /// Applies a force in the direction of the origin of the field in local space. To repel objects, use a negative strength.
211        /// The force is proportional to the distance from the field origin. Varies with the mass of the object according to F = ma
212        /// The field node's rotation property can be used to orient the gravity in a particular direction.
213        #[unsafe(method(radialGravityField))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn radialGravityField(mtm: MainThreadMarker) -> Retained<SKFieldNode>;
216
217        #[cfg(feature = "SKTexture")]
218        /// The supplied texture contains velocity values for any object entering the field’s area of effect.
219        /// If no texture is supplied, the direction property is used instead.
220        /// Velocity fields override the effect of any other acceleration applied to the body.
221        /// Velocity fields are typically used for such effects as advection, for example, a velocity field
222        /// might describe the velocity on the surface of a river. An object placed in the river would then follow the river.
223        ///
224        ///
225        /// Parameter `velocityTexture`: The R and G channels of the supplied texture become x and y components of velocity. B and A, if present in the SKTexture, are ignored.
226        ///
227        ///
228        /// See: texture
229        #[unsafe(method(velocityFieldWithTexture:))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn velocityFieldWithTexture(
232            velocity_texture: &SKTexture,
233            mtm: MainThreadMarker,
234        ) -> Retained<SKFieldNode>;
235
236        #[cfg(feature = "objc2-core-foundation")]
237        /// A time varying differentiable Perlin simplex noise field. By default a smooth noise is calculated,
238        /// and the field is time varying. Use this to simulate such effects as fireflies, or snow.
239        /// To freeze the noise in place, set animationSpeed to 0.0. Mass is ignored.
240        ///
241        ///
242        /// Parameter `smoothness`: value of 0 means as noisy as possible, 1 means as smooth as possible
243        ///
244        /// Parameter `speed`: is the general rate in Hz that any particular texel changes to a different value
245        ///
246        ///
247        /// See: smoothness
248        ///
249        /// See: animationSpeed
250        #[unsafe(method(noiseFieldWithSmoothness:animationSpeed:))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn noiseFieldWithSmoothness_animationSpeed(
253            smoothness: CGFloat,
254            speed: CGFloat,
255            mtm: MainThreadMarker,
256        ) -> Retained<SKFieldNode>;
257
258        #[cfg(feature = "objc2-core-foundation")]
259        /// Just like Noise, except the strength of the noise is proportional to the velocity of the object in the field.
260        ///
261        ///
262        /// Parameter `smoothness`: value of 0 means as noisy as possible, 1 means as smooth as possible
263        ///
264        /// Parameter `speed`: is the general rate in Hz that any particular texel changes to a different value
265        ///
266        ///
267        /// See: smoothness
268        ///
269        /// See: animationSpeed
270        #[unsafe(method(turbulenceFieldWithSmoothness:animationSpeed:))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn turbulenceFieldWithSmoothness_animationSpeed(
273            smoothness: CGFloat,
274            speed: CGFloat,
275            mtm: MainThreadMarker,
276        ) -> Retained<SKFieldNode>;
277
278        /// A Hooke’s law force - a force linearly proportional to distance from the center of the field. An object in this
279        /// field will oscillate with a period proportional to the inverse of the mass.
280        /// An example use is to keep objects confined to a particular region.
281        #[unsafe(method(springField))]
282        #[unsafe(method_family = none)]
283        pub unsafe fn springField(mtm: MainThreadMarker) -> Retained<SKFieldNode>;
284
285        /// A force proportional to the charge on the object. A charge property has been
286        /// added to SKPhysicsBodies to accomplish this. An example use of this field is to make objects behavior differently
287        /// from one another when they enter a region, or to make an object's behavior different than its mass based behavior
288        /// This field models the first part of the Lorentz equation, F = qE
289        #[unsafe(method(electricField))]
290        #[unsafe(method_family = none)]
291        pub unsafe fn electricField(mtm: MainThreadMarker) -> Retained<SKFieldNode>;
292
293        /// A force proportional to the charge on the object and the object’s velocity. A charge property has been
294        /// added to SKPhysicsBodies to accomplish this. An example use of this field is to make objects behavior differently
295        /// from one another when they enter a region, or to make an object's behavior different than its mass based behavior
296        /// This field models the second part of the Lorentz equation, F = qvB
297        #[unsafe(method(magneticField))]
298        #[unsafe(method_family = none)]
299        pub unsafe fn magneticField(mtm: MainThreadMarker) -> Retained<SKFieldNode>;
300    );
301}
302
303/// Methods declared on superclass `SKNode`.
304#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
305#[cfg(target_os = "macos")]
306impl SKFieldNode {
307    extern_methods!(
308        #[unsafe(method(init))]
309        #[unsafe(method_family = init)]
310        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
311
312        /// Support coding and decoding via NSKeyedArchiver.
313        ///
314        /// # Safety
315        ///
316        /// `a_decoder` possibly has further requirements.
317        #[unsafe(method(initWithCoder:))]
318        #[unsafe(method_family = init)]
319        pub unsafe fn initWithCoder(
320            this: Allocated<Self>,
321            a_decoder: &NSCoder,
322        ) -> Option<Retained<Self>>;
323
324        #[unsafe(method(node))]
325        #[unsafe(method_family = none)]
326        pub unsafe fn node(mtm: MainThreadMarker) -> Retained<Self>;
327
328        #[unsafe(method(nodeWithFileNamed:))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn nodeWithFileNamed(
331            filename: &NSString,
332            mtm: MainThreadMarker,
333        ) -> Option<Retained<Self>>;
334
335        /// # Safety
336        ///
337        /// `classes` generic probably has further requirements.
338        #[unsafe(method(nodeWithFileNamed:securelyWithClasses:andError:_))]
339        #[unsafe(method_family = none)]
340        pub unsafe fn nodeWithFileNamed_securelyWithClasses_andError(
341            filename: &NSString,
342            classes: &NSSet<AnyClass>,
343            mtm: MainThreadMarker,
344        ) -> Result<Retained<Self>, Retained<NSError>>;
345    );
346}
347
348/// Methods declared on superclass `NSObject`.
349#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
350#[cfg(target_os = "macos")]
351impl SKFieldNode {
352    extern_methods!(
353        #[unsafe(method(new))]
354        #[unsafe(method_family = new)]
355        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
356    );
357}