#pragma once #include #include #include #include #include "ModelInfo.h" #include "StaticRegistry.h" class Item; class Block; class BlockTypeEnum { public: static const int NO_BLOCK = 0; static const int AIR = 1; static const int DIRT = 2; static const int SAND = 3; static const int GRAVEL = 4; static const int STONE = 5; static const int STONE_GRANITE = 6; static const int STONE_COBBLE = 7; static const int STONE_BASALT = 8; static const int WOOD_OAK = 9; static const int WOOD_BIRCH = 10; static const int WOOD_BEECH = 11; static const int WOOD_PINE = 12; static const int LEAVES_WOOD_OAK = 13; static const int LEAVES_WOOD_BIRCH = 14; static const int LEAVES_WOOD_BEECH = 15; static const int LEAVES_WOOD_PINE = 16; static const int SEBLING_WOOD_OAK = 17; static const int SEBLING_WOOD_BIRCH = 18; static const int SEBLING_WOOD_BEECH = 19; static const int SEBLING_WOOD_PINE = 20; static const int TORCH = 21; static const int GRASS = 22; static const int FARMLAND = 23; static const int WHEAT_SEED = 24; static const int WHEAT = 25; static const int WATER = 26; static const int CRAFTING_TABLE = 27; static const int CHEST = 28; static const int MAX_VALUE = 100000; // leve enough space for other blocks }; class BlockType : public virtual Framework::ReferenceCounter { private: const int id; const ModelInfo model; int initialMaxHP; const bool needsClientInstance; bool lightSource; const char* name; const bool needModelSubscription; protected: int initialMapColor; Block* defaultBlock; BlockType(int id, Block* defaultBlock, ModelInfo model, bool needsClientInstance, int initialMaxHP, bool lightSource, const char* name, bool needModelSubscription, int initialMapColor); virtual ~BlockType(); virtual void loadSuperBlock( Block* zBlock, Framework::StreamReader* zReader, int dimensionId) const; virtual void saveSuperBlock( Block* zBlock, Framework::StreamWriter* zWriter) const; virtual void createSuperBlock(Block* zBlock, Item* zItem) const; virtual void createSuperItem(Block* zBlock, Item* zItem) const; virtual Block* createBlock(Framework::Vec3 position, int dimensionId) const = 0; virtual Item* createItem() const = 0; public: virtual Framework::Text getTargetUIML() const; virtual Block* loadBlock(Framework::Vec3 position, Framework::StreamReader* zReader, int dimensionId) const; virtual void saveBlock( Block* zBlock, Framework::StreamWriter* zWriter) const; virtual Item* getItemFromBlock(Block* zBlock) const; virtual Block* createBlockAt( Framework::Vec3 position, int dimensionId, Item* zUsedItem) const; virtual const Block* zDefault() const; bool doesNeedClientInstance() const; const ModelInfo& getModel() const; int getId() const; int getInitialMaxHP() const; bool isLightSource() const; BlockType* initializeDefault(); const char* getName() const; const bool doesNeedModelSubscription() const; void writeTypeInfo(Framework::StreamWriter* zWriter) const; static int getTypeId(const char* name); }; const Block* getDefaultBlock(Framework::Either b);