BlockType.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 WHEAT_SEED = 24;
  38. static const int WHEAT = 25;
  39. static const int MAX_VALUE = 25;
  40. };
  41. class BlockType : public virtual Framework::ReferenceCounter
  42. {
  43. private:
  44. const int id;
  45. const ModelInfo model;
  46. int initialMaxHP;
  47. const bool needsClientInstance;
  48. bool lightSource;
  49. const char* name;
  50. protected:
  51. Block* defaultBlock;
  52. BlockType(int id,
  53. Block* defaultBlock,
  54. ModelInfo model,
  55. bool needsClientInstance,
  56. int initialMaxHP,
  57. bool lightSource, const char *name);
  58. virtual ~BlockType();
  59. virtual void loadSuperBlock(
  60. Block* zBlock, Framework::StreamReader* zReader, int dimensionId) const;
  61. virtual void saveSuperBlock(
  62. Block* zBlock, Framework::StreamWriter* zWriter) const;
  63. virtual void createSuperBlock(Block* zBlock, Item* zItem) const;
  64. virtual void createSuperItem(Block* zBlock, Item* zItem) const;
  65. virtual Block* createBlock(Framework::Vec3<int> position) const = 0;
  66. virtual Item* createItem() const = 0;
  67. public:
  68. virtual Framework::Text getTargetUIML() const;
  69. virtual Block* loadBlock(Framework::Vec3<int> position,
  70. Framework::StreamReader* zReader,
  71. int dimensionId) const;
  72. virtual void saveBlock(
  73. Block* zBlock, Framework::StreamWriter* zWriter) const;
  74. virtual Item* getItemFromBlock(Block* zBlock) const;
  75. virtual Block* createBlockAt(
  76. Framework::Vec3<int> position, Item* zUsedItem) const;
  77. virtual const Block* zDefault() const;
  78. bool doesNeedClientInstance() const;
  79. const ModelInfo& getModel() const;
  80. int getId() const;
  81. int getInitialMaxHP() const;
  82. bool isLightSource() const;
  83. BlockType* initializeDefault();
  84. const char* getName() const;
  85. };
  86. const Block* getDefaultBlock(Framework::Either<Block*, int> b);