Minor refactor + comments
This commit is contained in:
parent
1d5037893c
commit
c0050cffaa
@ -145,7 +145,7 @@ void LevelScreen::update(float delta) {
|
|||||||
if (!hud->isPause()) {
|
if (!hud->isPause()) {
|
||||||
level->world->updateTimers(delta);
|
level->world->updateTimers(delta);
|
||||||
}
|
}
|
||||||
controller->update(delta, !inputLocked, hud->isPause(), !inputLocked);
|
controller->update(delta, !inputLocked, hud->isPause());
|
||||||
hud->update();
|
hud->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,20 +11,26 @@ class VoxelRenderer;
|
|||||||
class ChunksLoader;
|
class ChunksLoader;
|
||||||
class WorldGenerator;
|
class WorldGenerator;
|
||||||
|
|
||||||
|
/* ChunksController manages chunks dynamic loading/unloading */
|
||||||
class ChunksController {
|
class ChunksController {
|
||||||
private:
|
private:
|
||||||
Level* level;
|
Level* level;
|
||||||
Chunks* chunks;
|
Chunks* chunks;
|
||||||
Lighting* lighting;
|
Lighting* lighting;
|
||||||
int64_t avgDurationMcs = 1000;
|
|
||||||
uint padding;
|
uint padding;
|
||||||
WorldGenerator* generator;
|
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:
|
public:
|
||||||
ChunksController(Level* level, Chunks* chunks, Lighting* lighting, uint padding);
|
ChunksController(Level* level, Chunks* chunks, Lighting* lighting, uint padding);
|
||||||
~ChunksController();
|
~ChunksController();
|
||||||
|
|
||||||
|
/* @param maxDuration milliseconds reserved for chunks loading */
|
||||||
void update(int64_t maxDuration);
|
void update(int64_t maxDuration);
|
||||||
bool loadVisible();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* VOXELS_CHUNKSCONTROLLER_H_ */
|
#endif /* VOXELS_CHUNKSCONTROLLER_H_ */
|
||||||
|
|||||||
@ -22,8 +22,7 @@ LevelController::~LevelController() {
|
|||||||
void LevelController::update(
|
void LevelController::update(
|
||||||
float delta,
|
float delta,
|
||||||
bool input,
|
bool input,
|
||||||
bool pause,
|
bool pause) {
|
||||||
bool interactions) {
|
|
||||||
if (!pause) {
|
if (!pause) {
|
||||||
if (input) {
|
if (input) {
|
||||||
player->updateKeyboard();
|
player->updateKeyboard();
|
||||||
@ -35,7 +34,7 @@ void LevelController::update(
|
|||||||
|
|
||||||
}
|
}
|
||||||
player->refreshCamera();
|
player->refreshCamera();
|
||||||
if (interactions) {
|
if (input) {
|
||||||
player->updateInteraction();
|
player->updateInteraction();
|
||||||
} else {
|
} else {
|
||||||
player->selectedBlockId = -1;
|
player->selectedBlockId = -1;
|
||||||
|
|||||||
@ -7,21 +7,25 @@ class Level;
|
|||||||
class ChunksController;
|
class ChunksController;
|
||||||
class PlayerController;
|
class PlayerController;
|
||||||
|
|
||||||
|
/* LevelController - the main game logic controller */
|
||||||
class LevelController {
|
class LevelController {
|
||||||
EngineSettings& settings;
|
EngineSettings& settings;
|
||||||
|
|
||||||
Level* level;
|
Level* level;
|
||||||
|
// Sub-controllers
|
||||||
ChunksController* chunks;
|
ChunksController* chunks;
|
||||||
PlayerController* player;
|
PlayerController* player;
|
||||||
public:
|
public:
|
||||||
LevelController(EngineSettings& settings, Level* level);
|
LevelController(EngineSettings& settings, Level* level);
|
||||||
~LevelController();
|
~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,
|
void update(float delta,
|
||||||
bool input,
|
bool input,
|
||||||
bool pause,
|
bool pause);
|
||||||
bool interactions);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LOGIC_LEVEL_CONTROLLER_H_
|
#endif // LOGIC_LEVEL_CONTROLLER_H_
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user