migrate main
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
namespace td {
|
||||
|
||||
@@ -19,16 +20,17 @@ class StateMachine {
|
||||
};
|
||||
|
||||
StateMachine() {}
|
||||
StateMachine(StateMachine&&) = default;
|
||||
virtual ~StateMachine() {}
|
||||
|
||||
TReturn Update(TArgs... args) {
|
||||
assert(m_State);
|
||||
virtual TReturn Update(TArgs... args) {
|
||||
assert(m_State && "You must change state at least once before updating !");
|
||||
return m_State->Update(args...);
|
||||
}
|
||||
|
||||
template <typename T, typename... Args>
|
||||
void ChangeState(Args&&... args) {
|
||||
m_State = std::make_unique<T>(static_cast<TDerived&>(*this), args...);
|
||||
m_State = std::make_unique<T>(static_cast<TDerived&>(*this), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user