lifetimerandom.cpp 880 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "lifetimerandom.h"
  2. using namespace wp::core::objects::particles::initializers;
  3. lifetimerandom* lifetimerandom::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 lifetimerandom (id, *min_it, *max_it);
  16. }
  17. lifetimerandom::lifetimerandom (irr::u32 id, irr::u32 min, irr::u32 max) :
  18. initializer (id, "lifetimerandom"),
  19. m_min (min),
  20. m_max (max)
  21. {
  22. }
  23. irr::u32 lifetimerandom::getMinimum ()
  24. {
  25. return this->m_min;
  26. }
  27. irr::u32 lifetimerandom::getMaximum ()
  28. {
  29. return this->m_max;
  30. }