Recipie.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. protected:
  20. Framework::RCArray<Item> outputs;
  21. Framework::Array<int> outputAmount;
  22. public:
  23. Recipie();
  24. virtual void addOutput(Item* item, int amount);
  25. virtual bool testApplicability(CraftingStorage* zStorage) = 0;
  26. virtual void apply(CraftingStorage* zStorage) = 0;
  27. virtual Framework::Text getRecipieUIML() = 0;
  28. virtual Framework::Array<ItemInfo> getOutput(
  29. CraftingStorage* zStorage) const;
  30. virtual bool createsOutput(const ItemType* zType);
  31. };
  32. class UnshapedRecipie : public Recipie
  33. {
  34. private:
  35. Framework::RCArray<ItemFilter> filters;
  36. Framework::RCArray<ItemModifier> modifiers;
  37. Framework::Array<int> inputAmount;
  38. public:
  39. UnshapedRecipie();
  40. void addIngredient(ItemFilter* filter, int amount, ItemModifier* modifier);
  41. bool testApplicability(CraftingStorage* zStorage) override;
  42. void apply(CraftingStorage* zStorage) override;
  43. Framework::Text getRecipieUIML() override;
  44. };
  45. class ShapedRecipie : public Recipie
  46. {
  47. private:
  48. Framework::RCArray<ItemFilter> filters;
  49. Framework::RCArray<ItemModifier> modifiers;
  50. Framework::Array<int> inputAmount;
  51. int width;
  52. int height;
  53. public:
  54. ShapedRecipie(int width, int height);
  55. void setIngredient(
  56. int x, int y, ItemFilter* filter, ItemModifier* modifier);
  57. bool testApplicability(CraftingStorage* zStorage) override;
  58. void apply(CraftingStorage* zStorage) override;
  59. Framework::Text getRecipieUIML() override;
  60. };