RecipieList.h 717 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. }
  27. const Framework::Text& getName() const
  28. {
  29. return name;
  30. }
  31. };
  32. typedef RecipieListType<Recipie, CraftingStorage> RecipieList;
  33. typedef RecipieListType<ShapedRecipie, ShapedCraftingStorage> ShapedRecipieList;