blob: 8af5a4b1fe70b50401bbb5ff7fa0d28334e6518f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "Block.hpp"
#include <map>
static std::map<BlockId, BlockInfo> blocks;
static std::map<BlockId, LiquidInfo> liquids;
static BlockInfo UnknownBlock{ true, "", "" };
static LiquidInfo UnknownLiquid{ "", "" };
void RegisterStaticBlockInfo(BlockId blockId, BlockInfo blockInfo) {
blocks.emplace(blockId, blockInfo);
}
void RegisterStaticLiquidInfo(BlockId blockId, LiquidInfo liquidInfo) {
liquids[blockId] = liquidInfo;
for (uint8_t i = 0; i < 16; i++)
blocks.emplace(BlockId{ blockId.id, i }, BlockInfo{ true, "@liquid", liquidInfo.stillTexture });
}
BlockInfo* GetBlockInfo(BlockId blockId) {
auto it = blocks.find(blockId);
return it != blocks.end() ? &it->second : &UnknownBlock;
}
const LiquidInfo& GetBlockLiquidInfo(BlockId blockId) {
auto it = liquids.find(blockId);
return it != liquids.end() ? it->second : UnknownLiquid;
}
|