BasicBlocks.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #include "Block.h"
  3. #include "BlockType.h"
  4. #include "Item.h"
  5. class BlockType;
  6. class ItemType;
  7. class BasicBlockType;
  8. class BasicBlock : public Block
  9. {
  10. public:
  11. BasicBlock(
  12. int typeId, ItemType* zTool, Framework::Vec3<int> pos, int dimensionId);
  13. BasicBlock(int typeId,
  14. ItemType* zTool,
  15. Framework::Vec3<int> pos,
  16. int dimensionId,
  17. bool hasInventory);
  18. virtual bool onTick(
  19. TickQueue* zQueue, int numTicks, bool& blocked) override;
  20. virtual void onPostTick() override;
  21. friend BasicBlockType;
  22. };
  23. struct SpawnConfig
  24. {
  25. int min;
  26. int max;
  27. double chance;
  28. int itemType;
  29. };
  30. class AdditionalItemSpawningBlock : public BasicBlock
  31. {
  32. private:
  33. Framework::Array<SpawnConfig> spawns;
  34. public:
  35. AdditionalItemSpawningBlock(
  36. int typeId, ItemType* zTool, Framework::Vec3<int> pos, int dimensionId);
  37. void addSpawn(SpawnConfig config);
  38. virtual void onDestroy() override;
  39. };
  40. class BasicBlockType : public BlockType
  41. {
  42. private:
  43. int itemType;
  44. bool transparent;
  45. bool passable;
  46. float hardness;
  47. ItemType* zTool;
  48. float speedModifier;
  49. bool interactable;
  50. std::function<Block*(Framework::Vec3<int>, int)> creatBlockCustom;
  51. protected:
  52. virtual void createSuperBlock(Block* zBlock, Item* zItem) const override;
  53. public:
  54. BasicBlockType(int typeId,
  55. int itemTypeId,
  56. ModelInfo model,
  57. const char* name,
  58. int mapColor);
  59. BasicBlockType(int typeId,
  60. int itemTypeId,
  61. ModelInfo model,
  62. std::function<Block*(Framework::Vec3<int>, int)> creatBlockCustom,
  63. const char* name,
  64. int mapColor);
  65. BasicBlockType(int typeId,
  66. int itemTypeId,
  67. ModelInfo model,
  68. std::function<Block*(Framework::Vec3<int>, int)> creatBlockCustom,
  69. const char* name,
  70. int mapColor,
  71. bool modelSubscription);
  72. virtual Block* createBlock(
  73. Framework::Vec3<int> position, int dimensionId) const override;
  74. virtual Item* createItem() const override;
  75. BasicBlockType* setHardness(float hardness);
  76. BasicBlockType* setTransparent(bool transparent);
  77. };