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_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>;
    );
}