mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
General refactor
This commit is contained in:
parent
de134dc2e5
commit
1d5037893c
27 changed files with 558 additions and 419 deletions
45
src/logic/LevelController.cpp
Normal file
45
src/logic/LevelController.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#include "LevelController.h"
|
||||
#include "../world/Level.h"
|
||||
|
||||
#include "PlayerController.h"
|
||||
#include "ChunksController.h"
|
||||
|
||||
LevelController::LevelController(EngineSettings& settings, Level* level)
|
||||
: settings(settings), level(level) {
|
||||
chunks = new ChunksController(
|
||||
level,
|
||||
level->chunks,
|
||||
level->lighting,
|
||||
settings.chunks.padding);
|
||||
player = new PlayerController(level, settings);
|
||||
}
|
||||
|
||||
LevelController::~LevelController() {
|
||||
delete player;
|
||||
delete chunks;
|
||||
}
|
||||
|
||||
void LevelController::update(
|
||||
float delta,
|
||||
bool input,
|
||||
bool pause,
|
||||
bool interactions) {
|
||||
if (!pause) {
|
||||
if (input) {
|
||||
player->updateKeyboard();
|
||||
} else {
|
||||
player->resetKeyboard();
|
||||
}
|
||||
player->updateCamera(delta, input);
|
||||
player->updateControls(delta);
|
||||
|
||||
}
|
||||
player->refreshCamera();
|
||||
if (interactions) {
|
||||
player->updateInteraction();
|
||||
} else {
|
||||
player->selectedBlockId = -1;
|
||||
}
|
||||
level->update();
|
||||
chunks->update(settings.chunks.loadSpeed);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue