CSEngine
Loading...
Searching...
No Matches
MoreComponentFunc.cpp
1//
2// Created by ounols on 19. 8. 31.
3//
4
5#include "MoreComponentFunc.h"
6#include "../Component/Animation/AnimatorComponent.h"
7#include "../Component/CameraComponent.h"
8#include "../Component/CustomComponent.h"
9#include "../Component/LightComponent.h"
10#include "../Component/RenderComponent.h"
11#include "../Component/TransformComponent.h"
12
13#define CREATE_COMPONENT_MACRO(CLASSNAME) \
14if(component_type == #CLASSNAME) { \
15 return obj->CreateComponent<CLASSNAME>(); \
16}
17
18#define BIND_COMPONENT_MACRO(CLASSNAME) \
19if(component_type == #CLASSNAME) { \
20 auto comp_r = static_cast<CLASSNAME*>(component); \
21 instance->set(name.c_str(), comp_r); \
22 return; \
23}
24
25using namespace CSE;
26
27SComponent* MoreComponentFunc::CreateComponent(SGameObject* obj, std::string component_type) {
28
29 CREATE_COMPONENT_MACRO(AnimatorComponent);
30 CREATE_COMPONENT_MACRO(JointComponent);
31 CREATE_COMPONENT_MACRO(CameraComponent);
32 CREATE_COMPONENT_MACRO(CustomComponent);
33 CREATE_COMPONENT_MACRO(DrawableSkinnedMeshComponent);
34 CREATE_COMPONENT_MACRO(DrawableStaticMeshComponent);
35 CREATE_COMPONENT_MACRO(LightComponent);
36 CREATE_COMPONENT_MACRO(RenderComponent);
37 CREATE_COMPONENT_MACRO(TransformComponent);
38
39 return nullptr;
40
41}
42
43void MoreComponentFunc::BindComponentToSQInstance(SComponent* component, std::string name,
44 sqext::SQIClassInstance* instance) {
45 std::string component_type = component->GetClassType();
46
47 BIND_COMPONENT_MACRO(AnimatorComponent);
48 BIND_COMPONENT_MACRO(JointComponent);
49 BIND_COMPONENT_MACRO(CameraComponent);
50 BIND_COMPONENT_MACRO(CustomComponent);
51 BIND_COMPONENT_MACRO(DrawableSkinnedMeshComponent);
52 BIND_COMPONENT_MACRO(DrawableStaticMeshComponent);
53 BIND_COMPONENT_MACRO(LightComponent);
54 BIND_COMPONENT_MACRO(RenderComponent);
55 BIND_COMPONENT_MACRO(TransformComponent);
56}
57