#pragma once #include #include #include "GeneratedStructure.h" #include "Noise.h" class GeneratorTemplate : public Framework::ReferenceCounter { private: float propability; Framework::Vec3 minPosOffset; Framework::Vec3 maxSize; public: GeneratorTemplate(); protected: void setMinPosOffset(Framework::Vec3 minPosOffset); void setMaxSize(Framework::Vec3 maxSize); public: void setPropability(float propability); virtual bool canEffect(Framework::Vec3 location, Framework::Vec3 affectedLocation) const; virtual GeneratedStructure* generateAt( Framework::Vec3 location, Noise* zNoise, int dimensionId) = 0; float getPropability() const; Framework::Vec3 getMinAffectedOffset() const; Framework::Vec3 getMaxAffectedOffset() const; }; template class GeneratorTemplateFactory : public SubTypeFactory { public: GeneratorTemplateFactory() : SubTypeFactory() {} void fromJson(S* zResult, Framework::JSON::JSONObject* zJson) const override { GeneratorTemplate* zRecipie = dynamic_cast(zResult); zRecipie->setPropability( (float)zJson->zValue("propability")->asNumber()->getNumber()); } void toJson(S* zObject, Framework::JSON::JSONObject* zResult) const override { GeneratorTemplate* zRecipie = dynamic_cast(zResult); zResult->addValue("propability", new Framework::JSON::JSONNumber(zRecipie->getPropability())); }; JSONObjectValidationBuilder* addToValidator( JSONObjectValidationBuilder* builder) const override { return builder->withRequiredNumber("propability")->finishNumber(); } };