blob: 70ad75b6d4722bf7f92bc3c8b3518517237eda9c (
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.try_emplace(blockId, blockInfo);
}
void RegisterStaticLiquidInfo(BlockId blockId, const LiquidInfo& liquidInfo) {
liquids[blockId] = liquidInfo;
for (uint8_t i = 0; i < 16; i++)
blocks.try_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;
}
|