ArtifactEngine/Client/Client.cpp
2026-04-06 18:30:52 -04:00

56 lines
1.1 KiB
C++

#include <chrono>
#include "Client.h"
#include "Network.h"
#include "Graphics/UIRenderer.h"
#include "Graphics/Graphics.h"
#include <Network/Network.h>
namespace Artifact {
void Client::init() {
window = subsystem<WindowImpl>();
for (auto & system : subsystems) {
system->client = this;
system->init();
system->reload();
}
}
void Client::render() {
for (auto & system : subsystems) {
system->render();
}
}
void Client::run() {
init();
auto time = std::chrono::steady_clock::now();
while (!window->shouldClose()) {
auto now = std::chrono::steady_clock::now();
if (time - now > std::chrono::milliseconds(50)) {
tick();
}
render();
}
}
void Client::tick() {
for (auto & system : subsystems) {
system->tick();
}
}
void Client::addDefaultSubsystems() {
addSubsystem<Window>(1080, 640, "Artifact Engine");
addSubsystem<ClientNetwork>();
auto graphics = addSubsystem<Graphics>();
{
graphics->addSubsystem<UIRenderer>();
}
}
}