Initial commit.
This commit is contained in:
commit
82b4f23c06
56 changed files with 3485 additions and 0 deletions
56
Client/Client.cpp
Normal file
56
Client/Client.cpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#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>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue