feat? add basich ah scene loading
This commit is contained in:
@@ -32,7 +32,7 @@ GameObject* Scene::CreateGameObject(std::string name)
|
||||
|
||||
GameObject* rawPtr = obj.get();
|
||||
|
||||
// obj->SetScene(this);
|
||||
obj->SetScene(this);
|
||||
m_pendingAdditions.emplace_back(std::move(obj));
|
||||
|
||||
return rawPtr;
|
||||
@@ -61,15 +61,9 @@ void Scene::Load() {
|
||||
}
|
||||
|
||||
void Scene::Update() {
|
||||
if (!m_pendingAdditions.empty()) {
|
||||
for (auto& obj : m_pendingAdditions) {
|
||||
m_objects.emplace_back(std::move(obj));
|
||||
}
|
||||
m_pendingAdditions.clear();
|
||||
}
|
||||
CommitPendingAdditions();
|
||||
|
||||
|
||||
for (const auto& object: m_objects) {
|
||||
for (const auto& object : m_objects) {
|
||||
if (object->IsActiveInHierarchy()) {
|
||||
object->Update();
|
||||
}
|
||||
@@ -155,3 +149,15 @@ void Scene::DestroyGameObjects() {
|
||||
assert(m_BeingUnloaded && "Scene is being cleared but not unloaded? Weird");
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::CommitPendingAdditions() {
|
||||
if (m_pendingAdditions.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& obj : m_pendingAdditions) {
|
||||
m_objects.emplace_back(std::move(obj));
|
||||
}
|
||||
|
||||
m_pendingAdditions.clear();
|
||||
}
|
||||
Reference in New Issue
Block a user