diff --git a/SDK/include/NDK/StateMachine.hpp b/SDK/include/NDK/StateMachine.hpp index 8d05f8335..8e7ad2f64 100644 --- a/SDK/include/NDK/StateMachine.hpp +++ b/SDK/include/NDK/StateMachine.hpp @@ -16,7 +16,7 @@ namespace Ndk class StateMachine { public: - inline StateMachine(); + inline StateMachine(std::shared_ptr originalState); StateMachine(const StateMachine&) = delete; inline StateMachine(StateMachine&& fsm) = default; inline ~StateMachine(); diff --git a/SDK/include/NDK/StateMachine.inl b/SDK/include/NDK/StateMachine.inl index 0a1e195c4..208a609a3 100644 --- a/SDK/include/NDK/StateMachine.inl +++ b/SDK/include/NDK/StateMachine.inl @@ -2,11 +2,24 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp +#include #include #include namespace Ndk { + inline StateMachine::StateMachine(std::shared_ptr originalState) : + m_currentState(std::move(originalState)) + { + NazaraAssert(m_currentState, "StateMachine must have a state to begin with"); + } + + inline StateMachine::~StateMachine() + { + m_currentState->Leave(*this); + } + + inline void StateMachine::ChangeState(std::shared_ptr state) { m_nextState = std::move(state);