light/modules/app/private/application.cpp

49 lines
748 B
C++
Raw Normal View History

#include <app/application.hpp>
#include <app/system.hpp>
namespace lt::app {
2025-07-11 01:42:56 +03:30
void Application::game_loop()
2022-03-07 21:57:00 +03:30
{
for (auto &system : m_systems)
2022-03-07 21:57:00 +03:30
{
system->init();
2025-07-11 00:49:04 +03:30
}
2025-07-07 15:13:05 +03:30
while (true)
2025-07-11 00:49:04 +03:30
{
for (auto &system : m_systems)
2025-07-06 17:23:28 +03:30
{
if (system->tick())
{
return;
}
2025-07-06 17:23:28 +03:30
}
2021-05-23 18:10:11 +04:30
for (auto &system : m_systems_to_be_removed)
2025-07-06 16:30:38 +03:30
{
m_systems.erase(
std::remove(m_systems.begin(), m_systems.end(), system),
m_systems.end()
);
2025-07-06 16:30:38 +03:30
}
2021-06-15 09:39:11 +04:30
if (m_systems.empty())
2025-07-06 16:30:38 +03:30
{
2022-03-07 21:57:00 +03:30
return;
2025-07-06 16:30:38 +03:30
}
}
2022-03-07 21:57:00 +03:30
}
void Application::register_system(Ref<app::ISystem> system)
2025-07-11 00:24:44 +03:30
{
m_systems.emplace_back(std::move(system));
2025-07-11 00:24:44 +03:30
}
void Application::unregister_system(Ref<app::ISystem> system)
2022-03-07 21:57:00 +03:30
{
m_systems_to_be_removed.emplace_back(std::move(system));
2022-03-07 21:57:00 +03:30
}
} // namespace lt::app