CraftingStorage.h 2.3 KB

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