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
galaxy::core::Prefab Class Referencefinal

Preconstructed entity definition that can be loaded at any time. More...

#include <Prefab.hpp>

+ Collaboration diagram for galaxy::core::Prefab:

Public Member Functions

 Prefab ()
 Constructor.
 
 Prefab (entt::entity entity, entt::registry &registry)
 Entity constructor.
 
 Prefab (const nlohmann::json &json)
 JSON constructor.
 
 Prefab (const Prefab &)
 Copy constructor.
 
 Prefab (Prefab &&)
 Move constructor.
 
Prefaboperator= (const Prefab &)
 Copy assignment operator.
 
Prefaboperator= (Prefab &&)
 Move assignment operator.
 
 ~Prefab ()
 Destructor.
 
bool load (const std::string &file)
 Loads from a json file on disk.
 
void from_entity (entt::entity entity, entt::registry &registry)
 Creates the prefab from an entity.
 
void from_json (const nlohmann::json &json)
 Creates the prefab from a json object.
 
entt::entity to_entity (entt::registry &registry) const
 Creates an entity from this prefab.
 
const nlohmann::json & to_json () const
 Gets the json representation of this prefab.
 

Private Attributes

nlohmann::json m_json
 Prefab as json data.
 

Detailed Description

Preconstructed entity definition that can be loaded at any time.

Definition at line 21 of file Prefab.hpp.

Constructor & Destructor Documentation

◆ Prefab() [1/5]

galaxy::core::Prefab::Prefab ( )

Constructor.

Definition at line 27 of file Prefab.cpp.

◆ Prefab() [2/5]

galaxy::core::Prefab::Prefab ( entt::entity entity,
entt::registry & registry )

Entity constructor.

Parameters
entityEntity to use.
registryRegistry entity and its components belong to.

Definition at line 31 of file Prefab.cpp.

+ Here is the call graph for this function:

◆ Prefab() [3/5]

galaxy::core::Prefab::Prefab ( const nlohmann::json & json)

JSON constructor.

Parameters
jsonJSON data to construct prefab from.

Definition at line 36 of file Prefab.cpp.

+ Here is the call graph for this function:

◆ Prefab() [4/5]

galaxy::core::Prefab::Prefab ( const Prefab & p)

Copy constructor.

Definition at line 41 of file Prefab.cpp.

◆ Prefab() [5/5]

galaxy::core::Prefab::Prefab ( Prefab && p)

Move constructor.

Definition at line 46 of file Prefab.cpp.

◆ ~Prefab()

galaxy::core::Prefab::~Prefab ( )

Destructor.

Definition at line 71 of file Prefab.cpp.

Member Function Documentation

◆ operator=() [1/2]

Prefab & galaxy::core::Prefab::operator= ( const Prefab & p)

Copy assignment operator.

Definition at line 51 of file Prefab.cpp.

◆ operator=() [2/2]

Prefab & galaxy::core::Prefab::operator= ( Prefab && p)

Move assignment operator.

Definition at line 61 of file Prefab.cpp.

◆ load()

bool galaxy::core::Prefab::load ( const std::string & file)
nodiscard

Loads from a json file on disk.

Parameters
fileJson file to read from disk.

Definition at line 75 of file Prefab.cpp.

+ Here is the call graph for this function:

◆ from_entity()

void galaxy::core::Prefab::from_entity ( entt::entity entity,
entt::registry & registry )

Creates the prefab from an entity.

Parameters
entityEntity to use.
registryRegistry entity and its components belong to.

Definition at line 95 of file Prefab.cpp.

+ Here is the caller graph for this function:

◆ from_json()

void galaxy::core::Prefab::from_json ( const nlohmann::json & json)

Creates the prefab from a json object.

Parameters
jsonJSON data to construct prefab from.

Definition at line 105 of file Prefab.cpp.

+ Here is the caller graph for this function:

◆ to_entity()

entt::entity galaxy::core::Prefab::to_entity ( entt::registry & registry) const
nodiscard

Creates an entity from this prefab.

Parameters
registryRegistry to create the entity from.
Returns
Newly created entity.

Definition at line 113 of file Prefab.cpp.

◆ to_json()

const nlohmann::json & galaxy::core::Prefab::to_json ( ) const
nodiscard

Gets the json representation of this prefab.

Returns
Const reference from the json object.

Definition at line 119 of file Prefab.cpp.

Member Data Documentation

◆ m_json

nlohmann::json galaxy::core::Prefab::m_json
private

Prefab as json data.

Definition at line 114 of file Prefab.hpp.


The documentation for this class was generated from the following files: