DimensionGenerator.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. #include "DimensionGenerator.h"
  2. #include <iostream>
  3. #include <Logging.h>
  4. #include <Zeit.h>
  5. #include "Constants.h"
  6. #include "Dimension.h"
  7. #include "Game.h"
  8. #include "NoBlock.h"
  9. #include "Noise.h"
  10. #include "RandNoise.h"
  11. #include "WormCaveGenerator.h"
  12. WorldHeightLayer::WorldHeightLayer()
  13. : ReferenceCounter(),
  14. noiseConfig(0),
  15. noise(0),
  16. value(0)
  17. {}
  18. WorldHeightLayer::~WorldHeightLayer()
  19. {
  20. if (noiseConfig) noiseConfig->release();
  21. if (noise) noise->release();
  22. if (value) value->release();
  23. }
  24. void WorldHeightLayer::initialize(JExpressionMemory* zMemory)
  25. {
  26. if (noise) noise->release();
  27. noise = JNoise::parseNoise(noiseConfig, zMemory);
  28. zMemory->setNoise(name, dynamic_cast<Noise*>(noise->getThis()));
  29. }
  30. void WorldHeightLayer::calculateValue(JExpressionMemory* zMemory)
  31. {
  32. zMemory->setFloatVariable(name, value->getValue(zMemory));
  33. }
  34. void WorldHeightLayer::setNoiseConfig(Framework::JSON::JSONObject* noiseConfig)
  35. {
  36. if (this->noiseConfig) this->noiseConfig->release();
  37. this->noiseConfig = noiseConfig;
  38. }
  39. Framework::JSON::JSONObject* WorldHeightLayer::zNoiseConfig() const
  40. {
  41. return noiseConfig;
  42. }
  43. void WorldHeightLayer::setName(Framework::Text name)
  44. {
  45. this->name = name;
  46. }
  47. Framework::Text WorldHeightLayer::getName() const
  48. {
  49. return name;
  50. }
  51. void WorldHeightLayer::setValue(JFloatExpression* value)
  52. {
  53. if (this->value) this->value->release();
  54. this->value = value;
  55. }
  56. JFloatExpression* WorldHeightLayer::zValue() const
  57. {
  58. return value;
  59. }
  60. WorldHeightLayerFactory::WorldHeightLayerFactory() {}
  61. WorldHeightLayer* WorldHeightLayerFactory::fromJson(
  62. Framework::JSON::JSONObject* zJson) const
  63. {
  64. WorldHeightLayer* result = new WorldHeightLayer();
  65. result->setName(zJson->zValue("name")->asString()->getString());
  66. result->setNoiseConfig(zJson->getValue("noise")->asObject());
  67. result->setValue(
  68. Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
  69. zJson->zValue("value")));
  70. return result;
  71. }
  72. Framework::JSON::JSONObject* WorldHeightLayerFactory::toJsonObject(
  73. WorldHeightLayer* zObject) const
  74. {
  75. Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
  76. result->addValue(
  77. "name", new Framework::JSON::JSONString(zObject->getName()));
  78. result->addValue("noise", zObject->zNoiseConfig());
  79. result->addValue("value",
  80. Game::INSTANCE->zTypeRegistry()->toJson<JFloatExpression>(
  81. zObject->zValue()));
  82. return result;
  83. }
  84. JSONObjectValidationBuilder* WorldHeightLayerFactory::addToValidator(
  85. JSONObjectValidationBuilder* builder) const
  86. {
  87. return builder->withRequiredString("name")
  88. ->finishString()
  89. ->withRequiredAttribute("noise", JNoise::getValidator(false))
  90. ->withRequiredAttribute("value",
  91. Game::INSTANCE->zTypeRegistry()->getValidator<JFloatExpression>());
  92. }
  93. DimensionGenerator::DimensionGenerator()
  94. : ReferenceCounter(),
  95. jExpressionMemory(new JExpressionMemory()),
  96. seedExpression(0),
  97. dimensionId(0)
  98. {}
  99. DimensionGenerator::~DimensionGenerator()
  100. {
  101. jExpressionMemory->release();
  102. if (seedExpression) seedExpression->release();
  103. }
  104. JExpressionMemory* DimensionGenerator::zMemory() const
  105. {
  106. return jExpressionMemory;
  107. }
  108. void DimensionGenerator::calculateHeightLayers()
  109. {
  110. for (WorldHeightLayer* layer : heightLayers)
  111. {
  112. layer->calculateValue(jExpressionMemory);
  113. }
  114. }
  115. Dimension* DimensionGenerator::createDimension()
  116. {
  117. return new Dimension(getId());
  118. }
  119. void DimensionGenerator::initialize(int worldSeed)
  120. {
  121. jExpressionMemory->setFloatVariable("worldSeed", (float)worldSeed);
  122. jExpressionMemory->setFloatVariable(
  123. "dimensionSeed", seedExpression->getValue(jExpressionMemory));
  124. for (WorldHeightLayer* layer : heightLayers)
  125. {
  126. layer->initialize(jExpressionMemory);
  127. }
  128. }
  129. int DimensionGenerator::getDimensionId() const
  130. {
  131. return dimensionId;
  132. }
  133. void DimensionGenerator::addHeightLayer(WorldHeightLayer* layer)
  134. {
  135. heightLayers.add(layer);
  136. }
  137. const Framework::RCArray<WorldHeightLayer>&
  138. DimensionGenerator::getHeightLayers() const
  139. {
  140. return heightLayers;
  141. }
  142. void DimensionGenerator::setName(Framework::Text name)
  143. {
  144. this->name = name;
  145. }
  146. Framework::Text DimensionGenerator::getName() const
  147. {
  148. return name;
  149. }
  150. void DimensionGenerator::setId(int id)
  151. {
  152. dimensionId = id;
  153. }
  154. int DimensionGenerator::getId() const
  155. {
  156. return dimensionId;
  157. }
  158. void DimensionGenerator::setSeed(JFloatExpression* seed)
  159. {
  160. if (seedExpression) seedExpression->release();
  161. seedExpression = seed;
  162. }
  163. JFloatExpression* DimensionGenerator::zSeed() const
  164. {
  165. return seedExpression;
  166. }
  167. BiomedCavedDimensionGenerator::BiomedCavedDimensionGenerator()
  168. : DimensionGenerator(),
  169. caveGenerator(0),
  170. noiseConfig(0),
  171. biomNoise(0)
  172. {}
  173. BiomedCavedDimensionGenerator::~BiomedCavedDimensionGenerator()
  174. {
  175. if (noiseConfig) noiseConfig->release();
  176. if (biomNoise) biomNoise->release();
  177. if (caveGenerator) caveGenerator->release();
  178. }
  179. void BiomedCavedDimensionGenerator::initialize(int worldSeed)
  180. {
  181. if (biomNoise) biomNoise->release();
  182. if (caveGenerator) caveGenerator->release();
  183. DimensionGenerator::initialize(worldSeed);
  184. biomNoise = JNoise::parseNoise(noiseConfig, zMemory());
  185. for (BiomGenerator* gen : biomGenerators)
  186. {
  187. gen->initialize(zMemory());
  188. }
  189. caveGenerator = new WormCaveGenerator(75, 150, 1, 6, 0.1f, worldSeed - 1);
  190. }
  191. BiomGenerator* BiomedCavedDimensionGenerator::zBiomGenerator()
  192. {
  193. for (BiomGenerator* generator : biomGenerators)
  194. {
  195. if (generator->isApplicable(zMemory())) return generator;
  196. }
  197. return 0;
  198. }
  199. Framework::RCArray<GeneratedStructure>*
  200. BiomedCavedDimensionGenerator::getGeneratedStructoresForArea(
  201. Framework::Vec3<int> minPos, Framework::Vec3<int> maxPos)
  202. {
  203. int minSearchX = minPos.x - maxStructureOffset.x;
  204. int minSearchY = minPos.y - maxStructureOffset.y;
  205. int minSearchZ = MAX(minPos.z - maxStructureOffset.z, 0);
  206. int maxSearchX = maxPos.x - minStructureOffset.x;
  207. int maxSearchY = maxPos.y - minStructureOffset.y;
  208. int maxSearchZ = MIN(maxPos.z - minStructureOffset.z, WORLD_HEIGHT - 1);
  209. Framework::RCArray<GeneratedStructure>* result
  210. = new Framework::RCArray<GeneratedStructure>();
  211. for (int x = minSearchX; x <= maxSearchX; x++)
  212. {
  213. for (int y = minSearchY; y <= maxSearchY; y++)
  214. {
  215. zMemory()->setFloatVariable("x", (float)x);
  216. zMemory()->setFloatVariable("y", (float)y);
  217. calculateHeightLayers();
  218. BiomGenerator* gen = zBiomGenerator();
  219. for (int z = minSearchZ; z <= maxSearchZ; z++)
  220. {
  221. zMemory()->setFloatVariable("z", (float)z);
  222. gen->generateStructures(x,
  223. y,
  224. z,
  225. getDimensionId(),
  226. zMemory(),
  227. minPos,
  228. maxPos,
  229. result);
  230. }
  231. }
  232. }
  233. return result;
  234. }
  235. Chunk* BiomedCavedDimensionGenerator::generateChunk(int centerX, int centerY)
  236. {
  237. zMemory()->lock();
  238. Framework::Logging::debug()
  239. << "generating chunk " << centerX << ", " << centerY;
  240. double structureTime = 0;
  241. double structureTime2 = 0;
  242. double structureTime3 = 0;
  243. double caveTime = 0;
  244. double caveTime2 = 0;
  245. double blockGenTime = 0;
  246. double biomTime = 0;
  247. double layerTime = 0;
  248. Framework::ZeitMesser zm;
  249. Framework::ZeitMesser zmGlobal;
  250. zm.messungStart();
  251. zmGlobal.messungStart();
  252. Framework::RCArray<GeneratedStructure>* structures
  253. = getGeneratedStructoresForArea(
  254. Framework::Vec3<int>(
  255. centerX - CHUNK_SIZE / 2, centerY - CHUNK_SIZE / 2, 0),
  256. Framework::Vec3<int>(centerX + CHUNK_SIZE / 2,
  257. centerY + CHUNK_SIZE / 2,
  258. WORLD_HEIGHT - 1));
  259. zm.messungEnde();
  260. structureTime += zm.getSekunden();
  261. zm.messungStart();
  262. CaveChunkGenerator* caveGen
  263. = caveGenerator->getGeneratorForChunk(centerX, centerY);
  264. zm.messungEnde();
  265. caveTime += zm.getSekunden();
  266. Chunk* chunk
  267. = new Chunk(Framework::Punkt(centerX, centerY), getDimensionId());
  268. zMemory()->setCurrentChunk(dynamic_cast<Chunk*>(chunk->getThis()));
  269. for (int x = -CHUNK_SIZE / 2; x < CHUNK_SIZE / 2; x++)
  270. {
  271. for (int y = -CHUNK_SIZE / 2; y < CHUNK_SIZE / 2; y++)
  272. {
  273. zMemory()->setFloatVariable("x", (float)x + (float)centerX);
  274. zMemory()->setFloatVariable("y", (float)y + (float)centerY);
  275. // calculate height layers
  276. zm.messungStart();
  277. calculateHeightLayers();
  278. zm.messungEnde();
  279. layerTime += zm.getSekunden();
  280. // calculate biom
  281. zm.messungStart();
  282. BiomGenerator* biom = zBiomGenerator();
  283. zm.messungEnde();
  284. biomTime += zm.getSekunden();
  285. // generate blocks
  286. for (int z = 0; z < WORLD_HEIGHT; z++)
  287. {
  288. zMemory()->setFloatVariable("z", (float)z);
  289. Framework::Either<Block*, int> generated = BlockTypeEnum::AIR;
  290. bool structureAffected = 0;
  291. // check if the block is inside of a structure
  292. zm.messungStart();
  293. for (auto structure : *structures)
  294. {
  295. if (structure->isBlockAffected(
  296. Framework::Vec3<int>(x + centerX, y + centerY, z)))
  297. {
  298. zm.messungEnde();
  299. structureTime2 += zm.getSekunden();
  300. zm.messungStart();
  301. generated = structure->generateBlockAt(
  302. Framework::Vec3<int>(x + centerX, y + centerY, z),
  303. getDimensionId());
  304. structureAffected = 1;
  305. zm.messungEnde();
  306. structureTime3 += zm.getSekunden();
  307. zm.messungStart();
  308. break;
  309. }
  310. }
  311. zm.messungEnde();
  312. structureTime2 += zm.getSekunden();
  313. if (!structureAffected)
  314. {
  315. // check if block is a cave block
  316. zm.messungStart();
  317. bool inCave
  318. = caveGen->isInCave(x + centerX, y + centerY, z);
  319. zm.messungEnde();
  320. caveTime2 += zm.getSekunden();
  321. if (!inCave)
  322. {
  323. // generate biom block
  324. zm.messungStart();
  325. generated = biom->generateBlock(x + centerX,
  326. y + centerY,
  327. z,
  328. getDimensionId(),
  329. zMemory(),
  330. chunk);
  331. zm.messungEnde();
  332. blockGenTime += zm.getSekunden();
  333. }
  334. }
  335. if (generated.isA())
  336. chunk->putBlockAt(
  337. Framework::Vec3<int>(
  338. x + CHUNK_SIZE / 2, y + CHUNK_SIZE / 2, z),
  339. generated);
  340. else
  341. chunk->putBlockTypeAt(
  342. Framework::Vec3<int>(
  343. x + CHUNK_SIZE / 2, y + CHUNK_SIZE / 2, z),
  344. generated);
  345. }
  346. }
  347. }
  348. caveGen->release();
  349. structures->release();
  350. zmGlobal.messungEnde();
  351. Framework::Logging::trace() << "structureGenerationTime: " << structureTime;
  352. Framework::Logging::trace()
  353. << "structure.isBlockAffected: " << structureTime2;
  354. Framework::Logging::trace()
  355. << "structure.generateBlockAt: " << structureTime3;
  356. Framework::Logging::trace() << "caveGenerationTime: " << caveTime;
  357. Framework::Logging::trace() << "caveEvaluationTime: " << caveTime2;
  358. Framework::Logging::trace() << "blockGenTime: " << blockGenTime;
  359. Framework::Logging::trace() << "biomTime: " << biomTime;
  360. Framework::Logging::trace() << "layerTime: " << layerTime;
  361. Framework::Logging::debug() << "totalTime: " << zmGlobal.getSekunden();
  362. zMemory()->unlock();
  363. return chunk;
  364. }
  365. void BiomedCavedDimensionGenerator::generateEntities(Chunk* zChunk)
  366. {
  367. zMemory()->lock();
  368. zMemory()->setCurrentChunk(dynamic_cast<Chunk*>(zChunk->getThis()));
  369. zMemory()->setFloatVariable("x", (float)zChunk->getCenter().x);
  370. zMemory()->setFloatVariable("y", (float)zChunk->getCenter().y);
  371. calculateHeightLayers();
  372. BiomGenerator* biom = zBiomGenerator();
  373. for (int x = -CHUNK_SIZE / 2; x < CHUNK_SIZE / 2; x++)
  374. {
  375. for (int y = -CHUNK_SIZE / 2; y < CHUNK_SIZE / 2; y++)
  376. {
  377. for (int z = 0; z < WORLD_HEIGHT; z++)
  378. {
  379. if (zChunk->getBlockTypeAt(Framework::Vec3<int>(x, y, z))
  380. == BlockTypeEnum::AIR)
  381. {
  382. zMemory()->setFloatVariable("x", (float)z);
  383. zMemory()->setFloatVariable("y", (float)z);
  384. zMemory()->setFloatVariable("z", (float)z);
  385. biom->generateEntities(
  386. x, y, z, getDimensionId(), zMemory());
  387. }
  388. }
  389. }
  390. }
  391. zMemory()->unlock();
  392. }
  393. Framework::Either<Block*, int> BiomedCavedDimensionGenerator::generateBlock(
  394. Framework::Vec3<int> location)
  395. {
  396. Chunk* zChunk
  397. = Game::INSTANCE->zDimension(getDimensionId())
  398. ->zChunk(Game::INSTANCE->getChunkCenter(location.x, location.y));
  399. if (!zChunk)
  400. {
  401. return BlockTypeEnum::NO_BLOCK;
  402. }
  403. zMemory()->lock();
  404. zMemory()->setCurrentChunk(dynamic_cast<Chunk*>(zChunk->getThis()));
  405. Framework::RCArray<GeneratedStructure>* structures
  406. = getGeneratedStructoresForArea(location, location);
  407. zMemory()->setFloatVariable("x", (float)location.x);
  408. zMemory()->setFloatVariable("y", (float)location.y);
  409. calculateHeightLayers();
  410. BiomGenerator* biom = zBiomGenerator();
  411. zMemory()->setFloatVariable("z", (float)location.z);
  412. for (auto structure : *structures)
  413. {
  414. if (structure->isBlockAffected(location))
  415. {
  416. auto generated
  417. = structure->generateBlockAt(location, getDimensionId());
  418. structures->release();
  419. zMemory()->unlock();
  420. return generated;
  421. }
  422. }
  423. structures->release();
  424. Framework::Punkt chunkCenter = Game::getChunkCenter(location.x, location.y);
  425. CaveChunkGenerator* caveGen
  426. = caveGenerator->getGeneratorForChunk(chunkCenter.x, chunkCenter.y);
  427. if (caveGen->isInCave(location.x, location.y, location.z))
  428. {
  429. caveGen->release();
  430. zMemory()->unlock();
  431. return BlockTypeEnum::AIR;
  432. }
  433. caveGen->release();
  434. auto generated = biom->generateBlock(location.x,
  435. location.y,
  436. location.z,
  437. getDimensionId(),
  438. zMemory(),
  439. zChunk);
  440. zMemory()->unlock();
  441. return generated;
  442. }
  443. bool BiomedCavedDimensionGenerator::spawnStructure(
  444. Framework::Vec3<int> location,
  445. std::function<bool(GeneratorTemplate* tmpl)> filter)
  446. {
  447. zMemory()->lock();
  448. zMemory()->setFloatVariable("x", (float)location.x);
  449. zMemory()->setFloatVariable("y", (float)location.y);
  450. BiomGenerator* biom = zBiomGenerator();
  451. zMemory()->unlock();
  452. for (StructureTemplateCollection* tc : biom->getTemplates())
  453. {
  454. for (GeneratorTemplate* t : tc->getStructures())
  455. {
  456. if (filter(t))
  457. {
  458. RandNoise noise((int)time(0));
  459. GeneratedStructure* genStr
  460. = t->generateAt(location, &noise, getDimensionId());
  461. if (genStr)
  462. {
  463. int minSearchX = location.x + t->getMinAffectedOffset().x;
  464. int minSearchY = location.y + t->getMinAffectedOffset().y;
  465. int minSearchZ
  466. = MAX(location.z + t->getMinAffectedOffset().z, 0);
  467. int maxSearchX = location.x + t->getMaxAffectedOffset().x;
  468. int maxSearchY = location.y + t->getMaxAffectedOffset().y;
  469. int maxSearchZ
  470. = MIN(location.z + t->getMaxAffectedOffset().z,
  471. WORLD_HEIGHT - 1);
  472. for (int x = minSearchX; x <= maxSearchX; x++)
  473. {
  474. for (int y = minSearchY; y <= maxSearchY; y++)
  475. {
  476. for (int z = minSearchZ; z <= maxSearchZ; z++)
  477. {
  478. if (genStr->isBlockAffected(
  479. Framework::Vec3<int>(x, y, z)))
  480. {
  481. auto gen = genStr->generateBlockAt(
  482. Framework::Vec3<int>(x, y, z),
  483. getDimensionId());
  484. Game::INSTANCE->zDimension(getDimensionId())
  485. ->placeBlock(
  486. Framework::Vec3<int>(x, y, z), gen);
  487. }
  488. }
  489. }
  490. }
  491. genStr->release();
  492. zMemory()->unlock();
  493. return 1;
  494. }
  495. }
  496. }
  497. }
  498. return 0;
  499. }
  500. void BiomedCavedDimensionGenerator::addBiomGenerator(
  501. BiomGenerator* biomGenerator)
  502. {
  503. biomGenerators.add(biomGenerator);
  504. if (biomGenerators.getEintragAnzahl() == 1)
  505. {
  506. minStructureOffset = biomGenerator->getMinStructureOffset();
  507. maxStructureOffset = biomGenerator->getMaxStructureOffset();
  508. }
  509. else
  510. {
  511. Framework::Vec3<int> min = biomGenerator->getMinStructureOffset();
  512. Framework::Vec3<int> max = biomGenerator->getMaxStructureOffset();
  513. if (minStructureOffset.x > min.x) minStructureOffset.x = min.x;
  514. if (minStructureOffset.y > min.y) minStructureOffset.y = min.y;
  515. if (minStructureOffset.z > min.z) minStructureOffset.z = min.z;
  516. if (maxStructureOffset.x < max.x) maxStructureOffset.x = max.x;
  517. if (maxStructureOffset.y < max.y) maxStructureOffset.y = max.y;
  518. if (maxStructureOffset.z < max.z) maxStructureOffset.z = max.z;
  519. }
  520. }
  521. const Framework::RCArray<BiomGenerator>&
  522. BiomedCavedDimensionGenerator::getBiomGenerators() const
  523. {
  524. return biomGenerators;
  525. }
  526. void BiomedCavedDimensionGenerator::setBiomNoiseConfig(
  527. Framework::JSON::JSONObject* biomNoiseConfig)
  528. {
  529. if (noiseConfig) noiseConfig->release();
  530. noiseConfig = biomNoiseConfig;
  531. }
  532. Framework::JSON::JSONObject*
  533. BiomedCavedDimensionGenerator::zBiomNoiseConfig() const
  534. {
  535. return noiseConfig;
  536. }
  537. BiomedCavedDimensionGeneratorFactory::BiomedCavedDimensionGeneratorFactory() {}
  538. BiomedCavedDimensionGenerator*
  539. BiomedCavedDimensionGeneratorFactory::createValue(
  540. Framework::JSON::JSONObject* zJson) const
  541. {
  542. return new BiomedCavedDimensionGenerator();
  543. }
  544. BiomedCavedDimensionGenerator* BiomedCavedDimensionGeneratorFactory::fromJson(
  545. Framework::JSON::JSONObject* zJson) const
  546. {
  547. BiomedCavedDimensionGenerator* result
  548. = DimensionGeneratorFactory::fromJson(zJson);
  549. result->setBiomNoiseConfig(zJson->getValue("biomNoise")->asObject());
  550. for (Framework::JSON::JSONValue* value : *zJson->zValue("bioms")->asArray())
  551. {
  552. result->addBiomGenerator(
  553. Game::INSTANCE->zTypeRegistry()->fromJson<BiomGenerator>(value));
  554. }
  555. return result;
  556. }
  557. Framework::JSON::JSONObject* BiomedCavedDimensionGeneratorFactory::toJsonObject(
  558. BiomedCavedDimensionGenerator* zObject) const
  559. {
  560. Framework::JSON::JSONObject* result
  561. = DimensionGeneratorFactory::toJsonObject(zObject);
  562. Framework::JSON::JSONArray* bioms = new Framework::JSON::JSONArray();
  563. for (BiomGenerator* biom : zObject->getBiomGenerators())
  564. {
  565. bioms->addValue(
  566. Game::INSTANCE->zTypeRegistry()->toJson<BiomGenerator>(biom));
  567. }
  568. result->addValue("bioms", bioms);
  569. result->addValue("biomNoise",
  570. dynamic_cast<Framework::JSON::JSONValue*>(
  571. zObject->zBiomNoiseConfig()->getThis()));
  572. return result;
  573. }
  574. JSONObjectValidationBuilder*
  575. BiomedCavedDimensionGeneratorFactory::addToValidator(
  576. JSONObjectValidationBuilder* builder) const
  577. {
  578. return DimensionGeneratorFactory::addToValidator(
  579. builder->withRequiredArray("bioms")
  580. ->addAcceptedTypeInArray(
  581. Game::INSTANCE->zTypeRegistry()->getValidator<BiomGenerator>())
  582. ->finishArray()
  583. ->withRequiredAttribute("biomNoise", JNoise::getValidator(false)));
  584. }
  585. const char* BiomedCavedDimensionGeneratorFactory::getTypeToken() const
  586. {
  587. return "cavedBioms";
  588. }