37 lines
679 B
C++
37 lines
679 B
C++
#include "Server.h"
|
|
#include "Network.h"
|
|
#include "World/WorldManager.h"
|
|
|
|
namespace Artifact {
|
|
|
|
void Server::init() {
|
|
for (auto & system : subsystems) {
|
|
system->init();
|
|
system->reload();
|
|
}
|
|
}
|
|
|
|
void Server::tick() {
|
|
for (auto & system : subsystems) {
|
|
system->tick();
|
|
}
|
|
}
|
|
|
|
void Server::run() {
|
|
init();
|
|
|
|
auto time = std::chrono::steady_clock::now();
|
|
while (true) {
|
|
auto now = std::chrono::steady_clock::now();
|
|
if (time - now > std::chrono::milliseconds(50)) {
|
|
tick();
|
|
}
|
|
}
|
|
}
|
|
|
|
void Server::addDefaultSubsystems() {
|
|
addSubsystem<ServerNetwork>();
|
|
addSubsystem<WorldManager>();
|
|
}
|
|
|
|
}
|