Recipie.h 1.2 KB

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