objc2-sprite-kit 0.3.2

Bindings to the SpriteKit 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::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/spritekit/skphysicscontactdelegate?language=objc)
    pub unsafe trait SKPhysicsContactDelegate: NSObjectProtocol {
        #[cfg(feature = "SKPhysicsContact")]
        #[optional]
        #[unsafe(method(didBeginContact:))]
        #[unsafe(method_family = none)]
        unsafe fn didBeginContact(&self, contact: &SKPhysicsContact);

        #[cfg(feature = "SKPhysicsContact")]
        #[optional]
        #[unsafe(method(didEndContact:))]
        #[unsafe(method_family = none)]
        unsafe fn didEndContact(&self, contact: &SKPhysicsContact);
    }
);

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/spritekit/skphysicsworld?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SKPhysicsWorld;
);

extern_conformance!(
    unsafe impl NSCoding for SKPhysicsWorld {}
);

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

extern_conformance!(
    unsafe impl NSSecureCoding for SKPhysicsWorld {}
);

impl SKPhysicsWorld {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        /// A global 2D vector specifying the field force acceleration due to gravity. The unit is meters per second so standard earth gravity would be { 0.0, +/-9.8 }.
        #[unsafe(method(gravity))]
        #[unsafe(method_family = none)]
        pub unsafe fn gravity(&self) -> CGVector;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`gravity`][Self::gravity].
        #[unsafe(method(setGravity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setGravity(&self, gravity: CGVector);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(speed))]
        #[unsafe(method_family = none)]
        pub unsafe fn speed(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`speed`][Self::speed].
        #[unsafe(method(setSpeed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSpeed(&self, speed: CGFloat);

        /// # Safety
        ///
        /// This is not retained internally, you must ensure the object is still alive.
        #[unsafe(method(contactDelegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn contactDelegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn SKPhysicsContactDelegate>>>;

        /// Setter for [`contactDelegate`][Self::contactDelegate].
        ///
        /// # Safety
        ///
        /// This is unretained, you must ensure the object is kept alive while in use.
        #[unsafe(method(setContactDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setContactDelegate(
            &self,
            contact_delegate: Option<&ProtocolObject<dyn SKPhysicsContactDelegate>>,
        );

        #[cfg(feature = "SKPhysicsJoint")]
        #[unsafe(method(addJoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addJoint(&self, joint: &SKPhysicsJoint);

        #[cfg(feature = "SKPhysicsJoint")]
        #[unsafe(method(removeJoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeJoint(&self, joint: &SKPhysicsJoint);

        #[unsafe(method(removeAllJoints))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeAllJoints(&self);

        #[cfg(all(feature = "SKPhysicsBody", feature = "objc2-core-foundation"))]
        #[unsafe(method(bodyAtPoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn bodyAtPoint(&self, point: CGPoint) -> Option<Retained<SKPhysicsBody>>;

        #[cfg(all(feature = "SKPhysicsBody", feature = "objc2-core-foundation"))]
        #[unsafe(method(bodyInRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn bodyInRect(&self, rect: CGRect) -> Option<Retained<SKPhysicsBody>>;

        #[cfg(all(feature = "SKPhysicsBody", feature = "objc2-core-foundation"))]
        #[unsafe(method(bodyAlongRayStart:end:))]
        #[unsafe(method_family = none)]
        pub unsafe fn bodyAlongRayStart_end(
            &self,
            start: CGPoint,
            end: CGPoint,
        ) -> Option<Retained<SKPhysicsBody>>;

        #[cfg(all(
            feature = "SKPhysicsBody",
            feature = "block2",
            feature = "objc2-core-foundation"
        ))]
        #[unsafe(method(enumerateBodiesAtPoint:usingBlock:))]
        #[unsafe(method_family = none)]
        pub unsafe fn enumerateBodiesAtPoint_usingBlock(
            &self,
            point: CGPoint,
            block: &block2::DynBlock<dyn Fn(NonNull<SKPhysicsBody>, NonNull<Bool>)>,
        );

        #[cfg(all(
            feature = "SKPhysicsBody",
            feature = "block2",
            feature = "objc2-core-foundation"
        ))]
        #[unsafe(method(enumerateBodiesInRect:usingBlock:))]
        #[unsafe(method_family = none)]
        pub unsafe fn enumerateBodiesInRect_usingBlock(
            &self,
            rect: CGRect,
            block: &block2::DynBlock<dyn Fn(NonNull<SKPhysicsBody>, NonNull<Bool>)>,
        );

        #[cfg(all(
            feature = "SKPhysicsBody",
            feature = "block2",
            feature = "objc2-core-foundation"
        ))]
        #[unsafe(method(enumerateBodiesAlongRayStart:end:usingBlock:))]
        #[unsafe(method_family = none)]
        pub unsafe fn enumerateBodiesAlongRayStart_end_usingBlock(
            &self,
            start: CGPoint,
            end: CGPoint,
            block: &block2::DynBlock<
                dyn Fn(NonNull<SKPhysicsBody>, CGPoint, CGVector, NonNull<Bool>),
            >,
        );
    );
}

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