Brenta Engine 1.2
Loading...
Searching...
No Matches
ecs.cpp
1// SPDX-License-Identifier: MIT
2// Author: Giovanni Santini
3// Mail: giovanni.santini@proton.me
4// Github: @San7o
5
6#include <brenta/ecs.hpp>
7#include <brenta/logger.hpp>
8
9using namespace brenta;
10
11//
12// Static variables
13//
14
15const std::string ecs::subsystem_name = "ecs";
16bool ecs::initialized = false;
17
18//
19// Subsystem interface
20//
21
22std::expected<void, subsystem::error> ecs::initialize()
23{
24 if (this->is_initialized()) return {};
25
26 viotecs::world::init();
27
28 ecs::initialized = true;
29 INFO("{}: initialized", ecs::subsystem_name);
30 return {};
31}
32
33std::expected<void, subsystem::error> ecs::terminate()
34{
35 if (!this->is_initialized()) return {};
36
37 viotecs::world::destroy();
38
39 ecs::initialized = true;
40 INFO("{}: terminated", ecs::subsystem_name);
41 return {};
42}
43
44std::string ecs::name()
45{
46 return ecs::subsystem_name;
47}
48
49bool ecs::is_initialized()
50{
51 return ecs::initialized;
52}
53
54//
55// Member functions
56//
57
58ecs &ecs::instance()
59{
60 static ecs _ecs;
61 return _ecs;
62}
63
64//
65// Builder
66//
67
68subsystem &ecs::builder::build()
69{
70 return ecs::instance();
71}
Subsystem interface.
Definition subsystem.hpp:22