TreeSeblingBlock.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #pragma once
  2. #include "Block.h"
  3. class TreeSeblingBlockType;
  4. class TreeSeblingBlock : public Block
  5. {
  6. private:
  7. float seblingTicks;
  8. int seblingTicksMax;
  9. const BlockType* wood;
  10. const BlockType* leaves;
  11. public:
  12. TreeSeblingBlock(int typeId,
  13. Framework::Vec3<int> pos,
  14. int dimensionId,
  15. const BlockType* wood,
  16. const BlockType* leaves);
  17. virtual bool onTick(
  18. TickQueue* zQueue, int numTicks, bool& blocked) override;
  19. virtual void onPostTick() override;
  20. virtual Framework::Text getTargetUIML();
  21. friend TreeSeblingBlockType;
  22. };
  23. class TreeSeblingBlockType : public BlockType
  24. {
  25. private:
  26. Framework::Text itemTypeName;
  27. int itemTypeId;
  28. bool transparent;
  29. bool passable;
  30. float speedModifier;
  31. bool interactable;
  32. Framework::Text woodTypeName;
  33. Framework::Text leavesTypeName;
  34. int woodTypeId;
  35. int leavesTypeId;
  36. public:
  37. TreeSeblingBlockType();
  38. protected:
  39. virtual void createSuperBlock(Block* zBlock, Item* zItem) const override;
  40. virtual void loadSuperBlock(Block* zBlock,
  41. Framework::StreamReader* zReader,
  42. int dimensionId) const override;
  43. virtual void saveSuperBlock(
  44. Block* zBlock, Framework::StreamWriter* zWriter) const override;
  45. virtual Item* createItem() const override;
  46. virtual Block* createBlock(
  47. Framework::Vec3<int> position, int dimensionId) const override;
  48. public:
  49. virtual bool initialize(Game* zGame) override;
  50. virtual ItemType* createItemType() const override;
  51. void setItemTypeName(Framework::Text itemTypeName);
  52. Framework::Text getItemTypeName() const;
  53. void setWoodTypeName(Framework::Text woodTypeName);
  54. Framework::Text getWoodTypeName() const;
  55. void setLeavesTypeName(Framework::Text leavesTypeName);
  56. Framework::Text getLeavesTypeName() const;
  57. void setTransparent(bool transparent);
  58. bool isTransparent() const;
  59. void setPassable(bool passable);
  60. bool isPassable() const;
  61. void setSpeedModifier(float speedModifier);
  62. float getSpeedModifier() const;
  63. void setInteractable(bool interactable);
  64. bool isInteractable() const;
  65. };
  66. class TreeSeblingBlockTypeFactory
  67. : public BlockTypeFactoryBase<TreeSeblingBlockType>
  68. {
  69. public:
  70. TreeSeblingBlockTypeFactory();
  71. TreeSeblingBlockType* createValue(
  72. Framework::JSON::JSONObject* zJson) const override;
  73. void fromJson(TreeSeblingBlockType* zResult,
  74. Framework::JSON::JSONObject* zJson) const override;
  75. void toJson(TreeSeblingBlockType* zObject,
  76. Framework::JSON::JSONObject* zResult) const override;
  77. JSONObjectValidationBuilder* addToValidator(
  78. JSONObjectValidationBuilder* builder) const override;
  79. Framework::Text getTypeToken() const override;
  80. };