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!(
    /// [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkcompositebehavior?language=objc)
    #[unsafe(super(GKBehavior, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "GKBehavior")]
    pub struct GKCompositeBehavior;
);

#[cfg(feature = "GKBehavior")]
extern_conformance!(
    unsafe impl NSCopying for GKCompositeBehavior {}
);

#[cfg(feature = "GKBehavior")]
unsafe impl CopyingHelper for GKCompositeBehavior {
    type Result = Self;
}

#[cfg(feature = "GKBehavior")]
extern_conformance!(
    unsafe impl NSFastEnumeration for GKCompositeBehavior {}
);

#[cfg(feature = "GKBehavior")]
extern_conformance!(
    unsafe impl NSObjectProtocol for GKCompositeBehavior {}
);

#[cfg(feature = "GKBehavior")]
impl GKCompositeBehavior {
    extern_methods!(
        /// Number of sub-behaviors in this behavior
        #[unsafe(method(behaviorCount))]
        #[unsafe(method_family = none)]
        pub unsafe fn behaviorCount(&self) -> NSInteger;

        /// Creates a behavior with an array of sub-behaviors
        #[unsafe(method(behaviorWithBehaviors:))]
        #[unsafe(method_family = none)]
        pub unsafe fn behaviorWithBehaviors(behaviors: &NSArray<GKBehavior>) -> Retained<Self>;

        /// Creates a behavior with two associated arrays of sub-behaviors and weights
        #[unsafe(method(behaviorWithBehaviors:andWeights:))]
        #[unsafe(method_family = none)]
        pub unsafe fn behaviorWithBehaviors_andWeights(
            behaviors: &NSArray<GKBehavior>,
            weights: &NSArray<NSNumber>,
        ) -> Retained<Self>;

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

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

        /// Remove the indicated sub-behavior from this behavior.
        ///
        /// Parameter `behavior`: the sub-behavior to be removed
        #[unsafe(method(removeBehavior:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeBehavior(&self, behavior: &GKBehavior);

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

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

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

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

/// Methods declared on superclass `GKBehavior`.
#[cfg(feature = "GKBehavior")]
impl GKCompositeBehavior {
    extern_methods!(
        #[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>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "GKBehavior")]
impl GKCompositeBehavior {
    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>;
    );
}