Grindstone Game Engine
v0.2.0
An open source game engine and toolkit.
Toggle main menu visibility
Loading...
Searching...
No Matches
WorldContextSet.hpp
1
#pragma once
2
3
#include <map>
4
#include <entt/entt.hpp>
5
#include <Common/Memory/SmartPointers/UniquePtr.hpp>
6
#include <Common/HashedString.hpp>
7
8
#include "WorldContext.hpp"
9
10
namespace
Grindstone {
11
class
WorldContextSet {
12
public
:
13
WorldContextSet(
const
std::string& name) : name(name), registry(), contexts() {}
14
15
WorldContextSet(
const
WorldContextSet&) =
delete
;
16
WorldContextSet& operator=(
const
WorldContextSet&) =
delete
;
17
18
WorldContextSet(WorldContextSet&&)
noexcept
=
default
;
19
WorldContextSet& operator=(WorldContextSet&&)
noexcept
=
default
;
20
21
virtual
~WorldContextSet();
22
23
[[nodiscard]] entt::registry& GetEntityRegistry() {
24
return
registry;
25
}
26
27
[[nodiscard]]
Grindstone::WorldContext
* GetContext(
Grindstone::HashedString
hashedString) {
28
auto
it = contexts.find(hashedString);
29
if
(it == contexts.end()) {
30
return
nullptr
;
31
}
32
33
return
it->second.Get();
34
}
35
36
[[nodiscard]]
const
entt::registry& GetEntityRegistry()
const
{
37
return
registry;
38
}
39
40
[[nodiscard]]
const
Grindstone::WorldContext
* GetContext(
Grindstone::HashedString
hashedString)
const
{
41
auto
it = contexts.find(hashedString);
42
if
(it == contexts.end()) {
43
return
nullptr
;
44
}
45
46
return
it->second.Get();
47
}
48
49
void
Create(
Grindstone::HashedString
hashedString,
Grindstone::UniquePtr<Grindstone::WorldContext>
&& cxt) {
50
contexts.emplace(hashedString, std::move(cxt));
51
}
52
53
void
Remove(
Grindstone::HashedString
hashedString) {
54
contexts.erase(hashedString);
55
}
56
57
protected
:
58
std::string name;
59
entt::registry registry;
60
std::map<Grindstone::HashedString, Grindstone::UniquePtr<Grindstone::WorldContext>> contexts;
61
};
62
}
Grindstone::HashedString
Definition
HashedString.hpp:9
Grindstone::UniquePtr
Definition
UniquePtr.hpp:7
Grindstone::WorldContext
Definition
WorldContext.hpp:7
sources
code
EngineCore
WorldContext
WorldContextSet.hpp
Generated by
1.17.0