CraftingStorage.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include <Array.h>
  3. #include "ItemStack.h"
  4. #include "ItemFilter.h"
  5. #include "ItemSlot.h"
  6. #include "Inventory.h"
  7. class CraftingStorage
  8. {
  9. public:
  10. virtual bool isAllAvailable(Framework::RCArray<ItemFilter>& filters, Framework::Array<int>& inputAmount) = 0;
  11. virtual bool hasFreeSpace(const Item* zItem, int amount) = 0;
  12. virtual bool consume(Framework::RCArray<ItemFilter>& filters, Framework::Array<int>& inputAmount) = 0;
  13. virtual void addCraftingResult(ItemStack* stack) = 0;
  14. };
  15. class ShapedCraftingStorage
  16. {
  17. public:
  18. virtual bool isAllAvailable(Framework::RCArray<ItemFilter>& filters, int width, int height) = 0;
  19. virtual bool hasFreeSpace(const Item* zItem, int amount) = 0;
  20. virtual bool consume(Framework::RCArray<ItemFilter>& filters, int width, int height) = 0;
  21. virtual void addCraftingResult(ItemStack* stack) = 0;
  22. };
  23. class BasicShapedCrafter : public ShapedCraftingStorage
  24. {
  25. private:
  26. Framework::Array<ItemSlot*> craftingInput;
  27. Inventory* zInventory;
  28. int width;
  29. int height;
  30. public:
  31. BasicShapedCrafter(int width, int height, Inventory* zInventory);
  32. virtual bool isAllAvailable(Framework::RCArray<ItemFilter>& filters, int width, int height);
  33. virtual bool hasFreeSpace(const Item* zItem, int amount);
  34. virtual bool consume(Framework::RCArray<ItemFilter>& filters, int width, int height);
  35. virtual void addCraftingResult(ItemStack* stack);
  36. };