Lodestone.Level
Loading...
Searching...
No Matches
BlockRegistry.h
Go to the documentation of this file.
1//
2// Created by DexrnZacAttack on 10/14/25 using zPc-i2.
3//
4#ifndef LODESTONE_BLOCKREGISTRY_H
5#define LODESTONE_BLOCKREGISTRY_H
7
8#include <unordered_map>
9
11
14#include <gtl/phmap.hpp>
15
18 protected:
20
21 public:
22#define REGISTER_BLOCK(n, m, d) {n, new lodestone::level::block::Block(n, m, d)}
23#define REGISTER_DERIVED_BLOCK(n, m, d, f) {n, new f(n, m, d)}
24#define REGISTER_BLOCK_FUNC(n, m, d) registerBlock(n, new lodestone::level::block::Block(n, m, d))
25#define REGISTER_DERIVED_BLOCK_FUNC(n, m, d, f) registerBlock(n, new f(n, m, d))
26
27 static const Block *s_defaultBlock;
28
29 static BlockRegistry &getInstance();
30
32 const Block *block);
33
34 // couldn't come up with a better name
37 const Block *block) noexcept;
38
39 const Block *
41
42 const Block *
44
46 const Block *>::iterator
48 return m_blocks.begin();
49 }
50
52 const Block *>::iterator
53 end() {
54 return m_blocks.end();
55 }
56
58 private:
61 };
62} // namespace lodestone::level::block
63
64#endif // LODESTONE_BLOCKREGISTRY_H
#define LODESTONE_API
gtl::flat_hash_map< T... > map_t
const Block * operator[](const lodestone::common::registry::Identifier *id) const
Definition BlockRegistry.cpp:62
static BlockRegistry & getInstance()
Definition BlockRegistry.cpp:22
static const Block * s_defaultBlock
Definition BlockRegistry.h:27
map_t< constlodestone::common::registry::Identifier *, constBlock * >::iterator end()
Definition BlockRegistry.h:53
common::event::Event< const lodestone::common::registry::Identifier *, const Block * > blockRegisteredEvent
Definition BlockRegistry.h:57
map_t< const lodestone::common::registry::Identifier *, const Block * > m_blocks
Definition BlockRegistry.h:60
bool registerBlockIfNonExistent(const lodestone::common::registry::Identifier *id, const Block *block) noexcept
Definition BlockRegistry.cpp:40
map_t< constlodestone::common::registry::Identifier *, constBlock * >::iterator begin()
Definition BlockRegistry.h:47
BlockRegistry()
Definition BlockRegistry.cpp:18
const Block * getBlock(const lodestone::common::registry::Identifier *id) const
Definition BlockRegistry.cpp:54
void registerBlock(const lodestone::common::registry::Identifier *id, const Block *block)
Definition BlockRegistry.cpp:27
Definition Block.h:18
Definition Block.cpp:6