Auto content packs detection

This commit is contained in:
MihailRis
2023-12-20 20:54:03 +03:00
parent bcfdc55277
commit 3ad903449e
8 changed files with 93 additions and 100 deletions
+13 -5
View File
@@ -27,9 +27,11 @@ World::World(string name,
path directory,
uint64_t seed,
EngineSettings& settings,
const Content* content)
const Content* content,
const std::vector<ContentPack> packs)
: settings(settings),
content(content),
packs(packs),
name(name),
seed(seed) {
wfile = new WorldFiles(directory, settings.debug);
@@ -71,8 +73,9 @@ Level* World::create(string name,
path directory,
uint64_t seed,
EngineSettings& settings,
const Content* content) {
World* world = new World(name, directory, seed, settings, content);
const Content* content,
const std::vector<ContentPack>& packs) {
World* world = new World(name, directory, seed, settings, content, packs);
Player* player = new Player(vec3(0, DEF_PLAYER_Y, 0), DEF_PLAYER_SPEED);
return new Level(world, content, player, settings);
}
@@ -88,8 +91,9 @@ ContentLUT* World::checkIndices(const path& directory,
Level* World::load(path directory,
EngineSettings& settings,
const Content* content) {
unique_ptr<World> world (new World(".", directory, 0, settings, content));
const Content* content,
const std::vector<ContentPack>& packs) {
unique_ptr<World> world (new World(".", directory, 0, settings, content, packs));
auto& wfile = world->wfile;
if (!wfile->readWorldInfo(world.get())) {
@@ -103,3 +107,7 @@ Level* World::load(path directory,
world.release();
return level;
}
const std::vector<ContentPack>& World::getPacks() const {
return packs;
}
+12 -3
View File
@@ -2,12 +2,15 @@
#define WORLD_WORLD_H_
#include <string>
#include <vector>
#include <filesystem>
#include <stdexcept>
#include "../typedefs.h"
#include "../settings.h"
#include "../util/timeutil.h"
#include "../content/ContentPack.h"
class Content;
class WorldFiles;
class Chunks;
@@ -23,6 +26,7 @@ public:
class World {
EngineSettings& settings;
const Content* const content;
std::vector<ContentPack> packs;
public:
std::string name;
WorldFiles* wfile;
@@ -39,7 +43,8 @@ public:
std::filesystem::path directory,
uint64_t seed,
EngineSettings& settings,
const Content* content);
const Content* content,
std::vector<ContentPack> packs);
~World();
void updateTimers(float delta);
@@ -52,10 +57,14 @@ public:
std::filesystem::path directory,
uint64_t seed,
EngineSettings& settings,
const Content* content);
const Content* content,
const std::vector<ContentPack>& packs);
static Level* load(std::filesystem::path directory,
EngineSettings& settings,
const Content* content);
const Content* content,
const std::vector<ContentPack>& packs);
const std::vector<ContentPack>& getPacks() const;
};
#endif /* WORLD_WORLD_H_ */