Recipie.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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(
  44. int x, int y, ItemFilter* filter, ItemModifier* modifier);
  45. void setOutput(Item* item, int amount);
  46. bool testApplicability(ShapedCraftingStorage* zStorage);
  47. void apply(ShapedCraftingStorage* zStorage);
  48. Framework::Array<ItemInfo> getOutput(ShapedCraftingStorage* zStorage);
  49. };