#include "common/block/Blocks.h" const int BlockRegistry::BLOCK_AMOUNT = 4; const Block* BlockRegistry::BLOCKS[BLOCK_AMOUNT]; const BlockAir Blocks::AIR; const Block Blocks::GRASS; const Block Blocks::DIRT; const Block Blocks::STONE; BlockRegistry::BlockRegistry() { } void BlockRegistry::registerBlock(const Block& block) { BlockId id = block.getId(); if(id >= 0 && id < BLOCK_AMOUNT && BLOCKS[id] == nullptr) { BLOCKS[id] = █ } } const Block& BlockRegistry::getBlockFromId(BlockId id) { return *BLOCKS[(id >= 0 && id < BLOCK_AMOUNT && BLOCKS[id] != nullptr) * id]; } void BlockRegistry::init() { for(int i = 0; i < BLOCK_AMOUNT; i++) { BLOCKS[i] = nullptr; } } void BlockRegistry::registerBlocks() { init(); registerBlock(Blocks::AIR); registerBlock(Blocks::GRASS); registerBlock(Blocks::DIRT); registerBlock(Blocks::STONE); }