General refactor
This commit is contained in:
+1
-30
@@ -5,12 +5,10 @@
|
||||
#include "../lighting/Lighting.h"
|
||||
#include "../voxels/Chunk.h"
|
||||
#include "../voxels/Chunks.h"
|
||||
#include "../voxels/ChunksController.h"
|
||||
#include "../voxels/ChunksStorage.h"
|
||||
#include "../physics/Hitbox.h"
|
||||
#include "../physics/PhysicsSolver.h"
|
||||
#include "../objects/Player.h"
|
||||
#include "../objects/player_control.h"
|
||||
|
||||
Level::Level(World* world, const Content* content, Player* player, EngineSettings& settings)
|
||||
: world(world),
|
||||
@@ -30,9 +28,6 @@ Level::Level(World* world, const Content* content, Player* player, EngineSetting
|
||||
events,
|
||||
content);
|
||||
lighting = new Lighting(content, chunks);
|
||||
chunksController = new ChunksController(this, chunks, lighting,
|
||||
settings.chunks.padding);
|
||||
playerController = new PlayerController(this, settings);
|
||||
|
||||
events->listen(EVT_CHUNK_HIDDEN, [this](lvl_event_type type, Chunk* chunk) {
|
||||
this->chunksStorage->remove(chunk->x, chunk->z);
|
||||
@@ -45,31 +40,7 @@ Level::~Level(){
|
||||
delete physics;
|
||||
delete player;
|
||||
delete lighting;
|
||||
delete chunksController;
|
||||
delete chunksStorage;
|
||||
delete playerController;
|
||||
}
|
||||
|
||||
void Level::updatePlayer(float delta,
|
||||
bool input,
|
||||
bool pause,
|
||||
bool interactions) {
|
||||
if (!pause) {
|
||||
if (input) {
|
||||
playerController->updateKeyboard();
|
||||
playerController->updateCameraControl();
|
||||
} else {
|
||||
playerController->resetKeyboard();
|
||||
}
|
||||
playerController->updateControls(delta);
|
||||
|
||||
}
|
||||
playerController->refreshCamera();
|
||||
if (interactions) {
|
||||
playerController->updateInteraction();
|
||||
} else {
|
||||
playerController->selectedBlockId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void Level::update() {
|
||||
@@ -77,7 +48,7 @@ void Level::update() {
|
||||
chunks->setCenter(position.x, position.z);
|
||||
|
||||
int matrixSize = (settings.chunks.loadDistance+
|
||||
settings.chunks.padding) * 2;
|
||||
settings.chunks.padding) * 2;
|
||||
if (chunks->w != matrixSize) {
|
||||
chunks->resize(matrixSize, matrixSize);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user