Prepare script lifecycle and data layer

This commit is contained in:
2026-03-26 20:14:58 +08:00
parent 5ca5ca1f19
commit 0921f2a459
20 changed files with 1367 additions and 26 deletions

View File

@@ -8,5 +8,35 @@ TransformComponent& Component::transform() const {
return *m_gameObject->GetTransform();
}
Scene* Component::GetScene() const {
return m_gameObject ? m_gameObject->GetScene() : nullptr;
}
void Component::SetEnabled(bool enabled) {
if (m_enabled == enabled) {
return;
}
bool wasEffectivelyEnabled = m_enabled;
bool isEffectivelyEnabled = enabled;
if (m_gameObject) {
wasEffectivelyEnabled = m_enabled && m_gameObject->IsActiveInHierarchy();
isEffectivelyEnabled = enabled && m_gameObject->IsActiveInHierarchy();
}
m_enabled = enabled;
if (wasEffectivelyEnabled == isEffectivelyEnabled) {
return;
}
if (isEffectivelyEnabled) {
OnEnable();
} else {
OnDisable();
}
}
}
}
}