RecipieList.h 729 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include <Text.h>
  3. #include "Recipie.h"
  4. template <typename T, typename S>
  5. class RecipieListType : public virtual Framework::ReferenceCounter
  6. {
  7. private:
  8. Framework::RCArray<T> recipies;
  9. Framework::Text name;
  10. public:
  11. RecipieListType(const char* name)
  12. : ReferenceCounter(),
  13. name(name)
  14. {}
  15. void addRecipie(T* recipie)
  16. {
  17. recipies.add(recipie);
  18. }
  19. T* zFirstRecipie(S* zStorage)
  20. {
  21. for (T* recipie : recipies)
  22. {
  23. if (recipie->testApplicability(zStorage))
  24. return recipie;
  25. }
  26. return 0;
  27. }
  28. const Framework::Text& getName() const
  29. {
  30. return name;
  31. }
  32. };
  33. typedef RecipieListType<Recipie, CraftingStorage> RecipieList;
  34. typedef RecipieListType<ShapedRecipie, ShapedCraftingStorage> ShapedRecipieList;