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
//! 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::*;
use objc2_foundation::*;
use crate::*;
extern_protocol!(
/// Delegate that will receive messages regarding GKAgent updates.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkagentdelegate?language=objc)
pub unsafe trait GKAgentDelegate: NSObjectProtocol {
#[cfg(feature = "GKComponent")]
#[optional]
#[unsafe(method(agentWillUpdate:))]
#[unsafe(method_family = none)]
unsafe fn agentWillUpdate(&self, agent: &GKAgent);
#[cfg(feature = "GKComponent")]
#[optional]
#[unsafe(method(agentDidUpdate:))]
#[unsafe(method_family = none)]
unsafe fn agentDidUpdate(&self, agent: &GKAgent);
}
);
extern_class!(
/// An agent is a point mass whose local coordinate system is aligned to its velocity. Agents have a variety of
/// steering functions that can be used to simulate vehicles or entities with agency.
/// The units of mass, velocity and radius are dimensionless but related. The visual representation of these values
/// are specific to each game's own situation.
///
///
/// Values close to 1.0 should be canonical and are expected to yield pleasing results. When applied to visuals
/// these values should be scaled and biased into their target coordinate system and a simple filter on top ensures
/// any noise generated from the steering logic doesn't affect the visual represtentation.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkagent?language=objc)
#[unsafe(super(GKComponent, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "GKComponent")]
pub struct GKAgent;
);
#[cfg(feature = "GKComponent")]
extern_conformance!(
unsafe impl NSCoding for GKAgent {}
);
#[cfg(feature = "GKComponent")]
extern_conformance!(
unsafe impl NSCopying for GKAgent {}
);
#[cfg(feature = "GKComponent")]
unsafe impl CopyingHelper for GKAgent {
type Result = Self;
}
#[cfg(feature = "GKComponent")]
extern_conformance!(
unsafe impl NSObjectProtocol for GKAgent {}
);
#[cfg(feature = "GKComponent")]
extern_conformance!(
unsafe impl NSSecureCoding for GKAgent {}
);
#[cfg(feature = "GKComponent")]
impl GKAgent {
extern_methods!(
/// Object which has agentDidUpdate called on it during this agent's behavior updatekbeha
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn GKAgentDelegate>>>;
/// Setter for [`delegate`][Self::delegate].
///
/// This is a [weak property][objc2::topics::weak_property].
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn GKAgentDelegate>>);
#[cfg(feature = "GKBehavior")]
/// The behavior to apply when updateWithDeltaTime is called.
/// All forces from the goals in the behavior are summed and then applied.
#[unsafe(method(behavior))]
#[unsafe(method_family = none)]
pub unsafe fn behavior(&self) -> Option<Retained<GKBehavior>>;
#[cfg(feature = "GKBehavior")]
/// Setter for [`behavior`][Self::behavior].
#[unsafe(method(setBehavior:))]
#[unsafe(method_family = none)]
pub unsafe fn setBehavior(&self, behavior: Option<&GKBehavior>);
/// Agent's mass. Used for agent impulse application purposes.
///
/// Defaults to 1.0
#[unsafe(method(mass))]
#[unsafe(method_family = none)]
pub unsafe fn mass(&self) -> c_float;
/// Setter for [`mass`][Self::mass].
#[unsafe(method(setMass:))]
#[unsafe(method_family = none)]
pub unsafe fn setMass(&self, mass: c_float);
/// Radius of the agent's bounding circle. Used by the agent avoid steering functions.
///
/// Defaults to 0.5 for a canonical diameter of 1.0
#[unsafe(method(radius))]
#[unsafe(method_family = none)]
pub unsafe fn radius(&self) -> c_float;
/// Setter for [`radius`][Self::radius].
#[unsafe(method(setRadius:))]
#[unsafe(method_family = none)]
pub unsafe fn setRadius(&self, radius: c_float);
/// Current speed of the agent along its foward direction.
///
/// Defaults to 0.0
#[unsafe(method(speed))]
#[unsafe(method_family = none)]
pub unsafe fn speed(&self) -> c_float;
/// Setter for [`speed`][Self::speed].
#[unsafe(method(setSpeed:))]
#[unsafe(method_family = none)]
pub unsafe fn setSpeed(&self, speed: c_float);
/// Maximum amount of acceleration that can be applied to this agent. All applied impulses are clipped to this amount.
///
/// Defaults to 1.0
#[unsafe(method(maxAcceleration))]
#[unsafe(method_family = none)]
pub unsafe fn maxAcceleration(&self) -> c_float;
/// Setter for [`maxAcceleration`][Self::maxAcceleration].
#[unsafe(method(setMaxAcceleration:))]
#[unsafe(method_family = none)]
pub unsafe fn setMaxAcceleration(&self, max_acceleration: c_float);
/// Maximum speed of this agent. Impulses cannot cause the agents speed to ever be greater than this value.
///
/// Defaults to 1.0
#[unsafe(method(maxSpeed))]
#[unsafe(method_family = none)]
pub unsafe fn maxSpeed(&self) -> c_float;
/// Setter for [`maxSpeed`][Self::maxSpeed].
#[unsafe(method(setMaxSpeed:))]
#[unsafe(method_family = none)]
pub unsafe fn setMaxSpeed(&self, max_speed: c_float);
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(feature = "GKComponent")]
impl GKAgent {
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 2D specalization of an agent that moves on a 2-axis logical coordinate system. This coordinate system does not
/// need to match the visual coordinate system of the delegate. One simple case of that is isometric 2D content where the
/// 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
/// simulated depth as well as some translation in the display plane.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkagent2d?language=objc)
#[unsafe(super(GKAgent, GKComponent, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "GKComponent")]
pub struct GKAgent2D;
);
#[cfg(feature = "GKComponent")]
extern_conformance!(
unsafe impl NSCoding for GKAgent2D {}
);
#[cfg(feature = "GKComponent")]
extern_conformance!(
unsafe impl NSCopying for GKAgent2D {}
);
#[cfg(feature = "GKComponent")]
unsafe impl CopyingHelper for GKAgent2D {
type Result = Self;
}
#[cfg(feature = "GKComponent")]
extern_conformance!(
unsafe impl NSObjectProtocol for GKAgent2D {}
);
#[cfg(feature = "GKComponent")]
extern_conformance!(
unsafe impl NSSecureCoding for GKAgent2D {}
);
#[cfg(feature = "GKComponent")]
impl GKAgent2D {
extern_methods!(
/// Z rotation of the agent on the logical XY plane
#[unsafe(method(rotation))]
#[unsafe(method_family = none)]
pub unsafe fn rotation(&self) -> c_float;
/// Setter for [`rotation`][Self::rotation].
#[unsafe(method(setRotation:))]
#[unsafe(method_family = none)]
pub unsafe fn setRotation(&self, rotation: c_float);
/// Overridden from GKComponent.
/// Updates this agent with the current behavior, generating a force to reach its goals and applying that force.
#[unsafe(method(updateWithDeltaTime:))]
#[unsafe(method_family = none)]
pub unsafe fn updateWithDeltaTime(&self, seconds: NSTimeInterval);
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(feature = "GKComponent")]
impl GKAgent2D {
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 3D specialization of an agent that moves on a 3-axis logical coordinate system.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkagent3d?language=objc)
#[unsafe(super(GKAgent, GKComponent, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "GKComponent")]
pub struct GKAgent3D;
);
#[cfg(feature = "GKComponent")]
extern_conformance!(
unsafe impl NSCoding for GKAgent3D {}
);
#[cfg(feature = "GKComponent")]
extern_conformance!(
unsafe impl NSCopying for GKAgent3D {}
);
#[cfg(feature = "GKComponent")]
unsafe impl CopyingHelper for GKAgent3D {
type Result = Self;
}
#[cfg(feature = "GKComponent")]
extern_conformance!(
unsafe impl NSObjectProtocol for GKAgent3D {}
);
#[cfg(feature = "GKComponent")]
extern_conformance!(
unsafe impl NSSecureCoding for GKAgent3D {}
);
#[cfg(feature = "GKComponent")]
impl GKAgent3D {
extern_methods!(
/// Should this vehicle operate in a right-handed coordinate system? NO means it will be left-handed
#[unsafe(method(rightHanded))]
#[unsafe(method_family = none)]
pub unsafe fn rightHanded(&self) -> bool;
/// Setter for [`rightHanded`][Self::rightHanded].
#[unsafe(method(setRightHanded:))]
#[unsafe(method_family = none)]
pub unsafe fn setRightHanded(&self, right_handed: bool);
/// Overridden from GKComponent.
/// Updates this agent with the current behavior, generating a force to reach its goals and applying that force.
#[unsafe(method(updateWithDeltaTime:))]
#[unsafe(method_family = none)]
pub unsafe fn updateWithDeltaTime(&self, seconds: NSTimeInterval);
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(feature = "GKComponent")]
impl GKAgent3D {
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>;
);
}