/* * Author: Patrick-Christopher Mattulat * Company: Lynar Studios * E-Mail: webmaster@lynarstudios.com * Created: 2020-09-05 * Changed: 2022-07-15 * * */ #ifndef LS_STD_STATE_MACHINE_HPP #define LS_STD_STATE_MACHINE_HPP #include #include #include #include #include #include "State.hpp" #include #include namespace ls::std::logic { class [[deprecated("consider using ls_game_tool_kit dependency instead!")]] LS_STD_DYNAMIC_GOAL StateMachine : public ls::std::core::Class { public: explicit StateMachine(const ::std::string &_name); ~StateMachine() override = default; bool addState(const ::std::shared_ptr &_state); ::std::shared_ptr getCurrentState(); ::std::vector getMemory(); ::std::string getName(); ::std::unordered_map> getStates(); bool hasState(const ls::std::core::type::state_id &_id); bool proceed(); void setMemory(const ::std::vector &_memory); void setName(const ::std::string &_name); bool setStartState(const ls::std::core::type::state_id &_id); private: ::std::shared_ptr currentState{}; ::std::vector memory{}; ::std::string name{}; ::std::unordered_map> states{}; void _assignMemory(const ::std::vector &_memory); void _assignName(const ::std::string &_name); ::std::vector _getNextValidStates(); void _remember(const ls::std::core::type::state_id &_id); bool _hasState(const ls::std::core::type::state_id &_id); }; } #endif