Added MachinePool::Update

MachinePool::Update allows a user update the states of a single machine
This commit is contained in:
Erris 2025-04-22 09:12:59 +02:00
parent 7f441153ab
commit c42b0aa5bf
2 changed files with 21 additions and 11 deletions

View File

@ -30,6 +30,12 @@ class StateMachinePool {
void UpdateAll() {
for (const auto &[id, machine] : machines) {
Update(id);
}
}
void Update(const std::string &id) {
auto &machine = machines.find(id);
auto &owner = machine->GetOwner();
const std::string &current = machine->GetCurrentStateId();
@ -42,7 +48,6 @@ class StateMachinePool {
}
machine->Update();
}
}
void ChangeState(const std::string &id, const std::string &stateId) {
auto it = machines.find(id);

View File

@ -43,6 +43,11 @@ class StateSystem {
GetPool<T>().UpdateAll();
}
template <typename T>
void Update(const std::string &id) {
GetPool<T>().Update(id);
}
template <typename T>
json Serialize() const {
StateMachinePool<T> &pool = GetPool<T>();