1 #ifndef _RIVE_STATE_MACHINE_INSTANCE_HPP_
2 #define _RIVE_STATE_MACHINE_INSTANCE_HPP_
6 #include "animation/linear_animation_instance.hpp"
18 class StateMachineLayerInstance;
20 class StateMachineInstance
22 friend class SMIInput;
25 const StateMachine* m_Machine;
26 bool m_NeedsAdvance = false;
29 SMIInput** m_InputInstances;
31 StateMachineLayerInstance* m_Layers;
33 void markNeedsAdvance();
36 StateMachineInstance(const StateMachine* machine);
37 ~StateMachineInstance();
39 // Advance the state machine by the specified time. Returns true if the
40 // state machine will continue to animate after this advance.
41 bool advance(Artboard* artboard, float seconds);
43 // Returns true when the StateMachineInstance has more data to process.
44 bool needsAdvance() const;
46 // Returns a pointer to the instance's stateMachine
47 const StateMachine* stateMachine() const { return m_Machine; }
49 size_t inputCount() const { return m_InputCount; }
50 SMIInput* input(size_t index) const;
52 SMIBool* getBool(std::string name) const;
53 SMINumber* getNumber(std::string name) const;
54 SMITrigger* getTrigger(std::string name) const;
56 const size_t currentAnimationCount() const;
57 const LinearAnimationInstance*
58 currentAnimationByIndex(size_t index) const;
60 // The number of state changes that occurred across all layers on the
62 size_t stateChangedCount() const;
64 // Returns the state name for states that changed in layers on the
65 // previously called advance. If the index of out of range, it returns
67 const LayerState* stateChangedByIndex(size_t index) const;