galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
Prefab.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_CORE_PREFAB_HPP_
9#define GALAXY_CORE_PREFAB_HPP_
10
11#include <entt/fwd.hpp>
12#include <nlohmann/json.hpp>
13
14namespace galaxy
15{
16 namespace core
17 {
21 class Prefab final
22 {
23 public:
27 Prefab();
28
35 Prefab(entt::entity entity, entt::registry& registry);
36
42 Prefab(const nlohmann::json& json);
43
47 Prefab(const Prefab&);
48
52 Prefab(Prefab&&);
53
57 Prefab& operator=(const Prefab&);
58
63
67 ~Prefab();
68
74 [[nodiscard]]
75 bool load(const std::string& file);
76
83 void from_entity(entt::entity entity, entt::registry& registry);
84
90 void from_json(const nlohmann::json& json);
91
99 [[nodiscard]]
100 entt::entity to_entity(entt::registry& registry) const;
101
107 [[nodiscard]]
108 const nlohmann::json& to_json() const;
109
110 private:
114 nlohmann::json m_json;
115 };
116 } // namespace core
117} // namespace galaxy
118
119#endif
Preconstructed entity definition that can be loaded at any time.
Definition Prefab.hpp:22
entt::entity to_entity(entt::registry &registry) const
Creates an entity from this prefab.
Definition Prefab.cpp:113
const nlohmann::json & to_json() const
Gets the json representation of this prefab.
Definition Prefab.cpp:119
nlohmann::json m_json
Prefab as json data.
Definition Prefab.hpp:114
bool load(const std::string &file)
Loads from a json file on disk.
Definition Prefab.cpp:75
Prefab()
Constructor.
Definition Prefab.cpp:27
~Prefab()
Destructor.
Definition Prefab.cpp:71
void from_json(const nlohmann::json &json)
Creates the prefab from a json object.
Definition Prefab.cpp:105
Prefab & operator=(const Prefab &)
Copy assignment operator.
Definition Prefab.cpp:51
void from_entity(entt::entity entity, entt::registry &registry)
Creates the prefab from an entity.
Definition Prefab.cpp:95
Timer.hpp galaxy.
Definition Async.hpp:17