objc2_gameplay_kit/generated/
GKAgent.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_protocol!(
11    /// Delegate that will receive messages regarding GKAgent updates.
12    ///
13    /// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkagentdelegate?language=objc)
14    pub unsafe trait GKAgentDelegate: NSObjectProtocol {
15        #[cfg(feature = "GKComponent")]
16        #[optional]
17        #[unsafe(method(agentWillUpdate:))]
18        #[unsafe(method_family = none)]
19        unsafe fn agentWillUpdate(&self, agent: &GKAgent);
20
21        #[cfg(feature = "GKComponent")]
22        #[optional]
23        #[unsafe(method(agentDidUpdate:))]
24        #[unsafe(method_family = none)]
25        unsafe fn agentDidUpdate(&self, agent: &GKAgent);
26    }
27);
28
29extern_class!(
30    /// An agent is a point mass whose local coordinate system is aligned to its velocity.  Agents have a variety of
31    /// steering functions that can be used to simulate vehicles or entities with agency.
32    /// The units of mass, velocity and radius are dimensionless but related. The visual representation of these values
33    /// are specific to each game's own situation.
34    ///
35    ///
36    /// Values close to 1.0 should be canonical and are expected to yield pleasing results. When applied to visuals
37    /// these values should be scaled and biased into their target coordinate system and a simple filter on top ensures
38    /// any noise generated from the steering logic doesn't affect the visual represtentation.
39    ///
40    /// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkagent?language=objc)
41    #[unsafe(super(GKComponent, NSObject))]
42    #[derive(Debug, PartialEq, Eq, Hash)]
43    #[cfg(feature = "GKComponent")]
44    pub struct GKAgent;
45);
46
47#[cfg(feature = "GKComponent")]
48extern_conformance!(
49    unsafe impl NSCoding for GKAgent {}
50);
51
52#[cfg(feature = "GKComponent")]
53extern_conformance!(
54    unsafe impl NSCopying for GKAgent {}
55);
56
57#[cfg(feature = "GKComponent")]
58unsafe impl CopyingHelper for GKAgent {
59    type Result = Self;
60}
61
62#[cfg(feature = "GKComponent")]
63extern_conformance!(
64    unsafe impl NSObjectProtocol for GKAgent {}
65);
66
67#[cfg(feature = "GKComponent")]
68extern_conformance!(
69    unsafe impl NSSecureCoding for GKAgent {}
70);
71
72#[cfg(feature = "GKComponent")]
73impl GKAgent {
74    extern_methods!(
75        /// Object which has agentDidUpdate called on it during this agent's behavior updatekbeha
76        #[unsafe(method(delegate))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn GKAgentDelegate>>>;
79
80        /// Setter for [`delegate`][Self::delegate].
81        ///
82        /// This is a [weak property][objc2::topics::weak_property].
83        #[unsafe(method(setDelegate:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn GKAgentDelegate>>);
86
87        #[cfg(feature = "GKBehavior")]
88        /// The behavior to apply when updateWithDeltaTime is called.
89        /// All forces from the goals in the behavior are summed and then applied.
90        #[unsafe(method(behavior))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn behavior(&self) -> Option<Retained<GKBehavior>>;
93
94        #[cfg(feature = "GKBehavior")]
95        /// Setter for [`behavior`][Self::behavior].
96        #[unsafe(method(setBehavior:))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn setBehavior(&self, behavior: Option<&GKBehavior>);
99
100        /// Agent's mass. Used for agent impulse application purposes.
101        ///
102        /// Defaults to 1.0
103        #[unsafe(method(mass))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn mass(&self) -> c_float;
106
107        /// Setter for [`mass`][Self::mass].
108        #[unsafe(method(setMass:))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn setMass(&self, mass: c_float);
111
112        /// Radius of the agent's bounding circle.  Used by the agent avoid steering functions.
113        ///
114        /// Defaults to 0.5 for a canonical diameter of 1.0
115        #[unsafe(method(radius))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn radius(&self) -> c_float;
118
119        /// Setter for [`radius`][Self::radius].
120        #[unsafe(method(setRadius:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn setRadius(&self, radius: c_float);
123
124        /// Current speed of the agent along its foward direction.
125        ///
126        /// Defaults to 0.0
127        #[unsafe(method(speed))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn speed(&self) -> c_float;
130
131        /// Setter for [`speed`][Self::speed].
132        #[unsafe(method(setSpeed:))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn setSpeed(&self, speed: c_float);
135
136        /// Maximum amount of acceleration that can be applied to this agent.  All applied impulses are clipped to this amount.
137        ///
138        /// Defaults to 1.0
139        #[unsafe(method(maxAcceleration))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn maxAcceleration(&self) -> c_float;
142
143        /// Setter for [`maxAcceleration`][Self::maxAcceleration].
144        #[unsafe(method(setMaxAcceleration:))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn setMaxAcceleration(&self, max_acceleration: c_float);
147
148        /// Maximum speed of this agent. Impulses cannot cause the agents speed to ever be greater than this value.
149        ///
150        /// Defaults to 1.0
151        #[unsafe(method(maxSpeed))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn maxSpeed(&self) -> c_float;
154
155        /// Setter for [`maxSpeed`][Self::maxSpeed].
156        #[unsafe(method(setMaxSpeed:))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn setMaxSpeed(&self, max_speed: c_float);
159    );
160}
161
162/// Methods declared on superclass `NSObject`.
163#[cfg(feature = "GKComponent")]
164impl GKAgent {
165    extern_methods!(
166        #[unsafe(method(init))]
167        #[unsafe(method_family = init)]
168        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
169
170        #[unsafe(method(new))]
171        #[unsafe(method_family = new)]
172        pub unsafe fn new() -> Retained<Self>;
173    );
174}
175
176extern_class!(
177    /// A 2D specalization of an agent that moves on a 2-axis logical coordinate system. This coordinate system does not
178    /// need to match the visual coordinate system of the delegate. One simple case of that is isometric 2D content where the
179    /// game model is on a flat 2D plane but the visuals are displayed on an angle where one of the logical axes are used for
180    /// simulated depth as well as some translation in the display plane.
181    ///
182    /// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkagent2d?language=objc)
183    #[unsafe(super(GKAgent, GKComponent, NSObject))]
184    #[derive(Debug, PartialEq, Eq, Hash)]
185    #[cfg(feature = "GKComponent")]
186    pub struct GKAgent2D;
187);
188
189#[cfg(feature = "GKComponent")]
190extern_conformance!(
191    unsafe impl NSCoding for GKAgent2D {}
192);
193
194#[cfg(feature = "GKComponent")]
195extern_conformance!(
196    unsafe impl NSCopying for GKAgent2D {}
197);
198
199#[cfg(feature = "GKComponent")]
200unsafe impl CopyingHelper for GKAgent2D {
201    type Result = Self;
202}
203
204#[cfg(feature = "GKComponent")]
205extern_conformance!(
206    unsafe impl NSObjectProtocol for GKAgent2D {}
207);
208
209#[cfg(feature = "GKComponent")]
210extern_conformance!(
211    unsafe impl NSSecureCoding for GKAgent2D {}
212);
213
214#[cfg(feature = "GKComponent")]
215impl GKAgent2D {
216    extern_methods!(
217        /// Z rotation of the agent on the logical XY plane
218        #[unsafe(method(rotation))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn rotation(&self) -> c_float;
221
222        /// Setter for [`rotation`][Self::rotation].
223        #[unsafe(method(setRotation:))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn setRotation(&self, rotation: c_float);
226
227        /// Overridden from GKComponent.
228        /// Updates this agent with the current behavior, generating a force to reach its goals and applying that force.
229        #[unsafe(method(updateWithDeltaTime:))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn updateWithDeltaTime(&self, seconds: NSTimeInterval);
232    );
233}
234
235/// Methods declared on superclass `NSObject`.
236#[cfg(feature = "GKComponent")]
237impl GKAgent2D {
238    extern_methods!(
239        #[unsafe(method(init))]
240        #[unsafe(method_family = init)]
241        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
242
243        #[unsafe(method(new))]
244        #[unsafe(method_family = new)]
245        pub unsafe fn new() -> Retained<Self>;
246    );
247}
248
249extern_class!(
250    /// A 3D specialization of an agent that moves on a 3-axis logical coordinate system.
251    ///
252    /// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkagent3d?language=objc)
253    #[unsafe(super(GKAgent, GKComponent, NSObject))]
254    #[derive(Debug, PartialEq, Eq, Hash)]
255    #[cfg(feature = "GKComponent")]
256    pub struct GKAgent3D;
257);
258
259#[cfg(feature = "GKComponent")]
260extern_conformance!(
261    unsafe impl NSCoding for GKAgent3D {}
262);
263
264#[cfg(feature = "GKComponent")]
265extern_conformance!(
266    unsafe impl NSCopying for GKAgent3D {}
267);
268
269#[cfg(feature = "GKComponent")]
270unsafe impl CopyingHelper for GKAgent3D {
271    type Result = Self;
272}
273
274#[cfg(feature = "GKComponent")]
275extern_conformance!(
276    unsafe impl NSObjectProtocol for GKAgent3D {}
277);
278
279#[cfg(feature = "GKComponent")]
280extern_conformance!(
281    unsafe impl NSSecureCoding for GKAgent3D {}
282);
283
284#[cfg(feature = "GKComponent")]
285impl GKAgent3D {
286    extern_methods!(
287        /// Should this vehicle operate in a right-handed coordinate system? NO means it will be left-handed
288        #[unsafe(method(rightHanded))]
289        #[unsafe(method_family = none)]
290        pub unsafe fn rightHanded(&self) -> bool;
291
292        /// Setter for [`rightHanded`][Self::rightHanded].
293        #[unsafe(method(setRightHanded:))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn setRightHanded(&self, right_handed: bool);
296
297        /// Overridden from GKComponent.
298        /// Updates this agent with the current behavior, generating a force to reach its goals and applying that force.
299        #[unsafe(method(updateWithDeltaTime:))]
300        #[unsafe(method_family = none)]
301        pub unsafe fn updateWithDeltaTime(&self, seconds: NSTimeInterval);
302    );
303}
304
305/// Methods declared on superclass `NSObject`.
306#[cfg(feature = "GKComponent")]
307impl GKAgent3D {
308    extern_methods!(
309        #[unsafe(method(init))]
310        #[unsafe(method_family = init)]
311        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
312
313        #[unsafe(method(new))]
314        #[unsafe(method_family = new)]
315        pub unsafe fn new() -> Retained<Self>;
316    );
317}