|
enum | STATUS { IDLE = 0
, INIT = 1
, DESTROY = -1
, UNKOWN = -2
} |
|
Definition at line 18 of file SGameObject.h.
◆ STATUS
enum CSE::SGameObject::STATUS |
Definition at line 20 of file SGameObject.h.
20 {
21 IDLE = 0, INIT = 1, DESTROY = -1, UNKOWN = -2
22 };
◆ SGameObject() [1/3]
SGameObject::SGameObject |
( |
| ) |
|
Definition at line 14 of file SGameObject.cpp.
14 {
16 m_transform = CreateComponent<TransformComponent>();
17
18 SGameObject::Init();
19}
◆ SGameObject() [2/3]
SGameObject::SGameObject |
( |
std::string | name | ) |
|
|
explicit |
Definition at line 21 of file SGameObject.cpp.
21 {
23 m_name = std::move(name);
24 m_transform = CreateComponent<TransformComponent>();
25
26 SGameObject::Init();
27}
◆ SGameObject() [3/3]
SGameObject::SGameObject |
( |
std::string | name, |
|
|
std::string | hash ) |
|
explicit |
Definition at line 29 of file SGameObject.cpp.
29 {
30 SObject::SetHash(hash);
32 m_name = std::move(name);
33 m_transform = CreateComponent<TransformComponent>();
34
35 SGameObject::Init();
36}
◆ AddChild()
Definition at line 101 of file SGameObject.cpp.
101 {
102 if (object == nullptr) return;
103 object->RemoveParent();
104 m_children.push_back(object);
105 object->m_parent = this;
106}
◆ AddComponent()
void SGameObject::AddComponent |
( |
SComponent * | component | ) |
|
컴포넌트를 이 오브젝트에 추가합니다.
- Parameters
-
Definition at line 138 of file SGameObject.cpp.
138 {
139 m_components.push_back(component);
140}
◆ CreateComponent() [1/2]
template<class T >
T * CSE::SGameObject::CreateComponent |
( |
| ) |
|
Definition at line 163 of file SGameObject.h.
163 {
164 T* component = new T(this);
166 if (m_status == IDLE)
167 component->Init();
168 return component;
169 }
void AddComponent(SComponent *component)
컴포넌트를 이 오브젝트에 추가합니다.
◆ CreateComponent() [2/2]
SComponent * SGameObject::CreateComponent |
( |
const char * | type | ) |
|
Definition at line 165 of file SGameObject.cpp.
165 {
167 component->SetGameObject(this);
169 if (m_status == IDLE)
170 component->Init();
171 return component;
172}
◆ DeleteComponent()
void SGameObject::DeleteComponent |
( |
SComponent * | component | ) |
|
Definition at line 161 of file SGameObject.cpp.
161 {
162 m_components.remove(component);
163}
◆ Destroy()
void SGameObject::Destroy |
( |
| ) |
|
|
overridevirtual |
자동 삭제가 아닌 특정한 상황에서 삭제될 때 호출되는 함수
Reimplemented from CSE::SObject.
Definition at line 69 of file SGameObject.cpp.
69 {
70 {
71 auto iter = m_components.begin();
72 while (iter != m_components.end()) {
73 auto component = *iter;
74 m_components.erase(iter++);
75
76 if (component == nullptr) continue;
77 CORE->GetCore(
MemoryMgr)->ReleaseObject(component);
78 }
79 }
80
81 m_components.clear();
82
83 if (m_parent != nullptr) {
84 RemoveParent();
85 }
86
87 {
88 auto iter = m_children.begin();
89 while (iter != m_children.end()) {
90 auto object = *iter;
91 m_children.erase(iter++);
92
93 if (object == nullptr) continue;
94 object->Destroy();
95 }
96 }
97 m_status = DESTROY;
99}
◆ Exterminate()
void SGameObject::Exterminate |
( |
| ) |
|
|
overridevirtual |
Implements CSE::SObject.
Definition at line 55 of file SGameObject.cpp.
55 {
56 {
57 auto iter = m_components.begin();
58 while (iter != m_components.end()) {
59 auto component = *iter;
60 m_components.erase(iter++);
61
62 if (component == nullptr) continue;
63 CORE->GetCore(
MemoryMgr)->ReleaseObject(component);
64 }
65 }
67}
◆ Find()
SGameObject * SGameObject::Find |
( |
std::string | name | ) |
const |
◆ FindByHash()
SGameObject * SGameObject::FindByHash |
( |
const std::string & | hash | ) |
|
|
static |
◆ FindByID()
◆ FindLocalByID()
SGameObject * SGameObject::FindLocalByID |
( |
const std::string & | id | ) |
|
Definition at line 197 of file SGameObject.cpp.
197 {
198 const auto& currentId = GetID();
199 if (currentId == id) return this;
200
201 for (const auto& child: m_children) {
202 const auto& result = child->FindLocalByID(id);
203 if (result != nullptr) return result;
204 }
205 return nullptr;
206}
◆ GetChildren()
const std::list< SGameObject * > & SGameObject::GetChildren |
( |
| ) |
const |
◆ GetComponent()
template<class T >
T * CSE::SGameObject::GetComponent |
( |
| ) |
|
Definition at line 145 of file SGameObject.h.
145 {
146 const auto& ref = ReflectionRef<T>();
147 for (const auto& component : m_components) {
148 if (component == nullptr) continue;
149 if (ref.IsSameClass(component)) {
150 return static_cast<T*>(component);
151 }
152 }
153
154 return nullptr;
155 }
◆ GetComponentByHash()
template<class T >
T * CSE::SGameObject::GetComponentByHash |
( |
const std::string & | id | ) |
const |
Definition at line 158 of file SGameObject.h.
158 {
159 return static_cast<T*>(GetSComponentByHash(id));
160 }
◆ GetComponents()
const std::list< SComponent * > & SGameObject::GetComponents |
( |
| ) |
const |
◆ GetCustomComponent()
HSQOBJECT SGameObject::GetCustomComponent |
( |
const char * | className | ) |
|
Definition at line 146 of file SGameObject.cpp.
146 {
147 for (const auto& component: m_components) {
148 if (component == nullptr) continue;
151 if (customComponent->SGetClassName() != className) continue;
152 return customComponent->GetClassInstance().GetObject();
153 }
154 }
155 auto obj = HSQOBJECT();
156 obj._type = OT_NULL;
157
158 return obj;
159}
◆ GetID() [1/2]
std::string SGameObject::GetID |
( |
| ) |
const |
Definition at line 174 of file SGameObject.cpp.
174 {
175 std::string id;
177 if (node == nullptr) break;
178
179 id = node->GetName() + (id.empty() ? "" : "/") + id;
180 }
181
182 return id;
183}
◆ GetID() [2/2]
std::string SGameObject::GetID |
( |
const SComponent * | component | ) |
const |
Definition at line 185 of file SGameObject.cpp.
185 {
186 if (component == nullptr) return "";
187
188 const auto& object = component->GetGameObject();
189 return object->m_hash + "?" + component->GetClassType();
190}
◆ GetIsEnable()
bool SGameObject::GetIsEnable |
( |
| ) |
const |
◆ GetName()
std::string CSE::SGameObject::GetName |
( |
| ) |
const |
|
inline |
◆ GetParent()
◆ GetResourceID()
std::string SGameObject::GetResourceID |
( |
| ) |
const |
◆ GetSComponentByHash()
SComponent * SGameObject::GetSComponentByHash |
( |
const std::string & | hash | ) |
const |
Definition at line 281 of file SGameObject.cpp.
281 {
282 const auto&
object = CORE->GetCore(
GameObjectMgr)->FindByHash(ConvertSpaceStr(hash,
true));
283 if (object == nullptr) return nullptr;
284
285 std::string componentName = split(hash, '?')[1];
286
287 for (const auto& component: object->m_components) {
288 if (componentName == component->GetClassType()) {
289 return component;
290 }
291 }
292 return nullptr;
293}
◆ GetStatus()
STATUS CSE::SGameObject::GetStatus |
( |
| ) |
const |
|
inline |
◆ GetTransform()
Definition at line 105 of file SGameObject.h.
105 {
106 return m_transform;
107 }
◆ Init()
void SGameObject::Init |
( |
| ) |
|
|
virtual |
◆ isPrefab()
bool SGameObject::isPrefab |
( |
bool | OnlyThisObject = false | ) |
const |
Definition at line 257 of file SGameObject.cpp.
257 {
258 if (m_isPrefab || m_parent == nullptr || OnlyThisObject) return m_isPrefab;
259
260 return m_parent->isPrefab();
261}
◆ RemoveChild()
Definition at line 115 of file SGameObject.cpp.
115 {
116 if (object == nullptr) return;
117 m_children.remove(object);
118 object->m_parent = nullptr;
119}
◆ RemoveChildren()
void SGameObject::RemoveChildren |
( |
bool | isAllLevel = false | ) |
|
Definition at line 108 of file SGameObject.cpp.
108 {
109 for (const auto& child: m_children) {
110 child->RemoveChildren(isAllLevel);
111 }
112 m_children.clear();
113}
◆ RemoveParent()
void SGameObject::RemoveParent |
( |
| ) |
|
Definition at line 129 of file SGameObject.cpp.
129 {
130 if (m_parent == nullptr) return;
131 m_parent->RemoveChild(this);
132}
◆ SetHash()
void SGameObject::SetHash |
( |
std::string & | hash | ) |
|
|
overridevirtual |
Reimplemented from CSE::SObject.
Definition at line 295 of file SGameObject.cpp.
295 {
296 const std::string prevHash = std::string(m_hash);
297 SObject::SetHash(hash);
299}
◆ SetIsEnable()
void SGameObject::SetIsEnable |
( |
bool | is_enable | ) |
|
Definition at line 220 of file SGameObject.cpp.
220 {
221 isEnable = is_enable;
222 for (const auto& component: m_components) {
223 if (component == nullptr) continue;
224 component->SetIsEnable(is_enable);
225 }
226}
◆ SetIsPrefab()
void SGameObject::SetIsPrefab |
( |
bool | m_isPrefab | ) |
|
Definition at line 263 of file SGameObject.cpp.
263 {
264 SGameObject::m_isPrefab = m_isPrefab;
265}
◆ SetName()
void CSE::SGameObject::SetName |
( |
std::string | name | ) |
|
|
inline |
Definition at line 101 of file SGameObject.h.
101 {
102 m_name = std::move(name);
103 }
◆ SetParent()
◆ SetResourceID()
void SGameObject::SetResourceID |
( |
const std::string & | resID, |
|
|
bool | setChildren = false ) |
Definition at line 271 of file SGameObject.cpp.
271 {
272 m_resourceID = resID;
273
274 if (setChildren) {
275 for (const auto& child: m_children) {
276 child->SetResourceID(resID, setChildren);
277 }
278 }
279}
◆ SetUndestroyable()
void SGameObject::SetUndestroyable |
( |
bool | enable | ) |
|
|
overridevirtual |
Reimplemented from CSE::SObject.
Definition at line 245 of file SGameObject.cpp.
245 {
246 SObject::SetUndestroyable(enable);
247
248 for (const auto& component: m_components) {
249 component->SetUndestroyable(enable);
250 }
251
252 for (const auto& child: m_children) {
253 child->SetUndestroyable(enable);
254 }
255}
◆ Tick()
void SGameObject::Tick |
( |
float | elapsedTime | ) |
|
|
virtual |
Definition at line 49 of file SGameObject.cpp.
49 {
50 if (!isEnable) return;
51 if (isPrefab()) return;
52 UpdateComponent(elapsedTime);
53}
The documentation for this class was generated from the following files: