Block.h 1.7 KB

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