123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- #pragma once
- #include <Array.h>
- #include <Either.h>
- #include <ReferenceCounter.h>
- #include "BiomGenerator.h"
- #include "CaveGenerator.h"
- #include "Chunk.h"
- #include "JNoise.h"
- #include "JsonExpression.h"
- class DimensionGenerator;
- class WorldHeightLayer : public virtual Framework::ReferenceCounter
- {
- private:
- Noise* noise;
- Framework::Text name;
- JFloatExpression* value;
- public:
- WorldHeightLayer(
- Framework::JSON::JSONValue* zConfig, JExpressionMemory* zMemory);
- ~WorldHeightLayer();
- void calculateValue(JExpressionMemory* zMemory);
- static Framework::JSON::Validator::JSONValidator* getValidator();
- };
- class DimensionGenerator : public virtual Framework::ReferenceCounter
- {
- private:
- JExpressionMemory* jExpressionMemory;
- Framework::RCArray<WorldHeightLayer> heightLayers;
- const int dimensionId;
- protected:
- DimensionGenerator(
- Framework::JSON::JSONValue* zConfig, int worldSeed, int dimensionId);
- ~DimensionGenerator();
- JExpressionMemory* zMemory() const;
- void calculateHeightLayers();
- public:
- virtual Chunk* generateChunk(int centerX, int centerY) = 0;
- virtual Framework::Either<Block*, int> generateBlock(
- Framework::Vec3<int> location)
- = 0;
- virtual bool spawnStructure(Framework::Vec3<int> location,
- std::function<bool(GeneratorTemplate* tmpl)> filter)
- = 0;
- int getDimensionId() const;
- template<typename T>
- static Framework::JSON::Validator::ObjectValidationBuilder<T>*
- addConfigAttributes(
- Framework::JSON::Validator::ObjectValidationBuilder<T>* zBuilder)
- {
- return zBuilder
- ->withRequiredAttribute(
- "dimensionSeed", JExpressionParser::getFloatValidator())
- ->withRequiredAttribute("heightLayers",
- Framework::JSON::Validator::JSONValidator::buildForArray()
- ->withDefault(new Framework::JSON::JSONArray())
- ->removeInvalidEntries()
- ->addAcceptedTypeInArray(WorldHeightLayer::getValidator())
- ->finishArray());
- }
- };
- class BiomGenerator;
- class BiomedCavedDimensionGenerator : public DimensionGenerator
- {
- private:
- Framework::RCArray<BiomGenerator> biomGenerators;
- CaveGenerator* caveGenerator;
- Noise* biomNoise;
- Framework::Vec3<int> minStructureOffset;
- Framework::Vec3<int> maxStructureOffset;
- BiomGenerator* zBiomGenerator();
- protected:
- Framework::RCArray<GeneratedStructure>* getGeneratedStructoresForArea(
- Framework::Vec3<int> minPos, Framework::Vec3<int> maxPos);
- public:
- BiomedCavedDimensionGenerator(
- Framework::JSON::JSONValue* zConfig, int worldSeed, int dimensionId);
- ~BiomedCavedDimensionGenerator();
- Chunk* generateChunk(int centerX, int centerY);
- Framework::Either<Block*, int> generateBlock(Framework::Vec3<int> location);
- bool spawnStructure(Framework::Vec3<int> location,
- std::function<bool(GeneratorTemplate* tmpl)> filter);
- template<typename T>
- static Framework::JSON::Validator::ObjectValidationBuilder<T>*
- addConfigAttributes(
- Framework::JSON::Validator::ObjectValidationBuilder<T>* zBuilder)
- {
- return DimensionGenerator::addConfigAttributes(zBuilder
- ->withRequiredArray("bioms")
- ->addAcceptedTypeInArray(BiomGenerator::getConfigValidator())
- ->finishArray()
- ->withRequiredAttribute("biomNoise", JNoise::getValidator(false)));
- }
- };
|