37 lines
899 B
C++
37 lines
899 B
C++
#ifndef ITEM_DB_HPP
|
|
#define ITEM_DB_HPP
|
|
|
|
#include "item.hpp"
|
|
#include <godot_cpp/templates/vector.hpp>
|
|
|
|
namespace gd = godot;
|
|
|
|
class ItemDB {
|
|
struct StaticData {
|
|
StaticData() = default;
|
|
~StaticData();
|
|
gd::String &get_hint();
|
|
gd::String &get_array_hint();
|
|
gd::String *array_hint{};
|
|
gd::String *hint{};
|
|
gd::Vector<Item *> items{};
|
|
};
|
|
static ItemID register_item(Item *item, gd::String item_name);
|
|
|
|
public:
|
|
static Item const *get_item(ItemID id);
|
|
static gd::String const &get_enum_hint();
|
|
static gd::String const &get_array_hint();
|
|
static Item const *get_item_by_name(gd::StringName item);
|
|
|
|
template <class TItem>
|
|
_FORCE_INLINE_ static ItemID register_item() {
|
|
return ItemDB::register_item(new TItem(), TItem::get_static_class());
|
|
}
|
|
|
|
private:
|
|
static StaticData data;
|
|
};
|
|
|
|
#endif // !ITEM_DB_HPP
|