GrasslandBiom.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "GrasslandBiom.h"
  2. #include "BlockType.h"
  3. #include "BasicBlocks.h"
  4. #include "FastNoiseLite.h"
  5. #include "FastNoiseWrapper.h"
  6. #include "TreeTemplate.h"
  7. GrasslandBiom::GrasslandBiom()
  8. : BiomGenerator()
  9. {
  10. addTemplateGenerator(new TreeTemplate(0.02f, BirchBlockType::INSTANCE, LeavesBlockType::INSTANCE, 8, 15));
  11. addTemplateGenerator(new TreeTemplate(0.01f, BeechBlockType::INSTANCE, LeavesBlockType::INSTANCE, 8, 13));
  12. addTemplateGenerator(new TreeTemplate(0.005f, OakBlockType::INSTANCE, LeavesBlockType::INSTANCE, 10, 15));
  13. heightNoise = 0;
  14. }
  15. GrasslandBiom::~GrasslandBiom()
  16. {
  17. if (heightNoise)
  18. heightNoise->release();
  19. }
  20. Framework::Either<Block*, int> GrasslandBiom::generateSurfaceBlock(int x, int y, int z)
  21. {
  22. return DirtBlockType::ID;
  23. }
  24. Framework::Either<Block*, int> GrasslandBiom::generateBelowSurfaceBlock(int x, int y, int z)
  25. {
  26. return StoneBlockType::ID;
  27. }
  28. Noise* GrasslandBiom::zHeightMapNoise(int seed)
  29. {
  30. if (heightNoise)
  31. return heightNoise;
  32. FastNoiseLite* noise = new FastNoiseLite(seed);
  33. noise->SetNoiseType(FastNoiseLite::NoiseType::NoiseType_ValueCubic);
  34. FastNoiseWrapper* wrapper = new FastNoiseWrapper(noise, seed);
  35. wrapper->setMultiplier(0.2f);
  36. heightNoise = wrapper;
  37. return heightNoise;
  38. }