Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailRis committed Dec 29, 2023
1 parent e7e7bbb commit d2ace01
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
9 changes: 3 additions & 6 deletions src/logic/LevelController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@

LevelController::LevelController(EngineSettings& settings, Level* level)
: settings(settings), level(level) {
blocks = new BlocksController(level, settings.chunks.padding);
chunks = new ChunksController(level, settings.chunks.padding);
player = new PlayerController(level, settings, blocks);
blocks = std::make_unique<BlocksController>(level, settings.chunks.padding);
chunks = std::make_unique<ChunksController>(level, settings.chunks.padding);
player = std::make_unique<PlayerController>(level, settings, blocks.get());

scripting::on_world_load(level);
}

LevelController::~LevelController() {
scripting::on_world_quit();
delete player;
delete chunks;
delete blocks;
}

void LevelController::update(float delta, bool input, bool pause) {
Expand Down
7 changes: 4 additions & 3 deletions src/logic/LevelController.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef LOGIC_LEVEL_CONTROLLER_H_
#define LOGIC_LEVEL_CONTROLLER_H_

#include <memory>
#include "../settings.h"

class Level;
Expand All @@ -13,9 +14,9 @@ class LevelController {
EngineSettings& settings;
Level* level;
// Sub-controllers
BlocksController* blocks;
ChunksController* chunks;
PlayerController* player;
std::unique_ptr<BlocksController> blocks;
std::unique_ptr<ChunksController> chunks;
std::unique_ptr<PlayerController> player;
public:
LevelController(EngineSettings& settings, Level* level);
~LevelController();
Expand Down

0 comments on commit d2ace01

Please sign in to comment.