BasicBlocks.h 2.0 KB

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