feat: client-side '--script' and '--test' basic support

This commit is contained in:
MihailRis 2026-06-01 01:14:30 +03:00
parent 0ffefddee1
commit b2ed4b472f
8 changed files with 112 additions and 57 deletions

View file

@ -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();