BlockType.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #pragma once
  2. #include <Array.h>
  3. #include <Either.h>
  4. #include <Vec3.h>
  5. #include <Writer.h>
  6. #include "ModelInfo.h"
  7. #include "StaticRegistry.h"
  8. class Item;
  9. class Block;
  10. class BlockTypeEnum
  11. {
  12. public:
  13. static const int NO_BLOCK = 0;
  14. static const int AIR = 1;
  15. static const int DIRT = 2;
  16. static const int SAND = 3;
  17. static const int GRAVEL = 4;
  18. static const int STONE = 5;
  19. static const int STONE_GRANITE = 6;
  20. static const int STONE_COBBLE = 7;
  21. static const int STONE_BASALT = 8;
  22. static const int WOOD_OAK = 9;
  23. static const int WOOD_BIRCH = 10;
  24. static const int WOOD_BEECH = 11;
  25. static const int WOOD_PINE = 12;
  26. static const int LEAVES_WOOD_OAK = 13;
  27. static const int LEAVES_WOOD_BIRCH = 14;
  28. static const int LEAVES_WOOD_BEECH = 15;
  29. static const int LEAVES_WOOD_PINE = 16;
  30. static const int SEBLING_WOOD_OAK = 17;
  31. static const int SEBLING_WOOD_BIRCH = 18;
  32. static const int SEBLING_WOOD_BEECH = 19;
  33. static const int SEBLING_WOOD_PINE = 20;
  34. static const int TORCH = 21;
  35. static const int GRASS = 22;
  36. static const int FARMLAND = 23;
  37. static const int MAX_VALUE = 23;
  38. };
  39. class BlockType : public virtual Framework::ReferenceCounter
  40. {
  41. private:
  42. const int id;
  43. const ModelInfo model;
  44. int initialMaxHP;
  45. const bool needsClientInstance;
  46. bool lightSource;
  47. const char* name;
  48. protected:
  49. Block* defaultBlock;
  50. BlockType(int id,
  51. Block* defaultBlock,
  52. ModelInfo model,
  53. bool needsClientInstance,
  54. int initialMaxHP,
  55. bool lightSource, const char *name);
  56. virtual ~BlockType();
  57. virtual void loadSuperBlock(
  58. Block* zBlock, Framework::StreamReader* zReader, int dimensionId) const;
  59. virtual void saveSuperBlock(
  60. Block* zBlock, Framework::StreamWriter* zWriter) const;
  61. virtual void createSuperBlock(Block* zBlock, Item* zItem) const;
  62. virtual void createSuperItem(Block* zBlock, Item* zItem) const;
  63. virtual Block* createBlock(Framework::Vec3<int> position) const = 0;
  64. virtual Item* createItem() const = 0;
  65. public:
  66. virtual Framework::Text getTargetUIML() const;
  67. virtual Block* loadBlock(Framework::Vec3<int> position,
  68. Framework::StreamReader* zReader,
  69. int dimensionId) const;
  70. virtual void saveBlock(
  71. Block* zBlock, Framework::StreamWriter* zWriter) const;
  72. virtual Item* getItemFromBlock(Block* zBlock) const;
  73. virtual Block* createBlockAt(
  74. Framework::Vec3<int> position, Item* zUsedItem) const;
  75. virtual const Block* zDefault() const;
  76. bool doesNeedClientInstance() const;
  77. const ModelInfo& getModel() const;
  78. int getId() const;
  79. int getInitialMaxHP() const;
  80. bool isLightSource() const;
  81. BlockType* initializeDefault();
  82. const char* getName() const;
  83. };
  84. const Block* getDefaultBlock(Framework::Either<Block*, int> b);