blob: 388f1c4d327c1b8a8d76134baf18eaa11a4c0f62 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include "api/Transform.h"
#include "Metadata.h"
#include "GameObject.h"
using namespace crepe::api;
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);
}
|