| 376 | } |
| 377 | |
| 378 | void Scene::update() |
| 379 | { |
| 380 | if (!m_futureLoad.empty()) |
| 381 | { |
| 382 | const std::string futureLoadBuffer = std::move(m_futureLoad); |
| 383 | const std::string currentScene = m_levelFileName; |
| 384 | this->loadFromFile(futureLoadBuffer); |
| 385 | if (m_onLoadCallback) |
| 386 | { |
| 387 | sol::protected_function_result result |
| 388 | = m_onLoadCallback(futureLoadBuffer); |
| 389 | if (!result.valid()) |
| 390 | { |
| 391 | const auto error = result.get<sol::error>(); |
| 392 | const std::string errMsg = "\n \"" |
| 393 | + Utils::String::replace(error.what(), "\n", "\n ") + "\""; |
| 394 | throw Exceptions::SceneOnLoadCallbackError( |
| 395 | currentScene, futureLoadBuffer, errMsg, EXC_INFO); |
| 396 | } |
| 397 | } |
| 398 | } |
| 399 | if (m_updateState) |
| 400 | { |
| 401 | const size_t arraySize = m_gameObjectArray.size(); |
| 402 | for (size_t i = 0; i < arraySize; i++) |
| 403 | { |
| 404 | Script::GameObject& gameObject = *m_gameObjectArray[i]; |
| 405 | if (!gameObject.deletable) |
| 406 | gameObject.update(); |
| 407 | } |
| 408 | m_gameObjectArray.erase( |
| 409 | std::remove_if(m_gameObjectArray.begin(), m_gameObjectArray.end(), |
| 410 | [this](const std::unique_ptr<Script::GameObject>& ptr) { |
| 411 | if (ptr->deletable) |
| 412 | { |
| 413 | Debug::Log->debug( |
| 414 | "<Scene> Removing GameObject {}", ptr->getId()); |
| 415 | if (ptr->m_sprite) |
| 416 | this->removeSprite(ptr->getSprite().getId()); |
| 417 | if (ptr->m_collider) |
| 418 | this->removeCollider(ptr->getCollider().getId()); |
| 419 | return true; |
| 420 | } |
| 421 | return false; |
| 422 | }), |
| 423 | m_gameObjectArray.end()); |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | void Scene::draw(Graphics::RenderTarget surface) |
| 428 | { |
nothing calls this directly
no test coverage detected