mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
feat: client-side '--script' and '--test' basic support
This commit is contained in:
parent
0ffefddee1
commit
b2ed4b472f
8 changed files with 112 additions and 57 deletions
|
|
@ -9,6 +9,8 @@
|
|||
#include "world/Level.hpp"
|
||||
#include "graphics/ui/GUI.hpp"
|
||||
#include "graphics/ui/elements/Container.hpp"
|
||||
#include "logic/scripting/scripting.hpp"
|
||||
#include "io/path.hpp"
|
||||
|
||||
static debug::Logger logger("mainloop");
|
||||
|
||||
|
|
@ -16,9 +18,11 @@ Mainloop::Mainloop(Engine& engine) : engine(engine) {
|
|||
}
|
||||
|
||||
void Mainloop::run() {
|
||||
const auto& coreParams = engine.getCoreParameters();
|
||||
auto& time = engine.getTime();
|
||||
auto& window = engine.getWindow();
|
||||
auto& settings = engine.getSettings();
|
||||
double targetDelta = 1.0 / static_cast<double>(coreParams.tps);
|
||||
|
||||
engine.setLevelConsumer([this](auto level, int64_t localPlayer) {
|
||||
if (level == nullptr) {
|
||||
|
|
@ -35,10 +39,13 @@ void Mainloop::run() {
|
|||
|
||||
logger.info() << "starting menu screen";
|
||||
engine.setScreen(std::make_shared<MenuScreen>(engine));
|
||||
|
||||
double testTimer = 0.0;
|
||||
|
||||
logger.info() << "main loop started";
|
||||
while (!window.isShouldClose()){
|
||||
time.update(window.time());
|
||||
while (!window.isShouldClose()) {
|
||||
testTimer += targetDelta;
|
||||
time.update(coreParams.testMode ? testTimer : window.time());
|
||||
engine.applicationTick();
|
||||
engine.updateFrontend();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue