migrate main

This commit is contained in:
2025-08-10 11:49:07 +02:00
parent 6b987cf78d
commit 8bdcffcfa6
13 changed files with 276 additions and 192 deletions

View File

@@ -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: