mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 12:31:51 +00:00
cleanup
This commit is contained in:
parent
895a496f6e
commit
2475a7e8f5
20 changed files with 88 additions and 79 deletions
|
|
@ -259,7 +259,7 @@ void BlocksController::onBlockInteraction(
|
|||
}
|
||||
|
||||
void BlocksController::listenBlockInteraction(
|
||||
const on_block_interaction& callback
|
||||
const OnBlockInteraction& callback
|
||||
) {
|
||||
blockInteractionCallbacks.push_back(callback);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class ContentIndices;
|
|||
enum class BlockInteraction { step, destruction, placing };
|
||||
|
||||
/// @brief Player argument is nullable
|
||||
using on_block_interaction = std::function<
|
||||
using OnBlockInteraction = std::function<
|
||||
void(Player*, const glm::ivec3&, const Block&, BlockInteraction)>;
|
||||
|
||||
/// BlocksController manages block updates and data (inventories, metadata)
|
||||
|
|
@ -32,7 +32,7 @@ class BlocksController {
|
|||
util::Clock blocksTickClock;
|
||||
util::Clock worldTickClock;
|
||||
FastRandom random {};
|
||||
std::vector<on_block_interaction> blockInteractionCallbacks;
|
||||
std::vector<OnBlockInteraction> blockInteractionCallbacks;
|
||||
uint64_t randomTickId = 0;
|
||||
public:
|
||||
BlocksController(const Level& level, Lighting* lighting);
|
||||
|
|
@ -61,5 +61,5 @@ public:
|
|||
);
|
||||
|
||||
/// @brief Add block interaction callback
|
||||
void listenBlockInteraction(const on_block_interaction& callback);
|
||||
void listenBlockInteraction(const OnBlockInteraction& callback);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -133,9 +133,8 @@ static void check_world(const EnginePaths& paths, const io::path& folder) {
|
|||
}
|
||||
|
||||
static const Content* load_world_content(Engine& engine, const io::path& folder) {
|
||||
auto& paths = engine.getPaths();
|
||||
const auto& paths = engine.getPaths();
|
||||
auto& contentControl = engine.getContentControl();
|
||||
paths.setCurrentWorldFolder(folder);
|
||||
|
||||
check_world(paths, folder);
|
||||
call(engine, [&contentControl]() {
|
||||
|
|
@ -221,9 +220,10 @@ static void confirm(
|
|||
}
|
||||
|
||||
void EngineController::openWorld(const std::string& name, bool confirmConvert) {
|
||||
const auto& paths = engine.getPaths();
|
||||
auto& paths = engine.getPaths();
|
||||
auto& debugSettings = engine.getSettings().debug;
|
||||
auto folder = paths.getWorldsFolder() / name;
|
||||
paths.setCurrentWorldFolder(folder);
|
||||
|
||||
auto content = load_world_content(engine, folder);
|
||||
auto worldFiles = std::make_shared<WorldFiles>(folder, debugSettings);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "debug/Logger.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
#include "engine/EnginePaths.hpp"
|
||||
#include "world/files/WorldFiles.hpp"
|
||||
#include "maths/voxmaths.hpp"
|
||||
#include "objects/Entities.hpp"
|
||||
|
|
@ -22,9 +23,10 @@
|
|||
static debug::Logger logger("level-control");
|
||||
|
||||
LevelController::LevelController(
|
||||
Engine* engine, std::unique_ptr<Level> levelPtr, Player* clientPlayer
|
||||
Engine& engine, std::unique_ptr<Level> levelPtr, Player* clientPlayer
|
||||
)
|
||||
: settings(engine->getSettings()),
|
||||
: engine(engine),
|
||||
settings(engine.getSettings()),
|
||||
level(std::move(levelPtr)),
|
||||
chunks(std::make_unique<ChunksController>(*level)),
|
||||
playerTickClock(20, 3) {
|
||||
|
|
@ -147,6 +149,7 @@ void LevelController::saveWorld() {
|
|||
|
||||
void LevelController::onWorldQuit() {
|
||||
scripting::on_world_quit();
|
||||
engine.getPaths().setCurrentWorldFolder("");
|
||||
}
|
||||
|
||||
Level* LevelController::getLevel() {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ struct EngineSettings;
|
|||
|
||||
/// @brief LevelController manages other controllers
|
||||
class LevelController {
|
||||
Engine& engine;
|
||||
EngineSettings& settings;
|
||||
std::unique_ptr<Level> level;
|
||||
// Sub-controllers
|
||||
|
|
@ -24,7 +25,7 @@ class LevelController {
|
|||
public:
|
||||
CallbacksSet<> preQuitCallbacks;
|
||||
|
||||
LevelController(Engine* engine, std::unique_ptr<Level> level, Player* clientPlayer);
|
||||
LevelController(Engine& engine, std::unique_ptr<Level> level, Player* clientPlayer);
|
||||
|
||||
/// @param delta time elapsed since the last update
|
||||
/// @param pause is world and player simulation paused
|
||||
|
|
|
|||
|
|
@ -768,7 +768,7 @@ void scripting::load_layout_script(
|
|||
const std::string& prefix,
|
||||
const io::path& file,
|
||||
const std::string& fileName,
|
||||
uidocscript& script
|
||||
UiDocScript& script
|
||||
) {
|
||||
int env = *senv;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ struct ItemFuncsSet;
|
|||
struct ItemFuncNamesCache;
|
||||
struct WorldFuncsSet;
|
||||
struct UserComponent;
|
||||
struct uidocscript;
|
||||
struct UiDocScript;
|
||||
class BlocksController;
|
||||
class LevelController;
|
||||
class Entity;
|
||||
|
|
@ -231,7 +231,7 @@ namespace scripting {
|
|||
const std::string& prefix,
|
||||
const io::path& file,
|
||||
const std::string& fileName,
|
||||
uidocscript& script
|
||||
UiDocScript& script
|
||||
);
|
||||
|
||||
/// @brief Finalize lua state. Using scripting after will lead to Lua panic
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue