objc2_gameplay_kit/generated/GKStateMachine.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 /// Models a finite state machine that has a single current state.
12 ///
13 /// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkstatemachine?language=objc)
14 #[unsafe(super(NSObject))]
15 #[derive(Debug, PartialEq, Eq, Hash)]
16 pub struct GKStateMachine;
17);
18
19extern_conformance!(
20 unsafe impl NSObjectProtocol for GKStateMachine {}
21);
22
23impl GKStateMachine {
24 extern_methods!(
25 #[cfg(feature = "GKState")]
26 /// The current state that the state machine is in.
27 /// Prior to the first called to enterState this is equal to nil.
28 #[unsafe(method(currentState))]
29 #[unsafe(method_family = none)]
30 pub unsafe fn currentState(&self) -> Option<Retained<GKState>>;
31
32 #[cfg(feature = "GKState")]
33 /// Creates a state machine with an array of possible states and an initial state.
34 ///
35 ///
36 /// Parameter `states`: a list of possible states for this state machine.
37 #[unsafe(method(stateMachineWithStates:))]
38 #[unsafe(method_family = none)]
39 pub unsafe fn stateMachineWithStates(states: &NSArray<GKState>) -> Retained<Self>;
40
41 #[cfg(feature = "GKState")]
42 #[unsafe(method(initWithStates:))]
43 #[unsafe(method_family = init)]
44 pub unsafe fn initWithStates(
45 this: Allocated<Self>,
46 states: &NSArray<GKState>,
47 ) -> Retained<Self>;
48
49 /// Updates the current state machine.
50 ///
51 ///
52 /// Parameter `sec`: the time, in seconds, since the last frame
53 #[unsafe(method(updateWithDeltaTime:))]
54 #[unsafe(method_family = none)]
55 pub unsafe fn updateWithDeltaTime(&self, sec: NSTimeInterval);
56
57 #[cfg(feature = "GKState")]
58 /// Gets the instance of the indicated state class from this state machine.
59 /// Returns nil if the state does not exist
60 ///
61 ///
62 /// Parameter `stateClass`: the class of the state to be retrieved
63 ///
64 /// # Safety
65 ///
66 /// `state_class` probably has further requirements.
67 #[unsafe(method(stateForClass:))]
68 #[unsafe(method_family = none)]
69 pub unsafe fn stateForClass(&self, state_class: &AnyClass) -> Option<Retained<GKState>>;
70
71 /// Returns YES if the indicated class is a a valid next state or if currentState is nil
72 ///
73 ///
74 /// Parameter `stateClass`: the class of the state to be tested
75 ///
76 /// # Safety
77 ///
78 /// `state_class` probably has further requirements.
79 #[unsafe(method(canEnterState:))]
80 #[unsafe(method_family = none)]
81 pub unsafe fn canEnterState(&self, state_class: &AnyClass) -> bool;
82
83 /// Calls canEnterState to check if we can enter the given state and then enters that state if so.
84 /// [GKState willExitWithNextState:] is called on the old current state.
85 /// [GKState didEnterWithPreviousState:] is called on the new state.
86 ///
87 ///
88 /// Parameter `stateClass`: the class of the state to switch to
89 ///
90 /// Returns: YES if state was entered. NO otherwise.
91 ///
92 /// # Safety
93 ///
94 /// `state_class` probably has further requirements.
95 #[unsafe(method(enterState:))]
96 #[unsafe(method_family = none)]
97 pub unsafe fn enterState(&self, state_class: &AnyClass) -> bool;
98 );
99}
100
101/// Methods declared on superclass `NSObject`.
102impl GKStateMachine {
103 extern_methods!(
104 #[unsafe(method(init))]
105 #[unsafe(method_family = init)]
106 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
107
108 #[unsafe(method(new))]
109 #[unsafe(method_family = new)]
110 pub unsafe fn new() -> Retained<Self>;
111 );
112}