CraftingStorage.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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<ItemFilter>& filters,
  12. Framework::Array<int>& inputAmount)
  13. = 0;
  14. virtual bool hasFreeSpace(const Item* zItem, int amount) = 0;
  15. virtual bool consume(Framework::RCArray<ItemFilter>& filters,
  16. Framework::Array<int>& inputAmount)
  17. = 0;
  18. virtual void addCraftingResult(ItemStack* stack) = 0;
  19. };
  20. class ShapedCraftingStorage
  21. {
  22. public:
  23. virtual bool isAllAvailable(
  24. Framework::RCArray<ItemFilter>& filters, int width, int height)
  25. = 0;
  26. virtual bool hasFreeSpace(const Item* zItem, int amount) = 0;
  27. virtual bool consume(Framework::RCArray<ItemFilter>& filters,
  28. Framework::RCArray<ItemModifier>& modifiers,
  29. int width,
  30. int height)
  31. = 0;
  32. virtual void addCraftingResult(ItemStack* stack) = 0;
  33. };
  34. class BasicShapedCrafter : public ShapedCraftingStorage
  35. {
  36. private:
  37. Framework::Array<ItemSlot*> craftingInput;
  38. Inventory* zInventory;
  39. ShapedRecipie* currentRecipie;
  40. Framework::Text recipieList;
  41. int width;
  42. int height;
  43. void getOutputPreview(NetworkMessage* zMsg);
  44. public:
  45. BasicShapedCrafter(int width,
  46. int height,
  47. Inventory* zInventory,
  48. Framework::Text recipieList);
  49. virtual bool isAllAvailable(Framework::RCArray<ItemFilter>& filters,
  50. int width,
  51. int height) override;
  52. virtual bool hasFreeSpace(const Item* zItem, int amount) override;
  53. virtual bool consume(Framework::RCArray<ItemFilter>& filters,
  54. Framework::RCArray<ItemModifier>& modifiers,
  55. int width,
  56. int height) override;
  57. virtual void addCraftingResult(ItemStack* stack) override;
  58. void applyCurrentRecipie();
  59. void calculateOutputPreview();
  60. };