mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 20:11:50 +00:00
refactor
This commit is contained in:
parent
3d3da1cdcd
commit
4f2448daed
9 changed files with 46 additions and 35 deletions
|
|
@ -27,7 +27,7 @@ world_load_error::world_load_error(const std::string& message)
|
|||
|
||||
World::World(
|
||||
WorldInfo info,
|
||||
std::unique_ptr<WorldFiles> worldFiles,
|
||||
const std::shared_ptr<WorldFiles>& worldFiles,
|
||||
const Content* content,
|
||||
const std::vector<ContentPack>& packs
|
||||
) : info(std::move(info)),
|
||||
|
|
@ -102,12 +102,11 @@ std::unique_ptr<Level> World::create(
|
|||
}
|
||||
|
||||
std::unique_ptr<Level> World::load(
|
||||
const fs::path& directory,
|
||||
const std::shared_ptr<WorldFiles>& worldFilesPtr,
|
||||
EngineSettings& settings,
|
||||
const Content* content,
|
||||
const std::vector<ContentPack>& packs
|
||||
) {
|
||||
auto worldFilesPtr = std::make_unique<WorldFiles>(directory, settings.debug);
|
||||
auto worldFiles = worldFilesPtr.get();
|
||||
auto info = worldFiles->readWorldInfo();
|
||||
if (!info.has_value()) {
|
||||
|
|
@ -156,11 +155,11 @@ std::unique_ptr<Level> World::load(
|
|||
}
|
||||
|
||||
std::shared_ptr<ContentLUT> World::checkIndices(
|
||||
const fs::path& directory, const Content* content
|
||||
const std::shared_ptr<WorldFiles>& worldFiles, const Content* content
|
||||
) {
|
||||
fs::path indicesFile = directory / fs::path("indices.json");
|
||||
fs::path indicesFile = worldFiles->getIndicesFile();
|
||||
if (fs::is_regular_file(indicesFile)) {
|
||||
return ContentLUT::create(indicesFile, content);
|
||||
return ContentLUT::create(worldFiles, indicesFile, content);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,11 +63,11 @@ class World {
|
|||
|
||||
void writeResources(const Content* content);
|
||||
public:
|
||||
std::unique_ptr<WorldFiles> wfile;
|
||||
std::shared_ptr<WorldFiles> wfile;
|
||||
|
||||
World(
|
||||
WorldInfo info,
|
||||
std::unique_ptr<WorldFiles> wfile,
|
||||
const std::shared_ptr<WorldFiles>& worldFiles,
|
||||
const Content* content,
|
||||
const std::vector<ContentPack>& packs
|
||||
);
|
||||
|
|
@ -86,7 +86,7 @@ public:
|
|||
/// @param content current Content instance
|
||||
/// @return ContentLUT if world convert required else nullptr
|
||||
static std::shared_ptr<ContentLUT> checkIndices(
|
||||
const fs::path& directory, const Content* content
|
||||
const std::shared_ptr<WorldFiles>& worldFiles, const Content* content
|
||||
);
|
||||
|
||||
/// @brief Create new world
|
||||
|
|
@ -110,7 +110,7 @@ public:
|
|||
);
|
||||
|
||||
/// @brief Load an existing world
|
||||
/// @param directory root world directory
|
||||
/// @param worldFiles world files manager
|
||||
/// @param settings current engine settings
|
||||
/// @param content current engine Content instance
|
||||
/// with all world content-packs applied
|
||||
|
|
@ -118,7 +118,7 @@ public:
|
|||
/// @return Level instance containing World instance
|
||||
/// @throws world_load_error on world.json load error
|
||||
static std::unique_ptr<Level> load(
|
||||
const fs::path& directory,
|
||||
const std::shared_ptr<WorldFiles>& worldFiles,
|
||||
EngineSettings& settings,
|
||||
const Content* content,
|
||||
const std::vector<ContentPack>& packs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue