objc2_sprite_kit/generated/
SKPhysicsWorld.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
12extern_protocol!(
13    /// [Apple's documentation](https://developer.apple.com/documentation/spritekit/skphysicscontactdelegate?language=objc)
14    pub unsafe trait SKPhysicsContactDelegate: NSObjectProtocol {
15        #[cfg(feature = "SKPhysicsContact")]
16        #[optional]
17        #[unsafe(method(didBeginContact:))]
18        #[unsafe(method_family = none)]
19        unsafe fn didBeginContact(&self, contact: &SKPhysicsContact);
20
21        #[cfg(feature = "SKPhysicsContact")]
22        #[optional]
23        #[unsafe(method(didEndContact:))]
24        #[unsafe(method_family = none)]
25        unsafe fn didEndContact(&self, contact: &SKPhysicsContact);
26    }
27);
28
29extern_class!(
30    /// [Apple's documentation](https://developer.apple.com/documentation/spritekit/skphysicsworld?language=objc)
31    #[unsafe(super(NSObject))]
32    #[derive(Debug, PartialEq, Eq, Hash)]
33    pub struct SKPhysicsWorld;
34);
35
36extern_conformance!(
37    unsafe impl NSCoding for SKPhysicsWorld {}
38);
39
40extern_conformance!(
41    unsafe impl NSObjectProtocol for SKPhysicsWorld {}
42);
43
44extern_conformance!(
45    unsafe impl NSSecureCoding for SKPhysicsWorld {}
46);
47
48impl SKPhysicsWorld {
49    extern_methods!(
50        #[cfg(feature = "objc2-core-foundation")]
51        /// A global 2D vector specifying the field force acceleration due to gravity. The unit is meters per second so standard earth gravity would be { 0.0, +/-9.8 }.
52        #[unsafe(method(gravity))]
53        #[unsafe(method_family = none)]
54        pub unsafe fn gravity(&self) -> CGVector;
55
56        #[cfg(feature = "objc2-core-foundation")]
57        /// Setter for [`gravity`][Self::gravity].
58        #[unsafe(method(setGravity:))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn setGravity(&self, gravity: CGVector);
61
62        #[cfg(feature = "objc2-core-foundation")]
63        #[unsafe(method(speed))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn speed(&self) -> CGFloat;
66
67        #[cfg(feature = "objc2-core-foundation")]
68        /// Setter for [`speed`][Self::speed].
69        #[unsafe(method(setSpeed:))]
70        #[unsafe(method_family = none)]
71        pub unsafe fn setSpeed(&self, speed: CGFloat);
72
73        /// # Safety
74        ///
75        /// This is not retained internally, you must ensure the object is still alive.
76        #[unsafe(method(contactDelegate))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn contactDelegate(
79            &self,
80        ) -> Option<Retained<ProtocolObject<dyn SKPhysicsContactDelegate>>>;
81
82        /// Setter for [`contactDelegate`][Self::contactDelegate].
83        ///
84        /// # Safety
85        ///
86        /// This is unretained, you must ensure the object is kept alive while in use.
87        #[unsafe(method(setContactDelegate:))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn setContactDelegate(
90            &self,
91            contact_delegate: Option<&ProtocolObject<dyn SKPhysicsContactDelegate>>,
92        );
93
94        #[cfg(feature = "SKPhysicsJoint")]
95        #[unsafe(method(addJoint:))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn addJoint(&self, joint: &SKPhysicsJoint);
98
99        #[cfg(feature = "SKPhysicsJoint")]
100        #[unsafe(method(removeJoint:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn removeJoint(&self, joint: &SKPhysicsJoint);
103
104        #[unsafe(method(removeAllJoints))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn removeAllJoints(&self);
107
108        #[cfg(all(feature = "SKPhysicsBody", feature = "objc2-core-foundation"))]
109        #[unsafe(method(bodyAtPoint:))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn bodyAtPoint(&self, point: CGPoint) -> Option<Retained<SKPhysicsBody>>;
112
113        #[cfg(all(feature = "SKPhysicsBody", feature = "objc2-core-foundation"))]
114        #[unsafe(method(bodyInRect:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn bodyInRect(&self, rect: CGRect) -> Option<Retained<SKPhysicsBody>>;
117
118        #[cfg(all(feature = "SKPhysicsBody", feature = "objc2-core-foundation"))]
119        #[unsafe(method(bodyAlongRayStart:end:))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn bodyAlongRayStart_end(
122            &self,
123            start: CGPoint,
124            end: CGPoint,
125        ) -> Option<Retained<SKPhysicsBody>>;
126
127        #[cfg(all(
128            feature = "SKPhysicsBody",
129            feature = "block2",
130            feature = "objc2-core-foundation"
131        ))]
132        #[unsafe(method(enumerateBodiesAtPoint:usingBlock:))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn enumerateBodiesAtPoint_usingBlock(
135            &self,
136            point: CGPoint,
137            block: &block2::DynBlock<dyn Fn(NonNull<SKPhysicsBody>, NonNull<Bool>)>,
138        );
139
140        #[cfg(all(
141            feature = "SKPhysicsBody",
142            feature = "block2",
143            feature = "objc2-core-foundation"
144        ))]
145        #[unsafe(method(enumerateBodiesInRect:usingBlock:))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn enumerateBodiesInRect_usingBlock(
148            &self,
149            rect: CGRect,
150            block: &block2::DynBlock<dyn Fn(NonNull<SKPhysicsBody>, NonNull<Bool>)>,
151        );
152
153        #[cfg(all(
154            feature = "SKPhysicsBody",
155            feature = "block2",
156            feature = "objc2-core-foundation"
157        ))]
158        #[unsafe(method(enumerateBodiesAlongRayStart:end:usingBlock:))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn enumerateBodiesAlongRayStart_end_usingBlock(
161            &self,
162            start: CGPoint,
163            end: CGPoint,
164            block: &block2::DynBlock<
165                dyn Fn(NonNull<SKPhysicsBody>, CGPoint, CGVector, NonNull<Bool>),
166            >,
167        );
168    );
169}
170
171/// Methods declared on superclass `NSObject`.
172impl SKPhysicsWorld {
173    extern_methods!(
174        #[unsafe(method(init))]
175        #[unsafe(method_family = init)]
176        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
177
178        #[unsafe(method(new))]
179        #[unsafe(method_family = new)]
180        pub unsafe fn new() -> Retained<Self>;
181    );
182}