Now have a mostly working inventory UI and can pickup items and see them. Next up, being able to use things by clicking on them.
This commit is contained in:
parent
fa6311f10c
commit
b7f49aa719
9 changed files with 84 additions and 28 deletions
|
@ -4,7 +4,6 @@
|
|||
#include <nlohmann/json_fwd.hpp>
|
||||
#include "dinkyecs.hpp"
|
||||
|
||||
|
||||
#define ENROLL_COMPONENT(COMPONENT, ...) \
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(COMPONENT, __VA_ARGS__); \
|
||||
template <> struct NameOf<COMPONENT> { \
|
||||
|
@ -25,6 +24,18 @@ namespace components {
|
|||
return result;
|
||||
}
|
||||
|
||||
template<typename COMPONENT> COMPONENT get(nlohmann::json &data) {
|
||||
for (auto &i : data["components"]) {
|
||||
if(i["_type"] == NameOf<COMPONENT>::name) {
|
||||
COMPONENT result;
|
||||
from_json(i, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
template <typename COMPONENT> void enroll(ComponentMap &m) {
|
||||
m[NameOf<COMPONENT>::name] = [](DinkyECS::World& world, DinkyECS::Entity ent, nlohmann::json &j) {
|
||||
COMPONENT c;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue