forked from Shell4026/ShellEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComponentTest.cpp
More file actions
49 lines (41 loc) · 1.05 KB
/
Copy pathComponentTest.cpp
File metadata and controls
49 lines (41 loc) · 1.05 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "ComponentTest.h"
#include "Core/Logger.h"
#include "Game/GameObject.h"
#include "Game/Input.h"
#include <iostream>
ComponentTest::ComponentTest(GameObject& owner) :
Component(owner)
{
}
ComponentTest::~ComponentTest()
{
}
void ComponentTest::OnEnable()
{
std::cout << "Test: Enable!\n";
}
void ComponentTest::Update()
{
using namespace sh;
using namespace sh::game;
if (Input::GetKeyDown(Input::KeyCode::Enter))
{
gameObject.transform->SetParent(nullptr);
}
if (Input::GetKeyDown(Input::KeyCode::Space))
{
glm::vec3 pos = gameObject.transform->GetWorldPosition();
glm::vec3 rot = gameObject.transform->GetWorldRotation();
SH_INFO_FORMAT("worldPosition: x: {}, y: {}, z: {}", pos.x, pos.y, pos.z);
SH_INFO_FORMAT("worldRotation: x: {}, y: {}, z: {}", rot.x, rot.y, rot.z);
}
}
void ComponentTest::OnPropertyChanged(const sh::core::reflection::Property& prop)
{
std::string* name = prop.Get<std::string>(this);
auto obj = gameObject.world.GetGameObject(*name);
if (obj)
{
gameObject.transform->SetParent(obj->transform);
}
}