objc2_gameplay_kit/generated/
GKBehavior.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 GKGoals or GKBehaviors with weights that can be applied to a GKAgent
12    /// The sub-goals or sub-behaviors are summed to produce a total force to be applied to an agent
13    ///
14    /// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkbehavior?language=objc)
15    #[unsafe(super(NSObject))]
16    #[derive(Debug, PartialEq, Eq, Hash)]
17    pub struct GKBehavior;
18);
19
20extern_conformance!(
21    unsafe impl NSCopying for GKBehavior {}
22);
23
24unsafe impl CopyingHelper for GKBehavior {
25    type Result = Self;
26}
27
28extern_conformance!(
29    unsafe impl NSFastEnumeration for GKBehavior {}
30);
31
32extern_conformance!(
33    unsafe impl NSObjectProtocol for GKBehavior {}
34);
35
36impl GKBehavior {
37    extern_methods!(
38        #[unsafe(method(goalCount))]
39        #[unsafe(method_family = none)]
40        pub unsafe fn goalCount(&self) -> NSInteger;
41
42        #[cfg(feature = "GKGoal")]
43        /// Creates a behavior with a single goal and weight
44        #[unsafe(method(behaviorWithGoal:weight:))]
45        #[unsafe(method_family = none)]
46        pub unsafe fn behaviorWithGoal_weight(goal: &GKGoal, weight: c_float) -> Retained<Self>;
47
48        #[cfg(feature = "GKGoal")]
49        /// Creates a behavior with an array of goals.  All weights are set to 1.0f
50        #[unsafe(method(behaviorWithGoals:))]
51        #[unsafe(method_family = none)]
52        pub unsafe fn behaviorWithGoals(goals: &NSArray<GKGoal>) -> Retained<Self>;
53
54        #[cfg(feature = "GKGoal")]
55        /// Creates a behavior with two associated arrays of goals and weights
56        #[unsafe(method(behaviorWithGoals:andWeights:))]
57        #[unsafe(method_family = none)]
58        pub unsafe fn behaviorWithGoals_andWeights(
59            goals: &NSArray<GKGoal>,
60            weights: &NSArray<NSNumber>,
61        ) -> Retained<Self>;
62
63        #[cfg(feature = "GKGoal")]
64        /// Creates a behavior with a dictionary of goal/weight pairs
65        #[unsafe(method(behaviorWithWeightedGoals:))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn behaviorWithWeightedGoals(
68            weighted_goals: &NSDictionary<GKGoal, NSNumber>,
69        ) -> Retained<Self>;
70
71        #[cfg(feature = "GKGoal")]
72        /// Adds a new goal or changes the weight of the existing goal in this behavior.
73        /// If the goal does not exist in this behavior, it is added.
74        ///
75        /// Parameter `weight`: the weight for this goal
76        ///
77        /// Parameter `goal`: the goal who's weight to change
78        #[unsafe(method(setWeight:forGoal:))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn setWeight_forGoal(&self, weight: c_float, goal: &GKGoal);
81
82        #[cfg(feature = "GKGoal")]
83        /// Gets the current weight for a given goal.
84        ///
85        /// Returns: the weight of the goal, or 0 if there is no such goal on this behavior
86        #[unsafe(method(weightForGoal:))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn weightForGoal(&self, goal: &GKGoal) -> c_float;
89
90        #[cfg(feature = "GKGoal")]
91        /// Remove the indicated goal from this behavior.
92        ///
93        /// Parameter `goal`: the goal to be removed
94        #[unsafe(method(removeGoal:))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn removeGoal(&self, goal: &GKGoal);
97
98        /// Removes all the goals on the behavior.
99        #[unsafe(method(removeAllGoals))]
100        #[unsafe(method_family = none)]
101        pub unsafe fn removeAllGoals(&self);
102
103        #[cfg(feature = "GKGoal")]
104        /// Supports getting goals via a [int] subscript.
105        #[unsafe(method(objectAtIndexedSubscript:))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn objectAtIndexedSubscript(&self, idx: NSUInteger) -> Retained<GKGoal>;
108
109        #[cfg(feature = "GKGoal")]
110        /// Supports setting a weight via a [goal] subscript.
111        #[unsafe(method(setObject:forKeyedSubscript:))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn setObject_forKeyedSubscript(&self, weight: &NSNumber, goal: &GKGoal);
114
115        #[cfg(feature = "GKGoal")]
116        /// Supports getting a weight via a [goal] subscript.
117        #[unsafe(method(objectForKeyedSubscript:))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn objectForKeyedSubscript(&self, goal: &GKGoal) -> Option<Retained<NSNumber>>;
120    );
121}
122
123/// Methods declared on superclass `NSObject`.
124impl GKBehavior {
125    extern_methods!(
126        #[unsafe(method(init))]
127        #[unsafe(method_family = init)]
128        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
129
130        #[unsafe(method(new))]
131        #[unsafe(method_family = new)]
132        pub unsafe fn new() -> Retained<Self>;
133    );
134}