Lodestone.Level
Loading...
Searching...
No Matches
ItemRegistry.h
Go to the documentation of this file.
1//
2// Created by DexrnZacAttack on 10/14/25 using zPc-i2.
3//
4#ifndef LODESTONE_ITEMREGISTRY_H
5#define LODESTONE_ITEMREGISTRY_H
7
8#include <unordered_map>
9
11
14#include <gtl/phmap.hpp>
15
16namespace lodestone::level::item {
18 protected:
19 ItemRegistry() = default;
20
21 public:
22#define REGISTER_ITEM(n, d) {n, new Item(n, d)}
23
24 static const Item *sDefaultItem;
25
26 static ItemRegistry &getInstance();
27
29 const Item *item);
30
31 // couldn't come up with a better name
34 const Item *item) noexcept;
35
36 const Item *
38
39 const Item *
41
43 const Item *>::iterator
45 return m_items.begin();
46 }
47
49 const Item *>::iterator
50 end() {
51 return m_items.end();
52 }
53
55 private:
58 };
59} // namespace lodestone::level::item
60
61#endif // LODESTONE_ITEMREGISTRY_H
#define LODESTONE_API
gtl::flat_hash_map< T... > map_t
#define REGISTER_ITEM(n, d)
Definition ItemRegistry.h:22
map_t< constlodestone::common::registry::Identifier *, constItem * >::iterator end()
Definition ItemRegistry.h:50
bool registerItemIfNonExistent(const lodestone::common::registry::Identifier *id, const Item *item) noexcept
Definition ItemRegistry.cpp:32
const Item * getItem(const lodestone::common::registry::Identifier *id) const
Definition ItemRegistry.cpp:46
static ItemRegistry & getInstance()
Definition ItemRegistry.cpp:15
common::event::Event< const lodestone::common::registry::Identifier *, const Item * > itemRegisteredEvent
Definition ItemRegistry.h:54
map_t< constlodestone::common::registry::Identifier *, constItem * >::iterator begin()
Definition ItemRegistry.h:44
map_t< const lodestone::common::registry::Identifier *, const Item * > m_items
Definition ItemRegistry.h:57
static const Item * sDefaultItem
Definition ItemRegistry.h:24
const Item * operator[](const lodestone::common::registry::Identifier *id) const
Definition ItemRegistry.cpp:54
void registerItem(const lodestone::common::registry::Identifier *id, const Item *item)
Definition ItemRegistry.cpp:20
Definition Item.h:21
Definition BlockItem.cpp:6
static constexpr const lodestone::common::registry::Identifier NONE
Definition Items.h:17