blob: 2592d2df9f55b542610dfa44baa1671fd644f272 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include "api/Transform.h"
#include "GameObject.h"
#include "Metadata.h"
using namespace crepe;
using namespace std;
GameObject::GameObject(uint32_t id, std::string name, std::string tag,
Point position, double rotation, double scale)
: id(id) {
ComponentManager & mgr = ComponentManager::get_instance();
mgr.add_component<Transform>(this->id, position, rotation, scale);
mgr.add_component<Metadata>(this->id, name, tag);
}
void GameObject::set_parent(GameObject & parent) {
auto & mgr = ComponentManager::get_instance();
vector<reference_wrapper<Metadata>> thisMetadata
= mgr.get_components_by_id<Metadata>(this->id);
vector<reference_wrapper<Metadata>> parentMetadata
= mgr.get_components_by_id<Metadata>(parent.id);
thisMetadata.at(0).get().parent = parent.id;
parentMetadata.at(0).get().children.push_back(this->id);
}
|