TreeSeblingBlock.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 TickSourceType isTickSource() const override;
  21. virtual Framework::Text getTargetUIML();
  22. friend TreeSeblingBlockType;
  23. };
  24. class TreeSeblingBlockType : public BlockType
  25. {
  26. private:
  27. Framework::Text itemTypeName;
  28. int itemTypeId;
  29. bool transparent;
  30. bool passable;
  31. float speedModifier;
  32. bool interactable;
  33. Framework::Text woodTypeName;
  34. Framework::Text leavesTypeName;
  35. int woodTypeId;
  36. int leavesTypeId;
  37. public:
  38. TreeSeblingBlockType();
  39. protected:
  40. virtual void createSuperBlock(Block* zBlock, Item* zItem) const override;
  41. virtual void loadSuperBlock(Block* zBlock,
  42. Framework::StreamReader* zReader,
  43. int dimensionId) const override;
  44. virtual void saveSuperBlock(
  45. Block* zBlock, Framework::StreamWriter* zWriter) const override;
  46. virtual Item* createItem() const override;
  47. virtual Block* createBlock(
  48. Framework::Vec3<int> position, int dimensionId) const override;
  49. public:
  50. virtual bool initialize(Game* zGame) override;
  51. virtual ItemType* createItemType() const override;
  52. void setItemTypeName(Framework::Text itemTypeName);
  53. Framework::Text getItemTypeName() const;
  54. void setWoodTypeName(Framework::Text woodTypeName);
  55. Framework::Text getWoodTypeName() const;
  56. void setLeavesTypeName(Framework::Text leavesTypeName);
  57. Framework::Text getLeavesTypeName() const;
  58. void setTransparent(bool transparent);
  59. bool isTransparent() const;
  60. void setPassable(bool passable);
  61. bool isPassable() const;
  62. void setSpeedModifier(float speedModifier);
  63. float getSpeedModifier() const;
  64. void setInteractable(bool interactable);
  65. bool isInteractable() const;
  66. };
  67. class TreeSeblingBlockTypeFactory
  68. : public BlockTypeFactoryBase<TreeSeblingBlockType>
  69. {
  70. public:
  71. TreeSeblingBlockTypeFactory();
  72. TreeSeblingBlockType* createValue(
  73. Framework::JSON::JSONObject* zJson) const override;
  74. void fromJson(TreeSeblingBlockType* zResult,
  75. Framework::JSON::JSONObject* zJson) const override;
  76. void toJson(TreeSeblingBlockType* zObject,
  77. Framework::JSON::JSONObject* zResult) const override;
  78. JSONObjectValidationBuilder* addToValidator(
  79. JSONObjectValidationBuilder* builder) const override;
  80. Framework::Text getTypeToken() const override;
  81. };