RecipieList.cpp 759 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "RecipieList.h"
  2. RecipieList::RecipieList(Framework::Text name)
  3. : ReferenceCounter(),
  4. name(name)
  5. {}
  6. void RecipieList::addRecipie(Recipie* recipie)
  7. {
  8. recipies.add(recipie);
  9. }
  10. Recipie* RecipieList::zFirstRecipie(CraftingStorage* zStorage)
  11. {
  12. for (Recipie* recipie : recipies)
  13. {
  14. if (recipie->testApplicability(zStorage)) return recipie;
  15. }
  16. return 0;
  17. }
  18. const Framework::Text& RecipieList::getName() const
  19. {
  20. return name;
  21. }
  22. void RecipieList::findRecipies(
  23. int itemTypeId, Framework::RCArray<Recipie>& recipies)
  24. {
  25. for (Recipie* recipie : this->recipies)
  26. {
  27. if (recipie->createsOutput(itemTypeId))
  28. {
  29. recipies.add(dynamic_cast<Recipie*>(recipie->getThis()));
  30. }
  31. }
  32. }