objc2-gameplay-kit 0.3.2

Bindings to the GameplayKit framework
Documentation
//! 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_class!(
    /// A collection of GKGoals or GKBehaviors with weights that can be applied to a GKAgent
    /// The sub-goals or sub-behaviors are summed to produce a total force to be applied to an agent
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkbehavior?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GKBehavior;
);

extern_conformance!(
    unsafe impl NSCopying for GKBehavior {}
);

unsafe impl CopyingHelper for GKBehavior {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSFastEnumeration for GKBehavior {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for GKBehavior {}
);

impl GKBehavior {
    extern_methods!(
        #[unsafe(method(goalCount))]
        #[unsafe(method_family = none)]
        pub unsafe fn goalCount(&self) -> NSInteger;

        #[cfg(feature = "GKGoal")]
        /// Creates a behavior with a single goal and weight
        #[unsafe(method(behaviorWithGoal:weight:))]
        #[unsafe(method_family = none)]
        pub unsafe fn behaviorWithGoal_weight(goal: &GKGoal, weight: c_float) -> Retained<Self>;

        #[cfg(feature = "GKGoal")]
        /// Creates a behavior with an array of goals.  All weights are set to 1.0f
        #[unsafe(method(behaviorWithGoals:))]
        #[unsafe(method_family = none)]
        pub unsafe fn behaviorWithGoals(goals: &NSArray<GKGoal>) -> Retained<Self>;

        #[cfg(feature = "GKGoal")]
        /// Creates a behavior with two associated arrays of goals and weights
        #[unsafe(method(behaviorWithGoals:andWeights:))]
        #[unsafe(method_family = none)]
        pub unsafe fn behaviorWithGoals_andWeights(
            goals: &NSArray<GKGoal>,
            weights: &NSArray<NSNumber>,
        ) -> Retained<Self>;

        #[cfg(feature = "GKGoal")]
        /// Creates a behavior with a dictionary of goal/weight pairs
        #[unsafe(method(behaviorWithWeightedGoals:))]
        #[unsafe(method_family = none)]
        pub unsafe fn behaviorWithWeightedGoals(
            weighted_goals: &NSDictionary<GKGoal, NSNumber>,
        ) -> Retained<Self>;

        #[cfg(feature = "GKGoal")]
        /// Adds a new goal or changes the weight of the existing goal in this behavior.
        /// If the goal does not exist in this behavior, it is added.
        ///
        /// Parameter `weight`: the weight for this goal
        ///
        /// Parameter `goal`: the goal who's weight to change
        #[unsafe(method(setWeight:forGoal:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setWeight_forGoal(&self, weight: c_float, goal: &GKGoal);

        #[cfg(feature = "GKGoal")]
        /// Gets the current weight for a given goal.
        ///
        /// Returns: the weight of the goal, or 0 if there is no such goal on this behavior
        #[unsafe(method(weightForGoal:))]
        #[unsafe(method_family = none)]
        pub unsafe fn weightForGoal(&self, goal: &GKGoal) -> c_float;

        #[cfg(feature = "GKGoal")]
        /// Remove the indicated goal from this behavior.
        ///
        /// Parameter `goal`: the goal to be removed
        #[unsafe(method(removeGoal:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeGoal(&self, goal: &GKGoal);

        /// Removes all the goals on the behavior.
        #[unsafe(method(removeAllGoals))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeAllGoals(&self);

        #[cfg(feature = "GKGoal")]
        /// Supports getting goals via a [int] subscript.
        #[unsafe(method(objectAtIndexedSubscript:))]
        #[unsafe(method_family = none)]
        pub unsafe fn objectAtIndexedSubscript(&self, idx: NSUInteger) -> Retained<GKGoal>;

        #[cfg(feature = "GKGoal")]
        /// Supports setting a weight via a [goal] subscript.
        #[unsafe(method(setObject:forKeyedSubscript:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setObject_forKeyedSubscript(&self, weight: &NSNumber, goal: &GKGoal);

        #[cfg(feature = "GKGoal")]
        /// Supports getting a weight via a [goal] subscript.
        #[unsafe(method(objectForKeyedSubscript:))]
        #[unsafe(method_family = none)]
        pub unsafe fn objectForKeyedSubscript(&self, goal: &GKGoal) -> Option<Retained<NSNumber>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl GKBehavior {
    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>;
    );
}