Kemena3D
Loading...
Searching...
No Matches
kprefab.h
Go to the documentation of this file.
1
5
6#ifndef KPREFAB_H
7#define KPREFAB_H
8
9#include "kexport.h"
10#include "kdatatype.h"
11
12#include <nlohmann/json.hpp>
13
14#include <string>
15#include <unordered_map>
16
17using json = nlohmann::json;
18
19namespace kemena
20{
41 {
42 public:
47
53 bool loadFromFile(const kString &path);
54
60 bool saveToFile(const kString &path);
61
63 kString getUuid() const { return uuid; }
65 void setUuid(const kString &v){ uuid = v; }
67 kString getName() const { return name; }
69 void setName(const kString &v){ name = v; }
70
72 const json &getRootJson() const { return rootJson; }
74 json &getRootJson() { return rootJson; }
76 void setRootJson(const json &j) { rootJson = j; }
77
91 static json instantiateJson(const json &source,
92 std::unordered_map<kString, kString> *templateMap = nullptr);
93
94 private:
95 kString uuid;
96 kString name;
97 json rootJson;
98 };
99}
100
101#endif // KPREFAB_H
bool saveToFile(const kString &path)
Writes this prefab to a .prefab JSON file.
kString getUuid() const
Returns the prefab asset UUID.
Definition kprefab.h:63
bool loadFromFile(const kString &path)
Loads a .prefab JSON file from disk into this prefab.
kString getName() const
Returns the display name of the prefab.
Definition kprefab.h:67
kPrefab()
Constructs an empty prefab with no UUID, name, or root subtree.
const json & getRootJson() const
Returns the object subtree JSON (the "root" field).
Definition kprefab.h:72
json & getRootJson()
Returns a mutable reference to the object subtree JSON (the "root" field).
Definition kprefab.h:74
void setRootJson(const json &j)
Replaces the object subtree JSON.
Definition kprefab.h:76
void setName(const kString &v)
Sets the display name of the prefab.
Definition kprefab.h:69
~kPrefab()
Destroys the prefab and releases its stored JSON.
static json instantiateJson(const json &source, std::unordered_map< kString, kString > *templateMap=nullptr)
Generates a fresh-uuid copy of an object subtree.
void setUuid(const kString &v)
Sets the prefab asset UUID.
Definition kprefab.h:65
Core type aliases, enumerations, structs, and utility functions used throughout the engine.
Symbol visibility / linkage macro for the Kemena3D library.
#define KEMENA3D_API
Definition kexport.h:35
nlohmann::json json
Definition kobject.h:30
Top-level Kemena3D engine namespace.
Definition kanimation.h:23
std::string kString
Standard string alias.
Definition kdatatype.h:42