light/modules/app/private/application.cpp
light7734 2b96a85b62
Some checks reported errors
continuous-integration/drone/push Build was killed
feat: systems
feat: surface system

This commit puts the project in major jeopardy as it overhauls the
architecture such as removing the layer stack completely, etc.

I am filled with determination.
2025-07-26 18:01:27 +03:30

48 lines
748 B
C++

#include <app/application.hpp>
#include <app/system.hpp>
namespace lt::app {
void Application::game_loop()
{
for (auto &system : m_systems)
{
system->init();
}
while (true)
{
for (auto &system : m_systems)
{
if (system->tick())
{
return;
}
}
for (auto &system : m_systems_to_be_removed)
{
m_systems.erase(
std::remove(m_systems.begin(), m_systems.end(), system),
m_systems.end()
);
}
if (m_systems.empty())
{
return;
}
}
}
void Application::register_system(Ref<app::ISystem> system)
{
m_systems.emplace_back(std::move(system));
}
void Application::unregister_system(Ref<app::ISystem> system)
{
m_systems_to_be_removed.emplace_back(std::move(system));
}
} // namespace lt::app