mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add 'player-min-spawn-height', 'player-max-spawn-height' generator parameters
This commit is contained in:
parent
fda8e9753a
commit
4befbb0086
3 changed files with 7 additions and 1 deletions
|
|
@ -219,6 +219,8 @@ void ContentLoader::loadGenerator(
|
|||
map.at("sea-level").get(def.seaLevel);
|
||||
map.at("wide-structs-chunks-radius").get(def.wideStructsChunksRadius);
|
||||
map.at("player-spawn-radius").get(def.playerSpawnRadius);
|
||||
map.at("player-min-spawn-height").get(def.playerMinSpawnHeight);
|
||||
map.at("player-max-spawn-height").get(def.playerMaxSpawnHeight);
|
||||
if (map.has("heightmap-inputs")) {
|
||||
for (const auto& element : map["heightmap-inputs"]) {
|
||||
int index = element.asInteger();
|
||||
|
|
|
|||
|
|
@ -128,7 +128,9 @@ void Player::attemptToChooseSpawnpoint() {
|
|||
const auto& generatorDef =
|
||||
level.content.generators.require(level.getWorld()->getGenerator());
|
||||
|
||||
glm::vec3 newpos {0.0f, random.randFloat() * 100 + 100, 0.0f};
|
||||
int minHeight = generatorDef.playerMinSpawnHeight;
|
||||
int maxHeight = generatorDef.playerMaxSpawnHeight;
|
||||
glm::vec3 newpos {0.0f, random.randFloat() * (maxHeight - minHeight + 1) + minHeight, 0.0f};
|
||||
double angle = random.randDouble() * glm::two_pi<double>();
|
||||
double radius = glm::sqrt(random.randDouble());
|
||||
newpos.x += glm::cos(angle) * generatorDef.playerSpawnRadius * radius;
|
||||
|
|
|
|||
|
|
@ -214,6 +214,8 @@ struct GeneratorDef {
|
|||
uint heightsBPD = 4;
|
||||
|
||||
float playerSpawnRadius = DEFAULT_PLAYER_SPAWN_RADIUS;
|
||||
int playerMinSpawnHeight = CHUNK_H / 4;
|
||||
int playerMaxSpawnHeight = CHUNK_H;
|
||||
|
||||
/// @brief Biome parameter maps interpolation method
|
||||
InterpolationType biomesInterpolation = InterpolationType::LINEAR;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue