aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-11-06 15:20:25 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-11-06 15:20:25 +0100
commit6296b85846b21083e4f545b209f1d9edce2b06f9 (patch)
treeae83cf160d44541850f970cc933530474d3cb651 /src/crepe/api
parent5af0b90f11929ca99a48389ef29d8a56f39b0efd (diff)
Moved Matadata to api folder (because it may be used by the game programmer)
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/CMakeLists.txt2
-rw-r--r--src/crepe/api/Metadata.cpp8
-rw-r--r--src/crepe/api/Metadata.h43
3 files changed, 53 insertions, 0 deletions
diff --git a/src/crepe/api/CMakeLists.txt b/src/crepe/api/CMakeLists.txt
index 0bb1263..3e0c044 100644
--- a/src/crepe/api/CMakeLists.txt
+++ b/src/crepe/api/CMakeLists.txt
@@ -11,6 +11,7 @@ target_sources(crepe PUBLIC
Texture.cpp
AssetManager.cpp
Sprite.cpp
+ Metadata.cpp
)
target_sources(crepe PUBLIC FILE_SET HEADERS FILES
@@ -28,4 +29,5 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES
Texture.h
AssetManager.h
AssetManager.hpp
+ Metadata.h
)
diff --git a/src/crepe/api/Metadata.cpp b/src/crepe/api/Metadata.cpp
new file mode 100644
index 0000000..53d93da
--- /dev/null
+++ b/src/crepe/api/Metadata.cpp
@@ -0,0 +1,8 @@
+#include "Metadata.h"
+
+using namespace crepe;
+using namespace std;
+
+Metadata::Metadata(uint32_t game_object_id, const string & name,
+ const string & tag)
+ : Component(game_object_id), name(name), tag(tag) {}
diff --git a/src/crepe/api/Metadata.h b/src/crepe/api/Metadata.h
new file mode 100644
index 0000000..4d37108
--- /dev/null
+++ b/src/crepe/api/Metadata.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include "../Component.h"
+
+namespace crepe {
+
+/**
+ * \brief Metadata component
+ *
+ * This class represents the Metadata component. It stores the name, tag, parent
+ * and children of a GameObject.
+ */
+class Metadata : public Component {
+public:
+ /**
+ * \param game_object_id The id of the GameObject this component belongs to
+ * \param name The name of the GameObject
+ * \param tag The tag of the GameObject
+ */
+ Metadata(uint32_t game_object_id, const std::string & name,
+ const std::string & tag);
+ /**
+ * \brief Get the maximum number of instances for this component
+ *
+ * \return The maximum number of instances for this component
+ */
+ virtual int get_instances_max() const { return 1; }
+
+public:
+ //! The name of the GameObject
+ std::string name;
+ //! The tag of the GameObject
+ std::string tag;
+ //! The id of the parent GameObject (-1 if no parent)
+ uint32_t parent = -1;
+ //! The ids of the children GameObjects
+ std::vector<uint32_t> children;
+};
+
+} // namespace crepe