GenerationTemplate.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "GenerationTemplate.h"
  2. GenerationTemplate::GenerationTemplate(float propability, int minSurfaceDist, int maxSurfaceDist, Framework::Vec3<int> minPosOffset, Framework::Vec3<int> maxSize)
  3. : ReferenceCounter(),
  4. propability(propability),
  5. minSurfaceDist(minSurfaceDist),
  6. maxSurfaceDist(maxSurfaceDist),
  7. minPosOffset(minPosOffset),
  8. maxSize(maxSize)
  9. {}
  10. bool GenerationTemplate::canEffect(Framework::Vec3<int> location, Framework::Vec3<int> affectedLocation) const
  11. {
  12. Framework::Vec3<int> localPos = affectedLocation - (location + minPosOffset);
  13. return localPos.x >= 0 && localPos.y >= 0 && localPos.z >= 0 && localPos.x < maxSize.x&& localPos.y < maxSize.y&& localPos.z < maxSize.z;
  14. }
  15. bool GenerationTemplate::isGenerationPossable(Framework::Vec3<int> location, int distToSurface) const
  16. {
  17. return distToSurface >= minSurfaceDist && distToSurface <= maxSurfaceDist;
  18. }
  19. float GenerationTemplate::getPropability() const
  20. {
  21. return propability;
  22. }
  23. Framework::Vec3<int> GenerationTemplate::getMinAffectedOffset() const
  24. {
  25. return minPosOffset;
  26. }
  27. Framework::Vec3<int> GenerationTemplate::getMaxAffectedOffset() const
  28. {
  29. return minPosOffset + maxSize;
  30. }