Minor refactor + comments

This commit is contained in:
MihailRis 2023-11-30 05:00:48 +03:00
parent 1d5037893c
commit c0050cffaa
4 changed files with 19 additions and 10 deletions

View File

@ -145,7 +145,7 @@ void LevelScreen::update(float delta) {
if (!hud->isPause()) {
level->world->updateTimers(delta);
}
controller->update(delta, !inputLocked, hud->isPause(), !inputLocked);
controller->update(delta, !inputLocked, hud->isPause());
hud->update();
}

View File

@ -11,20 +11,26 @@ class VoxelRenderer;
class ChunksLoader;
class WorldGenerator;
/* ChunksController manages chunks dynamic loading/unloading */
class ChunksController {
private:
Level* level;
Chunks* chunks;
Lighting* lighting;
int64_t avgDurationMcs = 1000;
uint padding;
WorldGenerator* generator;
/* Average measured microseconds duration of loadVisible call */
int64_t avgDurationMcs = 1000;
/* Process one chunk: load it or calculate lights for it */
bool loadVisible();
public:
ChunksController(Level* level, Chunks* chunks, Lighting* lighting, uint padding);
~ChunksController();
/* @param maxDuration milliseconds reserved for chunks loading */
void update(int64_t maxDuration);
bool loadVisible();
};
#endif /* VOXELS_CHUNKSCONTROLLER_H_ */

View File

@ -22,8 +22,7 @@ LevelController::~LevelController() {
void LevelController::update(
float delta,
bool input,
bool pause,
bool interactions) {
bool pause) {
if (!pause) {
if (input) {
player->updateKeyboard();
@ -35,7 +34,7 @@ void LevelController::update(
}
player->refreshCamera();
if (interactions) {
if (input) {
player->updateInteraction();
} else {
player->selectedBlockId = -1;

View File

@ -7,21 +7,25 @@ class Level;
class ChunksController;
class PlayerController;
/* LevelController - the main game logic controller */
class LevelController {
EngineSettings& settings;
Level* level;
// Sub-controllers
ChunksController* chunks;
PlayerController* player;
public:
LevelController(EngineSettings& settings, Level* level);
~LevelController();
/*
@param delta time elapsed since the last update
@param input is user input allowed to be handled
@param pause is world and player simulation paused
*/
void update(float delta,
bool input,
bool pause,
bool interactions);
bool pause);
};
#endif // LOGIC_LEVEL_CONTROLLER_H_