BlockType.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma once
  2. #include <Vec3.h>
  3. #include <Array.h>
  4. #include <Writer.h>
  5. #include <Either.h>
  6. #include "StaticRegistry.h"
  7. #include "ModelInfo.h"
  8. class Item;
  9. class Block;
  10. class BlockType : public virtual Framework::ReferenceCounter
  11. {
  12. private:
  13. const int id;
  14. const ModelInfo model;
  15. int initialMaxHP;
  16. const bool needsClientInstance;
  17. bool lightSource;
  18. protected:
  19. Block* defaultBlock;
  20. BlockType(int id, Block* defaultBlock, ModelInfo model, bool needsClientInstance, int initialMaxHP, bool lightSource);
  21. virtual ~BlockType();
  22. virtual void loadSuperBlock(Block* zBlock, Framework::StreamReader* zReader) const;
  23. virtual void saveSuperBlock(Block* zBlock, Framework::StreamWriter* zWriter) const;
  24. virtual void createSuperBlock(Block* zBlock, Item* zItem) const;
  25. virtual void createSuperItem(Block* zBlock, Item* zItem) const;
  26. virtual Block* createBlock(Framework::Vec3<int> position) const = 0;
  27. virtual Item* createItem() const = 0;
  28. public:
  29. virtual Block* loadBlock(Framework::Vec3<int> position, Framework::StreamReader* zReader) const;
  30. virtual void saveBlock(Block* zBlock, Framework::StreamWriter* zWriter) const;
  31. virtual Item* getItemFromBlock(Block* zBlock) const;
  32. virtual Block* createBlockAt(Framework::Vec3<int> position, Item* zUsedItem) const;
  33. virtual const Block* zDefault() const;
  34. bool doesNeedClientInstance() const;
  35. const ModelInfo& getModel() const;
  36. int getId() const;
  37. int getInitialMaxHP() const;
  38. bool isLightSource() const;
  39. };
  40. const Block* getDefaultBlock(Framework::Either<Block*, int> b);