mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 20:41:49 +00:00
Merge pull request #840 from MihailRis/environments
environments (part 1)
This commit is contained in:
commit
8b520a3787
28 changed files with 601 additions and 311 deletions
|
|
@ -25,7 +25,7 @@ const uint MIN_SURROUNDING = 9;
|
|||
ChunksController::ChunksController(Level& level)
|
||||
: level(level),
|
||||
generator(std::make_unique<WorldGenerator>(
|
||||
level.content.generators.require(level.getWorld()->getGenerator()),
|
||||
level.content.generators.require(level.environment.generator),
|
||||
level.content,
|
||||
level.getWorld()->getSeed()
|
||||
)) {}
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ void EngineController::onMissingContent(
|
|||
if (engine.isHeadless()) {
|
||||
throw std::runtime_error(
|
||||
"missing content: " +
|
||||
json::stringify(create_missing_content_report(report), true, " ")
|
||||
util::quote(json::stringify(create_missing_content_report(report), true, " "))
|
||||
);
|
||||
} else {
|
||||
engine.setScreen(std::make_shared<MenuScreen>(engine));
|
||||
|
|
@ -268,7 +268,7 @@ inline uint64_t str2seed(const std::string& seedstr) {
|
|||
void EngineController::createWorld(
|
||||
const std::string& name,
|
||||
const std::string& seedstr,
|
||||
const std::string& generatorID
|
||||
const std::string& environment
|
||||
) {
|
||||
uint64_t seed = str2seed(seedstr);
|
||||
|
||||
|
|
@ -279,17 +279,31 @@ void EngineController::createWorld(
|
|||
paths.setCurrentWorldFolder(folder);
|
||||
engine.getContentControl().loadContent();
|
||||
});
|
||||
const auto& generators = engine.getContentControl().get()->generators;
|
||||
|
||||
// generator-based environments must die in 1.0
|
||||
bool genBasedEnv = false;
|
||||
if (auto genDef = generators.find(environment)) {
|
||||
genBasedEnv = true;
|
||||
}
|
||||
|
||||
auto& contentControl = engine.getContentControl();
|
||||
auto level = World::create(
|
||||
name,
|
||||
generatorID,
|
||||
genBasedEnv ? "" : environment,
|
||||
genBasedEnv ? environment : "",
|
||||
folder,
|
||||
seed,
|
||||
engine.getSettings(),
|
||||
*contentControl.get(),
|
||||
contentControl.getContentPacks()
|
||||
);
|
||||
|
||||
// generator-based environment initialization
|
||||
if (genBasedEnv) {
|
||||
level->environment.generator = environment;
|
||||
}
|
||||
|
||||
if (!engine.isHeadless()) {
|
||||
level->players->create(localPlayer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ void LevelController::saveWorld() {
|
|||
world->wfile->createDirectories();
|
||||
scripting::on_world_save();
|
||||
level->onSave();
|
||||
level->getWorld()->write(level.get());
|
||||
level->getWorld()->write(*level);
|
||||
}
|
||||
|
||||
void LevelController::onWorldQuit() {
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ static int l_is_night(lua::State* L) {
|
|||
}
|
||||
|
||||
static int l_get_generator(lua::State* L) {
|
||||
return lua::pushstring(L, require_world_info().generator);
|
||||
return lua::pushstring(L, require_level().environment.generator);
|
||||
}
|
||||
|
||||
static int l_get_chunk_data(lua::State* L) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue