#include "scene.hpp"

#include "game_object.hpp"
#include "engine.hpp"


void frog::scene::cleanup(frog::engine& eng)
{
    for (auto& ptr : objects)
    {
        if (ptr->is_destroyed())
            ptr.reset();
    }

    objects.erase(std::remove_if(
        objects.begin(),
        objects.end(),
        [&](const auto& ptr) { return !ptr; }),
        objects.end());
}


void frog::scene::init(frog::engine& eng)
{
    for_each_object([&](auto& obj) { obj.init(eng); });
}


void frog::scene::stable_update(frog::engine& eng)
{
    for_each_object([&](auto& obj) { obj.stable_update(eng); });
}


void frog::scene::frame_update(frog::engine& eng)
{
    for_each_object([&](auto& obj) { obj.frame_update(eng); });
}
