Block.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include <Model3D.h>
  3. #include "Inventory.h"
  4. #include "Chunk.h"
  5. #include "BlockType.h"
  6. using namespace Framework;
  7. class BasicBlockItemType;
  8. #define AIR_BLOCK -1
  9. #define IS_BLOCK(b) (((__int64)b) > 0)
  10. class Block : public Model3D, public Inventory
  11. {
  12. private:
  13. bool visible;
  14. bool transparent;
  15. bool passable;
  16. float hp;
  17. float maxHP;
  18. float hardness;
  19. float speedModifier;
  20. ItemType *zTool;
  21. Block *zNeighbours[ 6 ];
  22. public:
  23. Block( ItemType *zTool, Vec3<int> position );
  24. virtual ~Block();
  25. bool updateVisibility();
  26. virtual void setNeighbour( Direction dir, Block *zN );
  27. bool isVisible() const;
  28. friend Chunk;
  29. friend BlockType;
  30. };
  31. class BasicBlockItem : public Item
  32. {
  33. protected:
  34. bool transparent;
  35. bool passable;
  36. float hp;
  37. float maxHP;
  38. float hardness;
  39. int toolId;
  40. float speedModifier;
  41. public:
  42. BasicBlockItem( const ItemType *zType, const char *name );
  43. friend BasicBlockItemType;
  44. friend BlockType;
  45. };
  46. class BasicBlockItemType : public ItemType
  47. {
  48. protected:
  49. BasicBlockItemType( int id );
  50. virtual void loadSuperItem( Item *zItem, Framework::StreamReader *zReader ) const override;
  51. };