World copying with facts and constants is working so now new levels are possible, but need to work on previous level motion.
This commit is contained in:
parent
2735a0ac1f
commit
82216b8307
6 changed files with 52 additions and 32 deletions
24
dinkyecs.hpp
24
dinkyecs.hpp
|
@ -14,7 +14,7 @@ namespace DinkyECS {
|
|||
|
||||
typedef unsigned long Entity;
|
||||
|
||||
typedef std::unordered_map<Entity, std::any> EntityMap;
|
||||
using EntityMap = std::unordered_map<Entity, std::any>;
|
||||
|
||||
struct Event {
|
||||
int event = 0;
|
||||
|
@ -29,20 +29,30 @@ namespace DinkyECS {
|
|||
std::unordered_map<std::type_index, EntityMap> $components;
|
||||
std::unordered_map<std::type_index, std::any> $facts;
|
||||
std::unordered_map<std::type_index, EventQueue> $events;
|
||||
std::vector<Entity> constants;
|
||||
std::vector<Entity> $constants;
|
||||
|
||||
Entity entity() {
|
||||
return ++entity_count;
|
||||
}
|
||||
/*
|
||||
void clone_into(DinkyECS::World &from_world, DinkyECS::World &to_world) {
|
||||
|
||||
void clone_into(DinkyECS::World &to_world) {
|
||||
to_world.$constants = $constants;
|
||||
to_world.$facts = $facts;
|
||||
to_world.entity_count = entity_count;
|
||||
|
||||
for(auto eid : $constants) {
|
||||
for(const auto &[tid, eid_map] : $components) {
|
||||
auto& their_map = to_world.$components[tid];
|
||||
if(eid_map.contains(eid)) {
|
||||
their_map.insert_or_assign(eid, eid_map.at(eid));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void update_constants(DinkyECS::World &from_world, DinkyECS::World &to_world) {
|
||||
|
||||
void make_constant(DinkyECS::Entity entity) {
|
||||
$constants.push_back(entity);
|
||||
}
|
||||
*/
|
||||
|
||||
template <typename Comp>
|
||||
EntityMap& entity_map_for() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue