Recipie.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include <Array.h>
  3. #include <JSON.h>
  4. #include "ItemFilter.h"
  5. #include "ItemModifier.h"
  6. class CraftingStorage;
  7. class ShapedCraftingStorage;
  8. struct ItemInfo
  9. {
  10. int type;
  11. int count;
  12. float hp;
  13. float maxHp;
  14. float durability;
  15. float maxDurability;
  16. };
  17. class Recipie : public virtual Framework::ReferenceCounter
  18. {
  19. private:
  20. Framework::RCArray<ItemFilter> filters;
  21. Framework::Array<int> inputAmount;
  22. Framework::RCArray<Item> outputs;
  23. Framework::Array<int> outputAmount;
  24. public:
  25. Recipie();
  26. void addIngredient(ItemFilter* filter, int amount);
  27. void addOutput(Item* item, int amount);
  28. bool testApplicability(CraftingStorage* zStorage);
  29. void apply(CraftingStorage* zStorage);
  30. };
  31. class ShapedRecipie : public virtual Framework::ReferenceCounter
  32. {
  33. private:
  34. Framework::RCArray<ItemFilter> filters;
  35. Framework::RCArray<ItemModifier> modifiers;
  36. int width;
  37. int height;
  38. Item* output;
  39. int outputAmount;
  40. public:
  41. ShapedRecipie(int width, int height);
  42. ~ShapedRecipie();
  43. void setIngredient(int x, int y, ItemFilter* filter, ItemModifier* modifier);
  44. void setOutput(Item* item, int amount);
  45. bool testApplicability(ShapedCraftingStorage* zStorage);
  46. void apply(ShapedCraftingStorage* zStorage);
  47. Framework::Array<ItemInfo> getOutput(ShapedCraftingStorage* zStorage);
  48. };