Block.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. public:
  23. Block( const BlockType* zType, ItemType* zTool, Vec3<int> position, bool hasInventory );
  24. virtual ~Block();
  25. bool isTransparent() const;
  26. const BlockType* zBlockType() const;
  27. friend Chunk;
  28. friend BlockType;
  29. };
  30. class BasicBlockItem : public Item
  31. {
  32. protected:
  33. bool transparent;
  34. bool passable;
  35. float hp;
  36. float maxHP;
  37. float hardness;
  38. int toolId;
  39. float speedModifier;
  40. public:
  41. BasicBlockItem( const ItemType* zType, const char* name );
  42. friend BasicBlockItemType;
  43. friend BlockType;
  44. };
  45. class BasicBlockItemType : public ItemType
  46. {
  47. protected:
  48. BasicBlockItemType( int id );
  49. virtual void loadSuperItem( Item* zItem, Framework::StreamReader* zReader ) const override;
  50. };