|
enum | STATUS { IDLE = 0
, INIT = 1
, DESTROY = -1
, UNKOWN = -2
} |
|
Definition at line 17 of file SGameObject.h.
◆ STATUS
enum CSE::SGameObject::STATUS |
Definition at line 19 of file SGameObject.h.
19 {
20 IDLE = 0, INIT = 1, DESTROY = -1, UNKOWN = -2
21 };
◆ 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 SetHash(hash);
32 m_name = std::move(name);
33 m_transform = CreateComponent<TransformComponent>();
34
35 SGameObject::Init();
36}
◆ AddChild()
Definition at line 91 of file SGameObject.cpp.
91 {
92 if (object == nullptr) return;
93 object->RemoveParent();
94 m_children.push_back(object);
95 object->m_parent = this;
96}
◆ AddComponent()
void SGameObject::AddComponent |
( |
SComponent * |
component | ) |
|
컴포넌트를 이 오브젝트에 추가합니다.
- Parameters
-
Definition at line 128 of file SGameObject.cpp.
128 {
129 auto str_class = component->GetClassType();
130 m_components.push_back(component);
131}
◆ CreateComponent()
template<class T >
T * CSE::SGameObject::CreateComponent |
( |
| ) |
|
Definition at line 161 of file SGameObject.h.
161 {
162 T* component = new T(this);
164 if (m_status == IDLE)
165 component->Init();
166 return component;
167
168 }
void AddComponent(SComponent *component)
컴포넌트를 이 오브젝트에 추가합니다.
◆ DeleteComponent()
void SGameObject::DeleteComponent |
( |
SComponent * |
component | ) |
|
Definition at line 152 of file SGameObject.cpp.
152 {
153 m_components.remove(component);
154}
◆ Destroy()
void SGameObject::Destroy |
( |
| ) |
|
|
overridevirtual |
자동 삭제가 아닌 특정한 상황에서 삭제될 때 호출되는 함수
Reimplemented from CSE::SObject.
Definition at line 59 of file SGameObject.cpp.
59 {
60 {
61 auto iter = m_components.begin();
62 while (iter != m_components.end()) {
63 auto component = *iter;
64 m_components.erase(iter++);
65
66 if (component == nullptr) continue;
67 CORE->GetCore(
MemoryMgr)->ReleaseObject(component);
68 }
69 }
70
71 m_components.clear();
72
73 if (m_parent != nullptr) {
74 RemoveParent();
75 }
76
77 {
78 auto iter = m_children.begin();
79 while (iter != m_children.end()) {
80 auto object = *iter;
81 m_children.erase(iter++);
82
83 if (object == nullptr) continue;
84 object->Destroy();
85 }
86 }
87 m_status = DESTROY;
89}
◆ Exterminate()
void SGameObject::Exterminate |
( |
| ) |
|
|
overridevirtual |
◆ 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 179 of file SGameObject.cpp.
179 {
180 const auto& currentId = GetID();
181 if (currentId == id) return this;
182
183 for (const auto& child: m_children) {
184 const auto& result = child->FindLocalByID(id);
185 if (result != nullptr) return result;
186 }
187 return nullptr;
188}
◆ GenerateMeta()
std::string SGameObject::GenerateMeta |
( |
| ) |
|
|
overridevirtual |
Reimplemented from CSE::SObject.
Definition at line 290 of file SGameObject.cpp.
290 {
291 unsigned int startIndex = GetID().size() - GetName().size();
292 return GetMetaString(*this, startIndex);
293}
◆ GetChildren()
const std::list< SGameObject * > & SGameObject::GetChildren |
( |
| ) |
const |
◆ GetComponent()
template<class T >
T * CSE::SGameObject::GetComponent |
( |
| ) |
|
Definition at line 142 of file SGameObject.h.
142 {
143 for (const auto& component : m_components) {
144 if (component == nullptr) continue;
145 if (dynamic_cast<T*>(component)) {
146 return static_cast<T*>(component);
147 }
148 }
149
150 return nullptr;
151 }
◆ GetComponentByHash()
template<class T >
T * CSE::SGameObject::GetComponentByHash |
( |
const std::string & |
id | ) |
const |
Definition at line 154 of file SGameObject.h.
154 {
155 return static_cast<T*>(GetSComponentByHash(id));
156 }
◆ GetComponents()
const std::list< SComponent * > & SGameObject::GetComponents |
( |
| ) |
const |
◆ GetCustomComponent()
HSQOBJECT SGameObject::GetCustomComponent |
( |
const char * |
className | ) |
|
Definition at line 137 of file SGameObject.cpp.
137 {
138 for (const auto& component: m_components) {
139 if (component == nullptr) continue;
142 if (customComponent->SGetClassName() != className) continue;
143 return customComponent->GetClassInstance().GetObject();
144 }
145 }
146 auto obj = HSQOBJECT();
147 obj._type = OT_NULL;
148
149 return obj;
150}
◆ GetID() [1/2]
std::string SGameObject::GetID |
( |
| ) |
const |
Definition at line 156 of file SGameObject.cpp.
156 {
157 std::string id;
159 if (node == nullptr) break;
160
161 id = node->GetName() + (id.empty() ? "" : "/") + id;
162 }
163
164 return id;
165}
◆ GetID() [2/2]
std::string SGameObject::GetID |
( |
const SComponent * |
component | ) |
const |
Definition at line 167 of file SGameObject.cpp.
167 {
168 if (component == nullptr) return "";
169
170 const auto& object = component->GetGameObject();
171 return object->m_hash + "?" + component->GetClassType();
172}
◆ 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 263 of file SGameObject.cpp.
263 {
264 const auto&
object = CORE->GetCore(
GameObjectMgr)->FindByHash(ConvertSpaceStr(hash,
true));
265 if (object == nullptr) return nullptr;
266
267 std::string componentName = split(hash, '?')[1];
268
269 for (const auto& component: object->m_components) {
270 if (componentName == component->GetClassType()) {
271 return component;
272 }
273 }
274 return nullptr;
275}
◆ GetStatus()
STATUS CSE::SGameObject::GetStatus |
( |
| ) |
const |
|
inline |
◆ GetTransform()
Definition at line 102 of file SGameObject.h.
102 {
103 return m_transform;
104 }
◆ Init()
void SGameObject::Init |
( |
| ) |
|
|
virtual |
◆ isPrefab()
bool SGameObject::isPrefab |
( |
bool |
OnlyThisObject = false | ) |
const |
Definition at line 239 of file SGameObject.cpp.
239 {
240 if (m_isPrefab || m_parent == nullptr || OnlyThisObject) return m_isPrefab;
241
242 return m_parent->isPrefab();
243}
◆ RemoveChild()
Definition at line 105 of file SGameObject.cpp.
105 {
106 if (object == nullptr) return;
107 m_children.remove(object);
108 object->m_parent = nullptr;
109}
◆ RemoveChildren()
void SGameObject::RemoveChildren |
( |
bool |
isAllLevel = false | ) |
|
Definition at line 98 of file SGameObject.cpp.
98 {
99 for (const auto& child: m_children) {
100 child->RemoveChildren(isAllLevel);
101 }
102 m_children.clear();
103}
◆ RemoveParent()
void SGameObject::RemoveParent |
( |
| ) |
|
Definition at line 119 of file SGameObject.cpp.
119 {
120 if (m_parent == nullptr) return;
121 m_parent->RemoveChild(this);
122}
◆ SetIsEnable()
void SGameObject::SetIsEnable |
( |
bool |
is_enable | ) |
|
Definition at line 202 of file SGameObject.cpp.
202 {
203 isEnable = is_enable;
204 for (const auto& component: m_components) {
205 if (component == nullptr) continue;
206 component->SetIsEnable(is_enable);
207 }
208}
◆ SetIsPrefab()
void SGameObject::SetIsPrefab |
( |
bool |
m_isPrefab | ) |
|
Definition at line 245 of file SGameObject.cpp.
245 {
246 SGameObject::m_isPrefab = m_isPrefab;
247}
◆ SetName()
void CSE::SGameObject::SetName |
( |
std::string |
name | ) |
|
|
inline |
Definition at line 98 of file SGameObject.h.
98 {
99 m_name = std::move(name);
100 }
◆ SetParent()
◆ SetResourceID()
void SGameObject::SetResourceID |
( |
const std::string & |
resID, |
|
|
bool |
setChildren = false |
|
) |
| |
Definition at line 253 of file SGameObject.cpp.
253 {
254 m_resourceID = resID;
255
256 if (setChildren) {
257 for (const auto& child: m_children) {
258 child->SetResourceID(resID, setChildren);
259 }
260 }
261}
◆ SetUndestroyable()
void SGameObject::SetUndestroyable |
( |
bool |
enable | ) |
|
|
overridevirtual |
Reimplemented from CSE::SObject.
Definition at line 227 of file SGameObject.cpp.
227 {
228 SObject::SetUndestroyable(enable);
229
230 for (const auto& component: m_components) {
231 component->SetUndestroyable(enable);
232 }
233
234 for (const auto& child: m_children) {
235 child->SetUndestroyable(enable);
236 }
237}
◆ 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: