CLifeTimeRandom.cpp 901 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "CLifeTimeRandom.h"
  2. using namespace wp::core::Objects::Particles::Initializers;
  3. CLifeTimeRandom* CLifeTimeRandom::fromJSON (json data, irr::u32 id)
  4. {
  5. json::const_iterator min_it = data.find ("min");
  6. json::const_iterator max_it = data.find ("max");
  7. if (min_it == data.end ())
  8. {
  9. throw std::runtime_error ("Lifetimerandom initializer must have a minimum value");
  10. }
  11. if (max_it == data.end ())
  12. {
  13. throw std::runtime_error ("Lifetimerandom initializer must have a maximum value");
  14. }
  15. return new CLifeTimeRandom (id, *min_it, *max_it);
  16. }
  17. CLifeTimeRandom::CLifeTimeRandom (irr::u32 id, irr::u32 min, irr::u32 max) :
  18. CInitializer (id, "lifetimerandom"),
  19. m_min (min),
  20. m_max (max)
  21. {
  22. }
  23. irr::u32 CLifeTimeRandom::getMinimum ()
  24. {
  25. return this->m_min;
  26. }
  27. irr::u32 CLifeTimeRandom::getMaximum ()
  28. {
  29. return this->m_max;
  30. }