CraftingStorage.h 1.7 KB

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