objc2_gameplay_kit/generated/
GKObstacleGraph.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_class!(
11    /// A collection of GKGraphNodes that are governed by a set of extruded GKPolygonObstacles
12    ///
13    /// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkobstaclegraph?language=objc)
14    #[unsafe(super(GKGraph, NSObject))]
15    #[derive(Debug, PartialEq, Eq, Hash)]
16    #[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
17    pub struct GKObstacleGraph<NodeType: ?Sized = AnyObject>;
18);
19
20#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
21impl<NodeType: ?Sized + Message + AsRef<GKGraphNode2D>> GKObstacleGraph<NodeType> {
22    /// Unchecked conversion of the generic parameter.
23    ///
24    /// # Safety
25    ///
26    /// The generic must be valid to reinterpret as the given type.
27    #[inline]
28    pub unsafe fn cast_unchecked<NewNodeType: ?Sized + Message + AsRef<GKGraphNode2D>>(
29        &self,
30    ) -> &GKObstacleGraph<NewNodeType> {
31        unsafe { &*((self as *const Self).cast()) }
32    }
33}
34
35#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
36extern_conformance!(
37    unsafe impl<NodeType: ?Sized + NSCoding + AsRef<GKGraphNode2D>> NSCoding
38        for GKObstacleGraph<NodeType>
39    {
40    }
41);
42
43#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
44extern_conformance!(
45    unsafe impl<NodeType: ?Sized + AsRef<GKGraphNode2D>> NSCopying for GKObstacleGraph<NodeType> {}
46);
47
48#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
49unsafe impl<NodeType: ?Sized + Message + AsRef<GKGraphNode2D>> CopyingHelper
50    for GKObstacleGraph<NodeType>
51{
52    type Result = Self;
53}
54
55#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
56extern_conformance!(
57    unsafe impl<NodeType: ?Sized + AsRef<GKGraphNode2D>> NSObjectProtocol
58        for GKObstacleGraph<NodeType>
59    {
60    }
61);
62
63#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
64extern_conformance!(
65    unsafe impl<NodeType: ?Sized + NSSecureCoding + AsRef<GKGraphNode2D>> NSSecureCoding
66        for GKObstacleGraph<NodeType>
67    {
68    }
69);
70
71#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
72impl<NodeType: Message + AsRef<GKGraphNode2D>> GKObstacleGraph<NodeType> {
73    extern_methods!(
74        #[cfg(feature = "GKObstacle")]
75        #[unsafe(method(obstacles))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn obstacles(&self) -> Retained<NSArray<GKPolygonObstacle>>;
78
79        #[unsafe(method(bufferRadius))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn bufferRadius(&self) -> c_float;
82
83        #[cfg(feature = "GKObstacle")]
84        /// Creates an optimal bidirectional graph based on a list of obstacles.
85        /// Each vertex of each obstacle is extruded and a connection is made between each vertex that does not intersect an obstacle
86        /// Guaranteed not to have any edges which intersect obstacles.
87        /// Same effect as [[GKObstacleGraph alloc] init], setting bufferRadius, and then calling addObstacles.
88        ///
89        /// Parameter `obstacles`: a list of obstacles to create the graph from
90        ///
91        /// Parameter `bufferRadius`: the circular radius of a potential agent that will navigate this graph.  Obstacles are extruded by this amount to create the graph.  Must be positive.  Negative values are clipped to 0.0f
92        #[unsafe(method(graphWithObstacles:bufferRadius:))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn graphWithObstacles_bufferRadius(
95            obstacles: &NSArray<GKPolygonObstacle>,
96            buffer_radius: c_float,
97        ) -> Retained<Self>;
98
99        #[cfg(feature = "GKObstacle")]
100        #[unsafe(method(initWithObstacles:bufferRadius:))]
101        #[unsafe(method_family = init)]
102        pub unsafe fn initWithObstacles_bufferRadius(
103            this: Allocated<Self>,
104            obstacles: &NSArray<GKPolygonObstacle>,
105            buffer_radius: c_float,
106        ) -> Retained<Self>;
107
108        #[cfg(feature = "GKObstacle")]
109        /// Creates an optimal bidirectional graph based on a list of obstacles.
110        /// Each vertex of each obstacle is extruded and a connection is made between each vertex that does not intersect an obstacle
111        /// Guaranteed not to have any edges which intersect obstacles.
112        /// Same effect as [[GKObstacleGraph alloc] init], setting bufferRadius, and then calling addObstacles.
113        ///
114        /// Parameter `obstacles`: a list of obstacles to create the graph from
115        ///
116        /// Parameter `bufferRadius`: the circular radius of a potential agent that will navigate this graph.  Obstacles are extruded by this amount to create the graph.  Must be positive.  Negative values are clipped to 0.0f
117        ///
118        /// Parameter `nodeClass`: the class of the nodes that this graph should create.  Must descend from GKGraphNode2D
119        ///
120        /// # Safety
121        ///
122        /// `node_class` probably has further requirements.
123        #[unsafe(method(graphWithObstacles:bufferRadius:nodeClass:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn graphWithObstacles_bufferRadius_nodeClass(
126            obstacles: &NSArray<GKPolygonObstacle>,
127            buffer_radius: c_float,
128            node_class: &AnyClass,
129        ) -> Retained<Self>;
130
131        #[cfg(feature = "GKObstacle")]
132        /// # Safety
133        ///
134        /// `node_class` probably has further requirements.
135        #[unsafe(method(initWithObstacles:bufferRadius:nodeClass:))]
136        #[unsafe(method_family = init)]
137        pub unsafe fn initWithObstacles_bufferRadius_nodeClass(
138            this: Allocated<Self>,
139            obstacles: &NSArray<GKPolygonObstacle>,
140            buffer_radius: c_float,
141            node_class: &AnyClass,
142        ) -> Retained<Self>;
143
144        /// Connects the node to this graph by testing edge intersection with existing obstacles.
145        /// Same behavior as if this node had been present during initWithObstacles.
146        ///
147        /// Parameter `node`: the node to connect
148        #[unsafe(method(connectNodeUsingObstacles:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn connectNodeUsingObstacles(&self, node: &NodeType);
151
152        #[cfg(feature = "GKObstacle")]
153        /// Same behavior as connectNodeUsingObstacles: except you can optionally ignore certain obstacles from being tested for intersection.
154        #[unsafe(method(connectNodeUsingObstacles:ignoringObstacles:))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn connectNodeUsingObstacles_ignoringObstacles(
157            &self,
158            node: &NodeType,
159            obstacles_to_ignore: &NSArray<GKPolygonObstacle>,
160        );
161
162        #[cfg(feature = "GKObstacle")]
163        /// Same behavior as connectNodeUsingObstacles: except you can optionally ignore the bounding radius of certain obstacles from being tested for intersection
164        #[unsafe(method(connectNodeUsingObstacles:ignoringBufferRadiusOfObstacles:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn connectNodeUsingObstacles_ignoringBufferRadiusOfObstacles(
167            &self,
168            node: &NodeType,
169            obstacles_buffer_radius_to_ignore: &NSArray<GKPolygonObstacle>,
170        );
171
172        #[cfg(feature = "GKObstacle")]
173        /// Adds obstacles to this graph.
174        /// Obstacle is extruded and graph nodes are generated from its vertices and then connected to this graph
175        /// Nothing is done if an obstacle is already present in this graph
176        /// Any existing connections that intersect the new obstacles are destroyed unless they are protected with [GKObstacleGraph lockConnection:]
177        ///
178        /// Parameter `obstacles`: an array of obstacles to be added
179        ///
180        /// See: lockConnection
181        #[unsafe(method(addObstacles:))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn addObstacles(&self, obstacles: &NSArray<GKPolygonObstacle>);
184
185        #[cfg(feature = "GKObstacle")]
186        /// Removes obstacles from this graph.
187        /// All associated graph nodes are removed and their connections are bidirectionally removed.
188        /// Connections between obstacle nodes that were previously invalidated by any of these obstacles are restored.
189        /// Nothing is done if an obstacle is already present in this graph
190        ///
191        /// Parameter `obstacles`: an array of obstacles to be removed
192        #[unsafe(method(removeObstacles:))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn removeObstacles(&self, obstacles: &NSArray<GKPolygonObstacle>);
195
196        /// Removes all obstacles from this graph.
197        #[unsafe(method(removeAllObstacles))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn removeAllObstacles(&self);
200
201        #[cfg(feature = "GKObstacle")]
202        /// Returns an array of the graph nodes associated with a given obstacle
203        ///
204        /// Parameter `obstacle`: the obstacle who's nodes are to be retrieved
205        #[unsafe(method(nodesForObstacle:))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn nodesForObstacle(
208            &self,
209            obstacle: &GKPolygonObstacle,
210        ) -> Retained<NSArray<NodeType>>;
211
212        /// Marks a connection as "locked", preventing this connection from being destroyed when you add obstacles that would intersect it
213        ///
214        /// Parameter `startNode`: startNode of the connection to lock
215        ///
216        /// Parameter `endNode`: endNode of the connection to lock
217        #[unsafe(method(lockConnectionFromNode:toNode:))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn lockConnectionFromNode_toNode(
220            &self,
221            start_node: &NodeType,
222            end_node: &NodeType,
223        );
224
225        /// "Unlocks" a connection, removing its protection from being destroyed when you add obstacles that would intersect it
226        ///
227        /// Parameter `startNode`: startNode of the connection to unlock
228        ///
229        /// Parameter `endNode`: endNode of the connection to unlock
230        ///
231        /// See: lockConnection
232        #[unsafe(method(unlockConnectionFromNode:toNode:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn unlockConnectionFromNode_toNode(
235            &self,
236            start_node: &NodeType,
237            end_node: &NodeType,
238        );
239
240        /// Query if a given connection is locked
241        ///
242        /// Parameter `startNode`: startNode of the connection to query
243        ///
244        /// Parameter `endNode`: endNode of the connection to query
245        ///
246        /// See: lockConnection
247        ///
248        /// See: unlockConnection
249        ///
250        /// Returns: YES if the connection was locked with lockConnection, NO if it was never locked or was unlocked via unlockConnection
251        #[unsafe(method(isConnectionLockedFromNode:toNode:))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn isConnectionLockedFromNode_toNode(
254            &self,
255            start_node: &NodeType,
256            end_node: &NodeType,
257        ) -> bool;
258
259        /// Returns the class of the specified generic index
260        #[unsafe(method(classForGenericArgumentAtIndex:))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn classForGenericArgumentAtIndex(&self, index: NSUInteger)
263            -> &'static AnyClass;
264    );
265}
266
267/// Methods declared on superclass `GKGraph`.
268#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
269impl<NodeType: Message + AsRef<GKGraphNode2D>> GKObstacleGraph<NodeType> {
270    extern_methods!(
271        /// Creates a graph with the provided array of nodes.
272        ///
273        /// Parameter `nodes`: the nodes to create the graph with
274        #[unsafe(method(graphWithNodes:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn graphWithNodes(nodes: &NSArray<GKGraphNode>) -> Retained<Self>;
277
278        #[unsafe(method(initWithNodes:))]
279        #[unsafe(method_family = init)]
280        pub unsafe fn initWithNodes(
281            this: Allocated<Self>,
282            nodes: &NSArray<GKGraphNode>,
283        ) -> Retained<Self>;
284    );
285}
286
287/// Methods declared on superclass `NSObject`.
288#[cfg(all(feature = "GKGraph", feature = "GKGraphNode"))]
289impl<NodeType: Message + AsRef<GKGraphNode2D>> GKObstacleGraph<NodeType> {
290    extern_methods!(
291        #[unsafe(method(init))]
292        #[unsafe(method_family = init)]
293        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
294
295        #[unsafe(method(new))]
296        #[unsafe(method_family = new)]
297        pub unsafe fn new() -> Retained<Self>;
298    );
299}