1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- //
- // RUStateTransition.hpp
- // RoleTool
- //
- // Created by 徐炼新 on 2023/4/19.
- //
- #ifndef RUStateTransition_hpp
- #define RUStateTransition_hpp
- #include "cocos2d.h"
- #include "RUDefine.h"
- #include "RUStateMachine.h"
- NS_RU_BEGIN
- class StateTransition : public cocos2d::Ref {
- public:
- static StateTransition* create(StateMachine*, const FsmTransition*, std::function<void(StateTransition*, std::function<void(void)>, bool)> cf);
-
- void setEvent(const std::string& eventName, const std::map<std::string, std::string>& eventParams, std::function<void(void)> handleEventCb);
-
- /// 终止状态转移
- void interrupt();
-
- /// 执行状态转移
- void execute();
-
- private:
- StateTransition() = default;
-
- std::function<void(StateTransition*, std::function<void(void)>, bool)> _cf = nullptr;
- StateMachine* _machine = nullptr;
- const FsmTransition* _transition = nullptr;
- void* _param = nullptr;
- std::string _eventName;
- std::map<std::string, std::string> _eventParams;
- std::function<void(void)> _cf4Event = nullptr;
- bool _bIsInterrupted = false;
- };
- NS_RU_END
- #endif /* RUStateTransition_hpp */
|