Block.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #include <Model3D.h>
  3. #include <Either.h>
  4. #include "Inventory.h"
  5. #include "BlockType.h"
  6. #include "Registries.h"
  7. using namespace Framework;
  8. #define CONST_BLOCK(maybeBlock, type) (maybeBlock ? maybeBlock : STATIC_REGISTRY( BlockType ).zElement((int)type)->zDefault())
  9. class BasicBlockItemType;
  10. class Chunk;
  11. class Block : public Model3D, public Inventory
  12. {
  13. protected:
  14. bool transparent;
  15. bool passable;
  16. float hp;
  17. float maxHP;
  18. float hardness;
  19. float speedModifier;
  20. const BlockType* zType;
  21. ItemType* zTool;
  22. bool sideVisible[ 6 ];
  23. public:
  24. Block( const BlockType* zType, ItemType* zTool, Vec3<int> position, bool hasInventory );
  25. virtual ~Block();
  26. bool isTransparent() const;
  27. bool isPassable() const;
  28. void setSideVisible( Direction dir, bool visible );
  29. const BlockType* zBlockType() const;
  30. friend Chunk;
  31. friend BlockType;
  32. };
  33. class BasicBlockItem : public Item
  34. {
  35. protected:
  36. bool transparent;
  37. bool passable;
  38. float hp;
  39. float maxHP;
  40. float hardness;
  41. int toolId;
  42. float speedModifier;
  43. public:
  44. BasicBlockItem( const ItemType* zType, const char* name );
  45. friend BasicBlockItemType;
  46. friend BlockType;
  47. };
  48. class BasicBlockItemType : public ItemType
  49. {
  50. protected:
  51. BasicBlockItemType( int id );
  52. virtual void loadSuperItem( Item* zItem, Framework::StreamReader* zReader ) const override;
  53. };