 |
Grail (C++)
1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
|
3 #ifndef GRAIL_FINITE_STATE_MACHINE_H
4 #define GRAIL_FINITE_STATE_MACHINE_H
7 #include "../GrailLogger/LoggerManager.hh"
14 #include <unordered_set>
28 std::shared_ptr<State> sourceState;
29 std::shared_ptr<State> destinationState;
30 std::function<bool()> condition;
39 FiniteStateMachine(
const std::map<std::shared_ptr<State>, std::function<std::shared_ptr<State>()>>& transitionFunctions,
40 std::shared_ptr<State> initialState,
41 const std::string& stateMachineName =
"state machine");
50 std::shared_ptr<State> initialState,
51 const std::string& stateMachineName =
"state machine");
61 virtual void Enter()
override;
66 virtual void Update(
float deltaTime)
override;
74 virtual const std::string&
GetName()
const override;
77 std::map<std::shared_ptr<State>, std::function<std::shared_ptr<State>()>> transitionFunctions{};
78 std::shared_ptr<State> currentState{
nullptr};
79 std::string stateMachineName{};
84 #endif //GRAIL_FINITE_STATE_MACHINE_H
FiniteStateMachine(const std::map< std::shared_ptr< State >, std::function< std::shared_ptr< State >()>> &transitionFunctions, std::shared_ptr< State > initialState, const std::string &stateMachineName="state machine")
FiniteStateMachine - Constructor.
Definition: FiniteStateMachine.cpp:9
The FiniteStateMachine class - Class representing basic Finite State Machine.
Definition: FiniteStateMachine.hh:23
virtual void Enter() override
Enter - Called once after machine enters this state.
Definition: FiniteStateMachine.cpp:52
The FiniteStateMachineState class - Class representing state of finite state machine.
Definition: State.hh:15
std::shared_ptr< State > GetCurrentState() const
GetCurrentStateName.
Definition: FiniteStateMachine.cpp:78
Definition: FiniteStateMachine.hh:26
virtual const std::string & GetName() const override
GetName.
Definition: FiniteStateMachine.cpp:79
virtual void Update(float deltaTime) override
Update - Performs state transition, if one is required, and runs update for resulting state.
Definition: FiniteStateMachine.cpp:57