CraftingStorage.h 1.7 KB

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