Game now builds and is using the new dynamic component loading but enemies do not spawn in and device events are really working. Also inventory is a giant bag of fail and needs a rewrite.

This commit is contained in:
Zed A. Shaw 2025-02-08 21:16:25 -05:00
parent 9e91c71125
commit a69be90464
23 changed files with 130 additions and 122 deletions

View file

@ -7,14 +7,9 @@
#include <any>
#include <tuple>
#include <queue>
#include <functional>
#include <nlohmann/json.hpp>
#include <nlohmann/json_fwd.hpp>
#include "dbc.hpp"
namespace DinkyECS {
using namespace nlohmann;
typedef unsigned long Entity;
using EntityMap = std::unordered_map<Entity, std::any>;
@ -158,26 +153,4 @@ namespace DinkyECS {
return !queue.empty();
}
};
template <typename T> struct NameOf;
using ReflFuncSignature = std::function<void(World& world, Entity ent, nlohmann::json &j)>;
using ComponentMap = std::unordered_map<std::string, ReflFuncSignature>;
#define DINKY_HAS_COMPONENT(COMPONENT, ...) \
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(COMPONENT, __VA_ARGS__); \
template <> struct DinkyECS::NameOf<COMPONENT> { \
static constexpr const char *name = #COMPONENT; \
};
template <typename COMPONENT> void Component(ComponentMap &m) {
m[NameOf<COMPONENT>::name] = [](DinkyECS::World& world, DinkyECS::Entity ent, nlohmann::json &j) {
COMPONENT c;
from_json(j, c);
world.set<COMPONENT>(ent, c);
};
}
void configure(const ComponentMap& component_map, World& world, Entity ent, json& data);
}