BasicBlocks.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. };