blob: 06370f312425575fa1dab4e3693d977fe0cae785 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#pragma once
#include <memory>
#include <string>
#include <unordered_map>
#include "State.h"
namespace Donut
{
class StateManager
{
public:
~StateManager() = default;
void Shutdown();
void Update(float deltaTime);
void Render();
void OnEvent(Event& event);
void RegisterState(const std::string& stateName, std::unique_ptr<State> state);
void SwitchToState(const std::string& stateName);
std::string GetCurrentStateName() const { return m_CurrentStateName; }
State* GetCurrentState() const { return m_CurrentState; }
State* GetState(const std::string& stateName);
bool HasState(const std::string& stateName) const;
private:
void CreateStates();
void DestroyStates();
private:
State* m_CurrentState = nullptr;
std::string m_CurrentStateName = "";
std::unordered_map<std::string, std::unique_ptr<State>> m_States;
};
}
|