diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2019-09-02 18:23:09 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2019-09-02 18:23:09 -0400 |
commit | 6614ea639414caab546091841bf920fe6459cc9e (patch) | |
tree | 408df7aeb419ed6e096512d371f499ac6732cade /lib | |
parent | 0466537f81106f679c0b291be26861862c43c13c (diff) |
json entity saving: cout
Diffstat (limited to 'lib')
-rw-r--r-- | lib/entityx/entityx/Entity.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/entityx/entityx/Entity.h b/lib/entityx/entityx/Entity.h index 11bacfa..193d581 100644 --- a/lib/entityx/entityx/Entity.h +++ b/lib/entityx/entityx/Entity.h @@ -34,8 +34,6 @@ #include "entityx/Event.h" #include "entityx/help/NonCopyable.h" -class Archive; - namespace entityx { typedef std::uint32_t uint32_t; @@ -244,8 +242,7 @@ struct BaseComponent { void operator delete([[maybe_unused]] void *p) { fail(); } void operator delete[]([[maybe_unused]] void *p) { fail(); } - virtual void save([[maybe_unused]] Archive& ar) {} - virtual void load([[maybe_unused]] Archive& ar) {} + virtual void internal_serialize(bool save, void *ar) = 0; protected: static void fail() { @@ -753,13 +750,16 @@ class EntityManager : entityx::help::NonCopyable { * EDIT by tcsullivan * Iterates through all components of a given Entity. */ - void entity_each_component(Entity entity, std::function<void(BaseComponent*)> f) + template<class Archive> + void entity_serialize(Entity entity, bool save, Archive& ar) { - auto mask = entity.component_mask(); + auto mask = component_mask(entity.id()); for (size_t i = 0; i < component_helpers_.size(); i++) { BaseComponentHelper *helper = component_helpers_[i]; - if (helper && mask.test(i)) - f(helper->get_component(entity)); + if (helper && mask.test(i)) { + helper->get_component(entity)->internal_serialize(save, + static_cast<void*>(&ar)); + } } } |