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