CSEngine
Loading...
Searching...
No Matches
ComponentDef.h
1//
2// Created by ounols on 19. 3. 14.
3//
4
5#ifndef CSENGINE_APP_COMPONENTDEF_H
6#define CSENGINE_APP_COMPONENTDEF_H
7
8#define Transform static_cast<TransformInterface*>(gameObject->GetTransform())
9#define COMPONENT_DECLARE(CLASSNAME) \
10CLASSNAME(); \
11auto GetComponent() override
12
13#define COMPONENT_DEFINE_CONSTRUCTOR(CLASSNAME) \
14explicit CLASSNAME(CSE::SGameObject* l_gameObject)
15
16#define COMPONENT_CONSTRUCTOR(CLASSNAME) \
17CLASSNAME::CLASSNAME(CSE::SGameObject* l_gameObject) : CSE::SComponent(#CLASSNAME, l_gameObject)
18
19#define FIND_OBJ_REFERENCE(obj, src) \
20{ \
21 auto targetObject = lists_obj.find(src->obj); \
22 obj = (targetObject != lists_obj.end()) ? targetObject->second : src->obj; \
23}
24#define FIND_COMP_REFERENCE(comp, src, componentName) \
25{ \
26 auto targetObject = lists_comp.find(src->comp); \
27 comp = (targetObject != lists_comp.end()) ? static_cast<componentName*>(targetObject->second) : src->comp; \
28}
29
30#define INIT_COMPONENT_CLONE(className, cloneName) \
31className* cloneName = nullptr; \
32if (object == nullptr) { \
33cloneName = new className(object); \
34} else { \
35cloneName = object->CreateComponent<className>(); \
36}
37
38#endif //CSENGINE_APP_COMPONENTDEF_H