1 #ifndef _RIVE_STATE_TRANSITION_BASE_HPP_
2 #define _RIVE_STATE_TRANSITION_BASE_HPP_
3 #include "rive/animation/state_machine_layer_component.hpp"
4 #include "rive/core/field_types/core_uint_type.hpp"
6 class StateTransitionBase : public StateMachineLayerComponent {
8 typedef StateMachineLayerComponent Super;
11 static const uint16_t typeKey = 65;
13 /// Helper to quickly determine if a core object extends another without RTTI
15 bool isTypeOf(uint16_t typeKey) const override {
17 case StateTransitionBase::typeKey:
18 case StateMachineLayerComponentBase::typeKey:
25 uint16_t coreType() const override { return typeKey; }
27 static const uint16_t stateToIdPropertyKey = 151;
28 static const uint16_t flagsPropertyKey = 152;
29 static const uint16_t durationPropertyKey = 158;
30 static const uint16_t exitTimePropertyKey = 160;
33 uint32_t m_StateToId = -1;
35 uint32_t m_Duration = 0;
36 uint32_t m_ExitTime = 0;
39 inline uint32_t stateToId() const { return m_StateToId; }
40 void stateToId(uint32_t value) {
41 if (m_StateToId == value) {
48 inline uint32_t flags() const { return m_Flags; }
49 void flags(uint32_t value) {
50 if (m_Flags == value) {
57 inline uint32_t duration() const { return m_Duration; }
58 void duration(uint32_t value) {
59 if (m_Duration == value) {
66 inline uint32_t exitTime() const { return m_ExitTime; }
67 void exitTime(uint32_t value) {
68 if (m_ExitTime == value) {
75 Core* clone() const override;
76 void copy(const StateTransitionBase& object) {
77 m_StateToId = object.m_StateToId;
78 m_Flags = object.m_Flags;
79 m_Duration = object.m_Duration;
80 m_ExitTime = object.m_ExitTime;
81 StateMachineLayerComponent::copy(object);
84 bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
85 switch (propertyKey) {
86 case stateToIdPropertyKey:
87 m_StateToId = CoreUintType::deserialize(reader);
89 case flagsPropertyKey:
90 m_Flags = CoreUintType::deserialize(reader);
92 case durationPropertyKey:
93 m_Duration = CoreUintType::deserialize(reader);
95 case exitTimePropertyKey:
96 m_ExitTime = CoreUintType::deserialize(reader);
99 return StateMachineLayerComponent::deserialize(propertyKey, reader);
103 virtual void stateToIdChanged() {}
104 virtual void flagsChanged() {}
105 virtual void durationChanged() {}
106 virtual void exitTimeChanged() {}