-
-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathactor.h
More file actions
126 lines (81 loc) · 2.64 KB
/
Copy pathactor.h
File metadata and controls
126 lines (81 loc) · 2.64 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef ACTOR_H
#define ACTOR_H
#include "engine.h"
class Scene;
class Component;
class Transform;
class Prefab;
class ENGINE_EXPORT Actor : public Object {
A_REGISTER(Actor, Object, Actor)
A_PROPERTIES(
A_PROPERTY(bool, enabled, Actor::isEnabled, Actor::setEnabled),
A_PROPERTY(bool, static, Actor::isStatic, Actor::setStatic)
)
A_METHODS(
A_METHOD(Transform *, Actor::transform),
A_METHOD(Scene *, Actor::scene),
A_METHOD(World *, Actor::world),
A_METHOD(Component *, Actor::component),
A_METHOD(Component *, Actor::componentInChild),
A_METHOD(Component *, Actor::addComponent),
A_METHOD(Object *, Actor::clone),
A_METHOD(void, Actor::deleteLater)
)
public:
enum HideFlags {
ENABLE = (1<<0),
SELECTABLE = (1<<1)
};
public:
Actor();
~Actor();
Transform *transform();
void setTransform(Transform *transform);
Scene *scene() const;
World *world() const;
Component *component(const std::string type);
template<typename T>
T *getComponent() {
return static_cast<T *>(component(T::metaClass()->name()));
}
Component *componentInChild(const std::string type);
std::list<Component *> componentsInChild(const std::string type);
Component *addComponent(const std::string type);
bool isEnabled() const;
void setEnabled(const bool enabled);
int hideFlags() const;
void setHideFlags(int flags);
bool isEnabledInHierarchy() const;
bool isStatic() const;
void setStatic(const bool flag);
int layers() const;
void setLayers(const int layers);
void setParent(Object *parent, int32_t position = -1, bool force = false) override;
bool isInstance() const;
bool isInHierarchy(Actor *actor) const;
Prefab *prefab() const;
void setPrefab(Prefab *prefab);
private:
Object *cloneStructure(Object::ObjectPairs &pairs) override;
void loadObjectData(const VariantMap &data) override;
void loadUserData(const VariantMap &data) override;
Variant loadObject(Variant &value);
VariantMap saveUserData() const override;
Variant saveObject(const Variant &lv, const Variant &rv) const;
bool isSerializable() const override;
void clearCloneRef() override;
void setHierarchyEnabled(bool enabled);
void setScene(Scene *scene);
static void prefabUpdated(int state, void *ptr);
private:
friend class ActorTest;
VariantMap m_data;
Transform *m_transform;
Prefab *m_prefab;
Scene *m_scene;
int32_t m_layers;
int m_flags;
bool m_hierarchyEnable;
bool m_static;
};
#endif // ACTOR_H