BasicBlocks.h 1.4 KB

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