BasicBlocks.h 1.6 KB

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